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); }