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

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
@@ -28,7 +28,6 @@ using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using CoreCms.Net.Utility.Helper;
using CoreCms.Net.WeChat.Service.HttpClients;
using CoreCms.Net.WeChat.Service.TransactionComponent.Enum;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
@@ -62,9 +61,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
private readonly ICoreCmsLogisticsServices _logisticsServices;
private readonly ICoreCmsPaymentsServices _paymentsServices;
private readonly ICoreCmsSettingServices _settingServices;
private readonly IWeChatTransactionComponentOrderServices _tcOrderServices;
private readonly ICoreCmsUserWeChatInfoServices _userWeChatInfoServices;
private readonly IWeChatTransactionComponentDeliveryCompanyServices _tcDeliveryCompanyServices;
private readonly IRedisOperationRepository _redisOperationRepository;
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
@@ -85,7 +82,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
, ICoreCmsLogisticsServices logisticsServices
, ICoreCmsBillPaymentsServices billPaymentsServices
, ICoreCmsPaymentsServices paymentsServices
, ICoreCmsSettingServices settingServices, IWeChatTransactionComponentOrderServices tcOrderServices, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IWeChatTransactionComponentDeliveryCompanyServices tcDeliveryCompanyServices, IRedisOperationRepository redisOperationRepository, ICoreCmsBillDeliveryServices billDeliveryServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, ICoreCmsOrderItemServices orderItemServices)
, ICoreCmsSettingServices settingServices, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IRedisOperationRepository redisOperationRepository, ICoreCmsBillDeliveryServices billDeliveryServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, ICoreCmsOrderItemServices orderItemServices)
{
_webHostEnvironment = webHostEnvironment;
_coreCmsOrderServices = coreCmsOrderServices;
@@ -97,9 +94,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
_billPaymentsServices = billPaymentsServices;
_paymentsServices = paymentsServices;
_settingServices = settingServices;
_tcOrderServices = tcOrderServices;
_userWeChatInfoServices = userWeChatInfoServices;
_tcDeliveryCompanyServices = tcDeliveryCompanyServices;
_redisOperationRepository = redisOperationRepository;
_billDeliveryServices = billDeliveryServices;
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
@@ -498,7 +493,6 @@ namespace CoreCms.Net.Web.Admin.Controllers
var storeList = await _storeServices.QueryAsync();
var logistics = await _logisticsServices.QueryListByClauseAsync(p => p.isDelete == false);
var deliveryCompany = await _tcDeliveryCompanyServices.GetCaChe();
var result = await _coreCmsOrderServices.GetOrderShipInfo(entity.id);
if (!result.status)
@@ -525,7 +519,6 @@ namespace CoreCms.Net.Web.Admin.Controllers
orderModel = result.data,
storeList,
logistics,
deliveryCompany
};
return jm;
@@ -1660,7 +1653,6 @@ namespace CoreCms.Net.Web.Admin.Controllers
}
#endregion
#region ============================================================
// POST: Api/CoreCmsOrder/DeleteOrder/10
/// <summary>
@@ -1724,8 +1716,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
return jm;
}
#endregion
#region ============================================================
// POST: Api/CoreCmsOrder/GetDetails/10
/// <summary>
@@ -1752,99 +1743,5 @@ namespace CoreCms.Net.Web.Admin.Controllers
}
#endregion
#region
// POST: Api/CoreCmsOrder/GetTcOrder/10
/// <summary>
/// 获取交易组件订单信息
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
[Description("获取交易组件订单信息")]
public async Task<AdminUiCallBack> GetTcOrder([FromBody] FMStringId entity)
{
var jm = new AdminUiCallBack();
var orderModel = await _coreCmsOrderServices.QueryByClauseAsync(p => p.orderId == entity.id);
if (orderModel == null)
{
jm.msg = "不存在此订单信息";
return jm;
}
var tcOrder = await _tcOrderServices.QueryByClauseAsync(p => p.outOrderId == entity.id);
if (tcOrder == null)
{
jm.msg = "不存在此订单交易组件推送记录";
return jm;
}
var weChatUserInfo = await _userWeChatInfoServices.QueryByClauseAsync(p => p.userId == orderModel.userId);
if (weChatUserInfo == null)
{
jm.msg = "用户微信数据拉取失败";
return jm;
}
//获取小程序认证
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
var request = new ShopOrderGetRequest();
request.AccessToken = accessToken;
request.OutOrderId = orderModel.orderId;
request.OpenId = weChatUserInfo.openid;
var response = await client.ExecuteShopOrderGetAsync(request);
var orderStatus = EnumHelper.EnumToList<OrderStatus>();
var deliveryTypeEnum = EnumHelper.EnumToList<DeliveryTypeEnum>();
jm.code = response.IsSuccessful() ? 0 : 1;
jm.msg = response.IsSuccessful() ? "获取成功" : response.ErrorMessage;
jm.data = new
{
response.Order,
orderStatus,
deliveryTypeEnum
};
jm.otherData = accessToken;
//更新拉取订单
if (response.Order is { OrderId: > 0 } && tcOrder.orderId == null)
{
await _tcOrderServices.UpdateAsync(
p => new WeChatTransactionComponentOrder() { orderId = response.Order.OrderId },
p => p.id == tcOrder.id && p.outOrderId == tcOrder.outOrderId);
}
if (response.Order is { OrderId: > 0 } && (response.Order.Status == 11 || response.Order.Status == 10) && (orderModel.payStatus == (int)GlobalEnumVars.OrderPayStatus.Yes || orderModel.payStatus == (int)GlobalEnumVars.OrderPayStatus.PartialYes))
{
var payment = await _billPaymentsServices.QueryByClauseAsync(p =>
p.sourceId == orderModel.orderId && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed);
if (payment != null)
{
var userInfo = await _userWeChatInfoServices.QueryByClauseAsync(p => p.userId == orderModel.userId);
//获取同步地址接口地址
var refreshRequest = new ShopOrderPayRequest();
refreshRequest.AccessToken = accessToken;
refreshRequest.OutOrderId = orderModel.orderId;
refreshRequest.OpenId = userInfo.openid;
refreshRequest.ActionType = 1;
refreshRequest.TransactionId = payment.tradeNo;
refreshRequest.PayTime = payment.createTime;
var refreshResponse = await client.ExecuteShopOrderPayAsync(refreshRequest);
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.RedisMessageQueue, "自定义交易组件-手动同步", JsonConvert.SerializeObject(refreshResponse));
}
}
return jm;
}
#endregion
}
}