Quellcode durchsuchen

自动扣费逻辑

qzyReal vor 2 Jahren
Ursprung
Commit
72b199584f

+ 18 - 3
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -107,7 +107,7 @@ public class OpenService {
             StaticLog.error("缓存入场图片:{}", carNo);
             IMAGE_CACHE.put(carNo, image);
         }
-       automaticPay.unbindRun(carNo);
+        automaticPay.unbindRun(carNo);
         TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
         Date now = new Date();
         TbCar tbCar = tbCarService.findByCardNo(carNo);
@@ -197,7 +197,7 @@ public class OpenService {
             if (dif > 0) {
                 RedisUtil.setByMINUTES(channel, carNo, 1);
                 log.error("请求返回:请缴停车费:{},{}元", carNo, dif);
-                automaticPay.run(null,tbBusinessCar.getCarNo(),1);
+                automaticPay.run(null, tbBusinessCar.getCarNo(), 1);
                 return ResultJson.error("请缴停车费" + dif + "元");
             } else {
                 freeOut(tbBusinessCar, now, channel, image);
@@ -207,7 +207,22 @@ public class OpenService {
             //有业务的车
             //1、分越重车和空车
             //空车是否收费
-            automaticPay.run(null,tbBusinessCar.getCarNo(),3);
+            //该车所有的业务都是到达卡口才进行扣费才会进入自动扣费
+            int autoPayCount = 0;
+            for (TbBusiness business : businessList) {
+                TbGoods tbGoods = tbGoodsService.getById(business.getGoodsId());
+                if (TbGoods.DeductionTypeEnum.OUT_KK.getCode().equals(tbGoods.getAutoDeductionType())) {
+                    autoPayCount++;
+                }
+            }
+            if (autoPayCount == businessList.size()) {
+                log.info("车辆到达卡口进行扣停车费和业务费:{}",carNo);
+                //自动缴费
+                automaticPay.run(null, tbBusinessCar.getCarNo(), 3);
+                tbDeductionBindService.autoUnbindCar(tbBusinessCar.getCarNo());
+                freeOut(tbBusinessCar, now, channel, image);
+                return ResultJson.success();
+            }
             if (TbItem.ItemTypeEnum.EMPTY_TYPE.getType().equals(carType)) {
                 boolean chinaCarPay = businessList.stream().anyMatch(tbBusiness -> {
                     TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());

+ 2 - 2
sp-server/src/main/java/com/pj/project/tb_account/AutomaticPay.java

@@ -79,7 +79,7 @@ public class AutomaticPay {
      * @param feeType    收费类型,1-只收停车费、2-只收业务费,3-停车和业务费
      */
     //TODO 不要在此方法写逻辑
-    @Async
+
     public void run(String businessId, String plate, Integer feeType) {
         this.feeType = feeType;
         task(businessId, plate, feeType);
@@ -199,7 +199,7 @@ public class AutomaticPay {
                     cars, null, null, now);
             createTbDeductionRecord(parkFeeDetailsList, tbAccount,
                     totalMoneyBig.subtract(tbBusiness.getItemPrice()), plate, bind.getCustomerName(), no);
-            deductionBindService.autoUnbindCar(cars);
+
         }
         StaticLog.info("预充值自动缴费成功!,退出收费程序:{}{}", businessId, tbAccount.getCustomerId());
     }

+ 13 - 5
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -350,11 +350,11 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         ids.forEach(id -> {
             TbBusiness business = this.getById(id);
             SpAdmin currAdmin = StpUserUtil.getAdmin();
-            String adminName = StrUtil.isNotEmpty(currAdmin.getNickname()) ? currAdmin.getNickname():currAdmin.getName();
+            String adminName = StrUtil.isNotEmpty(currAdmin.getNickname()) ? currAdmin.getNickname() : currAdmin.getName();
             business.setConfirmInput(1).setAdminConfirmInput(1)
                     .setConfirmInputTime(new Date())
                     .setConfirmInputBy(StpUserUtil.getAdmin().getName())
-                    .setConfirmBy(adminName).setConfirmByAdminId(currAdmin.getId()+"");
+                    .setConfirmBy(adminName).setConfirmByAdminId(currAdmin.getId() + "");
             this.updateById(business);
             List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(business.getId());
             String carNoStr = cars.stream().map(TbBusinessCar::getCarNo).collect(Collectors.joining("、"));
@@ -382,7 +382,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                                 .setPickCustomerName(tbCostomer.getName()).setPickTime(now)
                                 .setConfirm(1).setConfirmTime(now);
                         List<TbFeeDetails> feeDetailsList = tbFeeDetailsService.getByBusinessItemId(item.getId() + "");//重复交费会存在多个businessItemId
-                        if(feeDetailsList!=null) {
+                        if (feeDetailsList != null) {
                             for (TbFeeDetails feeDetails : feeDetailsList) {
                                 feeDetails.setPickCustomerName(item.getPickCustomerName());
                                 tbFeeDetailsService.updateById(feeDetails);
@@ -420,7 +420,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     }
                 }
             });
-            automaticPay.run(business.getId(),null,2); });
+            TbGoods tbGoods = tbGoodsService.getById(business.getGoodsId());
+            //只有改业务是在确认后扣费才需要执行自动扣费
+            if (TbGoods.DeductionTypeEnum.BUSINESS_OK.getCode().equals(tbGoods.getAutoDeductionType())){
+                automaticPay.run(business.getId(), null, 2);
+            }
+        });
     }
 
     public void adminConfirmPay(List<String> ids, String ticket) {
@@ -618,7 +623,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         tbBusiness.setCars(cars);
         return tbBusiness;
     }
-    /**获取业务信息,但只取装卸类型的收费项*/
+
+    /**
+     * 获取业务信息,但只取装卸类型的收费项
+     */
     public TbBusiness getZxBusinessById(String id) {
         TbBusiness tbBusiness = this.getById(id);
         List<TbBusinessItem> tbBusinessItems = tbBusinessItemService.findZxByBusinessId(id);