|
|
@@ -17,6 +17,7 @@ import shop.alien.mapper.*;
|
|
|
import shop.alien.util.common.UniqueRandomNumGenerator;
|
|
|
import shop.alien.util.common.constant.DiscountCouponEnum;
|
|
|
import shop.alien.util.common.constant.OrderStatusEnum;
|
|
|
+import shop.alien.util.common.constant.PaymentEnum;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
@@ -200,15 +201,37 @@ public class LifeUserOrderJob {
|
|
|
// 统计退款金额
|
|
|
BigDecimal totalRefundAmount = refundList.stream().map(x -> x.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
// 判断本次是否是全退 执行退款
|
|
|
- String refundResult = null;
|
|
|
- if (refundList.size() == orderCouponMiddleList.size()) {
|
|
|
- // 全退
|
|
|
- refundResult = alienStoreFeign.processRefund(order.getOrderNo(), totalRefundAmount.toString(), "过期自动退","");
|
|
|
+ String refundResult = "";
|
|
|
+ String partialRefundCode = "";
|
|
|
+ if (refundList.size() != orderCouponMiddleList.size()) {
|
|
|
+ partialRefundCode = UniqueRandomNumGenerator.generateUniqueCode(12);
|
|
|
+ }
|
|
|
+ String payMethod = order.getPayMethod();
|
|
|
+ String payType = "";
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ if("支付宝支付".equals(payMethod)) {
|
|
|
+ payType = PaymentEnum.ALIPAY.getType();
|
|
|
+ params.put("payType", payType);
|
|
|
+ params.put("outTradeNo", order.getOrderNo());
|
|
|
+ params.put("refundAmount", totalRefundAmount.toString());
|
|
|
+ params.put("refundReason", "过期自动退");
|
|
|
+ params.put("partialRefundCode",partialRefundCode);
|
|
|
} else {
|
|
|
- // TODO 本次部分退款
|
|
|
- String partialRefundCode = UniqueRandomNumGenerator.generateUniqueCode(12);
|
|
|
- refundResult = alienStoreFeign.processRefund(order.getOrderNo(), totalRefundAmount.toString(), "过期自动退",partialRefundCode);
|
|
|
+ payType = PaymentEnum.WECHAT_PAY.getType();
|
|
|
+ params.put("payType", payType);
|
|
|
+ params.put("outTradeNo", order.getOrderNo());
|
|
|
+ params.put("reason", "过期自动退");
|
|
|
+ params.put("refundAmount", String.valueOf(totalRefundAmount.multiply(new BigDecimal(100)).longValue()));
|
|
|
+ params.put("totalAmount", String.valueOf(new BigDecimal(order.getFinalPrice()).multiply(new BigDecimal(100)).longValue()));
|
|
|
+ }
|
|
|
+ // 调用支付策略
|
|
|
+ try {
|
|
|
+ refundResult = alienStoreFeign.refunds(params).getData().toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(String.format("LifeUserOrderJob requestRefund error, payType: %s, params: %s, error: %s", payType, params, e.getMessage()));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
if ("调用成功".equals(refundResult)) {
|
|
|
// 1.更新中间表状态
|
|
|
int updateNum = orderCouponMiddleMapper.update(null, new LambdaUpdateWrapper<OrderCouponMiddle>()
|