/// <summary> /// 添加到CRM表记录 /// </summary> /// <param name="value"></param> /// <param name="MId"></param> public void Add(string value, Guid MId) { if (!string.IsNullOrWhiteSpace(value)) { try { var mesInfo = JsonConvert.DeserializeObject <ReadSenceMQMessage>(value); if (mesInfo != null && mesInfo.data != null) { if (!string.IsNullOrWhiteSpace(mesInfo.data.person_uuid)) { var customer = CustomerHandle.GetCustomerInfo(mesInfo.data.person_uuid); if (customer == null) { throw new Exception("找不到会员"); } var model = new FaceRecognitionRecord { Id = Guid.NewGuid(), AddedOn = DateTime.Now, CustomerId = customer.CustomerID, DeviceName = mesInfo.data.device_name, RegionName = mesInfo.data.device_location, FaceId = mesInfo.data.person_uuid }; DbContext.Add(model); var MesInfo = new CRMMessageInfo { CustomerId = customer.CustomerID, CustomerName = customer.FullName, RegionName = mesInfo.data.device_location, CreatedOn = DateTime.Now, }; CRMProductor(JsonConvert.SerializeObject(MesInfo), MId); } } } catch (Exception ex) { _logger.LogError($"【添加到CRM表记录异常】{ex.Message}"); } } }
public IActionResult Receive([FromBody] ReadSenceEventRequest req) { if (req == null || req.error != null || req.Info == null || string.IsNullOrWhiteSpace(req.Info.person_id)) { throw new Exception("阅面消息推送:参数异常"); } var customer = CustomerHandle.GetCustomerInfo(req.Info.person_id); //获取会员信息 if (customer == null) { throw new Exception("找不到会员"); } var model = new FaceRecognitionRecord { Id = Guid.NewGuid(), AddedOn = DateTime.Now, CustomerId = customer.CustomerID, DeviceName = req.Info.device_name, RegionName = req.Info.region_name, FaceId = req.Info.person_id }; DbContext.Add <FaceRecognitionRecord>(model); var CRMWeChatInfo = CustomerHandle.GetCRMWeChatInfo(); //获取企业微信推送配置 if (!ReflectionUtil.ObjectIsNull(CRMWeChatInfo)) { throw new Exception("CRM企业微信推送配置异常"); } var EnterpriseWeChatUtil = new EnterpriseWeChatUtil(CRMWeChatInfo.AppID, CRMWeChatInfo.AppSecret); var MesContent = CommomUitl.ClearHTML(CRMWeChatInfo.ReminderContent); var mes = string.Format(MesContent, customer.FullName, req.Info.region_name, DateTime.Now); var sendReq = new SendMessageRequest { touser = CRMWeChatInfo.UserId, agentid = int.Parse(CRMWeChatInfo.WeChatPublicNo), text = new Content { content = mes } }; var result = EnterpriseWeChatUtil.Send(sendReq); var res = new ResponseModel <SendMessageResponse> { Result = new Result { HasError = false, Message = "" }, Data = result }; return(Ok(res)); }