From f361810945b33f5101f22ab26955466068b35fdd Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Sat, 3 Apr 2021 17:42:22 +0800 Subject: [PATCH] 1 --- .../bweb/controller/HighAgentController.java | 89 +++++++++++++++---- .../bweb/controller/HighOrderController.java | 4 +- .../com/hai/service/HighAgentService.java | 5 +- .../service/impl/BsCompanyServiceImpl.java | 2 +- .../service/impl/HighAgentServiceImpl.java | 27 +++++- 5 files changed, 101 insertions(+), 26 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighAgentController.java index 0c83d0eb..7d25e511 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighAgentController.java @@ -5,6 +5,7 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; import com.hai.common.utils.MemberValidateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.model.HighAgentModel; @@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.Date; /** * @Auther: 袁野 @@ -62,8 +64,7 @@ public class HighAgentController { throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); } - if (highAgentModel.getId() == null - || StringUtils.isBlank(highAgentModel.getAgentName()) + if (StringUtils.isBlank(highAgentModel.getAgentName()) || StringUtils.isBlank(highAgentModel.getAgentAddress()) || StringUtils.isBlank(highAgentModel.getAgentUser()) || StringUtils.isBlank(highAgentModel.getAgentPhone()) @@ -85,6 +86,23 @@ public class HighAgentController { throw ErrorHelp.genException(SysCode.System, ErrorCode.AGENT_NAME, ""); } + // 校验账户手机号 + if (!MemberValidateUtil.validatePhone(highAgentModel.getSecUser().getTelephone())) { + log.error("BsStudentController --> insertMerchant() error!", "请输入正确的电话号码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); + } + + // 校验账号手机号是否存在 + if (secUserService.findByPhone(highAgentModel.getSecUser().getTelephone()) != null) { + log.error("BsStudentController --> insertMerchant() error!", "电话号码已被使用"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); + } + + highAgentModel.setStatus(1); // 状态:0:不可用,1:可用 + highAgentModel.setCreateTime(new Date()); + highAgentModel.setOperatorId(userInfoModel.getSecUser().getId()); + highAgentModel.setOperatorName(userInfoModel.getSecUser().getUserName()); + highAgentService.insertAgentMsg(highAgentModel); return ResponseMsgUtil.success("新增成功"); @@ -97,23 +115,60 @@ public class HighAgentController { @RequestMapping(value = "/updateAgent", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "修改代理商") - public ResponseData updateAgentMsg(@RequestBody HighAgentModel highAgentMsgModel, HttpServletRequest request) { + public ResponseData updateAgentMsg(@RequestBody HighAgentModel highAgentModel, HttpServletRequest request) { try { -// if ( -// reqBody.getId() == null -// ) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); -// } -// -// HighUser highUser = highUserService.findByUserId(reqBody.getId()); -// -// if (highUser == null) { -// log.error("HighUserController --> updateUser() error!"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_USER_ERROR, ""); -// } -// -// highUserService.updateUser(reqBody); + //发布人员 + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (userInfoModel.getMerchant() == null) { + log.error("HighMerchantController -> insertAgent() error!","该主角色没有权限"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); + } + + if (highAgentModel.getId() == null + || StringUtils.isBlank(highAgentModel.getAgentName()) + || StringUtils.isBlank(highAgentModel.getAgentAddress()) + || StringUtils.isBlank(highAgentModel.getAgentUser()) + || StringUtils.isBlank(highAgentModel.getAgentPhone()) + || StringUtils.isBlank(highAgentModel.getSecUser().getPassword()) + || StringUtils.isBlank(highAgentModel.getSecUser().getTelephone()) + ) { + log.error("HighMerchantController -> insertAgent() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + + + // 校验账号手机号是否存在 + if (secUserService.findByPhone(highAgentModel.getSecUser().getTelephone()) != null) { + log.error("HighMerchantStoreController --> insertAgent() error!", "联系方式已被使用"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.TEL_EXISTED, ""); + } + + if (highAgentService.findByAgentName(highAgentModel.getAgentName())) { + log.error("HighMerchantStoreController --> insertAgent() error!", "代理商名称已存在"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.AGENT_NAME, ""); + } + + // 校验账户手机号 + if (!MemberValidateUtil.validatePhone(highAgentModel.getSecUser().getTelephone())) { + log.error("BsStudentController --> insertMerchant() error!", "请输入正确的电话号码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); + } + + // 校验账号手机号是否存在 + if (secUserService.findByPhone(highAgentModel.getSecUser().getTelephone()) != null) { + log.error("BsStudentController --> insertMerchant() error!", "电话号码已被使用"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); + } + + highAgentModel.setStatus(1); // 状态:0:不可用,1:可用 + highAgentModel.setCreateTime(new Date()); + highAgentModel.setOperatorId(userInfoModel.getSecUser().getId()); + highAgentModel.setOperatorName(userInfoModel.getSecUser().getUserName()); + highAgentService.insertAgentMsg(highAgentModel); + return ResponseMsgUtil.success("修改成功"); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java index 25da943b..59f2a61d 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java @@ -97,10 +97,10 @@ public class HighOrderController { } } - @RequestMapping(value = "/getOrderList", method = RequestMethod.GET) + @RequestMapping(value = "/getOrderBList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取用户订单") - public ResponseData getOrderList( + public ResponseData getOrderBList( @RequestParam(name = "orderStatus", required = false) Integer orderStatus, @RequestParam(name = "orderNo", required = false) String orderNo, @RequestParam(name = "memPhone", required = false) String memPhone, diff --git a/hai-service/src/main/java/com/hai/service/HighAgentService.java b/hai-service/src/main/java/com/hai/service/HighAgentService.java index 6e1f7dc1..28ebc278 100644 --- a/hai-service/src/main/java/com/hai/service/HighAgentService.java +++ b/hai-service/src/main/java/com/hai/service/HighAgentService.java @@ -1,6 +1,7 @@ package com.hai.service; import com.hai.entity.HighAgent; +import com.hai.model.HighAgentModel; import java.util.List; import java.util.Map; @@ -58,7 +59,7 @@ public interface HighAgentService { * @param: [highUser] 用户信息 * @return: com.hai.entity.HighAgentMsg */ - void updateAgentMsg(HighAgent highAgent); + void updateAgentMsg(HighAgentModel highAgentModel); /** * @@ -69,6 +70,6 @@ public interface HighAgentService { * @param: [highUser] 用户信息 * @return: com.hai.entity.HighAgentMsg */ - void insertAgentMsg(HighAgent highAgent); + void insertAgentMsg(HighAgentModel highAgentModel) throws Exception ; } diff --git a/hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java index 5e8dc888..35498ba7 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java @@ -61,7 +61,7 @@ public class BsCompanyServiceImpl implements BsCompanyService { bsOrganizationMapper.insert(secOrganization); // 保存公司主角色 secUser.setCompanyId(secCompany.getId()); - secUser.setObjectType(1); + secUser.setObjectType(5); secUser.setObjectId(secCompany.getId()); secUser.setOrganizationId(secOrganization.getId()); secUserMapper.insert(secUser); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighAgentServiceImpl.java index d5d32cb0..50710a25 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighAgentServiceImpl.java @@ -1,13 +1,17 @@ package com.hai.service.impl; +import com.hai.common.utils.MD5Util; import com.hai.dao.HighAgentMapper; import com.hai.entity.HighAgent; import com.hai.entity.HighAgentExample; +import com.hai.model.HighAgentModel; import com.hai.service.HighAgentService; +import com.hai.service.SecUserService; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.Date; import java.util.List; import java.util.Map; @@ -22,6 +26,9 @@ public class HighAgentServiceImpl implements HighAgentService { @Resource private HighAgentMapper highAgentMapper; + @Resource + private SecUserService secUserService; + @Override public List getListAgentMsg(Map map) throws Exception { @@ -54,12 +61,24 @@ public class HighAgentServiceImpl implements HighAgentService { } @Override - public void updateAgentMsg(HighAgent highAgent) { - highAgentMapper.updateByPrimaryKey(highAgent); + public void updateAgentMsg(HighAgentModel highAgentModel) { + highAgentMapper.updateByPrimaryKey(highAgentModel); } @Override - public void insertAgentMsg(HighAgent highAgent) { - highAgentMapper.insert(highAgent); + public void insertAgentMsg(HighAgentModel highAgentModel) throws Exception { + highAgentMapper.insert(highAgentModel); + + highAgentModel.getSecUser().setUserName(highAgentModel.getAgentName()); + highAgentModel.getSecUser().setLoginName(highAgentModel.getSecUser().getTelephone()); + highAgentModel.getSecUser().setPassword(MD5Util.encode(highAgentModel.getSecUser().getPassword().getBytes())); + highAgentModel.getSecUser().setAdminFlag(1); + highAgentModel.getSecUser().setStatus(1); + highAgentModel.getSecUser().setRoleId(6L); + highAgentModel.getSecUser().setObjectType(4); + highAgentModel.getSecUser().setObjectId(highAgentModel.getId()); + highAgentModel.getSecUser().setCreateTime(new Date()); + highAgentModel.getSecUser().setUpdateTime(new Date()); + secUserService.addUser(highAgentModel.getSecUser()); } }