'提交代码'

dev-discount
199901012 4 years ago
parent 5834b713bb
commit ecc1c80682
  1. 149
      hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java
  2. 13
      hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java
  3. 12
      hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java
  4. 63
      hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java

@ -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) {

@ -15,10 +15,17 @@ public interface HighMerchantStoreService {
/**
* @Author 胡锐
* @Description 编辑门店
* @Description 增加门店
* @Date 2021/3/9 20:26
**/
void editMerchantStore(HighMerchantStoreModel highMerchantStore) throws Exception;
void insertMerchantStore(HighMerchantStoreModel highMerchantStore) throws Exception;
/**
* @Author 胡锐
* @Description 修改门店
* @Date 2021/3/12 22:15
**/
void updateMerchantStore(HighMerchantStoreModel highMerchantStore) throws Exception;
/**
* @Author 胡锐
@ -32,7 +39,7 @@ public interface HighMerchantStoreService {
* @Description 根据id查询
* @Date 2021/3/9 20:26
**/
HighMerchantStore getMerchantStoreById(Long id);
HighMerchantStoreModel getMerchantStoreById(Long id);
/**
* @Author 胡锐

@ -54,10 +54,16 @@ public class HighMerchantServiceImpl implements HighMerchantService {
public void updateMerchant(HighMerchantModel highMerchant) throws Exception {
highMerchantMapper.updateByPrimaryKey(highMerchant);
if (StringUtils.isNotBlank(highMerchant.getSecUser().getPassword())) {
highMerchant.getSecUser().setPassword(MD5Util.encode(highMerchant.getSecUser().getPassword().getBytes()));
// 查询主账号
SecUser mainAccount = secUserService.getMainAccount(2, highMerchant.getId());
if (mainAccount != null) {
String userPass = MD5Util.encode(highMerchant.getSecUser().getPassword().getBytes());
if (!mainAccount.getPassword().equals(userPass)) {
mainAccount.setPassword(userPass);
}
mainAccount.setTelephone(highMerchant.getTelephone());
secUserService.updateUser(mainAccount);
}
secUserService.updateUser(highMerchant.getSecUser());
}
@Override

@ -14,6 +14,7 @@ import com.hai.service.HighMerchantStoreService;
import com.hai.service.SecUserService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -33,22 +34,36 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService {
@Override
@Transactional
public void editMerchantStore(HighMerchantStoreModel highMerchantStore) throws Exception {
if (highMerchantStore.getId() != null) {
highMerchantStoreMapper.updateByPrimaryKey(highMerchantStore);
} else {
highMerchantStoreMapper.insert(highMerchantStore);
highMerchantStore.getSecUser().setUserName(highMerchantStore.getStoreName());
highMerchantStore.getSecUser().setLoginName(highMerchantStore.getSecUser().getTelephone());
highMerchantStore.getSecUser().setPassword(MD5Util.encode(highMerchantStore.getSecUser().getPassword().getBytes()));
highMerchantStore.getSecUser().setAdminFlag(1);
highMerchantStore.getSecUser().setStatus(1);
highMerchantStore.getSecUser().setRoleId(3L);
highMerchantStore.getSecUser().setObjectType(3);
highMerchantStore.getSecUser().setObjectId(highMerchantStore.getId());
highMerchantStore.getSecUser().setCreateTime(new Date());
highMerchantStore.getSecUser().setUpdateTime(new Date());
secUserService.addUser(highMerchantStore.getSecUser());
public void insertMerchantStore(HighMerchantStoreModel highMerchantStore) throws Exception {
highMerchantStoreMapper.insert(highMerchantStore);
highMerchantStore.getSecUser().setUserName(highMerchantStore.getStoreName());
highMerchantStore.getSecUser().setLoginName(highMerchantStore.getSecUser().getTelephone());
highMerchantStore.getSecUser().setPassword(MD5Util.encode(highMerchantStore.getSecUser().getPassword().getBytes()));
highMerchantStore.getSecUser().setAdminFlag(1);
highMerchantStore.getSecUser().setStatus(1);
highMerchantStore.getSecUser().setRoleId(3L);
highMerchantStore.getSecUser().setObjectType(3);
highMerchantStore.getSecUser().setObjectId(highMerchantStore.getId());
highMerchantStore.getSecUser().setCreateTime(new Date());
highMerchantStore.getSecUser().setUpdateTime(new Date());
secUserService.addUser(highMerchantStore.getSecUser());
}
@Override
@Transactional
public void updateMerchantStore(HighMerchantStoreModel highMerchantStore) throws Exception {
highMerchantStoreMapper.updateByPrimaryKey(highMerchantStore);
// 查询主账号
SecUser mainAccount = secUserService.getMainAccount(3, highMerchantStore.getId());
if (mainAccount != null) {
String userPass = MD5Util.encode(highMerchantStore.getSecUser().getPassword().getBytes());
if (!mainAccount.getPassword().equals(userPass)) {
mainAccount.setPassword(userPass);
}
mainAccount.setTelephone(highMerchantStore.getTelephone());
secUserService.updateUser(mainAccount);
}
}
@ -73,8 +88,20 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService {
}
@Override
public HighMerchantStore getMerchantStoreById(Long id) {
return highMerchantStoreMapper.selectByPrimaryKey(id);
public HighMerchantStoreModel getMerchantStoreById(Long id) {
HighMerchantStore merchantStore = highMerchantStoreMapper.selectByPrimaryKey(id);
if (merchantStore == null) {
return null;
}
HighMerchantStoreModel model = new HighMerchantStoreModel();
BeanUtils.copyProperties(merchantStore, model);
// 查询主账号
SecUser mainAccount = secUserService.getMainAccount(3, merchantStore.getId());
if (mainAccount != null) {
model.setSecUser(mainAccount);
}
return model;
}
@Override

Loading…
Cancel
Save