From 198454103f43263d9ce014806f768d3dcd6f6ccf Mon Sep 17 00:00:00 2001 From: kevin jiang Date: Wed, 20 May 2020 17:08:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StoreStaffController.java | 34 ++++++ .../store/service/StoreEmployeeService.java | 104 +++++++++++++++++- 2 files changed, 137 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/kiisoo/ic/store/controller/StoreStaffController.java b/src/main/java/com/kiisoo/ic/store/controller/StoreStaffController.java index 90ce332..72e4dd5 100644 --- a/src/main/java/com/kiisoo/ic/store/controller/StoreStaffController.java +++ b/src/main/java/com/kiisoo/ic/store/controller/StoreStaffController.java @@ -198,6 +198,23 @@ public class StoreStaffController extends BaseController { } } + /** + * 添加组织 + * @author dexiang.jiang + * @date 2020/05/20 14:52 + */ + @RequestMapping(value = "/region/add",method = RequestMethod.POST) + @ResponseBody + public Map addRegion(@RequestParam("name") String name, @RequestParam("code") String code) { + try { + boolean b = storeEmployeeService.addOrganizationalByRegion(name,code); + return data(b); + } catch (KiisooException e) { + log.error("添加组织", e); + return fail(e.getCode(),e.getMsg()); + } + } + /** * 添加组织 * @author dexiang.jiang @@ -215,6 +232,23 @@ public class StoreStaffController extends BaseController { } } + /** + * 添加组织 + * @author dexiang.jiang + * @date 2020/05/20 14:52 + */ + @RequestMapping(value = "/company/add/code",method = RequestMethod.POST) + @ResponseBody + public Map companyAddCode(@RequestParam("name") String name, @RequestParam("code") String code, @RequestParam("parentCode") String parentCode, @RequestParam("level") Long level) { + try { + boolean b = storeEmployeeService.addOrganizationalByCode(name,code, parentCode, level); + return data(b); + } catch (KiisooException e) { + log.error("添加组织", e); + return fail(e.getCode(),e.getMsg()); + } + } + /** * 添加店铺 * @author dexiang.jiang 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 a2def16..8a1e73b 100644 --- a/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java +++ b/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java @@ -949,6 +949,108 @@ public class StoreEmployeeService { return bsdResponse.getSuccess(); } + /** + * 添加组织 大区 + * @param name 名称 + * @param code 编码 + * @author dexiang.jiang + * @date 2020/05/20 14:57 + */ + @Transactional(rollbackFor = Exception.class) + public boolean addOrganizationalByRegion(String name, String code) throws KiisooException { + Map map = new HashMap<>(); + map.put("name", name); + map.put("code", code); + map.put("level", 1); + List list = retailCompanyMapper.selectByMap(map); + if(CollectionUtils.isNotEmpty(list) && list.size() > 0){ + throw new KiisooException(Constants.MSG_ORGANIZATIONAL_HAS, Constants.CODE_ORGANIZATIONAL_HAS); + } + + PrivilageOrganizational entity = new PrivilageOrganizational(); + entity.setName(name); + entity.setCode(code); + entity.setParentId(0L); + entity.setLevel(1L); + entity.setStatus(1L); + entity.setType(1L); + entity.setCreateBy(Constants.SYS_OPERATION); + entity.setUpdateBy(Constants.SYS_OPERATION); + entity.setCreateTime(new Date()); + entity.setUpdateTime(new Date()); + int b = retailCompanyMapper.insert(entity); + + return b > 0; + } + + /** + * 添加组织 + * @param name 名称 + * @param code 编码 + * @author dexiang.jiang + * @date 2020/05/20 14:57 + */ + @Transactional(rollbackFor = Exception.class) + public boolean addOrganizationalByCode(String name, String code, String parentCode, Long level) throws KiisooException { + Map map = new HashMap<>(); + map.put("name", name); + map.put("code", code); + map.put("level", level); + List list = retailCompanyMapper.selectByMap(map); + if(CollectionUtils.isNotEmpty(list) && list.size() > 0){ + throw new KiisooException(Constants.MSG_ORGANIZATIONAL_HAS, Constants.CODE_ORGANIZATIONAL_HAS); + } + + Map cMap = new HashMap<>(); + cMap.put("code", parentCode); + List companyList = retailCompanyMapper.selectByMap(cMap); + if(CollectionUtils.isEmpty(companyList)){ + throw new KiisooException(Constants.MSG_ORGANIZATIONAL_HAS, Constants.CODE_ORGANIZATIONAL_HAS); + } + + PrivilageOrganizational item = companyList.get(0); + + PrivilageOrganizational entity = new PrivilageOrganizational(); + entity.setName(name); + entity.setCode(code); + entity.setParentId(item.getId()); + entity.setLevel(level); + entity.setStatus(1L); + entity.setType(1L); + entity.setCreateBy(Constants.SYS_OPERATION); + entity.setUpdateBy(Constants.SYS_OPERATION); + entity.setCreateTime(new Date()); + entity.setUpdateTime(new Date()); + int b = retailCompanyMapper.insert(entity); + + if(level == 3){ + //添加客户多了2步骤 + Map domainEntityMap = new HashMap<>(); + domainEntityMap.put("name", name); + List domainList = privilageDomainDOMapper.selectByMap(domainEntityMap); + if(domainList.size() > 1){ + throw new KiisooException(Constants.MSG_DOMAIN_ENTITY_HAS, Constants.CODE_DOMAIN_ENTITY_HAS); + } + //添加域 + PrivilageDomainDO domainEntity = new PrivilageDomainDO(); + domainEntity.setName(name); + domainEntity.setStatus(1); + domainEntity.setCreateTime(new Date()); + domainEntity.setUpdateTime(new Date()); + domainEntity.setCreateBy(Constants.SYS_OPERATION); + domainEntity.setUpdateBy(Constants.SYS_OPERATION); + int b2 = privilageDomainDOMapper.insert(domainEntity); + //添加域和组织的关系 + PrivilageOrganizationalDomain orgDomainEntity = new PrivilageOrganizationalDomain(); + orgDomainEntity.setOrgId(entity.getId()); + orgDomainEntity.setDomainId(domainEntity.getId()); + int b3 = privilageOrganizationalDomainMapper.insert(orgDomainEntity); + return (b + b2 + b3) == 3; + }else{ + return b > 0; + } + } + /** * 添加组织 * @param name 名称 @@ -956,6 +1058,7 @@ public class StoreEmployeeService { * @author dexiang.jiang * @date 2020/05/20 14:57 */ + @Transactional(rollbackFor = Exception.class) public boolean addOrganizational(String name, String code, Long parentId, Long level) throws KiisooException { Map map = new HashMap<>(); map.put("name", name); @@ -1036,7 +1139,6 @@ public class StoreEmployeeService { Map domainMap = new HashMap<>(); domainMap.put("name", poiStore.getCustomerName()); - domainMap.put("code", poiStore.getCustomerCode()); List domainList = privilageDomainDOMapper.selectByMap(domainMap); if(CollectionUtils.isEmpty(domainList)){