guoshuai 4 weeks ago
parent
commit
401968cd13

+ 3 - 3
src/main/java/com/qmrb/system/controller/OrderController.java

@@ -263,14 +263,14 @@ public class OrderController extends CommonController {
     ) throws MQBrokerException, RemotingException, UnsupportedEncodingException, InterruptedException, MQClientException {
         //todo 调用计费模块,计算是否有应付费用
         BigDecimal pendingAmount = BigDecimal.ZERO;
-        BarnRecordForm formData = barnRecordService.chargingByBarnId(id);
+        BarnRecordForm formData = barnRecordService.getFormData(id);
         if(formData != null){
             // 计算未支付金额
             pendingAmount = rulesService.calcuExpenses(formData.getId(),formData.getCarNumber(),isMonthlyCardMode);
         }
         if(formData != null && pendingAmount.compareTo(BigDecimal.ZERO) >0){
             ToCreateOrderVO toCreateOrderVO = new ToCreateOrderVO();
-            toCreateOrderVO.setTotal(formData.getPendingAmount().multiply(new BigDecimal(100)).intValueExact());
+            toCreateOrderVO.setTotal(pendingAmount.multiply(new BigDecimal(100)).intValueExact());
             toCreateOrderVO.setDescription("停车缴费");
             toCreateOrderVO.setOpenId(openId);
             Long orderId = IdUtil.getSnowflake().nextId();
@@ -283,7 +283,7 @@ public class OrderController extends CommonController {
                     .setGoodsName(toCreateOrderVO.getDescription())
                     .setPayStatus(SystemConstant.NUM_ZERO));
             return process(() -> orderService.createOrder(toolWxConfigService.findConf(),toCreateOrderVO));
-        }else if(formData != null && formData.getPendingAmount() != null && formData.getPendingAmount().compareTo(BigDecimal.ZERO) <= 0){
+        }else if(formData != null && pendingAmount.compareTo(BigDecimal.ZERO) <= 0){
             HashMap<String, Object> paramsMap = new HashMap<>();
             paramsMap.put("channelId",formData.getBarnId());
             paramsMap.put("carNumber",formData.getCarNumber());

+ 5 - 0
src/main/java/com/qmrb/system/service/impl/BarnRecordServiceImpl.java

@@ -267,6 +267,11 @@ public class BarnRecordServiceImpl extends ServiceImpl<BarnRecordMapper, BarnRec
         return list;
     }
 
+    /**
+     * 根据订单id查找停车记录
+     * @param orderId
+     * @return
+     */
     @Override
     public BarnRecordForm chargingByBarnId(Long orderId) {
         if(orderId == null){

+ 1 - 1
src/main/java/com/qmrb/system/service/impl/CarParkChargingRulesServiceImpl.java

@@ -136,7 +136,7 @@ public class CarParkChargingRulesServiceImpl extends ServiceImpl<CarParkCharging
 		CarParkChargingRules carParkChargingRules = parkChargingRules.get(0);
 
 		// 获取所有订单
-		List<Order> orderList = orderMapper.selectList(new LambdaQueryWrapper<Order>().eq(Order::getGoodId, recordId));
+		List<Order> orderList = orderMapper.selectList(new LambdaQueryWrapper<Order>().eq(Order::getGoodId, recordId).eq(Order::getPayStatus,1)); //查询已支付订单
 
 		// 示例计费规则
 		ParkingFeeCalculator.FeeRule feeRule = new ParkingFeeCalculator.FeeRule();

+ 2 - 0
src/main/java/com/qmrb/system/service/impl/OrderServiceImpl.java

@@ -289,6 +289,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                         //   更新计费金额,已收金额
                         BarnRecordForm barnRecordForm = barnRecordService.chargingByBarnId(Long.parseLong(orderNo));
                         Order order = this.getById(orderNo);
+                        // 支付金额
+                        BigDecimal amountsPayable = new BigDecimal(order.getAmountsPayable()).divide(new BigDecimal(100)); 
                         barnRecordForm.setReceivedAmount(barnRecordForm.getReceivedAmount().add(new BigDecimal(order.getAmountsPayable())));
                         barnRecordForm.setBillingStartTime(new Date());
                         barnRecordService.updateForm(barnRecordForm.getId(),barnRecordForm);