允许退款订单的手动缺人
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);
|
||||
|
||||
@@ -19,7 +19,13 @@
|
||||
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="submitForm(false)" type="primary" :disabled="formLoading">原路退款</el-button>
|
||||
<el-button
|
||||
v-if="formData.payType !== 'yue'"
|
||||
@click="submitForm(true)"
|
||||
type="warning"
|
||||
:disabled="formLoading"
|
||||
>手动确认退款成功</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
@@ -112,16 +118,23 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
const submitForm = async (manual: boolean) => {
|
||||
// 校验表单
|
||||
if (!formRef) return
|
||||
const valid = await formRef.value.validate()
|
||||
if (!valid) return
|
||||
if (manual) {
|
||||
try {
|
||||
await message.confirm('请确认退款款项已通过其他方式退还给用户,此操作不会调用支付平台且不可撤销。')
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
}
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as StoreOrderApi.StoreOrderVO
|
||||
await StoreOrderApi.rufundStoreOrder(data)
|
||||
await StoreOrderApi.rufundStoreOrder({ ...data, manual })
|
||||
message.success(t('common.updateSuccess'))
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
|
||||
Reference in new issue
Block a user