feat:正元退款支付流程
This commit is contained in:
1 parent
96208fd4d0
commit
61f63d6152
9 files changed
+46
-17
No files matched your search
+1
-1
@@ -27,7 +27,7 @@ public enum HardOrderTypeEnum {
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
public static final List<HardOrderTypeEnum> refundList = List.of(BELOW, RESERVE);
|
||||
public static final List<HardOrderTypeEnum> refundList = List.of(BELOW, RESERVE, FOREIGN_TICKET, ZY);
|
||||
|
||||
public static final List<HardOrderTypeEnum> payList = List.of(BELOW, RESERVE);
|
||||
|
||||
|
||||
+2
@@ -52,6 +52,8 @@ public interface HardAfterSaleService extends IService<HardAfterSaleEntity> {
|
||||
*/
|
||||
void refund(Long afterSaleId);
|
||||
|
||||
void refund(Long afterSaleId, String prefixStr);
|
||||
|
||||
/**
|
||||
* 同意售后
|
||||
*
|
||||
|
||||
+12
-5
@@ -8,6 +8,7 @@ import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
|
||||
import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardAfterSaleOperateTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardSaleStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.refund.HardSaleTypeEnum;
|
||||
@@ -79,10 +80,10 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
|
||||
.userId(dto.getUserId())
|
||||
.parentCarId(null)
|
||||
.sysType(null)
|
||||
.orderStatus(HardOrderStatusEnum.PAY.getType())
|
||||
.orderStatus(HardOrderStatusEnum.CREATE.getType())
|
||||
.merchantId(null)
|
||||
.orderType(HardOrderTypeEnum.ZY.getType())
|
||||
.payType(HardOrderTypeEnum.RESERVE.getType())
|
||||
.payType(HardPayTypeEnum.WALLET_CARD.getType())
|
||||
.orderSourceTypeId(null)
|
||||
.totalPrice(totalPrice)
|
||||
.extraPrice(0)
|
||||
@@ -118,21 +119,27 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
|
||||
try {
|
||||
// 校验订单是否可以退款
|
||||
HardOrderVo order = hardAfterSaleService.validateOrderCanRefund(dto.getOrderId());
|
||||
if (!ObjectUtil.equals(dto.getSerialNum(), order.getOrderNo())) {
|
||||
throw new RuntimeException("正元订单号不匹配");
|
||||
}
|
||||
// 用户
|
||||
UserInfo user = remoteUserService.getByUserId(order.getUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(user)) throw new RuntimeException("用户不存在");
|
||||
// 添加售后订单
|
||||
HardAfterSaleEntity saveObj = BeanUtils.toBean(dto, HardAfterSaleEntity.class);
|
||||
String refundCode = "hard_" + order.getId();
|
||||
String refundCode = "zy_" + order.getId();
|
||||
saveObj.setType(HardSaleTypeEnum.AFTER_SALE.getType());
|
||||
saveObj.setStatus(HardSaleStatusEnum.COMPLETE.getStatus());
|
||||
saveObj.setNo(refundCode);
|
||||
saveObj.setWay("10");
|
||||
saveObj.setOrderId(order.getId());
|
||||
saveObj.setRefundPrice(order.getPayPrice());
|
||||
saveObj.setUserId(order.getUserId());
|
||||
saveObj.setAuditUserId(null);
|
||||
saveObj.setAuditTime(LocalDateTime.now());
|
||||
saveObj.setAuditReason("后台退款");
|
||||
saveObj.setApplyReason("正元api退款");
|
||||
saveObj.setAuditReason("正元api退款");
|
||||
saveObj.setApplyDescription("正元api退款");
|
||||
hardAfterSaleService.save(saveObj);
|
||||
// 添加售后进度
|
||||
HardAfterSaleLogEntity saveLogObj = HardAfterSaleLogEntity.builder()
|
||||
@@ -145,7 +152,7 @@ public class HardThirdSelfZyServiceImpl implements HardThirdSelfZyService {
|
||||
.build();
|
||||
hardAfterSaleLogMapper.insert(saveLogObj);
|
||||
// 执行退款
|
||||
hardAfterSaleService.refund(saveObj.getId());
|
||||
hardAfterSaleService.refund(saveObj.getId(),"zy");
|
||||
// 退库存
|
||||
hardOrderService.fastenerInventory(order, YesNoEnum.NO);
|
||||
HardCallbackRefundVo result = new HardCallbackRefundVo();
|
||||
|
||||
+8
-1
@@ -209,12 +209,19 @@ public class HardAfterSaleServiceImpl extends ServiceImpl<HardAfterSaleMapper, H
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refund(Long afterSaleId) {
|
||||
getSelf().refund(afterSaleId, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refund(Long afterSaleId, String prefixStr) {
|
||||
HardAfterSaleEntity afterSale = baseMapper.selectById(afterSaleId);
|
||||
if (ObjectUtil.isEmpty(afterSale)) throw new RuntimeException("售后订单不存在");
|
||||
// 校验订单是否可以退款
|
||||
HardOrderVo order = validateOrderCanRefund(afterSale.getOrderId());
|
||||
// 生成退款单号
|
||||
String refundCode = "hard_" + order.getId();
|
||||
if (ObjectUtil.isEmpty(prefixStr)) prefixStr = "hard";
|
||||
String refundCode = prefixStr + "_" + order.getId();
|
||||
// 创建退款单
|
||||
WalletRechargeRefundDto hardRefundDto = WalletRechargeRefundDto.builder().walletId(order.getWalletId()).orderId(order.getId()).afterSaleId(afterSale.getId()).refundCode(refundCode).reason("订单退款").price(order.getPayPrice()).build();
|
||||
R<WalletRechargeVo> walletRefundResult = walletRechargeService.refund(hardRefundDto);
|
||||
|
||||
+4
-2
@@ -351,8 +351,10 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
|
||||
HardOrderEntity update = HardOrderEntity.builder().id(order.getId()).payTime(LocalDateTime.now()).orderStatus(HardOrderStatusEnum.PAY.getType()).payPrice(payPrice).build();
|
||||
baseMapper.updateById(update);
|
||||
// 父购物车订单表订单状态
|
||||
HardParentCarEntity updateParentCar = HardParentCarEntity.builder().id(order.getParentCarId()).orderStatus(HardOrderStatusEnum.PAY.getType()).build();
|
||||
hardParentCarServiceImpl.updateById(updateParentCar);
|
||||
if (ObjectUtil.isNotEmpty(order.getParentCarId())) {
|
||||
HardParentCarEntity updateParentCar = HardParentCarEntity.builder().id(order.getParentCarId()).orderStatus(HardOrderStatusEnum.PAY.getType()).build();
|
||||
hardParentCarServiceImpl.updateById(updateParentCar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-6
@@ -4,6 +4,7 @@
|
||||
<mapper namespace="com.bsd.pjcloud.hard.mapper.order.HardOrderMapper">
|
||||
<resultMap id="hardwareOrderMap" type="com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="orderNo" column="order_no"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="merchantId" column="merchant_id"/>
|
||||
<result property="hardId" column="hard_id"/>
|
||||
@@ -39,6 +40,7 @@
|
||||
|
||||
<sql id="selectA">
|
||||
select a.id,
|
||||
a.order_no,
|
||||
a.user_id,
|
||||
a.merchant_id,
|
||||
a.hard_id,
|
||||
@@ -194,13 +196,19 @@
|
||||
COALESCE(COUNT(0), 0) AS totalNum,
|
||||
COALESCE(SUM(a.pay_price), 0) AS totalMoney,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) THEN 1 ELSE 0 END), 0) AS totalNumYear,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS totalMoneyYear,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) THEN 1 ELSE 0 END), 0) AS totalNumMonth,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS totalMoneyMonth,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) AND DAY(a.create_time) = DAY(CURRENT_DATE()) THEN 1 ELSE 0 END), 0) AS totalNumDay,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) = MONTH(CURRENT_DATE()) AND DAY(a.create_time) = DAY(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS totalMoneyDay
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS
|
||||
totalMoneyYear,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) =
|
||||
MONTH(CURRENT_DATE()) THEN 1 ELSE 0 END), 0) AS totalNumMonth,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) =
|
||||
MONTH(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS totalMoneyMonth,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) =
|
||||
MONTH(CURRENT_DATE()) AND DAY(a.create_time) = DAY(CURRENT_DATE()) THEN 1 ELSE 0 END), 0) AS totalNumDay,
|
||||
COALESCE(SUM(CASE WHEN YEAR(a.create_time) = YEAR(CURRENT_DATE()) AND MONTH(a.create_time) =
|
||||
MONTH(CURRENT_DATE()) AND DAY(a.create_time) = DAY(CURRENT_DATE()) THEN a.pay_price ELSE 0 END), 0) AS
|
||||
totalMoneyDay
|
||||
FROM
|
||||
hard_order a
|
||||
hard_order a
|
||||
<where>
|
||||
a.del_flag = 0
|
||||
<if test="dto.orderStatusCodes != null and dto.orderStatusCodes.size() != 0">
|
||||
|
||||
+2
-2
@@ -98,8 +98,8 @@ public class ZyTest {
|
||||
@Test
|
||||
public void selfRefund() throws Exception {
|
||||
|
||||
String orderId = "1";
|
||||
String orderNo = "1";
|
||||
String orderId = "1897311229083856897";
|
||||
String orderNo = "01234567890123456789";
|
||||
|
||||
ZySelfGetTokenDto tokenParams = new ZySelfGetTokenDto();
|
||||
tokenParams.setAppid(zyConfig.getSelfAppId());
|
||||
|
||||
+2
@@ -2,6 +2,7 @@ package com.bsd.pjcloud.wallet.api.feign;
|
||||
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeRefundDto;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
@@ -17,6 +18,7 @@ public interface RemoteWalletRechargeService {
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/wallet-recharge/refund")
|
||||
R<WalletRechargeVo> refund(@RequestBody WalletRechargeRefundDto dto);
|
||||
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ public class WalletRechargeController {
|
||||
private final WalletRechargeService walletRechargeService;
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
@Inner
|
||||
@Operation(summary = "远程调用-退款", description = "远程调用-退款")
|
||||
@PostMapping("/refund")
|
||||
public R<WalletRechargeVo> refund(@Valid @RequestBody WalletRechargeRefundDto dto) {
|
||||
|
||||
Reference in new issue
Block a user