mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 20:13:26 +08:00
# 2022-03-21
### 1.4.1 开源社区版: 无 ### 0.3.0 专业版: 【新增】微信自定义交易组件增加【免审更新】功能。 【新增】微信自定义交易组件增加【上传品牌信息】功能。 【新增】微信自定义交易组件增加【品牌信息】审核回调验证功能。
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms.Net *
|
||||
* Web: https://CoreCms.Net *
|
||||
* ProjectName: 核心内容管理系统 *
|
||||
* Author: 大灰灰 *
|
||||
* Email: JianWeie@163.com *
|
||||
* CreateTime: 2020-08-13 23:57:23
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using CoreCms.Net.WeChat.Service.Models;
|
||||
using MediatR;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Events;
|
||||
|
||||
namespace CoreCms.Net.WeChat.Service.Mediator
|
||||
{
|
||||
/// <summary>
|
||||
/// 表示 TEXT 事件的数据
|
||||
/// </summary>
|
||||
public class OpenProductBrandAuditEventCommand : IRequest<WeChatApiCallBack>
|
||||
{
|
||||
public OpenProductBrandAuditEvent EventObj { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 品牌审核结果
|
||||
/// </summary>
|
||||
public class OpenProductBrandAuditEventCommandHandler : IRequestHandler<OpenProductBrandAuditEventCommand, WeChatApiCallBack>
|
||||
{
|
||||
private readonly IWeChatTransactionComponentBrandAuditServices _auditServices;
|
||||
private readonly IWeChatTransactionComponentBrandAuditLogServices _logServices;
|
||||
|
||||
private readonly ICoreCmsSettingServices _settingServices;
|
||||
private readonly ICoreCmsSmsServices _smsServices;
|
||||
|
||||
|
||||
public OpenProductBrandAuditEventCommandHandler(IWeChatTransactionComponentBrandAuditServices auditServices, IWeChatTransactionComponentBrandAuditLogServices logServices, ICoreCmsSettingServices settingServices, ICoreCmsSmsServices smsServices)
|
||||
{
|
||||
_auditServices = auditServices;
|
||||
_logServices = logServices;
|
||||
_settingServices = settingServices;
|
||||
_smsServices = smsServices;
|
||||
}
|
||||
|
||||
public async Task<WeChatApiCallBack> Handle(OpenProductBrandAuditEventCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
var jm = new WeChatApiCallBack() { Status = true };
|
||||
|
||||
if (request.EventObj != null)
|
||||
{
|
||||
var brand = await _auditServices.QueryByClauseAsync(p => p.audit_id == request.EventObj.EventData.AuditId);
|
||||
if (brand != null)
|
||||
{
|
||||
await _auditServices.UpdateAsync(p => new WeChatTransactionComponentBrandAudit()
|
||||
{
|
||||
status = request.EventObj.EventData.Status,
|
||||
rejectReason = request.EventObj.EventData.RejectReason,
|
||||
brandId = request.EventObj.EventData.BrandId,
|
||||
}, p => p.audit_id == request.EventObj.EventData.AuditId);
|
||||
|
||||
var log = new WeChatTransactionComponentBrandAuditLog();
|
||||
log.audit_id = request.EventObj.EventData.AuditId;
|
||||
log.status = request.EventObj.EventData.Status;
|
||||
log.audit_type = request.EventObj.EventData.AuditType;
|
||||
log.reject_reason = request.EventObj.EventData.RejectReason;
|
||||
log.brand_id = request.EventObj.EventData.BrandId;
|
||||
log.createTime = DateTime.Now;
|
||||
|
||||
var id = await _logServices.InsertAsync(log);
|
||||
if (id > 0)
|
||||
{
|
||||
var smsOptions = await _settingServices.GetSmsOptions();
|
||||
if (smsOptions.Enabled == true)
|
||||
{
|
||||
var smsBody = string.Empty;
|
||||
if (log.status == 1)
|
||||
{
|
||||
smsBody = "你提交的品牌已经通过,请登录平台查看。";
|
||||
}
|
||||
else if (log.status == 9)
|
||||
{
|
||||
smsBody = "你提交的品牌审核已被拒绝,失败原因为:" + log.reject_reason + ",请修改资料后重新提交。";
|
||||
|
||||
}
|
||||
if (!string.IsNullOrEmpty(smsBody))
|
||||
{
|
||||
var allConfigs = await _settingServices.GetConfigDictionaries();
|
||||
var shopMobile = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShopMobile);
|
||||
|
||||
await _smsServices.SendSms(shopMobile, smsBody, smsOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return await Task.FromResult(jm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user