|
@@ -2,6 +2,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.UserOrderRefundDao;
|
|
@@ -15,12 +16,14 @@ import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.OrderStatusEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.TradeStatusEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.sdk.PaymentSdk;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.UserOrderDetailVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.UserOrderRefundVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.res.RefundCreateRes;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.cooleshow.common.service.IdGeneratorService;
|
|
|
import com.yonge.toolset.utils.string.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -46,6 +49,12 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
|
|
|
private UserOrderDetailService orderDetailService;
|
|
|
@Autowired
|
|
|
private CourseGroupService courseGroupService;
|
|
|
+ @Autowired
|
|
|
+ private PaymentSdk paymentSdk;
|
|
|
+ @Autowired
|
|
|
+ private IdGeneratorService idGeneratorService;
|
|
|
+ @Autowired
|
|
|
+ private UserOrderRefundPaymentService refundPaymentService;
|
|
|
|
|
|
//验证是否可以退款,获取退款金额信息
|
|
|
private static final Map<GoodTypeEnum, Function<OrderRefundReq, HttpResponseResult<RefundCreateRes>>> refundCreate = new HashMap<>();
|
|
@@ -124,8 +133,9 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
|
|
|
String join = StringUtil.join(detilIds, ",");
|
|
|
|
|
|
UserOrderRefund orderRefunds = new UserOrderRefund();
|
|
|
- orderRefunds.setUserId(refundReq.getUserId());
|
|
|
- orderRefunds.setOrderId(refundReq.getOrderId());
|
|
|
+ orderRefunds.setUserId(detail.getUserId());
|
|
|
+ orderRefunds.setOrderId(detail.getId());
|
|
|
+ orderRefunds.setOrderNo(detail.getOrderNo());
|
|
|
orderRefunds.setOredrDetilIds(join);
|
|
|
orderRefunds.setStatus(AuthStatusEnum.DOING);
|
|
|
orderRefunds.setApplyAmount(actualPrice);
|
|
@@ -164,8 +174,8 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
|
|
|
updateById(orderRefund);
|
|
|
|
|
|
if (authOperaReq.getPass()) {
|
|
|
- //通过调用
|
|
|
-
|
|
|
+ //通过调用退款接口
|
|
|
+ return doOrderRefund(orderRefund);
|
|
|
} else {
|
|
|
List<String> detilIds = Arrays.asList(oredrDetilIds.split(","));
|
|
|
for (String id : detilIds) {
|
|
@@ -183,4 +193,17 @@ public class UserOrderRefundServiceImpl extends ServiceImpl<UserOrderRefundDao,
|
|
|
return HttpResponseResult.succeed(true);
|
|
|
}
|
|
|
|
|
|
+ private HttpResponseResult<Boolean> doOrderRefund(UserOrderRefund orderRefund) {
|
|
|
+ UserOrderPayment successPayment = orderPaymentService.getOne(Wrappers.<UserOrderPayment>lambdaQuery()
|
|
|
+ .eq(UserOrderPayment::getOrderNo, orderRefund.getOrderNo())
|
|
|
+ .eq(UserOrderPayment::getStatus, TradeStatusEnum.succeeded)
|
|
|
+ );
|
|
|
+
|
|
|
+ //单号生成
|
|
|
+ Long refundOrderNo = idGeneratorService.generatorId("userOrder");
|
|
|
+
|
|
|
+ HttpResponseResult<Map<String, Object>> responseResult = paymentSdk.refundPayment(successPayment.getTransNo(), refundOrderNo.toString(), orderRefund.getActualAmount());
|
|
|
+
|
|
|
+ return HttpResponseResult.succeed(true);
|
|
|
+ }
|
|
|
}
|