diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/Bonus.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/Bonus.java
index 1816a42b..3dffe6e0 100644
--- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/Bonus.java
+++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/Bonus.java
@@ -101,4 +101,5 @@ public class Bonus extends BaseEntity
@ApiModelProperty("是否需要加入到余额中")
private Boolean toBalance;
+ private Boolean byHand;
}
diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/BonusQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/BonusQuery.java
index 51bf5034..0f4c37bc 100644
--- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/BonusQuery.java
+++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/domain/BonusQuery.java
@@ -55,4 +55,7 @@ public class BonusQuery extends BonusVO {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime prePayTimeEnd;
+ @ApiModelProperty("是否有退款")
+ private Boolean hasRefund;
}
+
diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml
index 1ae252b0..9076e63e 100644
--- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml
+++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/mapper/BonusMapper.xml
@@ -25,7 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sb.pre_pay_time,
sb.payed_amount,
sb.wait_amount,
- sb.to_balance
+ sb.to_balance,
+ sb.by_hand
@@ -51,7 +52,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and sb.pre_pay_time >= #{query.prePayTimeStart}
and sb.pre_pay_time <= #{query.prePayTimeEnd}
and sb.to_balance = #{query.toBalance}
+ and sb.by_hand = #{query.byHand}
and date(sb.pay_time) = #{query.payDate}
+
+
+ and sb.refund_amount > 0
+
+
+ and sb.refund_amount = 0
+
+
and sb.bill_id in
@@ -250,6 +260,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
payed_amount,
wait_amount,
to_balance,
+ by_hand,
#{billId},
@@ -269,6 +280,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{payedAmount},
#{waitAmount},
#{toBalance},
+ #{byHand},
@@ -441,6 +453,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
payed_amount = #{data.payedAmount},
wait_amount = #{data.waitAmount},
to_balance = #{data.toBalance},
+ by_hand = #{data.byHand},
diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusService.java
index 03f8857e..cd1cc54e 100644
--- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusService.java
+++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/BonusService.java
@@ -176,4 +176,8 @@ public interface BonusService
List buildBonusListByCustom(TransactionBillVO bill);
+ /**
+ * 扣减分成方余额
+ */
+ int subtractBalance(Long id, BigDecimal amount);
}
diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java
index 28ea4ca4..ec4f7733 100644
--- a/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java
+++ b/smart-switch-service/src/main/java/com/ruoyi/ss/bonus/service/impl/BonusServiceImpl.java
@@ -448,6 +448,34 @@ public class BonusServiceImpl implements BonusService
return bonusList;
}
+ /**
+ * FIXME
+ * !!!! 重要 !!!!
+ * 临时用法,2025-01-17 发生大规模的退款账变BUG,需要临时处理
+ * 这个方法是用来直接修改数据库,所以需要谨慎使用
+ */
+ @Override
+ public int subtractBalance(Long id, BigDecimal amount) {
+ BonusVO bonus = this.selectBonusById(id);
+ ServiceUtil.assertion(bonus == null, "分成不存在");
+ ServiceUtil.assertion(bonus.getToBalance() == null || !bonus.getToBalance(), "分成未变动余额");
+ ServiceUtil.assertion(!BonusArrivalType.userList().contains(bonus.getArrivalType()), "该分成方不是用户");
+ ServiceUtil.assertion(bonus.getByHand(), "该分成已经手动处理过了");
+
+ Integer result = transactionTemplate.execute(status -> {
+ Bonus data = new BonusVO();
+ data.setId(id);
+ data.setByHand(true);
+ int update = this.updateBonus(data);
+ ServiceUtil.assertion(update != 1, "修改状态失败,请刷新后重试");
+
+ userService.subtractBalance(bonus.getArrivalId(), amount, false, String.format("订单退款:%s", bonus.getBillNo()), RecordBalanceBstType.RECHARGE, bonus.getBillId());
+
+ return update;
+ });
+ return result == null ? 0 : result;
+ }
+
private int batchUpdateAmount(List list) {
if (CollectionUtils.isEmptyElement(list)) {
return 0;
diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java
index ef6052cb..6b373a2b 100644
--- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java
+++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java
@@ -1672,6 +1672,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
refundBonus.setArrivalType(bonus.getArrivalType());
refundBonus.setBillNo(bonus.getBillNo());
refundBonus.setBillId(bonus.getBillId());
+ refundBonus.setToBalance(bonus.getToBalance());
refundList.add(refundBonus);
dividedAmount = dividedAmount.add(bonusRefundAmount);
@@ -1707,6 +1708,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
ServiceUtil.assertion(refund != 1, "可退款金额不足");
// 扣减分成方余额
+ ServiceUtil.assertion(bonus.getToBalance() == null, "数据异常,请联系管理员处理");
if (bonus.getToBalance() != null && bonus.getToBalance()) {
if (BonusArrivalType.userList().contains(bonus.getArrivalType())) {
userService.subtractBalance(bonus.getArrivalId(), bonus.getRefundAmount(), String.format("订单退款:%s", bonus.getBillNo()), RecordBalanceBstType.RECHARGE, bonus.getBillId());
diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/BonusController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/BonusController.java
index f7898866..b33cc85d 100644
--- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/BonusController.java
+++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/ss/BonusController.java
@@ -15,6 +15,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
import java.util.List;
/**
@@ -89,4 +90,12 @@ public class BonusController extends BaseController
return toAjax(bonusService.payBonusById(id));
}
+ @PreAuthorize("@ss.hasPermi('ss:bonus:subtract')")
+ @PutMapping("/{id}/subtract")
+ public AjaxResult subtract(@PathVariable Long id, @RequestParam BigDecimal amount) {
+ return error("当前接口不可用");
+// return toAjax(bonusService.subtractBalance(id, amount));
+ }
+
+
}