Jelajahi Sumber

1.店铺短信发发送前判断店铺余额是否充足;
2.店铺短信费用计算调整到服务费抽成之后;

codingliang 1 tahun lalu
induk
melakukan
8f37f74849

+ 16 - 7
src/main/java/com/sqx/modules/order/service/impl/AppAppOrderServiceImpl.java

@@ -30,6 +30,7 @@ import com.sqx.modules.app.dao.UserMoneyDao;
 import com.sqx.modules.app.dao.UserMoneyDetailsDao;
 import com.sqx.modules.app.entity.UserBrowse;
 import com.sqx.modules.app.entity.UserEntity;
+import com.sqx.modules.app.entity.UserMoney;
 import com.sqx.modules.app.entity.UserMoneyDetails;
 import com.sqx.modules.app.service.UserMoneyService;
 import com.sqx.modules.app.service.UserService;
@@ -584,6 +585,13 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
 
                 // 店铺信息
                 GoodsShop goodsShop = goodsShopDao.selectById(shopId);
+                // 查询短信发送费用
+                CommonInfo commonInfo = commonInfoService.findOne(421);
+                // 店铺钱包
+                UserMoney userMoney = userMoneyService.selectUserMoneyByUserId(goodsShop.getUserId());
+                if (userMoney.getMoney().compareTo(new BigDecimal(commonInfo.getValue())) < 0) {
+                    throw new SqxException("当前店铺余额不够,短信发送失败!");
+                }
 
                 // 发送短信并记录短信发送记录
                 SmsSendResult smsSendResult = smsTemplateService.sendSms(smsTemplateId, goodsShop.getPhone(), goodsShop.getShopName(), goodsShop.getShopId(), userPhone);
@@ -1796,6 +1804,11 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
             }
         }
 
+        // 店铺收入
+        BigDecimal shopMoney = sumMoney.multiply(shopRate);
+        shopMoney = shopMoney.setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal pingRate = sumMoney.subtract(shopMoney);
+
         // 商家配送短信服务费
         BigDecimal smsSendMoney = BigDecimal.ZERO;
         if(tbOrder.getAutoSendOrder()!=null && tbOrder.getAutoSendOrder() == 1) {
@@ -1805,18 +1818,14 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
                 if (ObjectUtil.isNotNull(smsSendLog)) {
                     // 查询短信发送费用
                     CommonInfo commonInfo = commonInfoService.findOne(421);
-
                     smsSendMoney = new BigDecimal(commonInfo.getValue());
-                    sumMoney = sumMoney.subtract(smsSendMoney);
+
+                    // 店铺收入-短信费用
+                    shopMoney = shopMoney.subtract(smsSendMoney);
                 }
             }
         }
 
-        BigDecimal shopMoney = sumMoney.multiply(shopRate);
-
-        shopMoney = (shopMoney.setScale(2, BigDecimal.ROUND_DOWN));
-        BigDecimal pingRate = sumMoney.subtract(shopMoney);
-
         //这里再判断 是否是商家优惠券  如果是商家优惠券  这笔钱商家承担
         if (shopIds != -1 && shopIds != 0) {
             shopMoney = shopMoney.subtract(couponMoney);