'提交代码'

dev-discount
199901012 4 years ago
parent 20447d83f5
commit 2b68b71ff0
  1. 103
      hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java
  2. 35
      hai-service/src/main/java/com/hai/model/HighCouponAgentCodeModel.java
  3. 25
      hai-service/src/main/java/com/hai/service/HighCouponAgentService.java
  4. 65
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java

@ -9,14 +9,13 @@ import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighAgent; import com.hai.entity.*;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighCouponAgentRel;
import com.hai.model.HighAgentModel; import com.hai.model.HighAgentModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.HighAgentService; import com.hai.service.HighAgentService;
import com.hai.service.HighCouponAgentService; import com.hai.service.HighCouponAgentService;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService; import com.hai.service.HighCouponService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -52,6 +51,9 @@ public class HighCouponAgentController {
@Resource @Resource
private HighAgentService highAgentService; private HighAgentService highAgentService;
@Resource
private HighCouponCodeService highCouponCodeService;
@Autowired @Autowired
private UserCenter userCenter; private UserCenter userCenter;
@ -146,21 +148,26 @@ public class HighCouponAgentController {
} }
} }
@RequestMapping(value = "/getAgentByCoupon", method = RequestMethod.GET) @RequestMapping(value = "/getAgentByCoupon", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据卡券 查询代理商") @ApiOperation(value = "根据卡券 查询代理商")
public ResponseData getAgentByCoupon(@RequestParam(name = "couponId", required = true) Long couponId, public ResponseData getAgentByCoupon(@RequestParam(name = "couponId", required = true) Long couponId,
@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) {
try { try {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("couponId", couponId); map.put("couponId", couponId);
map.put("status", status);
PageHelper.startPage(pageNum,pageSize); PageHelper.startPage(pageNum,pageSize);
PageInfo<HighCouponAgentRel> pageInfo = new PageInfo<>(highCouponAgentService.getCouponAgentList(map)); PageInfo<HighCouponAgentRel> pageInfo = new PageInfo<>(highCouponAgentService.getCouponAgentList(map));
for (HighCouponAgentRel rel : pageInfo.getList()) { if (pageInfo.getList().size() > 0) {
rel.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId())); for (HighCouponAgentRel code : pageInfo.getList()) {
code.setHighAgent(highAgentService.findByAgentMsgId(code.getAgentId()));
}
} }
return ResponseMsgUtil.success(pageInfo); return ResponseMsgUtil.success(pageInfo);
@ -171,4 +178,90 @@ public class HighCouponAgentController {
} }
@RequestMapping(value = "/getCodeListByAgentCoupon", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据代理商和卡券 查询分配的销售码")
public ResponseData getCodeListByAgentCoupon(@RequestParam(name = "couponId", required = true) Long couponId,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
try {
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getHighAgent() == null) {
log.error("HighCouponAgentController -> getCouponByAgent() error!","该角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "该角色没有权限");
}
Map<String,Object> map = new HashMap<>();
map.put("agentId", userInfoModel.getHighAgent().getId());
map.put("couponId", couponId);
PageHelper.startPage(pageNum,pageSize);
PageInfo<HighCouponAgentCode> pageInfo = new PageInfo<>(highCouponAgentService.getCouponCodeList(map));
if (pageInfo.getList().size() > 0) {
HighCoupon coupon = highCouponService.getCouponDetail(couponId);
for (HighCouponAgentCode code : pageInfo.getList()) {
code.setMerchantName(coupon.getMerchantName());
code.setHighCoupon(coupon);
code.setHighCouponCode(highCouponCodeService.getCouponCodeById(code.getCouponCodeId()));
}
}
return ResponseMsgUtil.success(pageInfo);
} catch (Exception e) {
log.error("HighCouponAgentController --> getCouponByAgent() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/generateCode", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "生成二维码")
public ResponseData generateCode(@RequestParam(name = "couponAgentCodeId", required = true) Long couponAgentCodeId,
HttpServletRequest request) {
try {
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getHighAgent() == null) {
log.error("HighCouponAgentController -> generateCode() error!","该角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "该角色没有权限");
}
return ResponseMsgUtil.success(highCouponAgentService.generateCode(couponAgentCodeId));
} catch (Exception e) {
log.error("HighCouponAgentController --> generateCode() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getCodeById", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据销售码查询详情")
public ResponseData getCodeById(@RequestParam(name = "couponAgentCodeId", required = true) Long couponAgentCodeId,
HttpServletRequest request) {
try {
// 查询卡券销售码
HighCouponAgentCode couponAgentCode = highCouponAgentService.getCodeById(couponAgentCodeId);
if (couponAgentCode == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到销售码");
}
Map<String, Object> map = new HashMap<>();
map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId()));
map.put("couponCode", highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId()));
map.put("couponAgentCode", couponAgentCode);
return ResponseMsgUtil.success(map);
} catch (Exception e) {
log.error("HighCouponAgentController --> getCodeById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -1,6 +1,8 @@
package com.hai.model; package com.hai.model;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighCouponAgentCode; import com.hai.entity.HighCouponAgentCode;
import com.hai.entity.HighCouponCode;
import java.util.List; import java.util.List;
@ -11,13 +13,36 @@ import java.util.List;
*/ */
public class HighCouponAgentCodeModel { public class HighCouponAgentCodeModel {
private List<HighCouponAgentCode> couponAgentCodeList; // 商户名称
private String merchantName;
public List<HighCouponAgentCode> getCouponAgentCodeList() { // 卡券
return couponAgentCodeList; private HighCoupon highCoupon;
// 销售码
private HighCouponCode highCouponCode;
public String getMerchantName() {
return merchantName;
}
public void setMerchantName(String merchantName) {
this.merchantName = merchantName;
}
public HighCoupon getHighCoupon() {
return highCoupon;
}
public void setHighCoupon(HighCoupon highCoupon) {
this.highCoupon = highCoupon;
}
public HighCouponCode getHighCouponCode() {
return highCouponCode;
} }
public void setCouponAgentCodeList(List<HighCouponAgentCode> couponAgentCodeList) { public void setHighCouponCode(HighCouponCode highCouponCode) {
this.couponAgentCodeList = couponAgentCodeList; this.highCouponCode = highCouponCode;
} }
} }

@ -28,6 +28,31 @@ public interface HighCouponAgentService {
**/ **/
HighCouponAgentRel getRelByCouponAgent(Long couponId,Long agentId); HighCouponAgentRel getRelByCouponAgent(Long couponId,Long agentId);
/**
* @Author 胡锐
* @Description 查询卡券与代理商关系列表
* @Date 2021/4/21 21:58
**/
List<HighCouponAgentRel> getCouponAgentList(Map<String, Object> map); List<HighCouponAgentRel> getCouponAgentList(Map<String, Object> map);
/**
* @Author 胡锐
* @Description 查询已分配销售码
* @Date 2021/4/21 22:05
**/
List<HighCouponAgentCode> getCouponCodeList(Map<String, Object> map);
/**
* @Author 胡锐
* @Description 根据分配的销售码id 查询
* @Date 2021/4/21 22:31
**/
HighCouponAgentCode getCodeById(Long couponAgentCodeId);
/**
* @Author 胡锐
* @Description 生成二维码
* @Date 2021/4/21 22:35
**/
Map<String, Object> generateCode(Long couponAgentCodeId);
} }

@ -3,6 +3,7 @@ package com.hai.service.impl;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.dao.HighCouponAgentCodeMapper; import com.hai.dao.HighCouponAgentCodeMapper;
import com.hai.dao.HighCouponAgentRelMapper; import com.hai.dao.HighCouponAgentRelMapper;
import com.hai.entity.*; import com.hai.entity.*;
@ -11,6 +12,8 @@ import com.hai.service.HighCouponCodeService;
import com.hai.service.HighCouponService; import com.hai.service.HighCouponService;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date; import java.util.Date;
@ -103,4 +106,66 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
example.setOrderByClause("create_time desc"); example.setOrderByClause("create_time desc");
return highCouponAgentRelMapper.selectByExample(example); return highCouponAgentRelMapper.selectByExample(example);
} }
@Override
public List<HighCouponAgentCode> getCouponCodeList(Map<String, Object> map) {
HighCouponAgentCodeExample example = new HighCouponAgentCodeExample();
HighCouponAgentCodeExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "couponAgentId") != null) {
criteria.andCouponAgentIdEqualTo(MapUtils.getLong(map, "couponAgentId"));
}
if (MapUtils.getLong(map, "couponId") != null) {
criteria.andCouponIdEqualTo(MapUtils.getLong(map, "couponId"));
}
if (MapUtils.getLong(map, "agentId") != null) {
criteria.andAgentIdEqualTo(MapUtils.getLong(map, "agentId"));
}
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
example.setOrderByClause("create_time desc");
return highCouponAgentCodeMapper.selectByExample(example);
}
@Override
public HighCouponAgentCode getCodeById(Long couponAgentCodeId) {
HighCouponAgentCodeExample example = new HighCouponAgentCodeExample();
example.createCriteria().andCouponAgentIdEqualTo(couponAgentCodeId);
List<HighCouponAgentCode> list = highCouponAgentCodeMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public Map<String, Object> generateCode(Long couponAgentCodeId) {
// 查询卡券销售码
HighCouponAgentCode couponAgentCode = getCodeById(couponAgentCodeId);
if (couponAgentCode == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到销售码");
}
if (couponAgentCode.getStatus() != 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "销售码已被销售");
}
couponAgentCode.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用
highCouponAgentCodeMapper.updateByPrimaryKey(couponAgentCode);
HighCouponCode couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId());
couponCode.setStatus(2);
couponCode.setReceiveTime(new Date());
highCouponCodeService.updateCouponCode(couponCode);
Map<String, Object> map = new HashMap<>();
map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId()));
map.put("couponCode", couponCode);
map.put("couponAgentCode", couponAgentCode);
return map;
}
} }

Loading…
Cancel
Save