Commit e2208bde authored by liudong1993's avatar liudong1993

企业微信客户模块

parent 3af710a4
using Edu.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Enum.WeChat
{
/// <summary>
/// 企业微信客户字段类型枚举
/// </summary>
public enum CustomerFieldInputTypeEnum
{
/// <summary>
/// 汉字
/// </summary>
[EnumField("汉字")]
Chinese = 1,
/// <summary>
/// 数字
/// </summary>
[EnumField("数字")]
Number = 2,
/// <summary>
/// 字母
/// </summary>
[EnumField("字母")]
Letter = 3,
/// <summary>
/// 符号
/// </summary>
[EnumField("符号")]
Symbol = 4
}
}
using Edu.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Common.Enum.WeChat
{
/// <summary>
/// 企业微信客户字段类型枚举
/// </summary>
public enum CustomerFieldTypeEnum
{
/// <summary>
/// 单行文本
/// </summary>
[EnumField("单行文本")]
Text = 1,
/// <summary>
/// 多行文本
/// </summary>
[EnumField("多行文本")]
MText = 2,
/// <summary>
/// 单选
/// </summary>
[EnumField("单选")]
Radio = 3,
/// <summary>
/// 多选
/// </summary>
[EnumField("多选")]
MultiSelect = 4,
/// <summary>
/// 日期
/// </summary>
[EnumField("日期")]
Date = 5,
/// <summary>
/// 日期时间
/// </summary>
[EnumField("日期时间")]
Time = 6,
/// <summary>
/// 数值
/// </summary>
[EnumField("数值")]
Number = 7
}
}
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_CustomerField
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 类型 枚举
/// </summary>
public CustomerFieldTypeEnum Type { get; set; }
/// <summary>
/// 字段名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 必填 1是
/// </summary>
public int Required { get; set; }
/// <summary>
/// 部门id (0表示通用)
/// </summary>
public int DeptId { get; set; }
/// <summary>
/// 字数
/// </summary>
public int WordNum { get; set; }
/// <summary>
/// 输入类型 多选 英文逗号分隔
/// </summary>
public string InputType { get; set; }
/// <summary>
/// 列表选项 json格式 key-value
/// </summary>
public string Options { get; set; }
/// <summary>
/// 小数位数
/// </summary>
public int Digits { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 是否启用 1是
/// </summary>
public int Enable { 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>
/// 是否系统字段 1是
/// </summary>
public int IsSystem { get; set; }
/// <summary>
/// 是否默认字段 1是 (默认字段无法删除)
/// </summary>
public int IsDefault { get; set; }
/// <summary>
/// 是否锁定字段 1是 (锁定字段无法禁用)
/// </summary>
public int IsLock { get; set; }
}
}
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_CustomerStage
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 类型 1跟进阶段 2结束跟进
/// </summary>
public int Type { get; set; }
/// <summary>
/// 阶段名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 排序
/// </summary>
public int? Sort { get; set; }
/// <summary>
/// 结束跟进 原因选项 json格式
/// </summary>
public string Options { get; set; }
/// <summary>
/// 是否默认 1是 (默认表示无法修改Name)
/// </summary>
public int IsDefault { 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; }
}
}
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_CustomerStageFlow
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 流程名称
/// </summary>
public string FlowName { get; set; }
/// <summary>
/// 适用部门Ids -1表示通用
/// </summary>
public string DeptIds { get; set; }
/// <summary>
/// 适用人员ids -1表示通用
/// </summary>
public string EmpIds { get; set; }
/// <summary>
/// 使用阶段 英文逗号分隔
/// </summary>
public string UseStage { get; set; }
/// <summary>
/// 选择输单原因 英文逗号分隔
/// </summary>
public string LoseCause { get; set; }
/// <summary>
/// 选择无效原因 英文逗号分隔
/// </summary>
public string InvalidCause { get; set; }
/// <summary>
/// 是否默认 1是 2否
/// </summary>
public int IsDefault { get; set; }
/// <summary>
/// 启用 1是 2否
/// </summary>
public int Enable { 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; }
}
}
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_CustomerField_ViewModel : RB_WeChat_CustomerField
{
/// <summary>
/// 选项列表
/// </summary>
public List<CustomerOptions> OptionsList { get; set; }
/// <summary>
/// 部门名称
/// </summary>
public string DeptName { get; set; }
}
/// <summary>
/// 选项列表
/// </summary>
public class CustomerOptions
{
/// <summary>
/// id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
}
}
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_CustomerStageFlow_ViewModel : RB_WeChat_CustomerStageFlow
{
/// <summary>
/// 阶段ID
/// </summary>
public int StageId { get; set; }
/// <summary>
/// 输单id
/// </summary>
public int LoseId { get; set; }
/// <summary>
/// 无效id
/// </summary>
public int InvalidId { get; set; }
/// <summary>
/// 阶段列表
/// </summary>
public List<string> StageList { get; set; }
/// <summary>
/// 部门/人员列表
/// </summary>
public List<DeptAndEmpModel> DeptEmpList { get; set; }
}
/// <summary>
/// 部门+人员
/// </summary>
public class DeptAndEmpModel {
/// <summary>
/// id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 类型 1部门 2人员
/// </summary>
public int Type { get; set; }
}
}
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_CustomerStage_ViewModel : RB_WeChat_CustomerStage
{
/// <summary>
/// 选项列表
/// </summary>
public List<CauseOptions> OptionsList { get; set; }
/// <summary>
/// 阶段ids
/// </summary>
public string StageIds { get; set; }
}
/// <summary>
/// 原因选项
/// </summary>
public class CauseOptions
{
/// <summary>
/// id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
}
}
This diff is collapsed.
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.Dapper;
namespace Edu.Repository.WeChat
{
/// <summary>
/// 企业微信客户字段仓储层
/// </summary>
public class RB_WeChat_CustomerFieldRepository : BaseRepository<RB_WeChat_CustomerField>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_WeChat_CustomerField_ViewModel> GetList(RB_WeChat_CustomerField_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.{nameof(RB_WeChat_CustomerField_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerField_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.Enable > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerField_ViewModel.Enable)} ={demodel.Enable}";
}
if (demodel.Type > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerField_ViewModel.Type)} ={(int)demodel.Type}";
}
if (!string.IsNullOrEmpty(demodel.Name))
{
where += $@" and r.{nameof(RB_WeChat_CustomerField_ViewModel.Name)} like @Name";
parameters.Add("Name", "%" + demodel.Name + "%");
}
string sql = $@"
SELECT * From RB_WeChat_CustomerField r
WHERE {where}
ORDER BY r.Sort asc, r.Id asc ";
return Get<RB_WeChat_CustomerField_ViewModel>(sql, parameters).ToList();
}
/// <summary>
/// 获取最大排序
/// </summary>
/// <param name="group_Id"></param>
/// <returns></returns>
public int GetSortMax(int group_Id)
{
string sql = $@" select Max(Sort) from RB_WeChat_CustomerField where Group_Id ={group_Id}";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj);
}
/// <summary>
/// 此排序后面的字段排序都加1
/// </summary>
/// <param name="sort"></param>
/// <param name="group_Id"></param>
/// <returns></returns>
public bool SetSortNumAdd(int sort, int group_Id)
{
string sql = $@" update RB_WeChat_CustomerField set Sort = Sort +1 where Group_Id ={group_Id} and Sort >{sort}";
return Execute(sql) > 0;
}
}
}
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.Dapper;
namespace Edu.Repository.WeChat
{
/// <summary>
/// 企业微信客户阶段流程仓储层
/// </summary>
public class RB_WeChat_CustomerStageFlowRepository : BaseRepository<RB_WeChat_CustomerStageFlow>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_WeChat_CustomerStageFlow_ViewModel> GetList(RB_WeChat_CustomerStageFlow_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.Enable > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.Enable)} ={demodel.Enable}";
}
if (demodel.IsDefault > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.IsDefault)} ={demodel.IsDefault}";
}
if (demodel.StageId > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.IsDefault)} <>1";
where += $@" and FIND_IN_SET('{demodel.StageId}',r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.UseStage)})";
}
if (demodel.LoseId > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.IsDefault)} <>1";
where += $@" and FIND_IN_SET('{demodel.LoseId}',r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.LoseCause)})";
}
if (demodel.InvalidId > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.IsDefault)} <>1";
where += $@" and FIND_IN_SET('{demodel.InvalidId}',r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.InvalidCause)})";
}
if (!string.IsNullOrEmpty(demodel.FlowName))
{
where += $@" and r.{nameof(RB_WeChat_CustomerStageFlow_ViewModel.FlowName)} like @FlowName";
parameters.Add("FlowName", "%" + demodel.FlowName + "%");
}
string sql = $@"
SELECT * From RB_WeChat_CustomerStageFlow r
WHERE {where}
ORDER BY r.Id desc ";
return Get<RB_WeChat_CustomerStageFlow_ViewModel>(sql, parameters).ToList();
}
}
}
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.Dapper;
namespace Edu.Repository.WeChat
{
/// <summary>
/// 企业微信客户阶段仓储层
/// </summary>
public class RB_WeChat_CustomerStageRepository : BaseRepository<RB_WeChat_CustomerStage>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_WeChat_CustomerStage_ViewModel> GetList(RB_WeChat_CustomerStage_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.Type > 0)
{
where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Type)} ={demodel.Type}";
}
if (!string.IsNullOrEmpty(demodel.StageIds))
{
where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Id)} in({demodel.StageIds})";
}
if (!string.IsNullOrEmpty(demodel.Name))
{
where += $@" and r.{nameof(RB_WeChat_CustomerStage_ViewModel.Name)} like @Name";
parameters.Add("Name", "%" + demodel.Name + "%");
}
string sql = $@"
SELECT * From RB_WeChat_CustomerStage r
WHERE {where}
ORDER BY r.Type asc, r.Sort asc, r.Id asc ";
return Get<RB_WeChat_CustomerStage_ViewModel>(sql, parameters).ToList();
}
}
}
using Senparc.Weixin.Entities;
using Senparc.Weixin.Work.AdvancedAPIs.MailList.Member;
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.ThirdCore.QYWinXin.Model
{
/// <summary>
/// GetMemberResult【QY移植修改】
/// </summary>
public class GetMemberResult_V2 : WorkJsonResult
{
/// <summary>
/// 员工UserID
/// </summary>
public string userid { get; set; }
/// <summary>
/// 成员名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 别名
/// </summary>
public string alias { get; set; }
/// <summary>
/// 成员所属部门id列表
/// </summary>
public long[] department { get; set; }
/// <summary>
/// 部门内的排序值,默认为0。数量必须和department一致,数值越大排序越前面。值范围是[0, 2^32)
/// </summary>
public int[] order { get; set; }
/// <summary>
/// 职位信息
/// </summary>
public string position { get; set; }
/// <summary>
/// 手机号码
/// </summary>
public string mobile { get; set; }
/// <summary>
/// 性别。gender=0表示男,=1表示女
/// </summary>
public int gender { get; set; }
/// <summary>
/// 邮箱
/// </summary>
public string email { get; set; }
/// <summary>
/// 上级字段,标识是否为上级。第三方暂不支持
/// </summary>
public int[] is_leader_in_dept { get; set; }
/// <summary>
/// 头像url。注:小图将url最后的"/0"改成"/64"
/// </summary>
public string avatar { get; set; }
/// <summary>
/// 激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业。 已激活代表已激活企业微信或已关注微信插件。未激活代表既未激活企业微信又未关注微信插件。
/// </summary>
public int status { get; set; }
/// <summary>
/// 座机。第三方暂不支持
/// </summary>
public string telephone { get; set; }
/// <summary>
/// 英文名。第三方暂不支持
/// </summary>
public string english_name { get; set; }
/// <summary>
/// 全局唯一。对于同一个服务商,不同应用获取到企业内同一个成员的open_userid是相同的,最多64个字节。仅第三方应用可获取
/// </summary>
public string open_userid { get; set; }
/// <summary>
/// 主部门
/// </summary>
public int main_department { get; set; }
/// <summary>
/// 扩展属性
/// </summary>
public Extattr extattr { get; set; }
/// <summary>
/// 启用/禁用成员,第三方不可获取。1表示启用成员,0表示禁用成员
/// </summary>
public int enable { get; set; }
/// <summary>
/// 关注微信插件的状态: 1=已关注,0=未关注
/// </summary>
public string wxplugin_status { get; set; }
/// <summary>
/// 员工个人二维码,扫描可添加为外部联系人(注意返回的是一个url,可在浏览器上打开该url以展示二维码);第三方仅通讯录应用可获取
/// </summary>
public string qr_code { get; set; }
}
}
......@@ -196,6 +196,27 @@ namespace Edu.ThirdCore.QYWinXin
return MailListApi.GetMember(accessTokenOrAppKey, userId);
}
/// <summary>
/// 获取成员(包含别名)
/// </summary>
/// <param name="accessTokenOrAppKey"></param>
/// <param name="userId"></param>
/// <returns></returns>
public static GetMemberResult_V2 GetMember_V2(string accessTokenOrAppKey, string userId) {
string url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=" + accessTokenOrAppKey + "&userid=" + userId;
string Rmsg = HttpHelper.HttpGet(url);
if (!string.IsNullOrEmpty(Rmsg))
{
var rmodel = JsonHelper.DeserializeObject<GetMemberResult_V2>(Rmsg);
return rmodel;
}
return new GetMemberResult_V2()
{
errcode = Senparc.Weixin.ReturnCode_Work.系统繁忙,
errmsg = "未请求到数据"
};
}
/// <summary>
/// 更新人员
/// </summary>
......
This diff is collapsed.
......@@ -189,6 +189,19 @@ namespace Edu.WebApi.Controllers.QYWeChat
string ContactName = ContactModel?.external_contact?.name ?? "";
welcomeModel.Content = welcomeModel.Content.Replace("##客户名称##", ContactName);
}
if (welcomeModel.Content.Contains("##员工姓名##"))
{
//替换员工姓名
welcomeModel.Content = welcomeModel.Content.Replace("##员工姓名##", empModel.EmployeeName);
}
if (welcomeModel.Content.Contains("##员工别名##"))
{
//替换客户名称
var MemberModel = QYWeiXinHelper.GetMember_V2(token, UserID);
string Alias = MemberModel?.alias ?? "";
welcomeModel.Content = welcomeModel.Content.Replace("##员工别名##", Alias);
}
//开始状态欢迎语 掉推送接口
string RMsg = weChatModule.SendNewCustomerWelcome(token, WelcomeCode, welcomeModel);
//处理消息
......@@ -223,6 +236,19 @@ namespace Edu.WebApi.Controllers.QYWeChat
welcomeModel.Content = welcomeModel.Content.Replace("##客户名称##", ContactName);
}
if (welcomeModel.Content.Contains("##员工姓名##"))
{
//替换员工姓名
welcomeModel.Content = welcomeModel.Content.Replace("##员工姓名##", empModel.EmployeeName);
}
if (welcomeModel.Content.Contains("##员工别名##"))
{
//替换客户名称
var MemberModel = QYWeiXinHelper.GetMember_V2(token, UserID);
string Alias = MemberModel?.alias ?? "";
welcomeModel.Content = welcomeModel.Content.Replace("##员工别名##", Alias);
}
//开始状态欢迎语 掉推送接口
string RMsg = weChatModule.SendNewCustomerWelcome(token, WelcomeCode, welcomeModel);
//处理消息
......@@ -327,6 +353,19 @@ namespace Edu.WebApi.Controllers.QYWeChat
welcomeModel.Content = welcomeModel.Content.Replace("##客户名称##", ContactName);
}
if (welcomeModel.Content.Contains("##员工姓名##"))
{
//替换员工姓名
welcomeModel.Content = welcomeModel.Content.Replace("##员工姓名##", empModel.EmployeeName);
}
if (welcomeModel.Content.Contains("##员工别名##"))
{
//替换客户名称
var MemberModel = QYWeiXinHelper.GetMember_V2(token, UserID);
string Alias = MemberModel?.alias ?? "";
welcomeModel.Content = welcomeModel.Content.Replace("##员工别名##", Alias);
}
//开始状态欢迎语 掉推送接口
string RMsg = weChatModule.SendNewCustomerWelcome(token, WelcomeCode, welcomeModel);
//处理消息
......
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