public async Task <IActionResult> GetMerchantInfoAsync([FromBody] GetMerchantInfoRequestDto request) { var merchantBiz = new MerchantBiz(); var merchantModel = await merchantBiz.GetAsync(request.MerchantGuid); var accModel = await new AccessoryBiz().GetAsync(merchantModel.MerchantPicture); var response = new GetMerchantInfoResponseDto { Address = merchantModel.MerchantAddress, MerchantGuid = merchantModel.MerchantGuid, MerchantName = merchantModel.MerchantName, MerchantPicture = merchantModel.MerchantPicture, MerchantPictureUrl = $"{ accModel?.BasePath}{accModel?.RelativePath}", SignatureGuid = merchantModel.SignatureGuid, Telephone = merchantModel.Telephone, Longitude = merchantModel.Longitude ?? 0, Latitude = merchantModel.Latitude ?? 0, Account = merchantModel.Account, Area = merchantModel.Area, City = merchantModel.City, Province = merchantModel.Province, Street = merchantModel.Street, HospitalGuid = merchantModel.HospitalGuid }; return(Success(response)); }
/// <summary> /// 用户预约的服务完成后发送微信模板消息通知 /// </summary> /// <param name="consumptionGuid"></param> private void NotifyUser(string consumptionGuid) { Task.Run(() => { if (string.IsNullOrWhiteSpace(PlatformSettings.UserAppointmentCompletedNotificationTemplate)) { return; } var userOpenId = ""; string controllerName = ControllerContext.ActionDescriptor.ControllerName; string actionName = ControllerContext.ActionDescriptor.ActionName; try { var model = new ConsumptionBiz().GetModel(consumptionGuid); var userModel = new UserBiz().GetModelAsync(model.UserGuid).Result; Logger.Debug($"NotifyUser-用户预约的服务已完成-用户openid-{userModel?.WechatOpenid}"); if (string.IsNullOrWhiteSpace(userModel?.WechatOpenid ?? "")) { return; } var merchantModel = new MerchantBiz().GetAsync(model.MerchantGuid).Result; var projectModel = new ProjectBiz().GetAsync(model.ProjectGuid).Result; var resToken = WeChartApi.GetAccessToken(PlatformSettings.CDClientAppId, PlatformSettings.CDClientAppSecret).Result; Logger.Debug($"NotifyUser-用户预约的服务已完成-获取token-{JsonConvert.SerializeObject(resToken)}"); if (string.IsNullOrWhiteSpace(resToken.AccessToken)) { Common.Helper.Logger.Error($"GD.API.Controllers.Consumer.{controllerName}.{actionName} openId:[{userOpenId}] {Environment.NewLine} error:用户预约后发送模板消息通知云医执行端公众号-获取token失败。{resToken.Errmsg}"); return; } userOpenId = userModel.WechatOpenid; var clientMsg = new WeChatTemplateMsg { Touser = userModel.WechatOpenid, Template_Id = PlatformSettings.UserAppointmentNotificationTemplate, Data = new { First = new { Value = "【您预约的服务已完成】" }, //完成时间 Keyword1 = new { Value = $"{model.ConsumptionEndDate.Value.ToString("MM月dd日 HH:mm")}" }, //服务项目 Keyword2 = new { Value = projectModel?.ProjectName }, //服务门店 Keyword3 = new { Value = merchantModel.MerchantName }, //备注 Remark = new { Value = "如对我们服务有什么建议,请及时与我们联系" }, } }; var clientTempMsgRes = WeChartApi.SendTemplateMsg(clientMsg, resToken.AccessToken); Logger.Debug($"NotifyUser-用户预约的服务已完成-发送模板消息-{JsonConvert.SerializeObject(clientTempMsgRes)}"); } catch (Exception ex) { Logger.Error($"GD.API.Controllers.Consumer.{controllerName}.{actionName} openId:[{userOpenId}] {Environment.NewLine} error:用户预约服务完成后发送模板消息通知云医用户端公众号端失败。{ex.Message}"); } }); }
public async Task <IActionResult> DisableEnableMerchantAsync([FromBody] DisableEnableMerchantRequestDto request) { var doctorBiz = new MerchantBiz(); var result = await doctorBiz.DisableEnableAsync(request.Guid, request.Enable, UserID); if (!result) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }
public async Task <IActionResult> ReviewRejectMerchantAsync([FromBody] ReviewRejectMerchantRequestDto request) { MerchantBiz merchantBiz = new MerchantBiz(); var entity = await merchantBiz.GetAsync(request.OwnerGuid); if (entity == null) { return(Failed(ErrorCode.DataBaseError)); } if (entity.Status.ToLower() == MerchantModel.StatusEnum.Reject.ToString().ToLower()) { return(Failed(ErrorCode.DataBaseError, "请不要重复审核")); } entity.Status = MerchantModel.StatusEnum.Reject.ToString(); entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; var response = await merchantBiz.ReviewMerchantAsync(entity, request.RejectReason); if (!response) { return(Failed(ErrorCode.DataBaseError, "审核失败")); } return(Success()); }
public async Task <IActionResult> UpdateMerchantAsync([FromBody] UpdateMerchantRequestDto request) { var merchantBiz = new MerchantBiz(); var merchantModel = await merchantBiz.GetAsync(request.MerchantGuid); if (merchantModel == null) { return(Failed(ErrorCode.UserData, "商户不存在!")); } if (request.Account != merchantModel.Account && await merchantBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } //商户信息 merchantModel.MerchantPicture = request.MerchantPicture; merchantModel.MerchantName = request.MerchantName; merchantModel.Telephone = request.Telephone; merchantModel.LastUpdatedBy = merchantModel.MerchantGuid; merchantModel.LastUpdatedDate = DateTime.Now; merchantModel.Latitude = request.Latitude; merchantModel.Longitude = request.Longitude; merchantModel.Account = request.Account; if (null != request.Password) { merchantModel.Password = CryptoHelper.AddSalt(merchantModel.MerchantGuid, request.Password); } merchantModel.MerchantAddress = $"{request.Province}{request.City}{request.Area}{request.Street}"; merchantModel.Area = request.Area; merchantModel.City = request.City; merchantModel.Province = request.Province; merchantModel.Street = request.Street; merchantModel.HospitalGuid = request.HospitalGuid ?? string.Empty; //商户经营范围信息 var scopes = request.Scopes.Select(scope => new ScopeModel { ScopeGuid = Guid.NewGuid().ToString("N"), ScopeDicGuid = scope.ScopeDicGuid, MerchantGuid = merchantModel.MerchantGuid, PictureGuid = scope.AccessoryGuid, CreatedBy = merchantModel.MerchantGuid, OrgGuid = string.Empty, LastUpdatedBy = merchantModel.MerchantGuid }); //商户配置项证书信息 & 配置项证书附件信息 var lstCertificate = request.Certificates.Select(item => new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = item.AccessoryGuid, OwnerGuid = merchantModel.MerchantGuid, DicGuid = item.DicGuid, CreatedBy = UserID, OrgGuid = string.Empty, LastUpdatedBy = UserID }); var result = await merchantBiz.UpdateMerchantAsync(merchantModel, scopes, lstCertificate); if (!result) { Failed(ErrorCode.DataBaseError, "商户修改失败!"); } return(Success()); }
public async Task <IActionResult> RegisterMerchantAsync([FromBody] RegisterMerchantRequestDto request) { if (!request.Scopes.Any()) { return(Failed(ErrorCode.UserData, "经营范围数据为空!")); } var merchantBiz = new MerchantBiz(); if (await merchantBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } //商户信息 string merchantGuid = Guid.NewGuid().ToString("N"); var merchantModel = new MerchantModel { Status = MerchantModel.StatusEnum.Approved.ToString(), MerchantGuid = merchantGuid, MerchantPicture = request.MerchantPicture, MerchantName = request.MerchantName, CreatedBy = merchantGuid, SignatureGuid = request.SignatureGuid, Telephone = request.Telephone, OrgGuid = string.Empty, MerchantAddress = $"{request.Province}{request.City}{request.Area}{request.Street}", Latitude = request.Latitude, Longitude = request.Longitude, LastUpdatedBy = merchantGuid, Password = CryptoHelper.AddSalt(merchantGuid, request.Password), Account = request.Account, Enable = true, Area = request.Area, City = request.City, Province = request.Province, Street = request.Street, HospitalGuid = request.HospitalGuid ?? string.Empty }; //商户经营范围信息 var lstScope = request.Scopes.Select(scope => new ScopeModel { ScopeGuid = Guid.NewGuid().ToString("N"), ScopeDicGuid = scope.ScopeDicGuid, MerchantGuid = merchantModel.MerchantGuid, PictureGuid = scope.AccessoryGuid, CreatedBy = merchantGuid, OrgGuid = string.Empty, LastUpdatedBy = merchantGuid }).ToList(); //商户配置项证书信息 & 配置项证书附件信息 var lstCertificate = request.Certificates.Select(item => new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = item.AccessoryGuid, OwnerGuid = merchantModel.MerchantGuid, DicGuid = item.DicGuid, CreatedBy = UserID, OrgGuid = string.Empty, LastUpdatedBy = UserID }); var lstAccessory = (await new AccessoryBiz().GetListAsync(request.Certificates.Select(a => a.AccessoryGuid).ToArray())).ToList(); lstAccessory.ForEach(a => { a.OwnerGuid = lstCertificate.FirstOrDefault(b => b.PictureGuid == a.AccessoryGuid)?.CertificateGuid; a.LastUpdatedDate = DateTime.Now; a.CreatedBy = UserID; }); var result = await merchantBiz.RegisterMerchantAsync(merchantModel, lstScope, lstCertificate, lstAccessory); if (!result) { Failed(ErrorCode.DataBaseError, "商户注册数据插入不成功!"); } return(Success()); }