Browse Source

过滤条件

qzyReal 2 years ago
parent
commit
24652f9ca5

+ 2 - 2
app/utils/request.js

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

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

@@ -62,12 +62,13 @@
 									<div class="c-item">
 										<label class="c-label">车辆类型:</label>
 										<el-select v-model="m.carType" placeholder="请选择" @change="carTypeChange">
-											<el-option :label="item.name" :value="item.name" v-for="(item,index) in carTypeList">
+											<el-option :label="item.name" :value="item.name"
+												v-for="(item,index) in carTypeList">
 											</el-option>
 										</el-select>
 									</div>
-									<sa-item v-if="m.carType.indexOf('重')!==-1" type="num" name="载重(kg)" placeholder="请输入车辆载重"
-										v-model="m.carWeight" br>
+									<sa-item v-if="m.carType.indexOf('重')!==-1" type="num" name="载重(kg)"
+										placeholder="请输入车辆载重" v-model="m.carWeight" br>
 									</sa-item>
 									<div class="c-item">
 										<label class="c-label">作业时间:</label>
@@ -116,7 +117,7 @@
 			</div>
 			<!-- ------- 底部按钮 ------- -->
 			<div class="s-foot">
-				<el-button type="primary" @click="ok()" v-if="sa.isAuth('tb-business-add')">确定</el-button>
+				<el-button type="primary" @click="ok()">确定</el-button>
 				<el-button @click="sa.closeCurrIframe()">取消</el-button>
 			</div>
 		</div>
@@ -149,7 +150,7 @@
 					checkList: [],
 					customerList: [],
 					carTypeList: [],
-					currentCustomerId:'1'
+					currentCustomerId: '1'
 				},
 				computed: {
 					totalPrice() {
@@ -167,22 +168,24 @@
 					getCustomer() {
 						sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
 							let id = resp.data;
-							if (id == 1) {} else {
+							if (id == 1) {
+								this.getCustomerList();
+							} else {
 								this.m.customerId = id;
 							}
 							this.currentCustomerId = id;
 						}.bind(this));
 					},
-					carTypeChange(v){
+					carTypeChange(v) {
 						this.getItems();
 					},
 					getItemType() {
 						sa.ajax('/TbItem/getItemType', function(resp) {
 							let list = resp.data;
 							if (list.length > 0) {
-								this.m.carType=list[0].id;
+								this.m.carType = list[0].id;
 							}
-							this.carTypeList=list;
+							this.carTypeList = list;
 							this.getItemTypeList()
 						}.bind(this))
 					},
@@ -191,7 +194,7 @@
 							pageNo: 1,
 							pageSize: 30,
 							judgeStatus: 2,
-							sortType:20
+							sortType: 20
 						}, function(res) {
 							let list = res.data;
 							if (list.length > 0) {
@@ -219,8 +222,9 @@
 							typeId: this.m.itemTypeId
 						}, function(resp) {
 							let list = resp.data;
-							if(this.m.carType){
-								list=list.filter(obj=>obj.itemType&&obj.itemType.indexOf(this.m.carType)!==-1);
+							if (this.m.carType) {
+								list = list.filter(obj => obj.itemType && obj.itemType.indexOf(this.m
+									.carType) !== -1);
 							}
 							this.checkList = list.filter(obj => obj.need == 1).map(obj => obj.id)
 							this.items = list;
@@ -244,7 +248,7 @@
 				},
 				mounted: function() {
 					this.getCustomer();
-					this.getCustomerList();
+
 					this.getItemTypeList();
 					this.getItemType();
 				}

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

@@ -62,23 +62,25 @@
 									<div class="c-item">
 										<label class="c-label">车辆类型:</label>
 										<el-select v-model="m.carType" placeholder="请选择" @change="carTypeChange">
-											<el-option :label="item.name" :value="item.name" v-for="(item,index) in carTypeList">
+											<el-option :label="item.name" :value="item.name"
+												v-for="(item,index) in carTypeList">
 											</el-option>
 										</el-select>
 									</div>
-									<sa-item v-if="m.carType.indexOf('重')!==-1" type="num" name="载重(kg)" placeholder="请输入车辆载重"
-										v-model="m.carWeight" br>
+									<sa-item v-if="m.carType.indexOf('重')!==-1" type="num" name="载重(kg)"
+										placeholder="请输入车辆载重" v-model="m.carWeight" br>
 									</sa-item>
 									<div class="c-item">
 										<label class="c-label">作业时间:</label>
-										<el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" v-model="m.operateTime"></el-date-picker>
+										<el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
+											v-model="m.operateTime"></el-date-picker>
 									</div>
 								</el-col>
 							</el-row>
 							<el-card class="box-card">
 								<div slot="header" class="clearfix">
 									<span>收费明细<label style="color: red;">(总共{{totalPrice}}元)</label></span>
-									<el-select v-model="m.itemTypeId" placeholder="请选择" @change="getItems"
+									<el-select v-model="m.itemTypeId" placeholder="请选择" @change="itemChange"
 										style="float: right; padding: 3px 0">
 										<el-option v-for="(item,index) in itemTypeList" :label="item.name"
 											:value="item.id">
@@ -114,7 +116,7 @@
 			</div>
 			<!-- ------- 底部按钮 ------- -->
 			<div class="s-foot">
-				<el-button type="primary" @click="ok()" v-if="sa.isAuth('tb-business-add')">确定</el-button>
+				<el-button type="primary" @click="ok()">确定</el-button>
 				<el-button @click="sa.closeCurrIframe()">取消</el-button>
 			</div>
 		</div>
@@ -144,17 +146,19 @@
 					}, // 实体对象 
 					itemTypeList: [],
 					items: [],
-					businessItems:[],
+					businessItems: [],
 					checkList: [],
-					customerList:[],
-					carTypeList:[],
-					currentCustomerId:''
+					customerList: [],
+					carTypeList: [],
+					currentCustomerId: ''
 				},
 				computed: {
+
+
 					totalPrice() {
 						let checkList = this.checkList;
 						let items = this.items
-						.filter(obj => checkList.indexOf(obj.id) !== -1);
+							.filter(obj => checkList.indexOf(obj.id) !== -1);
 						let price = 0;
 						for (let i in items) {
 							let item = items[i];
@@ -164,28 +168,55 @@
 					}
 				},
 				methods: {
+					itemChange() {
+						sa.ajax('/TbItem/getTypeItemList', {
+							pageNo: 1,
+							pageSize: 30,
+							typeId: this.m.itemTypeId
+						}, function(resp) {
+							let list = resp.data;
+							if (this.m.carType) {
+								list = list.filter(obj => obj.itemType && obj.itemType.indexOf(this.m
+									.carType) !== -1);
+							}
+							this.items = list;
+							this.checkList = list.filter(obj => obj.need == 1 || obj.itemType.indexOf(this.m
+								.carType) !== -1).map(obj => obj.id);
+							let businessItems = this.businessItems;
+							list.forEach(obj => {
+								businessItems.forEach(item => {
+									if (obj.id == item.itemId) {
+										obj.remark = item.remark;
+										obj.num = item.num;
+									}
+								})
+							})
+						}.bind(this))
+					},
 					getCustomer() {
 						sa.ajax('/TbCostomer/getCurrentCustomerId', function(resp) {
 							let id = resp.data;
-							if (id == 1) {} else {
+							if (id == 1) {
+								this.getCustomerList();
+							} else {
 								this.m.customerId = id;
 							}
 							this.currentCustomerId = id;
 						}.bind(this));
 					},
-					carTypeChange(v){
+					carTypeChange(v) {
 						this.getItems();
 					},
 					getItemType() {
 						sa.ajax('/TbItem/getItemType', function(resp) {
-							this.carTypeList= resp.data;
+							this.carTypeList = resp.data;
 						}.bind(this))
 					},
 					getCustomerList() {
 						sa.ajax('/TbCostomer/getList', {
 							pageNo: 1,
 							pageSize: 30,
-							sortType:20,
+							sortType: 20,
 							judgeStatus: 2
 						}, function(res) {
 							this.customerList = res.data; // 数据
@@ -195,6 +226,7 @@
 						sa.ajax('/TbItemType/getList', sa.removeNull(this.p), function(res) {
 							let list = res.data;
 							this.itemTypeList = list;
+
 							this.getItems();
 						}.bind(this));
 					},
@@ -205,16 +237,19 @@
 							typeId: this.m.itemTypeId
 						}, function(resp) {
 							let list = resp.data;
-							if(this.m.carType){
-								list=list.filter(obj=>obj.itemType&&obj.itemType.indexOf(this.m.carType)!==-1);
+							if (this.m.carType) {
+								list = list.filter(obj => obj.itemType && obj.itemType.indexOf(this.m
+									.carType) !== -1);
 							}
 							this.items = list;
-							let businessItems=this.businessItems;
-							list.forEach(obj=>{
-								businessItems.forEach(item=>{
-									if(obj.id==item.itemId){
-										obj.remark=item.remark;
-										obj.num=item.num;
+							this.checkList = list.filter(obj => obj.need == 1 || obj.itemType.indexOf(this.m
+								.carType) !== -1).map(obj => obj.id);
+							let businessItems = this.businessItems;
+							list.forEach(obj => {
+								businessItems.forEach(item => {
+									if (obj.id == item.itemId) {
+										obj.remark = item.remark;
+										obj.num = item.num;
 									}
 								})
 							})
@@ -230,7 +265,7 @@
 						let itemList = this.items;
 						let list = itemList.filter(obj => checkList.indexOf(obj.id) !== -1);
 						m.itemJson = JSON.stringify(list);
-						m.items=null;
+						m.items = null;
 						sa.ajax('/api/editOtherBusiness', sa.removeNull(m), function(resp) {
 							parent.app.f5(); // 刷新父页面列表
 							sa.closeCurrIframe(); // 关闭本页 
@@ -240,19 +275,21 @@
 						sa.ajax('/TbBusiness/getOtherBusinessById', {
 							id: this.id
 						}, function(resp) {
-							let data=resp.data;
+							let data = resp.data;
 							this.m = data
-							this.businessItems=data.items;
-							this.checkList=data.items.map(obj=>obj.itemId);
+							this.businessItems = data.items;
+							this.checkList = data.items.map(obj => obj.itemId);
+							console.log(this.checkList);
 							this.getItemTypeList();
 							this.getItemType();
 						}.bind(this))
 					}
 				},
 				mounted: function() {
-					this.getCustomer();
 					this.getOtherBusinessById();
-					this.getCustomerList();
+					this.getCustomer();
+
+
 				}
 			})
 		</script>

+ 1 - 1
sp-server/app.pid

@@ -1 +1 @@
-26984
+23292

+ 15 - 7
sp-server/src/main/java/com/pj/api/service/ApiService.java

@@ -147,6 +147,7 @@ public class ApiService {
             TbBusiness tbBusiness = tbBusinessService.getById(businessId);
             return tbBusiness.getAdminConfirmInput() == 1;
         }).collect(Collectors.toList());
+
         List<TbBusinessCar> otherBusinessCarList = tbBusinessCarService.searchOtherBusinessCar(carNo);
         otherBusinessCarList = otherBusinessCarList.stream().filter(tbBusinessCar -> {
             String businessCarId = tbBusinessCar.getId();
@@ -156,6 +157,8 @@ public class ApiService {
                     || (TbItemType.PayStep.AFTER_CONFIRM.getCode().equals(tbBusiness.getPayStep()) && tbBusiness.getAdminConfirmInput() == 1))
             ));
         }).collect(Collectors.toList());
+
+
         List<TbBusinessCar> cars = tbBusinessCarService.findTheNoBusinessCar(carNo);
         //过滤掉不用缴费的车
         list.addAll(cars);
@@ -299,7 +302,17 @@ public class ApiService {
     }
 
     public void addCarDisinfect(OtherBusinessBO otherBusinessBO) {
+        List<TbItem> tbItems = otherBusinessBO.getItems();
+        if (tbItems.isEmpty()) {
+            throw new BusinessException("请选择明细");
+        }
         String carNo = otherBusinessBO.getCarNo().trim().toUpperCase();
+        for (TbItem tbItem1 : tbItems) {
+            List<TbBusinessCar> tbBusinessCarList = tbBusinessCarService.findTodayRecord(carNo, tbItem1.getId());
+            if (!tbBusinessCarList.isEmpty()) {
+                throw new BusinessException("该车当天已有相同业务");
+            }
+        }
         TbBusinessCar db = tbBusinessCarService.findNotOutCar(carNo);
         String customerId = otherBusinessBO.getCustomerId();
         TbItemType tbItemType = tbItemTypeService.getById(otherBusinessBO.getItemTypeId());
@@ -315,17 +328,12 @@ public class ApiService {
                 tbBusinessCarService.save(db);
             }
         }
-
         TbBusiness tbBusiness = new TbBusiness();
         tbBusiness.setBusinessCarId(db.getId()).setPayStep(tbItemType.getPayStep());
         TbCostomer tbCostomer = tbCostomerService.getById(customerId);
         if (tbCostomer != null) {
             tbBusiness.setCustomerId(customerId).setCustomerName(tbCostomer.getName());
         }
-        List<TbItem> tbItems = otherBusinessBO.getItems();
-        if (tbItems.isEmpty()) {
-            throw new BusinessException("请选择明细");
-        }
         BigDecimal price = new BigDecimal("0");
         List<TbBusinessItem> itemList = new ArrayList<>();
         String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
@@ -388,7 +396,7 @@ public class ApiService {
         tbBusiness.setOperateTime(otherBusinessBO.getOperateTime())
                 .setOperator(otherBusinessBO.getOperator())
                 .setPayStep(tbItemType.getPayStep()).setItemTypeName(tbItemType.getName())
-                .setCardSize(otherBusinessBO.getCarSize())
+                .setCardSize(otherBusinessBO.getCarSize()).setItemTypeId(tbItemType.getId())
                 .setCustomerId(customerId).setNetWeight(otherBusinessBO.getCarWeight())
                 .setGoodsName(otherBusinessBO.getCarType())
                 .setCustomerName(tbCostomer.getName());
@@ -400,7 +408,7 @@ public class ApiService {
         }
         String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
         TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(tbBusiness.getBusinessCarId());
-        tbBusinessCar.setCarSize(otherBusinessBO.getCarSize())
+        tbBusinessCar.setCarSize(otherBusinessBO.getCarSize()).setBusinessType(TbBusiness.BusinessType.CAR_DISINCLE.getCode())
                 .setCustomerId(otherBusinessBO.getCustomerId()).setCarNo(carNo)
                 .setTimeUpdate(new Date());
         int index = 1;

+ 17 - 7
sp-server/src/main/java/com/pj/api/wx/service/WxService.java

@@ -47,8 +47,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.nio.charset.Charset;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
+
 import java.util.*;
 
 @Service
@@ -81,6 +80,7 @@ public class WxService {
     @Resource
     private TbOrderService tbOrderService;
 
+    private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
 
     /**
      * 统一下单接口
@@ -199,17 +199,17 @@ public class WxService {
 
     public void WxNotify(NotifyBO notifyBO) {
         String outTradeNo = notifyBO.getOutTradeNo();
-        if (StrUtil.isNotEmpty(RedisUtil.get(outTradeNo))){
+        if (StrUtil.isNotEmpty(RedisUtil.get(outTradeNo))) {
             log.error("========订单已处理==========:{}", outTradeNo);
             return;
         }
-        RedisUtil.setByHour(outTradeNo,DateUtil.now(),1);
+        RedisUtil.setByHour(outTradeNo, DateUtil.now(), 1);
         TbOrder tbOrder = tbOrderService.findByOutTradeNo(outTradeNo);
         if (tbOrder == null) {
             log.error("========订单不存在==========:{}", outTradeNo);
             return;
         }
-        if (StrUtil.equals("SUCCESS",tbOrder.getOrderStatus())) {
+        if (StrUtil.equals("SUCCESS", tbOrder.getOrderStatus())) {
             log.error("========订单已支付==========:{}", outTradeNo);
             return;
         }
@@ -244,15 +244,25 @@ public class WxService {
                 List<TbBusinessItem> items;
                 List<TbBusiness> businessList = new ArrayList<>();
                 if (TbBusiness.BusinessType.CAR_DISINCLE.getCode().equals(tbOrder.getBusinessType())) {
-                    List<String> businessIds = StrUtil.splitTrim(businessId,",");
+                    List<String> businessIds = StrUtil.splitTrim(businessId, ",");
                     items = tbBusinessItemService.findByBusinessIdList(businessIds);
                     businessList = tbBusinessService.listByIds(businessIds);
                 } else {
                     items = tbBusinessItemService.findByBusinessId(businessId);
                     TbBusiness tbBusiness = tbBusinessService.getById(businessId);
                     businessList.add(tbBusiness);
+                    //整车越南车变成已支付=免费
+                    List<TbBusinessCar> carList = tbBusinessCarService.findByBusinessId(businessId);
+                    carList.forEach(tbBusinessCar -> {
+                        String carNo = tbBusinessCar.getCarNo();
+                        String carNoStr = StrUtil.sub(carNo, 0, 1);
+                        if (!CAR_LIST.contains(carNoStr)) {
+                            tbBusinessCar.setPay(1);
+                            tbBusinessCarService.updateById(tbBusinessCar);
+                        }
+                    });
                 }
-                log.error("items size:{},{}",items.size(),JSONUtil.toJsonStr(items));
+                log.error("items size:{},{}", items.size(), JSONUtil.toJsonStr(items));
                 tbFeeStatisticsService.countBusinessFee(items, transactionId, outTradeNo);//业务费日统计
                 items.forEach(tbBusinessItem -> tbBusinessItem.setPayStatus(1).setPayTime(now));
                 tbBusinessItemService.updateBatchById(items);

+ 16 - 12
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarMapper.java

@@ -6,30 +6,34 @@ import org.apache.ibatis.annotations.Mapper;
 
 import com.pj.utils.so.*;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 /**
- * Mapper: tb_business_car -- 
- * @author qzy 
+ * Mapper: tb_business_car --
+ *
+ * @author qzy
  */
 
 @Mapper
 @Repository
-public interface TbBusinessCarMapper extends BaseMapper <TbBusinessCar> {
+public interface TbBusinessCarMapper extends BaseMapper<TbBusinessCar> {
 
 
-
-	/**
-	 * 查集合 - 根据条件(参数为空时代表忽略指定条件)
-	 * @param so 参数集合 
-	 * @return 数据列表 
-	 */
-	List<TbBusinessCar> getList(SoMap so);
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     *
+     * @param so 参数集合
+     * @return 数据列表
+     */
+    List<TbBusinessCar> getList(SoMap so);
 
 
     List<TbBusinessCar> searchPartCar(String carNo);
 
-	List<TbBusinessCar> findTheNoBusinessCar(String carNo);
+    List<TbBusinessCar> findTheNoBusinessCar(String carNo);
+
+    List<TbBusinessCar> searchOtherBusinessCar(String carNo);
 
-	List<TbBusinessCar> searchOtherBusinessCar(String carNo);
+    List<TbBusinessCar> findTodayRecord(@Param("carNo") String carNo, @Param("itemId") String itemId);
 }

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

@@ -107,11 +107,21 @@
             tb_business b
         where
             a.id = b.business_car_id
+            and a.business_type=1
             AND (b.total_money> b.pay_money or a.pay=0 or a.real_out_time is null)
             AND a.car_no LIKE CONCAT( '%', #{carNo}, '%' )
 
 
     </select>
+    <select id="findTodayRecord" resultType="com.pj.project.tb_business_car.TbBusinessCar">
+        SELECT a.* from tb_business_car a,tb_business b, tb_business_item c
+         where a.id=b.business_car_id
+         and b.id=c.business_id
+         and DATE_FORMAT(c.create_time,'%y-%m-%d')=DATE_FORMAT(now(),'%y-%m-%d')
+         and a.car_no=#{carNo}
+         and c.item_id=#{itemId};
+
+    </select>
 
 
 </mapper>

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

@@ -387,4 +387,8 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
     public List<TbBusinessCar> searchOtherBusinessCar(String carNo) {
        return tbBusinessCarMapper.searchOtherBusinessCar(carNo);
     }
+
+    public List<TbBusinessCar> findTodayRecord(String carNo, String itemId) {
+        return tbBusinessCarMapper.findTodayRecord(carNo,itemId);
+    }
 }

+ 3 - 1
sp-server/src/main/java/com/pj/project/tb_item_type/TbItemTypeService.java

@@ -3,6 +3,7 @@ package com.pj.project.tb_item_type;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.constants.RoleEnum;
@@ -72,7 +73,8 @@ public class TbItemTypeService extends ServiceImpl<TbItemTypeMapper, TbItemType>
                 list = list.stream().filter(tbItemType -> {
                     List<TbItem> items = tbItemService.getItemTypeById(tbItemType.getId());
                     List<String> businessTypeList = items.stream().map(TbItem::getBusinessType).collect(Collectors.toList());
-                    return businessTypeList.contains(tbCostomer.getType());
+                    List<String> typeList = StrUtil.splitTrim(tbCostomer.getType(), ",");
+                    return businessTypeList.stream().anyMatch(typeList::contains);
                 }).collect(Collectors.toList());
             }
         }