Переглянути джерело

Merge branch 'dev' into debug

qzyReal 3 роки тому
батько
коміт
4987e5f41b
31 змінених файлів з 396 додано та 176 видалено
  1. 22 14
      app/pages/wx/pay.vue
  2. 2 2
      app/utils/request.js
  3. 27 2
      sp-admin/sa-frame/menu-list.js
  4. 34 24
      sp-admin/sa-view/tb-business-car/tb-business-car-list.html
  5. 2 2
      sp-admin/sa-view/tb-fee-statistics/month-statistcs-list.html
  6. 1 0
      sp-admin/sa-view/tb-fee-statistics/tb-fee-details-list.html
  7. 1 1
      sp-admin/static/sa.js
  8. 1 0
      sp-server/app.pid
  9. 4 1
      sp-server/pom.xml
  10. 2 0
      sp-server/src/main/java/com/pj/api/h5/ApiController.java
  11. 20 1
      sp-server/src/main/java/com/pj/api/jh/api/JhController.java
  12. 22 0
      sp-server/src/main/java/com/pj/api/jh/bo/JhNotifyBO.java
  13. 47 21
      sp-server/src/main/java/com/pj/api/jh/service/JhService.java
  14. 39 0
      sp-server/src/main/java/com/pj/api/jh/utils/JhHttpUtils.java
  15. 3 3
      sp-server/src/main/java/com/pj/api/jh/utils/MerchantApiUtil.java
  16. 8 1
      sp-server/src/main/java/com/pj/api/open/service/OpenService.java
  17. 17 11
      sp-server/src/main/java/com/pj/api/service/ApiService.java
  18. 1 0
      sp-server/src/main/java/com/pj/api/wx/api/WxController.java
  19. 2 0
      sp-server/src/main/java/com/pj/api/wx/bo/NotifyBO.java
  20. 6 15
      sp-server/src/main/java/com/pj/api/wx/service/WxService.java
  21. 0 1
      sp-server/src/main/java/com/pj/current/satoken/SaTokenConfigure.java
  22. 1 1
      sp-server/src/main/java/com/pj/project/tb_business/TbBusiness.java
  23. 1 1
      sp-server/src/main/java/com/pj/project/tb_business/TbBusinessService.java
  24. 4 0
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCar.java
  25. 10 3
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarController.java
  26. 6 0
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.xml
  27. 17 4
      sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java
  28. 88 62
      sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsService.java
  29. 7 5
      sp-server/src/main/java/com/pj/project/tb_fee_statistics/TbFeeStatisticsService.java
  30. 1 1
      sp-server/src/main/resources/application-dev.yml
  31. BIN
      sp-server/src/main/resources/static/day-fee-new.xlsx

+ 22 - 14
app/pages/wx/pay.vue

@@ -30,7 +30,7 @@
 							</view>
 							<view class="c">{{item.carNo}}</view>
 							<view class="r" v-if="item.price>0">{{item.price}}元</view>
-								<view class="r" v-else>无需缴费</view>
+							<view class="r" v-else>无需缴费</view>
 						</label>
 					</view>
 				</u-checkbox-group>
@@ -91,7 +91,7 @@
 				state: '',
 				list: [],
 				cars: [],
-				type:0,
+				type: 0,
 				businessAble: true,
 				item: {
 					itemsPrice: 0,
@@ -114,6 +114,9 @@
 			this.state = options.state;
 			this.getOpenidByCode();
 		},
+		onShow() {
+			this.$common.hidingLoading();
+		},
 		created() {},
 		mounted() {
 			this.getChannelCar();
@@ -178,7 +181,7 @@
 			confirmPayFn() {
 				let carIds = this.carsSelect
 				let cars = this.cars.filter(obj => carIds.indexOf(obj.id) !== -1);
-				let carNos=this.cars.map(obj=>obj.carNo).join('、')
+				let carNos = this.cars.map(obj => obj.carNo).join('、')
 				let p = {
 					b: this.businessSelect.length > 0 ? this.item.businessId : '',
 					c: JSON.stringify(cars.map(obj => {
@@ -191,17 +194,22 @@
 					tradeType: "JSAPI",
 					openid: this.openid
 				}
-				let type=this.type;
-				let con='A1停车费';
-				if(type==2){
-					con='A1整车业务';
-				}else if(type==1){
-					con='A1车辆消杀'
+				let type = this.type;
+				let con = 'A1停车费';
+				if (type == 2) {
+					con = 'A1整车业务';
+				} else if (type == 1) {
+					con = 'A1车辆消杀'
 				}
-				p.desc=con+'-'+carNos;
-				this.$api.getPrePay(this.$common.removeNull(p)).then(resp => {
+				p.desc = con + '-' + carNos;
+				this.$common.showLoading('正在请求...');
+				let that = this;
+				that.$api.getPrePay(that.$common.removeNull(p)).then(resp => {
 					let data = resp.data;
-					let that = this;
+					if (resp.code !== 200) {
+						that.$common.toast(resp.msg);
+						return;
+					}
 					jweixin.chooseWXPay({
 						timestamp: data
 							.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
@@ -245,9 +253,9 @@
 				}).then(resp => {
 					let data = resp.data;
 					this.cars = data.carList;
-					this.type=data.type;
+					this.type = data.type;
 					let list = data.itemList;
-					this.carsSelect = this.cars.filter(obj => obj.id == carId &&obj.price>0).map(obj => obj.id)
+					this.carsSelect = this.cars.filter(obj => obj.id == carId && obj.price > 0).map(obj => obj.id)
 					Object.assign(this.item, {
 						itemsPrice: data.itemsPrice,
 						businessId: data.businessId,

+ 2 - 2
app/utils/request.js

@@ -1,5 +1,5 @@
-const server = 'http://127.0.0.1:8099/pro';
-// const server = 'http://pco.aseanbusiness.cn/pro';
+// const server = 'http://127.0.0.1:8099/pro';
+const server = 'https://pco.aseanbusiness.cn/pro';
 // const server = 'https://dxkaa1.bgigc.com/pro';
 
 import common from '../common/js/common.js';

+ 27 - 2
sp-admin/sa-frame/menu-list.js

@@ -331,8 +331,33 @@ var menuList = [{
 		childList: [{
 			id: 'tb-business-car-list',
 			name: '放行列表',
-
-			url: 'sa-view/tb-business-car/tb-business-car-list.html'
+			url: 'sa-view/tb-business-car/tb-business-car-list.html',
+			childList:[
+				{
+				
+					id: 'tb-business-car-add',
+					name: '添加记录',
+					isShow: false
+				},
+				{
+				
+					id: 'tb-business-car-export',
+					name: '导出记录',
+					isShow: false
+				},
+				{
+				
+					id: 'tb-business-car-edit',
+					name: '修改记录',
+					isShow: false
+				},
+				{
+				
+					id: 'tb-business-car-del',
+					name: '删除记录',
+					isShow: false
+				},
+			]
 		}, ]
 	},
 	{

+ 34 - 24
sp-admin/sa-view/tb-business-car/tb-business-car-list.html

@@ -18,7 +18,6 @@
 	<body>
 		<div class="vue-box" style="display: none;" :style="'display: block;'">
 			<div class="c-panel">
-				<div class="c-title">检索参数</div>
 				<el-form ref="form" :model='p' @submit.native.prevent>
 					<sa-item type="text" name="车牌号" v-model="p.carNo"></sa-item>
 					<div class="c-item">
@@ -37,6 +36,15 @@
 							<el-option label="未离场" value="3"> </el-option>
 						</el-select>
 					</div>
+					<div class="c-item" style="width: 120px;">
+						<label class="c-label">车辆颜色:</label>
+						<el-select v-model="p.color" placeholder="请选择">
+							<el-option label="-全部-" value=""> </el-option>
+							<el-option v-for="(item,index) in colorList" :key="index" :label="item.carNoColor"
+								:value="item.carNoColor"> </el-option>
+
+						</el-select>
+					</div>
 				</el-form>
 				<el-form>
 					<div class="c-item">
@@ -52,10 +60,18 @@
 						</el-date-picker>
 					</div>
 					<el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
-					<el-button size="mini" type="primary" @click="exportFn">导出</el-button>
+					<el-button size="mini" type="primary" @click="exportFn" v-if="sa.isAuth('tb-business-car-export')">导出</el-button>
 					<el-button size="mini" type="info" @click="sa.f5()">重置</el-button>
-					<el-button size="mini" type="primary" @click="add()">
+					<el-button size="mini" type="primary" @click="add()" v-if="sa.isAuth('tb-business-car-add')">
 						新增</el-button>
+						<br/>
+					<sa-item name="综合排序">
+						<el-radio-group v-model="p.sortType" class="s-radio-text">
+							<el-radio :label="10">默认</el-radio>
+							<el-radio :label="6">入场时间</el-radio>
+							<el-radio :label="7">离场时间</el-radio>
+						</el-radio-group>
+					</sa-item>
 				</el-form>
 				<!-- ------------- 数据列表 ------------- -->
 				<el-table class="data-table" ref="data-table" :data="dataList">
@@ -88,9 +104,10 @@
 						<template slot-scope="s">
 							<el-button class="c-btn" type="success" icon="el-icon-view" @click="get(s.row)">查看
 							</el-button>
-							<el-button v-if="sa.isAuth('tb-business-edit')" class="c-btn" type="primary"
+							<el-button v-if="sa.isAuth('tb-business-car-edit')" class="c-btn" type="primary"
 								icon="el-icon-edit" @click="update(s.row)">修改
 							</el-button>
+							<el-button v-if="sa.isAuth('tb-business-car-del')&&s.row.money==0" class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除</el-button>
 						</template>
 					</el-table-column>
 				</el-table>
@@ -112,6 +129,7 @@
 					p: { // 查询参数
 						id: '', //  
 						businessId: sa.p('id', ''), //  
+						color: '',
 						carNo: '', //  
 						leave: '1',
 						pay: '',
@@ -123,8 +141,18 @@
 					},
 					dataCount: 0,
 					dataList: [], // 数据集合 
+					colorList: []
 				},
 				methods: {
+					getCarColor() {
+						sa.ajax('/TbCarNoColor/getList', {
+							pageNo: 1,
+							pageSize: 20,
+							status: 1
+						}, function(resp) {
+							this.colorList = resp.data;
+						}.bind(this))
+					},
 					exportFn() {
 						this.$confirm('确定导出符合条件的数据?', '提示', {
 							confirmButtonText: '确定',
@@ -179,36 +207,18 @@
 					// 删除
 					del: function(data) {
 						sa.confirm('是否删除,此操作不可撤销', function() {
-							sa.ajax('/TbBusinessCar/delete?id=' + data.id, function(res) {
+							sa.ajax('/TbBusinessCar/deleteRecord?id=' + data.id, function(res) {
 								sa.arrayDelete(this.dataList, data);
 								sa.ok('删除成功');
 								sa.f5TableHeight(); // 刷新表格高度 
 							}.bind(this))
 						}.bind(this));
 					},
-					// 改 - 状态(0=否,1=是)
-					updateStatus: function(data) {
-						// 声明变量记录是否成功 
-						var isOk = false;
-						var oldValue = data.isLock;
-						var ajax = sa.ajax('/TbBusinessCar/updateStatus', {
-							id: data.id,
-							value: data.isLock
-						}, function(res) {
-							isOk = true;
-							sa.msg('修改成功');
-						}.bind(this));
-						// 如果未能修改成功, 则回滚 
-						$.when(ajax).done(function() {
-							if (isOk == false) {
-								data.isLock = oldValue;
-							}
-						})
-					},
 				},
 				created: function() {
 					this.f5();
 					sa.onInputEnter();
+					this.getCarColor();
 				}
 			})
 		</script>

+ 2 - 2
sp-admin/sa-view/tb-fee-statistics/month-statistcs-list.html

@@ -110,9 +110,9 @@
 					f5: function() {
 						if ( this.selectMonth != null && this.selectMonth.length != 0) {
 							this.selectMonthRange.beginMonth = this.selectMonth[0];
-							this.selectMonthRange.beginMonth = this.selectMonth[1];
+							this.selectMonthRange.endMonth = this.selectMonth[1];
 						}
-						sa.ajax('/TbFeeStatistics/getMonth?beginMonth='+this.selectMonthRange.beginMonth+"&endMonth="+this.selectMonthRange.beginMonth,
+						sa.ajax('/TbFeeStatistics/getMonth?beginMonth='+this.selectMonthRange.beginMonth+"&endMonth="+this.selectMonthRange.endMonth,
 								sa.removeNull(this.p), function(res) {
 							this.dataList = res.data; // 数据
 							this.dataCount = res.dataCount; // 数据总数 

+ 1 - 0
sp-admin/sa-view/tb-fee-statistics/tb-fee-details-list.html

@@ -21,6 +21,7 @@
 				<div class="c-title">检索参数</div>
 				<el-form ref="form" :model='p' @submit.native.prevent>
 					<div class="c-item">
+						<sa-item type="text" name="车牌号" v-model="p.carNo"></sa-item>
 						<label class="c-label">收费项目:</label>
 						<el-select v-model="p.feeType" placeholder="请选择" filterable>
 							<el-option label="核酸检测" value="1"></el-option>

+ 1 - 1
sp-admin/static/sa.js

@@ -14,7 +14,7 @@ var sa = {
 	}
 	// 服务器测试环境
 	var cfg_test = {
-		api_url: 'http://pco.aseanbusiness.cn/pro',
+		api_url: 'https://pco.aseanbusiness.cn/pro',
 		web_url: 'http://www.baidu.com'
 	}
 	// 正式生产环境

+ 1 - 0
sp-server/app.pid

@@ -0,0 +1 @@
+25324

+ 4 - 1
sp-server/pom.xml

@@ -45,7 +45,10 @@
             <artifactId>pagehelper-spring-boot-starter</artifactId>
             <version>1.2.13</version>
         </dependency>
-        
+		<dependency>
+			<groupId>org.springframework.retry</groupId>
+			<artifactId>spring-retry</artifactId>
+		</dependency>
 		<!-- mysql -->
 		<dependency>
 			<groupId>mysql</groupId>

+ 2 - 0
sp-server/src/main/java/com/pj/api/h5/ApiController.java

@@ -2,6 +2,7 @@ package com.pj.api.h5;
 
 
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.log.StaticLog;
 import com.pj.api.bo.InOutRecordBO;
 import com.pj.api.service.ApiService;
 import com.pj.constants.RoleEnum;
@@ -115,6 +116,7 @@ public class ApiController {
 
     @GetMapping(value = "getPartCarByChannel")
     public AjaxJson getPartCarByChannel(String channel) {
+        StaticLog.error("查询通道车辆:{}",channel);
         return AjaxJson.getSuccessData(apiService.getPartCarByChannel(channel));
     }
 

+ 20 - 1
sp-server/src/main/java/com/pj/api/jh/api/JhController.java

@@ -1,11 +1,13 @@
 package com.pj.api.jh.api;
 
 import cn.hutool.core.util.XmlUtil;
+import com.pj.api.jh.bo.JhNotifyBO;
 import com.pj.api.jh.service.JhService;
 import com.pj.utils.sg.AjaxJson;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
@@ -29,9 +31,26 @@ public class JhController {
 
     @Resource
     JhService jhService;
+
     @RequestMapping(value = "init-pay")
-    public AjaxJson prePay( HttpServletRequest request) throws Exception {
+    public AjaxJson prePay(HttpServletRequest request) throws Exception {
         return AjaxJson.getSuccessData(jhService.initPay(request));
     }
+    @RequestMapping(value = "notify")
+    public String notifyResult(JhNotifyBO bo) {
+        jhService.notifyResult(bo);
+        return "SUCCESS";
+    }
+
+
+    @RequestMapping(value = "check-pay-result")
+    public AjaxJson checkPayResult(@RequestParam String outTradeNo) {
+        return AjaxJson.getSuccessData(jhService.checkPayResult(outTradeNo));
+    }
+
+    @RequestMapping(value = "refund")
+    public AjaxJson refund(@RequestParam String outTradeNo) {
+        return AjaxJson.getSuccessData(jhService.checkPayResult(outTradeNo));
+    }
 
 }

+ 22 - 0
sp-server/src/main/java/com/pj/api/jh/bo/JhNotifyBO.java

@@ -0,0 +1,22 @@
+package com.pj.api.jh.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+@Data
+public class JhNotifyBO implements Serializable {
+    private String businessMerchantNo;
+    private String orderPrice;
+    private String outTradeNo;
+    private String bankOrderNo;
+    private String productName;
+    private String productType;
+    private String tradeStatus;
+    private String successTime;
+    private String orderTime;
+    private String trxNo;
+    private String remark;
+    private String sign;
+    private String attach;
+    private String bankTrxNo;
+}

+ 47 - 21
sp-server/src/main/java/com/pj/api/jh/service/JhService.java

@@ -3,19 +3,21 @@ package com.pj.api.jh.service;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.crypto.SecureUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.log.StaticLog;
-import com.pj.api.jh.MerchantApiUtil;
-import com.pj.api.wx.WxUtils;
+import com.pj.api.jh.utils.JhHttpUtils;
+import com.pj.api.jh.utils.MerchantApiUtil;
+import com.pj.api.jh.bo.JhNotifyBO;
 import com.pj.api.wx.bo.Attach;
+import com.pj.api.wx.bo.NotifyBO;
 import com.pj.api.wx.service.WxService;
 import com.pj.current.config.JhConfig;
 import com.pj.current.config.MyConfig;
-import com.pj.current.config.WxConfig;
+import com.pj.current.config.PartConfig;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -23,10 +25,8 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * @Auther: lzm
@@ -39,27 +39,29 @@ import java.util.Set;
 public class JhService {
 
     @Resource
-    WxConfig wxConfig;
-    @Resource
     MyConfig myConfig;
     @Resource
     JhConfig jhConfig;
     @Resource
-    WxUtils wxUtils;
+    PartConfig partConfig;
     @Resource
     WxService wxService;
 
+    @Resource
+    JhHttpUtils jhHttpUtils;
+
     public JSONObject initPay(HttpServletRequest request) throws Exception {
         String money = request.getParameter("money");
-//        String openid = request.getParameter("openid");
-        String openid = "oDWvn5w-hVkzUuKeY7OBXBV_l1rU";
+        String openid = request.getParameter("openid");
+        String desc = request.getParameter("desc");
         String businessId = request.getParameter("b");
         String c = request.getParameter("c");
         String a = request.getParameter("a");
         Attach atchMap = new Attach();
         atchMap.setC(c).setB(businessId).setA(a);
         String out_trade_no = RandomUtil.randomString(30);
-        Map<String, String> params = new HashMap<>();
+        StaticLog.info("outTradeNo:{}",out_trade_no);
+        Map<String, Object> params = new HashMap<>();
         params.put("attach", JSONUtil.toJsonStr(atchMap));
         params.put("productType", jhConfig.getProductType());
         params.put("businessMerchantNo", jhConfig.getBusinessMerchantNo());
@@ -67,26 +69,23 @@ public class JhService {
         params.put("merchantNo", jhConfig.getBusinessMerchantNo());
         params.put("tradeType", jhConfig.getTradeType());
         params.put("subTradeType", "");
-//        String total_free = money+"";
-        String total_free = "0.01";
+        String total_free = partConfig.isTestEnv() ? "0.01" : money + "";
         log.info("order price:{}", total_free);
         params.put("orderPrice", total_free);
         params.put("outTradeNo", out_trade_no);
-        params.put("productName", "业务订单支付");
+        params.put("productName", desc);
         params.put("orderIp", WxService.getIpAddress(request));
         String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
         params.put("orderTime", now);
         params.put("returnUrl", "");
-        params.put("notifyUrl", myConfig.getDomain() + "/wx/notify");
-        params.put("remark", "业务订单支付");
+        params.put("notifyUrl", myConfig.getDomain() + "/jh/notify");
+        params.put("remark", desc);
         String paySecrit = jhConfig.getPaySecret();
         String sign = MerchantApiUtil.getSign(params, paySecrit);
         params.put("sign", sign);
-
         String jsonParam = JSONUtil.toJsonStr(params);
         String initPayUrl = jhConfig.getServerUrl() + "/uaps-web-gateway/cnpPay/initPay";
-        String result = HttpUtil.createPost(initPayUrl).header("Content-Type", "application/json").body(jsonParam)
-                .execute().body();
+        String result = jhHttpUtils.postJson(initPayUrl,jsonParam);
         StaticLog.info("调用聚合支付返回:{}", result);
         JSONObject jsonResult = JSONUtil.parseObj(result);
         if (StrUtil.equals("0000", jsonResult.get("resultCode").toString())) {
@@ -94,10 +93,37 @@ public class JhService {
             String p = payMessage.getStr("package");
             Map<String, String> r = wxService.getPayP(payMessage.getStr("timeStamp"), payMessage.getStr("nonceStr"), openid, p);
             StaticLog.info("re:{}", JSONUtil.toJsonStr(r));
-            return JSONUtil.parseObj(payMessage);
+            JSONObject object = JSONUtil.parseObj(payMessage);
+            object.set("outTradeNo", out_trade_no);
+            return object;
         }
         throw new Exception("支付信息有误");
     }
 
 
+    public JSONObject checkPayResult(String outTradeNo) {
+        String url = jhConfig.getServerUrl() + "/uaps-web-gateway/query/singleOrder";
+        Map<String, Object> params = new HashMap<>();
+        params.put("businessMerchantNo", jhConfig.getBusinessMerchantNo());
+        params.put("outTradeNo", outTradeNo);
+        String paySecrit = jhConfig.getPaySecret();
+        String sign = MerchantApiUtil.getSign(params, paySecrit);
+        params.put("sign", sign);
+        String result = jhHttpUtils.postForm(url,params);
+        StaticLog.info("调用聚合支付查询支付接口返回:{}", result);
+        return JSONUtil.parseObj(result);
+    }
+    @Async
+    public void notifyResult(JhNotifyBO bo) {
+        StaticLog.info("聚合支付回调:{}", JSONUtil.toJsonStr(bo));
+        if (!"SUCCESS".equals(bo.getTradeStatus().toUpperCase())){
+            return;
+        }
+        NotifyBO notifyBO=new NotifyBO();
+        notifyBO.setOutTradeNo(bo.getOutTradeNo())
+                .setAttach(bo.getAttach())
+                .setTransactionId(bo.getBankTrxNo())
+        .setTotalFee(NumberUtil.mul(bo.getOrderPrice(),100+"").toString());
+        wxService.WxNotify(notifyBO);
+    }
 }

+ 39 - 0
sp-server/src/main/java/com/pj/api/jh/utils/JhHttpUtils.java

@@ -0,0 +1,39 @@
+package com.pj.api.jh.utils;
+
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.retry.annotation.Backoff;
+import org.springframework.retry.annotation.Retryable;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+@Slf4j
+public class JhHttpUtils {
+
+    @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 1000, maxDelay = 1200))
+    public String postJson(String url, String body) {
+        log.info("开始请求接口:{},{}", url, body);
+        String resp = HttpUtil.createPost(url)
+                .header("Content-Type", "application/json")
+                .setConnectionTimeout(3000).setReadTimeout(2000)
+                .body(body)
+                .execute().body();
+        log.info("接口返回:{},{}", url, resp);
+        return resp;
+    }
+
+    @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 1000, maxDelay = 1200))
+    public String postForm(String url, Map<String, Object> params) {
+        log.info("开始请求接口:{},{}", url, JSONUtil.toJsonStr(params));
+        String resp = HttpUtil.createPost(url)
+                .setConnectionTimeout(3000).setReadTimeout(2000)
+                .form(params)
+                .execute().body();
+        log.info("接口返回:{},{}", url, resp);
+        return resp;
+    }
+}

+ 3 - 3
sp-server/src/main/java/com/pj/api/jh/MerchantApiUtil.java → sp-server/src/main/java/com/pj/api/jh/utils/MerchantApiUtil.java

@@ -1,4 +1,4 @@
-package com.pj.api.jh;
+package com.pj.api.jh.utils;
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.crypto.SecureUtil;
@@ -27,7 +27,7 @@ public class MerchantApiUtil {
      *            签名密钥
      * @return
      */
-    public static String getSign(Map<String, String> paramMap, String paySecret) {
+    public static String getSign(Map<String, Object> paramMap, String paySecret) {
         SortedMap<String, Object> smap = new TreeMap<String, Object>(paramMap);
         if (smap.get("sign") != null) {
             smap.remove("sign");
@@ -56,7 +56,7 @@ public class MerchantApiUtil {
      *            原始签名密文
      * @return
      */
-    public static boolean isRightSign(Map<String, String> paramMap, String paySecret, String signStr) {
+    public static boolean isRightSign(Map<String, Object> paramMap, String paySecret, String signStr) {
 
         if (StrUtil.isBlank(signStr)) {
             return false;

+ 8 - 1
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -137,6 +137,7 @@ public class OpenService {
                 tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(channel);
                 tbBusinessCarService.updateById(tbBusinessCar);
                 CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
+                RedisUtil.del(channel);
                 return ResultJson.success();
             }
         }
@@ -145,9 +146,11 @@ public class OpenService {
             tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(channel);
             tbBusinessCarService.updateById(tbBusinessCar);
             CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
+            RedisUtil.del(channel);
             return ResultJson.success();
         }
         if (tbBusinessCar.getIsLock() == 1) {
+            RedisUtil.setByMINUTES(channel, carNo,2);
             return ResultJson.error("车辆已锁定");
         }
         String businessId = tbBusinessCar.getBusinessId();
@@ -162,13 +165,14 @@ public class OpenService {
 //        double dif = price.subtract(tbBusinessCar.getMoney()).doubleValue();
         double dif = price.doubleValue();
         if (dif > 0) {
-            RedisUtil.set(channel, carNo);
+            RedisUtil.setByMINUTES(channel, carNo,1);
             return ResultJson.error("请缴停车费" + dif + "元");
         }
         if (StrUtil.isEmpty(businessId)) {
             tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setTimeUpdate(now);
             tbBusinessCarService.updateById(tbBusinessCar);
             CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
+            RedisUtil.del(channel);
             return ResultJson.success();
         }
         TbBusiness business = tbBusinessService.getById(businessId);
@@ -182,16 +186,19 @@ public class OpenService {
 
         if (!CAR_LIST.contains(StrUtil.sub(carNo, 0, 1))) {
             if (!business.getItemPrice().equals(itemPayPrice) && business.getCustomerType() != 2) {
+                RedisUtil.setByMINUTES(channel, carNo,2);
                 return ResultJson.error("请缴纳业务费用");
             }
         }
 
         if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(business.getBusinessType()) && !business.getItemPrice().equals(itemPayPrice)) {
+            RedisUtil.setByMINUTES(channel, carNo,1);
             return ResultJson.error("请缴纳业务费用");
         }
         tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setTimeUpdate(now);
         tbBusinessCarService.updateById(tbBusinessCar);
         CoverBase64ToUrl(image, tbBusinessCar.getId(), 2);
+        RedisUtil.del(channel);
         return ResultJson.success();
     }
 

+ 17 - 11
sp-server/src/main/java/com/pj/api/service/ApiService.java

@@ -136,9 +136,9 @@ public class ApiService {
             TbBusiness tbBusiness = tbBusinessService.getById(businessId);
             return tbBusiness.getAdminConfirmInput() == 1;
         }).collect(Collectors.toList());
-       List<TbBusinessCar>cars= tbBusinessCarService.findTheNoBusinessCar(carNo);
-       //过滤掉不用缴费的车
-       list.addAll(cars);
+        List<TbBusinessCar> cars = tbBusinessCarService.findTheNoBusinessCar(carNo);
+        //过滤掉不用缴费的车
+        list.addAll(cars);
         return list;
     }
 
@@ -153,18 +153,24 @@ public class ApiService {
     public Map<String, Object> getPartCarByChannel(String channel) {
         Map<String, Object> result = new HashMap<>();
         String carNo = RedisUtil.get(channel);
-        TbBusinessCar tbBusinessCar = tbBusinessCarService.findInBuNoOutAndNotPay(carNo);
+        if (StrUtil.isEmpty(carNo)) {
+            return result;
+        }
+        TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
         if (tbBusinessCar == null) {
             return result;
         }
         Date now = new Date();
-        BigDecimal price = tbBusinessService.calculationPartMoney(tbBusinessCar.getRealInTime(), now);
-        BigDecimal dif = price.subtract(tbBusinessCar.getMoney());
+        Date startTime = tbBusinessCar.getRealInTime();
+        if (tbBusinessCar.getPayTime() != null) {
+            startTime = tbBusinessCar.getPayTime();
+        }
+        BigDecimal price = tbBusinessService.calculationPartMoney(startTime, now);
         Map<String, Object> car = new HashMap<>();
         car.put("id", tbBusinessCar.getId());
         car.put("carNo", tbBusinessCar.getCarNo());
-        car.put("price", dif);
-        result.put("total", dif);
+        car.put("price", price);
+        result.put("total", price);
         result.put("cars", Collections.singleton(car));
         return result;
     }
@@ -244,7 +250,7 @@ public class ApiService {
         TbBusiness tbBusiness = tbBusinessService.getById(tbBusinessItem.getBusinessId());
         MsgDataBO msgDataBO = new MsgDataBO("订单号:" + tbBusinessItem.getNo(), tbCostomer.getName(), DateUtil.now(), tbBusiness.getGoodsName() + "(" + tbBusinessItem.getItemTypeName() + tbBusinessItem.getItemName() + ")");
         spAdminList.stream().filter(admin -> StrUtil.isNotEmpty(admin.getOpenid())).forEach(admin -> {
-            String detailUrl = myConfig.getWebDomain() + "/pages/business-order/business-item?id=" + tbBusiness.getId() +"&itemId="+tbBusinessItem.getId()+ "&openid=" + openid;
+            String detailUrl = myConfig.getWebDomain() + "/pages/business-order/business-item?id=" + tbBusiness.getId() + "&itemId=" + tbBusinessItem.getId() + "&openid=" + openid;
             log.info("admin confirm business:[{}]", detailUrl);
             wxService.sendTemplateMsg(wxConfig.getBusinessPickTemplate(), admin.getOpenid(), msgDataBO, detailUrl);
         });
@@ -267,7 +273,7 @@ public class ApiService {
         }
         db = new TbBusinessCar();
         TbCar tbCar = tbCarService.findByCardNo(carNo);
-        db.setCarNo(carNo).setIsLock(0).setCarCompany(tbCar!=null?tbCar.getCustomerName():"临时");
+        db.setCarNo(carNo).setIsLock(0).setCarCompany(tbCar != null ? tbCar.getCustomerName() : "临时");
         TbBusiness tbBusiness = new TbBusiness();
         if (StpUserUtil.isLogin()) {
             String customerId = StpUserUtil.getCustomerId();
@@ -306,7 +312,7 @@ public class ApiService {
         }
         tbBusinessService.save(tbBusiness);
         db.setBusinessId(tbBusiness.getId())
-        .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
+                .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
         tbBusinessCarService.save(db);
         itemList.forEach(tbBusinessItem -> tbBusinessItem.setBusinessId(tbBusiness.getId()));
         tbBusinessItemService.saveBatch(itemList);

+ 1 - 0
sp-server/src/main/java/com/pj/api/wx/api/WxController.java

@@ -26,6 +26,7 @@ public class WxController {
 
     @RequestMapping(value = "notify")
     public void notify(@RequestBody NotifyBO notifyBO, HttpServletResponse response) throws Exception{
+        log.info("wx pay notify;{}", JSONUtil.toJsonStr(notifyBO));
         response.setContentType("application/json");
         response.setCharacterEncoding("UTF-8");
         Writer writer = response.getWriter();

+ 2 - 0
sp-server/src/main/java/com/pj/api/wx/bo/NotifyBO.java

@@ -3,9 +3,11 @@ package com.pj.api.wx.bo;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 @JacksonXmlRootElement(localName = "xml")
 @Data
+@Accessors(chain = true)
 public class NotifyBO {
 
 

+ 6 - 15
sp-server/src/main/java/com/pj/api/wx/service/WxService.java

@@ -129,7 +129,9 @@ public class WxService {
             vo.setPayUrl(webUrl == null ? "" : webUrl.toString())
                     .setPrePayId(preId)
                     .setTradeType(tradeType);
-            return getPayParams(openid, preId);
+            Map<String, String> payParams = getPayParams(openid, preId);
+            payParams.put("outTradeNo", out_trade_no);
+            return payParams;
         }
         throw new Exception("支付信息有误");
     }
@@ -182,7 +184,7 @@ public class WxService {
     TimedCache<String, Integer> NotifyCache = CacheUtil.newTimedCache(360000);
 
     @Async
-    public void WxNotify(NotifyBO notifyBO) throws Exception {
+    public void WxNotify(NotifyBO notifyBO)  {
         String outTradeNo = notifyBO.getOutTradeNo();
         if (NotifyCache.get(outTradeNo) != null) {
             return;
@@ -190,9 +192,6 @@ public class WxService {
         NotifyCache.put(outTradeNo, 1);
         String total_fee = notifyBO.getTotalFee();
         BigDecimal money = new BigDecimal(total_fee).divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP);
-        log.info("wx pay notify;{}", JSONUtil.toJsonStr(notifyBO));
-        String tradeNo = notifyBO.getOutTradeNo();
-        tradeNo = StrUtil.subBefore(tradeNo, "_", true);
         String attachStr = notifyBO.getAttach();
         String transactionId = notifyBO.getTransactionId();
         Date now = new Date();
@@ -225,16 +224,6 @@ public class WxService {
                         .setPayNo(transactionId);
                 tbBusiness.setPayStatus(tbBusiness.getPayMoney().equals(tbBusiness.getTotalMoney()) ? 3 : 4);
                 tbBusinessService.updateById(tbBusiness);
-                TbPayRecord payRecord = new TbPayRecord();
-                TbCostomer tbCostomer = tbCostomerService.getById(tbBusiness.getCustomerId());
-                payRecord.setCreateTime(now)
-                        .setOutTradeNo(tradeNo)
-                        .setTransactionId(transactionId)
-                        .setPayMoney(money);
-                if (tbCostomer != null) {
-                    payRecord.setCustomerId(tbCostomer.getId()).setCustomerName(tbCostomer.getName());
-                }
-                tbPayRecordService.save(payRecord);
             }
             String a = attach.getA();
             if (StrUtil.isNotEmpty(a)) {
@@ -244,6 +233,8 @@ public class WxService {
         }
     }
 
+
+
     public String getRedirectUrl(String path, String state) {
         String redirectUrl = myConfig.getWebDomain() + path;
         String encoderUrl = URLDecoder.decode(redirectUrl, Charset.forName("utf-8"));

+ 0 - 1
sp-server/src/main/java/com/pj/current/satoken/SaTokenConfigure.java

@@ -62,7 +62,6 @@ public class SaTokenConfigure implements WebMvcConfigurer {
         			
         			// 如果是预检请求,则立即返回到前端 
         			SaRouter.match(SaHttpMethod.OPTIONS)
-        				.free(r -> System.out.println("--------OPTIONS预检请求,不做处理"))
         				.back();
         		})
         		;

+ 1 - 1
sp-server/src/main/java/com/pj/project/tb_business/TbBusiness.java

@@ -46,7 +46,7 @@ public class TbBusiness extends Model<TbBusiness> implements Serializable {
     public static final String PERMISSION_CONFIRM = "tb-business-confirm";
     public static final String PERMISSION_PAY = "tb-business-pay";
     public static final String PERMISSION_INPUT = "tb-business-add";
-    public static final String PERMISSION_EXPORT = "tb-business-car-export";
+
 
 
     // ---------- 表中字段 ----------

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

@@ -498,7 +498,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             BigDecimal partMoney = new BigDecimal("0");
             String carNo = tbBusinessCar.getCarNo().substring(0, 1);
             if (inTime != null && CAR_LIST.contains(carNo)) {
-                if (tbBusinessCar.getPay()==1){
+                if (tbBusinessCar.getPay()==1&&tbBusinessCar.getPayTime()!=null){
                     inTime=tbBusinessCar.getPayTime();
                 }
                 partMoney = this.calculationPartMoney(inTime, now);

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

@@ -44,6 +44,10 @@ public class TbBusinessCar extends Model<TbBusinessCar> implements Serializable
      */
     public static final String PERMISSION_CODE = "tb-business-car";
     public static final String PERMISSION_LIST = "tb-business-car-list";
+    public static final String PERMISSION_EXPORT = "tb-business-car-export";
+    public static final String PERMISSION_ADD = "tb-business-car-add";
+    public static final String PERMISSION_EDIT = "tb-business-car-edit";
+    public static final String PERMISSION_DEL= "tb-business-car-del";
 
 
     // ---------- 表中字段 ----------

+ 10 - 3
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarController.java

@@ -43,6 +43,13 @@ public class TbBusinessCarController {
 		return tbBusinessCarService.deleteCar(id);
 	}
 
+	/** 查 - 根据id */
+	@RequestMapping("deleteRecord")
+	@SaCheckPermission(TbBusinessCar.PERMISSION_DEL)
+	public AjaxJson deleteRecord(String id) {
+		return tbBusinessCarService.deleteRecord(id);
+	}
+
 	@RequestMapping(value = "findInAndNoBusinessCar")
 	public AjaxJson findInAndNoBusinessCar(){
 		List<TbBusinessCar>list=tbBusinessCarService.findInAndNoBusinessCar();
@@ -86,20 +93,20 @@ public class TbBusinessCarController {
 
     /** 手动添加放行记录*/
     @RequestMapping("addCarRecord")
-    @SaCheckPermission(TbBusiness.PERMISSION_CODE)
+    @SaCheckPermission(TbBusinessCar.PERMISSION_ADD)
     public AjaxJson addManualCar(TbBusinessCar t) throws Exception{
         tbBusinessCarService.addCarRecord(t);
         return AjaxJson.getSuccess();
     }
 
     @RequestMapping("updateCarRecord")
-    @SaCheckPermission(TbBusiness.PERMISSION_CODE)
+    @SaCheckPermission(TbBusinessCar.PERMISSION_EDIT)
     public AjaxJson updateCarRecord(TbBusinessCar t) throws Exception{
         tbBusinessCarService.updateCarRecord(t);
         return AjaxJson.getSuccess();
     }
     @RequestMapping("export")
-    @SaCheckPermission(TbBusiness.PERMISSION_CODE)
+    @SaCheckPermission(TbBusinessCar.PERMISSION_EXPORT)
     public AjaxJson export() {
     	SoMap soMap=SoMap.getRequestSoMap();
         return AjaxJson.getSuccessData( tbBusinessCarService.export(soMap));

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

@@ -56,6 +56,12 @@
             <if test="inEnd!=null and inEnd !=''">
                 and  date_format(real_in_time,'%Y-%m-%d %H:%m:%s') &lt;=#{inEnd}
             </if>
+            <if test="color !=null and color !='' and color !='其他'">
+                and color=#{color}
+            </if>
+            <if test="color =='其他'">
+                and (color='' or color ='未知' or color is null)
+            </if>
         </where>
         order by
         <choose>

+ 17 - 4
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java

@@ -71,6 +71,7 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
     private UploadConfig uploadConfig;
 
 
+
     /**
      * 查集合 - 根据条件(参数为空时代表忽略指定条件)
      */
@@ -288,11 +289,14 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
             feeDetailsLIst.forEach(fee -> fee.setCarNo(carNo));
             tbFeeDetailsService.updateBatchById(feeDetailsLIst);
         } else{
-            TbFeeDetails feeDetail = tbFeeDetailsService.getByBusinessCarIdAndCarNoAndFeeType(t.getId(), oldCarNo, TbFeeDetails.fee.PARK_FEE.getCode());
-            if(feeDetail != null){
-                feeDetail.setCarNo(carNo);
-                tbFeeDetailsService.updateById(feeDetail);
+            List<TbFeeDetails> feeDetailsList = tbFeeDetailsService.getByBusinessCarIdAndCarNoAndFeeType(t.getId(), oldCarNo, TbFeeDetails.fee.PARK_FEE.getCode());
+            for (TbFeeDetails feeDetail : feeDetailsList) {
+                if(feeDetail != null){
+                    feeDetail.setCarNo(carNo);
+                    tbFeeDetailsService.updateById(feeDetail);
+                }
             }
+
         }
 
     }
@@ -332,4 +336,13 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         ew.eq("car_no",carNo);
         return list(ew);
     }
+
+    public AjaxJson deleteRecord(String id) {
+      TbFeeDetails tbFeeDetails=  tbFeeDetailsService.findByBusinessCarId(id,TbFeeDetails.fee.PARK_FEE.getCode());
+      if (tbFeeDetails!=null){
+          return AjaxJson.getError("该车有付款记录,不能删除");
+      }
+      this.removeById(id);
+        return AjaxJson.getSuccess();
+    }
 }

+ 88 - 62
sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsService.java

@@ -122,12 +122,12 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
         return getOne(qw);
     }
 
-    public TbFeeDetails getByBusinessCarIdAndCarNoAndFeeType(String businessCarId, String carNo, Integer feeType){
+    public List<TbFeeDetails> getByBusinessCarIdAndCarNoAndFeeType(String businessCarId, String carNo, Integer feeType){
         QueryWrapper<TbFeeDetails> qw = new QueryWrapper<>();
         qw.eq("business_car_id", businessCarId);
         qw.eq("car_no", carNo);
         qw.eq("fee_type", feeType);
-        return getOne(qw);
+        return list(qw);
     }
 
 
@@ -142,21 +142,21 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
             TbBusinessCar car = tbBusinessCarService.getById(bo1.getId());
             TbBusiness business = tbBusinessService.getById(car.getBusinessId());
             String carNo = car.getCarNo();
-            TbFeeDetails parkFee;
-            if(business != null){
-                parkFee = getByBusinessIdAndCarNoAndFeeType(car.getBusinessId(), carNo, TbFeeDetails.fee.PARK_FEE.getCode());
-            } else {
-                parkFee = getByBusinessCarIdAndCarNoAndFeeType(car.getId(), carNo, TbFeeDetails.fee.PARK_FEE.getCode());
-            }
+            TbFeeDetails parkFee = null;
+//            if(business != null){
+//                parkFee = getByBusinessIdAndCarNoAndFeeType(car.getBusinessId(), carNo, TbFeeDetails.fee.PARK_FEE.getCode());
+//            } else {
+//                parkFee = getByBusinessCarIdAndCarNoAndFeeType(car.getId(), carNo, TbFeeDetails.fee.PARK_FEE.getCode());
+//            }
             if(parkFee == null){
                 parkFee = new TbFeeDetails();
                 parkFee.setTaxRate(partConfig.getTaxRate());
             }
-            BigDecimal taxPrice = car.getMoney().divide(BigDecimal.valueOf(1).add(parkFee.getTaxRate()),2, BigDecimal.ROUND_HALF_UP).multiply(parkFee.getTaxRate());
-            BigDecimal noTaxPrice = car.getMoney().subtract(taxPrice);
+            BigDecimal taxPrice = bo1.getP().divide(BigDecimal.valueOf(1).add(parkFee.getTaxRate()),2, BigDecimal.ROUND_HALF_UP).multiply(parkFee.getTaxRate());
+            BigDecimal noTaxPrice = bo1.getP().subtract(taxPrice);
             parkFee.setBusinessId(car.getBusinessId()).setBusinessCarId(car.getId())
                     .setCarNo(car.getCarNo())
-                    .setItemPrice(car.getMoney()).setUnitPrice(car.getMoney()).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
+                    .setItemPrice(bo1.getP()).setUnitPrice(bo1.getP()).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
                     .setFeeType(TbFeeDetails.fee.PARK_FEE.getCode()).setItemTypeName("停车业务")
                     .setPayDay(toDay).setPayType(3).setCreateTime(now)
                     .setNum(1).setIsSettle(1).setPayMode(1).setPayTime(nowStr)
@@ -169,64 +169,32 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
         }
     }
 
-    //@Async
-    public void chargeBusinessFee(List<TbBusinessItem> items) {
-        Date now = new Date();
-        String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm:ss");
-        String toDay = DateUtil.format(now, "yyyy-MM-dd");
-        for (TbBusinessItem item : items) {
-            int feeType = -1;
-            String itemType = item.getItemTypeName();
-            if (itemType.contains("核酸")) {
-                feeType = TbFeeDetails.fee.NUCLEIC_FEE.getCode();
-            } else if (itemType.contains("消毒") || itemType.contains("消杀")) {
-                feeType = TbFeeDetails.fee.DISINFECT_FEE.getCode();
-            } else if (itemType.contains("装卸")) {
-                feeType = TbFeeDetails.fee.STEVEDORE_FEE.getCode();
-            } else if (StrUtil.equals(itemType, "特殊车辆") || StrUtil.equals(itemType, "汽车吊")) {
-                feeType = TbFeeDetails.fee.STEVEDORE_FEE.getCode();
-            } else if (itemType.contains("入场管理")) {
-                feeType = TbFeeDetails.fee.MANAGE_FEE.getCode();
-            } else if (StrUtil.equals(itemType, "充电打冷")) {
-                feeType = TbFeeDetails.fee.CHARGE_FEE.getCode();
-            }
-            TbBusiness business = tbBusinessService.getById(item.getBusinessId());
-            TbFeeDetails businessFeeDetail = this.getByBusinessIdAndCarNoAndItemType(item.getBusinessId(), business.getCardNo(), item.getItemTypeId());
-            if (businessFeeDetail == null) {
-                businessFeeDetail = new TbFeeDetails();
-                businessFeeDetail.setTaxRate(BigDecimal.valueOf(TbFeeStatistics.taxRate.BUSINESS.getValue()));
-            }
-            BigDecimal taxPrice = item.getItemPrice()
-                    .divide(BigDecimal.valueOf(1).add(businessFeeDetail.getTaxRate()),2, BigDecimal.ROUND_HALF_UP)
-                    .multiply(businessFeeDetail.getTaxRate());
-            BigDecimal noTaxPrice = item.getItemPrice().subtract(taxPrice);
 
-            String carNo = business.getCardNo();
-            if(StrUtil.isEmpty(business.getCardNo())){
-                carNo = business.getChinaCarNo();
-            }
-            businessFeeDetail.setBusinessId(item.getBusinessId()).setBusinessNo(business.getNo())
-                    .setBusinessItemNo(item.getNo())
-                    .setCarNo(carNo)
-                    .setItemPrice(item.getItemPrice()).setUnitPrice(item.getItemPrice()).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
-                    .setFeeType(feeType)
-                    .setItemTypeId(item.getItemTypeId()).setItemTypeName(item.getItemTypeName())
-                    .setItemId(item.getItemId()).setItemName(item.getItemName())
-                    .setPayDay(toDay).setPayType(3).setCreateTime(now)
-                    .setBusinessItemId(item.getId() + "")
-                    .setPickCustomerName(item.getPickCustomerName())
-                    .setNum(1).setIsSettle(1).setPayMode(1).setPayTime(nowStr).setWeight(business.getNetWeight());
-            this.saveOrUpdate(businessFeeDetail);
-        }
-    }
 
     public String export(SoMap so) throws Exception{
         Date now = new Date();
         String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm");
-        String time = so.getString("beginTime") + "至" + so.getString("endTime");
+        String beginTime = so.getString("beginTime");
+        String endTime = so.getString("endTime");
+        String time = beginTime + "至" + endTime;
         Map<String, String> head = new HashMap<>();
         head.put("time", time);
         head.put("exportTime", nowStr);
+        String inCarNum = "";
+        String outPayCarNum = "";
+        String notOutCarNum = "";
+        boolean isIn = checkTimeRange(beginTime, endTime, now);
+        if(isIn){
+            inCarNum = getInCarNum(now) + "";
+            outPayCarNum = getOutAndPayCarNum(now) + "";
+            notOutCarNum = getNotOutCarNum(now) + "";
+        }
+        head.put("inCarNum", inCarNum);
+        head.put("outPayCarNum", outPayCarNum);
+        head.put("notOutCarNum", notOutCarNum);
+
+        BigDecimal toDayFee = new BigDecimal(0);
+        BigDecimal allDayFee = new BigDecimal(0);
 	    List<ExportFeeDetailDTO> exportList = new ArrayList<>();
         List<TbFeeDetails> list = this.getList(so);
         Integer index = 1;
@@ -247,10 +215,18 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
             }else {
                 detailDTO.setBusinessNo(feeDetails.getBusinessCarNo());
             }
-
             exportList.add(detailDTO);
+            if(checkTimeRange(beginTime, endTime, feeDetails.getCreateTime()) && feeDetails.getFeeType()==TbFeeDetails.fee.PARK_FEE.getCode()){
+                toDayFee = toDayFee.add(feeDetails.getItemPrice());
+            }
+            if(feeDetails.getFeeType()==TbFeeDetails.fee.PARK_FEE.getCode()){
+                allDayFee = allDayFee.add(feeDetails.getItemPrice());
+            }
         }
 
+        head.put("toDayFee", toDayFee.toString());
+        head.put("allDayFee", allDayFee.toString());
+
         String separator = File.separator;
         String today = DateUtil.today();
         String rootPath = UploadUtil.uploadConfig.rootFolder + separator + UploadUtil.uploadConfig.httpPrefix;
@@ -275,4 +251,54 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
         return prefix + "/feeDetails/" + today + "/收费明细表_" + time + ".xlsx";
     }
 
+    private boolean checkTimeRange(String begin, String end, Date now) {
+        Date beginTime = DateUtil.beginOfDay(DateUtil.parse(begin));
+        Date endTime = DateUtil.endOfDay(DateUtil.parse(end));
+        if(now.getTime() >= beginTime.getTime() && now.getTime() <= endTime.getTime()){
+            return true;
+        }
+        return false;
+    }
+
+    private Integer getInCarNum(Date now){
+        Date beginOfDay = DateUtil.beginOfDay(now);
+        Date endOfDay = DateUtil.endOfDay(now);
+        QueryWrapper<TbBusinessCar> qw = new QueryWrapper();
+        qw.isNotNull("real_in_time")
+                .ge("real_in_time", beginOfDay)
+                .le("real_in_time", endOfDay);
+        List<TbBusinessCar> list = tbBusinessCarService.list(qw);
+        return list != null ? list.size() : 0;
+    }
+
+    private Integer getOutAndPayCarNum(Date now){
+        Date beginOfDay = DateUtil.beginOfDay(now);
+        Date endOfDay = DateUtil.endOfDay(now);
+        QueryWrapper<TbBusinessCar> qw = new QueryWrapper();
+        qw.eq("pay", 1)
+                .isNotNull("real_in_time").isNotNull("real_out_time")
+                .ge("real_out_time", beginOfDay)
+                .le("real_out_time", endOfDay);
+        List<TbBusinessCar> list = tbBusinessCarService.list(qw);
+        return list != null ? list.size() : 0;
+    }
+
+    private Integer getNotOutCarNum(Date now){
+        Date beginOfDay = DateUtil.beginOfDay(now);
+        Date endOfDay = DateUtil.endOfDay(now);
+        QueryWrapper<TbBusinessCar> qw = new QueryWrapper();
+        qw.isNotNull("real_in_time")
+                .ge("real_in_time", beginOfDay)
+                .le("real_in_time", endOfDay)
+                .isNull("real_out_time");
+        List<TbBusinessCar> list = tbBusinessCarService.list(qw);
+        return list != null ? list.size() : 0;
+    }
+
+    public TbFeeDetails findByBusinessCarId(String businessCarId,int feeType) {
+        QueryWrapper<TbFeeDetails>ew=new QueryWrapper<>();
+        ew.eq("business_car_id",businessCarId);
+        ew.eq("fee_type",feeType);
+        return getOne(ew);
+    }
 }

+ 7 - 5
sp-server/src/main/java/com/pj/project/tb_fee_statistics/TbFeeStatisticsService.java

@@ -119,10 +119,11 @@ public class TbFeeStatisticsService extends ServiceImpl<TbFeeStatisticsMapper, T
             BigDecimal price = bo1.getP();
             if(price.compareTo(BigDecimal.valueOf(0)) != 0){
                 totalPrice = totalPrice.add(price);
-                TbBusinessCar car = tbBusinessCarService.getById(bo1.getId());
-                if(car.getMoney().compareTo(BigDecimal.valueOf(0)) == 0){
-                    totalNum++;
-                }
+//                TbBusinessCar car = tbBusinessCarService.getById(bo1.getId());
+//                if(car.getMoney().compareTo(BigDecimal.valueOf(0)) == 0){
+//                    totalNum++;
+//                }
+                totalNum++;
             }
         }
         if(totalPrice.compareTo(BigDecimal.valueOf(0)) == 0){
@@ -186,7 +187,8 @@ public class TbFeeStatisticsService extends ServiceImpl<TbFeeStatisticsMapper, T
             /*-----------------分割线------------------*/
             //添加此item的收费明细
             TbBusiness business = tbBusinessService.getById(item.getBusinessId());
-            TbFeeDetails businessFeeDetail = tbFeeDetailsService.getByBusinessIdAndCarNoAndItemType(item.getBusinessId(), business.getCardNo(), item.getItemTypeId());
+//            TbFeeDetails businessFeeDetail = tbFeeDetailsService.getByBusinessIdAndCarNoAndItemType(item.getBusinessId(), business.getCardNo(), item.getItemTypeId());
+            TbFeeDetails businessFeeDetail = null;
             if (businessFeeDetail == null) {
                 businessFeeDetail = new TbFeeDetails();
                 businessFeeDetail.setTaxRate(BigDecimal.valueOf(TbFeeStatistics.taxRate.BUSINESS.getValue()));

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

@@ -6,7 +6,7 @@ spring:
     # 数据源配置
     datasource:
         type: com.alibaba.druid.pool.DruidDataSource
-        url: jdbc:mysql://127.0.0.1:3306/pco_system?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
         username: root
         password: 123456
         # 是否打开sql监控台  (生产环境请务必关闭此选项)

BIN
sp-server/src/main/resources/static/day-fee-new.xlsx