From 14eade9413a0fd1f64edcb72ac5c70a6ddc18327 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 6 May 2021 23:20:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=9F=A5=E8=AF=A2=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HighDiscountAgentRelController.java | 58 +++++++++++++++++-- .../com/hai/entity/HighDiscountAgentCode.java | 4 +- .../hai/model/HighDiscountAgentCodeModel.java | 44 ++++++++++++++ .../com/hai/service/HighOrderService.java | 7 +++ .../HighDiscountAgentCodeServiceImpl.java | 33 +++++++++-- .../service/impl/HighOrderServiceImpl.java | 21 +++++++ 6 files changed, 156 insertions(+), 11 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/model/HighDiscountAgentCodeModel.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java index bb7623c4..e3393547 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java @@ -15,15 +15,11 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.common.utils.IDGenerator; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.HighAgent; -import com.hai.entity.HighDiscount; -import com.hai.entity.HighDiscountAgentRel; +import com.hai.entity.*; import com.hai.enum_type.QrCodeType; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; -import com.hai.service.HighAgentService; -import com.hai.service.HighDiscountAgentRelService; -import com.hai.service.HighDiscountService; +import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -62,6 +58,12 @@ public class HighDiscountAgentRelController { @Resource private HighDiscountAgentRelService highDiscountAgentRelService; + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + + @Resource + private HighOrderService highOrderService; + @RequestMapping(value="/insertDiscountAgent",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "分配优惠券给代理商") @@ -157,4 +159,48 @@ public class HighDiscountAgentRelController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value="/getDiscountCodeList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询优惠券码 列表") + public ResponseData getDiscountAgentList(@RequestParam(name = "couponAgentId", required = true) Long couponAgentId, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + + Map map = new HashMap<>(); + map.put("couponAgentId", couponAgentId); + map.put("status", status); + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highDiscountAgentCodeService.getDiscountCode(map))); + + } catch (Exception e) { + log.error("HighDiscountController -> getDiscountAgentList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getDiscountCodeById",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询优惠券码 详情") + public ResponseData getDiscountCodeById(@RequestParam(name = "couponCodeId", required = true) Long couponCodeId) { + try { + + HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(couponCodeId); + if (code != null) { + HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(code.getDiscountAgentId()); + code.setHighDiscount(highDiscountService.getDiscountById(rel.getDiscountId())); + code.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId())); + code.setHighOrder(highOrderService.getConsumeOrderByDiscountCode(code.getId())); + return ResponseMsgUtil.success(code); + } + return ResponseMsgUtil.success(null); + + } catch (Exception e) { + log.error("HighDiscountController -> getDiscountCodeById() error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/hai-service/src/main/java/com/hai/entity/HighDiscountAgentCode.java b/hai-service/src/main/java/com/hai/entity/HighDiscountAgentCode.java index 78246096..0ca3bbf3 100644 --- a/hai-service/src/main/java/com/hai/entity/HighDiscountAgentCode.java +++ b/hai-service/src/main/java/com/hai/entity/HighDiscountAgentCode.java @@ -1,5 +1,7 @@ package com.hai.entity; +import com.hai.model.HighDiscountAgentCodeModel; + import java.io.Serializable; import java.util.Date; @@ -12,7 +14,7 @@ import java.util.Date; * 代码由工具生成 * **/ -public class HighDiscountAgentCode implements Serializable { +public class HighDiscountAgentCode extends HighDiscountAgentCodeModel implements Serializable { /** * 主键 */ diff --git a/hai-service/src/main/java/com/hai/model/HighDiscountAgentCodeModel.java b/hai-service/src/main/java/com/hai/model/HighDiscountAgentCodeModel.java new file mode 100644 index 00000000..a562c4ec --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/HighDiscountAgentCodeModel.java @@ -0,0 +1,44 @@ +package com.hai.model; + +import com.hai.entity.HighAgent; +import com.hai.entity.HighDiscount; +import com.hai.entity.HighOrder; + +/** + * 优惠券码 + */ +public class HighDiscountAgentCodeModel { + + // 代理商 + private HighAgent highAgent; + + // 优惠券 + private HighDiscount highDiscount; + + // 订单 + private HighOrder highOrder; + + public HighAgent getHighAgent() { + return highAgent; + } + + public void setHighAgent(HighAgent highAgent) { + this.highAgent = highAgent; + } + + public HighDiscount getHighDiscount() { + return highDiscount; + } + + public void setHighDiscount(HighDiscount highDiscount) { + this.highDiscount = highDiscount; + } + + public HighOrder getHighOrder() { + return highOrder; + } + + public void setHighOrder(HighOrder highOrder) { + this.highOrder = highOrder; + } +} diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index c173f5a2..9c2e870e 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -105,6 +105,13 @@ public interface HighOrderService { **/ List getCloseOrder(); + /** + * 根据优惠券代理商id 查询已消费的订单 + * @param discountAgentId + * @return + */ + HighOrder getConsumeOrderByDiscountCode(Long discountCodeId); + /** * @Author 胡锐 * @Description 子订单完成 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java index aa1dd8ee..4f8377e1 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java @@ -1,9 +1,8 @@ package com.hai.service.impl; import com.hai.dao.HighDiscountAgentCodeMapper; -import com.hai.entity.HighDiscountAgentCode; -import com.hai.entity.HighDiscountAgentCodeExample; -import com.hai.service.HighDiscountAgentCodeService; +import com.hai.entity.*; +import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; @@ -22,6 +21,18 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe @Resource private HighDiscountAgentCodeMapper highDiscountAgentCodeMapper; + @Resource + private HighDiscountAgentRelService highDiscountAgentRelService; + + @Resource + private HighDiscountService highDiscountService; + + @Resource + private HighAgentService highAgentService; + + @Resource + private HighOrderService highOrderService; + @Override public void insertCodeList(List discountAgentCodeList) { highDiscountAgentCodeMapper.insertListCode(discountAgentCodeList); @@ -45,7 +56,21 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe if (MapUtils.getLong(map, "discountAgentId") != null) { criteria.andDiscountAgentIdEqualTo(MapUtils.getLong(map, "discountAgentId")); } - return highDiscountAgentCodeMapper.selectByExample(example); + + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } + + example.setOrderByClause("create_time desc"); + List list = highDiscountAgentCodeMapper.selectByExample(example); + for (HighDiscountAgentCode code : list) { + HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(code.getDiscountAgentId()); + if (rel != null) { + code.setHighDiscount(highDiscountService.getDiscountById(rel.getDiscountId())); + code.setHighAgent(highAgentService.findByAgentMsgId(rel.getAgentId())); + } + } + return list; } @Override diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 625e8c0a..97d6172c 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -342,6 +342,27 @@ public class HighOrderServiceImpl implements HighOrderService { return highOrderMapperExt.getCloseOrder(); } + @Override + public HighOrder getConsumeOrderByDiscountCode(Long discountCodeId) { + + // 查询优惠券有没有被使用 + HighDiscountUserRelExample example = new HighDiscountUserRelExample(); + example.createCriteria().andDiscountAgentCodeIdEqualTo(discountCodeId).andStatusEqualTo(2); + List userRels = highDiscountUserRelMapper.selectByExample(example); + + if (userRels.size() > 0) { + HighOrderExample orderExample =new HighOrderExample(); + orderExample.createCriteria().andMemDiscountIdEqualTo(userRels.get(0).getId()); + List orderList = highOrderMapper.selectByExample(orderExample); + if (orderList.size() > 0) { + HighOrder highOrder = orderList.get(0); + highOrder.setHighChildOrderList(getChildOrderByOrder(highOrder.getId())); + return highOrder; + } + } + return null; + } + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void childOrderComplete(Long childOrderId) {