【修复】修复拼团失败退款失效的问题。

This commit is contained in:
大灰灰
2022-10-17 02:00:50 +08:00
parent d8d564e5dd
commit 2fc5aef172
9 changed files with 140 additions and 205 deletions

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Caching.AutoMate.RedisCache;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
@@ -44,12 +45,13 @@ namespace CoreCms.Net.Services
private readonly IUnitOfWork _unitOfWork;
private readonly IServiceProvider _serviceProvider;
private readonly ISysTaskLogServices _taskLogServices;
private readonly IRedisOperationRepository _redisOperationRepository;
public CoreCmsPinTuanRecordServices(IUnitOfWork unitOfWork
, ICoreCmsPinTuanRecordRepository dal
, ICoreCmsPinTuanRuleRepository pinTuanRuleRepository
, ICoreCmsUserRepository userRepository, IServiceProvider serviceProvider, ISysTaskLogServices taskLogServices)
, ICoreCmsUserRepository userRepository, IServiceProvider serviceProvider, ISysTaskLogServices taskLogServices, IRedisOperationRepository redisOperationRepository)
{
this._dal = dal;
base.BaseDal = dal;
@@ -58,6 +60,7 @@ namespace CoreCms.Net.Services
_userRepository = userRepository;
_serviceProvider = serviceProvider;
_taskLogServices = taskLogServices;
_redisOperationRepository = redisOperationRepository;
}
@@ -260,6 +263,7 @@ namespace CoreCms.Net.Services
var orderServices = container.ServiceProvider.GetService<ICoreCmsOrderServices>();
var billRefundServices = container.ServiceProvider.GetService<ICoreCmsBillRefundServices>();
var billLadingServices = container.ServiceProvider.GetService<ICoreCmsBillLadingServices>();
var jm = new WebApiCallBack();
@@ -273,9 +277,7 @@ namespace CoreCms.Net.Services
//获取开团数据
var teamList = await _dal.QueryListByClauseAsync(p => p.teamId == item.id);
//更新开团失败数据
await _dal.UpdateAsync(
p => new CoreCmsPinTuanRecord() { status = (int)GlobalEnumVars.PinTuanRecordStatus.Defeated },
p => p.teamId == item.id);
await _dal.UpdateAsync(p => new CoreCmsPinTuanRecord() { status = (int)GlobalEnumVars.PinTuanRecordStatus.Defeated }, p => p.teamId == item.id);
if (teamList == null || !teamList.Any()) continue;
{
@@ -298,7 +300,15 @@ namespace CoreCms.Net.Services
if (orderInfo.shipStatus == (int)GlobalEnumVars.OrderShipStatus.Yes)
{
//如果已经发货了,就不管了,手动退款吧
continue;
if (orderInfo.receiptType == (int)GlobalEnumVars.OrderReceiptType.SelfDelivery)
{
//清理掉未使用的提货单。
await billLadingServices.DeleteAsync(p => p.orderId == orderInfo.orderId);
}
else
{
continue;
}
}
if (orderInfo.payStatus == (int)GlobalEnumVars.OrderPayStatus.No)
@@ -310,40 +320,19 @@ namespace CoreCms.Net.Services
else
{
//已支付,生成退款单,并直接退款,之后,更改订单状态
var res = await billRefundServices.ToAdd(orderInfo.userId, orderInfo.orderId, 1,
orderInfo.payedAmount, "");
var res = await billRefundServices.ToAdd(orderInfo.userId, orderInfo.orderId, (int)GlobalEnumVars.OrderType.PinTuan, orderInfo.payedAmount, "");
if (res.status == false)
{
continue;
}
var refundInfo = await billRefundServices.QueryByClauseAsync(p =>
p.sourceId == orderInfo.orderId &&
p.status == (int)GlobalEnumVars.BillRefundType.Order && p.type == 1);
var refundInfo = await billRefundServices.QueryByClauseAsync(p => p.sourceId == orderInfo.orderId && p.status == (int)GlobalEnumVars.BillRefundType.Order && p.type == (int)GlobalEnumVars.OrderType.PinTuan);
if (refundInfo == null)
{
//没有找到退款单
continue;
}
//去退款
var toRefundResult = await billRefundServices.ToRefund(refundInfo.refundId, (int)GlobalEnumVars.BillRefundStatus.STATUS_REFUND);
//插入退款日志
var log = new SysTaskLog
{
createTime = DateTime.Now,
isSuccess = toRefundResult.status,
name = "定时任务取消拼团订单退款日志",
parameters = JsonConvert.SerializeObject(toRefundResult)
};
await _taskLogServices.InsertAsync(log);
//更新订单状态为已退款已完成
await orderServices.UpdateAsync(p => new CoreCmsOrder()
{
payStatus = (int)GlobalEnumVars.OrderPayStatus.Refunded,
status = (int)GlobalEnumVars.OrderStatus.Complete
}, p => p.orderId == orderInfo.orderId);
//走队列
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.RefundSubscribeQueue, JsonConvert.SerializeObject(refundInfo));
}
}
}