mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-05 05:19:49 +08:00
2022-01-11
## 1.2.9 开源社区版: 【修复】修复全局定义微信配置引用的配置文件命名错误问题。 【修复】修复自动生成sku模式价格出现货号重复情况,#I4Q4WU ## 0.0.6 会员先行版: 【新增】新增微信自定义交易组件,实现微信视频号直播带货功能。
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/7/10 22:41:46
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using InitQ.Abstractions;
|
||||
using InitQ.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace CoreCms.Net.RedisMQ.Subscribe
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义交易组件-同步创建售后单
|
||||
/// </summary>
|
||||
public class TCOrderAfterSaleCreateSyncSubscribe : IRedisSubscribe
|
||||
{
|
||||
private readonly string _wxOpenAppId = AppSettingsConstVars.WxOpenAppId;
|
||||
private readonly string _wxOpenAppSecret = AppSettingsConstVars.WxOpenAppSecret;
|
||||
|
||||
private readonly ICoreCmsUserWeChatInfoServices _userWeChatInfoServices;
|
||||
private readonly ICoreCmsBillDeliveryServices _billDeliveryServices;
|
||||
private readonly ICoreCmsOrderServices _orderServices;
|
||||
private readonly ICoreCmsOrderItemServices _orderItemServices;
|
||||
private readonly ICoreCmsUserWeChatInfoServices _weChatInfoServices;
|
||||
private readonly IWeChatTransactionComponentOrderServices _tcOrderServices;
|
||||
|
||||
|
||||
|
||||
public TCOrderAfterSaleCreateSyncSubscribe(ICoreCmsUserWeChatInfoServices userWeChatInfoServices, ICoreCmsBillDeliveryServices billDeliveryServices, ICoreCmsOrderServices orderServices, ICoreCmsUserWeChatInfoServices weChatInfoServices, IWeChatTransactionComponentOrderServices tcOrderServices, ICoreCmsOrderItemServices orderItemServices)
|
||||
{
|
||||
_userWeChatInfoServices = userWeChatInfoServices;
|
||||
_billDeliveryServices = billDeliveryServices;
|
||||
_orderServices = orderServices;
|
||||
_weChatInfoServices = weChatInfoServices;
|
||||
_tcOrderServices = tcOrderServices;
|
||||
_orderItemServices = orderItemServices;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义交易组件-同步创建售后单
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
[Subscribe(RedisMessageQueueKey.TransactionComponentAfterSaleCreateSync)]
|
||||
private async Task TransactionComponentAfterSaleCreateSync(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
var orderModel = JsonConvert.DeserializeObject<CoreCmsOrder>(msg);
|
||||
if (orderModel is { scene: > 0 })
|
||||
{
|
||||
var tcOrderModel = await _tcOrderServices.QueryByClauseAsync(p => p.outOrderId == orderModel.orderId, true);
|
||||
if (tcOrderModel == null)
|
||||
{
|
||||
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.RedisMessageQueue, "自定义交易组件-同步创建售后单", "未查询到远程订单推送记录");
|
||||
return;
|
||||
}
|
||||
|
||||
var orderInfo = await _orderServices.QueryByClauseAsync(p => p.orderId == orderModel.orderId, true);
|
||||
if (orderInfo == null)
|
||||
{
|
||||
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.RedisMessageQueue, "自定义交易组件-同步创建售后单", "订单信息获取失败");
|
||||
return;
|
||||
}
|
||||
|
||||
////获取小程序认证
|
||||
//var accessToken = await new WeChatHelper().GetWxOpenAccessToken();
|
||||
////检查场景值是否在支付校验范围内
|
||||
////接口调用请求地址
|
||||
//var sceneUrl = WeChat.TransactionComponent.Api.Delivery.recieve(accessToken);
|
||||
|
||||
////组合请求
|
||||
//var sceneClient = new RestClient(sceneUrl);
|
||||
//var request = new RestRequest(RestSharp.Method.POST);
|
||||
|
||||
//request.AddHeader("Content-Type", "application/json");
|
||||
//request.AddJsonBody(new
|
||||
//{
|
||||
// out_order_id = orderModel.orderId,
|
||||
// openid = tcOrderModel.openid,
|
||||
//});
|
||||
//var response = await sceneClient.ExecuteAsync(request);
|
||||
//var result = JsonConvert.DeserializeObject<CheckSceneResult>(response.Content);
|
||||
|
||||
//if (result != null && result.errcode == 0)
|
||||
//{
|
||||
// NLogUtil.WriteAll(NLog.LogLevel.Info, LogType.RedisMessageQueue, "自定义交易组件-同步创建售后单", JsonConvert.SerializeObject(result));
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.RedisMessageQueue, "自定义交易组件-同步创建售后单", JsonConvert.SerializeObject(result));
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.RedisMessageQueue, "自定义交易组件-同步创建售后单", "订单获取失败");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var obj = new
|
||||
{
|
||||
wxOpenAppId = _wxOpenAppId,
|
||||
wxOpenAppSecret = _wxOpenAppSecret,
|
||||
msg
|
||||
};
|
||||
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.RedisMessageQueue, "自定义交易组件-同步创建售后单", JsonConvert.SerializeObject(obj), ex);
|
||||
throw;
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user