Sfoglia il codice sorgente

其他业务扣除预存款

qzyReal 2 anni fa
parent
commit
070540325e

+ 153 - 0
sp-admin/sa-view/tb-business/tb-abinet-record.html

@@ -0,0 +1,153 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>业务作业项-列表</title>
+		<meta charset="utf-8">
+		<meta name="viewport"
+			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+		<!-- 所有的 css & js 资源 -->
+		<link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
+		<link rel="stylesheet" href="../../static/sa.css">
+		<script src="../../static/kj/vue.min.js"></script>
+		<script src="../../static/kj/element-ui/index.js"></script>
+		<script src="../../static/kj/httpVueLoader.js"></script>
+		<script src="../../static/kj/jquery.min.js"></script>
+		<script src="../../static/kj/layer/layer.js"></script>
+		<script src="../../static/sa.js"></script>
+	</head>
+	<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.cabinetNo"></sa-item>
+					<sa-item type="text" name="车牌号" v-model="p.carNo"></sa-item>
+					<sa-item type="text" name="客户" v-model="p.customerName"></sa-item>
+					<sa-item type="text" name="合作伙伴" v-model="p.pickCustomerName"></sa-item>
+					<el-button type="primary" @click="p.pageNo = 1; f5()">查询</el-button>
+					<el-button type="info" @click="p.pageNo = 1; p.cabinetNo='';p.carNo='';p.customerName='';p.pickCustomerName='';f5()">重置</el-button>
+				</el-form>
+				<!-- ------------- 数据列表 ------------- -->
+				<el-table class="data-table" ref="data-table" :data="dataList">
+					<sa-td name="序号" type="index"></sa-td>
+					<sa-td name="柜号" prop="cabinetNo"></sa-td>
+					<sa-td name="车牌号" prop="cardNo"></sa-td>
+					<sa-td name="取/存" prop="cabinetType" type="enum" :jv="{0: '存柜', 1:'取柜'}">
+					</sa-td>
+					<sa-td name="存柜时间" prop="coldStartTime" width="150"></sa-td>
+					<sa-td name="取柜时间" prop="coldEndTime" width="150"></sa-td>
+					<sa-td name="状态" prop="cabinetStatus" type="enum" :jv="{0: '未取柜', 1:'已取柜'}">
+					</sa-td>
+					<sa-td name="客户" prop="customerName" width="160"></sa-td>
+					<sa-td name="合作伙伴" prop="pickCustomerName" width="160"></sa-td>
+					<sa-td name="录入时间" prop="createTime" width="150"></sa-td>
+					<sa-td name="单价(元)" prop="itemPrice"></sa-td>
+					<sa-td name="费用(元)" prop="total"></sa-td>
+					<sa-td name="支付状态" prop="payStatus" type="enum" :jv="{0: '未支付', 1:'已支付'}">
+					</sa-td>
+					<sa-td name="支付时间" prop="payTime" width="150"></sa-td>
+					<!-- 	<el-table-column label="操作" fixed="right" width="240px">
+						<template slot-scope="s">
+							<el-button class="c-btn" type="success" icon="el-icon-view"
+								@click="get(s.row)">查看</el-button>
+							<el-button class="c-btn" type="primary" icon="el-icon-edit"
+								@click="update(s.row)">修改</el-button>
+							<el-button class="c-btn" type="danger" icon="el-icon-delete"
+								@click="del(s.row)">删除</el-button>
+						</template>
+					</el-table-column> -->
+				</el-table>
+				<!-- ------------- 分页 ------------- -->
+				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount"
+					@change="f5()"></sa-item>
+			</div>
+		</div>
+		<script>
+			var app = new Vue({
+				components: {
+					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
+					"sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
+				},
+				el: '.vue-box',
+				data: {
+					p: { // 查询参数
+						id: '', // 主键
+						carNo: '', // 等级表id
+						cabinetNo: '', // 项目编号
+						pickCustomerName:'',
+						customerName:'',
+						pageNo: 1, // 当前页
+						pageSize: 10, // 页大小
+						sortType: 0 // 排序方式
+					},
+					dataCount: 0,
+					dataList: [], // 数据集合
+				},
+				methods: {
+					// 刷新
+					f5: function() {
+						sa.ajax('/TbBusinessItem/getCabinetRecord', sa.removeNull(this.p), function(res) {
+							this.dataList = res.data; // 数据
+							this.dataCount = res.dataCount; // 数据总数
+							sa.f5TableHeight(); // 刷新表格高度
+						}.bind(this));
+					},
+					// 查看
+					get: function(data) {
+						sa.showIframe('数据详情', 'tb-business-item-info.html?id=' + data.id, '1050px', '90%');
+					},
+					// 查看 - 根据选中的
+					getBySelect: function(data) {
+						var selection = this.$refs['data-table'].selection;
+						if (selection.length == 0) {
+							return sa.msg('请选择一条数据')
+						}
+						this.get(selection[0]);
+					},
+					// 修改
+					update: function(data) {
+						sa.showIframe('修改数据', 'tb-business-item-add.html?id=' + data.id, '1000px', '90%');
+					},
+					// 新增
+					add: function(data) {
+						sa.showIframe('新增数据', 'tb-business-item-add.html?id=-1', '1000px', '90%');
+					},
+					// 删除
+					del: function(data) {
+						sa.confirm('是否删除,此操作不可撤销', function() {
+							sa.ajax('/TbBusinessItem/delete?id=' + data.id, function(res) {
+								sa.arrayDelete(this.dataList, data);
+								sa.ok('删除成功');
+								sa.f5TableHeight(); // 刷新表格高度
+							}.bind(this))
+						}.bind(this));
+					},
+					// 批量删除
+					deleteByIds: function() {
+						// 获取选中元素的id列表
+						let selection = this.$refs['data-table'].selection;
+						let ids = sa.getArrayField(selection, 'id');
+						if (selection.length == 0) {
+							return sa.msg('请至少选择一条数据')
+						}
+						// 提交删除
+						sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
+							sa.ajax('/TbBusinessItem/deleteByIds', {
+								ids: ids.join(',')
+							}, function(res) {
+								sa.arrayDelete(this.dataList, selection);
+								sa.ok('删除成功');
+								sa.f5TableHeight(); // 刷新表格高度
+							}.bind(this))
+						}.bind(this));
+					},
+				},
+				created: function() {
+					this.f5();
+					sa.onInputEnter();
+				}
+			})
+		</script>
+	</body>
+</html>

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

@@ -650,7 +650,7 @@
 								this.partnerDis = true;
 								this.m.customerId = id;
 							}
-							let customerList = this.customerList;
+							let customerList = this.customerList.filter(obj => obj.type == 0);
 							arr = customerList.filter(obj => obj.id == id);
 							if (arr.length > 0) {
 								this.customerDis = true;

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

@@ -647,7 +647,7 @@
 								this.m.pickCustomerId = id;
 								this.partnerDis = true;
 							}
-							let customerList = this.customerList;
+							let customerList = this.customerList.filter(obj => obj.type == 0);
 							arr = customerList.filter(obj => obj.id == id);
 							if (arr.length > 0) {
 								this.customerDis = true;

+ 2 - 2
sp-admin/sa-view/tb-deduction-record/tb-deduction-record-list.html

@@ -92,8 +92,8 @@
 					<sa-td name="车牌号" prop="carNo" width="100"></sa-td>
 					<sa-td name="收费项目" prop="feeType" type="enum"
 						:jv="{1: '核酸检测',2: '消杀作业', 3: '装卸作业', 4: '停车业务', 5: '过磅费', 6: '入场管理费', 7: '充电打冷作业'}"></sa-td>
-					<sa-td name="业务类型id" prop="itemTypeId" v-if="false"></sa-td>
 					<sa-td name="业务类型" prop="itemTypeName" width="150"></sa-td>
+					<sa-td name="车型" prop="itemName" width="150"></sa-td>
 					<sa-td name="原金额" prop="originalMoney" width="120"></sa-td>
 					<sa-td name="扣除金额" prop="deductMoney" width="90"></sa-td>
 					<sa-td name="余额" prop="totalMoney"></sa-td>
@@ -117,7 +117,7 @@
 					</el-table-column>
 					<!-- <sa-td name="生成时间" prop="createTime" width="150px"></sa-td> -->
 					<sa-td name="扣款时间" prop="payTime" width="150px"></sa-td>
-					<el-table-column label="操作" fixed="right" width="240px">
+					<el-table-column label="操作" fixed="right" width="130px">
 						<template slot-scope="s">
 							<el-button class="c-btn" type="primary"
 								v-if="s.row.reviewStatus!=1 && sa.isAuth('tb-deduction-record-list-review')"

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

@@ -132,7 +132,7 @@
 					<sa-td name="业务类型" prop="itemTypeName"></sa-td>
 					<sa-td name="车型" prop="itemName"></sa-td>
 					<sa-td name="车牌号" prop="carNo" width="90px"></sa-td>
-					<sa-td name="重量(kg)" prop="weight"></sa-td>
+					<!-- <sa-td name="重量(kg)" prop="weight"></sa-td> -->
 					<sa-td name="数量" prop="num"></sa-td>
 					<sa-td name="单价(元)" prop="unitPrice"></sa-td>
 					<sa-td name="总价(元)" prop="itemPrice"></sa-td>

+ 137 - 60
sp-admin/sa-view/tb-invoice-order/tb-invoice-order-list.html

@@ -3,7 +3,8 @@
 	<head>
 		<title>开票订单表-列表</title>
 		<meta charset="utf-8">
-		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
+		<meta name="viewport"
+			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
 		<!-- 所有的 css & js 资源 -->
 		<link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
 		<link rel="stylesheet" href="../../static/sa.css">
@@ -15,7 +16,21 @@
 		<script src="../../static/sa.js"></script>
 	</head>
 	<style>
-		.c1-label{width: 7em; color: #333; padding-right: 4px; display: inline-block; text-align: right; vertical-align: top;}
+		.c1-label {
+			width: 7em;
+			color: #333;
+			padding-right: 4px;
+			display: inline-block;
+			text-align: right;
+			vertical-align: top;
+		}
+
+		.el-tooltip__popper {
+			font-size: 14px;
+			max-width: 40%
+		}
+
+		/* 设置显示隐藏部分内容,按40%显示 */
 	</style>
 	<body>
 		<div class="vue-box" style="display: none;" :style="'display: block;'">
@@ -32,12 +47,28 @@
 						<el-input type="text" v-model="p.carNo"></el-input>
 					</div>
 					<div class="c-item">
+						<label class="c1-label">客户名称:</label>
+						<el-input type="text" v-model="p.customerName"></el-input>
+					</div>
+					<div class="c-item">
+						<label class="c1-label">主体名称:</label>
+						<el-input type="text" v-model="p.entityName"></el-input>
+					</div>
+					<div class="c-item">
+						<label class="c-label">付款类型:</label>
+						<el-select v-model="p.payType" placeholder="请选择" @change="f5()">
+							<el-option label="全部" :value="0"></el-option>
+							<el-option label="微信支付" :value="1"></el-option>
+							<el-option label="预存款支付" :value="2"></el-option>
+						</el-select>
+					</div>
+					<div class="c-item">
 						<label class="c1-label">微信支付订单:</label>
 						<el-input type="text" v-model="p.transactionId"></el-input>
 					</div>
 					<div class="c-item">
 						<label class="c-label">开票状态:</label>
-						<el-select v-model="p.status" placeholder="请选择">
+						<el-select v-model="p.status" placeholder="请选择" @change="f5()">
 							<el-option label="不限" value=""></el-option>
 							<el-option label="待申请" :value="0"></el-option>
 							<el-option label="已申请" :value="1"></el-option>
@@ -50,52 +81,73 @@
 				</el-form>
 				<!-- ------------- 快捷按钮 ------------- -->
 				<el-form ref="form" :model='p' @submit.native.prevent>
-					<el-button style="display: inline;" type="primary"  @click="add()">上传账单截图</el-button>
-					<el-button style="display: inline;" type="primary"  @click="applyFn()">申请开票</el-button>
+					<el-button style="display: inline;" type="primary" @click="add()">上传账单截图</el-button>
+					<el-button style="display: inline;" type="primary" @click="applyFn()">申请开票</el-button>
 				</el-form>
 				<!-- ------------- 数据列表 ------------- -->
-				<el-table class="data-table" ref="data-table" :data="dataList" >
+				<el-table class="data-table" ref="data-table" :data="dataList">
 					<sa-td type="selection"></sa-td>
-
-					<sa-td name="业务名称" prop="businessName" width="150px" ></sa-td>
+					<sa-td name="业务名称" prop="businessName" width="210px"></sa-td>
 					<sa-td name="车牌号" prop="carNo" width="150px"></sa-td>
 					<el-table-column label="业务订单号" width="150px">
 						<template slot-scope="s">
-							<el-tooltip :content="s.row.businessNo"placement="bottom"effect="light">
+							<el-tooltip :content="s.row.businessNo" placement="top" effect="light">
 								<el-button class="keyButton">{{ s.row.businessNo }}</el-button>
 							</el-tooltip>
 						</template>
 					</el-table-column>
-<!--					<sa-td name="业务订单号" prop="businessNo" width="150" ></sa-td>-->
-
-					<sa-td name="微信支付订单号" prop="transactionId" width="210px"></sa-td>
-					<sa-td name="账单金额" prop="billMoney" ></sa-td>
+					<el-table-column label="客户名称" width="190px">
+						<template slot-scope="s">
+							<el-tooltip :content="s.row.customerName" placement="top" effect="light">
+								<el-button class="keyButton">{{ s.row.customerName }}</el-button>
+							</el-tooltip>
+						</template>
+					</el-table-column>
+					<el-table-column label="主体名称" width="190px">
+						<template slot-scope="s">
+							<el-tooltip v-if="s.row.entityName" :content="s.row.entityName" placement="top"
+								effect="light">
+								<el-button class="keyButton">{{ s.row.entityName }}</el-button>
+							</el-tooltip>
+						</template>
+					</el-table-column>
+					<sa-td name="微信支付订单号" prop="transactionId" width="210px" v-if="p.payType==0||p.payType==1"></sa-td>
+					<sa-td name="账单金额" prop="billMoney"></sa-td>
+					<el-table-column label="支付方式" width="100px">
+						<template slot-scope="s">
+							<label v-if="s.row.transactionId">微信支付</label>
+							<label v-else>预存款支付</label>
+						</template>
+					</el-table-column>
 					<sa-td name="账单截图" prop="billImage" type="img"></sa-td>
 					<sa-td name="开票状态" prop="status" type="enum" :jv="{0: '待申请', 1: '已申请', 2: '已开票'}"></sa-td>
 					<sa-td name="开票时间" prop="invoiceTime" width="100px"></sa-td>
 					<sa-td name="开票信息" prop="infoNo" width="130"></sa-td>
-					<el-table-column label="操作" fixed="right"  width="240px">
+					<el-table-column label="操作" fixed="right" width="140px">
 						<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="s.row.status==0" class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">删除</el-button>
+							<el-button class="c-btn" type="success" icon="el-icon-view"
+								@click="get(s.row)">查看</el-button>
+							<el-button v-if="s.row.status==0" class="c-btn" type="danger" icon="el-icon-delete"
+								@click="del(s.row)">删除</el-button>
 						</template>
 					</el-table-column>
 				</el-table>
 				<!-- ------------- 分页 ------------- -->
-				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()"></sa-item>
+				<sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount"
+					@change="f5()"></sa-item>
 			</div>
 			<el-dialog title="申请开票" :visible.sync="applyDate.visible" width="38%">
 				<sa-item name="发票总额" v-model="applyDate.form.totalMoney" type="num" :disabled="true"></sa-item>
-				<sa-item name="开票种类" v-model="applyDate.form.isElec" type="enum" :jv="{1: '电子普票', 0: '纸质普票', 2:'纸质专票'}"></sa-item>
+				<sa-item name="开票种类" v-model="applyDate.form.isElec" type="enum"
+					:jv="{1: '电子普票', 0: '纸质普票', 2:'纸质专票'}"></sa-item>
 				<div class="c-item">
 					<label class="c-label">开票主体:</label>
-					<el-select v-model="applyDate.form.entityId" placeholder="请选择" filterable @change="changeEntity">
-						<el-option v-for="item in entityList" :key="item.id"
-								   :label="item.name" :value="item.id">
+					<el-select :disabled="selectDisabled" v-model="applyDate.form.entityId" placeholder="请选择" filterable @change="changeEntity">
+						<el-option v-for="item in entityList" :key="item.id" :label="item.name" :value="item.id">
 						</el-option>
 					</el-select>
 				</div>
-				<sa-item type="text" name="企业名称" v-model="applyDate.entity.name":disabled="true"></sa-item>
+				<sa-item type="text" name="企业名称" v-model="applyDate.entity.name" :disabled="true"></sa-item>
 				<sa-item type="text" name="税号" v-model="applyDate.entity.taxIdNo" :disabled="true"></sa-item>
 				<sa-item type="text" name="地址" v-model="applyDate.entity.address" :disabled="true"></sa-item>
 				<sa-item type="text" name="电话" v-model="applyDate.entity.phone" :disabled="true"></sa-item>
@@ -110,29 +162,28 @@
 		<script>
 			var app = new Vue({
 				components: {
-					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),  
-					"sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),		
+					"sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
+					"sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
 				},
 				el: '.vue-box',
 				data: {
 					p: { // 查询参数  
-						id: '',		// 主键 、
-
-						customerId: '',		// 客户id 
-						businessId: '',		// 业务订单id 
-						businessName: '',		// 业务名称 
-						businessNo: '',		// 业务订单号
-						carNo: '',         //车牌号
-						transactionId: '',		// 微信支付订单号 
-						billMoney: '',		// 账单金额 
-						status: '',		// 支付状态(0=未开票,1=已开票) 
-						invoiceTime: '',		// 开票时间 
-						createTime: '',		// 创建时间 
-						infoId: '',		// 开票信息id
-						infoNo: '',     // 开票信息no
-						pageNo: 1,		// 当前页 
-						pageSize: 10,	// 页大小 
-						sortType: 0		// 排序方式 
+						id: '', // 主键 、
+						payType: 0,
+						customerId: '', // 客户id 
+						businessId: '', // 业务订单id 
+						businessName: '', // 业务名称 
+						customerName: '',
+						entityName: '',
+						businessNo: '', // 业务订单号
+						carNo: '', //车牌号
+						transactionId: '', // 微信支付订单号 
+						status: '', // 支付状态(0=未开票,1=已开票) 
+						invoiceTime: '', // 开票时间 
+						infoNo: '', // 开票信息no
+						pageNo: 1, // 当前页 
+						pageSize: 10, // 页大小 
+						sortType: 0 // 排序方式 
 					},
 					dataCount: 0,
 					dataList: [], // 数据集合
@@ -147,47 +198,69 @@
 							customerId: '',
 							customerName: '',
 						},
-						entity:{},
+						entity: {},
 					},
 					currentCustomerId: '1',
 					currentCustomerName: '',
+					selectDisabled:false
 				},
 				methods: {
-					apply(){
+					apply() {
 						sa.checkNull(this.applyDate.form.entityId, '请选择 [主体信息]');
 						sa.checkNull(this.applyDate.form.isElec, '请选择 [电子发票]');
 
-						sa.ajax('/TbInvoiceInfo/generate', this.applyDate.form, function(res){
+						sa.ajax('/TbInvoiceInfo/generate', this.applyDate.form, function(res) {
 							this.applyDate.visible = false;
 							sa.alert('成功生成开票信息', this.f5);
 						}.bind(this));
 					},
-					applyFn(){
+					applyFn() {
+						this.selectDisabled=false;
+						this.applyDate.form={
+							ids: '',
+							entityId: '',
+							isElec: 1,
+							totalMoney: 0,
+							customerId: '',
+							customerName: '',
+						}
 						let selection = this.$refs['data-table'].selection;
-						if(selection.length == 0) {
+						if (selection.length == 0) {
 							return sa.msg('请至少选择一条数据')
 						}
 						let ids = sa.getArrayField(selection, 'id');
-						for(var i=0; i<selection.length; i++){
-							if(selection[i].status == 1 || selection[i].status == 2){
+						let entityName=selection[0].entityName;
+						for (var i = 0; i < selection.length; i++) {
+							if (selection[i].status == 1 || selection[i].status == 2) {
 								return sa.msg('请选择待申请的订单')
 							}
+							if(selection[i].entityName!=entityName){
+								return sa.msg('请选择同一个主体的订单进行开票');
+							}
 						}
 						let billMoneys = sa.getArrayField(selection, 'billMoney');
 						var totalMoney = 0;
-						for (var i=billMoneys.length-1; i>=0; i--) {
+						for (var i = billMoneys.length - 1; i >= 0; i--) {
 							totalMoney += billMoneys[i];
 						}
+						if(selection[0].entityName){
+							let entityArry=this.entityList.filter(obj=>obj.name==selection[0].entityName);
+							if(entityArry.length==0){
+								return sa.msg('开票主体缺少【'+selection[0].entityName+'】信息,请先录入主体信息');
+							}
+							this.applyDate.entity = entityArry[0];
+							this.applyDate.form.entityId=entityArry[0].id;
+							this.selectDisabled=true;
+						}
 						this.applyDate.form.totalMoney = totalMoney;
 						this.applyDate.visible = true;
 						this.applyDate.form.ids = ids.join(',');
-						this.getEntityList();
 					},
-					changeEntity(value){
+					changeEntity(value) {
 						let entity = this.entityList.filter(obj => obj.id == value).pop();
 						this.applyDate.entity = entity;
 					},
-					getEntityList(){
+					getEntityList() {
 						sa.ajax('/TbEntity/getList', function(res) {
 							this.entityList = res.data; // 数据
 						}.bind(this));
@@ -206,7 +279,7 @@
 						sa.ajax('/TbInvoiceOrder/getList', sa.removeNull(this.p), function(res) {
 							this.dataList = res.data; // 数据
 							this.dataCount = res.dataCount; // 数据总数 
-							sa.f5TableHeight();		// 刷新表格高度 
+							sa.f5TableHeight(); // 刷新表格高度 
 						}.bind(this));
 					},
 					// 查看
@@ -216,7 +289,7 @@
 					// 查看 - 根据选中的
 					getBySelect: function(data) {
 						var selection = this.$refs['data-table'].selection;
-						if(selection.length == 0) {
+						if (selection.length == 0) {
 							return sa.msg('请选择一条数据')
 						}
 						this.get(selection[0]);
@@ -227,7 +300,8 @@
 					},
 					// 新增
 					add: function(data) {
-						sa.showIframe('新增数据', 'tb-invoice-order-add.html?id=-1&customerId=' + this.currentCustomerId, '550px', '60%');
+						sa.showIframe('新增数据', 'tb-invoice-order-add.html?id=-1&customerId=' + this.currentCustomerId,
+							'550px', '60%');
 					},
 					// 删除
 					del: function(data) {
@@ -235,7 +309,7 @@
 							sa.ajax('/TbInvoiceOrder/delete?id=' + data.id, function(res) {
 								sa.arrayDelete(this.dataList, data);
 								sa.ok('删除成功');
-								sa.f5TableHeight();		// 刷新表格高度 
+								sa.f5TableHeight(); // 刷新表格高度 
 							}.bind(this))
 						}.bind(this));
 					},
@@ -244,15 +318,17 @@
 						// 获取选中元素的id列表 
 						let selection = this.$refs['data-table'].selection;
 						let ids = sa.getArrayField(selection, 'id');
-						if(selection.length == 0) {
+						if (selection.length == 0) {
 							return sa.msg('请至少选择一条数据')
 						}
 						// 提交删除 
 						sa.confirm('是否批量删除选中数据?此操作不可撤销', function() {
-							sa.ajax('/TbInvoiceOrder/deleteByIds', {ids: ids.join(',')}, function(res) {
+							sa.ajax('/TbInvoiceOrder/deleteByIds', {
+								ids: ids.join(',')
+							}, function(res) {
 								sa.arrayDelete(this.dataList, selection);
 								sa.ok('删除成功');
-								sa.f5TableHeight();		// 刷新表格高度 
+								sa.f5TableHeight(); // 刷新表格高度 
 							}.bind(this))
 						}.bind(this));
 					},
@@ -260,9 +336,10 @@
 				created: function() {
 					this.f5();
 					this.getCustomer();
+					this.getEntityList();
 					sa.onInputEnter();
 				}
 			})
 		</script>
 	</body>
-</html>
+</html>

+ 12 - 13
sp-server/src/main/java/com/pj/api/open/service/OpenService.java

@@ -245,8 +245,12 @@ public class OpenService {
         //============业务费计算是否交完
         for (TbBusiness tbBusiness : businessList) {
             List<TbBusinessItem> businessItems = tbBusinessItemService.findByBusinessId(tbBusiness.getId());
+            if (businessItems.isEmpty()) {
+                continue;
+            }
             //柜车、栏车 则取对应的入场和离场时间为开始结束时间
-            businessItems.stream().filter(item -> StrUtil.equals(item.getItemAlias(), SystemObject.config.getCabinetCar()))
+            businessItems.stream()
+                    .filter(item -> StrUtil.equals(item.getItemAlias(), SystemObject.config.getCabinetCar()))
                     .forEach(item -> {
                         item.setColdStartTime(tbBusinessCar.getRealInTime()).setColdEndTime(now);
                         //堆存业务的车辆====>免停车费
@@ -259,7 +263,7 @@ public class OpenService {
             int weiCarLeave = tbGoods.getVietnamCarLeave();
             //空车离场限制
             int emptyCarLeave = tbGoods.getChinaCarLeave();
-            boolean pay = tbBusiness.getPayMoney().doubleValue()>0;
+            boolean pay = tbBusiness.getPayMoney().doubleValue() > 0;
             //需要交业务费
             if (CarEnum.CarTypeEnum.WEIGHT_TYPE.getType().equals(carType)) {//==重车
                 if (GoodsEnum.LeaveEnum.PART_MONEY.getCode() != weiCarLeave
@@ -280,7 +284,6 @@ public class OpenService {
             businessRes = syncService.orderPriceCal(expenses);
         }
         BigDecimal carMoney = partMoneyRes.getTotalOrderPrice();
-
         BigDecimal businessMoney = businessRes.getTotalOrderPrice();
         BigDecimal total = businessMoney.add(carMoney);
         if (total.doubleValue() > 0) {
@@ -288,20 +291,16 @@ public class OpenService {
             if (businessMoney.doubleValue() > 0) {
                 desc += "业务费" + businessMoney.toString() + "元";
             }
-            // if (dto.getPrice().doubleValue() > 0) {
-            //     desc += " 入场管理费" + dto.getPrice().toString() + "元";
-            //  }
             if (carMoney.doubleValue() > 0) {
                 desc += " 停车费" + carMoney.toString() + "元";
             }
             RedisUtil.setByMINUTES(channel, carNo, 5);
-            // boolean flag = automaticPay.payBusinessAndPartMoney(businessList, tbBusinessCar, partMoneyRes);
-            //  if (flag) {
-            //
-            //   log.error("预存款扣款成功,返回:{},{}", carNo, desc);
-            //    freeOut(tbBusinessCar, now, channel, image);
-            //   return ResultJson.success();
-            //  }
+            boolean flag = automaticPay.payBusinessAndPartMoney(businessList, tbBusinessCar, partMoneyRes,businessRes);
+            if (flag) {
+                log.error("预存款扣款成功,返回:{},{}", carNo, desc);
+                freeOut(tbBusinessCar, now, channel, image);
+                return ResultJson.success();
+            }
             log.error("请求返回:{},{}", carNo, desc);
             return ResultJson.error(desc);
         }

+ 0 - 2
sp-server/src/main/java/com/pj/api/wx/service/WxService.java

@@ -246,8 +246,6 @@ public class WxService {
                         .setOutTradeNo(outTradeNo)
                         .setPayOpenid(payopenid);
                 tbBusinessCarService.updateById(car);
-                //支付完之后要解绑
-                automaticPay.unbindRun(car.getCarNo());
             }
             if (!cars.isEmpty()) {
                 tbFeeDetailsService.chargeParkFee(cars, transactionId, outTradeNo, payTime, PayEnum.PayType.WX_PAY);//添加cars的收费明细

+ 3 - 3
sp-server/src/main/java/com/pj/constants/business/FeeTypeEnum.java

@@ -13,9 +13,9 @@ public enum FeeTypeEnum {
 //    DISINFECT_FEE(2, "消杀作业"),
     STEVEDORE_FEE(3, "装卸作业"),
     PARK_FEE(4, "停车业务"),
-    //    WEIGHT_FEE(5, "过磅费"),
-    MANAGE_FEE(6, "入场管理费");
-    //    CHARGE_FEE(7, "充电打冷作业");
+        WEIGHT_FEE(5, "过磅费"),
+    MANAGE_FEE(6, "入场管理费"),
+        CHARGE_FEE(7, "充电打冷作业");
     private int code;
     private String desc;
 

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

@@ -13,9 +13,11 @@ import com.pj.constants.business.CarEnum;
 import com.pj.constants.business.FeeTypeEnum;
 import com.pj.constants.business.GoodsEnum;
 import com.pj.constants.business.PayEnum;
+import com.pj.current.config.SystemObject;
 import com.pj.project.sync.SyncService;
 import com.pj.project.sync.request.item.IOrderItem;
 import com.pj.project.sync.response.IOrderPriceRes;
+import com.pj.project.sync.response.item.OrderPriceResultItem;
 import com.pj.project.sync.response.item.PriceDetailItem;
 import com.pj.project.tb_business.TbBusiness;
 import com.pj.project.tb_business.TbBusinessService;
@@ -23,6 +25,8 @@ import com.pj.project.tb_business_car.TbBusinessCar;
 import com.pj.project.tb_business_car.TbBusinessCarService;
 import com.pj.project.tb_business_item.TbBusinessItem;
 import com.pj.project.tb_business_item.TbBusinessItemService;
+import com.pj.project.tb_costomer.TbCostomer;
+import com.pj.project.tb_costomer.TbCostomerService;
 import com.pj.project.tb_deduction_bind.TbDeductionBind;
 import com.pj.project.tb_deduction_bind.TbDeductionBindService;
 import com.pj.project.tb_deduction_record.TbDeductionRecord;
@@ -33,6 +37,7 @@ import com.pj.project.tb_goods.TbGoods;
 import com.pj.project.tb_goods.TbGoodsService;
 import com.pj.project.tb_invoice_order.TbInvoiceOrder;
 import com.pj.project.tb_invoice_order.TbInvoiceOrderService;
+import com.pj.project.tb_item.TbItemService;
 import com.pj.utils.AesUtil;
 import com.pj.utils.cache.RedisUtil;
 import com.pj.utils.sg.NbUtil;
@@ -62,8 +67,7 @@ public class AutomaticPay {
     TbBusinessCarService tbBusinessCarService;
     @Resource
     TbBusinessService tbBusinessService;
-    @Resource
-    TbDeductionBindService deductionBindService;
+
     @Resource
     TbBusinessItemService tbBusinessItemService;
     @Resource
@@ -72,40 +76,21 @@ public class AutomaticPay {
     TbAccountService tbAccountService;
     @Resource
     TbInvoiceOrderService invoiceOrderService;
-    @Resource
-    TbGoodsService tbGoodsService;
-    @Resource
-    @Lazy
-    private TbDeductionBindService tbDeductionBindService;
+
     @Resource
     private TbFeeStatisticsService tbFeeStatisticsService;
 
     @Resource
     private SyncService syncService;
-
-
-    /**
-     * 异步解绑入口
-     *
-     * @param plate
-     */
-    @Async
-    public void unbindRun(String plate) {
-        if (isExistTask(null, plate)) {
-            return;
-        }
-        autoUnbindCarByPlate(plate);
-        delRedisTask(null, plate);
-//        TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(plate);
-//        TbDeductionBind bind = tbDeductionBindService.findTheLastUnBindCar(plate);
-    }
+    @Resource
+    private TbCostomerService tbCostomerService;
 
 
     /**
      * 生成扣费记录
      */
     public TbDeductionRecord createTbDeductionRecord(TbFeeDetails feeDetails, BigDecimal originalMoney, BigDecimal balance,
-                                        String customerId,String customerName,String plate, String businessCarId, FeeTypeEnum feeTypeEnum) {
+                                                     String customerId, String customerName, String plate, String businessCarId, FeeTypeEnum feeTypeEnum) {
         TbDeductionRecord deductionRecord = BeanUtil.toBean(feeDetails, TbDeductionRecord.class);
         BigDecimal itemPrice = feeDetails.getItemPrice();
         String no = feeDetails.getBusinessNo();
@@ -115,7 +100,7 @@ public class AutomaticPay {
                 .setDeductMoney(itemPrice)
                 .setBusinessNo(no)
                 .setOriginalMoney(originalMoney).setBusinessId(feeDetails.getBusinessId())
-                .setTotalMoney(balance).setBusinessCarId(businessCarId)
+                .setTotalMoney(originalMoney.subtract(itemPrice)).setBusinessCarId(businessCarId)
                 .setFeeDetailsId(feeDetails.getId()).setItemName(feeDetails.getItemName())
                 .setItemTypeId(feeDetails.getItemTypeId()).setItemTypeName(feeDetails.getItemTypeName())
                 .setReviewStatus(0).setFeeType(feeTypeEnum.getCode()).setFeeTypeName(feeTypeEnum.getDesc())
@@ -123,239 +108,12 @@ public class AutomaticPay {
                 .setFeeDetailsId(feeDetails.getId())
                 .setBusinessNo(feeDetails.getBusinessNo());
         deductionRecord.insert();
-        String preNo= DateUtil.format(new Date(),"yyyyMMddHHmm")+RandomUtil.randomString(5);
+        String preNo = DateUtil.format(new Date(), "yyyyMMddHHmm") + RandomUtil.randomString(5);
         feeDetails.setPreOrderNum(preNo);
         tbFeeDetailsService.updateById(feeDetails);
         return deductionRecord;
     }
 
-    /**
-     * 更新停车费状态
-     */
-    private void updateTbBusinessCar(TbBusinessCar car) {
-        if (car == null) return;
-        car.setPay(1).setPayTime(new Date()).setPayType(CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType());
-        car.updateById();
-    }
-
-    /**
-     * 更新停车费状态
-     */
-    private void updateTbBusinessCars(List<TbBusinessCar> cars) {
-        if (cars == null) return;
-        for (TbBusinessCar car : cars) {
-            updateTbBusinessCar(car);
-        }
-    }
-
-    /**
-     * 生成开票订单信息
-     *
-     * @param tbBusiness
-     */
-    private void createTbInvoiceOrder(TbBusiness tbBusiness, List<TbBusinessCar> cars, BigDecimal parkingFee,
-                                      String plate, String customerId, String no, boolean isOut) {
-        TbInvoiceOrder invoiceOrder = new TbInvoiceOrder();
-        List<String> businessNameList = new ArrayList<>();
-        List<String> businessNoList = new ArrayList<>();
-        List<String> carNos = new ArrayList<>();
-        businessNoList.add(tbBusiness.getNo());
-        carNos.add(plate);
-        businessNameList.add(tbBusiness.getGoodsName());
-        if (cars != null) {
-            for (TbBusinessCar car : cars) {
-                if (isOut) {
-                    if (CarEnum.PayTypeEnum.FEE_TYPE.getType().equals(car.getPayType())) {
-                        continue;
-                    }
-                    if (!businessNameList.contains("停车费")) {
-                        businessNameList.add("停车费");
-                    }
-                } else {
-                    if (NbUtil.isNull(car.getCarNo()) || !car.getCarNo().equals(plate)) {
-                        continue;
-                    }
-                }
-                if (!businessNoList.contains(car.getNo())) {
-                    businessNoList.add(car.getNo());
-                }
-                if (!carNos.contains(car.getCarNo())) {
-                    carNos.add(car.getCarNo());
-                }
-            }
-        }
-        String businessNameStr = businessNameList.stream().map(String::valueOf).collect(Collectors.joining(","));
-        String businessNoStr = businessNoList.stream().map(String::valueOf).collect(Collectors.joining(","));
-        String carNoStr = carNos.stream().map(String::valueOf).collect(Collectors.joining(","));
-        BigDecimal billMoney = tbBusiness.getItemPrice();
-        if (parkingFee != null) {
-            billMoney = parkingFee.add(billMoney);
-        }
-        invoiceOrder.setBusinessName(businessNameStr).setBusinessNo(businessNoStr).setCarNo(carNoStr)
-                .setTransactionId(null).setBillMoney(billMoney).setBusinessId(tbBusiness.getId())
-                .setStatus(0).setCreateTime(new Date()).setCustomerId(customerId).setPreOrderNum(no);
-        invoiceOrderService.save(invoiceOrder);
-    }
-
-    /**
-     * 无业务车辆收停车费生成发票信息
-     */
-    private void createTbInvoiceOrderPark(TbBusinessCar car, String customerId, String no) {
-        TbInvoiceOrder invoiceOrder = new TbInvoiceOrder();
-
-        invoiceOrder.setBusinessName("停车费").setBusinessNo(car.getNo()).setCarNo(car.getCarNo())
-                .setTransactionId(null).setBillMoney(car.getMoney()).setBusinessId(null)
-                .setStatus(0).setCreateTime(new Date()).setCustomerId(customerId).setPreOrderNum(no);
-        invoiceOrderService.save(invoiceOrder);
-    }
-
-
-    /**
-     * 补录进场解绑逻辑
-     *
-     * @return
-     */
-    private void autoUnbindCarByPlate(String plate) {
-        if (NbUtil.isNull(plate)) return;
-        TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(plate);
-        //离场逻辑
-        if (tbBusinessCar != null) {
-            if (doUnbindCarByPlate(tbBusinessCar)) {
-                return;
-            }
-        }
-        //进场逻辑
-        TbDeductionBind bind = deductionBindService.getOne(new LambdaQueryWrapper<TbDeductionBind>().eq(
-                TbDeductionBind::getBindCar, plate).isNull(TbDeductionBind::getUnbindTime));
-        if (bind != null) {
-            TbDeductionRecord record = new TbDeductionRecord();
-            Integer count = record.selectCount(new LambdaQueryWrapper<TbDeductionRecord>().like(
-                    TbDeductionRecord::getDeductionBindId, bind.getId()));
-            if (count > 0) {
-                bind.setUpdateBy("预充值自动缴费解绑");
-                bind.setUpdateTime(new Date());
-                bind.setUnbindTime(new Date());
-                bind.updateById();
-            } else {
-                Integer buCount = tbBusinessService.count(new LambdaQueryWrapper<TbBusiness>().ne(
-                        TbBusiness::getPayStatus, 1)
-                        .between(TbBusiness::getCreateTime, bind.getBindTime(), NbUtil.getNow()));
-                if (buCount > 0) {
-                    bind.setUpdateBy("预充值自动缴费解绑");
-                    bind.setUpdateTime(new Date());
-                    bind.setUnbindTime(new Date());
-                    bind.updateById();
-                }
-            }
-        }
-    }
-
-    /**
-     * 补录出场解绑逻辑
-     *
-     * @param tbBusinessCar
-     */
-    private boolean doUnbindCarByPlate(TbBusinessCar tbBusinessCar) {
-        if (tbBusinessCar == null || tbBusinessCar.getRealOutTime() == null) {
-            return false;
-        }
-        TbDeductionBind bind = deductionBindService.getOne(new LambdaQueryWrapper<TbDeductionBind>().eq(
-                TbDeductionBind::getBindCar, tbBusinessCar.getCarNo())
-                .lt(TbDeductionBind::getBindTime, tbBusinessCar.getRealOutTime())
-                .isNull(TbDeductionBind::getUnbindTime));
-        if (bind == null) {
-            return false;
-        }
-        bind.setUpdateBy("预充值自动缴费解绑");
-        bind.setUpdateTime(new Date());
-        bind.setUnbindTime(new Date());
-        bind.updateById();
-        return true;
-    }
-
-    /**
-     * 缓存任务,如果存在任务不继续往下执行
-     *
-     * @param businessId
-     * @param plate
-     * @return
-     */
-    private boolean isExistTask(String businessId, String plate) {
-        String key = getRedisKey(businessId, plate);
-        if (NbUtil.isNullStr(RedisUtil.get(key))) {
-            RedisUtil.setBySECONDS(key, key, 5);
-            return false;
-        }
-        return true;
-    }
-
-    private void delRedisTask(String businessId, String plate) {
-        String key = getRedisKey(businessId, plate);
-        RedisUtil.del(key);
-    }
-
-    private String getRedisKey(String businessId, String plate) {
-        if (NbUtil.isNullStr(businessId)) {
-            businessId = "100";
-        }
-        if (NbUtil.isNullStr(plate)) {
-            plate = "100";
-        }
-        String key = "autoPay:" + businessId + plate;
-        return key;
-    }
-
-    /**
-     * 预付款支付停车费
-     *
-     * @param tbBusinessCar
-     * @param now
-     * @return
-     */
-    public boolean payPartMoney(TbBusinessCar tbBusinessCar, IOrderPriceRes orderPriceRes, Date now) {
-        String carNo = tbBusinessCar.getCarNo();
-        TbDeductionBind bind = tbDeductionBindService.getBindCarByPlate(carNo);
-        //未绑定
-        if (bind == null) {
-            return false;
-        }
-        TbAccount tbAccount = tbAccountService.getAccountByCustomerId(bind.getCustomerId());
-        BigDecimal balance = tbAccount.getTotalMoney();
-        //不足
-        BigDecimal partMoney = orderPriceRes.getTotalOrderPrice();
-        if (balance.compareTo(partMoney) < 0) {
-            return false;
-        }
-        balance = balance.subtract(partMoney);
-        //更新余额+累计扣款
-        tbAccount.setTotalMoney(balance).setLastSumMoney(tbAccount.getLastSumMoney().add(partMoney));
-        tbAccountService.updateById(tbAccount);
-        tbBusinessCar.setMoney(partMoney).setPayType(CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType()).setPayTime(now);
-        //todo 自动扣款修改
-        PriceBO priceBO = new PriceBO();
-        priceBO.setId(tbBusinessCar.getId()).setHourDesc(orderPriceRes.getHourDesc()).setCarDesc(orderPriceRes.getCarDesc())
-                .setCalculateId(orderPriceRes.getCalculateId()).setP(orderPriceRes.getTotalOrderPrice());
-        List<PriceDetailItem> priceDetailItems = orderPriceRes.getFireResult().get(0).getPriceDetail();
-        for (PriceDetailItem priceDetailItem : priceDetailItems) {
-            String k = StrUtil.trim(priceDetailItem.getKey()).toLowerCase();
-            String v = priceDetailItem.getValue();
-            if (k.equals("standard")) {
-                priceBO.setStandard(new BigDecimal(v));
-            } else if (k.equals("extraPrice")) {
-                priceBO.setExtraPrice(new BigDecimal(v));
-            }
-        }
-        List<PriceBO> priceBOList = new ArrayList<PriceBO>() {{
-            add(priceBO);
-        }};
-        String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + RandomUtil.randomNumbers(4);
-        //车辆的扣费记录
-        List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.chargeParkFee(
-                priceBOList, null, null, now, PayEnum.PayType.PER_PAY);
-
-        tbFeeStatisticsService.addOrUpdateStatistic(now, PayEnum.PayType.PER_PAY.getCode());//更新当前日期的日统计
-        return true;
-    }
 
     /**
      * 支付停车费和业务费
@@ -365,88 +123,108 @@ public class AutomaticPay {
      */
     public boolean payBusinessAndPartMoney(List<TbBusiness> businessList,
                                            TbBusinessCar tbBusinessCar,
-                                           IOrderPriceRes partMoneyRes) {
+                                           IOrderPriceRes partMoneyRes, IOrderPriceRes businessRes) {
         Date now = new Date();
-        for (TbBusiness tbBusiness : businessList) {
-            TbAccount tbAccount = tbAccountService.getAccountByCustomerId(tbBusiness.getCustomerId());
-            BigDecimal balance = tbAccount.getTotalMoney();
-            //停车费扣除
-            BigDecimal partMoney = partMoneyRes.getTotalOrderPrice();
-            if (partMoney.compareTo(balance) > 0) {
-                return false;//不够交
+        String customerId = tbBusinessCar.getCustomerId();
+        if (StrUtil.isEmpty(customerId)) {
+            return false;
+        }
+        TbAccount tbAccount = tbAccountService.getAccountByCustomerId(customerId);
+        //原金额
+        BigDecimal originalMoney = tbAccount.getTotalMoney();
+        //停车费扣除
+        BigDecimal partMoney = partMoneyRes.getTotalOrderPrice();
+        //业务费用
+        BigDecimal businessMoney = businessRes.getTotalOrderPrice();
+        //总费用
+        BigDecimal totalMoney = partMoney.add(businessMoney);
+        if (totalMoney.compareTo(originalMoney) > 0) {
+            return false;//不够交
+        }
+        BigDecimal balance = originalMoney.subtract(totalMoney);
+        tbAccount.setTotalMoney(balance);
+        TbCostomer tbCostomer = tbCostomerService.getById(customerId);
+        String customerName = tbCostomer.getName();
+        //需要交停车费且未交的话
+        if (tbBusinessCar.getPay() == 0 && partMoney.compareTo(BigDecimal.ZERO) > 0) {
+            String businessIds = businessList.stream().filter(tbBusiness -> tbBusiness.getGoodsName().contains("停车"))
+                    .map(TbBusiness::getId).collect(Collectors.joining(","));
+            String uniqExpenseId = partMoneyRes.getUniqueExpenseId();
+            String calculateId = partMoneyRes.getCalculateId();
+            String carDesc = partMoneyRes.getCarDesc();
+            String hourDesc = partMoneyRes.getHourDesc();
+            List<PriceDetailItem> items = partMoneyRes.getFireResult().get(0).getPriceDetail();
+            if (partMoneyRes.getTotalOrderPrice().intValue() > 0) {
+                items = partMoneyRes.getFireResult().get(0).getPriceDetail();
             }
-            if (tbBusinessCar.getPay() == 0 && partMoney.compareTo(BigDecimal.ZERO) > 0) {
-                String uniqExpenseId = partMoneyRes.getUniqueExpenseId();
-                String calculateId = partMoneyRes.getCalculateId();
-                String carDesc = partMoneyRes.getCarDesc();
-                String hourDesc = partMoneyRes.getHourDesc();
-                List<PriceDetailItem> items = partMoneyRes.getFireResult().get(0).getPriceDetail();
-                if (partMoneyRes.getTotalOrderPrice().intValue() > 0) {
-                    items = partMoneyRes.getFireResult().get(0).getPriceDetail();
-                }
-                PriceBO priceBO = new PriceBO();
-                List<PriceBO> priceBOList = new ArrayList<>();
-                priceBO.setId(tbBusinessCar.getId()).setP(partMoney).setCalculateId(calculateId)
-                        .setCarDesc(carDesc).setHourDesc(hourDesc).setBusinessId(tbBusiness.getId())
-                        .setUniqExpenseId(uniqExpenseId);
-                priceBOList.add(priceBO);
-                for (PriceDetailItem item : items) {
-                    if (item.getKey().toLowerCase().trim().equals("standard")) {
-                        priceBO.setStandard(new BigDecimal(item.getValue()));
-                    } else if (item.getKey().toLowerCase().trim().equals("extraPrice")) {
-                        priceBO.setStandard(new BigDecimal(item.getValue()));
-                    }
+            PriceBO priceBO = new PriceBO();
+            List<PriceBO> priceBOList = new ArrayList<>();
+            priceBO.setId(tbBusinessCar.getId()).setP(partMoney).setCalculateId(calculateId)
+                    .setCarDesc(carDesc).setHourDesc(hourDesc).setBusinessId(businessIds)
+                    .setUniqExpenseId(uniqExpenseId);
+            priceBOList.add(priceBO);
+            for (PriceDetailItem item : items) {
+                if (item.getKey().toLowerCase().trim().equals("standard")) {
+                    priceBO.setStandard(new BigDecimal(item.getValue()));
+                } else if (item.getKey().trim().equals("extraPrice")) {
+                    priceBO.setExtraPrice(new BigDecimal(item.getValue()));
                 }
-                BigDecimal afterBalance = balance.subtract(partMoney);
-                tbAccount.setTotalMoney(afterBalance);
-                tbAccountService.updateById(tbAccount);
-                String plate = tbBusinessCar.getCarNo();
-                tbBusinessCar.setPay(1).setPayType(CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType())
-                        .setPayTime(now).setMoney(partMoney);
-                tbBusinessCarService.updateById(tbBusinessCar);
-                List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.chargeParkFee(priceBOList, null, null, now, PayEnum.PayType.PER_PAY);
-                //停车费明细
-                this.createTbDeductionRecord(parkFeeDetailsList.get(0), balance, afterBalance,
-                      tbBusiness.getCustomerId(),tbBusiness.getCustomerName(), plate, tbBusinessCar.getId(), FeeTypeEnum.PARK_FEE);
-
             }
+            String plate = tbBusinessCar.getCarNo();
+            tbBusinessCar.setPay(1).setPayType(CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType())
+                    .setPayTime(now).setMoney(partMoney);
+            tbBusinessCarService.updateById(tbBusinessCar);
+            TbBusiness tbBusiness = businessList.get(0);
+            String businessNo = tbBusiness.getNo();
+            List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.chargeParkFee(priceBOList, null, null, now, PayEnum.PayType.PER_PAY);
+            //停车费明细
+            for (TbFeeDetails tbFeeDetails : parkFeeDetailsList) {
+                tbFeeDetails.setBusinessNo(businessNo);
+                TbDeductionRecord record = this.createTbDeductionRecord(tbFeeDetails, originalMoney, BigDecimal.ZERO,
+                        customerId, customerName, plate, tbBusinessCar.getId(), FeeTypeEnum.PARK_FEE);
+                invoiceOrderService.addInvoiceOrder("停车业务", businessNo, tbBusinessCar.getCarNo(), tbBusiness.getId(), tbBusinessCar.getCustomerId(), tbBusiness.getCustomerName(), tbBusiness.getCustomerName(), partMoney, tbFeeDetails, record);
+                originalMoney = originalMoney.subtract(tbFeeDetails.getItemPrice());
+            }
+        }
+        //业务费用
+        for (TbBusiness tbBusiness : businessList) {
             List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(tbBusiness.getId());
             items = items.stream().filter(item -> item.getPayStatus() == 0).collect(Collectors.toList());
             for (TbBusinessItem item : items) {
                 if (item.getPayStatus() == 1) {//已支付的
                     continue;
                 }
-                int feeType = item.getPayType();
-                FeeTypeEnum feeTypeEnum = FeeTypeEnum.getEnum(feeType);
-                List<IOrderItem> expenses = new ArrayList<>();
-                tbBusinessItemService.buildExpenses(Collections.singletonList(item), expenses);
-                IOrderPriceRes res = syncService.orderPriceCal(expenses);
-                BigDecimal price = res.getTotalOrderPrice();
-                if (balance.compareTo(price) < 0) {
-                    return false;
+                //支付金额累加
+                if (!StrUtil.equals(item.getItemAlias(), SystemObject.config.getPartItemAlias())) {
+                    List<IOrderItem> orderItems = new ArrayList<>();
+                    tbBusinessItemService.buildExpenses(Collections.singletonList(item), orderItems);
+                    if (orderItems.isEmpty()) {
+                        continue;
+                    }
+                    IOrderPriceRes res = syncService.orderPriceCal(orderItems);
+                    BigDecimal price = res.getTotalOrderPrice();
+                    item.setTotal(price);
+                    tbBusiness.setPayMoney(tbBusiness.getPayMoney().add(price));
+                    int feeType = item.getPayType();
+                    FeeTypeEnum feeTypeEnum = FeeTypeEnum.getEnum(feeType);
+                    TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, tbBusiness.getCustomerName(), tbBusiness.getPickCustomerName(), feeTypeEnum);
+                    TbDeductionRecord record = createTbDeductionRecord(details, originalMoney, BigDecimal.ZERO, customerId, tbBusiness.getCustomerName(),
+                            tbBusinessCar.getCarNo(), tbBusinessCar.getId(), feeTypeEnum);
+                    invoiceOrderService.addInvoiceOrder(tbBusiness.getGoodsName(), tbBusiness.getNo(), tbBusiness.getCarNoStr(), tbBusiness.getId(),
+                            tbBusiness.getCustomerId(), tbBusiness.getCustomerName(), tbBusiness.getCustomerName(), res.getTotalOrderPrice(), details, record);
+                } else {
+                    tbBusiness.setPayMoney(tbBusiness.getPayMoney().add(partMoney)).setItemPrice(BigDecimal.ZERO);
                 }
-                item.setPayStatus(1).setPayTime(new Date());
+                item.setPayStatus(1).setPayTime(now);
                 tbBusinessItemService.updateById(item);
-                String customerId = tbBusiness.getCustomerId();
-                BigDecimal afterBalance = balance.subtract(price);
-                tbAccount.setTotalMoney(afterBalance);
-                tbAccountService.updateById(tbAccount);
-                //支付金额累加
-                tbBusiness.setPayMoney(tbBusiness.getPayMoney().add(price));
+                tbBusiness.setPayStatus(PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode()).setPayTime(now);
                 tbBusinessService.updateById(tbBusiness);
-                TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, feeTypeEnum);
-                createTbDeductionRecord(details, balance, afterBalance, customerId,tbBusiness.getCustomerName(),
-                        tbBusinessCar.getCarNo(), tbBusinessCar.getId(), feeTypeEnum);
             }
         }
-
-        if (businessList.isEmpty()&&partMoneyRes.getTotalOrderPrice().compareTo(BigDecimal.ZERO)>0){
-            //单独交停车费
-
-        }
-
         //todo 构造统计数据
         tbFeeStatisticsService.addOrUpdateStatistic(now, PayEnum.PayType.PER_PAY.getCode());//更新当前日期的日统计
+        //更新账户余额
+        tbAccountService.updateById(tbAccount);
         return true;
     }
 }

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

@@ -456,7 +456,11 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     partMoney = new BigDecimal("0");
                 }
                 if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())) {
-                    inTime = tbBusinessCar.getPayTime();
+                    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());
@@ -685,7 +689,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         for (TbItem tbItem : tbItems) {
             TbItem db = tbItemService.getById(tbItem.getId());
             String itemName = db.getItemName();
-            goodsName = goodsName + "" + itemName;
+            goodsName = goodsName + "-" + itemName;
             String alaisName = db.getItemAlias();
             String startImage = tbItem.getStartImage();
             if (StrUtil.equals(SystemObject.config.getColdItemAlias(), alaisName) && StrUtil.isEmpty(startImage)) {
@@ -823,6 +827,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         throw new AjaxError("车辆【" + carNo + "】绑定的客户与已绑定的【" + exitBusiness.getCustomerName() + "】不一致");
                     }
                 }
+                exitBusinessList.add(tbBusiness);
+                long partBusinessCount = exitBusinessList.stream().filter(busienss -> StrUtil.equals("A10006", busienss.getGoodsCode()))
+                        .count();
+                if (exitBusinessList.size()>1&&partBusinessCount>0){
+                    throw new AjaxError("车辆【"+carNo+"】录入停车业务的同时存在其他业务");
+                }
             }
             if (!tbGoods.getName().contains("整车")) {
                 //记录不存在或者已离场
@@ -904,7 +914,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         String carBuseinssNo = DateUtil.format(now, "yyyyMMddHHmm");
         String goodsName = tbGoods.getName();
         List<TbBusinessItem> itemList = new ArrayList<>();
-        if (dbBusiness.getPayMoney().compareTo(dbBusiness.getItemPrice()) < 0) {
+        if (PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode() != dbBusiness.getPayStatus()) {
             List<TbBusinessItem> businessItemList = tbBusinessItemService.findByBusinessId(id);
             //变成未取柜状态
             businessItemList.stream().filter(item -> item.getParentCabinetId() != null).forEach(item -> {
@@ -927,7 +937,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 TbItem db = tbItemService.getById(tbItem.getId());
                 String alaisName = db.getItemAlias();
                 String itemName = db.getItemName();
-                goodsName = goodsName + "" + itemName;
+                goodsName = goodsName + "-" + itemName;
                 String endImage = tbItem.getEndImage();
                 if (StrUtil.equals(SystemObject.config.getColdItemAlias(), alaisName) && StrUtil.isEmpty(endImage)) {
                     throw new AjaxError("请上传结束时间图片");
@@ -1034,13 +1044,18 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             if (checkCar != null && checkCar.getRealOutTime() == null) {
                 //未离场====>检查是否录入了其他业务,需要校验其绑定的客户是否一致
                 List<TbBusiness> exitBusinessList = this.findOtherBusinessByCarId(checkCar.getId());
-                if (!exitBusinessList.isEmpty()) {
-                    TbBusiness exitBusiness = exitBusinessList.get(0);
-                    String bindCustomerId = exitBusiness.getCustomerId();
-                    if (!StrUtil.equals(bindCustomerId, customerId)) {
-                        //throw new AjaxError("车辆【" + carNo + "】绑定的客户与已绑定的【" + exitBusiness.getCustomerName() + "】不一致");
+                for (TbBusiness tbBusiness : exitBusinessList) {
+                    String bindCustomerId = tbBusiness.getCustomerId();
+                    if (!StrUtil.equals(bindCustomerId, customerId)
+                            && !StrUtil.equals(tbBusiness.getId(), dbBusiness.getId())) {
+                        throw new AjaxError("车辆【" + carNo + "】绑定的客户与已绑定的【" + tbBusiness.getCustomerName() + "】不一致");
                     }
                 }
+                long partBusinessCount = exitBusinessList.stream().filter(busienss -> StrUtil.equals("A10006", busienss.getGoodsCode()))
+                        .count();
+                if (exitBusinessList.size()>1&&partBusinessCount>0){
+                    throw new AjaxError("车辆【"+carNo+"】录入停车业务的同时存在其他业务");
+                }
             }
             if (StrUtil.isNotEmpty(businessCarId)) {
                 //原来已存在的
@@ -1733,18 +1748,21 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         throw new AjaxError("[" + tbAccount.getCustomerName() + "]账户余额不足扣除" + item.getItemName());
                     } else {
                         tbBusinessCar.setPayUnloadMoney(1);
+
                         tbBusinessCarService.updateById(tbBusinessCar);
                         item.setPayTime(now).setPayStatus(1).setPayType(PayEnum.PayType.PER_PAY.getCode())
                                 .setPayTypeName(PayEnum.PayType.PER_PAY.getDesc());
                         tbBusinessItemService.updateById(item);
-                        tbBusiness.setPayMoney(price.add(tbBusiness.getPayMoney())).setPayTime(now);
+                        tbBusiness.setPayMoney(price.add(tbBusiness.getPayMoney())).setPayTime(now)
+                                .setPayStatus(PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode());
                         BigDecimal afterBalance = balance.subtract(price);
                         tbAccount.setTotalMoney(afterBalance);//增加累计扣款
                         tbAccountService.updateById(tbAccount);
-                        TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, FeeTypeEnum.STEVEDORE_FEE);
+                        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);
-                        addInvoiceOrder(tbBusiness, res.getTotalOrderPrice(), details, record);
+                        tbInvoiceOrderService.addInvoiceOrder(tbBusiness.getGoodsName(), tbBusiness.getNo(), tbBusiness.getCarNoStr(), tbBusiness.getId(),
+                                tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusiness.getPickCustomerName(), res.getTotalOrderPrice(), details, record);
                     }
                 }
             }
@@ -1784,7 +1802,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     item.setPayTime(now).setPayStatus(1).setPayType(PayEnum.PayType.PER_PAY.getCode())
                             .setPayTypeName(PayEnum.PayType.PER_PAY.getDesc());
                     tbBusinessItemService.updateById(item);
-                    tbBusiness.setPayMoney(price.add(tbBusiness.getPayMoney())).setPayTime(now);
+                    tbBusiness.setPayMoney(price.add(tbBusiness.getPayMoney())).setPayTime(now).setPayStatus(PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode());
                     //查找越南车--->统计以--->重车对集装箱吊装 (重 柜 ) =====空车 vs 集装箱吊装 (空 柜 )
                     String itemAlias = item.getItemAlias();
                     TbBusinessCar tbBusinessCar = tbBusinessCars.stream().filter(car -> car.getCarType().equals(CarEnum.CarTypeEnum.EMPTY_TYPE.getType()))
@@ -1793,10 +1811,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         tbBusinessCar = tbBusinessCars.stream().filter(car -> car.getCarType().equals(CarEnum.CarTypeEnum.WEIGHT_TYPE.getType()))
                                 .findAny().orElse(tbBusinessCars.get(0));
                     }
-                    TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, FeeTypeEnum.STEVEDORE_FEE);
+                    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);
-                    addInvoiceOrder(tbBusiness, res.getTotalOrderPrice(), details, record);
+                    tbInvoiceOrderService.addInvoiceOrder(tbBusiness.getGoodsName(), tbBusiness.getNo(), tbBusiness.getCarNoStr(), tbBusiness.getId(),
+                            tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusiness.getPickCustomerName(), res.getTotalOrderPrice(), details, record);
+
                 }
             }
         }
@@ -1806,25 +1826,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         this.updateById(tbBusiness);
     }
 
-    /**
-     * 添加开票订单
-     *
-     * @param tbBusiness
-     * @param billMoney
-     */
-    private void addInvoiceOrder(TbBusiness tbBusiness, BigDecimal billMoney, TbFeeDetails details, TbDeductionRecord record) {
-        TbInvoiceOrder t = new TbInvoiceOrder();
-        t.setBusinessName(tbBusiness.getGoodsName())
-                .setBusinessNo(tbBusiness.getNo())
-                .setCarNo(tbBusiness.getCarNoStr())
-                .setBusinessId(tbBusiness.getId())
-                .setCustomerId(tbBusiness.getCustomerId())
-                .setBillMoney(billMoney).setDetailId(details.getId())
-                .setPreOrderNum(details.getPreOrderNum())
-                .setDeductionRecordId(record.getId())
-                .setStatus(0).setCreateTime(new Date());
-        tbInvoiceOrderService.save(t);
-    }
 
     /**
      * 审核驳回

+ 0 - 14
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarController.java

@@ -217,20 +217,6 @@ public class TbBusinessCarController {
     }
 
 
-    /**
-     * 审核通过
-     *
-     * @return
-     */
-    @RequestMapping("confirmJudgePass")
-    @SaCheckPermission(TbBusinessCar.PERMISSION__JUDGE)
-    @Deprecated
-    public AjaxJson confirmJudge() {
-        SoMap soMap = SoMap.getRequestSoMap();
-        String id = soMap.getString("id");
-       String msg= tbBusinessCarService.confirmJudgePass(id);
-        return AjaxJson.getSuccess(msg);
-    }
 
     /**
      * 驳回

+ 0 - 93
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java

@@ -508,100 +508,7 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         this.updateById(db);
     }
 
-    /**
-     * 审核通
-     *
-     * @param id
-     */
-    public String confirmJudgePass(String id) {
-        List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(id);
-        if (businessList.isEmpty()) {
-            throw new AjaxError("车辆对应业务已被删除");
-        }
-        AtomicReference<String> msg = new AtomicReference<>("");
-        for (TbBusiness tbBusiness : businessList) {
-            Date now = new Date();
-            List<TbBusinessCar> tbBusinessCars = this.findOtherBusinessCar(tbBusiness.getId());
-            //审核
-            List<TbBusinessItem> tbBusinessItems = tbBusinessItemService.findByBusinessId(tbBusiness.getId());
-            String customerId = tbBusiness.getPickCustomerId();
-            TbAccount tbAccount = tbAccountService.getAccountByCustomerId(customerId);
-            for (TbBusinessCar tbBusinessCar : tbBusinessCars) {
-                for (TbBusinessItem item : tbBusinessItems) {
-                    String itemName = item.getItemName();
-                    // todo 扣除 人工、机械装卸车辆---->每辆车都要支付----->
-                    if (SystemObject.config.getEveryCarPay().contains(itemName) && tbBusinessCar.getPayUnloadMoney() == 0) {
-                        List<IOrderItem> expenses = new ArrayList<>();
-                        IOrderItem orderItem = new IOrderItem();
-                        orderItem.setExpenseNum(Integer.parseInt(item.getNum()))
-                                .setUniqExpenseId(item.getItemCode());
-                        expenses.add(orderItem);
-                        IOrderPriceRes res = syncService.orderPriceCal(expenses);
-                        BigDecimal price = res.getTotalOrderPrice();
-                        BigDecimal balance = tbAccount.getTotalMoney();
-                        if (price.compareTo(balance) > 0) {
-                            throw new AjaxError("[" + tbAccount.getCustomerName() + "]账户余额不足扣除" + item.getItemName());
-                        } else {
-                            tbBusinessCar.setPayUnloadMoney(1);
-                            item.setPayTime(now).setPayStatus(1).setPayType(PayEnum.PayType.PER_PAY.getCode())
-                                    .setPayTypeName(PayEnum.PayType.PER_PAY.getDesc());
-                            tbBusinessItemService.updateById(item);
-                            tbBusiness.setPayMoney(price.add(tbBusiness.getPayMoney()));
-                            tbBusinessService.updateById(tbBusiness);
-                            BigDecimal afterBalance = balance.subtract(price);
-                            tbAccount.setTotalMoney(afterBalance);//增加累计扣款
-                            tbAccountService.updateById(tbAccount);
-                            TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, FeeTypeEnum.STEVEDORE_FEE);
-                            tbFeeStatisticsService.addOrUpdateStatistic(now, PayEnum.PayType.PER_PAY.getCode());//更新当前日期的日统计
-                            automaticPay.createTbDeductionRecord(details, balance, afterBalance, tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.STEVEDORE_FEE);
-                        }
-                    }
-                }
-                tbBusinessCar.setConfirmJudge(CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode())
-                        .setConfirmJudgeContent("审核通过").setConfirmJudgeTime(now)
-                        .setConfirmJudgeBy(StpUserUtil.getCreateBy());
-            }
-            this.updateBatchById(tbBusinessCars);
-            //其他费项 装卸业务管理费” 进行预存款扣除
-            for (TbBusinessItem item : tbBusinessItems) {
-                //业务类型是装卸业务管理费且未支付的进行扣款
-                if (item.getPayStatus() == 0 && SystemObject.config.getUnLoadItem().contains(item.getItemTypeName())) {
-                    List<IOrderItem> expenses = new ArrayList<>();
-                    IOrderItem orderItem = new IOrderItem();
-                    orderItem.setExpenseNum(Integer.parseInt(item.getNum()))
-                            .setUniqExpenseId(item.getItemCode());
-                    expenses.add(orderItem);
-                    IOrderPriceRes res = syncService.orderPriceCal(expenses);
-                    BigDecimal price = res.getTotalOrderPrice();
-                    BigDecimal balance = tbAccount.getTotalMoney();
-                    if (price.compareTo(balance) > 0) {
-                        throw new AjaxError("[" + tbAccount.getCustomerName() + "]账户余额不足扣除" + item.getItemName());
-                    } else {
-                        BigDecimal afterBalance = balance.subtract(price);
-                        tbAccount.setTotalMoney(afterBalance);//增加累计扣款
-                        tbAccountService.updateById(tbAccount);
-                        item.setPayTime(now).setPayStatus(1).setPayType(PayEnum.PayType.PER_PAY.getCode())
-                                .setPayTypeName(PayEnum.PayType.PER_PAY.getDesc());
-                        tbBusinessItemService.updateById(item);
-                        tbBusiness.setPayMoney(price.add(tbBusiness.getPayMoney()));
-                        tbBusinessService.updateById(tbBusiness);
-                        //查找越南车--->统计以
-                        TbBusinessCar tbBusinessCar = tbBusinessCars.stream().filter(car -> !CAR_LIST.contains(car.getCarNo().substring(0, 1)))
-                                .findAny().orElse(tbBusinessCars.get(0));
-                        TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, FeeTypeEnum.STEVEDORE_FEE);
-                        tbFeeStatisticsService.addOrUpdateStatistic(now, PayEnum.PayType.PER_PAY.getCode());//更新当前日期的日统计
-                        automaticPay.createTbDeductionRecord(details, balance, afterBalance, tbBusiness.getPickCustomerId(), tbBusiness.getPickCustomerName(), tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.STEVEDORE_FEE);
-                    }
-                }
-            }
 
-        }
-        return msg.get();
-    }
-
-    private void pay() {
-
-    }
 
     /**
      * 未支付的车

+ 26 - 23
sp-server/src/main/java/com/pj/project/tb_business_item/TbBusinessItemService.java

@@ -332,33 +332,36 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
      * @return
      */
     public void buildExpenses(List<TbBusinessItem> businessItems, List<IOrderItem> orderItems) {
-        businessItems = businessItems
-                .stream().filter(item -> item.getPayStatus() == 0).collect(Collectors.toList());
+        log.info("business-------:{}",businessItems.get(0).getItemName());
         for (TbBusinessItem item : businessItems) {
-            IOrderItem orderItem = new IOrderItem();
-            String itemAlias = item.getItemAlias();
-            Date startTime = item.getColdStartTime();
-            Date endTime = item.getColdEndTime();
-            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){
-                    continue;
+            if (item.getPayStatus()==0){
+                IOrderItem orderItem = new IOrderItem();
+                String itemAlias = item.getItemAlias();
+                Date startTime = item.getColdStartTime();
+                Date endTime = item.getColdEndTime();
+                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){
+                        continue;
+                    }
+                    //空柜堆存、重箱堆存
+                    buildDaysFceItem(item, orderItem, startTime, endTime);
+                }else if (StrUtil.equals(itemAlias,SystemObject.config.getBigHeadCar())
+                        ||StrUtil.equals(itemAlias,SystemObject.config.getCabinetCar())){
+                    //大车头、柜车、栏车
+                    buildDaysFceItem(item, orderItem, startTime, endTime);
                 }
-                //空柜堆存、重箱堆存
-                buildDaysFceItem(item, orderItem, startTime, endTime);
-            }else if (StrUtil.equals(itemAlias,SystemObject.config.getBigHeadCar())
-                    ||StrUtil.equals(itemAlias,SystemObject.config.getCabinetCar())){
-                //大车头、柜车、栏车
-                buildDaysFceItem(item, orderItem, startTime, endTime);
+                orderItem.setUniqExpenseId(item.getItemCode())
+                        .setExpenseNum(Integer.parseInt(item.getNum()));
+                boolean flag= orderItems.add(orderItem);
+                log.info("flag-----------:{}",flag);
             }
-            orderItem.setUniqExpenseId(item.getItemCode())
-                    .setExpenseNum(Integer.parseInt(item.getNum()));
-            orderItems.add(orderItem);
         }
+       log.info("size------------------------:{}",orderItems.size());
     }
 
     public void buildDaysFceItem(TbBusinessItem item, IOrderItem orderItem, Date startTime, Date endTime) {

+ 12 - 9
sp-server/src/main/java/com/pj/project/tb_fee_details/TbFeeDetailsService.java

@@ -210,7 +210,7 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
                     TbFeeDetails out24Details = new TbFeeDetails();
                     BigDecimal unitPrice = bo1.getExtraPrice();
                     int num = out24Price.divide(unitPrice, BigDecimal.ROUND_UP, 0).intValue();
-                    out24Details.setNum(num).setItemTypeName(PartFeeEnum.OUT_24_HOURS.getDesc())
+                    out24Details.setNum(num).setItemTypeName(PartFeeEnum.OUT_24_HOURS.getDesc()).setItemName(bo1.getCarDesc())
                             .setUnitPrice(unitPrice).setItemPrice(out24Price).setModule(payType.getDesc()).setBusinessId(bo1.getBusinessId());
                     setFee(taxRate, out24Details, car, transactionId, outTradeNo, now);
                     type = StrUtil.isEmpty(out24Details.getId()) ? SyncTypeEnum.INSERT.getCode() : SyncTypeEnum.UPDATE.getCode();
@@ -278,7 +278,7 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
             if (StrUtil.isEmpty(carNo)) {
                 carNo = business.getChinaCarNo();
             }
-            int num = item.getTotal().divide(item.getItemPrice(),1,BigDecimal.ROUND_UP).intValue();
+            int num = item.getTotal().divide(item.getItemPrice(), 1, BigDecimal.ROUND_UP).intValue();
             TbGoods businessCfg = tbGoodsService.getById(business.getGoodsId());
             if ((GoodsEnum.LeaveEnum.APART_BUSINESS.getCode().equals(businessCfg.getChinaCarLeave()))
                     && GoodsEnum.LeaveEnum.PART_MONEY.getCode().equals(businessCfg.getVietnamCarLeave())) {
@@ -326,10 +326,13 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
      * @param business
      * @return
      */
-    public TbFeeDetails savePrePayDetails(IOrderPriceRes res, TbBusinessItem item, TbBusinessCar tbBusinessCar, TbBusiness business, FeeTypeEnum feeTypeEnum) {
+    public TbFeeDetails savePrePayDetails(IOrderPriceRes res, TbBusinessItem item,
+                                          TbBusinessCar tbBusinessCar, TbBusiness business, String customerName, String pickCustomerName, FeeTypeEnum feeTypeEnum) {
         Integer feeType = feeTypeEnum.getCode();
         Double taxRate = item.getTaxRate();
         BigDecimal totalPrice = res.getTotalOrderPrice();
+        BigDecimal itemPrice = item.getItemPrice();
+        int num = totalPrice.divide(itemPrice, 0, BigDecimal.ROUND_UP).intValue();
         Date now = new Date();
         //添加此item的收费明细
         TbFeeDetails businessFeeDetail = new TbFeeDetails();
@@ -343,26 +346,26 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
         businessFeeDetail.setBusinessId(item.getBusinessId()).setBusinessNo(business.getNo())
                 .setBusinessItemNo(item.getNo()).setBusinessCarId(tbBusinessCar.getId()).setBusinessCarNo(tbBusinessCar.getCarNo())
                 .setCarNo(tbBusinessCar.getCarNo()).setCalculateId(res.getCalculateId())
-                .setItemPrice(totalPrice).setUnitPrice(item.getItemPrice()).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
+                .setItemPrice(totalPrice).setUnitPrice(itemPrice).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
                 .setFeeType(feeType)
                 .setItemTypeId(item.getItemTypeId()).setItemTypeName(item.getItemTypeName())
                 .setItemId(item.getItemId()).setItemName(item.getItemName())
                 .setPayDay(DateUtil.today()).setPayType(PayEnum.PayType.PER_PAY.getCode()).setCreateTime(now).setUpdateTime(now)
                 .setBusinessItemId(item.getId() + "").setWeight(tbBusinessCar.getNetWeight())
-                .setPickCustomerName(item.getPickCustomerName())
-                .setCustomerName(business.getCustomerName())
+                .setPickCustomerName(pickCustomerName)//作业公司
+                .setCustomerName(customerName) //客户名称
                 .setIsSettle(1).setPayMode(1).setPayTime(DateUtil.now())
-                .setNum(Integer.valueOf(item.getNum()))
+                .setNum(num)
                 .setModule(PayEnum.PayType.PER_PAY.getDesc());
         this.save(businessFeeDetail);
         taskService.addTask(new FeeDetailSyncTask(RandomUtil.randomNumbers(10), 1000, businessFeeDetail.getId(), SyncTypeEnum.INSERT.getCode(), PayEnum.PayType.PER_PAY));
         return businessFeeDetail;
     }
 
-    public List<TbFeeDetails> savePrePayDetails(IOrderPriceRes res, List<TbBusinessItem> itemList, TbBusinessCar tbBusinessCar, TbBusiness business, FeeTypeEnum feeTypeEnum) {
+    public List<TbFeeDetails> savePrePayDetails(IOrderPriceRes res, List<TbBusinessItem> itemList, TbBusinessCar tbBusinessCar, TbBusiness business, String customerName, String pickCustomerName, FeeTypeEnum feeTypeEnum) {
         List<TbFeeDetails> feeDetailsList = new ArrayList<>();
         for (TbBusinessItem item : itemList) {
-            TbFeeDetails feeDetails = savePrePayDetails(res, item, tbBusinessCar, business, feeTypeEnum);
+            TbFeeDetails feeDetails = savePrePayDetails(res, item, tbBusinessCar, business, customerName, pickCustomerName, feeTypeEnum);
             feeDetailsList.add(feeDetails);
         }
         return feeDetailsList;

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

@@ -44,6 +44,18 @@ public class TbInvoiceOrder implements Serializable {
 	 * 客户id 
 	 */
 	public String customerId;
+	/**
+	 * 客户名称
+	 */
+	public String customerName;
+	/**
+	 * 主体ID
+	 */
+	public String entityId;
+	/**
+	 * 主体名称
+	 */
+	public String entityName;
 
 	/**
 	 * 业务订单id 

+ 4 - 0
sp-server/src/main/java/com/pj/project/tb_invoice_order/TbInvoiceOrderMapper.xml

@@ -78,6 +78,10 @@
         <where>
             <if test=' this.has("id") '>and id = #{id}</if>
             <if test=' this.has("customerId") '>and customer_id = #{customerId}</if>
+            <if test=' this.has("customerName") '>and customer_name like concat('%',#{customerName},'%')</if>
+            <if test=' this.has("entityName") '>and entity_name like concat('%',#{entityName},'%')</if>
+            <if test='payType!=null and payType==1'>and transaction_id is not null</if>
+            <if test='payType!=null and payType==2'>and transaction_id is null</if>
             <if test=' this.has("businessId") '>and business_id = #{businessId}</if>
             <if test=' this.has("businessName") '>and business_name = #{businessName}</if>
             <if test=' this.has("businessNo") '>and business_no = #{businessNo}</if>

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

@@ -23,6 +23,9 @@ import com.pj.project.tb_business.TbBusinessService;
 import com.pj.project.tb_business_car.TbBusinessCar;
 import com.pj.project.tb_business_car.TbBusinessCarService;
 import com.pj.project.tb_costomer.TbCostomerService;
+import com.pj.project.tb_deduction_record.TbDeductionRecord;
+import com.pj.project.tb_entity.TbEntity;
+import com.pj.project.tb_entity.TbEntityService;
 import com.pj.project.tb_fee_details.TbFeeDetails;
 import com.pj.project.tb_fee_details.TbFeeDetailsService;
 import com.pj.project.tb_goods.TbGoods;
@@ -63,14 +66,15 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
     TbGoodsService tbGoodsService;
     @Resource
     TbBusinessCarService tbBusinessCarService;
-    @Resource
-    TbCostomerService tbCostomerService;
+
     @Resource
     TbFeeDetailsService tbFeeDetailsService;
     @Resource
     MyConfig myConfig;
     @Resource
     OcrConfig ocrConfig;
+    @Resource
+    private TbEntityService tbEntityService;
 
     /**
      * 增 --PC后台上传截图的情况
@@ -108,14 +112,14 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
             for (TbBusiness tbBusiness : businessList) {
                 businessNoList.add(tbBusiness.getNo());
                 List<String> carNoList = new ArrayList<>();
-                if(StrUtil.isNotEmpty(tbBusiness.getCardNo())){
+                if (StrUtil.isNotEmpty(tbBusiness.getCardNo())) {
                     carNoList.addAll(StrUtil.split(tbBusiness.getCardNo(), "、"));
                 }
-                if(StrUtil.isNotEmpty(tbBusiness.getChinaCarNo())){
+                if (StrUtil.isNotEmpty(tbBusiness.getChinaCarNo())) {
                     carNoList.addAll(StrUtil.split(tbBusiness.getChinaCarNo(), "、"));
                 }
                 for (String no : carNoList) {
-                    if(!carNos.contains(no)){
+                    if (!carNos.contains(no)) {
                         carNos.add(no);
                     }
                 }
@@ -125,12 +129,12 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
             }
         }
         List<PriceBO> cars = JSONUtil.toList(attach.getC(), PriceBO.class);
-        if(cars.size()>0){
+        if (cars.size() > 0) {
             businessNameList.add("停车费");
             for (PriceBO bo1 : cars) {
                 TbBusinessCar car = tbBusinessCarService.getById(bo1.getId());
                 businessNoList.add(car.getNo());
-                if(!carNos.contains(car.getCarNo())){
+                if (!carNos.contains(car.getCarNo())) {
                     carNos.add(car.getCarNo());
                 }
             }
@@ -144,20 +148,22 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
                 .setStatus(0).setCreateTime(new Date());
         tbInvoiceOrderMapper.add(t);
         return "200";
-	}
+    }
 
-	/**增 --微信回调自动生成整车业务开票订单的情况*/
-	public void addT(String transactionId){
+    /**
+     * 增 --微信回调自动生成整车业务开票订单的情况
+     */
+    public void addT(String transactionId) {
         TbInvoiceOrder t = new TbInvoiceOrder();
         TbInvoiceOrder InOrder = findByTransactionId(transactionId);
-        if(InOrder != null){
+        if (InOrder != null) {
             throw new BusinessException("该账单已生成开票订单");
         }
         List<String> businessNameList = new ArrayList<>();
         List<String> businessNoList = new ArrayList<>();
         List<String> carNos = new ArrayList<>();
         TbOrder tbOrder = tbOrderService.findByTransactionId(transactionId);
-        if(tbOrder == null){
+        if (tbOrder == null) {
             throw new BusinessException("交易单号识别有误,或不存在该交易单号的业务订单");
         }
         BigDecimal billMoney = new BigDecimal(tbOrder.getPrice());
@@ -172,14 +178,14 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
             for (TbBusiness tbBusiness : businessList) {
                 businessNoList.add(tbBusiness.getNo());
                 List<String> carNoList = new ArrayList<>();
-                if(StrUtil.isNotEmpty(tbBusiness.getCardNo())){
+                if (StrUtil.isNotEmpty(tbBusiness.getCardNo())) {
                     carNoList.addAll(StrUtil.split(tbBusiness.getCardNo(), "、"));
                 }
-                if(StrUtil.isNotEmpty(tbBusiness.getChinaCarNo())){
+                if (StrUtil.isNotEmpty(tbBusiness.getChinaCarNo())) {
                     carNoList.addAll(StrUtil.split(tbBusiness.getChinaCarNo(), "、"));
                 }
                 for (String no : carNoList) {
-                    if(!carNos.contains(no)){
+                    if (!carNos.contains(no)) {
                         carNos.add(no);
                     }
                 }
@@ -187,7 +193,7 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
                 TbGoods good = tbGoodsService.getById(tbBusiness.getGoodsId());
                 businessNameList.add(good.getName());
                 //微信回调的情况下,获取整车业务的客户id
-                if(!includZheng && StrUtil.contains(good.getName(), "整车")){
+                if (!includZheng && StrUtil.contains(good.getName(), "整车")) {
                     includZheng = true;
                     t.setCustomerId(tbBusiness.getCustomerId());
                 }
@@ -257,17 +263,18 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
         ew.eq("info_id", infoId);
         return list(ew);
     }
+
     public List<TbInvoiceOrder> findByInfoId2(String infoId) {
         QueryWrapper<TbInvoiceOrder> ew = new QueryWrapper<>();
         ew.eq("info_id", infoId).orderByDesc("create_time");
         return list(ew);
     }
 
-    private String orcImage(String billImageUrl){
+    private String orcImage(String billImageUrl) {
         String separator = File.separator;
         int startIndex = StrUtil.lastIndexOf(billImageUrl, "/", billImageUrl.length(), false);
         int endIndex = StrUtil.lastIndexOf(billImageUrl, ".", billImageUrl.length(), false);
-        String picName =  StrUtil.sub(billImageUrl, startIndex+1, endIndex);
+        String picName = StrUtil.sub(billImageUrl, startIndex + 1, endIndex);
         String rootPath = UploadUtil.uploadConfig.rootFolder + separator + UploadUtil.uploadConfig.httpPrefix;
         String prefix = myConfig.getDomain() + UploadUtil.uploadConfig.httpPrefix;
         String path = billImageUrl.replaceAll(prefix, rootPath);
@@ -282,31 +289,18 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
 
     private static String getTransId(String content) {
         int index = StrUtil.indexOf(content, "420000", 0, false);
-        String sub = StrUtil.sub(content, index, index+28);
-        sub=sub.trim();
+        String sub = StrUtil.sub(content, index, index + 28);
+        sub = sub.trim();
         String transId = "";
-        for (int i=0; i<sub.length();i++){
-            if(sub.charAt(i)>=48 && sub.charAt(i)<=57){
+        for (int i = 0; i < sub.length(); i++) {
+            if (sub.charAt(i) >= 48 && sub.charAt(i) <= 57) {
                 transId += sub.charAt(i);
             }
         }
         log.info("transId:" + transId);
         return transId;
     }
-    private static BigDecimal getMoney(String content) {
 
-        int index = StrUtil.indexOf(content, ".", 0, false);
-        String sub = StrUtil.sub(content, index -5, index+3);
-        sub=sub.trim();
-        String money = "";
-        for (int i=0; i<sub.length();i++){
-            if(sub.charAt(i)>=48 && sub.charAt(i)<=57 || sub.charAt(i) == '.'){
-                money += sub.charAt(i);
-            }
-        }
-        log.info("账单金额 :", money);
-        return new BigDecimal(money);
-    }
 
     public List<TbFeeDetails> getDetailsByTransId(String transactionId) {
         List<TbFeeDetails> detailsList = tbFeeDetailsService.findByTransactionId(transactionId);
@@ -314,12 +308,15 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
     }
 
     public List<TbFeeDetails> getDetailsByBusinessId(String preOrderNum) {
-        if(NbUtil.isNullStr(preOrderNum))return null;
+        if (NbUtil.isNullStr(preOrderNum)) return null;
         List<TbFeeDetails> detailsList = tbFeeDetailsService.list(new LambdaQueryWrapper<TbFeeDetails>()
-                .eq(TbFeeDetails::getPreOrderNum,preOrderNum));
+                .eq(TbFeeDetails::getPreOrderNum, preOrderNum));
         return detailsList;
     }
-    /**根据InvoiceDetail的id*/
+
+    /**
+     * 根据InvoiceDetail的id
+     */
     public List<TbInvoiceOrder> findByDetailId(String detailId) {
         QueryWrapper<TbInvoiceOrder> ew = new QueryWrapper<>();
         ew.eq("detail_id", detailId);
@@ -328,7 +325,44 @@ public class TbInvoiceOrderService extends ServiceImpl<TbInvoiceOrderMapper, TbI
 
     public TbInvoiceOrder findByRecord(String recordId) {
         QueryWrapper<TbInvoiceOrder> ew = new QueryWrapper<>();
-        ew.lambda().eq(TbInvoiceOrder::getDeductionRecordId,recordId);
+        ew.lambda().eq(TbInvoiceOrder::getDeductionRecordId, recordId);
         return getOne(ew);
     }
+
+
+    /**
+     * 添加开票订单
+     * @param businessName
+     * @param businessNo
+     * @param carNo
+     * @param businessId
+     * @param customerId
+     * @param customerName
+     * @param entityName
+     * @param billMoney
+     * @param details
+     * @param record
+     */
+    public void addInvoiceOrder(String businessName,String businessNo,String carNo,
+                                String businessId,String customerId, String customerName,
+                                String entityName, BigDecimal billMoney, TbFeeDetails details,
+                                TbDeductionRecord record) {
+        TbInvoiceOrder t = new TbInvoiceOrder();
+        t.setBusinessName(businessName)
+                .setBusinessNo(businessNo)
+                .setCarNo(carNo)
+                .setBusinessId(businessId)
+                .setCustomerId(customerId)
+                .setCustomerName(customerName)
+                .setEntityName(entityName)
+                .setBillMoney(billMoney).setDetailId(details.getId())
+                .setPreOrderNum(details.getPreOrderNum())
+                .setDeductionRecordId(record.getId())
+                .setStatus(0).setCreateTime(new Date());
+        TbEntity tbEntity = tbEntityService.findByName(entityName);
+        if (tbEntity != null) {
+            t.setEntityId(tbEntity.getId());
+        }
+        save(t);
+    }
 }