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

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

@@ -828,6 +828,7 @@ namespace CoreCms.Net.Services
}
userId = orderInfo.userId;
type = orderInfo.orderType;
}
//::todo 校验支付方式是否存在

View File

@@ -129,8 +129,6 @@ namespace CoreCms.Net.Services
if (status == (int)GlobalEnumVars.BillRefundStatus.STATUS_REFUND)
{
//退款完成后的钩子
jm.msg = "退款单退款成功";
//如果前端传过来的退款方式和退款单上的退款方式一样的话,就说明是原路返回,试着调用支付方式的退款方法,如果不一样的话,就直接做退款单的退款状态为已退款就可以了
if (paymentCodeStr == info.paymentCode && paymentCodeStr != "offline")
@@ -152,7 +150,13 @@ namespace CoreCms.Net.Services
//退款同意,先发退款消息和钩子,下面原路返回可能失败,但是在业务上相当于退款已经退过了,只是实际的款项可能还没到账
//发送退款消息
await _messageCenterServices.SendMessage(info.userId, GlobalEnumVars.PlatformMessageTypes.RefundSuccess.ToString(), JObject.FromObject(info));
if (jm.status)
{
await _messageCenterServices.SendMessage(info.userId, GlobalEnumVars.PlatformMessageTypes.RefundSuccess.ToString(), JObject.FromObject(info));
//退款完成后的钩子
jm.msg = "退款单退款成功";
}
return jm;
}

View File

@@ -251,7 +251,7 @@ namespace CoreCms.Net.Services
else
{
jm.status = false;
jm.msg = "退款失败";
jm.msg = "退款失败" + response.ErrCodeDes;
jm.data = response;
}

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));
}
}
}