'提交代码'

dev-discount
199901012 4 years ago
parent 3ea063d118
commit 8988856570
  1. 57
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  2. 85
      hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java
  3. 7
      hai-service/src/main/java/com/hai/service/HighCouponService.java
  4. 17
      hai-service/src/main/java/com/hai/service/HighMerchantService.java
  5. 50
      hai-service/src/main/java/com/hai/service/SecUserService.java
  6. 21
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java
  7. 37
      hai-service/src/main/java/com/hai/service/impl/HighMerchantServiceImpl.java
  8. 1
      hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java
  9. 42
      hai-service/src/main/java/com/hai/service/impl/SecUserServiceImpl.java

@ -108,4 +108,61 @@ public class HighCouponController {
}
}
@RequestMapping(value="/updateCoupon",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改卡卷")
public ResponseData updateCoupon(@RequestBody HighCouponModel highCoupon, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (highCoupon.getId() == null
|| highCoupon.getMerchantId() == null
|| StringUtils.isNotBlank(highCoupon.getCouponKey())
|| StringUtils.isNotBlank(highCoupon.getCouponName())
|| StringUtils.isNotBlank(highCoupon.getCouponValue())
|| StringUtils.isNotBlank(highCoupon.getCouponImg())
|| highCoupon.getIsPresent() == null
|| highCoupon.getCouponPrice() == null) {
log.error("HighCouponController -> updateCoupon() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 是否赠送卡卷
if (highCoupon.getIsPresent() == true) {
if (highCoupon.getHandselCouponList() == null || highCoupon.getHandselCouponList().size() == 0) {
log.error("HighCouponController -> updateCoupon() error!","请选择赠送卡卷名单");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SELECT_HANDSEL_COUPON_ERROR, "");
}
for (HighCouponHandsel handsel : highCoupon.getHandselCouponList()) {
// 如果没有id 就是需要增加的
if (handsel.getId() == null) {
handsel.setCreateTime(new Date());
handsel.setStatus(1); // 状态 0:删除 1:正常
handsel.setOperatorId(userInfoModel.getSecUser().getId());
handsel.setOperatorName(userInfoModel.getSecUser().getUserName());
}
}
}
// 查询商户
HighMerchant merchant = highMerchantService.getMerchantById(highCoupon.getCompanyId());
if (merchant == null) {
log.error("HighCouponController -> updateCoupon() error!","未找到商户");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, "");
}
highCoupon.setCompanyId(merchant.getCompanyId());
highCoupon.setOperatorId(userInfoModel.getSecUser().getId());
highCoupon.setOperatorName(userInfoModel.getSecUser().getUserName());
highCoupon.setUpdateTime(new Date());
highCouponService.updateCoupon(highCoupon);
return ResponseMsgUtil.success(highCoupon);
} catch (Exception e) {
log.error("HighCouponController -> updateCoupon() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

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

@ -17,4 +17,11 @@ public interface HighCouponService {
**/
void insertCoupon(HighCouponModel highCouponModel);
/**
* @Author 胡锐
* @Description 修改
* @Date 2021/3/12 20:41
**/
void updateCoupon(HighCouponModel highCouponModel);
}

@ -12,16 +12,25 @@ import java.util.Map;
public interface HighMerchantService {
/**
* 编辑
*/
void editMerchant(HighMerchantModel highMerchant) throws Exception;
* @Author 胡锐
* @Description 增加
* @Date 2021/3/12 21:24
**/
void insertMerchant(HighMerchantModel highMerchant) throws Exception;
/**
* @Author 胡锐
* @Description 修改
* @Date 2021/3/12 21:24
**/
void updateMerchant(HighMerchantModel highMerchant) throws Exception;
/**
* 根据id查询
* @param id
* @return
*/
HighMerchant getMerchantById(Long id);
HighMerchantModel getMerchantById(Long id);
/**
* 查询列表

@ -133,52 +133,12 @@ public interface SecUserService {
void modifyUser(SecUser user);
/**
*
* @Title: findAgencyUser
* @Description: 查询机构用户
* @author: 杜江
* @Date: 2020/7/28 16:05
* @param: [agencyId]
* @return: com.shinwoten.train.entity.SecUser
* @throws
*/
SecUser findAgencyUser(Long agencyId);
/**
*
* @Title: findAgencyWorker
* @Description: 查询机构工作人员
* @author: 袁野
* @Date: 2020/10/08 16:05
* @param: [workerId]
* @return: com.shinwoten.train.entity.SecUser
* @throws
*/
SecUser findAgencyWorker(Long workerId);
/**
*
* @Title: findTeacherUser
* @Description: 查询教师账号
* @author: 杜江
* @Date: 2020/7/30 14:48
* @param: [teacherId]
* @return: com.shinwoten.train.entity.SecUser
* @throws
*/
SecUser findTeacherUser(Long teacherId);
* @Author 胡锐
* @Description 查询主账号
* @Date 2021/3/12 21:05
**/
SecUser getMainAccount(Integer objectType,Long objectId);
/**
*
* @Title: findTeacherUser
* @Description: 查询工作人员账号
* @author: 袁野
* @Date: 2020/09/29 14:48
* @param: [workId]
* @return: com.shinwoten.train.entity.SecUser
* @throws
*/
SecUser findWorkerUser(Long workId);
/**
*
* @Title: findUserList

@ -37,8 +37,29 @@ public class HighCouponServiceImpl implements HighCouponService {
if (highCouponModel.getHandselCouponList() != null && highCouponModel.getHandselCouponList().size() > 0) {
for (HighCouponHandselModel handsel : highCouponModel.getHandselCouponList()) {
handsel.setCouponId(highCouponModel.getId());
highCouponHandselMapper.insert(handsel);
}
}
}
@Override
@Transactional
public void updateCoupon(HighCouponModel highCouponModel) {
highCouponMapper.updateByPrimaryKey(highCouponModel);
// 赠送卡卷
if (highCouponModel.getHandselCouponList() != null && highCouponModel.getHandselCouponList().size() > 0) {
for (HighCouponHandselModel handsel : highCouponModel.getHandselCouponList()) {
// 状态标记为删除的,进行删除操作
if (handsel.getStatus() == 0) {
highCouponHandselMapper.deleteByPrimaryKey(handsel.getId());
}
// id为空的,进行增加操作
if (handsel.getId() == null) {
handsel.setCouponId(highCouponModel.getId());
highCouponHandselMapper.insert(handsel);
}
}
}
}
}

@ -1,5 +1,8 @@
package com.hai.service.impl;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.MD5Util;
import com.hai.dao.HighMerchantMapper;
import com.hai.entity.HighMerchant;
@ -10,6 +13,7 @@ import com.hai.service.HighMerchantService;
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;
@ -29,13 +33,13 @@ public class HighMerchantServiceImpl implements HighMerchantService {
@Override
@Transactional
public void editMerchant(HighMerchantModel highMerchant) throws Exception {
if (highMerchant.getId() == null) {
public void insertMerchant(HighMerchantModel highMerchant) throws Exception {
highMerchantMapper.insert(highMerchant);
highMerchant.getSecUser().setUserName(highMerchant.getMerchantName());
highMerchant.getSecUser().setLoginName(highMerchant.getSecUser().getTelephone());
highMerchant.getSecUser().setPassword(MD5Util.encode(highMerchant.getSecUser().getPassword().getBytes()));
highMerchant.getSecUser().setAdminFlag(1);
highMerchant.getSecUser().setStatus(1);
highMerchant.getSecUser().setRoleId(2L);
highMerchant.getSecUser().setObjectType(2);
@ -43,15 +47,34 @@ public class HighMerchantServiceImpl implements HighMerchantService {
highMerchant.getSecUser().setCreateTime(new Date());
highMerchant.getSecUser().setUpdateTime(new Date());
secUserService.addUser(highMerchant.getSecUser());
}
} else {
@Override
@Transactional
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()));
}
secUserService.updateUser(highMerchant.getSecUser());
}
@Override
public HighMerchant getMerchantById(Long id) {
return highMerchantMapper.selectByPrimaryKey(id);
public HighMerchantModel getMerchantById(Long id) {
HighMerchant merchant = highMerchantMapper.selectByPrimaryKey(id);
if (merchant == null) {
return null;
}
HighMerchantModel merchantModel = new HighMerchantModel();
BeanUtils.copyProperties(merchant, merchantModel);
// 查询商户主账号
SecUser mainAccount = secUserService.getMainAccount(2, merchant.getId());
if (mainAccount != null) {
merchantModel.setSecUser(mainAccount);
}
return merchantModel;
}
@Override
@ -75,6 +98,10 @@ public class HighMerchantServiceImpl implements HighMerchantService {
criteria.andTelephoneEqualTo(MapUtils.getString(map, "telephone"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "status"))) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
example.setOrderByClause("create_time desc");
return highMerchantMapper.selectByExample(example);
}

@ -41,6 +41,7 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService {
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);

@ -176,45 +176,13 @@ public class SecUserServiceImpl implements SecUserService {
}
@Override
public SecUser findAgencyUser(Long agencyId) {
public SecUser getMainAccount(Integer objectType, Long objectId) {
SecUserExample example = new SecUserExample();
example.createCriteria().andObjectTypeEqualTo(2).andObjectIdEqualTo(agencyId).andStatusEqualTo(1);
List<SecUser> secUsers = secUserMapper.selectByExample(example);
if (secUsers != null && secUsers.size() != 0) {
return secUsers.get(0);
}
return null;
}
@Override
public SecUser findAgencyWorker(Long workerId) {
SecUserExample example = new SecUserExample();
example.createCriteria().andObjectTypeEqualTo(4).andObjectIdEqualTo(workerId).andStatusEqualTo(1);
List<SecUser> secUsers = secUserMapper.selectByExample(example);
if (secUsers != null && secUsers.size() != 0) {
return secUsers.get(0);
}
return null;
}
example.createCriteria().andAdminFlagEqualTo(1).andObjectTypeEqualTo(objectType).andObjectIdEqualTo(objectId);
@Override
public SecUser findTeacherUser(Long teacherId) {
SecUserExample example = new SecUserExample();
example.createCriteria().andObjectTypeEqualTo(3).andObjectIdEqualTo(teacherId).andStatusEqualTo(1);
List<SecUser> secUsers = secUserMapper.selectByExample(example);
if (secUsers != null && secUsers.size() != 0) {
return secUsers.get(0);
}
return null;
}
@Override
public SecUser findWorkerUser(Long workId) {
SecUserExample example = new SecUserExample();
example.createCriteria().andObjectTypeEqualTo(4).andObjectIdEqualTo(workId).andStatusEqualTo(1);
List<SecUser> secUsers = secUserMapper.selectByExample(example);
if (secUsers != null && secUsers.size() != 0) {
return secUsers.get(0);
List<SecUser> list = secUserMapper.selectByExample(example);
if (list != null && list.size() > 0) {
return list.get(0);
}
return null;
}

Loading…
Cancel
Save