From 02e257b996510409f299905ce1cb19204c6b653e Mon Sep 17 00:00:00 2001 From: kevin jiang Date: Fri, 22 May 2020 18:58:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=9A=E5=BA=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0cp=5Fuser=5Fid=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=88=B0op=5Fseller=5Fcustomer=5Frelation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kiisoo/ic/customer/CustomerService.java | 3 ++ .../entity/OpSellerCustomerRelation.java | 4 +++ .../store/service/PoiStoreStaffService.java | 2 ++ .../store/service/StoreEmployeeService.java | 31 ++++++++++--------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/kiisoo/ic/customer/CustomerService.java b/src/main/java/com/kiisoo/ic/customer/CustomerService.java index 702b8b1..84f6ebc 100644 --- a/src/main/java/com/kiisoo/ic/customer/CustomerService.java +++ b/src/main/java/com/kiisoo/ic/customer/CustomerService.java @@ -387,6 +387,7 @@ public class CustomerService { insertRelation.setUserId(sellerId); insertRelation.setCreateBy(Constants.SYS_OPERATION); insertRelation.setUpdateBy(Constants.SYS_OPERATION); + insertRelation.setCpUserId(opCustomer.getCpUserId()); //判断是否有效 QueryWrapper wrapper = new QueryWrapper<>(); @@ -409,6 +410,7 @@ public class CustomerService { opSellerCustomerRelation.setUserId(sellerId); opSellerCustomerRelation.setCreateBy(Constants.SYS_OPERATION); opSellerCustomerRelation.setUpdateBy(Constants.SYS_OPERATION); + opSellerCustomerRelation.setCpUserId(opCustomer.getCpUserId()); opSellerCustomerRelationDOMapper.updateById(opSellerCustomerRelation); } } @@ -428,6 +430,7 @@ public class CustomerService { insertRelation.setUserId(0L); insertRelation.setCreateBy(Constants.SYS_OPERATION); insertRelation.setUpdateBy(Constants.SYS_OPERATION); + insertRelation.setCpUserId(opCustomer.getCpUserId()); //判断是否有效 QueryWrapper wrapper = new QueryWrapper<>(); diff --git a/src/main/java/com/kiisoo/ic/customer/entity/OpSellerCustomerRelation.java b/src/main/java/com/kiisoo/ic/customer/entity/OpSellerCustomerRelation.java index 455afe4..9867cfb 100644 --- a/src/main/java/com/kiisoo/ic/customer/entity/OpSellerCustomerRelation.java +++ b/src/main/java/com/kiisoo/ic/customer/entity/OpSellerCustomerRelation.java @@ -61,4 +61,8 @@ public class OpSellerCustomerRelation { */ private String updateBy; + /** + * 企业微信账号 + */ + private String cpUserId; } diff --git a/src/main/java/com/kiisoo/ic/store/service/PoiStoreStaffService.java b/src/main/java/com/kiisoo/ic/store/service/PoiStoreStaffService.java index 2da3a6a..89e5757 100644 --- a/src/main/java/com/kiisoo/ic/store/service/PoiStoreStaffService.java +++ b/src/main/java/com/kiisoo/ic/store/service/PoiStoreStaffService.java @@ -37,6 +37,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; @@ -237,6 +238,7 @@ public class PoiStoreStaffService { * 添加店铺人员 * @param poiStoreStaffVO */ + @Transactional(rollbackFor = Exception.class) public String addStaff(PoiStoreStaffVO poiStoreStaffVO) throws Exception { String staffCode = poiStoreStaffVO.getStaffCode(); String mobil = poiStoreStaffVO.getMobil(); diff --git a/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java b/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java index 2853b4f..bd7c260 100644 --- a/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java +++ b/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java @@ -1085,17 +1085,17 @@ public class StoreEmployeeService { QueryWrapper cpUserRelationQwByStore = new QueryWrapper<>(); cpUserRelationQwByStore.eq("store_id",poiStore.getId()).last("limit 1"); privilageCpUserStoreDO = privilageCpUserStoreDOMapper.selectOne(cpUserRelationQwByStore); - if (privilageCpUserStoreDO != null){ - throw new KiisooException(Constants.MSG_DOMAIN_ENTITY_HAS, Constants.CODE_DOMAIN_ENTITY_HAS); - } +// if (privilageCpUserStoreDO != null){ +// throw new KiisooException(Constants.MSG_DOMAIN_ENTITY_HAS, Constants.CODE_DOMAIN_ENTITY_HAS); +// } if (privilageCpUserDO != null){ //查询关系是否存在 QueryWrapper cpUserRelationQwByCpUser = new QueryWrapper<>(); cpUserRelationQwByCpUser.eq("cp_user_id",privilageCpUserDO.getId()).last("limit 1"); privilageCpUserStoreDO = privilageCpUserStoreDOMapper.selectOne(cpUserRelationQwByCpUser); - if (privilageCpUserStoreDO != null){ - throw new KiisooException(Constants.MSG_DOMAIN_ENTITY_HAS, Constants.CODE_DOMAIN_ENTITY_HAS); - } +// if (privilageCpUserStoreDO != null){ +// throw new KiisooException(Constants.MSG_DOMAIN_ENTITY_HAS, Constants.CODE_DOMAIN_ENTITY_HAS); +// } privilageCpUserDO.setStatus(1); privilageCpUserDO.setName(name); privilageCpUserDO.setAlias(alias); @@ -1113,12 +1113,15 @@ public class StoreEmployeeService { privilageCpUserDO.setPosition("店长"); privilageCpUserDOMapper.insert(privilageCpUserDO); } - privilageCpUserStoreDO = new PrivilageCpUserStoreDO(); - privilageCpUserStoreDO.setStoreId(poiStore.getId()); - privilageCpUserStoreDO.setCpUserId(privilageCpUserDO.getId()); - int insert = privilageCpUserStoreDOMapper.insert(privilageCpUserStoreDO); - if (insert == 0){ - throw new KiisooException(Constants.MSG_INSERT_ERROR, Constants.CODE_INSERT_ERROR); + + if(null == privilageCpUserStoreDO){ + privilageCpUserStoreDO = new PrivilageCpUserStoreDO(); + privilageCpUserStoreDO.setStoreId(poiStore.getId()); + privilageCpUserStoreDO.setCpUserId(privilageCpUserDO.getId()); + int insert = privilageCpUserStoreDOMapper.insert(privilageCpUserStoreDO); + if (insert == 0){ + throw new KiisooException(Constants.MSG_INSERT_ERROR, Constants.CODE_INSERT_ERROR); + } } SaveAccountInput saveAccountInput = new SaveAccountInput(); @@ -1274,11 +1277,11 @@ public class StoreEmployeeService { public boolean addStoreStaff(PoiStoreStaffVO poiStoreStaffVO) throws KiisooException { //查看店铺 - if (poiStoreStaffVO.getStoreCode() != null) { + if (poiStoreStaffVO.getStoreCode() == null) { throw new KiisooException(Constants.MSG_STORE_NO, Constants.CODE_STORE_NO); } - if (poiStoreStaffVO.getStaffCode() != null) { + if (poiStoreStaffVO.getStaffCode() == null) { throw new KiisooException(Constants.MSG_STAFF_NO, Constants.CODE_STORE_NO); }