升级自定义交易组件常用商品接口,spu接口,品牌接口,订单接口,物流接口。

This commit is contained in:
大灰灰
2022-06-30 22:42:19 +08:00
parent 43a691d1be
commit dc408b8596
27 changed files with 1070 additions and 667 deletions

View File

@@ -0,0 +1,71 @@
/***********************************************************************
* 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

@@ -0,0 +1,80 @@
/***********************************************************************
* 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);
}
}
}