From 49cae8a70e2c2c0755c193a9978b092873dd3eaa Mon Sep 17 00:00:00 2001 From: Caps <452713115@qq.com> Date: Mon, 27 Apr 2020 20:50:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E7=AE=A1=E7=90=86=E9=9B=B6?= =?UTF-8?q?=E5=94=AE=E5=85=AC=E5=8F=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kiisoo/ic/customer/CustomerService.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/kiisoo/ic/customer/CustomerService.java b/src/main/java/com/kiisoo/ic/customer/CustomerService.java index a9102de..ed162dc 100644 --- a/src/main/java/com/kiisoo/ic/customer/CustomerService.java +++ b/src/main/java/com/kiisoo/ic/customer/CustomerService.java @@ -199,7 +199,9 @@ public class CustomerService { opCustomerDOMapper.updateById(insertCustomer); if(poiStoreStaff != null){ //存在--1.处理客户导购关系。 - sellerCustomerRelation(opCustomer,turnBackDTOS.getEaCode(),poiStore.getId(),poiStoreStaff.getUserId()); + sellerCustomerRelation(opCustomer,turnBackDTOS.getEaCode(),poiStore.getStoreId(),poiStoreStaff.getUserId()); + }else { + storeCustomerRelation(opCustomer,poiStore.getStoreId()); } }else { log.info("客户信息不存在在就新增"); @@ -209,7 +211,9 @@ public class CustomerService { if(poiStoreStaff != null) { log.info("导购的信息没有就不添加导购客户的关系"); //添加关系 - sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(), poiStore.getId(), poiStoreStaff.getUserId()); + sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(), poiStore.getStoreId(), poiStoreStaff.getUserId()); + }else { + storeCustomerRelation(opCustomer,poiStore.getStoreId()); } } @@ -301,6 +305,35 @@ public class CustomerService { } } + private void storeCustomerRelation(OpCustomer opCustomer,long shopId){ + QueryWrapper wrapper1 = new QueryWrapper<>(); + wrapper1.eq("customer_id",opCustomer.getId()).eq("store_id",shopId).last("limit 1"); + OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1); + if(null == opSellerCustomerRelation){ + //不存在就添加 + OpSellerCustomerRelation insertRelation = new OpSellerCustomerRelation(); + insertRelation.setCreateTime(new Date()); + insertRelation.setUpdateTime(new Date()); + insertRelation.setCustomerId(opCustomer.getId()); + insertRelation.setStoreId(shopId); + insertRelation.setCreateBy(Constants.SYS_OPERATION); + insertRelation.setUpdateBy(Constants.SYS_OPERATION); + + //判断是否有效 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("customer_id",opCustomer.getId()).last("limit 1"); + OpSellerCustomerRelation op = opSellerCustomerRelationDOMapper.selectOne(wrapper); + if(op == null){ + //有效 + insertRelation.setType(1); + }else { + //无效 + insertRelation.setType(2); + } + opSellerCustomerRelationDOMapper.insert(insertRelation); + } + } + /** * 根据店铺id找到顾客信息 * @param shopIds