|
|
@ -57,10 +57,10 @@ public class HighMerchantController { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private SecUserService secUserService; |
|
|
|
private SecUserService secUserService; |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/editMerchant",method = RequestMethod.POST) |
|
|
|
@RequestMapping(value="/insertMerchant",method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "编辑商户") |
|
|
|
@ApiOperation(value = "增加商户") |
|
|
|
public ResponseData editMerchant(@RequestBody HighMerchantModel highMerchant, HttpServletRequest request) { |
|
|
|
public ResponseData insertMerchant(@RequestBody HighMerchantModel highMerchant, HttpServletRequest request) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
@ -69,49 +69,93 @@ public class HighMerchantController { |
|
|
|
|| StringUtils.isBlank(highMerchant.getMerchantName()) |
|
|
|
|| StringUtils.isBlank(highMerchant.getMerchantName()) |
|
|
|
|| StringUtils.isBlank(highMerchant.getTelephone()) |
|
|
|
|| StringUtils.isBlank(highMerchant.getTelephone()) |
|
|
|
|| StringUtils.isBlank(highMerchant.getAddress()) |
|
|
|
|| StringUtils.isBlank(highMerchant.getAddress()) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(highMerchant.getSecUser().getPassword()) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(highMerchant.getSecUser().getTelephone()) |
|
|
|
) { |
|
|
|
) { |
|
|
|
log.error("HighMerchantController -> editMerchant() error!","参数错误"); |
|
|
|
log.error("HighMerchantController -> insertMerchant() error!","参数错误"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// id为空 就是增加商户,需要校验账号是否填写
|
|
|
|
// 校验账户手机号
|
|
|
|
if (highMerchant.getId() == null) { |
|
|
|
if (!MemberValidateUtil.validatePhone(highMerchant.getSecUser().getTelephone())) { |
|
|
|
if (StringUtils.isBlank(highMerchant.getSecUser().getPassword()) || StringUtils.isBlank(highMerchant.getSecUser().getTelephone())) { |
|
|
|
log.error("BsStudentController --> insertMerchant() error!", "请输入正确的电话号码"); |
|
|
|
log.error("HighMerchantController -> editMerchant() error!","参数错误"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验账户手机号
|
|
|
|
|
|
|
|
if (!MemberValidateUtil.validatePhone(highMerchant.getSecUser().getTelephone())) { |
|
|
|
|
|
|
|
log.error("BsStudentController --> addStudent() error!", "请输入正确的电话号码"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验账号手机号是否存在
|
|
|
|
|
|
|
|
if (secUserService.findByPhone(highMerchant.getSecUser().getTelephone()) != null) { |
|
|
|
|
|
|
|
log.error("BsStudentController --> addStudent() error!", "电话号码已被使用"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
highMerchant.setStatus(1); // 状态:0:不可用,1:可用
|
|
|
|
|
|
|
|
highMerchant.setCreateTime(new Date()); |
|
|
|
|
|
|
|
highMerchant.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (highMerchantService.getMerchantById(highMerchant.getId()) == null) { |
|
|
|
|
|
|
|
log.error("HighMerchantController -> editMerchant() error!","未找到商户"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
highMerchant.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验账号手机号是否存在
|
|
|
|
|
|
|
|
if (secUserService.findByPhone(highMerchant.getSecUser().getTelephone()) != null) { |
|
|
|
|
|
|
|
log.error("BsStudentController --> insertMerchant() error!", "电话号码已被使用"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
highMerchant.setStatus(1); // 状态:0:不可用,1:可用
|
|
|
|
|
|
|
|
highMerchant.setCreateTime(new Date()); |
|
|
|
|
|
|
|
highMerchant.setUpdateTime(new Date()); |
|
|
|
highMerchant.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
highMerchant.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
highMerchant.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
highMerchant.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
highMerchantService.editMerchant(highMerchant); |
|
|
|
highMerchantService.insertMerchant(highMerchant); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highMerchant); |
|
|
|
return ResponseMsgUtil.success(highMerchant); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("HighMerchantController -> editMerchant() error!",e); |
|
|
|
log.error("HighMerchantController -> insertMerchant() error!",e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/updateMerchant",method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "修改商户") |
|
|
|
|
|
|
|
public ResponseData updateMerchant(@RequestBody HighMerchantModel highMerchant, HttpServletRequest request) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
|
|
|
if (highMerchant.getId() == null |
|
|
|
|
|
|
|
|| highMerchant.getCompanyId() == null |
|
|
|
|
|
|
|
|| StringUtils.isBlank(highMerchant.getMerchantKey()) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(highMerchant.getMerchantName()) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(highMerchant.getTelephone()) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(highMerchant.getAddress()) |
|
|
|
|
|
|
|
|| StringUtils.isBlank(highMerchant.getTelephone()) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
log.error("HighMerchantController -> updateMerchant() error!","参数错误"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询商户
|
|
|
|
|
|
|
|
HighMerchantModel merchant = highMerchantService.getMerchantById(highMerchant.getId()); |
|
|
|
|
|
|
|
if (merchant == null) { |
|
|
|
|
|
|
|
log.error("HighMerchantController -> updateMerchant() error!","未找到商户"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 商户主账号
|
|
|
|
|
|
|
|
if (merchant.getSecUser() == null) { |
|
|
|
|
|
|
|
log.error("HighMerchantController -> updateMerchant() error!","主账号异常"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_ADMIN_USER_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验账户手机号
|
|
|
|
|
|
|
|
if (MemberValidateUtil.validatePhone(highMerchant.getSecUser().getTelephone())) { |
|
|
|
|
|
|
|
log.error("BsStudentController --> updateMerchant() error!", "请输入正确的电话号码"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 校验账号手机号是否存在
|
|
|
|
|
|
|
|
if (!merchant.getSecUser().getTelephone().equals(highMerchant.getSecUser().getTelephone()) |
|
|
|
|
|
|
|
&& secUserService.findByPhone(highMerchant.getSecUser().getTelephone()) != null) { |
|
|
|
|
|
|
|
log.error("BsStudentController --> updateMerchant() error!", "电话号码已被使用"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
highMerchant.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
highMerchant.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
|
|
|
|
highMerchant.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
|
|
|
highMerchantService.updateMerchant(highMerchant); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highMerchant); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighMerchantController -> updateMerchant() error!",e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -123,6 +167,7 @@ public class HighMerchantController { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highMerchantService.getMerchantById(id)); |
|
|
|
return ResponseMsgUtil.success(highMerchantService.getMerchantById(id)); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("HighMerchantController -> getMerchantById() error!",e); |
|
|
|
log.error("HighMerchantController -> getMerchantById() error!",e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
@ -135,6 +180,7 @@ public class HighMerchantController { |
|
|
|
public ResponseData getMerchantList(@RequestParam(name = "merchantKey", required = false) String merchantKey, |
|
|
|
public ResponseData getMerchantList(@RequestParam(name = "merchantKey", required = false) String merchantKey, |
|
|
|
@RequestParam(name = "merchantName", required = false) String merchantName, |
|
|
|
@RequestParam(name = "merchantName", required = false) String merchantName, |
|
|
|
@RequestParam(name = "telephone", required = false) String telephone, |
|
|
|
@RequestParam(name = "telephone", required = false) String telephone, |
|
|
|
|
|
|
|
@RequestParam(name = "status", required = false) Integer status, |
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
|
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
|
|
|
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
|
|
|
HttpServletRequest request) { |
|
|
|
HttpServletRequest request) { |
|
|
@ -150,6 +196,7 @@ public class HighMerchantController { |
|
|
|
map.put("merchantKey", merchantKey); |
|
|
|
map.put("merchantKey", merchantKey); |
|
|
|
map.put("merchantName", merchantName); |
|
|
|
map.put("merchantName", merchantName); |
|
|
|
map.put("telephone", telephone); |
|
|
|
map.put("telephone", telephone); |
|
|
|
|
|
|
|
map.put("status", status); |
|
|
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
return ResponseMsgUtil.success(new PageInfo<>(highMerchantService.getMerchantList(map))); |
|
|
|
return ResponseMsgUtil.success(new PageInfo<>(highMerchantService.getMerchantList(map))); |
|
|
|