Browse Source

实现园区内扫码支付

qzyReal 2 years ago
parent
commit
56033ecf73
30 changed files with 580 additions and 477 deletions
  1. 29 6
      app-ui/pages/wx/pay.vue
  2. 1 1
      sp-admin/sa-frame/com/sa-item.vue
  3. 6 0
      sp-admin/sa-frame/menu-list-sp.js
  4. 0 2
      sp-admin/sa-view/tb-business-car/tb-business-car-info.html
  5. 1 1
      sp-admin/sa-view/tb-business/tb-car-disincle-add.html
  6. 7 6
      sp-admin/sa-view/tb-business/tb-car-disincle-edit.html
  7. 42 12
      sp-admin/sa-view/tb-fee-statistics/tb-fee-details-list.html
  8. 0 6
      sp-admin/static/sa.js
  9. 10 1
      sp-server/pom.xml
  10. 14 7
      sp-server/src/main/java/com/pj/api/jh/service/JhService.java
  11. 6 15
      sp-server/src/main/java/com/pj/api/open/service/OpenService.java
  12. 13 9
      sp-server/src/main/java/com/pj/api/service/ApiService.java
  13. 24 22
      sp-server/src/main/java/com/pj/api/wx/service/WxService.java
  14. 2 2
      sp-server/src/main/java/com/pj/project/tb_account/AutomaticPay.java
  15. 84 87
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java
  16. 1 1
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCar.java
  17. 4 0
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.java
  18. 39 15
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.xml
  19. 16 69
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java
  20. 52 72
      sp-server/src/main/java/com/pj/project/tb_business_item/TbBusinessItemService.java
  21. 11 4
      sp-server/src/main/java/com/pj/project/tb_costomer/TbCostomerService.java
  22. 11 0
      sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsController.java
  23. 2 0
      sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsMapper.java
  24. 33 0
      sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsMapper.xml
  25. 140 122
      sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsService.java
  26. 19 8
      sp-server/src/main/java/com/pj/project/tb_invoice_info/TbInvoiceInfoService.java
  27. 1 0
      sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrder.java
  28. 1 1
      sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrderService.java
  29. 2 0
      sp-server/src/main/java/com/pj/project/tb_order/TbOrder.java
  30. 9 8
      sp-server/src/main/resources/application-dev.yml

+ 29 - 6
app-ui/pages/wx/pay.vue

@@ -132,6 +132,7 @@
 				openid: '',
 				carsSelect: [],
 				itemSelect: [],
+				businessCarId:'',
 				businessSelect: [],
 				goodsName: '',
 				businessNos: '',
@@ -243,6 +244,29 @@
 					});
 				})
 			},
+			buildDesc(){
+				let itemSelect=this.itemSelect;
+				let itemList=this.item.list;
+				let descArray=[];
+				if(this.carsSelect&&this.carsSelect.length>0){
+					descArray.push('停车费');
+				}
+				if(this.w){
+					descArray.push('过磅费');
+				}
+				for(let i in itemSelect){
+					let id=itemSelect[i];
+					for(let j in itemList){
+						if(itemList[j].id==id){
+							descArray.push(itemList[j].name);
+						}
+					}
+				}
+				let carIds = this.carsSelect
+				let carNos = this.cars.map(obj => obj.carNo).join('、');
+				let desc='A1-'+carNos+'-'+descArray.join('-');
+				return desc;
+			},
 			confirmPayFn() {
 				let carIds = this.carsSelect
 				let cars = this.cars.filter(obj => carIds.indexOf(obj.id) !== -1);
@@ -251,6 +275,7 @@
 				let businessSelect = this.businessSelect;
 				let openid = this.openid ? this.openid : uni.getStorageSync('openid')
 				let p = {
+					businessCarId:this.businessCarId,
 					w:this.w,
 					b: businessSelect.length > 0 ? this.item.businessId : '',
 					c: JSON.stringify(cars.map(obj => {
@@ -271,16 +296,11 @@
 					openid: openid
 				}
 				
-				let con = 'A1-'+carNos+'-' + carBusinessNo;
 				let tradeType = 'PORT_PARKING_FEE';
 				if (carIds.length == 0 || businessSelect.length > 0) { //交业务费
-					con = 'A1-' +carNos+'-'+ this.goodsName + '-' + this.businessNos;
 					tradeType = 'PORT_OPERATION_FEE';
 				}
-				if(p.money==p.w.price){
-					con='A1-'+carNos+'-' +'过磅费';
-				}
-				p.desc = con;
+				p.desc = this.buildDesc();
 				p.businessType = tradeType;
 				p.calculateId = this.item.calculateId;
 				this.$common.showLoading('正在请求...');
@@ -344,6 +364,8 @@
 				})
 			},
 			groupChange(carId) {
+				console.log(carId);
+				this.businessCarId=carId;
 				this.$api.getBusinessMoney({
 					carId: carId,
 					state: this.state
@@ -353,6 +375,7 @@
 						this.$common.toast(resp.msg);
 						return;
 					}
+				
 					let data = resp.data;
 					let cars = data.carList;
 					// this.manager=data.manager;

+ 1 - 1
sp-admin/sa-frame/com/sa-item.vue

@@ -219,7 +219,7 @@
                    :current-page.sync="curr"
                    :page-size.sync="size"
                    :total="total"
-                   :page-sizes="sizes || [1, 10, 20, 30, 40, 50, 100]"
+                   :page-sizes="sizes || [1, 10, 20, 30, 40, 50, 100,500]"
                    @current-change="changePage()"
                    @size-change="changePage()">
     </el-pagination>

+ 6 - 0
sp-admin/sa-frame/menu-list-sp.js

@@ -55,6 +55,12 @@ window.menuList.unshift({
 				url: 'sa-view-sp/sp-apilog/sys-log.html',
 				info: '记录系统运行日志'
 			},
+			{
+				id: 'sys-channel-application',
+				name: '道闸系统',
+				url: 'sa-view/sys-channel-application/sys-channel-application-list.html',
+				info: '道闸系统'
+			},
 		]
 	},
 

+ 0 - 2
sp-admin/sa-view/tb-business-car/tb-business-car-info.html

@@ -91,8 +91,6 @@
 										<sa-td name="企业" prop="pickCustomerName" width="170"></sa-td>
 										<sa-td name="业务项" prop="goodsName" width="160"></sa-td>
 										<sa-td name="费用(元)" prop="itemPrice" width="120"></sa-td>
-										<sa-td name="确认" prop="adminConfirmInput" type="enum" :jv="{1: '已确认', 0: '未确认'}"
-											width="130"></sa-td>
 										<sa-td name="已支付(元)" prop="payMoney" width="140"></sa-td>
 										<sa-td width="160" name="创建时间" prop="createTime" width="140"></sa-td>
 									</el-table>

+ 1 - 1
sp-admin/sa-view/tb-business/tb-car-disincle-add.html

@@ -124,7 +124,7 @@
 						<el-row>
 							<el-card class="box-card">
 								<div slot="header" class="clearfix">
-									<span>业务车辆</span>
+									<span>业务车辆<span style="color: red;">(注:录入货物堆存业务时,车牌号需是虚拟车牌)</span></span>
 									<el-button style="float: right;" icon="el-icon-plus" type="primary"
 										@click="showAddModal" v-if="goods.mulCar==1||car.list.length==0">添加
 									</el-button>

+ 7 - 6
sp-admin/sa-view/tb-business/tb-car-disincle-edit.html

@@ -122,7 +122,7 @@
 						<el-row>
 							<el-card class="box-card">
 								<div slot="header" class="clearfix">
-									<span>业务车辆</span>
+									<span>业务车辆<span style="color: red;">(注:录入货物堆存业务时,车牌号需是虚拟车牌)</span></span>
 									<el-button style="float: right;" icon="el-icon-plus" type="primary"
 										@click="showAddModal" v-if="goods.mulCar==1||car.list.length==0">添加
 									</el-button>
@@ -203,9 +203,10 @@
 												v-if="(type.itemAlias&&(type.itemAlias=='coldTruck'||type.itemAlias.indexOf('Store')>-1))">
 												<label class="c-label" v-if="type.itemAlias.indexOf('Store')>-1">
 													<span style="color: red;">*</span>存柜时间:</label>
-													<label class="c-label" v-else>
-														<span style="color: red;">*</span>开始时间:</label>
-												<el-date-picker type="datetime" disabled v-model="type.coldStartTime"></el-date-picker>
+												<label class="c-label" v-else>
+													<span style="color: red;">*</span>开始时间:</label>
+												<el-date-picker type="datetime" disabled
+													v-model="type.coldStartTime"></el-date-picker>
 											</div>
 											<div style="width: 360px;padding-bottom: 20px;"
 												v-if="type.itemAlias&&type.itemAlias=='coldTruck'">
@@ -293,7 +294,7 @@
 						goodsName: '', // 商品
 					}, // 实体对象
 					partnerDis: false,
-					customerDis:false,
+					customerDis: false,
 					customerList: [],
 					partnerList: [],
 					carList: [],
@@ -652,7 +653,7 @@
 							if (arr.length > 0) {
 								this.customerDis = true;
 								this.m.customerId = id;
-								this.m.customerName=arr[0].name
+								this.m.customerName = arr[0].name
 							}
 						}.bind(this));
 					},

+ 42 - 12
sp-admin/sa-view/tb-fee-statistics/tb-fee-details-list.html

@@ -16,12 +16,13 @@
 		<script src="../../static/sa.js"></script>
 	</head>
 	<style>
-		@page{
-		
-		      size: portrait; /* 纵向 */
-		       margin:1.5cm 2.5cm 1.5cm 2.5cm; * 边距 上右下左 */
-		
-		    }
+		@page {
+
+			size: portrait;
+			/* 纵向 */
+			margin: 1.5cm 2.5cm 1.5cm 2.5cm;
+			* 边距 上右下左 */
+		}
 
 		.keyButton.el-button {
 			width: 100%;
@@ -231,6 +232,7 @@
 				},
 				el: '.vue-box',
 				data: {
+					count:0,
 					p: { // 查询参数  
 						id: '', // 主键 
 						businessNo: '', // 业务单号 
@@ -489,7 +491,7 @@
 						let ids = sa.getArrayField(selection, 'id');
 						var str = '';
 						if (selection.length > 0) {
-							this.p.ids=ids.join(',');
+							this.p.ids = ids.join(',');
 							str = '所选项目';
 						} else {
 							if (this.selectTime != null && this.selectTime.length != 0) {
@@ -499,7 +501,7 @@
 
 							var beginTime = this.selectTimeRange.beginTime;
 							var endTime = this.selectTimeRange.endTime;
-							if(!beginTime&&!endTime){
+							if (!beginTime && !endTime) {
 								sa.error('导出时间必选');
 								return;
 							}
@@ -541,21 +543,49 @@
 								str += '车型为:' + itemName;
 							}
 						}
-						this.p.beginTime=beginTime;
-						this.p.endTime=endTime;
+						this.p.beginTime = beginTime;
+						this.p.endTime = endTime;
 						this.$confirm('确定导出' + str + '的数据?', '提示', {
 							confirmButtonText: '确定',
 							cancelButtonText: '取消',
 							type: 'warning'
 						}).then(() => {
+							let uuid=new Date().getTime();
+							this.p.uuid=uuid;
 							sa.ajax('/TbFeeDetails/export/details', sa.removeNull(this.p),
 								function(resp) {
-									window.open(resp.data);
+									sa.loading('正在导出....');
+									this.count=0
+									this.checkExportUrl(uuid);
 								}.bind(this));
 						}).catch(() => {
 
 						});
 					},
+					checkExportUrl(uuid) {
+						sa.ajaxNoLoading('/TbFeeDetails/export/details/path?uuid=' + uuid,
+							function(resp) {
+								let url = resp.data;
+								if (url) {
+									sa.hideLoading();
+									window.location.href = url;
+								} else {
+									let count=this.count;
+									if(count>=30){
+										sa.error('导出超时');
+										sa.hideLoading();
+										return;
+									}
+									setTimeout(() => {
+										this.count=count+1
+										this.checkExportUrl(uuid);
+									}, 1000)
+								}
+
+							}.bind(this));
+
+
+					},
 					// 刷新
 					f5: function() {
 						if (this.selectTime != null && this.selectTime.length != 0) {
@@ -606,4 +636,4 @@
 			})
 		</script>
 	</body>
-</html>
+</html>

+ 0 - 6
sp-admin/static/sa.js

@@ -120,11 +120,6 @@ var sa = {
 		// 将调用者的配置和默认配置合并
 		cfg = sa.extendJson(cfg, defaultCfg);
 
-		// 开始显示loading图标
-		if (cfg.msg != null) {
-			sa.loading(cfg.msg);
-		}
-
 		// 开始请求ajax
 		return $.ajax({
 			url: cfg.baseUrl + url,
@@ -144,7 +139,6 @@ var sa = {
 			},
 			success: function(res) {
 				setTimeout(function() {
-					sa.hideLoading();
 					// 如果相应的处理函数存在
 					if (cfg['success' + res.code] != undefined) {
 						return cfg['success' + res.code](res);

+ 10 - 1
sp-server/pom.xml

@@ -94,8 +94,17 @@
 	        <groupId>cn.dev33</groupId>
 	        <artifactId>sa-token-dao-redis-jackson</artifactId>
 		    <version>1.28.0</version>
+			<exclusions>
+				<exclusion>
+					<groupId>io.lettuce</groupId>
+					<artifactId>lettuce-core</artifactId>
+				</exclusion>
+			</exclusions>
 	    </dependency>
-
+		<dependency>
+			<groupId>redis.clients</groupId>
+			<artifactId>jedis</artifactId>
+		</dependency>
         <!-- 工具类大全 - 在线文档:https://hutool.cn/docs/#/ -->
         <dependency>
             <groupId>cn.hutool</groupId>

+ 14 - 7
sp-server/src/main/java/com/pj/api/jh/service/JhService.java

@@ -19,11 +19,14 @@ import com.pj.current.config.MyConfig;
 import com.pj.current.config.PartConfig;
 import com.pj.current.config.WxConfig;
 import com.pj.current.task.TaskService;
+import com.pj.project.tb_business_car.TbBusinessCar;
+import com.pj.project.tb_business_car.TbBusinessCarService;
 import com.pj.project.tb_order.TbOrder;
 import com.pj.project.tb_order.TbOrderService;
 import com.pj.project4sp.global.BusinessException;
 import com.pj.utils.sg.AjaxError;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -65,7 +68,8 @@ public class JhService {
     @Resource
     private TbOrderService tbOrderService;
     @Resource
-    private TaskService taskService;
+    @Lazy
+    private TbBusinessCarService tbBusinessCarService;
 
 
     public Map<String, ?> initPay(HttpServletRequest request) throws Exception {
@@ -77,22 +81,23 @@ public class JhService {
             throw new BusinessException("金额不正确");
         }
         String openid = request.getParameter("openid");
+        String businessCarId = request.getParameter("businessCarId");
         String calculateId = request.getParameter("calculateId");
         String desc = handlerDesc(request.getParameter("desc"));
-        String businessId = request.getParameter("b");
+        String b = request.getParameter("b");
         String c = request.getParameter("c");
         String a = request.getParameter("a");
         String w = request.getParameter("w");
         String businessType = request.getParameter("businessType");
         Attach atchMap = new Attach();
-        atchMap.setC(c).setB(businessId).setA(a).setW(w);
+        atchMap.setC(c).setB(b).setA(a).setW(w);
         String attchStr = JSONUtil.toJsonStr(atchMap);
         TbOrder dbOrder = tbOrderService.find30Seconds(attchStr, LocalDateTime.now().minusSeconds(wxConfig.getLimitPaySeconds()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
         if (dbOrder != null && !StrUtil.equals(dbOrder.getOpenid(), openid)) {
             throw new Exception("其他人正在付款....");
         }
         TbOrder successOrder = tbOrderService.findSuccessOrder(attchStr);
-        if (successOrder != null && StrUtil.contains(attchStr, "b")) {
+        if (successOrder != null && StrUtil.contains(attchStr, b)) {
             throw new Exception("业务订单已支付....");
         }
         String out_trade_no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + RandomUtil.randomNumbers(6);
@@ -130,17 +135,19 @@ public class JhService {
             JSONObject object = JSONUtil.parseObj(payMessage);
             object.set("outTradeNo", out_trade_no);
             TbOrder tbOrder = new TbOrder();
-            tbOrder.setAttach(attchStr)
+            tbOrder.setAttach(attchStr).setBusinessCarId(businessCarId)
                     .setCalculateId(calculateId)
                     .setOpenid(openid)
                     .setOrderTime(new Date())
                     .setOutTradeNo(out_trade_no).setPrice(money);
             tbOrderService.save(tbOrder);
             // taskService.addTask(new CheckPayStatusTask(RandomUtil.randomNumbers(12), 2000, out_trade_no));
+            TbBusinessCar last=tbBusinessCarService.getById(businessCarId);
+            log.info("last11111------>{}",JSONUtil.toJsonStr(last));
             return BeanUtil.beanToMap(object);
         }
-        throw new Exception("生成订单失败");
-        //  return new HashMap<>();
+        throw new AjaxError("生成订单失败");
+//          return new HashMap<>();
     }
 
     private String handlerDesc(String desc) {

+ 6 - 15
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -122,7 +122,6 @@ public class OpenService {
             log.error("入场返回:{}", msg);
             return ResultJson.error(msg);
         }
-        // automaticPay.unbindRun(carNo);
         TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
         Date now = new Date();
         TbCar tbCar = tbCarService.findByCardNo(carNo);
@@ -229,7 +228,7 @@ public class OpenService {
             //无业务车辆===>计算停车费
             //如果已经支付过,则从支付时间算起,重新计算停车费
             Date inTime = tbBusinessCar.getRealInTime();
-            if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())) {
+            if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())&&tbBusinessCar.getPayTime()!=null) {
                 inTime = tbBusinessCar.getPayTime();
             }
             IOrderPriceRes res = tbBusinessService.getPartMoney(inTime, now, carNo, tbBusinessCar.getColor());
@@ -258,10 +257,10 @@ public class OpenService {
                 return ResultJson.success();
             }
         } else {
-            //有业务的车--->都要交停车费
+            //有业务的车--->都要交停车费====>除了大头车,拦车
             //该车所有的业务都是到达卡口才进行扣费才会进入自动扣费
             Date inTime = tbBusinessCar.getRealInTime();
-            if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())) {
+            if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())&&tbBusinessCar.getPayTime()!=null) {
                 inTime = tbBusinessCar.getPayTime();
             }
             partMoneyRes = tbBusinessService.getPartMoney(inTime, now, carNo, tbBusinessCar.getColor());
@@ -281,17 +280,9 @@ public class OpenService {
             if (businessItems.isEmpty()) {
                 continue;
             }
-            boolean pay = tbBusiness.getPayMoney().doubleValue() > 0;
-            //柜车、栏车 则取对应的入场和离场时间为开始结束时间
-            businessItems.stream()
-                    .filter(item -> StrUtil.equals(item.getItemAlias(), SystemObject.config.getCabinetCar()))
-                    .forEach(item -> {
-                        item.setColdStartTime(tbBusinessCar.getRealInTime()).setColdEndTime(now);
-                        //堆存业务的车辆====>免停车费
-                        // tbBusinessCar.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType()).setPay(1).setMoney(BigDecimal.ZERO);
-                        // partMoneyRes.setTotalOrderPrice(BigDecimal.ZERO);
-                        tbBusinessItemService.updateById(item);
-                    });
+            //是否支付完
+            boolean pay = businessItems.stream().noneMatch(item -> item.getPayStatus() == 0);
+
             TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
             //重车离场限制
             int weiCarLeave = tbGoods.getVietnamCarLeave();

+ 13 - 9
sp-server/src/main/java/com/pj/api/service/ApiService.java

@@ -124,15 +124,19 @@ public class ApiService {
             return Collections.emptyList();
         }
         carNo = carNo.toUpperCase();
-        //有业务的车
-        List<TbBusinessCar> businessCarList = tbBusinessCarService.searchForPayCar(carNo);
-        //无业务车
-        List<TbBusinessCar> noBusinessCarList = tbBusinessCarService.findNotPayByCarNo(carNo);
-        businessCarList.addAll(noBusinessCarList);
-        //地磅未付费车
-        List<TbBusinessCar> wCarList = tbBusinessCarService.findNoPayWeightCar(carNo);
-        businessCarList.addAll(wCarList);
-        return businessCarList.stream().map(tbBusinessCar -> {
+        //1、没有离场的车
+        List<TbBusinessCar> list= tbBusinessCarService.findNotOutCarLike(carNo);
+        //2、没交完费用的车--->业务费
+        List<TbBusinessCar> noPayList = tbBusinessCarService.findByCarNoForWxPay(carNo);
+
+        list.addAll(noPayList);
+        //3、过磅费
+        List<TbBusinessCar> noPayWeightList = tbBusinessCarService.findByCarNoPayWeightLike(carNo);
+        list.addAll(noPayWeightList);
+        //4、已经离场了但是没交费用的车
+       List<TbBusinessCar>notPayList= tbBusinessCarService.findNotPayByCarNo(carNo);
+       list.addAll(notPayList);
+        return list.stream().map(tbBusinessCar -> {
             SearchBO searchBO = new SearchBO();
             searchBO.setId(tbBusinessCar.getId()).setCarNo(tbBusinessCar.getCarNo());
             return searchBO;

+ 24 - 22
sp-server/src/main/java/com/pj/api/wx/service/WxService.java

@@ -241,10 +241,26 @@ public class WxService {
         if (StrUtil.isNotEmpty(timeEnd)) {
             payTime = DateUtil.parse(timeEnd, "yyyyMMddHHmmss");
         }
+        TbBusinessCar businessCar = tbBusinessCarService.getById(tbOrder.getBusinessCarId());
+        log.info("last11----111------>{}",JSONUtil.toJsonStr(businessCar));
+        if (businessCar != null) {//更新放行记录的支付时间
+            Date lastPayTime = businessCar.getPayTime();
+            businessCar.setPay(1).setPayType(CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType());
+            if (lastPayTime == null) {
+                businessCar.setPayTime(now);
+            } else {
+                long nowSecond = System.currentTimeMillis() / 1000;
+                long freeSecond = partConfig.getFreeMinutes() * 60;
+                if (nowSecond - lastPayTime.getTime() / 1000 > freeSecond) {
+                    businessCar.setPayTime(now);
+                }
+            }
+            tbBusinessCarService.updateById(businessCar);
+        }
         if (StrUtil.isNotEmpty(attachStr)) {
             Attach attach = JSONUtil.toBean(attachStr, Attach.class);
             List<PriceBO> cars = JSONUtil.toList(attach.getC(), PriceBO.class);
-            BigDecimal partMoney = BigDecimal.ZERO;
+
             for (PriceBO bo1 : cars) {
                 TbBusinessCar car = tbBusinessCarService.getById(bo1.getId());
                 BigDecimal price = bo1.getP();
@@ -252,11 +268,11 @@ public class WxService {
                     log.error("付款金额不正确:{}", JSONUtil.toJsonStr(notifyBO));
                     continue;
                 }
-                partMoney = partMoney.add(price);
-                car.setPay(1).setMoney(price).setPayTime(payTime)
+                car.setPay(1).setPayTime(payTime)
                         .setPayType(CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType())
                         .setOutTradeNo(outTradeNo)
-                        .setPayOpenid(payopenid);
+                        .setPayOpenid(payopenid)
+                        .setMoney(price.add(car.getMoney()));
                 tbBusinessCarService.updateById(car);
             }
             if (!cars.isEmpty()) {
@@ -270,30 +286,16 @@ public class WxService {
                 // businessList = businessList.stream().filter(tbBusiness -> tbBusiness.getPayStatus() != PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode()).collect(Collectors.toList());
                 businessIds = businessList.stream().map(TbBusiness::getId).collect(Collectors.toList());
                 List<TbBusinessItem> items = tbBusinessItemService.findByBusinessIdList(businessIds);
-                //这辆车的地磅费用是否支付
-                items.stream().filter(item -> StrUtil.equals(SystemObject.config.getWeighbridge(), item.getItemAlias()))
-                        .forEach(item -> {
-                            TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(item.getCurrentBridgeCarId());
-                            tbBusinessCar.setPayNetweightMoney(1);
-                            tbBusinessCarService.updateById(tbBusinessCar);
-                            item.setPayStatus(0).setTotal(tbBusinessCar.getNetweightMoney());
-                        });
                 items = items.stream().filter(item -> item.getPayStatus() == 0).collect(Collectors.toList());
                 for (TbBusiness tbBusiness : businessList) {
                     tbBusiness.setPayTime(payTime).setPayType(PayEnum.PayType.WX_PAY.getCode())
                             .setConfirmInput(1).setConfirmInputTime(payTime)
                             .setPayOpenid(payopenid)
                             .setCalculateId(tbOrder.getCalculateId())
-                            .setPayNo(transactionId).setOutTradeNo(outTradeNo);
-                    tbBusiness.setPayStatus(PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode());
+                            .setPayNo(transactionId).setOutTradeNo(outTradeNo)
+                            .setPayStatus(PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode());
                     BigDecimal totalPrice = tbBusiness.getItemPrice();
-                    double itemPrice = items.stream().collect(Collectors.summarizingDouble(t -> t.getTotal().doubleValue())).getSum();
-                    if (totalPrice.doubleValue() > 0.6) {
-                        tbBusiness.setItemPrice(tbBusiness.getItemPrice().add(BigDecimal.valueOf(itemPrice)));
-                    } else {
-                        tbBusiness.setItemPrice(BigDecimal.valueOf(itemPrice));
-                    }
-                    tbBusiness.setPayMoney(BigDecimal.valueOf(itemPrice).add(tbBusiness.getPayMoney()));
+                    tbBusiness.setPayMoney(totalPrice);
                     tbBusinessService.updateById(tbBusiness);
                 }
                 items.forEach(tbBusinessItem -> tbBusinessItem.setPayStatus(1).setPayTime(finalPayTime).setCalculateId(tbOrder.getCalculateId()));
@@ -316,7 +318,7 @@ public class WxService {
                 }
                 TbItem tbItem = tbItemService.findByAliasName(SystemObject.config.getWeighbridge());
                 for (TbCarWeight carWeight : carWeightList) {
-                    tbFeeDetailsService.saveCarWeightDetails(transactionId,carWeight.getWeightPrice(), bo.getCalculateId(), carWeight.getNo(), tbBusinessCar, customerName, customerName, tbItem, PayEnum.PayType.WX_PAY);
+                    tbFeeDetailsService.saveCarWeightDetails(transactionId, carWeight.getWeightPrice(), bo.getCalculateId(), carWeight.getNo(), tbBusinessCar, customerName, customerName, tbItem, PayEnum.PayType.WX_PAY);
                     carWeight.setPayStatus(1).setPayTime(now).setPayType(PayEnum.PayType.PER_PAY.getCode());
                     tbCarWeightService.updateById(carWeight);
                 }

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

@@ -171,7 +171,7 @@ public class AutomaticPay {
             }
         }
         //需要交停车费且未交的话
-        if (tbBusinessCar.getPay() == 0 && partMoney.compareTo(BigDecimal.ZERO) > 0) {
+        if (partMoney.compareTo(BigDecimal.ZERO) > 0) {
             String businessIds = businessList.stream().filter(tbBusiness -> tbBusiness.getGoodsName().contains("停车"))
                     .map(TbBusiness::getId).collect(Collectors.joining(","));
             String uniqExpenseId = partMoneyRes.getUniqueExpenseId();
@@ -197,7 +197,7 @@ public class AutomaticPay {
             }
             String plate = tbBusinessCar.getCarNo();
             tbBusinessCar.setPay(1).setPayType(CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType())
-                    .setPayTime(now).setMoney(partMoney);
+                    .setPayTime(now).setMoney(partMoney.add(tbBusinessCar.getMoney()));
             tbBusinessCarService.updateById(tbBusinessCar);
             TbBusiness tbBusiness = businessList.get(0);
             String businessNo = tbBusiness.getNo();

+ 84 - 87
sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java

@@ -339,7 +339,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
      */
     public IOrderPriceRes getPartMoney(Date iTime, Date oTime, String carNo, String carColor) {
         long minutes = DateUtil.between(iTime, oTime, DateUnit.MINUTE);
-        double hours = NumberUtil.div(minutes, 60, 1);
+        double hours = NumberUtil.div(minutes, 60, 2);
         if (hours == 0) {
             hours = 0.1D;
         }
@@ -433,56 +433,53 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         //停车费
         if (inTime != null) {
             Date outTime = tbBusinessCar.getRealOutTime();
-            String cacheCarNo = RedisUtil.get(channel);
-            if (outTime == null && StrUtil.isNotEmpty(cacheCarNo) && StrUtil.equals(carNo.trim().toUpperCase(), cacheCarNo.trim().toUpperCase())) {
+            //  String cacheCarNo = RedisUtil.get(channel);
+            if (outTime == null) {
                 outTime = new Date();
             }
-            if (outTime != null) {
-                //默认需要缴费--->
-                BigDecimal partMoney = new BigDecimal("1");
-                if (StrUtil.isNotEmpty(tbBusinessCar.getColor()) && tbBusinessCar.getCarSize() != null) {
-                    String freeColor = partConfig.getFreeColor();
-                    //4.2米以下蓝色车辆
-                    if (tbBusinessCar.getColor().contains(freeColor)) {
-                        partMoney = new BigDecimal("0");
-                    }
-                }
-                if (CarEnum.PayTypeEnum.FEE_TYPE.getType().equals(tbBusinessCar.getPayType())) {
+            //默认需要缴费--->
+            BigDecimal partMoney = new BigDecimal("1");
+            if (StrUtil.isNotEmpty(tbBusinessCar.getColor()) && tbBusinessCar.getCarSize() != null) {
+                String freeColor = partConfig.getFreeColor();
+                //4.2米以下蓝色车辆
+                if (tbBusinessCar.getColor().contains(freeColor)) {
                     partMoney = new BigDecimal("0");
                 }
-                if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())) {
-                    if (tbBusinessCar.getRealOutTime() == null) {
-                        inTime = tbBusinessCar.getPayTime();
-                    } else {
-                        partMoney = new BigDecimal("0");
-                    }
+            }
+            if (CarEnum.PayTypeEnum.FEE_TYPE.getType().equals(tbBusinessCar.getPayType())) {
+                partMoney = new BigDecimal("0");
+            } else if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())) {
+                if (tbBusinessCar.getRealOutTime() == null) {
+                    inTime = tbBusinessCar.getPayTime();
+                } else {
+                    partMoney = new BigDecimal("0");
                 }
-                if (partMoney.doubleValue() == 1) {
-                    IOrderPriceRes partPriceRes = getPartMoney(inTime, outTime, tbBusinessCar.getCarNo(), tbBusinessCar.getColor());
-                    BigDecimal partPrice = partPriceRes.getTotalOrderPrice();
-                    carCalculateIds.add(partPriceRes.getCalculateId());
-                    partMoney = partPrice;
-                    if (partPrice.doubleValue() > 0) {
-                        carMap.put("uniqExpenseId", partPriceRes.getFireResult().get(0).getUniqExpenseId());
-                        carMap.put("carDesc", partPriceRes.getCarDesc());
-                        carMap.put("calculateId;", partPriceRes.getCalculateId());
-                        carMap.put("hourDesc", partPriceRes.getHourDesc());
-                        carMap.put("over24Hour", partPriceRes.getOver24Hour());
-                        List<PriceDetailItem> detailItemList = partPriceRes.getFireResult().get(0)
-                                .getPriceDetail();
-                        detailItemList.forEach(obj -> carMap.put(obj.getKey(), obj.getValue()));
-                    }
-                    //todo 计算停车费
+            }
+            if (partMoney.doubleValue() == 1) {
+                IOrderPriceRes partPriceRes = getPartMoney(inTime, outTime, tbBusinessCar.getCarNo(), tbBusinessCar.getColor());
+                BigDecimal partPrice = partPriceRes.getTotalOrderPrice();
+                carCalculateIds.add(partPriceRes.getCalculateId());
+                partMoney = partPrice;
+                if (partPrice.doubleValue() > 0) {
+                    carMap.put("uniqExpenseId", partPriceRes.getFireResult().get(0).getUniqExpenseId());
+                    carMap.put("carDesc", partPriceRes.getCarDesc());
+                    carMap.put("calculateId;", partPriceRes.getCalculateId());
+                    carMap.put("hourDesc", partPriceRes.getHourDesc());
+                    carMap.put("over24Hour", partPriceRes.getOver24Hour());
+                    List<PriceDetailItem> detailItemList = partPriceRes.getFireResult().get(0)
+                            .getPriceDetail();
+                    detailItemList.forEach(obj -> carMap.put(obj.getKey(), obj.getValue()));
                 }
-                carMap.put("price", partMoney);
+                //todo 计算停车费
             }
+            carMap.put("price", partMoney);
+
         }
         carMap.put("id", tbBusinessCar.getId());
         carMap.put("carNo", tbBusinessCar.getCarNo());
         carMap.put("pay", pay);
         carMap.put("no", tbBusinessCar.getNo());
         result.put("carList", Collections.singleton(carMap));
-        BigDecimal itemsPrice = new BigDecimal("0");
         List<Map<String, Object>> itemList = new ArrayList<>();
         if (!items.isEmpty()) {
             //未支付的
@@ -497,6 +494,15 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 Date startTime = businessItem.getColdStartTime();
                 Date endTime = businessItem.getColdEndTime();
                 iOrderItem.setExpenseNum(num).setUniqExpenseId(itemCode);
+                Map<String, Object> itemMap = new HashMap<>();
+                itemMap.put("id", businessItem.getId());
+                itemMap.put("name", businessItem.getItemName() + "(" + businessItem.getItemTypeName() + ")");
+                if (StrUtil.equals(SystemObject.config.getWeighbridge(), businessItem.getItemAlias())) {
+                    itemMap.put("name", businessItem.getItemName() + "-" + carNo + "(" + businessItem.getItemTypeName() + ")");
+                }
+                itemMap.put("price", businessItem.getTotal());
+                itemMap.put("pay", businessItem.getPayStatus());
+                itemList.add(itemMap);
                 if (StrUtil.equals(itemAlias, SystemObject.config.getColdItemAlias())) {
                     tbBusinessItemService.buildColdFceItem(businessItem, iOrderItem, startTime, endTime);
                     //充电打冷--->按小时计费
@@ -511,57 +517,19 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 } else if (StrUtil.equals(itemAlias, SystemObject.config.getBigHeadCar())
                         || StrUtil.equals(itemAlias, SystemObject.config.getCabinetCar())) {
                     //大车头、柜车、栏车
-                    tbBusinessItemService.buildDaysFceItem(businessItem, iOrderItem, startTime, endTime);
+                    tbBusinessItemService.buildNumItem(businessItem, iOrderItem);
                     //不收停车费
                     //  carMap.put("price", 0);
                 }
                 expenses.add(iOrderItem);
             }
             result.put("carList", Collections.singleton(carMap));
-
             if (!expenses.isEmpty()) {
                 IOrderPriceRes orderPriceRes = syncService.orderPriceCal(expenses);
                 BigDecimal totalPrice = orderPriceRes.getTotalOrderPrice();
-                carCalculateIds.add(orderPriceRes.getCalculateId());
-                for (TbBusinessItem item : items) {
-                    BigDecimal itemPrice = item.getItemPrice().multiply(new BigDecimal(item.getNum())).setScale(2, BigDecimal.ROUND_HALF_UP);
-                    itemsPrice = itemsPrice.add(itemPrice);
-                    Map<String, Object> itemMap = new HashMap<>();
-                    itemMap.put("id", item.getId());
-                    itemMap.put("name", item.getItemName() + "(" + item.getItemTypeName() + ")");
-                    if (StrUtil.equals(SystemObject.config.getWeighbridge(), item.getItemAlias())) {
-                        itemMap.put("name", item.getItemName() + "-" + carNo + "(" + item.getItemTypeName() + ")");
-                    }
-                    itemMap.put("price", itemPrice);
-                    itemMap.put("pay", item.getPayStatus());
-                    orderPriceRes.getFireResult().stream()
-                            .filter(priceItem -> StrUtil.equals(item.getItemCode(), priceItem.getUniqExpenseId()))
-                            .findAny().ifPresent(priceItem -> {
-                        BigDecimal price = priceItem.getFirePrice().multiply(new BigDecimal(item.getNum()));
-                        boolean weighbridge = StrUtil.equals(item.getItemAlias(), SystemObject.config.getWeighbridge());
-                        if (weighbridge) {//地磅的,单价x重量
-                            price = priceItem.getFirePrice().multiply(BigDecimal.valueOf(item.getWeighbridge())).setScale(2, BigDecimal.ROUND_HALF_UP);
-                        }
-                        //柜车、栏车 || 过磅费 只有离场才知道多少钱
-                        if (StrUtil.equals(item.getItemAlias(), SystemObject.config.getCabinetCar())
-                        ) {
-                            TbBusiness tbBusiness = this.getById(item.getBusinessId());
-                            tbBusiness.setItemPrice(price);
-                            item.setTotal(price);
-                            tbBusinessItemService.updateById(item);
-                            this.updateById(tbBusiness);
-                        }
-                        if (weighbridge) {
-                            tbBusinessCar.setNetweightMoney(price);
-                            tbBusinessCarService.updateById(tbBusinessCar);
-                        }
-                        itemMap.put("price", price);
-                    });
-                    itemList.add(itemMap);
-                }
                 result.put("itemsPrice", totalPrice);
+                carCalculateIds.add(orderPriceRes.getCalculateId());
             }
-
         }
         result.put("itemList", itemList);
         result.put("calculateId", String.join(",", carCalculateIds));
@@ -584,6 +552,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             result.put("w", map);
             result.put("calculateId", String.join(",", carCalculateIds));
         }
+        TbBusinessCar last=tbBusinessCarService.getById(businessCarId);
+        log.info("last------>{}",JSONUtil.toJsonStr(last));
         return result;
     }
 
@@ -700,6 +670,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         int index = 1;
         int size = cars.size();
         String goodsName = tbGoods.getName();
+        boolean freePartMoney = false;
         for (TbItem tbItem : tbItems) {
             TbItem db = tbItemService.getById(tbItem.getId());
             String itemName = db.getItemName();
@@ -719,7 +690,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             String typeId = tbItem.getTypeId();
             TbItemType tbItemType = tbItemTypeService.getById(typeId);
             BigDecimal unitPrice = db.getPrice();
-            unitPrice = StrUtil.equals(db.getPattern(), "RULES") ? BigDecimal.ZERO : unitPrice;
             BigDecimal itemTotalPrice = unitPrice.multiply(new BigDecimal(num));
             item.setNo(no + "0" + index).setPayTypeName(db.getPayTypeName())
                     .setPayType(db.getPayType())
@@ -794,6 +764,15 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     item.setPayStatus(3);
                     itemTotalPrice = zero;
                 }
+            } else if (SystemObject.config.getBigHeadCar().equals(alaisName) || SystemObject.config.getCabinetCar().equals(alaisName)) {
+                //大头车、柜车、栏车  金额=单价x数量且无停车费
+                freePartMoney = true;
+                itemTotalPrice = new BigDecimal(item.getNum()).multiply(db.getPrice());
+                item.setTotal(itemTotalPrice);
+            }else if (SystemObject.config.getPartItemAlias().equals(alaisName)){
+                //停车业务
+                itemTotalPrice=BigDecimal.ZERO;
+                item.setTotal(BigDecimal.ZERO);
             }
             Date startTime = item.getColdStartTime();
             Date endTime = item.getColdEndTime();
@@ -802,14 +781,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 tbBusinessItemService.buildExpenses(Collections.singletonList(item), expenses);
                 IOrderPriceRes res = syncService.orderPriceCal(expenses);
                 item.setTotal(res.getTotalOrderPrice());
+                itemTotalPrice = res.getTotalOrderPrice();
             }
             price = price.add(itemTotalPrice);
             itemList.add(item);
             index++;
         }
-        if (price.doubleValue() < 5) {
-            price = BigDecimal.ZERO;
-        }
         String declareNo = otherBusinessBO.getDeclareNo();
         tbBusiness.setCardSize(otherBusinessBO.getCarSize()).setNetWeight(otherBusinessBO.getNetWeight())
                 .setOperator(otherBusinessBO.getOperator()).setOperateTime(otherBusinessBO.getOperateTime())
@@ -877,6 +854,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     .setColor(car.getColor())
                     .setCustomerId(customerId)
                     .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
+            if (freePartMoney) {
+                db.setPay(1).setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
+            }
             tbBusinessCarService.saveOrUpdate(db);
             RelationBusinessCar relationBusinessCar = new RelationBusinessCar();
             relationBusinessCar.setBusinessId(tbBusiness.getId()).setBusinessCarId(db.getId());
@@ -931,6 +911,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         String carBuseinssNo = DateUtil.format(now, "yyyyMMddHHmm");
         String goodsName = tbGoods.getName();
         List<TbBusinessItem> itemList = new ArrayList<>();
+        boolean freePartMoney = false;
         if (PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode() != dbBusiness.getPayStatus()) {
             List<TbBusinessItem> businessItemList = tbBusinessItemService.findByBusinessId(id);
             //变成未取柜状态
@@ -950,6 +931,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 dbBusiness.setPickCustomerId(pickCustomerId).setPickCustomerName(partner.getName());
             }
             int size = cars.size();
+
             for (TbItem tbItem : tbItems) {
                 TbItem db = tbItemService.getById(tbItem.getId());
                 String alaisName = db.getItemAlias();
@@ -969,7 +951,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 int num = tbItem.getNum();
                 TbItemType tbItemType = tbItemTypeService.getById(tbItem.getTypeId());
                 BigDecimal unitPrice = db.getPrice();
-                unitPrice = StrUtil.equals(db.getPattern(), "RULES") ? BigDecimal.ZERO : unitPrice;
                 BigDecimal itemTotalPrice = unitPrice.multiply(new BigDecimal(num));
                 item.setNo(no + "0" + index).setPayTypeName(db.getPayTypeName()).setPayType(db.getPayType())
                         .setBusinessType(db.getBusinessType()).setTaxRate(NumberUtil.div(db.getTaxRate().doubleValue(), 100D, 2));
@@ -1000,6 +981,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         IOrderPriceRes res = syncService.orderPriceCal(expenses);
                         BigDecimal itemPrice = res.getTotalOrderPrice();
                         item.setTotal(itemPrice);
+                        String itemNum = itemPrice.divide(item.getItemPrice(), 2, BigDecimal.ROUND_HALF_UP).toString();
+                        item.setNum(itemNum);
                         itemTotalPrice = itemPrice;
                     }
                 }
@@ -1045,15 +1028,20 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         //无需支付
                         item.setPayStatus(3);
                     }
+                } else if (SystemObject.config.getBigHeadCar().equals(alaisName) || SystemObject.config.getCabinetCar().equals(alaisName)) {
+                    //大头车、柜车、栏车  金额=单价x数量
+                    itemTotalPrice = new BigDecimal(item.getNum()).multiply(item.getItemPrice());
+                    item.setTotal(itemTotalPrice);
+                    freePartMoney = true;
+                }else if (SystemObject.config.getPartItemAlias().equals(alaisName)){
+                    //停车业务
+                    itemTotalPrice=BigDecimal.ZERO;
+                    item.setTotal(BigDecimal.ZERO);
                 }
-
                 price = price.add(itemTotalPrice);
                 itemList.add(item);
                 index++;
             }
-            if (price.doubleValue() < 5) {
-                price = BigDecimal.ZERO;
-            }
             dbBusiness.setItemPrice(price).setTotalMoney(price);
             tbBusinessItemService.saveBatch(itemList);
         }
@@ -1101,6 +1089,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     dbBusinessCar
                             .setCarSize(tbBusinessCar.getCarSize()).setCarType(tbBusinessCar.getCarType())
                             .setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode());
+                    if (freePartMoney) {
+                        dbBusinessCar.setPay(1).setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
+                    }
                     tbBusinessCarService.updateById(dbBusinessCar);
                 }
             } else {
@@ -1113,6 +1104,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         .setCustomerId(dbBusiness.getCustomerId())
                         .setTimeUpdate(now).setIsLock(0).setCarType(tbBusinessCar.getCarType()).setBusinessType(1)
                         .setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode());
+                if (freePartMoney) {
+                    checkCar.setPay(1).setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
+                }
                 tbBusinessCarService.updateById(checkCar);
                 RelationBusinessCar relationBusinessCar = new RelationBusinessCar();
                 relationBusinessCar.setBusinessId(dbBusiness.getId()).setBusinessCarId(checkCar.getId());
@@ -1238,6 +1232,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
      * @param errorBusinessBO
      * @param isAdmin         是否管理员
      */
+    @Deprecated
     public void selectErrorBusiness(ErrorBusinessBO errorBusinessBO, boolean isAdmin) {
         log.info("is admin :{}", isAdmin);
         TbBusiness tbBusiness = getById(errorBusinessBO.getId());
@@ -1272,6 +1267,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
      *
      * @param tbBusinessCar
      */
+    @Deprecated
     private void handlerCarPay(TbBusinessCar tbBusinessCar) {
         String carNo = tbBusinessCar.getCarNo();
         String payType = tbBusinessCar.getPayType();
@@ -1772,6 +1768,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, tbBusiness.getPickCustomerName(), tbBusiness.getPickCustomerName(), FeeTypeEnum.STEVEDORE_FEE);
                         tbFeeStatisticsService.addOrUpdateStatistic(now, PayEnum.PayType.PER_PAY.getCode());//更新当前日期的日统计
                         TbDeductionRecord record = automaticPay.createTbDeductionRecord(details, balance, afterBalance, tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.STEVEDORE_FEE);
+                        //生成开票订单
                         tbInvoiceOrderService.addInvoiceOrder(tbBusiness.getGoodsName(), tbBusiness.getNo(), tbBusiness.getCarNoStr(), tbBusiness.getId(),
                                 tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusiness.getPickCustomerName(), res.getTotalOrderPrice(), details, record);
                     }

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCar.java

@@ -87,7 +87,7 @@ public class TbBusinessCar extends Model<TbBusinessCar> implements Serializable
     private Date realOutTime;
 
     /**
-     *
+     *停车费
      */
     private BigDecimal money = new BigDecimal("0");
 

+ 4 - 0
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.java

@@ -47,4 +47,8 @@ public interface TbBusinessCarMapper extends BaseMapper<TbBusinessCar> {
     CarStatics staticsCar(@Param("weightCar") String weightCar, @Param("emptyCar") String emptyCar, @Param("list")List<String> list);
 
     void updateRecord(TbBusinessCar db);
+
+    List<TbBusinessCar> findByCarNoForWxPay(@Param("carNo")String carNo);
+
+    List<TbBusinessCar> findByCarNoPayWeightLike(@Param("carNo")String carNo);
 }

+ 39 - 15
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.xml

@@ -52,7 +52,7 @@
         <where>
             <if test=' this.has("id") '>and id = #{id}</if>
             <if test=' this.has("businessId") '>and business_id = #{businessId}</if>
-            <if test=' this.has("flag") '>and real_in_time is not null </if>
+            <if test=' this.has("flag") '>and real_in_time is not null</if>
             <if test=' this.has("customerId") '>and customer_id = #{customerId}</if>
             <if test=' this.has("confirmJudge") '>and confirm_judge = #{confirmJudge}</if>
             <if test=' this.has("carNoList") and carNoList.size>0'>
@@ -181,24 +181,24 @@
 
     <select id="staticsCar" resultType="com.pj.project.tb_business_car.statics.CarStatics">
         SELECT SUM(CASE
-                       WHEN DATE_FORMAT(real_in_time, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d') THEN 1
-                       ELSE 0 END)                                                                 as todayInCar,
+        WHEN DATE_FORMAT(real_in_time, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d') THEN 1
+        ELSE 0 END) as todayInCar,
 
-               SUM(CASE
-                       WHEN DATE_FORMAT(real_out_time, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d') and
-                            real_in_time is not null THEN 1
-                       ELSE 0 END)                                                                 as outCar,
+        SUM(CASE
+        WHEN DATE_FORMAT(real_out_time, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d') and
+        real_in_time is not null THEN 1
+        ELSE 0 END) as outCar,
 
-               SUM(CASE WHEN real_out_time is null and real_in_time is not null THEN 1 ELSE 0 END) as inCar,
+        SUM(CASE WHEN real_out_time is null and real_in_time is not null THEN 1 ELSE 0 END) as inCar,
 
-               SUM(CASE
-                       WHEN real_out_time is null and real_in_time is not null and car_type = #{weightCar} THEN 1
-                       ELSE 0 END)                                                                 as weightCar,
+        SUM(CASE
+        WHEN real_out_time is null and real_in_time is not null and car_type = #{weightCar} THEN 1
+        ELSE 0 END) as weightCar,
 
-               SUM(CASE
-                       WHEN real_out_time is null and real_in_time is not null and
-                            (car_type = #{emptyCar} or car_type = '') THEN 1
-                       ELSE 0 END)                                                                 as emptyCar
+        SUM(CASE
+        WHEN real_out_time is null and real_in_time is not null and
+        (car_type = #{emptyCar} or car_type = '') THEN 1
+        ELSE 0 END) as emptyCar
 
         FROM tb_business_car
         <if test="list!=null and list.size>0">
@@ -208,6 +208,30 @@
             </foreach>
         </if>
     </select>
+    <select id="findByCarNoForWxPay" resultType="com.pj.project.tb_business_car.TbBusinessCar">
+       SELECT
+	        c.id,c.car_no
+        FROM
+            tb_business_item a,
+            relation_business_car b,
+            tb_business_car c
+        WHERE
+            a.business_id = b.business_id
+            AND b.business_car_id = c.id
+            AND a.pay_status=0
+            and c.car_no like concat('%',#{carNo},'%')
+    </select>
+    <select id="findByCarNoPayWeightLike" resultType="com.pj.project.tb_business_car.TbBusinessCar">
+        SELECT
+	        b.id,b.car_no
+        FROM
+	        tb_car_weight a,
+	        tb_business_car b
+        WHERE
+	        a.business_car_id=b.id
+	        and a.pay_status=0
+	        and b.car_no like concat('%',#{carNo},'%')
+    </select>
 
 
 </mapper>

+ 16 - 69
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java

@@ -79,9 +79,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
     private TbBusinessItemService tbBusinessItemService;
     @Resource
     TbCarService tbCarService;
-    @Resource
-    @Lazy
-    TbFeeDetailsService tbFeeDetailsService;
 
     @Resource
     private UploadConfig uploadConfig;
@@ -99,17 +96,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
     private PartConfig partConfig;
 
     @Resource
-    @Lazy
-    private TbAccountService tbAccountService;
-
-    @Resource
-    @Lazy
-    private TbFeeStatisticsService tbFeeStatisticsService;
-
-    @Resource
-    @Lazy
-    private AutomaticPay automaticPay;
-    @Resource
     private SyncService syncService;
 
 
@@ -121,17 +107,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
     }
 
 
-    public TbBusinessCar findInAndNoBusinessCar(String carNo) {
-        QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
-        ew.eq("car_no", carNo.toUpperCase())
-                .isNotNull("real_in_time")
-                .isNull("business_id")
-                .isNull("real_out_time").orderByDesc("id");
-        List<TbBusinessCar> list = list(ew);
-        return list.isEmpty() ? null : list.get(0);
-    }
-
-
     public List<TbBusinessCar> findInAndNoBusinessCar() {
         QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
         ew.isNotNull("real_in_time")
@@ -152,17 +127,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         });
     }
 
-    public List<TbBusinessCar> searchPartCar(String carNo) {
-        return tbBusinessCarMapper.searchPartCar(carNo.toUpperCase());
-    }
-
-    public TbBusinessCar findNotInCar(String carNo) {
-        QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
-        ew.eq("car_no", carNo.toUpperCase())
-                .isNull("real_in_time").orderByDesc("id");
-        List<TbBusinessCar> list = list(ew);
-        return list.isEmpty() ? null : list.get(0);
-    }
 
     public List<TbBusinessCar> findNotOutCar(String carNo) {
         QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
@@ -172,6 +136,7 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         return list(ew);
     }
 
+
     public TbBusinessCar check(String carNo) {
         QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
         ew.eq("car_no", carNo.toUpperCase())
@@ -282,9 +247,9 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         }
         if (t.getRealInTime() != null && t.getRealOutTime() != null) {
             BigDecimal money = tbBusinessService.getPartMoney(t.getRealInTime(), t.getRealOutTime(), t.getCarNo(), t.getColor()).getTotalOrderPrice();
-            if (money.compareTo(BigDecimal.ZERO)==0){
-                t.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
-                db.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
+            if (money.compareTo(BigDecimal.ZERO) == 0) {
+                t.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType()).setPay(1);
+                db.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType()).setPay(1);
             }
             t.setMoney(money);
             db.setMoney(money);
@@ -310,16 +275,18 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
                     String aliasName = tbBusinessItem.getItemAlias();
                     //如果是大头车,则计算业务费用===>
                     if (StrUtil.equals(SystemObject.config.getBigHeadCar(), aliasName)
-                    ||StrUtil.equals(SystemObject.config.getCabinetCar(), aliasName)) {
+                            || StrUtil.equals(SystemObject.config.getCabinetCar(), aliasName)) {
                         tbBusinessItem.setColdStartTime(db.getRealInTime()).setColdEndTime(db.getRealOutTime());
                         List<IOrderItem> expenses = new ArrayList<>();
                         tbBusinessItemService.buildExpenses(Collections.singletonList(tbBusinessItem), expenses);
-                        if (!expenses.isEmpty()){
+                        if (!expenses.isEmpty()) {
                             IOrderPriceRes res = syncService.orderPriceCal(expenses);
                             tbBusinessItem.setTotal(res.getTotalOrderPrice());
                             tbBusiness.setItemPrice(res.getTotalOrderPrice());
                             tbBusinessItemService.updateById(tbBusinessItem);
                         }
+                        t.setMoney(BigDecimal.ZERO);
+                        db.setMoney(BigDecimal.ZERO);
                     }
                 }
                 tbBusinessService.updateById(tbBusiness);
@@ -404,9 +371,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         return list;
     }
 
-    public TbBusinessCar findInCar(String carNo) {
-        return null;
-    }
 
     public List<TbBusinessCar> searchOtherBusinessCar(String carNo) {
         return tbBusinessCarMapper.searchOtherBusinessCar(carNo);
@@ -418,11 +382,8 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
 
 
     public List<TbBusinessCar> findNotOutCarLike(String carNo) {
-        if (StrUtil.isEmpty(carNo) || StrUtil.length(carNo) < 3) {
-            return Collections.emptyList();
-        }
         QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
-        ew.select("car_no,car_size");
+        ew.select("car_no,id");
         ew.like("car_no", carNo.trim().toUpperCase());
         ew.isNull("real_out_time")
                 .isNotNull("real_in_time");
@@ -493,21 +454,6 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         return list.stream().distinct().collect(Collectors.toList());
     }
 
-    /**
-     * 审核驳回
-     *
-     * @param id
-     * @param judgeContent
-     */
-    public void callback(String id, String judgeContent) {
-        TbBusinessCar db = this.getById(id);
-        db.setConfirmJudge(CarEnum.ConfirmJudgeEnum.CALL_BACK.getCode())
-                .setConfirmJudgeContent(judgeContent).setConfirmJudgeTime(new Date())
-                .setConfirmJudgeBy(StpUserUtil.getCreateBy());
-        this.updateById(db);
-    }
-
-
 
     /**
      * 未支付的车
@@ -523,11 +469,12 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         return list(ew);
     }
 
-    public List<TbBusinessCar> findNoPayWeightCar(String carNo) {
-        QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
-        ew.lambda().like(TbBusinessCar::getCarNo, carNo)
-                .eq(TbBusinessCar::getPayNetweightMoney,0)
-                .gt(TbBusinessCar::getNetWeight,0);
-        return list(ew);
+
+    public List<TbBusinessCar> findByCarNoForWxPay(String carNo) {
+        return tbBusinessCarMapper.findByCarNoForWxPay(carNo);
+    }
+
+    public List<TbBusinessCar> findByCarNoPayWeightLike(String carNo) {
+        return tbBusinessCarMapper.findByCarNoPayWeightLike(carNo);
     }
 }

+ 52 - 72
sp-server/src/main/java/com/pj/project/tb_business_item/TbBusinessItemService.java

@@ -22,6 +22,7 @@ import com.pj.project.sync.request.item.IFactorItem;
 import com.pj.project.sync.request.item.IOrderItem;
 import com.pj.project.tb_business.TbBusiness;
 import com.pj.project.tb_business.TbBusinessService;
+import com.pj.project.tb_business_car.TbBusinessCarService;
 import com.pj.project.tb_costomer.TbCostomer;
 import com.pj.project.tb_costomer.TbCostomerService;
 import com.pj.project.tb_fee_details.TbFeeDetails;
@@ -99,7 +100,7 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
     private TbItemTypeService tbItemTypeService;
 
     @Resource
-    private TbItemFacService tbItemFacService;
+    private TbBusinessCarService tbBusinessCarService;
 
 
     /**
@@ -111,19 +112,19 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
 
 
     public void removeByBusinessId(String businessId) {
-        List<TbBusinessItem>list=this.findByBusinessId(businessId);
+        List<TbBusinessItem> list = this.findByBusinessId(businessId);
         for (TbBusinessItem tbBusinessItem : list) {
-            TbBusinessItem childItem= this.findByParentCabinetId(tbBusinessItem.getId());
-            if (childItem!=null){
-                throw new AjaxError("柜号["+tbBusinessItem.getCabinetNo()+"]存在取柜关联,不能删除");
+            TbBusinessItem childItem = this.findByParentCabinetId(tbBusinessItem.getId());
+            if (childItem != null) {
+                throw new AjaxError("柜号[" + tbBusinessItem.getCabinetNo() + "]存在取柜关联,不能删除");
             }
-            if (tbBusinessItem.getParentCabinetId()!=null){
-              TbBusinessItem pItem=  this.getById(tbBusinessItem.getParentCabinetId());
-              if (pItem!=null){
-                  //设置成未取柜
-                  pItem.setCabinetStatus(0);
-                  this.updateById(pItem);
-              }
+            if (tbBusinessItem.getParentCabinetId() != null) {
+                TbBusinessItem pItem = this.getById(tbBusinessItem.getParentCabinetId());
+                if (pItem != null) {
+                    //设置成未取柜
+                    pItem.setCabinetStatus(0);
+                    this.updateById(pItem);
+                }
             }
 
         }
@@ -134,7 +135,7 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
 
     private TbBusinessItem findByParentCabinetId(Long id) {
         QueryWrapper<TbBusinessItem> ew = new QueryWrapper<>();
-        ew.lambda().eq(TbBusinessItem::getParentCabinetId,id);
+        ew.lambda().eq(TbBusinessItem::getParentCabinetId, id);
         return getOne(ew);
     }
 
@@ -268,7 +269,7 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
      */
     public List<TbBusinessItem> getByBusinessCarId(String busienssCarId) {
         List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(busienssCarId);
-        if (businessList.isEmpty()){
+        if (businessList.isEmpty()) {
             return new ArrayList<>();
         }
         return this.findByBusinessIdList(businessList.stream().map(TbBusiness::getId).collect(Collectors.toList()));
@@ -335,101 +336,80 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
      * @return
      */
     public void buildExpenses(List<TbBusinessItem> businessItems, List<IOrderItem> orderItems) {
-        log.info("business-------:{}",businessItems.get(0).getItemName());
+        log.info("business-------:{}", businessItems.get(0).getItemName());
         for (TbBusinessItem item : businessItems) {
-            if (item.getPayStatus()==0){
+            if (item.getPayStatus() == 0) {
                 IOrderItem orderItem = new IOrderItem();
                 String itemAlias = item.getItemAlias();
                 Date startTime = item.getColdStartTime();
                 Date endTime = item.getColdEndTime();
+                orderItem.setUniqExpenseId(item.getItemCode())
+                        .setExpenseNum(item.getNum());
                 if (StrUtil.equals(itemAlias, SystemObject.config.getColdItemAlias())) {
                     buildColdFceItem(item, orderItem, startTime, endTime);
                     //充电打冷--->按小时计费
                 } else if (StrUtil.equals(itemAlias, SystemObject.config.getHeavyStoreItemAlias())
                         || StrUtil.equals(itemAlias, SystemObject.config.getEmptyStoreItemAlias())) {
                     //如果存柜的话则不收费
-                    if (item.getCabinetType()==0){
+                    if (item.getCabinetType() == 0) {
                         continue;
                     }
                     //空柜堆存、重箱堆存
                     buildDaysFceItem(item, orderItem, startTime, endTime);
-                }else if (StrUtil.equals(itemAlias,SystemObject.config.getBigHeadCar())
-                        ||StrUtil.equals(itemAlias,SystemObject.config.getCabinetCar())){
+                } else if (StrUtil.equals(itemAlias, SystemObject.config.getBigHeadCar())
+                        || StrUtil.equals(itemAlias, SystemObject.config.getCabinetCar())) {
                     //大车头、柜车、栏车
-                    buildDaysFceItem(item, orderItem, startTime, endTime);
-                }
-                orderItem.setUniqExpenseId(item.getItemCode())
-                        .setExpenseNum(item.getNum());
-                if (StrUtil.equals(itemAlias,SystemObject.config.getWeighbridge())){
+                    //  buildDaysFceItem(item, orderItem, startTime, endTime);
+                    buildNumItem(item, orderItem);
+                }else  if (StrUtil.equals(itemAlias, SystemObject.config.getWeighbridge())) {
                     orderItem.setExpenseNum(item.getWeighbridge().toString());
                 }
-                boolean flag= orderItems.add(orderItem);
-                log.info("flag-----------:{}",flag);
+                boolean flag = orderItems.add(orderItem);
+                log.info("flag-----------:{}", flag);
             }
         }
-       log.info("size------------------------:{}",orderItems.size());
+        log.info("size------------------------:{}", orderItems.size());
+    }
+
+    /**
+     * 数量x单价
+     *
+     * @param item
+     * @param orderItem
+     */
+    public void buildNumItem(TbBusinessItem item, IOrderItem orderItem) {
+        String uniqExpenseId = item.getItemCode();
+        orderItem.setUniqExpenseId(uniqExpenseId).setExpenseNum(item.getNum());
     }
 
     public void buildDaysFceItem(TbBusinessItem item, IOrderItem orderItem, Date startTime, Date endTime) {
         String uniqExpenseId = item.getItemCode();
-        TbItemFac tbItemFac = tbItemFacService.findByItemIdAndUniqExpenseId(item.getItemId(), uniqExpenseId);
-        if (tbItemFac == null) {
-            throw new BusinessException("收费规则未配置");
-        }
-        if (startTime == null || endTime == null) {
-            throw new BusinessException("时间未设置");
-        }
         long minutes = DateUtil.between(startTime, endTime, DateUnit.MINUTE);
-        int base=24*60;
+        int base = 24 * 60;
         //整数天数
-        long days=minutes/base;
+        long days = minutes / base;
         //余数
-        if (minutes%base>0){
-            days=days+1;
+        if (minutes % base > 0) {
+            days = days + 1;
         }
-        IFactorItem factorItem = new IFactorItem();
-        factorItem.setFacId(tbItemFac.getFacId() + "").setFacParams(days + "");
-        orderItem.setFactors(Collections.singletonList(factorItem));
+        orderItem.setExpenseNum(days+"").setUniqExpenseId(uniqExpenseId);
     }
 
-    public static void main(String[] args) {
-        Date startTime=DateUtil.parseDateTime("2023-05-05 00:00:00");
-        Date endTime=DateUtil.parseDateTime("2023-05-06 00:11:00");
-       LocalDateTime start= startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
-       LocalDateTime end= endTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
-       long m= ChronoUnit.MINUTES.between(start,end);
-        long minutes = DateUtil.between(startTime, endTime,DateUnit.MINUTE);
-        int base=60;
-        //整数天数
-        long hour=minutes/base;
-        //余数
-        if (minutes%base>0){
-            hour=hour+1;
-        }
-        System.out.println(hour);
-    }
 
     public void buildColdFceItem(TbBusinessItem item, IOrderItem orderItem, Date startTime, Date endTime) {
         String uniqExpenseId = item.getItemCode();
-        TbItemFac tbItemFac = tbItemFacService.findByItemIdAndUniqExpenseId(item.getItemId(), uniqExpenseId);
-        if (tbItemFac == null) {
-            throw new AjaxError("充电打冷收费规则未配置");
-        }
         if (startTime == null || endTime == null) {
             throw new AjaxError("充电打冷时间未设置");
         }
         long minutes = DateUtil.between(startTime, endTime, DateUnit.MINUTE);
-        int base=60;
+        int base = 60;
         //整数天数
-        long hour=minutes/base;
+        long hour = minutes / base;
         //余数
-        if (minutes%base>0){
-            hour=hour+1;
+        if (minutes % base > 0) {
+            hour = hour + 1;
         }
-        IFactorItem factorItem = new IFactorItem();
-        factorItem.setFacId(tbItemFac.getFacId() + "").setFacParams(hour + "");
-        orderItem.setFactors(Collections.singletonList(factorItem));
-
+        orderItem.setUniqExpenseId(uniqExpenseId).setExpenseNum(hour+"");
     }
 
     public TbBusinessItem findTheLastRecordByCabinetNo(String cabinetNo) {
@@ -446,9 +426,9 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
     }
 
     public TbBusinessItem findByBusinessIdAndItemId(String businessId, String itemId) {
-        QueryWrapper<TbBusinessItem>ew=new QueryWrapper<>();
-        ew.lambda().eq(TbBusinessItem::getBusinessId,businessId)
-                .eq(TbBusinessItem::getItemId,itemId);
+        QueryWrapper<TbBusinessItem> ew = new QueryWrapper<>();
+        ew.lambda().eq(TbBusinessItem::getBusinessId, businessId)
+                .eq(TbBusinessItem::getItemId, itemId);
         return getOne(ew);
     }
 }

+ 11 - 4
sp-server/src/main/java/com/pj/project/tb_costomer/TbCostomerService.java

@@ -91,6 +91,10 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
         if (!typeList.contains("0")) {
             syncService.syncPartnes(t.getId(), t.getName(), SyncTypeEnum.INSERT.getCode());
         }
+        TbAccount tbAccount=new TbAccount();
+        tbAccount.setCustomerId(t.getId()).setCustomerName(t.getName())
+                .setCreateTime(new Date()).setAccountNo(RandomUtil.randomNumbers(12));
+        tbAccountService.save(tbAccount);
         return 1;
     }
 
@@ -305,10 +309,13 @@ public class TbCostomerService extends ServiceImpl<TbCostomerMapper, TbCostomer>
     public void initAccount() {
         List<TbCostomer> list = list();
         list.forEach(tbCostomer -> {
-            TbAccount tbAccount=new TbAccount();
-            tbAccount.setCustomerId(tbCostomer.getId()).setCustomerName(tbCostomer.getName())
-                    .setCreateTime(new Date()).setAccountNo(RandomUtil.randomNumbers(12));
-            tbAccountService.save(tbAccount);
+            TbAccount tbAccount=tbAccountService.getAccountByCustomerId(tbCostomer.getId());
+            if (tbAccount==null){
+                tbAccount=new TbAccount();
+                tbAccount.setCustomerId(tbCostomer.getId()).setCustomerName(tbCostomer.getName())
+                        .setCreateTime(new Date()).setAccountNo(RandomUtil.randomNumbers(12));
+                tbAccountService.save(tbAccount);
+            }
         });
     }
 }

+ 11 - 0
sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsController.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
 import com.pj.project.tb_fee_details.dto.DetailSumDTO;
 import com.pj.project.tb_fee_details.statics.FeeTypeStatics;
 import com.pj.project4sp.SP;
+import com.pj.utils.cache.RedisUtil;
 import com.pj.utils.sg.AjaxJson;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -105,6 +106,16 @@ public class TbFeeDetailsController {
     }
 
     /**
+     * 异步查询导出地址
+     * @param uuid
+     * @return
+     */
+    @RequestMapping("export/details/path")
+    public AjaxJson getExportPath(String uuid) {
+        return AjaxJson.getSuccessData(RedisUtil.get(uuid));
+    }
+
+    /**
      * 准备打印的数据
      */
     @RequestMapping("prePrint")

+ 2 - 0
sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsMapper.java

@@ -69,4 +69,6 @@ public interface TbFeeDetailsMapper extends BaseMapper<TbFeeDetails> {
     DetailSumDTO getTotalMoney(SoMap so);
 
     List<TbFeeStatistics> getDayStatistics(@Param("toDay") String toDay);
+
+    long countList(SoMap so);
 }

+ 33 - 0
sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsMapper.xml

@@ -181,6 +181,39 @@
         where DATE_FORMAT(pay_time, '%Y-%m-%d') = #{toDay}
         group by fee_type,pay_type
     </select>
+    <select id="countList" resultType="java.lang.Long">
+        select  count(id) from tb_fee_details
+        <where>
+            <if test=' this.has("id") '>and id = #{id}</if>
+            <if test=' this.has("businessId") '>and business_id = #{businessId}</if>
+
+            <if test=' this.has("businessNo") '>and (business_no like concat('%',#{businessNo},'%')
+                or business_car_no like concat('%',#{businessNo},'%'))
+            </if>
+            <if test=' this.has("carNo") '>and car_no like concat('%',#{carNo},'%')</if>
+            <if test=' this.has("transactionId") '>and transaction_id like concat('%',#{transactionId},'%')</if>
+            <if test=' this.has("pickCustomerName") '>and pick_customer_name like concat('%',#{pickCustomerName},'%')
+            </if>
+            <if test=' this.has("feeType") '>and fee_type = #{feeType}</if>
+            <if test=' this.has("itemTypeId") '>and item_type_id = #{itemTypeId}</if>
+            <if test=' this.has("itemTypeName") '>and item_type_name = #{itemTypeName}</if>
+            <if test=' this.has("itemId") '>and item_id = #{itemId}</if>
+            <if test=' this.has("itemName") '>and item_name like concat('%',#{itemName},'%')</if>
+            <if test=' this.has("itemPrice") '>and item_price = #{itemPrice}</if>
+            <if test=' this.has("payDay") '>and pay_day = #{payDay}</if>
+            <if test=' this.has("payType") '>and pay_type = #{payType}</if>
+            <if test=' this.has("createTime") '>and create_time = #{createTime}</if>
+            <if test=' this.has("beginTime") and this.has("endTime") '>
+                and pay_day >= #{beginTime}
+                and pay_day &lt;= #{endTime}
+            </if>
+            <if test=' this.has("type")'>and fee_type in (${type})</if>
+            <if test=' this.has("isInvoice")'>
+                <if test=' isInvoice == 0'>and invoice is null</if>
+                <if test=' isInvoice == 1'>and invoice is not null</if>
+            </if>
+        </where>
+    </select>
 
 
 </mapper>

+ 140 - 122
sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsService.java

@@ -8,6 +8,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.stream.Collectors;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
@@ -61,6 +62,7 @@ import com.pj.project4sp.global.BusinessException;
 import com.pj.project4sp.role.SpRole;
 import com.pj.project4sp.role.SpRoleMapper;
 import com.pj.project4sp.uploadfile.UploadUtil;
+import com.pj.utils.cache.RedisUtil;
 import com.pj.utils.sg.AjaxError;
 import com.pj.utils.so.SoMap;
 import lombok.extern.slf4j.Slf4j;
@@ -68,6 +70,7 @@ import org.apache.poi.ss.usermodel.BorderStyle;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.core.io.ClassPathResource;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -119,7 +122,7 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
     @Resource
     private TbItemService tbItemService;
     @Resource
-    private    TbCarWeightService tbCarWeightService;
+    private TbCarWeightService tbCarWeightService;
 
     /**
      * 增
@@ -369,9 +372,9 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
     }
 
 
-    public TbFeeDetails saveCarWeightDetails(String transactionId,BigDecimal totalPrice,String calculateId,String businessNo,
+    public TbFeeDetails saveCarWeightDetails(String transactionId, BigDecimal totalPrice, String calculateId, String businessNo,
                                              TbBusinessCar tbBusinessCar, String customerName, String pickCustomerName,
-                                             TbItem item,PayEnum.PayType payType) {
+                                             TbItem item, PayEnum.PayType payType) {
         Integer feeType = FeeTypeEnum.WEIGHT_FEE.getCode();
         double taxRate = BigDecimal.valueOf(item.getTaxRate()).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
         BigDecimal itemPrice = item.getPrice();
@@ -402,7 +405,7 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
                 .setNum(num + "")
                 .setModule(payType.getDesc());
         this.save(businessFeeDetail);
-       // taskService.addTask(new FeeDetailSyncTask(RandomUtil.randomNumbers(10), 1000, businessFeeDetail.getId(), SyncTypeEnum.INSERT.getCode(), PayEnum.PayType.PER_PAY));
+        // taskService.addTask(new FeeDetailSyncTask(RandomUtil.randomNumbers(10), 1000, businessFeeDetail.getId(), SyncTypeEnum.INSERT.getCode(), PayEnum.PayType.PER_PAY));
         return businessFeeDetail;
     }
 
@@ -415,140 +418,144 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
         return feeDetailsList;
     }
 
+
     public String export(SoMap so) {
-        Date now = new Date();
-        String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm");
+        String uuid = so.getString("uuid");
+        TbFeeDetailsService tbFeeDetailsService = this;
         String beginTime = so.getString("beginTime");
         String endTime = so.getString("endTime");
-        String time = "未选时间";
-        if (StrUtil.isNotEmpty(beginTime) && StrUtil.isNotEmpty(endTime)) {
-            time = beginTime + "至" + endTime;
-        }
-        Map<String, String> head = new HashMap<>();
-        head.put("time", time);
-        head.put("exportTime", nowStr);
-
-        BigDecimal allDayFee = new BigDecimal(0);
-        BigDecimal allDayTaxes = new BigDecimal(0);
-        BigDecimal allDayNoTaxFee = new BigDecimal(0);
-        List<ExportFeeDetailDTO> exportList = new ArrayList<>();
         List<String> ids = so.getListByComma("ids", String.class);
-        List<TbFeeDetails> list;
-        if (ids != null && !ids.isEmpty()) {
-            list = this.listByIds(ids);
-        } else {
-            list = this.getList(so);
-        }
-        if (list.size() > 2000) {
-            throw new AjaxError("导出数据量过大,请筛选");
+        if (StrUtil.isEmpty(beginTime) && StrUtil.isEmpty(endTime) && ids.isEmpty()) {
+            throw new AjaxError("请选择导出时间或者选择导出数据");
         }
-        int index = 1;
-        for (TbFeeDetails feeDetails : list) {
-//            TbFeeItem tbFeeItem = tbFeeItemService.getById(feeDetails.getFeeType());
-            ExportFeeDetailDTO detailDTO = new ExportFeeDetailDTO();
-            detailDTO.setBusinessNo(feeDetails.getBusinessNo()).setCarNo(feeDetails.getCarNo())
-                    .setFeeType(FeeTypeEnum.getDesc(feeDetails.getFeeType())).setItemTypeName(feeDetails.getItemTypeName())
-                    .setItemName(feeDetails.getItemName()).setItemPrice(feeDetails.getItemPrice())
-                    .setPayType(PayEnum.PayType.getDescByCode(feeDetails.getPayType())).setIndex(index++)
-                    .setPayMode(PayEnum.PayType.CASH_PAY.getDesc())
-                    .setWeight(feeDetails.getWeight()).setNum(feeDetails.getNum()).setUnitPrice(feeDetails.getUnitPrice())
-                    .setSettle("已结算").setTaxRate(feeDetails.getTaxRate().multiply(new BigDecimal(100)))
-                    .setTaxPrice(feeDetails.getTaxPrice()).setNoTaxPrice(feeDetails.getNoTaxPrice()).setPayTime(feeDetails.getPayTime())
-                    .setPickCustomerName(feeDetails.getPickCustomerName())
-                    .setCustomerName(feeDetails.getCustomerName())
-                    .setTransactionId(feeDetails.getTransactionId())
-                    .setKaiDanPerson(feeDetails.getKaiDanPerson())
-                    .setJiChaPerson(feeDetails.getJiChaPerson())
-                    .setDiaoDuPerson(feeDetails.getDiaoDuPerson());
-            if (!StrUtil.isEmpty(feeDetails.getBusinessId())) {
-                detailDTO.setBusinessNo(feeDetails.getBusinessNo());
+        ThreadUtil.execute(() -> {
+            Date now = new Date();
+            String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm");
+            String time = "未选时间";
+            if (StrUtil.isNotEmpty(beginTime) && StrUtil.isNotEmpty(endTime)) {
+                time = beginTime + "至" + endTime;
+            }
+            Map<String, String> head = new HashMap<>();
+            head.put("time", time);
+            head.put("exportTime", nowStr);
+            BigDecimal allDayFee = new BigDecimal(0);
+            BigDecimal allDayTaxes = new BigDecimal(0);
+            BigDecimal allDayNoTaxFee = new BigDecimal(0);
+            List<ExportFeeDetailDTO> exportList = new ArrayList<>();
+
+            List<TbFeeDetails> list;
+            if (ids != null && !ids.isEmpty()) {
+                list = tbFeeDetailsService.listByIds(ids);
             } else {
-                detailDTO.setBusinessNo(feeDetails.getBusinessCarNo());
+                list = tbFeeDetailsService.getList(so);
             }
-            exportList.add(detailDTO);
-            allDayFee = allDayFee.add(feeDetails.getItemPrice());
-            allDayTaxes = allDayTaxes.add(feeDetails.getTaxPrice());
-            allDayNoTaxFee = allDayNoTaxFee.add(feeDetails.getNoTaxPrice());
-        }
-
-
-        String separator = File.separator;
-        String today = DateUtil.today();
-        String rootPath = UploadUtil.uploadConfig.rootFolder + separator + UploadUtil.uploadConfig.httpPrefix;
-        String prefix = myConfig.getDomain() + UploadUtil.uploadConfig.httpPrefix;
-        String extPath = "feeDetails" + separator + today + separator;
-        String fileName = "收费明细表_" + time + ".xlsx";
-        String savePath = rootPath + separator + extPath;
-        File saveFIle = new File(savePath);
-        if (!saveFIle.exists()) {
-            saveFIle.mkdirs();
-        }
-
-        ClassPathResource classPathResource = new ClassPathResource("static/day-fee-new.xlsx");
-        //InputStream tempInputStream =classPathResource.getInputStream();
-        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
-        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
-        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
-        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
-        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
-        HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(
-                contentWriteCellStyle, contentWriteCellStyle);
-        ExcelWriter excelWriter = null;
-        try {
-            excelWriter = EasyExcel.write(savePath + fileName, ExportFeeDetailDTO.class)
-                    .registerWriteHandler(horizontalCellStyleStrategy)
-                    .withTemplate(classPathResource.getInputStream()).build();
-            WriteSheet writeSheet = EasyExcel.writerSheet().build();
-            // FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();//换行
-            excelWriter.fill(exportList, writeSheet);
-            excelWriter.fill(head, writeSheet);
-            List<List<String>> totalListList = ListUtils.newArrayList();//动态添加行集合
-            List<String> totalList2 = ListUtils.newArrayList();//倒数第2行
-            List<String> totalList1 = ListUtils.newArrayList();//倒数第1行
-            totalListList.add(totalList2);
-            totalListList.add(totalList1);
-            for (int i = 0; i < 22; i++) {
-                if (i == 0) {
-                    totalList2.add("合计");
-                } else if (i == 8) {
-                    totalList2.add(allDayFee.toString());
-                } else if (i == 11) {
-                    totalList2.add(allDayTaxes.toString());
-                } else if (i == 12) {
-                    totalList2.add(allDayNoTaxFee.toString());
-                } else {
-                    totalList2.add(null);
-                }
-                if (i == 2) {
-                    totalList1.add("收费核对员:");
-                } else if (i == 10) {
-                    totalList1.add("收费统计员:");
-                } else if (i == 18) {
-                    totalList1.add("收费员:");
+            if (list.size() > 2000) {
+                //throw new AjaxError("导出数据量过大,请筛选");
+            }
+            int index = 1;
+            for (TbFeeDetails feeDetails : list) {
+//            TbFeeItem tbFeeItem = tbFeeItemService.getById(feeDetails.getFeeType());
+                ExportFeeDetailDTO detailDTO = new ExportFeeDetailDTO();
+                detailDTO.setBusinessNo(feeDetails.getBusinessNo()).setCarNo(feeDetails.getCarNo())
+                        .setFeeType(FeeTypeEnum.getDesc(feeDetails.getFeeType())).setItemTypeName(feeDetails.getItemTypeName())
+                        .setItemName(feeDetails.getItemName()).setItemPrice(feeDetails.getItemPrice())
+                        .setPayType(PayEnum.PayType.getDescByCode(feeDetails.getPayType())).setIndex(index++)
+                        .setPayMode(PayEnum.PayType.CASH_PAY.getDesc())
+                        .setWeight(feeDetails.getWeight()).setNum(feeDetails.getNum()).setUnitPrice(feeDetails.getUnitPrice())
+                        .setSettle("已结算").setTaxRate(feeDetails.getTaxRate().multiply(new BigDecimal(100)))
+                        .setTaxPrice(feeDetails.getTaxPrice()).setNoTaxPrice(feeDetails.getNoTaxPrice()).setPayTime(feeDetails.getPayTime())
+                        .setPickCustomerName(feeDetails.getPickCustomerName())
+                        .setCustomerName(feeDetails.getCustomerName())
+                        .setTransactionId(feeDetails.getTransactionId())
+                        .setKaiDanPerson(feeDetails.getKaiDanPerson())
+                        .setJiChaPerson(feeDetails.getJiChaPerson())
+                        .setDiaoDuPerson(feeDetails.getDiaoDuPerson());
+                if (!StrUtil.isEmpty(feeDetails.getBusinessId())) {
+                    detailDTO.setBusinessNo(feeDetails.getBusinessNo());
                 } else {
-                    totalList1.add(null);
+                    detailDTO.setBusinessNo(feeDetails.getBusinessCarNo());
                 }
+                exportList.add(detailDTO);
+                allDayFee = allDayFee.add(feeDetails.getItemPrice());
+                allDayTaxes = allDayTaxes.add(feeDetails.getTaxPrice());
+                allDayNoTaxFee = allDayNoTaxFee.add(feeDetails.getNoTaxPrice());
             }
-            excelWriter.write(totalListList, writeSheet);
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (excelWriter != null) {
-                excelWriter.finish();
+            String separator = File.separator;
+            String today = DateUtil.today();
+            String rootPath = UploadUtil.uploadConfig.rootFolder + separator + UploadUtil.uploadConfig.httpPrefix;
+            String prefix = myConfig.getDomain() + UploadUtil.uploadConfig.httpPrefix;
+            String extPath = "feeDetails" + separator + today + separator;
+            String fileName = "收费明细表_" + time + ".xlsx";
+            String savePath = rootPath + separator + extPath;
+            File saveFIle = new File(savePath);
+            if (!saveFIle.exists()) {
+                saveFIle.mkdirs();
             }
-        }
 
-        return prefix + "/feeDetails/" + today + "/收费明细表_" + time + ".xlsx";
+            ClassPathResource classPathResource = new ClassPathResource("static/day-fee-new.xlsx");
+            //InputStream tempInputStream =classPathResource.getInputStream();
+            WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
+            contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
+            contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
+            contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
+            contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
+            HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(
+                    contentWriteCellStyle, contentWriteCellStyle);
+            ExcelWriter excelWriter = null;
+            try {
+                excelWriter = EasyExcel.write(savePath + fileName, ExportFeeDetailDTO.class)
+                        .registerWriteHandler(horizontalCellStyleStrategy)
+                        .withTemplate(classPathResource.getInputStream()).build();
+                WriteSheet writeSheet = EasyExcel.writerSheet().build();
+                // FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();//换行
+                excelWriter.fill(exportList, writeSheet);
+                excelWriter.fill(head, writeSheet);
+                List<List<String>> totalListList = ListUtils.newArrayList();//动态添加行集合
+                List<String> totalList2 = ListUtils.newArrayList();//倒数第2行
+                List<String> totalList1 = ListUtils.newArrayList();//倒数第1行
+                totalListList.add(totalList2);
+                totalListList.add(totalList1);
+                for (int i = 0; i < 22; i++) {
+                    if (i == 0) {
+                        totalList2.add("合计");
+                    } else if (i == 8) {
+                        totalList2.add(allDayFee.toString());
+                    } else if (i == 11) {
+                        totalList2.add(allDayTaxes.toString());
+                    } else if (i == 12) {
+                        totalList2.add(allDayNoTaxFee.toString());
+                    } else {
+                        totalList2.add(null);
+                    }
+                    if (i == 2) {
+                        totalList1.add("收费核对员:");
+                    } else if (i == 10) {
+                        totalList1.add("收费统计员:");
+                    } else if (i == 18) {
+                        totalList1.add("收费员:");
+                    } else {
+                        totalList1.add(null);
+                    }
+                }
+                excelWriter.write(totalListList, writeSheet);
+            } catch (IOException e) {
+                e.printStackTrace();
+            } finally {
+                if (excelWriter != null) {
+                    excelWriter.finish();
+                }
+            }
+            String path = prefix + "/feeDetails/" + today + "/收费明细表_" + time + ".xlsx";
+            RedisUtil.setBySECONDS(uuid, path, 10);
+        });
+        return uuid;
     }
 
-
-    public List<TbFeeDetails> findByBusinessCarId(String businessCarId, int feeType) {
-        QueryWrapper<TbFeeDetails> ew = new QueryWrapper<>();
-        ew.eq("business_car_id", businessCarId);
-        ew.eq("fee_type", feeType);
-        return list(ew);
+    private long countList(SoMap so) {
+        return tbFeeDetailsMapper.countList(so);
     }
 
+
     public PrintFeeDetailDTO prePrint(SoMap so) {
         so.clearNull();
         String beginTime = so.getString("beginTime");
@@ -755,4 +762,15 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
     }
 
 
+    public List<TbFeeDetails> findByTransactionIdList(List<String> transactionIdList) {
+        QueryWrapper<TbFeeDetails> ew = new QueryWrapper<>();
+        ew.lambda().in(TbFeeDetails::getTransactionId, transactionIdList);
+        return list(ew);
+    }
+
+    public List<TbFeeDetails> findByPreOrderNumList(List<String> preOrderNumList) {
+        QueryWrapper<TbFeeDetails> ew = new QueryWrapper<>();
+        ew.lambda().in(TbFeeDetails::getPreOrderNum, preOrderNumList);
+        return list(ew);
+    }
 }

+ 19 - 8
sp-server/src/main/java/com/pj/project/tb_invoice_info/TbInvoiceInfoService.java

@@ -158,7 +158,7 @@ public class TbInvoiceInfoService extends ServiceImpl<TbInvoiceInfoMapper, TbInv
             List<TbFeeDetails> feeDetailsList = tbFeeDetailsService.findByTransactionId(invoiceOrder.getTransactionId());
             for (TbFeeDetails detail : feeDetailsList) {
                 String invoice = detail.getInvoice();
-                invoice = StrUtil.isEmpty(invoice) ? invoiceNo : invoice+","+invoiceNo;
+                invoice = StrUtil.isEmpty(invoice) ? invoiceNo : invoice + "," + invoiceNo;
                 detail.setInvoice(invoice).setEntityName(t.getEntityName()).setCustomerName(customerName).setUpdateTime(new Date());
             }
             tbFeeDetailsService.updateBatchById(feeDetailsList);
@@ -183,17 +183,28 @@ public class TbInvoiceInfoService extends ServiceImpl<TbInvoiceInfoMapper, TbInv
         */
     }
 
-    public List<FeeDeatilsGroup> getDetailsById(String id){
-        String jsonStr = RedisUtil.get("invoicedetails:" + id );
-        if(StrUtil.isNotEmpty(jsonStr)){
+    public List<FeeDeatilsGroup> getDetailsById(String id) {
+        String jsonStr = RedisUtil.get("invoicedetails:" + id);
+        if (StrUtil.isNotEmpty(jsonStr)) {
             JSONArray objects = JSONUtil.parseArray(jsonStr);
-            List<FeeDeatilsGroup> grouping = JSONUtil.toList(objects, FeeDeatilsGroup.class);
-            return grouping;
+            return JSONUtil.toList(objects, FeeDeatilsGroup.class);
         }
         List<TbInvoiceOrder> invoiceOrderList = tbInvoiceOrderService.findByInfoId(id);
         List<TbFeeDetails> allDetailsList = new ArrayList<>();
-        for (TbInvoiceOrder invoiceOrder : invoiceOrderList) {
-            List<TbFeeDetails> detailsList = tbFeeDetailsService.findByTransactionId(invoiceOrder.getTransactionId());
+        //微信支付的
+        List<String> transactionIdList = invoiceOrderList.stream()
+                .filter(tbInvoiceOrder -> StrUtil.isNotEmpty(tbInvoiceOrder.getTransactionId()))
+                .map(TbInvoiceOrder::getTransactionId).collect(Collectors.toList());
+        if (!transactionIdList.isEmpty()) {
+            List<TbFeeDetails> detailsList = tbFeeDetailsService.findByTransactionIdList(transactionIdList);
+            allDetailsList.addAll(detailsList);
+        }
+        //+预存款支付的
+        List<String> preOrderNumList = invoiceOrderList.stream()
+                .filter(tbInvoiceOrder -> StrUtil.isNotEmpty(tbInvoiceOrder.getPreOrderNum()))
+                .map(TbInvoiceOrder::getPreOrderNum).collect(Collectors.toList());
+        if (!preOrderNumList.isEmpty()){
+            List<TbFeeDetails> detailsList = tbFeeDetailsService.findByPreOrderNumList(preOrderNumList);
             allDetailsList.addAll(detailsList);
         }
         List<FeeDeatilsGroup> groups = new ArrayList<>();

+ 1 - 0
sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrder.java

@@ -124,6 +124,7 @@ public class TbInvoiceOrder implements Serializable {
      * 开票信息明细Id
      */
     public String detailId;
+
 	/**
 	 * 扣费记录ID
 	 */

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrderService.java

@@ -355,7 +355,7 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
                 .setCustomerId(customerId)
                 .setCustomerName(customerName)
                 .setEntityName(entityName)
-                .setBillMoney(billMoney).setDetailId(details.getId())
+                .setBillMoney(billMoney)
                 .setPreOrderNum(details.getPreOrderNum())
                 .setDeductionRecordId(record.getId())
                 .setStatus(0).setCreateTime(new Date());

+ 2 - 0
sp-server/src/main/java/com/pj/project/tb_order/TbOrder.java

@@ -49,6 +49,8 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
      */
     private String outTradeNo;
 
+    private String businessCarId;
+
     /**
      * 额外字段
      */

+ 9 - 8
sp-server/src/main/resources/application-dev.yml

@@ -31,7 +31,7 @@ spring:
         # password:
         # 连接超时时间(毫秒)
         timeout: 5000ms
-        lettuce:
+        jedis:
             pool:
                 # 连接池最大连接数
                 max-active: 200
@@ -66,7 +66,7 @@ spring:
 part-config:
     base-price: 30 #基础费用
     extra-price: 10 #过夜额外收费
-    free-minutes: 30
+    free-minutes: 2
     free-car-length: 4.2
     tax-rate: 0.09
     test-env: true
@@ -111,16 +111,17 @@ ocr-config:
 pushfee-config:
     enable: true
     remote-public-key-base6: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCb5yK85EKqwiQU+z1jyjOng6ecssQpEjC6STbCuSWN6KHLkijBxdqrCumXhbIyOVx4lHK9Rg5EjzlQxoaXQTgJdItaGjLC+UTE+NNAnnaFLg0x4jajNpLo473zdZxTYQaT3q/aKnTeXuKHw11PPUe4hmmfxPcdt9yJ0Iqo/XxV3QIDAQAB
-    sync-url: https://charge.gxbtka.com/gateway
+    sync-url: http://117.141.148.233:3101/gateway/
     sys-id: "0110"
-    sys-name: "东兴口岸(二桥)进口货物集散区 (A1地块)"
+    sys-name: 东兴口岸场站系统
     yield-id: 0001-a1
     yield-name: 东兴口岸场站系统-A1园区
-    start-time: 2022-08-10 00:00:00  #默认时间间隔为一小时
+    start-time: 2022-08-10 00:00:00
+    #默认时间间隔为一小时
     time-span: 3600000
-    client-public-key-base6: "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7f7ySq8nAxHMiWtzOCCMqU5A32zApObtLUKiInIZAyi9gfPpwNiy038yd3Na/erGF/rV97RD5ReqHVAaqSl26A9RIlA+TeZdLYcybtLAIPd/iIwr7QS+qFB/2ierJzVWgVyLNHfrAKmU7B1TF8sxZlhpiEpCopehd381fvgXTkwIDAQAB"
-    client-private-key-base6: "MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBALt/vJKrycDEcyJa3M4IIypTkDfbMCk5u0tQqIichkDKL2B8+nA2LLTfzJ3c1r96sYX+tX3tEPlF6odUBqpKXboD1EiUD5N5l0thzJu0sAg93+IjCvtBL6oUH/aJ6snNVaBXIs0d+sAqZTsHVMXyzFmWGmISkKil6F3fzV++BdOTAgMBAAECgYEAuQET9wDMRIlSNU7EWgLLd+MWBRcgUT0moezHLmyLR3h4ANOwZHH/8MR2aDlUJ4EPkvA88jCtM9iZzcfJ/9L64HDmIff83mpdgSquJvAeGLF+FlSBv4bpFVgwqpI4HmFkHJm7Sbbt1VNQkvwIWBJQLrmcX3PFxQcoWi7aNQUv88ECQQD6Lv3f8Fc1hQG95hL+Y08fsEMsELnEdUG1iXmTz2qBCuHBWuYNi2hcstJbW1LQ2zqgGygA3gZkKx3IsJ+9LZPhAkEAv9uq1xdgHtOl/OoSIJA8AOpAHrBJylHKKw8ow8Feefy5I2fe4mMf+p1Vq7hBNnCbrYiVVxaAPRH8C2R8MsEV8wJBAORslVWqviVabG2zLHJhv/OB3sLT/pj2KmmSvJONVIO/qMH+uX9yYnYIu3G4HxQcphla0hqAnTtF9qqvQRncDGECQQCgFU8QF54JOroGNNyZNSAL92k28gsv+FzC3uw5ojANgxSLeVDc/q6hMwRXuu8W2JDdE9jgCJNJ4aa3bsm+o6OHAkEAhYs00qflVJUjN0+tnpaIUipwpMnTlC4iD9sN7MTGdWrbASQe7StlKVkDT2pvfKBw5p+jFXwVYasm6GI4609K7A=="
-    server-public-key-base6: "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuSXMent4dXl9SE9hSUsxWre303rkguPJz+k9CqM0J6fUzYnrAfRES+Mu6xmrbpGnGe+v9ZxBH4jxGakyKLTdmuiaZC3kRDgjsPOwTtSAoAOQhj0Hw2X3obrxeqpJYwg3DQS1JWZzv7+QdVPxBkj+PAJtc1bacD1H4Kg9OyeD9XwIDAQAB"
+    client-public-key-base6: "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCimSu5J8apt2YR/o9joOCNdFzO3rOHcdcqnSCm1Wt19VwskTVjkKHc/CXHUoskX5vMiMiv6xPnf/lDpMO6KnCrwlVQFtbPvmnkwyUs/haW8ggR865MqDcBpdMGnuV0YJ04UXxSrOX+eu+dl91Web4/ZiRKbObOa8WhFm/Ln2QKswIDAQAB"
+    client-private-key-base6: "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKKZK7knxqm3ZhH+j2Og4I10XM7es4dx1yqdIKbVa3X1XCyRNWOQodz8JcdSiyRfm8yIyK/rE+d/+UOkw7oqcKvCVVAW1s++aeTDJSz+FpbyCBHzrkyoNwGl0wae5XRgnThRfFKs5f56752X3VZ5vj9mJEps5s5rxaEWb8ufZAqzAgMBAAECgYAmP/QaLXI9kIgxaXnfzQOmIx6GB7uh/DTKsIXy2TfbWunhDhPKJUb+jk5w0kkrOFaVSgQz5hAboG5J7GOi0sMINLb7H2WsOm3uGM/8HPZYsrNFnB8VUiD26LIZ6+HhPXfp/LN+k5eUnUlD6z/dZU1k6hJPOSFC3PyzfBWqaQMqGQJBAMVdQ9Uw+eC94qD1MSSEQZhqpfGE4vO7WrSACLFqyZrHvaIwZTjdUZRF1aMlJyT0afOkfSN/53QQEcejXMUrSBcCQQDS576SXkpdfrN2jmr9BAimi+6AP71GUgXL3O+2yRL2szLoU7GwtMREPBFw+ocnC4UN87NCYveJCzenQEt48JfFAkAqEIa0mYuoatAyng+rSMTyR0i3ASud5wCeF+vCZJAzfP7d4pKwW/tXLsspynFdXvp2A0jomAosooAnnJnZLDBhAkBzXoXm92Fip45wShPIeE5rHJzI1xUoxHGbRS50JKYVAY3VfQL0kM3ULa+0x7bq6uhL64WhyRVziAlXmlouvB2pAkEAuDvsjVhdo3uMGL7Tr+igPhajoWUTjPuAf+Od3SsqMTPFLBpbJM8ziXk39Me9S8wqgGwR3pnlC1Z6Rybgm+uy4g=="
+    server-public-key-base6: "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCb5yK85EKqwiQU+z1jyjOng6ecssQpEjC6STbCuSWN6KHLkijBxdqrCumXhbIyOVx4lHK9Rg5EjzlQxoaXQTgJdItaGjLC+UTE+NNAnnaFLg0x4jajNpLo473zdZxTYQaT3q/aKnTeXuKHw11PPUe4hmmfxPcdt9yJ0Iqo/XxV3QIDAQAB"
     server-private-key-base64: "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJvnIrzkQqrCJBT7PWPKM6eDp5yyxCkSMLpJNsK5JY3oocuSKMHF2qsK6ZeFsjI5XHiUcr1GDkSPOVDGhpdBOAl0i1oaMsL5RMT400CedoUuDTHiNqM2kujjvfN1nFNhBpPer9oqdN5e4ofDXU89R7iGaZ/E9x233InQiqj9fFXdAgMBAAECgYASoeKgcaVYFCDM0yQIn5thy1XGYAUapX5mXSaqygbneWSQ2FR/qB5Ur9awEb30y682CAPYhB1jazyd30QpopVINvyhaWhgq1b/8KD92FqOg1eXxa7bTuTe8aMuKTB/ZJjEry0d5Mu3i6zYKtTSbnpnag5I3UE5awLDy7utYOoOHwJBAPtvz2ZBhtJvL3lsMgs7kGqrPqqI2LAX8J3oOCtE/6eQjQ0I5fBCybrwHp3baDrYul5KTL3kJvl4iWN/gHDi/nMCQQCeu3gzy0DVtM8M8bzFc/ZA753WRn4Z5axQa6lE7Tski8TUw4Bhbfan9E/C6l6Guo/+2hXPAE/RMcncClqeXXZvAkEAgf6FsO1x4fxABDvvB6Ws/ak5hfuoZCqMaWd1GtHah2yRsEqIbxZoq7CXc6/LDJmeiT9Ku+ZoTBSIm5uA8Vw6hwJALEbs872pmzMxYlH4Lzf2pAxzAbduK3kmhNRTRjfKfJpEUHksUYEkAZujuCI6NejKi/N3i+NxYFA8F5YHyw8VHwJAWoiYSYLSziHgDytoPKFvUp6EKLGDClhACJKc4LuaPNWICMxb5Dp88sY0NDYb4HzCyWIE5G4vbiF/K3kEEwCIVA=="
 
 oa: