qzyReal 3 年 前
コミット
5e744f62fc

+ 155 - 46
app/pages/business-entering/business-edit.vue

@@ -31,7 +31,42 @@
 				</u-col>
 			</u-row>
 		</view>
-		<view class="box" v-show="!hs.visible">
+		<view class="box" v-show="china.visible">
+			<view class="top">
+				<text class="title">中国车录入</text>
+			</view>
+			<view style="display: flex;margin-top: 40rpx;">
+				<u-button type="primary" @click="china.visible=false" text="返回" style="width: 20px;" size="mini" />
+				<u-button type="primary" @click="showChinaModal" text="添加" icon="plus" style="width: 20px;"
+					size="mini" />
+			</view>
+			<u-row style="margin-top: 70rpx;">
+				<u-col span="3" style="text-align: center;">车牌号</u-col>
+				<u-col span="3" style="text-align: center;">联系人</u-col>
+				<u-col span="3" style="text-align: center;">联系号码</u-col>
+				<u-col span="3" style="text-align: center;">操作</u-col>
+			</u-row>
+			<u-row v-for="(item,index) in china.list" style="margin-top: 40rpx;">
+				<u-col span="3" style="text-align: center;">{{item.carNo}}</u-col>
+				<u-col span="3" style="text-align: center;">{{item.driverName}}</u-col>
+				<u-col span="3" style="text-align: center;">{{item.driverPhone}}</u-col>
+				<u-col span="3" style="text-align: center;">
+					<u-row>
+						<u-col span="6">
+							<u-button type="primary" text="编辑" style="width: 20px;" @click="editChinaCar(item,index)"
+								size="mini">
+							</u-button>
+						</u-col>
+						<u-col span="6">
+							<u-button type="error" style="width: 20px;" text="删除" @click="deleteChinaCar(item,index)"
+								size="mini">
+							</u-button>
+						</u-col>
+					</u-row>
+				</u-col>
+			</u-row>
+		</view>
+		<view class="box" v-show="!hs.visible&&!china.visible">
 			<view class="top">
 				<text class="title">业务录入</text>
 			</view>
@@ -59,7 +94,7 @@
 			<view class="item">
 				<view class="l"><text style="color: red;">*</text>载重:</view>
 				<view class="r">
-					<u-input type="number" placeholder="输入载重" v-model="form.netWeight">
+					<u-input type="number" placeholder="输入载重"  v-model="form.netWeight">
 						<text slot="suffix">吨</text>
 					</u-input>
 				</view>
@@ -67,44 +102,23 @@
 			<view class="item">
 				<view class="l"><text style="color: red;">*</text>境外车牌:</view>
 				<view class="r">
-					<u-input placeholder="输入车牌号" v-model="form.cardNo" />
+					<u-input placeholder="输入车牌号"  v-model="form.cardNo" />
 				</view>
 			</view>
 			<view class="item">
 				<view class="l"><text style="color: red;">*</text>境外车规格:</view>
 				<view class="r">
-					<u-input type="number" placeholder="输入车辆规格" @blur="car.carInput=false" @input="carSizeInput"
-						v-model="form.cardSize">
+					<u-input type="number" placeholder="输入车辆规格"  v-model="form.cardSize">
 						<text slot="suffix">米</text>
 					</u-input>
 				</view>
 			</view>
-
-			<view class="item">
-				<view class="l"><text style="color: red;">*</text>预计入场:</view>
-				<view class="r">
-					<view class="r">
-						<uni-datetime-picker placeholder="请选择" @change="expectDayChange" :clear-icon="false"
-							:start="exprctStart" type="datetime" v-model="form.expectInDay" @close="closeFn" />
-					</view>
-				</view>
-			</view>
-			<view class="item">
-				<view class="l"><text style="color: red;">*</text>中国车牌号:</view>
-				<view class="r">
-					<u-input placeholder="中国车牌号" v-model="form.chinaCarNo" />
-				</view>
-			</view>
 			<view class="item">
-				<view class="l"><text style="color: red;">*</text>中国司机:</view>
+				<view class="l">中国车:</view>
 				<view class="r">
-					<u-input placeholder="司机姓名" v-model="form.driverName" />
-				</view>
-			</view>
-			<view class="item">
-				<view class="l"><text style="color: red;">*</text>联系号码:</view>
-				<view class="r">
-					<u-input placeholder="司机联系号码" type="number" v-model="form.driverPhone" />
+					<u-input placeholder="中国车" v-model="china.list.map(obj=>obj.carNo).join('、')" readonly>
+						<text slot="suffix" style="font-size: 50rpx;" @click="addCar">+</text>
+					</u-input>
 				</view>
 			</view>
 
@@ -118,7 +132,7 @@
 					<view @click="selectItemFn(item)" style="width: 150px;">
 						<u-input placeholder="请选择" v-model="item.itemName" readonly clearable>
 							<u-icon name="close" v-if="item.itemName" slot="suffix" color="#E5E5E5;" size="5"
-								@click="item.itemName=''"></u-icon>
+								@click="cleanItemSelect(item)"></u-icon>
 						</u-input>
 					</view>
 					<view style="width: 20px;margin-left: 10rpx;">
@@ -137,7 +151,7 @@
 				合计:{{totalPrice}}元
 			</view>
 		</view>
-		<u-button type="primary" text="确定" @click="saveFn" v-show="!hs.visible"></u-button>
+		<u-button type="primary" text="确定" @click="saveFn" v-show="!hs.visible&&!china.visible"></u-button>
 		<!-- ---------------------------------------------------------- -->
 		<view class="bottom-safety"></view>
 		<u-popup :show="car.carInput" :overlay="false" @close="car.carInput=false" borderRadius="10">
@@ -176,6 +190,29 @@
 				</u--input>
 			</view>
 		</u-modal>
+		<u-modal :show="chinaAddModal.visible" title="中国车" @confirm="sureCarFn" @cancel="chinaAddModal.visible=false"
+			showCancelButton cancelText="关闭">
+			<view class="slot-content">
+				<u-row>
+					<u-col span="4">车牌号</u-col>
+					<u-col span="8">
+						<u--input placeholder="车牌号" v-model="chinaAddModal.form.carNo"></u--input>
+					</u-col>
+				</u-row>
+				<u-row>
+					<u-col span="4">联系人</u-col>
+					<u-col span="8">
+						<u--input placeholder="联系人" v-model="chinaAddModal.form.driverName"></u--input>
+					</u-col>
+				</u-row>
+				<u-row>
+					<u-col span="4">联系号码</u-col>
+					<u-col span="8">
+						<u--input placeholder="联系号码" v-model="chinaAddModal.form.driverPhone"></u--input>
+					</u-col>
+				</u-row>
+			</view>
+		</u-modal>
 	</view>
 </template>
 
@@ -242,7 +279,22 @@
 						name: '',
 						phone: ''
 					}
-				}
+				},
+				china: {
+					visible: false,
+					index: -1,
+					list: []
+				},
+				chinaAddModal: {
+					visible: false,
+					form: {
+						carNo: '',
+						driverName: '',
+						driverPhone: ''
+					}
+				},
+				checkItem: '',
+				chinaCarPrefix:"浙粤京津冀晋蒙辽黑沪吉苏皖赣鲁豫鄂湘桂琼渝川贵云藏陕甘青宁"
 			}
 		},
 		onShow() {
@@ -279,12 +331,61 @@
 
 		},
 		methods: {
+			addCar() {
+				this.china.visible = true;
+			},
+			showChinaModal() {
+				Object.assign(this.chinaAddModal, {
+					visible: true,
+					index: -1,
+					form: {
+						carNo: '',
+						driverName: '',
+						driverPhone: ''
+					}
+				})
+			},
+			sureCarFn() {
+				let form = this.chinaAddModal.form;
+				let carNo = form.carNo;
+				let phone = form.driverPhone;
+				if (carNo && !this.$common.isCarNo(carNo)) {
+					this.$common.toast('请输入正确的车牌号')
+					return;
+				}
+				if (phone && !this.$common.isPhone(phone)) {
+					this.$common.toast('请输入正确的手机号')
+					return;
+				}
+				let list = this.china.list;
+				let index = this.chinaAddModal.index;
+				if (index > -1) {
+					list.splice(index, 1)
+				}
+				list.push(form)
+				this.chinaAddModal.visible = false;
+			},
+			deleteChinaCar(item, index) {
+				this.china.list.splice(index, 1);
+			},
+			editChinaCar(item, index) {
+				Object.assign(this.chinaAddModal, {
+					visible: true,
+					index: index,
+					form: item
+				})
+			},
 			getBusinessById() {
 				this.$api.getBusinessById({
 					id: this.form.id
 				}).then(resp => {
 					let data = resp.data;
 					this.form = data;
+					let list=this.chinaCarPrefix;
+					this.china.list=data.cars.filter(obj=>{
+						return list.indexOf(obj.carNo.substr(0,1))!==-1
+					});
+					console.log(this.china.list)
 					let goodsName = data.goodsName;
 					this.customer.index = this.customer.customerList.map(obj => obj.name).indexOf(data
 						.customerName);
@@ -300,6 +401,10 @@
 							let item = items[j];
 							if (item.itemTypeId == type.id) {
 								type.itemName = item.itemName;
+								let typeName=type.name;
+								if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
+									this.checkItem = typeName;
+								}
 								type.num = item.num
 								break;
 							}
@@ -307,7 +412,7 @@
 					}
 					setTimeout(() => {
 						this.car.carInput = false;
-					}, 50)
+					}, 30)
 				})
 			},
 			getBusinessPeople() {
@@ -458,10 +563,27 @@
 			},
 
 			selectItemFn(item) {
+				let typeName = item.name;
+				let checkItem = this.checkItem;
+				if ((typeName == '干杂货人工装卸' && checkItem == '特殊车辆') ||
+					(typeName == '特殊车辆' && checkItem == '干杂货人工装卸')) {
+					this.$common.toast('不能同时选择干杂货人工装卸和特殊车辆');
+					return false;
+				}
+				if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
+					this.checkItem = typeName;
+				}
 				this.item = item;
 				this.show = true;
 
 			},
+			cleanItemSelect(item) {
+				item.itemName = '';
+				setTimeout(() => {
+					this.show = false;
+					this.checkItem = ''
+				}, 80)
+			},
 			itemSelectFn(data) {
 				this.show = false;
 				this.item.itemName = data;
@@ -475,19 +597,6 @@
 					this.$common.toast('车辆规格请录入数字')
 					return false;
 				}
-
-				if (!this.form.chinaCarNo) {
-					this.$common.toast('请录入中国车牌')
-					return false;
-				}
-				if (!this.form.driverName) {
-					this.$common.toast('请录入中国司机')
-					return false;
-				}
-				if (!this.$common.isPhone(this.form.driverPhone)) {
-					this.$common.toast('司机联系号码不正确')
-					return false;
-				}
 				if (!this.form.netWeight || !this.$common.isNum(this.form.netWeight)) {
 					this.$common.toast('载重必须输入数字')
 					return false;

+ 45 - 33
app/pages/business-entering/business-entering.vue

@@ -53,11 +53,13 @@
 				<u-col span="3" style="text-align: center;">
 					<u-row>
 						<u-col span="6">
-							<u-button type="primary" text="编辑" style="width: 20px;" @click="editChinaCar(item,index)" size="mini">
+							<u-button type="primary" text="编辑" style="width: 20px;" @click="editChinaCar(item,index)"
+								size="mini">
 							</u-button>
 						</u-col>
 						<u-col span="6">
-							<u-button type="error" style="width: 20px;" text="删除" @click="deleteChinaCar(item,index)" size="mini">
+							<u-button type="error" style="width: 20px;" text="删除" @click="deleteChinaCar(item,index)"
+								size="mini">
 							</u-button>
 						</u-col>
 					</u-row>
@@ -106,7 +108,7 @@
 			<view class="item">
 				<view class="l"><text style="color: red;">*</text>境外车规格:</view>
 				<view class="r">
-					<u-input type="number" placeholder="输入车辆规格" @blur="car.carInput=false" @input="carSizeInput"
+					<u-input type="number" placeholder="输入车辆规格"  @input="handler()"
 						v-model="form.cardSize">
 						<text slot="suffix">米</text>
 					</u-input>
@@ -115,7 +117,7 @@
 			<view class="item">
 				<view class="l">中国车:</view>
 				<view class="r">
-					<u-input placeholder="中国车" v-model="chinaCarNo" readonly>
+					<u-input placeholder="中国车" v-model="china.list.map(obj=>obj.carNo).join('、')" readonly>
 						<text slot="suffix" style="font-size: 50rpx;" @click="addCar">+</text>
 					</u-input>
 				</view>
@@ -130,7 +132,7 @@
 					<view @click="selectItemFn(item)">
 						<u-input placeholder="请选择" v-model="item.itemName" readonly clearable style="width: 120px;">
 							<u-icon name="close" v-if="item.itemName" slot="suffix" color="#E5E5E5;" size="5"
-								@click="item.itemName=''"></u-icon>
+								@click="cleanItemSelect(item)"></u-icon>
 						</u-input>
 					</view>
 					<u-input placeholder="数量" :disabled="item.inc==0" border="surround" v-model="item.num" type="number"
@@ -278,7 +280,7 @@
 				},
 				china: {
 					visible: false,
-					index:-1,
+					index: -1,
 					list: []
 				},
 				chinaAddModal: {
@@ -288,7 +290,8 @@
 						driverName: '',
 						driverPhone: ''
 					}
-				}
+				},
+				checkItem: ''
 			}
 		},
 		onShow() {
@@ -311,9 +314,6 @@
 				}
 				return price;
 			},
-			chinaCarNo(){
-				return this.china.list.map(obj=>obj.carNo).join("、");
-			}
 		},
 		created() {
 			if (this.customerId == '1') {
@@ -329,7 +329,7 @@
 			showChinaModal() {
 				Object.assign(this.chinaAddModal, {
 					visible: true,
-					index:-1,
+					index: -1,
 					form: {
 						carNo: '',
 						driverName: '',
@@ -350,21 +350,20 @@
 					return;
 				}
 				let list = this.china.list;
-				let index=this.chinaAddModal.index;
-				console.log(this.chinaAddModal.index)
-				if(index>-1){
+				let index = this.chinaAddModal.index;
+				if (index > -1) {
 					list.splice(index, 1)
 				}
 				list.push(form)
 				this.chinaAddModal.visible = false;
 			},
-			deleteChinaCar(item,index){
-				this.china.list.splice(index,1);
+			deleteChinaCar(item, index) {
+				this.china.list.splice(index, 1);
 			},
-			editChinaCar(item,index){
+			editChinaCar(item, index) {
 				Object.assign(this.chinaAddModal, {
 					visible: true,
-					index:index,
+					index: index,
 					form: item
 				})
 			},
@@ -509,9 +508,25 @@
 			},
 
 			selectItemFn(item) {
+				let typeName = item.name;
+				let checkItem = this.checkItem;
+				if ((typeName == '干杂货人工装卸' && checkItem == '特殊车辆') ||
+					(typeName == '特殊车辆' && checkItem == '干杂货人工装卸')) {
+					this.$common.toast('不能同时选择干杂货人工装卸和特殊车辆');
+					return false;
+				}
+				if (typeName == '干杂货人工装卸' || typeName == '特殊车辆') {
+					this.checkItem = typeName;
+				}
 				this.item = item;
 				this.show = true;
-
+			},
+			cleanItemSelect(item) {
+				item.itemName = '';
+				setTimeout(() => {
+					this.show = false;
+					this.checkItem = ''
+				}, 80)
 			},
 			itemSelectFn(data) {
 				this.show = false;
@@ -526,6 +541,7 @@
 				this.form.goodsIndex = goodsIndex;
 				this.form.countryIndex = countryIndex;
 				this.form.peopleJson = JSON.stringify(this.hs.list);
+				this.form.carJson = JSON.stringify(this.china.list);
 				let customerId = this.customerId;
 				if (customerId == '1') {
 					let customerIndex = this.customer.index;
@@ -571,6 +587,7 @@
 				this.goods.index = data.goodsIndex ? data.goodsIndex : 0;
 				this.customer.index = data.customerIndex ? data.customerIndex : 0;
 				this.hs.list = data.peopleJson ? JSON.parse(data.peopleJson) : [];
+				this.china.list = data.carJson ? JSON.parse(data.carJson) : [];
 				if (data.inputItemJson) {
 					let inputItemList = JSON.parse(data.inputItemJson);
 					let filterList = this.filterItemList;
@@ -600,19 +617,6 @@
 					this.$common.toast('车辆规格请录入数字')
 					return false;
 				}
-
-				if (!this.chinaCarNo) {
-					this.$common.toast('请录入中国车牌')
-					return false;
-				}
-				if (!this.form.driverName) {
-					this.$common.toast('请录入中国司机')
-					return false;
-				}
-				if (!this.$common.isPhone(this.form.driverPhone)) {
-					this.$common.toast('司机联系号码不正确')
-					return false;
-				}
 				if (!this.form.netWeight || !this.$common.isNum(this.form.netWeight)) {
 					this.$common.toast('载重必须输入数字')
 					return false;
@@ -623,17 +627,24 @@
 					return false;
 				}
 				let noNeedIds = this.noNeedIds;
+				let chechItem = this.checkItem;
 				let filterItemList = this.filterItemList.filter(obj => noNeedIds.indexOf(obj.id) == -1);
 				for (let j in this.needTypeId) {
 					let id = this.needTypeId[j];
 					for (let i in filterItemList) {
 						let type = filterItemList[i];
-						if (id == type.id && !type.itemName) {
+						let typeName = type.name;
+						if (id == type.id && !type.itemName && typeName !== '特殊车辆' && typeName !== '干杂货人工装卸') {
 							this.$common.toast('[' + type.name + ']必选')
 							return;
 						}
+
 					}
 				}
+				if (!chechItem && this.form.goodsName == '干杂货') {
+					this.$common.toast('请选择特殊车辆或干杂货人工装卸之一')
+					return;
+				}
 				let peopleList = this.hs.list;
 				if (typeList.filter(obj => obj.name.indexOf('人') !== -1 &&
 						obj.name.indexOf('核酸') !== -1).length > 0 &&
@@ -659,6 +670,7 @@
 				}
 				this.form.itemJson = JSON.stringify(list);
 				this.form.peopleJson = JSON.stringify(peopleList);
+				this.form.carJson = JSON.stringify(this.china.list);
 				this.form.items = null;
 				if (this.customerId == '1') {
 					this.form.customerId = this.customer.customerList[this.customer.index].id;

+ 1 - 4
app/pages/business-order/business-order.vue

@@ -53,7 +53,7 @@
 								&&perList.indexOf('tb-business-confirm')!=-1
 								&&customemrId!='1'" @click="sureZdFn(businessItem)">
 						支付账单</view>
-					<view class="btn b3"  @click="fkFn(businessItem)">
+					<view class="btn b3" v-if="customemrId!=='1'" @click="fkFn(businessItem)">
 						证明</view>
 						<view class="btn b3" @click="toDetail(businessItem)">详情</view>
 					<view class="btn b1" v-if="businessItem.confirmInput==0" @click="editFn(businessItem)">修改</view>
@@ -104,14 +104,11 @@
 		created() {
 			this.customemrId = uni.getStorageSync('customerId')
 			this.perList = uni.getStorageSync('perList')
-			console.log('create')
 		},
 		onShow() {
 			this.getBusinessList();
-			console.log('show')
 		},
 		mounted() {
-			console.log('mounted')
 		},
 		onBackPress() {
 			this.$common.to('/pages/index/index')

+ 15 - 13
app/pages/declare/add.vue

@@ -14,7 +14,7 @@
 			<view class="item">
 				<view class="l"><text style="color: red;">*</text>申报电话:</view>
 				<view class="r">
-					<u-input placeholder="申报电话" @input="handler()" v-model="form.declarePhone">
+					<u-input placeholder="申报电话" type="number" @input="handler()" v-model="form.declarePhone">
 					</u-input>
 				</view>
 			</view>
@@ -123,7 +123,7 @@
 			<view class="item">
 				<view class="l"><text style="color: red;">*</text>司机电话:</view>
 				<view class="r">
-					<u--textarea @input="handler()" v-model="form.driverPhone" placeholder="司机电话,多个请用逗号隔开">
+					<u--textarea  @input="handler()" v-model="form.driverPhone" placeholder="司机电话,多个请用逗号隔开">
 					</u--textarea>
 				</view>
 			</view>
@@ -131,7 +131,7 @@
 			<view class="item">
 				<view class="l" style="flex: 7;"><text style="color: red;">*</text>代理商电话:</view>
 				<view class="r">
-					<u-input placeholder="代理商电话" @input="handler()" v-model="form.agentPhone" />
+					<u-input type="number" placeholder="代理商电话" @input="handler()" v-model="form.agentPhone" />
 				</view>
 			</view>
 			<view class="item">
@@ -204,7 +204,7 @@
 					driverPhone: '',
 					agent: '',
 					chinaCarNo: '',
-					chinaCarNoSuff:'',
+					chinaCarNoSuff: '',
 					carNo: '',
 					customProof: '',
 					quarantineProof: '',
@@ -240,7 +240,7 @@
 					driverPhone: '',
 					agent: '',
 					chinaCarNo: '',
-					chinaCarNoSuff:'',
+					chinaCarNoSuff: '',
 					carNo: '',
 					customProof: '',
 					quarantineProof: '',
@@ -370,8 +370,8 @@
 					this.$common.toast('请填写运输车辆车头牌');
 					return;
 				}
-				let noArray=chinaCarNo.replace(",", ",").split(",");
-				for(let i in noArray){
+				let noArray = chinaCarNo.replace(",", ",").split(",");
+				for (let i in noArray) {
 					if (!this.$common.isCarNo(noArray[i])) {
 						this.$common.toast('运输车头牌不正确');
 						return;
@@ -382,8 +382,8 @@
 					this.$common.toast('请填写运输车辆车尾牌');
 					return;
 				}
-				let suffArray=chinaCarNoSuff.replace(",", ",").split(",");
-				for(let i in suffArray){
+				let suffArray = chinaCarNoSuff.replace(",", ",").split(",");
+				for (let i in suffArray) {
 					if (!this.$common.isCarNo(suffArray[i])) {
 						this.$common.toast('运输车尾牌不正确');
 						return;
@@ -398,9 +398,9 @@
 					this.$common.toast('请填写司机号码');
 					return;
 				}
-				let phoneArray=driverPhone.replace(",", ",").split(",");
-				for(let i in phoneArray){
-					let phone=phoneArray[i];
+				let phoneArray = driverPhone.replace(",", ",").split(",");
+				for (let i in phoneArray) {
+					let phone = phoneArray[i];
 					if (!this.$common.isPhone(phone)) {
 						this.$common.toast('司机联系号码不正确');
 						return;
@@ -437,7 +437,9 @@
 				}
 				this.$api.addDeclare(this.$common.removeNull(this.form)).then(resp => {
 					this.addStoreCount();
-					this.$common.to('/pages/declare/addDeclareSuccess')
+					if (resp.code == 200) {
+						this.$common.to('/pages/declare/addDeclareSuccess')
+					}
 				})
 			},
 		},

+ 5 - 10
app/pages/wx/pay.vue

@@ -24,7 +24,7 @@
 					<view v-for="(item,index) in cars" :key="index">
 						<label class="c-item">
 							<view class="l">
-								<u-checkbox :customStyle="{marginBottom: '8px'}" :name="item.id">
+								<u-checkbox :customStyle="{marginBottom: '8px'}" :name="item.id" :disabled="item.pay==1">
 								</u-checkbox>
 							</view>
 							<view class="c">{{item.carNo}}</view>
@@ -120,7 +120,6 @@
 		computed: {
 			total() {
 				let carIds = this.carsSelect;
-
 				let carMoney = this.cars.filter(obj => carIds.indexOf(obj.id) !== -1)
 					.map(obj => obj.price).reduce(function(pre, cur) {
 						return pre + cur;
@@ -130,7 +129,7 @@
 					.map(obj => obj.price).reduce(function(pre, cur) {
 						return pre + cur;
 					}, 0):0;
-				return carMoney + itemMoney;
+				return (carMoney + itemMoney).toFixed(2);
 			}
 		},
 		methods: {
@@ -232,7 +231,7 @@
 				}).then(resp => {
 					let data = resp.data;
 					this.cars = data.carList;
-					this.carsSelect = [carId]
+					this.carsSelect = this.cars.filter(obj=>obj.id==carId&&obj.pay==0).map(obj=>obj.id)
 					Object.assign(this.item, {
 						itemsPrice: data.itemsPrice,
 						businessId: data.businessId,
@@ -241,14 +240,10 @@
 					let selectCar = this.list.filter(obj => obj.id == carId).pop();
 					let carNo = selectCar.carNo;
 					if (!this.$common.isCarNo(carNo)) {
-						this.itemSelect = data.itemList.map(obj => obj.id)
-						this.businessSelect = [1]
+						this.itemSelect = data.itemList.map(obj => obj.id&&obj.pay==0)
+						this.businessSelect =this.itemSelect.length==0?[]:[1]
 					}
 					this.list = [];
-					if (data.total == 0) {
-						this.$common.toast('您无需缴费');
-						this.p.carNo = ''
-					}
 				})
 			},
 			searchFn() {

+ 8 - 6
sp-admin/sa-view/tb-business/tb-business-add.html

@@ -284,7 +284,7 @@
 						</el-table-column>
 						<el-table-column prop="declarePeople" label="申报人">
 						</el-table-column>
-						<el-table-column prop="declarePhone"  label="申报电话">
+						<el-table-column prop="declarePhone" label="申报电话">
 						</el-table-column>
 						<el-table-column prop="declareNo" width="180" label="申报单号">
 						</el-table-column>
@@ -713,7 +713,7 @@
 						}
 						sa.checkNull(m.goodsName, '请选择运输货物');
 						sa.checkNull(m.cardNo, '请输入 [车牌号]');
-						if (!m.cardSize||!sa.isNum(m.cardSize)) {
+						if (!m.cardSize || !sa.isNum(m.cardSize)) {
 							sa.error('车辆规格只能输入数字')
 							return;
 						}
@@ -732,12 +732,14 @@
 									sa.error('选择[' + this.m.goodsName + ']时,[' + typeName + ']必选')
 									return;
 								}
-								if (!chechItem && this.m.goodsName == '干杂货') {
-									sa.error('请选择特殊车辆或干杂货人工装卸之一')
-									return;
-								}
 							}
 						}
+						console.log(chechItem)
+						console.log(this.m)
+						if (!chechItem && this.m.goodsName == '干杂货') {
+							sa.error('请选择特殊车辆或干杂货人工装卸之一')
+							return;
+						}
 						let typeList = this.itemTypeList.filter(obj => obj.itemId);
 						let list = [];
 						if (typeList.length == 0) {

+ 1 - 1
sp-server/app.pid

@@ -1 +1 @@
-28900
+33632

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

@@ -85,7 +85,6 @@ public class ApiService {
     }
 
     public List<TbBusinessCar> searchPartCar(String carNo) {
-
         return tbBusinessCarService.searchPartCar(carNo);
     }
 
@@ -127,10 +126,10 @@ public class ApiService {
             carNo = carNo.toUpperCase();
             tbDeclare.setCarNo(carNo);
         }
-        SpAdmin admin=StpUserUtil.getAdmin();
-        if (admin!=null) {
-            tbDeclare.setCustomerId(admin.getCustomerId());
-        }
+//        SpAdmin admin=StpUserUtil.getAdmin();
+//        if (admin!=null) {
+//            tbDeclare.setCustomerId(admin.getCustomerId());
+//        }
         String productionCode = tbDeclare.getProductionCode();
         Date now = new Date();
         if (StrUtil.isNotEmpty(productionCode)) {
@@ -148,10 +147,6 @@ public class ApiService {
     }
 
     public void addDisinfect(TbDisinfect tbDisinfect) {
-        SpAdmin admin=StpUserUtil.getAdmin();
-        if (admin!=null) {
-            tbDisinfect.setCustomerId(admin.getCustomerId());
-        }
         String nowStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
         tbDisinfect.setCode(nowStr + RandomUtil.randomNumbers(6)).setApplyTime(DateUtil.now());
         tbDisinfectService.save(tbDisinfect);

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

@@ -1,5 +1,6 @@
 package com.pj.api.wx.api;
 
+import cn.hutool.core.util.XmlUtil;
 import cn.hutool.json.JSONUtil;
 import com.pj.api.wx.bo.Attach;
 import com.pj.api.wx.bo.NotifyBO;
@@ -32,7 +33,7 @@ public class WxController {
         result.put("return_code", "SUCCESS");
         result.put("return_msg", "OK");
         wxService.WxNotify(notifyBO);
-        writer.write(JSONUtil.toJsonStr(result));
+        writer.write(XmlUtil.mapToXmlStr(result));
         writer.flush();
         writer.close();
     }

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

@@ -1,5 +1,7 @@
 package com.pj.api.wx.service;
 
+import cn.hutool.cache.CacheUtil;
+import cn.hutool.cache.impl.TimedCache;
 import cn.hutool.core.net.URLDecoder;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.RandomUtil;
@@ -146,9 +148,14 @@ public class WxService {
             return ip;
         }
     }
-
+    TimedCache<String, Integer> NotifyCache = CacheUtil.newTimedCache(360000);
     @Async
     public void WxNotify(NotifyBO notifyBO) throws Exception {
+        String outTradeNo = notifyBO.getOutTradeNo();
+        if (NotifyCache.get(outTradeNo)!=null) {
+            return;
+        }
+        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));
@@ -167,21 +174,19 @@ public class WxService {
                 tbBusinessCarService.updateById(car);
                 TbBusiness business = tbBusinessService.getById(car.getBusinessId());
                 business.setPayMoney(business.getPayMoney().add(price));
-                business.setPayStatus(business.getPayMoney().add(price).equals(business.getTotalMoney()) ? 3 : 4);
+                business.setPayStatus(business.getPayMoney().equals(business.getTotalMoney()) ? 3 : 4);
                 tbBusinessService.updateById(business);
             }
             String businessId = attach.getB();
             if (StrUtil.isNotEmpty(businessId)) {
                 List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(businessId);
                 items.forEach(tbBusinessItem -> tbBusinessItem.setPayStatus(1).setPayTime(now));
-                double sum = items.stream().collect(Collectors.summarizingDouble(item -> item.getItemPrice().doubleValue())).getSum();
-                BigDecimal itemPrice=new BigDecimal(sum);
                 tbBusinessItemService.updateBatchById(items);
                 TbBusiness tbBusiness = tbBusinessService.getById(businessId);
-                tbBusiness.setPayStatus(tbBusiness.getPayMoney().add(itemPrice).equals(tbBusiness.getTotalMoney()) ? 3 : 4);
                 tbBusiness.setPayTime(now).setPayType(3).setConfirmInput(1).setConfirmInputTime(now)
-                        .setPayMoney(tbBusiness.getPayMoney().add(itemPrice))
+                        .setPayMoney(tbBusiness.getPayMoney().add(tbBusiness.getItemPrice()))
                         .setPayNo(transactionId);
+                tbBusiness.setPayStatus(tbBusiness.getPayMoney().equals(tbBusiness.getTotalMoney()) ? 3 : 4);
                 tbBusinessService.updateById(tbBusiness);
                 TbPayRecord payRecord = new TbPayRecord();
                 TbCostomer tbCostomer = tbCostomerService.getById(tbBusiness.getCustomerId());

+ 22 - 0
sp-server/src/main/java/com/pj/constants/ErrorMsgEnum.java

@@ -0,0 +1,22 @@
+package com.pj.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum ErrorMsgEnum {
+    /**
+     * 枚举
+     */
+    SYSTEM_ERROR(9999,"系统繁忙"),
+    IDCARD_EXIT(1000,"身份证已存在"),
+    PHONE_EXIT(1001,"手机号码被占用"),
+    INFO_EXIT(1002,"查询信息不存在"),
+    GOODS_EMPTY(1003,"请勾选商品"),
+
+    ;
+    private int code;
+    private String msg;
+
+}

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

@@ -6,6 +6,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
 import com.pj.project.tb_business_car.TbBusinessCar;
@@ -229,18 +230,21 @@ public class TbBusiness extends Model<TbBusiness> implements Serializable {
     @AllArgsConstructor
    public static enum PayStatus{
         NO_PAY(1,"未支付"),
-        HAS_PAY(2,"已支付");
+        HAS_PAY(2,"已支付"),
+        HAS_PAY_CONFIRM(3,"已支付已确认"),
+        HAS_PAY_PART(4,"已支付"),
+        ;
         private int code;
         private String desc;
     }
 
 
     public void setCardNo(String cardNo) {
-        this.cardNo = cardNo.toUpperCase().trim();
+        this.cardNo = StrUtil.isNotEmpty(cardNo)? cardNo.toUpperCase().trim():"";
     }
 
 
     public void setChinaCarNo(String chinaCarNo) {
-        this.chinaCarNo = chinaCarNo.toUpperCase().trim();
+        this.chinaCarNo = StrUtil.isNotEmpty(chinaCarNo)? chinaCarNo.toUpperCase().trim():"";
     }
 }

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

@@ -37,6 +37,8 @@ import com.pj.project.tb_declare.TbDeclare;
 import com.pj.project.tb_declare.TbDeclareService;
 import com.pj.project.tb_driver.TbDriver;
 import com.pj.project.tb_driver.TbDriverService;
+import com.pj.project.tb_goods.TbGoods;
+import com.pj.project.tb_goods.TbGoodsService;
 import com.pj.project.tb_item.TbItem;
 import com.pj.project.tb_item.TbItemService;
 import com.pj.project.tb_item_type.TbItemType;
@@ -48,6 +50,7 @@ import com.pj.project.tb_pass_record.TbPassRecordService;
 import com.pj.project.tb_unit.TbUnit;
 import com.pj.project.tb_unit.TbUnitService;
 import com.pj.project4sp.admin.SpAdmin;
+import com.pj.project4sp.global.BusinessException;
 import com.pj.project4sp.role.SpRoleUtil;
 import com.pj.project4sp.role4permission.SpRolePermissionService;
 import com.pj.utils.so.SoMap;
@@ -108,6 +111,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
     @Resource
     @Lazy
     TbDeclareService tbDeclareService;
+    @Resource
+    TbGoodsService tbGoodsService;
 
 
     public TbBusiness checkCarNo(String carNo) {
@@ -121,6 +126,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
      * 增
      */
     public AjaxJson addOrUpdate(TbBusiness t) {
+
         if (StrUtil.isNotEmpty(t.getId()) && StrUtil.isNotEmpty(t.getDeclareNo())) {
             TbBusiness db = this.getById(t.getId());
             if (!StrUtil.equals(db.getDeclareNo(), t.getDeclareNo())) {
@@ -132,7 +138,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             }
         }
         Double carSize = t.getCardSize();
-        if (carSize!=null&&carSize > carConfig.getMaxLength()) {
+        if (carSize != null && carSize > carConfig.getMaxLength()) {
             return AjaxJson.getError("车辆规格不能大于" + carConfig.getMaxLength());
         }
         Double netWeight = t.getNetWeight();
@@ -156,17 +162,19 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         } else {
             storeMsg(t.getCustomerId(), "业务订单:【" + t.getNo() + "】数据发生更改," + DateUtil.now() + "。");
         }
-        List<TbBusinessItem> items = JSONUtil.toList(t.getItemJson(), TbBusinessItem.class);
-
         saveOrUpdate(t);
         createBusinessPeople(t);
         tbBusinessItemService.removeByBusinessId(t.getId());
         BigDecimal price = new BigDecimal(0);
+        List<TbBusinessItem> items = JSONUtil.toList(t.getItemJson(), TbBusinessItem.class);
+        List<String> typeNames = new ArrayList<>();
         for (TbBusinessItem item : items) {
             Double num = NumberUtil.parseDouble(item.getNum());
             TbItem tbItem = tbItemService.getById(item.getItemId());
             price = price.add(NumberUtil.mul(num, tbItem.getPrice()));
             TbItemType tbItemType = tbItemTypeService.getById(tbItem.getTypeId());
+            String type = tbItemType.getName();
+            typeNames.add(type);
             item.setBusinessId(t.getId()).setItemCode(tbItem.getItemCode())
                     .setItemName(tbItem.getItemName()).setItemPrice(tbItem.getPrice())
                     .setItemTypeId(tbItem.getTypeId()).setItemTypeName(tbItemType.getName())
@@ -427,11 +435,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         List<TbBusinessCar> cars = tbBusinessCarService.findByBusinessId(businessId);
         Date now = new Date();
         List<Map<String, Object>> carsList = new ArrayList<>();
-        BigDecimal total = new BigDecimal("0");
         for (TbBusinessCar tbBusinessCar : cars) {
-            if (tbBusinessCar.getPay() == 1) {
-                continue;
-            }
             double partMoney = tbBusinessCar.getBasePartMoney().doubleValue();
             if (!StrUtil.equals("STATE", state)) {
                 Date inTime = tbBusinessCar.getRealInTime();
@@ -444,18 +448,16 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     partMoney = 0D;
                 }
             }
-            if (partMoney > 0) {
-                total = total.add(new BigDecimal(partMoney));
-                Map<String, Object> carMap = new HashMap<>();
-                carMap.put("price", partMoney);
-                carMap.put("id", tbBusinessCar.getId());
-                carMap.put("carNo", tbBusinessCar.getCarNo());
-                carsList.add(carMap);
-            }
+            Map<String, Object> carMap = new HashMap<>();
+            carMap.put("price", partMoney);
+            carMap.put("id", tbBusinessCar.getId());
+            carMap.put("carNo", tbBusinessCar.getCarNo());
+            carMap.put("pay",tbBusinessCar.getPay());
+            carsList.add(carMap);
         }
         result.put("carList", carsList);
         TbBusiness tbBusiness = this.getById(businessId);
-        if (tbBusiness != null && tbBusiness.getPayStatus() == TbBusiness.PayStatus.NO_PAY.getCode()) {
+        if (tbBusiness != null && tbBusiness.getPayStatus() != TbBusiness.PayStatus.HAS_PAY_CONFIRM.getCode()) {
             List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(businessId);
             result.put("itemsPrice", tbBusiness.getItemPrice());
             result.put("businessId", businessId);
@@ -465,12 +467,11 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 itemMap.put("id", item.getId());
                 itemMap.put("name", item.getItemName());
                 itemMap.put("price", item.getItemPrice());
-                total = total.add(item.getItemPrice());
+                itemMap.put("pay", item.getPayStatus());
                 itemList.add(itemMap);
             }
             result.put("itemList", itemList);
         }
-        result.put("total", total);
         return result;
     }
 

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

@@ -27,4 +27,5 @@ public interface TbBusinessCarMapper extends BaseMapper <TbBusinessCar> {
 	List<TbBusinessCar> getList(SoMap so);
 
 
+    List<TbBusinessCar> searchPartCar(String carNo);
 }

+ 58 - 55
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.xml

@@ -1,65 +1,68 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.pj.project.tb_business_car.TbBusinessCarMapper">
-	<!-- ================================== 查询相关 ================================== -->
-	<!-- select id, business_id, car_no, pre_in_time, pre_out_time, real_in_time, real_out_time, money, driver_phone from tb_business_car  -->
-	
-	<!-- 通用映射:手动模式 -->
-	<resultMap id="model" type="com.pj.project.tb_business_car.TbBusinessCar">
-		<result property="id" column="id" />
-		<result property="businessId" column="business_id" />
-		<result property="carNo" column="car_no" />
-		<result property="preInTime" column="pre_in_time" />
-		<result property="preOutTime" column="pre_out_time" />
-		<result property="realInTime" column="real_in_time" />
-		<result property="realOutTime" column="real_out_time" />
-		<result property="money" column="money" />
-		<result property="driverPhone" column="driver_phone" />
-	</resultMap>
-	
-	<!-- 公共查询sql片段 -->
-	<sql id="select_sql">
+    <!-- ================================== 查询相关 ================================== -->
+    <!-- select id, business_id, car_no, pre_in_time, pre_out_time, real_in_time, real_out_time, money, driver_phone from tb_business_car  -->
+
+    <!-- 通用映射:手动模式 -->
+    <resultMap id="model" type="com.pj.project.tb_business_car.TbBusinessCar">
+        <result property="id" column="id"/>
+        <result property="businessId" column="business_id"/>
+        <result property="carNo" column="car_no"/>
+        <result property="preInTime" column="pre_in_time"/>
+        <result property="preOutTime" column="pre_out_time"/>
+        <result property="realInTime" column="real_in_time"/>
+        <result property="realOutTime" column="real_out_time"/>
+        <result property="money" column="money"/>
+        <result property="driverPhone" column="driver_phone"/>
+    </resultMap>
+
+    <!-- 公共查询sql片段 -->
+    <sql id="select_sql">
 		select * 
 		from tb_business_car 
 	</sql>
 
-	<!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
-	<select id="getList" resultMap="model">
-		<include refid="select_sql"></include>
-		<where>
-			<if test=' this.has("id") '> and id = #{id} </if>
-			<if test=' this.has("businessId") '> and business_id = #{businessId} </if>
-            <if test=' this.has("customerId") '> and customer_id = #{customerId} </if>
-			<if test=' this.has("carNo") '> and car_no like concat('%',#{carNo},'%') </if>
-			<if test=' this.has("preInTime") '> and pre_in_time = #{preInTime} </if>
-			<if test=' this.has("preOutTime") '> and pre_out_time = #{preOutTime} </if>
-			<if test=' this.has("realInTime") '> and real_in_time = #{realInTime} </if>
-			<if test=' this.has("realOutTime") '> and real_out_time = #{realOutTime} </if>
-			<if test=' this.has("money") '> and money = #{money} </if>
-			<if test=' this.has("driverPhone") '> and driver_phone = #{driverPhone} </if>
-		</where>
-		order by
-		<choose>
-			<when test='sortType == 1'> id desc </when>
-			<when test='sortType == 2'> business_id desc </when>
-			<when test='sortType == 3'> car_no desc </when>
-			<when test='sortType == 4'> pre_in_time desc </when>
-			<when test='sortType == 5'> pre_out_time desc </when>
-			<when test='sortType == 6'> real_in_time desc </when>
-			<when test='sortType == 7'> real_out_time desc </when>
-			<when test='sortType == 8'> money desc </when>
-			<when test='sortType == 9'> driver_phone desc </when>
-			<otherwise> id desc </otherwise>
-		</choose>
+    <!-- 查集合 - 根据条件(参数为空时代表忽略指定条件) [G] -->
+    <select id="getList" resultMap="model">
+        <include refid="select_sql"></include>
+        <where>
+            <if test=' this.has("id") '>and id = #{id}</if>
+            <if test=' this.has("businessId") '>and business_id = #{businessId}</if>
+            <if test=' this.has("customerId") '>and customer_id = #{customerId}</if>
+            <if test=' this.has("carNo") '>and car_no like concat('%',#{carNo},'%')</if>
+            <if test=' this.has("preInTime") '>and pre_in_time = #{preInTime}</if>
+            <if test=' this.has("preOutTime") '>and pre_out_time = #{preOutTime}</if>
+            <if test=' this.has("realInTime") '>and real_in_time = #{realInTime}</if>
+            <if test=' this.has("realOutTime") '>and real_out_time = #{realOutTime}</if>
+            <if test=' this.has("money") '>and money = #{money}</if>
+            <if test=' this.has("driverPhone") '>and driver_phone = #{driverPhone}</if>
+        </where>
+        order by
+        <choose>
+            <when test='sortType == 1'>id desc</when>
+            <when test='sortType == 2'>business_id desc</when>
+            <when test='sortType == 3'>car_no desc</when>
+            <when test='sortType == 4'>pre_in_time desc</when>
+            <when test='sortType == 5'>pre_out_time desc</when>
+            <when test='sortType == 6'>real_in_time desc</when>
+            <when test='sortType == 7'>real_out_time desc</when>
+            <when test='sortType == 8'>money desc</when>
+            <when test='sortType == 9'>driver_phone desc</when>
+            <otherwise>id desc</otherwise>
+        </choose>
+    </select>
+    <select id="searchPartCar" resultType="com.pj.project.tb_business_car.TbBusinessCar">
+		SELECT
+	        a.*
+        FROM
+            tb_business_car a,
+            tb_business b
+        WHERE
+            a.business_id = b.id
+            AND b.total_money> b.pay_money
+            AND a.car_no LIKE CONCAT( '%', #{carNo}, '%' )
 	</select>
-	
-	
-	
-	
-	
-	
-	
-	
-	
+
 
 </mapper>

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

@@ -89,9 +89,7 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
 
 
     public List<TbBusinessCar> searchPartCar(String carNo) {
-        QueryWrapper<TbBusinessCar> ew = new QueryWrapper<>();
-        ew.like("car_no", carNo.toUpperCase()).and(j -> j.eq("pay", "0").or(i -> i.isNull("real_out_time").isNotNull("real_in_time")));
-        return list(ew);
+        return   tbBusinessCarMapper.searchPartCar(carNo.toUpperCase());
     }
 
 

+ 10 - 2
sp-server/src/main/java/com/pj/project/tb_goods/TbGoodsService.java

@@ -2,6 +2,9 @@ package com.pj.project.tb_goods;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -13,7 +16,7 @@ import com.pj.utils.sg.*;
  * @author qzy 
  */
 @Service
-public class TbGoodsService {
+public class TbGoodsService extends ServiceImpl<TbGoodsMapper,TbGoods> implements IService<TbGoods> {
 
 	/** 底层 Mapper 对象 */
 	@Autowired
@@ -43,6 +46,11 @@ public class TbGoodsService {
 	List<TbGoods> getList(SoMap so) {
 		return tbGoodsMapper.getList(so);	
 	}
-	
 
+
+	public TbGoods findByName(String goodsName) {
+		QueryWrapper<TbGoods>ew=new QueryWrapper<>();
+		ew.eq("name",goodsName);
+		return getOne(ew);
+	}
 }

+ 50 - 0
sp-server/src/main/java/com/pj/project4sp/global/BusinessException.java

@@ -0,0 +1,50 @@
+package com.pj.project4sp.global;
+
+import com.pj.constants.ErrorMsgEnum;
+import lombok.Data;
+
+/**
+ * @author qzy
+ * @description 业务异常
+ * @date Create in 2021/4/22
+ */
+@Data
+public class BusinessException extends RuntimeException {
+
+    private static final long serialVersionUID = -8661950806210020649L;
+    private Integer code;
+
+    /**
+     * 验证的时候,手动抛该异常
+     *
+     * @param errMsg 定义的错误信息
+     */
+    public BusinessException(String errMsg) {
+        super(errMsg);
+        this.code=500;
+    }
+    /**
+     * 验证的时候,手动抛该异常
+     *
+     * @param errMsg 定义的错误信息
+     */
+    public BusinessException(String errMsg, Integer code) {
+        super(errMsg);
+        this.code=code;
+    }
+    public BusinessException(ErrorMsgEnum errMsg) {
+        super(errMsg.getMsg());
+        this.code=errMsg.getCode();
+    }
+
+    /**
+     * catch中抛该异常
+     *
+     * @param errMsg 自定义的错误信息
+     * @param e      异常
+     */
+    public BusinessException(String errMsg, Throwable e) {
+        super(errMsg, e);
+    }
+
+}

+ 4 - 2
sp-server/src/main/java/com/pj/project4sp/global/GlobalException.java

@@ -37,9 +37,11 @@ public class GlobalException {
 		Throwable e2 = e.getCause();
 		
 		// ------------- 判断异常类型,提供个性化提示信息 
-		
+		if (e instanceof BusinessException){
+			aj=AjaxJson.getError(e.getMessage());
+		}
     	// 如果是未登录异常 
-		if(e instanceof NotLoginException){	
+		else if(e instanceof NotLoginException){
 			aj = AjaxJson.getNotLogin();
 		} 
 		// 如果是权限异常