|
|
|
@ -56,63 +56,124 @@ public class HighMerchantStoreController { |
|
|
|
|
@Resource |
|
|
|
|
private SecUserService secUserService; |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/editHighMerchantStore",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value="/insertMerchantStore",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "编辑商户门店") |
|
|
|
|
public ResponseData editMerchantStore(@RequestBody HighMerchantStoreModel highMerchantStore, HttpServletRequest request) { |
|
|
|
|
@ApiOperation(value = "增加商户门店") |
|
|
|
|
public ResponseData insertMerchantStore(@RequestBody HighMerchantStoreModel highMerchantStore, HttpServletRequest request) { |
|
|
|
|
try { |
|
|
|
|
//发布人员
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
if (highMerchantStore.getMerchantId() == null |
|
|
|
|
|| StringUtils.isNotBlank(highMerchantStore.getStoreKey()) |
|
|
|
|
|| StringUtils.isNotBlank(highMerchantStore.getStoreName()) |
|
|
|
|
|| StringUtils.isNotBlank(highMerchantStore.getTelephone()) |
|
|
|
|
|| StringUtils.isNotBlank(highMerchantStore.getAddress()) |
|
|
|
|
|| StringUtils.isNotBlank(highMerchantStore.getLatitude()) |
|
|
|
|
|| StringUtils.isNotBlank(highMerchantStore.getLongitude()) |
|
|
|
|
if (userInfoModel.getMerchant() == null) { |
|
|
|
|
log.error("HighMerchantController -> insertMerchantStore() error!","该主角色没有权限"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(highMerchantStore.getStoreKey()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getStoreName()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getTelephone()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getAddress()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getLatitude()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getLongitude()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getSecUser().getPassword()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getSecUser().getTelephone()) |
|
|
|
|
) { |
|
|
|
|
log.error("HighMerchantStoreController -> insertMerchantStore() error!","参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验账户手机号
|
|
|
|
|
if (!MemberValidateUtil.validatePhone(highMerchantStore.getSecUser().getTelephone())) { |
|
|
|
|
log.error("HighMerchantStoreController --> insertMerchantStore() error!", "请输入正确的电话号码"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验账号手机号是否存在
|
|
|
|
|
if (secUserService.findByPhone(highMerchantStore.getSecUser().getTelephone()) != null) { |
|
|
|
|
log.error("HighMerchantStoreController --> insertMerchantStore() error!", "电话号码已被使用"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验商户
|
|
|
|
|
HighMerchant merchant = highMerchantService.getMerchantById(userInfoModel.getMerchant().getId()); |
|
|
|
|
if (merchant != null) { |
|
|
|
|
log.error("HighMerchantStoreController -> insertMerchantStore() error!","未找到商户"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
highMerchantStore.setCreateTime(new Date()); |
|
|
|
|
highMerchantStore.setUpdateTime(new Date()); |
|
|
|
|
highMerchantStore.setStatus(1); // 状态:0:删除,1:正常
|
|
|
|
|
highMerchantStore.setCompanyId(merchant.getCompanyId()); |
|
|
|
|
highMerchantStore.setMerchantId(merchant.getId()); |
|
|
|
|
highMerchantStore.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
|
highMerchantStore.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
highMerchantStoreService.insertMerchantStore(highMerchantStore); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highMerchantStore); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighMerchantStoreController -> insertMerchantStore() error!",e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/updateMerchantStore",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "修改商户门店") |
|
|
|
|
public ResponseData updateMerchantStore(@RequestBody HighMerchantStoreModel highMerchantStore, HttpServletRequest request) { |
|
|
|
|
try { |
|
|
|
|
//发布人员
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
if (userInfoModel.getMerchant() == null) { |
|
|
|
|
log.error("HighMerchantController -> insertMerchantStore() error!","该主角色没有权限"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (highMerchantStore.getId() == null |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getStoreKey()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getStoreName()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getTelephone()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getAddress()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getLatitude()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getLongitude()) |
|
|
|
|
|| StringUtils.isBlank(highMerchantStore.getSecUser().getTelephone()) |
|
|
|
|
) { |
|
|
|
|
log.error("HighMerchantStoreController -> editMerchantStore() error!","参数错误"); |
|
|
|
|
log.error("HighMerchantStoreController -> insertMerchantStore() error!","参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// id为空 就是增加门店,需要校验账号是否填写
|
|
|
|
|
if (highMerchantStore.getId() == null) { |
|
|
|
|
if (StringUtils.isBlank(highMerchantStore.getSecUser().getPassword()) || StringUtils.isBlank(highMerchantStore.getSecUser().getTelephone())) { |
|
|
|
|
log.error("HighMerchantController -> editMerchant() error!","参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验账户手机号
|
|
|
|
|
if (!MemberValidateUtil.validatePhone(highMerchantStore.getSecUser().getTelephone())) { |
|
|
|
|
log.error("BsStudentController --> addStudent() error!", "请输入正确的电话号码"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验账号手机号是否存在
|
|
|
|
|
if (secUserService.findByPhone(highMerchantStore.getSecUser().getTelephone()) != null) { |
|
|
|
|
log.error("BsStudentController --> addStudent() error!", "电话号码已被使用"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验商户
|
|
|
|
|
HighMerchant merchant = highMerchantService.getMerchantById(highMerchantStore.getMerchantId()); |
|
|
|
|
if (merchant != null) { |
|
|
|
|
log.error("HighMerchantStoreController -> editMerchantStore() error!","未找到商户"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); |
|
|
|
|
} |
|
|
|
|
highMerchantStore.setCompanyId(merchant.getCompanyId()); |
|
|
|
|
highMerchantStore.setCreateTime(new Date()); |
|
|
|
|
highMerchantStore.setUpdateTime(new Date()); |
|
|
|
|
highMerchantStore.setStatus(1); // 状态:0:删除,1:正常
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
highMerchantStore.setUpdateTime(new Date()); |
|
|
|
|
// 校验账户手机号
|
|
|
|
|
if (!MemberValidateUtil.validatePhone(highMerchantStore.getSecUser().getTelephone())) { |
|
|
|
|
log.error("BsStudentController --> addStudent() error!", "请输入正确的电话号码"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询门店
|
|
|
|
|
HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highMerchantStore.getId()); |
|
|
|
|
if (store == null) { |
|
|
|
|
log.error("BsStudentController --> addStudent() error!", "请输入正确的电话号码"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验账号手机号是否存在
|
|
|
|
|
if (!store.getSecUser().getTelephone().equals(highMerchantStore.getSecUser().getTelephone()) |
|
|
|
|
&& secUserService.findByPhone(highMerchantStore.getSecUser().getTelephone()) != null) { |
|
|
|
|
log.error("BsStudentController --> addStudent() error!", "电话号码已被使用"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验商户
|
|
|
|
|
HighMerchant merchant = highMerchantService.getMerchantById(highMerchantStore.getMerchantId()); |
|
|
|
|
if (merchant != null) { |
|
|
|
|
log.error("HighMerchantStoreController -> editMerchantStore() error!","未找到商户"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
highMerchantStore.setUpdateTime(new Date()); |
|
|
|
|
highMerchantStore.setOperatorId(userInfoModel.getSecUser().getId()); |
|
|
|
|
highMerchantStore.setOperatorName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
highMerchantStoreService.editMerchantStore(highMerchantStore); |
|
|
|
|
highMerchantStoreService.updateMerchantStore(highMerchantStore); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(highMerchantStore); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|