| 
					
				 | 
			
			
				@@ -18,10 +18,7 @@ import com.qmrb.system.pojo.form.BarnRecordForm; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.form.PayOrderForm; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.query.PayOrderQuery; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.pojo.vo.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.qmrb.system.service.IBarnRecordService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.qmrb.system.service.OrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.qmrb.system.service.ToolWxConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.qmrb.system.service.UserService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.qmrb.system.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.utils.WxPayUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.wxpayback.api.CommonController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.qmrb.system.wxpayback.api.CommonResult; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -84,6 +81,9 @@ public class OrderController extends CommonController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private IBarnRecordService barnRecordService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ICarParkChargingRulesService rulesService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Value("${pickCarProducer.topic}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private String topic; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Value("${pickCarProducer.tags}") 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -243,18 +243,31 @@ public class OrderController extends CommonController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         orderService.closeOrder(toolWxConfigService.findConf(),outTradeNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Operation(summary = "根据岗亭端停车记录数据计费", security = {@SecurityRequirement(name = "Authorization")}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * 根据岗亭端停车记录数据计费取车 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param openId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws MQBrokerException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws RemotingException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws UnsupportedEncodingException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws InterruptedException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @throws MQClientException 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Operation(summary = "计费取车", security = {@SecurityRequirement(name = "Authorization")}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @GetMapping("/{id}/charging") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public CommonResult<?> pickUp( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             @Parameter(description = "岗亭端停车记录ID") @PathVariable Long id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             @ParameterObject String openId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ) throws MQBrokerException, RemotingException, UnsupportedEncodingException, InterruptedException, MQClientException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //todo 调用计费模块,计算是否有应付费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        BigDecimal bigDecimal = new BigDecimal(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal pendingAmount = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BarnRecordForm formData = barnRecordService.chargingByBarnId(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if(formData != null && formData.getPendingAmount() != null && formData.getPendingAmount().compareTo(BigDecimal.ZERO) >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(formData != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 计算未支付金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            pendingAmount = rulesService.calcuExpenses(formData.getId(),formData.getCarNumber()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(formData != null && pendingAmount.compareTo(BigDecimal.ZERO) >0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ToCreateOrderVO toCreateOrderVO = new ToCreateOrderVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             toCreateOrderVO.setTotal(formData.getPendingAmount().multiply(new BigDecimal(100)).intValueExact()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             toCreateOrderVO.setDescription("停车缴费"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -271,7 +284,7 @@ public class OrderController extends CommonController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return process(() -> orderService.createOrder(toolWxConfigService.findConf(),toCreateOrderVO)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }else if(formData != null && formData.getPendingAmount() != null && formData.getPendingAmount().compareTo(BigDecimal.ZERO) <= 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             HashMap<String, Object> paramsMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            paramsMap.put("channelId",formData.getOutChannelId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            paramsMap.put("channelId",formData.getBarnId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             paramsMap.put("carNumber",formData.getCarNumber()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 发送取车指令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             pickCarProducer.send(topic,tags, JSONUtil.toJsonStr(paramsMap)); 
			 |