|
|
|
@ -1,5 +1,7 @@ |
|
|
|
|
package com.bweb.controller; |
|
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
@ -8,6 +10,9 @@ 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.entity.HighAgent; |
|
|
|
|
import com.hai.entity.HighUser; |
|
|
|
|
import com.hai.entity.SecUser; |
|
|
|
|
import com.hai.model.HighAgentModel; |
|
|
|
|
import com.hai.model.ResponseData; |
|
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
@ -18,16 +23,18 @@ import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Auther: 袁野 |
|
|
|
@ -59,8 +66,8 @@ public class HighAgentController { |
|
|
|
|
//发布人员
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
if (userInfoModel.getMerchant() == null) { |
|
|
|
|
log.error("HighMerchantController -> insertAgent() error!","该主角色没有权限"); |
|
|
|
|
if (userInfoModel.getBsCompany() == null) { |
|
|
|
|
log.error("HighAgentController -> insertAgent() error!","该主角色没有权限"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -69,34 +76,24 @@ public class HighAgentController { |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getAgentUser()) |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getAgentPhone()) |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getSecUser().getPassword()) |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getSecUser().getTelephone()) |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getSecUser().getLoginName()) |
|
|
|
|
) { |
|
|
|
|
log.error("HighMerchantController -> insertAgent() error!","参数错误"); |
|
|
|
|
log.error("HighAgentController -> 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 (secUserService.findByLoginName(highAgentModel.getSecUser().getLoginName()) != null) { |
|
|
|
|
log.error("HighAgentController --> insertAgent() error!", "用户名已存在"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_LOGIN_NAME_IS_EXIST_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (highAgentService.findByAgentName(highAgentModel.getAgentName())) { |
|
|
|
|
log.error("HighMerchantStoreController --> insertAgent() error!", "代理商名称已存在"); |
|
|
|
|
log.error("HighAgentController --> 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()); |
|
|
|
@ -115,14 +112,14 @@ public class HighAgentController { |
|
|
|
|
@RequestMapping(value = "/updateAgent", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "修改代理商") |
|
|
|
|
public ResponseData updateAgentMsg(@RequestBody HighAgentModel highAgentModel, HttpServletRequest request) { |
|
|
|
|
public ResponseData updateAgent(@RequestBody HighAgentModel highAgentModel, HttpServletRequest request) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
//发布人员
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
if (userInfoModel.getMerchant() == null) { |
|
|
|
|
log.error("HighMerchantController -> insertAgent() error!","该主角色没有权限"); |
|
|
|
|
if (userInfoModel.getBsCompany() == null) { |
|
|
|
|
log.error("HighAgentController -> insertAgent() error!","该主角色没有权限"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -132,51 +129,132 @@ public class HighAgentController { |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getAgentUser()) |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getAgentPhone()) |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getSecUser().getPassword()) |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getSecUser().getTelephone()) |
|
|
|
|
|| StringUtils.isBlank(highAgentModel.getSecUser().getLoginName()) |
|
|
|
|
) { |
|
|
|
|
log.error("HighMerchantController -> insertAgent() error!","参数错误"); |
|
|
|
|
log.error("HighAgentController -> insertAgent() error!","参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HighAgent highAgent = highAgentService.findByAgentMsgId(highAgentModel.getId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验账号手机号是否存在
|
|
|
|
|
if (secUserService.findByPhone(highAgentModel.getSecUser().getTelephone()) != null) { |
|
|
|
|
log.error("HighMerchantStoreController --> insertAgent() error!", "联系方式已被使用"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.TEL_EXISTED, ""); |
|
|
|
|
// 校验账号用户名是否存在
|
|
|
|
|
if (secUserService.findByLoginName(highAgentModel.getSecUser().getLoginName()) != null && !highAgentModel.getId().equals(highAgent.getId())) { |
|
|
|
|
log.error("HighAgentController --> insertAgent() error!", "用户名已存在"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_LOGIN_NAME_IS_EXIST_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (highAgentService.findByAgentName(highAgentModel.getAgentName())) { |
|
|
|
|
log.error("HighMerchantStoreController --> insertAgent() error!", "代理商名称已存在"); |
|
|
|
|
if (highAgentService.findByAgentName(highAgentModel.getAgentName()) && !highAgentModel.getId().equals(highAgent.getId())) { |
|
|
|
|
log.error("HighAgentController --> 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); |
|
|
|
|
|
|
|
|
|
highAgentService.updateAgentMsg(highAgentModel); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("修改成功"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("BsPositionController --> addPosition() error!", e); |
|
|
|
|
log.error("HighAgentController --> insertAgent() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getListAgent", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询代理商列表") |
|
|
|
|
public ResponseData getListAgent( |
|
|
|
|
@RequestParam(value = "agentName", required = false) String agentName, |
|
|
|
|
@RequestParam(value = "agentPhone", required = false) String agentPhone, |
|
|
|
|
@RequestParam(value = "status", required = false) Integer status, |
|
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
|
|
@RequestParam(name = "pageSize", required = true) Integer pageSize |
|
|
|
|
) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(agentName)) { |
|
|
|
|
map.put("agentName", agentName); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNotBlank(agentPhone)) { |
|
|
|
|
map.put("agentPhone", agentPhone); |
|
|
|
|
} |
|
|
|
|
if (status != null) { |
|
|
|
|
map.put("status", Integer.toString(status)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
|
|
|
|
|
List<HighAgent> highAgents = highAgentService.getListAgentMsg(map); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(new PageInfo<>(highAgents)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighAgentController --> getListUser() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/findByAgentId", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "根据id查询详情") |
|
|
|
|
public ResponseData findById(@RequestParam(value = "agentId", required = true) Long agentId) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
HighAgentModel highAgentModel = new HighAgentModel(); |
|
|
|
|
HighAgent highAgent = highAgentService.findByAgentMsgId(agentId); |
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(highAgent, highAgentModel); |
|
|
|
|
|
|
|
|
|
// 查询商户主账号
|
|
|
|
|
SecUser mainAccount = secUserService.getMainAccount(4, highAgent.getId()); |
|
|
|
|
if (mainAccount != null) { |
|
|
|
|
highAgentModel.setSecUser(mainAccount); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highAgentModel); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighUserController --> findByUserId() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/forbiddenUser", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "禁用启用账号") |
|
|
|
|
public ResponseData forbiddenUser(@RequestParam(value = "agentId" , required = true) Long agentId) { |
|
|
|
|
try { |
|
|
|
|
HighAgent highAgent = highAgentService.findByAgentMsgId(agentId); |
|
|
|
|
|
|
|
|
|
if (highAgent == null) { |
|
|
|
|
log.error("HighUserController --> forbiddenUser() error!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_USER_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (highAgent.getStatus() == 1) { |
|
|
|
|
highAgent.setStatus(0); |
|
|
|
|
} else { |
|
|
|
|
highAgent.setStatus(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HighAgentModel highAgentModel = new HighAgentModel(); |
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(highAgent, highAgentModel); |
|
|
|
|
|
|
|
|
|
highAgentService.updateAgentMsg(highAgentModel); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("禁用成功"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("BsPositionController --> addPosition() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|