【优化】移除旧版自定义交易组件。

This commit is contained in:
jianweie code
2023-09-02 01:49:22 +08:00
parent 651dc6b231
commit 0a07f3e005
108 changed files with 181 additions and 14817 deletions

View File

@@ -1,74 +0,0 @@
/***********************************************************************
* 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.Loging;
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 Newtonsoft.Json;
using SKIT.FlurlHttpClient.Wechat.Api;
using SKIT.FlurlHttpClient.Wechat.Api.Events;
namespace CoreCms.Net.WeChat.Service.Mediator
{
/// <summary>
/// 表示 TEXT 事件的数据
/// </summary>
public class AftersaleUserCancelEventCommand : IRequest<WeChatApiCallBack>
{
public AftersaleUserCancelEvent EventObj { get; set; }
}
/// <summary>
/// 用户取消售后申请
/// </summary>
public class AftersaleUserCancelEventCommandHandler : IRequestHandler<AftersaleUserCancelEventCommand, WeChatApiCallBack>
{
private readonly ICoreCmsBillAftersalesServices _aftersalesServices;
public AftersaleUserCancelEventCommandHandler(ICoreCmsBillAftersalesServices aftersalesServices)
{
_aftersalesServices = aftersalesServices;
}
public async Task<WeChatApiCallBack> Handle(AftersaleUserCancelEventCommand request, CancellationToken cancellationToken)
{
var jm = new WeChatApiCallBack() { Status = true };
if (request.EventObj != null)
{
try
{
await _aftersalesServices.UpdateAsync(p => new CoreCmsBillAftersales()
{
status = (int)GlobalEnumVars.BillAftersalesStatus.Cancel
},
p => p.aftersalesId == request.EventObj.AftersaleOrder.OutAftersaleOrderId);
}
catch (Exception e)
{
NLogUtil.WriteFileLog(NLog.LogLevel.Info, LogType.WxPost, "接收服务器推送", "用户取消售后申请", e);
}
}
return await Task.FromResult(jm);
}
}
}

View File

@@ -1,112 +0,0 @@
/***********************************************************************
* 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 = (int)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 = (int)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);
}
}
}

View File

@@ -1,112 +0,0 @@
/***********************************************************************
* 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 OpenProductCategoryAuditEventCommand : IRequest<WeChatApiCallBack>
{
public OpenProductCategoryAuditEvent EventObj { get; set; }
}
/// <summary>
/// 商品审核结果
/// </summary>
public class OpenProductCategoryAuditEventCommandHandler : IRequestHandler<OpenProductCategoryAuditEventCommand, WeChatApiCallBack>
{
private readonly IWeChatTransactionComponentAuditCategoryAuditLogServices _logServices;
private readonly IWeChatTransactionComponentAuditCategoryServices _auditCategoryServices;
private readonly ICoreCmsSettingServices _settingServices;
private readonly ICoreCmsSmsServices _smsServices;
public OpenProductCategoryAuditEventCommandHandler(IWeChatTransactionComponentAuditCategoryAuditLogServices logServices, ICoreCmsSettingServices settingServices, ICoreCmsSmsServices smsServices, IWeChatTransactionComponentAuditCategoryServices auditCategoryServices)
{
_logServices = logServices;
_settingServices = settingServices;
_smsServices = smsServices;
_auditCategoryServices = auditCategoryServices;
}
public async Task<WeChatApiCallBack> Handle(OpenProductCategoryAuditEventCommand request, CancellationToken cancellationToken)
{
var jm = new WeChatApiCallBack() { Status = true };
if (request.EventObj != null)
{
var auditCategory =
await _auditCategoryServices.QueryByClauseAsync(
p => p.auditId == request.EventObj.EventData.AuditId);
if (auditCategory != null)
{
await _auditCategoryServices.UpdateAsync(p => new WeChatTransactionComponentAuditCategory()
{
status = request.EventObj.EventData.Status,
rejectReason = request.EventObj.EventData.RejectReason
}, p => p.auditId == request.EventObj.EventData.AuditId);
var log = new WeChatTransactionComponentAuditCategoryAuditLog();
log.auditId = request.EventObj.EventData.AuditId;
log.status = request.EventObj.EventData.Status;
log.auditType = request.EventObj.EventData.AuditType;
log.rejectReason = request.EventObj.EventData.RejectReason;
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.rejectReason + ",请修改资料后重新提交。";
}
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);
}
}
}

View File

@@ -1,71 +0,0 @@
/***********************************************************************
* 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.Loging;
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 Newtonsoft.Json;
using SKIT.FlurlHttpClient.Wechat.Api;
using SKIT.FlurlHttpClient.Wechat.Api.Events;
namespace CoreCms.Net.WeChat.Service.Mediator
{
/// <summary>
/// 表示 TEXT 事件的数据
/// </summary>
public class OpenProductOrderConfirmEventCommand : IRequest<WeChatApiCallBack>
{
public OpenProductOrderConfirmEvent EventObj { get; set; }
}
/// <summary>
/// 用户确认收货事件回调。
/// </summary>
public class OpenProductOrderConfirmEventCommandHandler : IRequestHandler<OpenProductOrderConfirmEventCommand, WeChatApiCallBack>
{
private readonly ICoreCmsOrderServices _orderServices;
public OpenProductOrderConfirmEventCommandHandler(ICoreCmsOrderServices orderServices)
{
_orderServices = orderServices;
}
public async Task<WeChatApiCallBack> Handle(OpenProductOrderConfirmEventCommand request, CancellationToken cancellationToken)
{
var jm = new WeChatApiCallBack() { Status = true };
if (request.EventObj != null)
{
try
{
await _orderServices.CompleteOrder(request.EventObj.Order.OutOrderId, 0, "微信消息推送事件", "wxpost");
}
catch (Exception e)
{
NLogUtil.WriteFileLog(NLog.LogLevel.Info, LogType.WxPost, "接收服务器推送", "用户确认收货事件回调异常", e);
}
}
return await Task.FromResult(jm);
}
}
}

View File

@@ -1,80 +0,0 @@
/***********************************************************************
* 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.Loging;
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 Newtonsoft.Json;
using SKIT.FlurlHttpClient.Wechat.Api;
using SKIT.FlurlHttpClient.Wechat.Api.Events;
namespace CoreCms.Net.WeChat.Service.Mediator
{
/// <summary>
/// 表示 TEXT 事件的数据
/// </summary>
public class OpenProductOrderPayEventCommand : IRequest<WeChatApiCallBack>
{
public OpenProductOrderPayEvent EventObj { get; set; }
}
/// <summary>
/// 订单支付回调
/// </summary>
public class OpenProductOrderPayEventCommandHandler : IRequestHandler<OpenProductOrderPayEventCommand, WeChatApiCallBack>
{
private readonly ICoreCmsOrderServices _orderServices;
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
private readonly IWeChatTransactionComponentOrderServices _transactionComponentOrderServices;
public OpenProductOrderPayEventCommandHandler(ICoreCmsOrderServices orderServices, ICoreCmsBillPaymentsServices billPaymentsServices, IWeChatTransactionComponentOrderServices transactionComponentOrderServices)
{
_orderServices = orderServices;
_billPaymentsServices = billPaymentsServices;
_transactionComponentOrderServices = transactionComponentOrderServices;
}
public async Task<WeChatApiCallBack> Handle(OpenProductOrderPayEventCommand request, CancellationToken cancellationToken)
{
var jm = new WeChatApiCallBack() { Status = true };
if (request.EventObj != null)
{
try
{
var tcOrder = await _transactionComponentOrderServices.QueryByClauseAsync(p => p.orderId == request.EventObj.Order.OrderId && p.outOrderId == request.EventObj.Order.OutOrderId);
var order = await _orderServices.QueryByClauseAsync(p => p.orderId == tcOrder.outOrderId);
await _billPaymentsServices.ToUpdate(tcOrder.paymentId,
(int)GlobalEnumVars.BillPaymentsStatus.Payed,
GlobalEnumVars.PaymentsTypes.wechatpay.ToString(), order.orderAmount, JsonConvert.SerializeObject(request),
request.EventObj.Order.TransactionId);
}
catch (Exception e)
{
NLogUtil.WriteFileLog(NLog.LogLevel.Info, LogType.WxPost, "接收服务器推送", "订单支付回调异常", e);
}
}
return await Task.FromResult(jm);
}
}
}

View File

@@ -1,102 +0,0 @@
/***********************************************************************
* 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 OpenProductSPUAuditEventCommand : IRequest<WeChatApiCallBack>
{
public OpenProductSPUAuditEvent EventObj { get; set; }
}
/// <summary>
/// 商品审核结果
/// </summary>
public class OpenProductSPUAuditEventCommandHandler : IRequestHandler<OpenProductSPUAuditEventCommand, WeChatApiCallBack>
{
private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
private readonly IWeChatTransactionComponentGoodAuditLogServices _logServices;
private readonly ICoreCmsGoodsServices _goodsServices;
private readonly ICoreCmsSettingServices _settingServices;
private readonly ICoreCmsSmsServices _smsServices;
public OpenProductSPUAuditEventCommandHandler(IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IWeChatTransactionComponentGoodAuditLogServices logServices, ICoreCmsGoodsServices goodsServices, ICoreCmsSettingServices settingServices, ICoreCmsSmsServices smsServices)
{
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
_logServices = logServices;
_goodsServices = goodsServices;
_settingServices = settingServices;
_smsServices = smsServices;
}
public async Task<WeChatApiCallBack> Handle(OpenProductSPUAuditEventCommand request, CancellationToken cancellationToken)
{
var jm = new WeChatApiCallBack() { Status = true };
if (request.EventObj != null)
{
var log = new WeChatTransactionComponentGoodAuditLog();
log.outProductId = request.EventObj.EventData.OutProductId;
log.productId = request.EventObj.EventData.ProductId;
log.status = request.EventObj.EventData.Status;
log.rejectReason = request.EventObj.EventData.RejectReason;
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 == 4)
{
smsBody = "你提交的商品审核已经通过,请登录平台上架商品。";
}
else if (log.status == 3)
{
smsBody = "你提交的商品审核已被拒绝,失败原因为:" + log.rejectReason + ",请修改资料后重新提交。";
}
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);
}
}
}