Commit e3c7c837 authored by liudong1993's avatar liudong1993

1探马客户

parent 0a02ab0b
using Edu.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Enum.WeChat
{
/// <summary>
/// 企业微信客户添加方式枚举
/// </summary>
public enum CustomerAddWayEnum
{
/// <summary>
/// 好友创建
/// </summary>
[EnumField("好友创建")]
Friend = 1,
/// <summary>
/// 转移添加
/// </summary>
[EnumField("转移添加")]
Transfer = 2,
/// <summary>
/// 个人创建
/// </summary>
[EnumField("个人创建")]
Person = 3,
/// <summary>
/// 公司分配
/// </summary>
[EnumField("公司分配")]
Company = 4,
/// <summary>
/// 公海领取
/// </summary>
[EnumField("公海领取")]
Public = 5,
}
}
using Edu.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Enum.WeChat
{
/// <summary>
/// 企业微信旅程类型枚举
/// </summary>
public enum CustomerTripTypeEnum
{
/// <summary>
/// 行为动态
/// </summary>
[EnumField("行为动态")]
Behavior = 1,
/// <summary>
/// 操作动态
/// </summary>
[EnumField("操作动态")]
Operate = 2,
/// <summary>
/// 跟进记录
/// </summary>
[EnumField("跟进记录")]
FollowUp = 3,
/// <summary>
/// 签到记录
/// </summary>
[EnumField("签到记录")]
Check = 4,
/// <summary>
/// 聊天
/// </summary>
[EnumField("聊天")]
Chat = 5,
/// <summary>
/// 短信
/// </summary>
[EnumField("短信")]
Message = 6,
/// <summary>
/// 通话
/// </summary>
[EnumField("通话")]
Tell = 7,
/// <summary>
/// 流转记录
/// </summary>
[EnumField("流转记录")]
Record = 8
}
}
using Edu.Common.Enum;
using Edu.Common.Enum.Course;
using Edu.Common.Enum.WeChat;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.WeChat
{
/// <summary>
/// 企业微信客户信息实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_WeChat_CustomerInfo
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 员工id
/// </summary>
public int EmpId { get; set; }
/// <summary>
/// 员工企业微信Id
/// </summary>
public string WorkEmpId { get; set; }
/// <summary>
/// 员工企业微信名称
/// </summary>
public string WorkEmpName { get; set; }
/// <summary>
/// 客户企业微信Id
/// </summary>
public string ExternalUserId { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 该成员对此客人的备注
/// </summary>
public string CustomerName { get; set; }
/// <summary>
/// 微信名称
/// </summary>
public string WeChatName { get; set; }
/// <summary>
/// 微信头像
/// </summary>
public string WeChatPhoto { get; set; }
/// <summary>
/// 外部联系人所在企业的简称(企业微信用户)
/// </summary>
public string CorpName { get; set; }
/// <summary>
/// 外部联系人所在企业的主体名称(企业微信用户)
/// </summary>
public string CorpFullName { get; set; }
/// <summary>
/// 类型,1微信用户,2企业微信用户
/// </summary>
public int CustomerType { get; set; }
/// <summary>
/// 阶段id
/// </summary>
public int StageId { get; set; }
/// <summary>
/// 企业标签ids
/// </summary>
public string LableIds { get; set; }
/// <summary>
/// 员工设置个人标签
/// </summary>
public string PersonLable { get; set; }
/// <summary>
/// 活码来源
/// </summary>
public string Source { get; set; }
/// <summary>
/// 自定义客户字段内容 json格式 需根据客户字段来查找
/// </summary>
public string CustomContent { get; set; }
/// <summary>
/// 好友状态 1好友客户 2待添加 3已申请
/// </summary>
public int FriendState { get; set; }
/// <summary>
/// 好友添加的时间
/// </summary>
public DateTime? FriendTime { get; set; }
/// <summary>
/// 上次跟进日期
/// </summary>
public DateTime? LastFollowUpTime { get; set; }
/// <summary>
/// 签到拜访数量
/// </summary>
public int CheckInNum { get; set; }
/// <summary>
/// 是否公海客户 1是 2否
/// </summary>
public int IsPublic { get; set; }
/// <summary>
/// 客户手机号码 多个英文逗号分隔
/// </summary>
public string CustomerMobile { get; set; }
/// <summary>
/// 添加方式枚举
/// </summary>
public CustomerAddWayEnum AddWay { get; set; }
/// <summary>
/// 系统备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 微信客户来源
/// </summary>
public int WeChatAddWay { get; set; }
}
}
using Edu.Common.Enum;
using Edu.Common.Enum.Course;
using Edu.Common.Enum.WeChat;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.WeChat
{
/// <summary>
/// 企业微信客户记录实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_WeChat_CustomerTrip
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 类型 枚举
/// </summary>
public CustomerTripTypeEnum Type { get; set; }
/// <summary>
/// 客户id
/// </summary>
public int CustomerId { get; set; }
/// <summary>
/// 员工id
/// </summary>
public int EmpId { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 图片地址 List<string>
/// </summary>
public string Images { get; set; }
/// <summary>
/// 附件 文件名称 地址 大小 json格式
/// </summary>
public string Files { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 集团编号
/// </summary>
public int Group_Id { get; set; }
/// <summary>
/// 创建人
/// </summary>
public int CreateBy { get; set; }
/// <summary>
/// 创建日期
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
public int UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
}
}
...@@ -20,6 +20,11 @@ namespace Edu.Model.ViewModel.WeChat ...@@ -20,6 +20,11 @@ namespace Edu.Model.ViewModel.WeChat
/// 部门名称 /// 部门名称
/// </summary> /// </summary>
public string DeptName { get; set; } public string DeptName { get; set; }
/// <summary>
/// 当前客户对应字段的值
/// </summary>
public string Value { get; set; }
} }
/// <summary> /// <summary>
......
using System;
using System.Collections.Generic;
using System.Text;
using Edu.Common.Enum.Sale;
using Edu.Model.Entity.WeChat;
namespace Edu.Model.ViewModel.WeChat
{
/// <summary>
/// 企业微信客户信息扩展类
/// </summary>
public class RB_WeChat_CustomerInfo_ViewModel : RB_WeChat_CustomerInfo
{
/// <summary>
/// 查询自定义参数
/// </summary>
public List<CustomerInfoSelectModel> SelectList { get; set; }
/// <summary>
/// 查询条件 1并且 2或者
/// </summary>
public int AddCondition { get; set; }
/// <summary>
/// 企业标签列表
/// </summary>
public List<RB_WeChat_Lable_ViewModel> LableList { get; set; }
/// <summary>
/// 自定义字段值
/// </summary>
public List<CustomFiledContentExtend> CustomFiledList { get; set; }
/// <summary>
/// 字段明细列表(包含下拉选项s)
/// </summary>
public List<RB_WeChat_CustomerField_ViewModel> FiledDetailList { get; set; }
/// <summary>
/// 客户阶段名称
/// </summary>
public string StageName { get; set; }
/// <summary>
/// 内部员工名称
/// </summary>
public string EmpName { get; set; }
/// <summary>
/// 未跟进天数
/// </summary>
public int Q_NotFollowUpDay { get; set; }
/// <summary>
/// 排序 1创建时间升序 2创建时间降序 3跟进时间升序 4跟进时间降序
/// </summary>
public int OrderBy { get; set; }
/// <summary>
/// 好友关系
/// </summary>
public string Q_Friends { get; set; }
/// <summary>
/// 获取途径
/// </summary>
public string Q_AddWay { get; set; }
/// <summary>
/// 创建开始时间
/// </summary>
public string CreateSTime { get; set; }
/// <summary>
/// 创建结束时间
/// </summary>
public string CreateETime { get; set; }
/// <summary>
/// 好友开始时间
/// </summary>
public string FriendSTime { get; set; }
/// <summary>
/// 好友结束时间
/// </summary>
public string FriendETime { get; set; }
}
/// <summary>
/// 扩展字段查询Model
/// </summary>
public class CustomerInfoSelectModel {
/// <summary>
/// 字段名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 类型 1包含 2等于 3日期 4日期范围 5数值
/// </summary>
public int Type { get; set; }
/// <summary>
/// 方向 1包含所有/等于/等于 2包含任意/不等于/大于 3不包含/为空/大于等于 4为空/不为空/小于 5不为空/模糊/小于等于 对应 type的1/2/5
/// </summary>
public int Direction { get; set; }
/// <summary>
/// 开始值
/// </summary>
public string StartValue { get; set; }
/// <summary>
/// 结束值
/// </summary>
public string EndValue { get; set; }
/// <summary>
/// 是否自定义字段 1是 2否
/// </summary>
public int IsCustom { get; set; }
}
/// <summary>
/// 客户信息自定义字段存值
/// </summary>
public class CustomerFiledContentModel {
/// <summary>
/// 字段ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 字段值 多选的:英文逗号分隔
/// </summary>
public string Value { get; set; }
}
/// <summary>
/// 自定义字段返回扩展
/// </summary>
public class CustomFiledContentExtend : CustomerFiledContentModel
{
/// <summary>
/// 字段名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 显示值
/// </summary>
public string ShowValue { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Edu.Common.Enum.Sale;
using Edu.Model.Entity.WeChat;
using Edu.Model.Public;
namespace Edu.Model.ViewModel.WeChat
{
/// <summary>
/// 企业微信客户旅途记录扩展类
/// </summary>
public class RB_WeChat_CustomerTrip_ViewModel : RB_WeChat_CustomerTrip
{
/// <summary>
/// 文件列表
/// </summary>
public List<FileModel> FileList { get; set; }
/// <summary>
/// 图片列表
/// </summary>
public List<string> ImageList { get; set; }
/// <summary>
/// 员工名称
/// </summary>
public string UpdateByName { get; set; }
}
}
This diff is collapsed.
This diff is collapsed.
...@@ -32,6 +32,10 @@ namespace Edu.Repository.WeChat ...@@ -32,6 +32,10 @@ namespace Edu.Repository.WeChat
{ {
where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Type)} ={demodel.Type}"; where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Type)} ={demodel.Type}";
} }
if (demodel.Id > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Id)} ={demodel.Id}";
}
if (!string.IsNullOrEmpty(demodel.StageIds)) if (!string.IsNullOrEmpty(demodel.StageIds))
{ {
where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Id)} in({demodel.StageIds})"; where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Id)} in({demodel.StageIds})";
......
using Edu.Common.Enum;
using Edu.Model.Entity.WeChat;
using Edu.Model.ViewModel.WeChat;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB;
using VT.FW.DB.Dapper;
namespace Edu.Repository.WeChat
{
/// <summary>
/// 企业微信客户旅程仓储层
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_WeChat_CustomerTripRepository : BaseRepository<RB_WeChat_CustomerTrip>
{
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_WeChat_CustomerTrip_ViewModel> GetPageList(int pageIndex,int pageSize,out long count, RB_WeChat_CustomerTrip_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.{nameof(RB_WeChat_CustomerTrip_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerTrip_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.Type > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerTrip_ViewModel.Type)} ={(int)demodel.Type}";
}
if (demodel.CustomerId > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerTrip_ViewModel.CustomerId)} ={demodel.CustomerId}";
}
string sql = $@"
SELECT * From RB_WeChat_CustomerTrip r
WHERE {where}
ORDER BY r.Id DESC ";
return GetPage<RB_WeChat_CustomerTrip_ViewModel>(pageIndex, pageSize, out count, sql, parameters).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_WeChat_CustomerTrip_ViewModel> GetList(RB_WeChat_CustomerTrip_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.{nameof(RB_WeChat_CustomerTrip_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerTrip_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.Type > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerTrip_ViewModel.Type)} ={(int)demodel.Type}";
}
if (demodel.CustomerId > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerTrip_ViewModel.CustomerId)} ={demodel.CustomerId}";
}
string sql = $@"
SELECT * From RB_WeChat_CustomerTrip r
WHERE {where}
ORDER BY r.Id DESC ";
return Get<RB_WeChat_CustomerTrip_ViewModel>(sql, parameters).ToList();
}
/// <summary>
/// 获取最后一次跟进时间
/// </summary>
/// <param name="group_Id"></param>
/// <param name="customerIds"></param>
/// <returns></returns>
public List<RB_WeChat_CustomerTrip_ViewModel> GetLastFollowUpTimeList(int group_Id, string customerIds)
{
string sql = $@"SELECT CustomerId , MAX(CreateTime) AS CreateTime FROM rb_wechat_customertrip
WHERE `Status` =0 and Group_Id ={group_Id} and Type =3 and CustomerId in ({customerIds}) GROUP BY CustomerId";
return Get<RB_WeChat_CustomerTrip_ViewModel>(sql).ToList();
}
}
}

using Senparc.Weixin.Entities;
using Senparc.Weixin.Work.AdvancedAPIs.External;
using System.Collections.Generic;
namespace Edu.ThirdCore.QYWinXin.Model
{
/// <summary>
/// 批量获取客户详情 返回结果
/// </summary>
public class GetExternalContactInfoBatchResult_V2 : WorkJsonResult
{
/// <summary>
/// 客户列表
/// </summary>
public List<ExternalContactList> external_contact_list { get; set; }
/// <summary>
/// 分页游标,再下次请求时填写以获取之后分页的记录,如果已经没有更多的数据则返回空
/// </summary>
public string next_cursor { get; set; }
}
public class ExternalContactList
{
/// <summary>
/// 客户信息
/// </summary>
public External_Contact external_contact { get; set; }
/// <summary>
/// 员工信息
/// </summary>
public Follow_User_V2 follow_info { get; set; }
}
public class Follow_User_V2
{
//
// 摘要:
// 添加了此外部联系人的企业成员userid
public string userid { get; set; }
//
// 摘要:
// 该成员对此外部联系人的备注
public string remark { get; set; }
//
// 摘要:
// 该成员对此外部联系人的描述
public string description { get; set; }
//
// 摘要:
// 该成员添加此外部联系人的时间
public int createtime { get; set; }
//
// 摘要:
// 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加,由企业通过创建「联系我」方式指定
public string state { get; set; }
//
// 摘要:
// 发起添加的userid,如果成员主动添加,为成员的userid;如果是客户主动添加,则为客户的外部联系人userid;如果是内部成员共享/管理员分配,则为对应的成员/管理员userid
public string oper_userid { get; set; }
//
// 摘要:
// 该成员添加此客户的来源
public int add_way { get; set; }
//
// 摘要:
// 该成员对此客户备注的企业名称
public string remark_corp_name { get; set; }
//
// 摘要:
// 该成员对此客户备注的手机号码,第三方不可获取
public string[] remark_mobiles { get; set; }
public string[] tag_id { get; set; }
}
}
...@@ -276,6 +276,34 @@ namespace Edu.ThirdCore.QYWinXin ...@@ -276,6 +276,34 @@ namespace Edu.ThirdCore.QYWinXin
return ExternalApi.GetExternalContactInfo(accessTokenOrAppKey, externalUserId); return ExternalApi.GetExternalContactInfo(accessTokenOrAppKey, externalUserId);
} }
/// <summary>
/// 批量获取客户详情
/// </summary>
/// <param name="accessTokenOrAppKey"></param>
/// <param name="userid"></param>
/// <param name="cursor"></param>
/// <param name="limit"></param>
/// <param name="timeOut"></param>
public static GetExternalContactInfoBatchResult_V2 GetExternalContactInfoBatch(string accessTokenOrAppKey, List<string> userid, string cursor = "", int limit = 50)
{
string url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token=" + accessTokenOrAppKey;
var SendDate = new
{
userid_list = userid,
cursor,
limit
};
var Rmsg = HttpHelper.HttpPost(url, JsonHelper.Serialize(SendDate), "");
if (!string.IsNullOrEmpty(Rmsg))
{
var rmodel = JsonHelper.DeserializeObject<GetExternalContactInfoBatchResult_V2>(Rmsg);
return rmodel;
}
return null;
}
/// <summary> /// <summary>
/// 转移客户 /// 转移客户
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment