Browse Source

审核->修改->审核导致重复扣装卸业务问题

qzyReal 2 years ago
parent
commit
228e25bf90

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

@@ -45,6 +45,7 @@
 			.china-car-size .el-input__inner {
 				width: 130px;
 			}
+
 			.flex-item {
 				width: 360px;
 				padding-bottom: 20px;
@@ -85,7 +86,8 @@
 										<el-col span=8>
 											<div class="c-item" v-if="goods.needCustomer">
 												<label class="c-label"><span style="color: red;">*</span>客户:</label>
-												<el-select v-model="m.customerId" placeholder="请选择" filterable>
+												<el-select :disabled="customerDis" v-model="m.customerId"
+													placeholder="请选择" filterable>
 													<el-option v-for="item in customerList" :key="item.id"
 														:label="item.name" :value="item.id">
 													</el-option>
@@ -134,9 +136,11 @@
 									</el-table-column>
 									<el-table-column prop="carType" label="类型">
 									</el-table-column>
-									<el-table-column prop="driverName" label="司机姓名" v-if="car.list.length>0&&car.list[0].driverName">
+									<el-table-column prop="driverName" label="司机姓名"
+										v-if="car.list.length>0&&car.list[0].driverName">
 									</el-table-column>
-									<el-table-column prop="driverPhone" label="司机电话" v-if="car.list.length>0&&car.list[0].driverName">
+									<el-table-column prop="driverPhone" label="司机电话"
+										v-if="car.list.length>0&&car.list[0].driverName">
 									</el-table-column>
 									<el-table-column label="操作" fixed="right" width="140">
 										<template slot-scope="s">
@@ -209,7 +213,8 @@
 												<el-date-picker type="datetime" v-model="type.coldStartTime"
 													:placeholder="type.cabinetType&&type.cabinetType==1?'结束时间':'开始时间'"></el-date-picker>
 											</div>
-											<div style="width: 360px;padding-bottom: 20px;" v-if="type.itemAlias&&type.itemAlias=='coldTruck'">
+											<div style="width: 360px;padding-bottom: 20px;"
+												v-if="type.itemAlias&&type.itemAlias=='coldTruck'">
 												<sa-item type="img" name="开始时间图片" v-model="type.startImage"></sa-item>
 											</div>
 											<div style="width: 360px;padding-bottom: 20px;"></div>
@@ -251,7 +256,7 @@
 							<el-input v-model="car.form.driverName" placeholder="司机姓名">
 							</el-input>
 						</div>
-						<div class="c-item"  v-if="m.goodsName=='集装箱正面吊装'">
+						<div class="c-item" v-if="m.goodsName=='集装箱正面吊装'">
 							<label class="c-label">司机号码:</label>
 							<el-input v-model="car.form.driverPhone" placeholder="司机号码">
 							</el-input>
@@ -285,6 +290,7 @@
 						businessGoodsName: ''
 					}, // 实体对象
 					partnerDis: false,
+					customerDis: false,
 					customerList: [],
 					partnerList: [],
 					carList: [],
@@ -300,8 +306,8 @@
 							carNo: '',
 							carType: '',
 							netWeight: '',
-							driverName:'',
-							driverPhone:'',
+							driverName: '',
+							driverPhone: '',
 							carSize: ''
 						}
 					},
@@ -395,19 +401,19 @@
 						type.coldStartTime = '';
 					},
 					itemChange(type) {
-							let itemId = type.itemId;
-							let item = type.items.filter(obj => obj.id == itemId).pop();
-							if (item) {
-								type.inc = item.inc;
-								type.price = item.price;
-								type.needRemark = item.needRemark;
-								type.disabled = false;
-								type.itemName = item.itemName;
-								type.itemAlias = item.itemAlias;
-								if (item.itemName == '人工、机械装卸车辆') {
-									type.disabled = true;
-								}
+						let itemId = type.itemId;
+						let item = type.items.filter(obj => obj.id == itemId).pop();
+						if (item) {
+							type.inc = item.inc;
+							type.price = item.price;
+							type.needRemark = item.needRemark;
+							type.disabled = false;
+							type.itemName = item.itemName;
+							type.itemAlias = item.itemAlias;
+							if (item.itemName == '人工、机械装卸车辆') {
+								type.disabled = true;
 							}
+						}
 					},
 					confirmAdd() {
 						let list = this.car.list;
@@ -427,8 +433,8 @@
 						if (index > -1) {
 							list.splice(index, 1);
 						}
-						let phone=form.driverPhone;
-						if(phone&&!sa.isPhone(phone)){
+						let phone = form.driverPhone;
+						if (phone && !sa.isPhone(phone)) {
 							sa.error('司机号码不正确')
 							return;
 						}
@@ -439,8 +445,8 @@
 							carType: carType,
 							carSize: carSize,
 							netWeight: netWeight,
-							driverName:form.driverName,
-							driverPhone:phone
+							driverName: form.driverName,
+							driverPhone: phone
 						}
 						this.car.list.push(car);
 						this.car.visible = false;
@@ -451,8 +457,8 @@
 						this.car.form.carNo = '';
 						this.car.form.carSize = '';
 						this.car.form.netWeight = '';
-						this.car.form.driverName='';
-						this.car.form.driverPhone='';
+						this.car.form.driverName = '';
+						this.car.form.driverPhone = '';
 					},
 					editFn(data) {
 						Object.assign(this.car, {
@@ -603,7 +609,7 @@
 									coldStartTime: type.coldStartTime,
 									itemAlias: type.itemAlias,
 									cabinetType: type.cabinetType,
-									startImage:type.startImage
+									startImage: type.startImage
 								}
 								selectList.push(obj);
 							}
@@ -644,6 +650,13 @@
 								this.partnerDis = true;
 								this.m.customerId = id;
 							}
+							let customerList = this.customerList;
+							arr = customerList.filter(obj => obj.id == id);
+							if (arr.length > 0) {
+								this.customerDis = true;
+								this.m.customerId = id;
+								this.m.customerName=arr[0].name
+							}
 						}.bind(this));
 					},
 				},

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

@@ -82,7 +82,7 @@
 										<el-col span=8>
 											<div class="c-item" v-if="goods.needCustomer">
 												<label class="c-label"><span style="color: red;">*</span>客户:</label>
-												<el-select :disabled="currentCustomerId!='1'" v-model="m.customerId"
+												<el-select :disabled="customerDis" v-model="m.customerId"
 													placeholder="请选择" filterable>
 													<el-option v-for="item in customerList" :key="item.id"
 														:label="item.name" :value="item.id">
@@ -293,6 +293,7 @@
 						goodsName: '', // 商品
 					}, // 实体对象
 					partnerDis: false,
+					customerDis:false,
 					customerList: [],
 					partnerList: [],
 					carList: [],
@@ -646,6 +647,13 @@
 								this.m.pickCustomerId = id;
 								this.partnerDis = true;
 							}
+							let customerList = this.customerList;
+							arr = customerList.filter(obj => obj.id == id);
+							if (arr.length > 0) {
+								this.customerDis = true;
+								this.m.customerId = id;
+								this.m.customerName=arr[0].name
+							}
 						}.bind(this));
 					},
 					getOtherBusinessById() {

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

@@ -534,7 +534,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                             .findAny().ifPresent(priceItem -> {
                         BigDecimal price = priceItem.getFirePrice().multiply(new BigDecimal(item.getNum()));
                         //柜车、栏车只有离场才知道多少钱
-                        if (StrUtil.equals(item.getItemAlias(),SystemObject.config.getCabinetCar())){
+                        if (StrUtil.equals(item.getItemAlias(), SystemObject.config.getCabinetCar())) {
                             TbBusiness tbBusiness = this.getById(item.getBusinessId());
                             tbBusiness.setItemPrice(price);
                             item.setTotal(price);
@@ -813,6 +813,17 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             }
             //最新一条记录
             TbBusinessCar db = tbBusinessCarService.findTheLastRecord(carNo);
+            if (db != null && db.getRealOutTime() == null) {
+                //未离场====>检查是否录入了其他业务,需要校验其绑定的客户是否一致
+                List<TbBusiness> exitBusinessList = this.findOtherBusinessByCarId(db.getId());
+                if (!exitBusinessList.isEmpty()) {
+                    TbBusiness exitBusiness = exitBusinessList.get(0);
+                    String bindCustomerId = exitBusiness.getCustomerId();
+                    if (!StrUtil.equals(bindCustomerId, customerId)) {
+                        throw new AjaxError("车辆【" + carNo + "】绑定的客户与已绑定的【" + exitBusiness.getCustomerName() + "】不一致");
+                    }
+                }
+            }
             if (!tbGoods.getName().contains("整车")) {
                 //记录不存在或者已离场
                 if (db == null || db.getRealOutTime() != null) {
@@ -824,11 +835,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 db = new TbBusinessCar();
                 db.setCreateTime(now).setPay(0).setNo(carBuseinssNo + RandomUtil.randomNumbers(4));
             }
-            for (TbBusinessItem item : itemList) {
-                if (StrUtil.isNotEmpty(otherBusinessBO.getOperateTime())) {
-                    checkOtherBusiness(item.getItemTypeId(), otherBusinessBO.getOperateTime(), tbBusiness.getId(), carNo);
-                }
-            }
             db.setPayType(CarEnum.PayTypeEnum.NO_PAY_TYPE.getType());
             TbCar tbCar = tbCarService.findByCardNo(carNo);
             if (tbCar != null) {
@@ -866,6 +872,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
 
     public void editOtherBusiness(OtherBusinessBO otherBusinessBO) {
         String id = otherBusinessBO.getId();
+        String customerId = otherBusinessBO.getCustomerId();
         TbBusiness dbBusiness = this.getById(id);
         if (dbBusiness == null) {
             throw new AjaxError("记录不存在");
@@ -897,7 +904,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         String carBuseinssNo = DateUtil.format(now, "yyyyMMddHHmm");
         String goodsName = tbGoods.getName();
         List<TbBusinessItem> itemList = new ArrayList<>();
-        if (PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode() != dbBusiness.getPayStatus()) {
+        if (dbBusiness.getPayMoney().compareTo(dbBusiness.getItemPrice()) < 0) {
             List<TbBusinessItem> businessItemList = tbBusinessItemService.findByBusinessId(id);
             //变成未取柜状态
             businessItemList.stream().filter(item -> item.getParentCabinetId() != null).forEach(item -> {
@@ -916,7 +923,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                 dbBusiness.setPickCustomerId(pickCustomerId).setPickCustomerName(partner.getName());
             }
             int size = cars.size();
-
             for (TbItem tbItem : tbItems) {
                 TbItem db = tbItemService.getById(tbItem.getId());
                 String alaisName = db.getItemAlias();
@@ -947,6 +953,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                         .setUnit(db.getUnit()).setTotal(itemTotalPrice).setCreateTime(now)
                         .setCabinetType(cabinetType).setEndImage(endImage).setStartImage(tbItem.getStartImage())
                         .setColdStartTime(tbItem.getColdStartTime()).setColdEndTime(tbItem.getColdEndTime());
+
                 if (partner != null) {
                     item.setPick(1).setPickCustomerId(pickCustomerId).setPickCustomerName(partner.getName())
                             .setPickBy(StpUserUtil.getCreateBy()).setPickTime(now);
@@ -1023,6 +1030,18 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         for (TbBusinessCar tbBusinessCar : cars) {
             String businessCarId = tbBusinessCar.getId();
             String carNo = tbBusinessCar.getCarNo();
+            TbBusinessCar checkCar = tbBusinessCarService.findTheLastRecord(carNo);
+            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() + "】不一致");
+                    }
+                }
+            }
             if (StrUtil.isNotEmpty(businessCarId)) {
                 //原来已存在的
                 TbBusinessCar dbBusinessCar = tbBusinessCarService.getById(businessCarId);
@@ -1050,7 +1069,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     tbBusinessCarService.updateById(dbBusinessCar);
                 }
             } else {
-                TbBusinessCar checkCar = tbBusinessCarService.findTheLastRecord(carNo);
+
                 //不存在或者已经离场的
                 if (checkCar == null) {
                     throw new AjaxError("车辆【" + carNo + "】未入场");
@@ -1069,7 +1088,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
             dbBusiness.setGoodsId(otherBusinessBO.getGoodsId())
                     .setGoodsName(goodsName).setPayStep(tbGoods.getPayStep());
         }
-        String customerId = otherBusinessBO.getCustomerId();
         if (StrUtil.isNotEmpty(customerId)) {
             TbCostomer tbCostomer = tbCostomerService.getById(customerId);
             dbBusiness.setCustomerId(customerId).setCustomerName(tbCostomer.getName());
@@ -1734,6 +1752,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
         //其他费项 装卸业务管理费” 进行预存款扣除
         for (TbBusinessItem item : tbBusinessItems) {
             String aliasName = item.getItemAlias();
+            String itemName = item.getItemName();
             //充电打冷,正面吊(取柜)必须得有开始时间+结束时间
             if (StrUtil.equals(aliasName, SystemObject.config.getColdItemAlias())
                     || (StrUtil.equals(aliasName, SystemObject.config.getEmptyStoreItemAlias())
@@ -1745,8 +1764,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
                     throw new AjaxError("请先点击【修改】,然后录入业务开始/结束时间");
                 }
             }
-            //业务类型是装卸业务管理费且未支付的进行扣款
-            if (item.getPayStatus() == 0 && SystemObject.config.getUnLoadItem().contains(item.getItemTypeName())) {
+            //其他业务类型是装卸业务管理费且未支付的进行扣款
+            if (item.getPayStatus() == 0 && SystemObject.config.getUnLoadItem().contains(item.getItemTypeName())
+                    && !SystemObject.config.getEveryCarPay().contains(itemName)) {
                 List<IOrderItem> expenses = new ArrayList<>();
                 IOrderItem orderItem = new IOrderItem();
                 orderItem.setExpenseNum(Integer.parseInt(item.getNum()))

+ 7 - 0
sp-server/src/main/java/com/pj/project/tb_business_item/TbBusinessItemService.java

@@ -435,4 +435,11 @@ public class TbBusinessItemService extends ServiceImpl<TbBusinessItemMapper, TbB
     public List<TbBusinessItem> getCabinetRecord(SoMap soMap) {
         return tbBusinessItemMapper.getCabinetRecord(soMap);
     }
+
+    public TbBusinessItem findByBusinessIdAndItemId(String businessId, String itemId) {
+        QueryWrapper<TbBusinessItem>ew=new QueryWrapper<>();
+        ew.lambda().eq(TbBusinessItem::getBusinessId,businessId)
+                .eq(TbBusinessItem::getItemId,itemId);
+        return getOne(ew);
+    }
 }

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

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