允许退款订单的手动缺人
This commit is contained in:
1 parent
3f14ef5007
commit
770d1e1547
5 files changed
+40
-12
No files matched your search
+2
-1
@@ -146,7 +146,8 @@ public class StoreOrderController {
|
||||
@PostMapping(value = "/refund")
|
||||
@PreAuthorize("@ss.hasPermission('order:store-order:update')")
|
||||
public CommonResult<Boolean> refund(@Validated @RequestBody StoreOrderRefundVO updateReqVO) {
|
||||
storeOrderService.orderRefund(updateReqVO.getId(),updateReqVO.getPayPrice(), 0, null);
|
||||
storeOrderService.orderRefund(updateReqVO.getId(), updateReqVO.getPayPrice(), 0, null,
|
||||
Boolean.TRUE.equals(updateReqVO.getManual()));
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -21,4 +21,7 @@ public class StoreOrderRefundVO {
|
||||
@NotNull(message = "退款金额不能为空")
|
||||
private BigDecimal payPrice;
|
||||
|
||||
@Schema(description = "是否手动确认退款成功", example = "false")
|
||||
private Boolean manual;
|
||||
|
||||
}
|
||||
+2
-1
@@ -89,8 +89,9 @@ public interface StoreOrderService {
|
||||
* @param price 金额
|
||||
* @param type ShopCommonEnum
|
||||
* @param salesId 售后id
|
||||
* @param manual 是否跳过支付平台并手动确认成功
|
||||
*/
|
||||
void orderRefund(Long id, BigDecimal price, Integer type, Long salesId);
|
||||
void orderRefund(Long id, BigDecimal price, Integer type, Long salesId, boolean manual);
|
||||
|
||||
/**
|
||||
* 订单30s内通知
|
||||
|
||||
+17
-7
@@ -342,10 +342,11 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
* @param price 金额
|
||||
* @param type ShopCommonEnum
|
||||
* @param salesId 售后id
|
||||
* @param manual 是否跳过支付平台并手动确认成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||
public void orderRefund(Long id, BigDecimal price, Integer type, Long salesId) {
|
||||
public void orderRefund(Long id, BigDecimal price, Integer type, Long salesId, boolean manual) {
|
||||
|
||||
StoreOrderDO storeOrderDO = storeOrderMapper.selectById(id);
|
||||
if (storeOrderDO == null) {
|
||||
@@ -361,10 +362,18 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
throw exception(ORDER_REFUNDED);
|
||||
}
|
||||
|
||||
if (storeOrderDO.getPayPrice().compareTo(price) < 0) {
|
||||
if (manual && !OrderInfoEnum.REFUND_STATUS_1.getValue().equals(storeOrderDO.getRefundStatus())) {
|
||||
throw exception(ORDER_REFUND_NOT);
|
||||
}
|
||||
|
||||
if (price.signum() <= 0 || storeOrderDO.getPayPrice().compareTo(price) < 0) {
|
||||
throw exception(ORDER_PRICE_ERROR);
|
||||
}
|
||||
|
||||
if (manual && PayTypeEnum.YUE.getValue().equals(storeOrderDO.getPayType())) {
|
||||
throw exception(new ErrorCode(999996, "余额支付订单请使用原路退款"));
|
||||
}
|
||||
|
||||
storeOrderDO.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue());
|
||||
storeOrderDO.setRefundPrice(price);
|
||||
|
||||
@@ -373,12 +382,12 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
||||
BigDecimal balance = userQueryVo.getNowMoney();
|
||||
//根据支付类型不同退款不同
|
||||
if (PayTypeEnum.YUE.getValue().equals(storeOrderDO.getPayType())) {
|
||||
if (!manual && PayTypeEnum.YUE.getValue().equals(storeOrderDO.getPayType())) {
|
||||
//退款到余额
|
||||
userService.incMoney(storeOrderDO.getUid(), price);
|
||||
balance = balance.add(price);
|
||||
|
||||
} else if (PayTypeEnum.WEIXIN.getValue().equals(storeOrderDO.getPayType())) {
|
||||
} else if (!manual && PayTypeEnum.WEIXIN.getValue().equals(storeOrderDO.getPayType())) {
|
||||
if(isDemo){
|
||||
throw exception(new ErrorCode(888888,"演示模式没有配置证书无法微信退款的哦!"));
|
||||
}
|
||||
@@ -406,7 +415,7 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
}
|
||||
}
|
||||
storeOrderDO.setOutTradeNo(orderSn);
|
||||
}else if (PayTypeEnum.ALI.getValue().equals(storeOrderDO.getPayType())){
|
||||
}else if (!manual && PayTypeEnum.ALI.getValue().equals(storeOrderDO.getPayType())){
|
||||
throw exception(new ErrorCode(999997,"支付宝暂时不支持退款"));
|
||||
}
|
||||
storeOrderMapper.updateById(storeOrderDO);
|
||||
@@ -415,9 +424,10 @@ public class StoreOrderServiceImpl implements StoreOrderService {
|
||||
BillDetailEnum.TYPE_5.getValue(),
|
||||
price.doubleValue(),
|
||||
balance.doubleValue(),
|
||||
"订单退款到余额" + price + "元", storeOrderDO.getId().toString(),orderSn);
|
||||
(manual ? "手动确认退款" : "订单退款") + price + "元", storeOrderDO.getId().toString(),orderSn);
|
||||
storeOrderStatusService.create(storeOrderDO.getUid(), storeOrderDO.getId(),
|
||||
OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(), "退款给用户:" + price + "元");
|
||||
OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(),
|
||||
(manual ? "管理员手动确认已退款:" : "退款给用户:") + price + "元");
|
||||
|
||||
//退库存
|
||||
this.regressionStock(storeOrderDO,0);
|
||||
|
||||
Reference in new issue
Block a user