|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
import com.alibaba.excel.util.StringUtils;
|
|
import com.alibaba.excel.util.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
|
|
+import com.gree.mall.manager.bean.admin.AdminWebsitNewBean;
|
|
import com.gree.mall.manager.bean.admin.AdminWebsitTree;
|
|
import com.gree.mall.manager.bean.admin.AdminWebsitTree;
|
|
import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
|
|
import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
|
|
import com.gree.mall.manager.exception.RemoteServiceException;
|
|
import com.gree.mall.manager.exception.RemoteServiceException;
|
|
@@ -42,6 +43,8 @@ public class AdminWebsitLogic {
|
|
CommonLogic commonLogic;
|
|
CommonLogic commonLogic;
|
|
@Autowired
|
|
@Autowired
|
|
StorageService storageService;
|
|
StorageService storageService;
|
|
|
|
+ @Autowired
|
|
|
|
+ AdminWebsitPayConfigService adminWebsitPayConfigService;
|
|
// @Autowired
|
|
// @Autowired
|
|
// EnterpriseWechatWorkerLogic enterpriseWechatWorkerLogic;
|
|
// EnterpriseWechatWorkerLogic enterpriseWechatWorkerLogic;
|
|
|
|
|
|
@@ -99,39 +102,79 @@ public class AdminWebsitLogic {
|
|
* 新增部门
|
|
* 新增部门
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
- public void add(AdminWebsit adminWebsit, HttpServletRequest request) throws WxErrorException, RemoteServiceException {
|
|
|
|
|
|
+ public void add(AdminWebsitNewBean adminWebsit, HttpServletRequest request) throws WxErrorException, RemoteServiceException {
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
|
|
Integer count = adminWebsitService.lambdaQuery()
|
|
Integer count = adminWebsitService.lambdaQuery()
|
|
- .eq(StringUtils.isNotBlank(adminUser.getCompanyWechatId()),AdminWebsit::getCompanyWechatId,adminUser.getCompanyWechatId())
|
|
|
|
|
|
+ .eq(StringUtils.isNotBlank(adminUser.getCompanyWechatId()), AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
.eq(AdminWebsit::getName, adminWebsit.getName())
|
|
.eq(AdminWebsit::getName, adminWebsit.getName())
|
|
.count();
|
|
.count();
|
|
- if(count > 0){
|
|
|
|
- throw new RemoteServiceException("部门名称已存在");
|
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ throw new RemoteServiceException("名称已存在");
|
|
}
|
|
}
|
|
AdminWebsit parent = adminWebsitService.getById(adminWebsit.getParentId());
|
|
AdminWebsit parent = adminWebsitService.getById(adminWebsit.getParentId());
|
|
- if(parent == null){
|
|
|
|
- throw new RemoteServiceException("请选择父部门");
|
|
|
|
- }
|
|
|
|
- if(StringUtils.isNotBlank(parent.getCompanyWechatId())) {
|
|
|
|
- //最多3个部门
|
|
|
|
- final int max = 3;
|
|
|
|
- Integer count1 = adminWebsitService.lambdaQuery()
|
|
|
|
- .eq(AdminWebsit::getCompanyWechatId, parent.getCompanyWechatId())
|
|
|
|
- .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey()).count();
|
|
|
|
- if(count1 >= max){
|
|
|
|
- throw new RemoteServiceException("创建网点数量已达上限3,请联系相关人员");
|
|
|
|
- }
|
|
|
|
|
|
+ if (Objects.isNull(parent)) {
|
|
|
|
+ throw new RemoteServiceException("请选择上级");
|
|
|
|
+ }
|
|
|
|
+ if (parent.getType().equals(AdminWebsitTypeEnum.A.getKey()) && adminUser.getType() != 2) {
|
|
|
|
+ throw new RemoteServiceException("非平台账号不能创建商户");
|
|
|
|
+ }
|
|
|
|
+ if (parent.getType().equals(AdminWebsitTypeEnum.B.getKey()) && adminUser.getType() == 0) {
|
|
|
|
+ throw new RemoteServiceException("网点账号不能创建网点");
|
|
|
|
+ }
|
|
|
|
+// if(StringUtils.isNotBlank(parent.getCompanyWechatId())) {
|
|
|
|
+// //最多3个部门
|
|
|
|
+// final int max = 3;
|
|
|
|
+// Integer count1 = adminWebsitService.lambdaQuery()
|
|
|
|
+// .eq(AdminWebsit::getCompanyWechatId, parent.getCompanyWechatId())
|
|
|
|
+// .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey()).count();
|
|
|
|
+// if(count1 >= max){
|
|
|
|
+// throw new RemoteServiceException("创建网点数量已达上限3,请联系相关人员");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ if (parent.getType().equals(AdminWebsitTypeEnum.A.getKey())) {
|
|
|
|
+ adminWebsit.setType(AdminWebsitTypeEnum.B.getKey());
|
|
|
|
+ } else if (parent.getType().equals(AdminWebsitTypeEnum.B.getKey())) {
|
|
|
|
+ adminWebsit.setType(AdminWebsitTypeEnum.C.getKey());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (adminWebsit.getType().equals(AdminWebsitTypeEnum.C.getKey())
|
|
|
|
+ && adminWebsit.getIsUseAllinpay()
|
|
|
|
+ && CollectionUtil.isEmpty(adminWebsit.getPayConfigList())) {
|
|
|
|
+ throw new RemoteServiceException("支付配置不能为空");
|
|
}
|
|
}
|
|
|
|
|
|
- adminWebsit.setType(AdminWebsitTypeEnum.C.getKey());
|
|
|
|
adminWebsit.setCompanyWechatId(parent.getCompanyWechatId());
|
|
adminWebsit.setCompanyWechatId(parent.getCompanyWechatId());
|
|
adminWebsit.setCompanyWechatName(parent.getCompanyWechatName());
|
|
adminWebsit.setCompanyWechatName(parent.getCompanyWechatName());
|
|
adminWebsit.setWebsitId(IdWorker.getIdStr());
|
|
adminWebsit.setWebsitId(IdWorker.getIdStr());
|
|
adminWebsit.setWebsitNumber(adminWebsit.getWebsitId());
|
|
adminWebsit.setWebsitNumber(adminWebsit.getWebsitId());
|
|
adminWebsit.insert();
|
|
adminWebsit.insert();
|
|
|
|
|
|
- reloadJoinCode(adminWebsit.getCompanyWechatId(),adminWebsit.getJoinCode());
|
|
|
|
|
|
+ if (adminWebsit.getIsUseAllinpay()
|
|
|
|
+ && CollectionUtil.isNotEmpty(adminWebsit.getPayConfigList())) {
|
|
|
|
+ for (int i = 0; i < adminWebsit.getPayConfigList().size(); i++) {
|
|
|
|
+ AdminWebsitPayConfig payConfig = adminWebsit.getPayConfigList().get(i);
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getName())) {
|
|
|
|
+ throw new RemoteServiceException("第" + (i+1) + "行, 商户名称不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getType())) {
|
|
|
|
+ throw new RemoteServiceException("第" + (i+1) + "行, 请选择类别");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getMchNo())) {
|
|
|
|
+ throw new RemoteServiceException("第" + (i+1) + "行, 通联商户号不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getAppid())) {
|
|
|
|
+ throw new RemoteServiceException("第" + (i+1) + "行, 通联商户appid不能为空");
|
|
|
|
+ }
|
|
|
|
+ payConfig.setCompanyWechatId(adminWebsit.getCompanyWechatId())
|
|
|
|
+ .setCompanyWechatName(adminWebsit.getCompanyWechatName())
|
|
|
|
+ .setWebsitId(adminWebsit.getWebsitId());
|
|
|
|
+ }
|
|
|
|
+ adminWebsitPayConfigService.saveBatch(adminWebsit.getPayConfigList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ reloadJoinCode(adminWebsit.getCompanyWechatId(), adminWebsit.getJoinCode());
|
|
|
|
|
|
// 初始化辅材配件默认仓
|
|
// 初始化辅材配件默认仓
|
|
initMaterialStorage(adminUser, adminWebsit);
|
|
initMaterialStorage(adminUser, adminWebsit);
|
|
@@ -167,40 +210,52 @@ public class AdminWebsitLogic {
|
|
* 编辑部门
|
|
* 编辑部门
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
- public void update(AdminWebsit adminWebsit,HttpServletRequest request) throws RemoteServiceException, WxErrorException {
|
|
|
|
|
|
+ public void update(AdminWebsitNewBean adminWebsit,HttpServletRequest request) throws RemoteServiceException, WxErrorException {
|
|
|
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
|
|
Integer count = adminWebsitService.lambdaQuery()
|
|
Integer count = adminWebsitService.lambdaQuery()
|
|
- .ne(AdminWebsit::getWebsitId,adminWebsit.getWebsitId())
|
|
|
|
- .eq(StringUtils.isNotBlank(adminUser.getCompanyWechatId()),AdminWebsit::getCompanyWechatId,adminUser.getCompanyWechatId())
|
|
|
|
|
|
+ .ne(AdminWebsit::getWebsitId, adminWebsit.getWebsitId())
|
|
|
|
+ .eq(StringUtils.isNotBlank(adminUser.getCompanyWechatId()), AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
.eq(AdminWebsit::getName, adminWebsit.getName())
|
|
.eq(AdminWebsit::getName, adminWebsit.getName())
|
|
.count();
|
|
.count();
|
|
- if(count > 0){
|
|
|
|
- throw new RemoteServiceException("部门名称或部门编号已存在");
|
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ throw new RemoteServiceException("名称或编号已存在");
|
|
}
|
|
}
|
|
- if(adminWebsit.getParentId().equals("0")){
|
|
|
|
- throw new RemoteServiceException("请选择父部门");
|
|
|
|
|
|
+ if (adminWebsit.getParentId().equals("0")) {
|
|
|
|
+ throw new RemoteServiceException("请选择上级");
|
|
}
|
|
}
|
|
AdminWebsit parent = adminWebsitService.getById(adminWebsit.getParentId());
|
|
AdminWebsit parent = adminWebsitService.getById(adminWebsit.getParentId());
|
|
- if(parent != null && parent.getType().equals(AdminWebsitTypeEnum.B.getKey())){
|
|
|
|
- adminWebsit.setType(AdminWebsitTypeEnum.C.getKey());
|
|
|
|
|
|
+ if (Objects.isNull(parent)) {
|
|
|
|
+ throw new RemoteServiceException("请选择上级");
|
|
|
|
+ }
|
|
|
|
+ if (parent.getType().equals(AdminWebsitTypeEnum.A.getKey()) && adminUser.getType() != 2) {
|
|
|
|
+ throw new RemoteServiceException("非平台账号不能创建商户");
|
|
}
|
|
}
|
|
- if(StringUtils.equals(adminWebsit.getWebsitId(),adminWebsit.getParentId())){
|
|
|
|
- throw new RemoteServiceException("父级部门不可以是自己");
|
|
|
|
|
|
+ if (parent.getType().equals(AdminWebsitTypeEnum.B.getKey()) && adminUser.getType() == 0) {
|
|
|
|
+ throw new RemoteServiceException("网点账号不能创建网点");
|
|
}
|
|
}
|
|
|
|
+ if (StringUtils.equals(adminWebsit.getWebsitId(), adminWebsit.getParentId())) {
|
|
|
|
+ throw new RemoteServiceException("上级不允许为自己");
|
|
|
|
+ }
|
|
|
|
+ if (parent.getType().equals(AdminWebsitTypeEnum.A.getKey())) {
|
|
|
|
+ adminWebsit.setType(AdminWebsitTypeEnum.B.getKey());
|
|
|
|
+ } else if (parent.getType().equals(AdminWebsitTypeEnum.B.getKey())) {
|
|
|
|
+ adminWebsit.setType(AdminWebsitTypeEnum.C.getKey());
|
|
|
|
+ }
|
|
|
|
+
|
|
adminWebsit.updateById();
|
|
adminWebsit.updateById();
|
|
|
|
|
|
AdminWebsit old = adminWebsitService.getById(adminWebsit.getWebsitId());
|
|
AdminWebsit old = adminWebsitService.getById(adminWebsit.getWebsitId());
|
|
//workWechatLogic.updateOrganization(adminWebsit.getWebsitId(),adminWebsit.getName(),adminWebsit.getParentId(),adminUser.getAdminCompanyWechat());
|
|
//workWechatLogic.updateOrganization(adminWebsit.getWebsitId(),adminWebsit.getName(),adminWebsit.getParentId(),adminUser.getAdminCompanyWechat());
|
|
- if(old.getType().equals(AdminWebsitTypeEnum.B.getKey())){
|
|
|
|
|
|
+ if (old.getType().equals(AdminWebsitTypeEnum.B.getKey())) {
|
|
adminCompanyWechatService.lambdaUpdate()
|
|
adminCompanyWechatService.lambdaUpdate()
|
|
- .set(AdminCompanyWechat::getLinkPhone,adminWebsit.getWebsitPhone())
|
|
|
|
- .eq(AdminCompanyWechat::getCompanyWechatId,old.getCompanyWechatId()).update();
|
|
|
|
|
|
+ .set(AdminCompanyWechat::getLinkPhone, adminWebsit.getWebsitPhone())
|
|
|
|
+ .eq(AdminCompanyWechat::getCompanyWechatId, old.getCompanyWechatId()).update();
|
|
}
|
|
}
|
|
//刷新成员部门名称
|
|
//刷新成员部门名称
|
|
// enterpriseWechatWorkerLogic.reloadEnterpriseWechatName(adminWebsit,request);
|
|
// enterpriseWechatWorkerLogic.reloadEnterpriseWechatName(adminWebsit,request);
|
|
- reloadJoinCode(old.getCompanyWechatId(),adminWebsit.getJoinCode());
|
|
|
|
|
|
+ reloadJoinCode(old.getCompanyWechatId(), adminWebsit.getJoinCode());
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -252,9 +307,17 @@ public class AdminWebsitLogic {
|
|
* 详情
|
|
* 详情
|
|
* @param id
|
|
* @param id
|
|
*/
|
|
*/
|
|
- public AdminWebsit detail(String id){
|
|
|
|
|
|
+ public AdminWebsitNewBean detail(String id){
|
|
AdminWebsit adminWebsit = adminWebsitService.getById(id);
|
|
AdminWebsit adminWebsit = adminWebsitService.getById(id);
|
|
- return adminWebsit;
|
|
|
|
|
|
+ AdminWebsitNewBean bean = new AdminWebsitNewBean();
|
|
|
|
+ BeanUtils.copyProperties(adminWebsit, bean);
|
|
|
|
+ if (bean.getIsUseAllinpay() && bean.getType().equals(AdminWebsitTypeEnum.C.getKey())) {
|
|
|
|
+ final List<AdminWebsitPayConfig> payConfigList = adminWebsitPayConfigService.lambdaQuery()
|
|
|
|
+ .eq(AdminWebsitPayConfig::getWebsitId, bean.getWebsitId())
|
|
|
|
+ .list();
|
|
|
|
+ bean.setPayConfigList(payConfigList);
|
|
|
|
+ }
|
|
|
|
+ return bean;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -299,8 +362,32 @@ public class AdminWebsitLogic {
|
|
return collect;
|
|
return collect;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void savePayConfig(AdminWebsitPayConfig payConfig, HttpServletRequest request) {
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getCompanyWechatId())) {
|
|
|
|
+ throw new RemoteServiceException("商户信息不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getCompanyWechatName())) {
|
|
|
|
+ throw new RemoteServiceException("商户信息不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getWebsitId())) {
|
|
|
|
+ throw new RemoteServiceException("网点编号不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getName())) {
|
|
|
|
+ throw new RemoteServiceException("商户名称不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getType())) {
|
|
|
|
+ throw new RemoteServiceException("请选择类别");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getMchNo())) {
|
|
|
|
+ throw new RemoteServiceException("通联商户号不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(payConfig.getAppid())) {
|
|
|
|
+ throw new RemoteServiceException("通联商户appid不能为空");
|
|
|
|
+ }
|
|
|
|
+ payConfig.insertOrUpdate();
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ public void deletePayConfig(String id, HttpServletRequest request) {
|
|
|
|
+ adminWebsitPayConfigService.removeById(id);
|
|
|
|
+ }
|
|
}
|
|
}
|