Procházet zdrojové kódy

修复骑手保证金bug

codingliang před 2 roky
rodič
revize
6d67f0fe78

+ 9 - 4
src/main/java/com/sqx/modules/errand/service/impl/ErrandComplaintServiceImpl.java

@@ -110,17 +110,19 @@ public class ErrandComplaintServiceImpl extends ServiceImpl<ErrandComplaintDao,
     @Transactional
     @Override
     public Result updateCustomerComplaint(Long complaintId, Integer complaintState) {
-        if(complaintState==1){
+        if (complaintState == 1) {
             //投诉通过,状态改为1
             ErrandComplaint errandComplaint = new ErrandComplaint();
             errandComplaint.setComplaintId(complaintId);
             errandComplaint.setComplaintState(1);
-            baseMapper.updateById(errandComplaint);
+
             //扣保证金
             ErrandComplaint errandComplaint1 = baseMapper.selectById(complaintId);
             UserEntity userEntity1 = userDao.selectById(errandComplaint1.getRiderUserId());
             BigDecimal deductMoney;
-
+            if (userEntity1.getCashDeposit().compareTo(BigDecimal.ZERO) <= 0){
+                return Result.error("师傅保证金暂无余额,无法扣除");
+            }
             if (errandComplaint1.getDeductMoney().doubleValue() > userEntity1.getCashDeposit().doubleValue()) {
                 //如果保证金不够,则保证金改为0
                 deductMoney = userEntity1.getCashDeposit();
@@ -128,6 +130,9 @@ public class ErrandComplaintServiceImpl extends ServiceImpl<ErrandComplaintDao,
                 //如果保证金足够,则扣除保证金
                 deductMoney = errandComplaint1.getDeductMoney();
             }
+            errandComplaint.setDeductMoney(deductMoney);
+            baseMapper.updateById(errandComplaint);
+
             UserEntity userEntity = new UserEntity();
             userEntity.setUserId(userEntity1.getUserId());
             userEntity.setCashDeposit(userEntity1.getCashDeposit().subtract(deductMoney));
@@ -139,7 +144,7 @@ public class ErrandComplaintServiceImpl extends ServiceImpl<ErrandComplaintDao,
             userMoneyDetails.setContent("被投诉订单,扣除保证金:" + deductMoney + "元!");
             userMoneyDetails.setType(2);
             userMoneyDetails.setClassify(1);
-            userMoneyDetails.setMoney(errandComplaint1.getDeductMoney());
+            userMoneyDetails.setMoney(deductMoney);
             userMoneyDetails.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
             userMoneyDetailsService.save(userMoneyDetails);