|
|
|
@ -1,5 +1,8 @@ |
|
|
|
|
package com.bweb.controller; |
|
|
|
|
|
|
|
|
|
import com.github.pagehelper.Page; |
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
@ -22,14 +25,14 @@ import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Auther: 胡锐 |
|
|
|
@ -64,34 +67,34 @@ public class HighCouponAgentController { |
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
if (userInfoModel.getBsCompany() == null) { |
|
|
|
|
log.error("HighAgentController -> insertAgent() error!","该主角色没有权限"); |
|
|
|
|
log.error("HighCouponAgentController -> assignCouponAgent() error!","该主角色没有权限"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(highCouponAgentRel.getCouponId() == null |
|
|
|
|
|| highCouponAgentRel.getAgentId() == null |
|
|
|
|
|| highCouponAgentRel.getStockCount() == null) { |
|
|
|
|
log.error("HighAgentController -> insertAgent() error!","参数错误"); |
|
|
|
|
log.error("HighCouponAgentController -> assignCouponAgent() error!","参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询卡券详情
|
|
|
|
|
HighCoupon coupon = highCouponService.getCouponById(highCouponAgentRel.getCouponId()); |
|
|
|
|
if (coupon == null) { |
|
|
|
|
log.error("HighAgentController -> insertAgent() error!","未找到卡券信息"); |
|
|
|
|
log.error("HighCouponAgentController -> assignCouponAgent() error!","未找到卡券信息"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询代理商
|
|
|
|
|
HighAgent highAgent = highAgentService.findByAgentMsgId(highCouponAgentRel.getAgentId()); |
|
|
|
|
if (highAgent == null) { |
|
|
|
|
log.error("HighAgentController -> insertAgent() error!","未找到代理商信息"); |
|
|
|
|
log.error("HighCouponAgentController -> assignCouponAgent() error!","未找到代理商信息"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_AGENT, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验是否重复分配
|
|
|
|
|
if (highCouponAgentService.getRelByCouponAgent(highCouponAgentRel.getCouponId(),highCouponAgentRel.getAgentId()) != null) { |
|
|
|
|
log.error("HighAgentController -> insertAgent() error!","参数错误"); |
|
|
|
|
log.error("HighCouponAgentController -> assignCouponAgent() error!","参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + "已分配给" + highAgent.getAgentName()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -106,7 +109,63 @@ public class HighCouponAgentController { |
|
|
|
|
return ResponseMsgUtil.success("分配成功"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighAgentController --> assignCouponAgent() error!", e); |
|
|
|
|
log.error("HighCouponAgentController --> assignCouponAgent() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getCouponByAgent", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "根据代理商 查询卡券") |
|
|
|
|
public ResponseData getCouponByAgent(@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()); |
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum,pageSize); |
|
|
|
|
PageInfo<HighCouponAgentRel> pageInfo = new PageInfo<>(highCouponAgentService.getCouponAgentList(map)); |
|
|
|
|
for (HighCouponAgentRel rel : pageInfo.getList()) { |
|
|
|
|
rel.setHighCoupon(highCouponService.getCouponById(rel.getCouponId())); |
|
|
|
|
} |
|
|
|
|
return ResponseMsgUtil.success(pageInfo); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighCouponAgentController --> getCouponByAgent() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getAgentByCoupon", method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "根据卡券 查询代理商") |
|
|
|
|
public ResponseData getAgentByCoupon(@RequestParam(name = "couponId", required = true) Long couponId, |
|
|
|
|
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
|
|
|
|
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
|
|
|
|
HttpServletRequest request) { |
|
|
|
|
try { |
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
map.put("couponId", couponId); |
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum,pageSize); |
|
|
|
|
PageInfo<HighCouponAgentRel> pageInfo = new PageInfo<>(highCouponAgentService.getCouponAgentList(map)); |
|
|
|
|
for (HighCouponAgentRel rel : pageInfo.getList()) { |
|
|
|
|
rel.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId())); |
|
|
|
|
} |
|
|
|
|
return ResponseMsgUtil.success(pageInfo); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("HighCouponAgentController --> getAgentByCoupon() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|