From 9170a7ca25d52f5103c985fda0f94c01294605b9 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 28 Mar 2023 18:04:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HighDiscountAgentRelController.java | 149 ++++++++++++------ .../dao/HighDiscountAgentCodeMapperExt.java | 106 ++++++------- .../hai/model/DiscountUseConditionModel.java | 58 +++++++ .../service/HighDiscountAgentCodeService.java | 3 +- .../HighDiscountAgentCodeServiceImpl.java | 30 ++-- .../resources/dev/commonConfig.properties | 4 +- 6 files changed, 228 insertions(+), 122 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/model/DiscountUseConditionModel.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 53665372..35e088fa 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java @@ -17,13 +17,16 @@ import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.common.utils.IDGenerator; +import com.hai.common.utils.PageUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.CommonSysConst; import com.hai.entity.*; import com.hai.enum_type.QrCodeType; +import com.hai.model.DiscountUseConditionModel; import com.hai.model.HighOrderModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.order.model.OrderCouponModel; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -164,31 +167,6 @@ public class HighDiscountAgentRelController { } } - @RequestMapping(value="/exportReceive",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "导出领取记录") - public ResponseData exportReceive(@RequestParam(name = "id", required = true) Long id) { - try { - HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(id); - if (rel == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "数据不存在"); - } - - String fileUrl = SysConst.getSysConfig().getFileUrl() + "/temporary/"; - String pathName = System.currentTimeMillis()+".xlsx"; - File file = new File(fileUrl); - if (!file.exists()) { - file.mkdirs(); - } - // EasyExcel.write(fileUrl+pathName).sheet("sheet1").doWrite(dataList); - return ResponseMsgUtil.success(pathName); - - } catch (Exception e) { - log.error("HighDiscountController -> getReceiveLink() error!",e); - return ResponseMsgUtil.exception(e); - } - } - @RequestMapping(value="/getDiscountAgentList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询列表") @@ -235,10 +213,10 @@ public class HighDiscountAgentRelController { @RequestMapping(value="/getDiscountUseConditionList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询优惠券使用情况") - public ResponseData getDiscountUseConditionList(@RequestParam(name = "discountId", required = false) Long discountId, - @RequestParam(name = "discountName", required = false) String discountName, - @RequestParam(name = "storeName", required = false) String storeName, - @RequestParam(name = "status", required = false) Integer status, + public ResponseData getDiscountUseConditionList(@RequestParam(name = "agentId", required = false) Long agentId, + @RequestParam(name = "discountId", required = false) Long discountId, + @RequestParam(name = "status", required = false) String status, + @RequestParam(name = "userPhone", required = false) String userPhone, @RequestParam(name = "receiveTimeS", required = false) Long receiveTimeS, @RequestParam(name = "receiveTimeE", required = false) Long receiveTimeE, @RequestParam(name = "useTimeS", required = false) Long useTimeS, @@ -251,17 +229,18 @@ public class HighDiscountAgentRelController { try { SessionObject sessionObject = userCenter.getSessionObject(request); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); - if (userInfoModel.getHighAgent() == null) { - log.error("HighCouponController -> insertCoupon() error!","该主角色没有权限"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); - } Map map = new HashMap<>(); - map.put("agentId", userInfoModel.getHighAgent().getId()); + if (userInfoModel.getBsCompany() != null) { + map.put("agentId", agentId); + } else if (userInfoModel.getHighAgent() != null) { + map.put("agentId", userInfoModel.getHighAgent().getId()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); + } map.put("discountId", discountId); - map.put("discountName", discountName); - map.put("storeName", storeName); map.put("status", status); + map.put("userPhone", userPhone); map.put("receiveTimeS", receiveTimeS); map.put("receiveTimeE", receiveTimeE); map.put("useTimeS", useTimeS); @@ -278,28 +257,77 @@ public class HighDiscountAgentRelController { } } - @RequestMapping(value="/getDiscountCodeById",method = RequestMethod.GET) + @RequestMapping(value="/exportDiscountUseCondition",method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "查询优惠券码 详情") - public ResponseData getDiscountCodeById(@RequestParam(name = "couponCodeId", required = true) Long couponCodeId) { + @ApiOperation(value = "查询优惠券使用情况") + public ResponseData exportDiscountUseCondition(@RequestParam(name = "agentId", required = false) Long agentId, + @RequestParam(name = "discountId", required = false) Long discountId, + @RequestParam(name = "status", required = false) String status, + @RequestParam(name = "userPhone", required = false) String userPhone, + @RequestParam(name = "receiveTimeS", required = false) Long receiveTimeS, + @RequestParam(name = "receiveTimeE", required = false) Long receiveTimeE, + @RequestParam(name = "useTimeS", required = false) Long useTimeS, + @RequestParam(name = "useTimeE", required = false) Long useTimeE, + @RequestParam(name = "idS", required = false) Long idS, + @RequestParam(name = "idE", required = false) Long idE, + HttpServletRequest request) { try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + Map map = new HashMap<>(); - 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); + if (userInfoModel.getBsCompany() != null) { + map.put("agentId", agentId); + } else if (userInfoModel.getHighAgent() != null) { + map.put("agentId", userInfoModel.getHighAgent().getId()); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); } - return ResponseMsgUtil.success(null); + map.put("discountId", discountId); + map.put("status", status); + map.put("userPhone", userPhone); + map.put("receiveTimeS", receiveTimeS); + map.put("receiveTimeE", receiveTimeE); + map.put("useTimeS", useTimeS); + map.put("useTimeE", useTimeE); + map.put("idS", idS); + map.put("idE", idE); + + String fileName = "/temporary/" + System.currentTimeMillis() + ".xlsx"; + EasyExcel.write(SysConst.getSysConfig().getFileUrl() + fileName, DiscountUseConditionModel.class) + .sheet("sheet1") + .doWrite(highDiscountAgentCodeService.getDiscountUseConditionList(map)); + + return ResponseMsgUtil.success(fileName); } catch (Exception e) { - log.error("HighDiscountController -> getDiscountCodeById() error!",e); + log.error("HighDiscountController -> getDiscountUseConditionList() 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); + } +} + @RequestMapping(value="/getDiscountStatus",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "修改状态") @@ -327,4 +355,29 @@ public class HighDiscountAgentRelController { } } + @RequestMapping(value="/exportDiscountReceive",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出领取记录") + public ResponseData exportDiscountReceive(@RequestParam(name = "id", required = true) Long id) { + try { + HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(id); + if (rel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "数据不存在"); + } + + String fileUrl = SysConst.getSysConfig().getFileUrl() + "/temporary/"; + String pathName = System.currentTimeMillis()+".xlsx"; + File file = new File(fileUrl); + if (!file.exists()) { + file.mkdirs(); + } + // EasyExcel.write(fileUrl+pathName).sheet("sheet1").doWrite(dataList); + return ResponseMsgUtil.success(pathName); + + } catch (Exception e) { + log.error("HighDiscountController -> getReceiveLink() error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapperExt.java index 5c72d708..91006c2e 100644 --- a/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapperExt.java @@ -1,6 +1,7 @@ package com.hai.dao; import com.hai.entity.HighDiscountAgentCode; +import com.hai.model.DiscountUseConditionModel; import org.apache.ibatis.annotations.*; import org.apache.ibatis.type.JdbcType; @@ -32,61 +33,56 @@ public interface HighDiscountAgentCodeMapperExt { void insertListCode(@Param(value = "list") List discountAgentCodeList); @Select({""}) - List> getDiscountUseConditionList(@Param("param") Map param); + " select * FROM ( " + + " select " + + " a.id discountAgentCodeId, " + + " c.discount_name discountName, " + + " case c.discount_type when 1 then '满减' when 2 then '抵扣' when 3 then '折扣' else '未知' end discountType, " + + " c.discount_price discountPrice, " + + " insert(b.phone, 4, 4, '****') userPhone, " + + " b.create_time receiveTime, " + + " b.use_end_time useEndTime, " + + " b.use_time useTime, " + + " case a.`status` " + + " when 1 then '待领取' " + + " when 2 then '待使用' " + + " when 3 then '已使用' " + + " when 4 then '已过期' " + + " when 5 then '已分配' " + + " end discountUseStatus, " + + " d.order_no orderNo, " + + " d.total_price orderTotalPrice, " + + " (d.total_price - d.pay_price) orderDiscountPrice, " + + " d.pay_price orderPayPrice " + + " from (select id,status,discount_agent_id from high_discount_agent_code " + + " where discount_agent_id in (select id from high_discount_agent_rel where agent_id = #{param.agentId}" + + " and discount_id = #{param.discountId} )) a " + + " " + + " LEFT JOIN (select ur.discount_agent_code_id,ur.id,ur.create_time,ur.use_time,ur.use_end_time,u.phone " + + " from high_discount_user_rel ur " + + " LEFT JOIN high_user u on u.id = ur.user_id " + + " ) b on b.discount_agent_code_id = a.id " + + " " + + " LEFT JOIN (select mem_discount_id,order_no,total_price,pay_price " + + " from high_order where mem_discount_id is not null and order_status in (2,3) GROUP BY mem_discount_id) d on d.mem_discount_id = b.id " + + " " + + " LEFT JOIN (select a.id, b.id discount_id,b.discount_name,b.discount_type,b.discount_price " + + " from high_discount_agent_rel a, high_discount b where a.discount_id = b.id GROUP BY a.id) c on c.id = a.discount_agent_id " + + " " + + " where 1 = 1 " + + " ORDER BY a.id desc " + + " " + + " ) discountData " + + " where 1 = 1 " + + " = #{param.receiveTimeS} ]]> " + + " " + + " = #{param.useTimeS} ]]> " + + " " + + " = #{param.idS} ]]> " + + " " + + " " + + "" }) + List getDiscountUseConditionList(@Param("param") Map param); @Select(" select * from high_discount_agent_code where discount_agent_id = #{discountAgentId} and status = 1 limit #{num} " ) @Results({ diff --git a/hai-service/src/main/java/com/hai/model/DiscountUseConditionModel.java b/hai-service/src/main/java/com/hai/model/DiscountUseConditionModel.java new file mode 100644 index 00000000..4d71b7d4 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/DiscountUseConditionModel.java @@ -0,0 +1,58 @@ +package com.hai.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @className: DiscountUseConditionModel + * @author: HuRui + * @date: 2023/3/28 + **/ +@Data +public class DiscountUseConditionModel { + + @ColumnWidth(15) + @ExcelProperty("优惠券编码") + private Long discountAgentCodeId; + @ColumnWidth(25) + @ExcelProperty("优惠券名称") + private String discountName; + @ColumnWidth(15) + @ExcelProperty("优惠券类型") + private String discountType; + @ColumnWidth(15) + @ExcelProperty("优惠券价格") + private BigDecimal discountPrice; + @ColumnWidth(15) + @ExcelProperty("优惠券状态") + private String discountUseStatus; + @ColumnWidth(15) + @ExcelProperty("客户电话") + private String userPhone; + @ColumnWidth(20) + @ExcelProperty("领取时间") + private Date receiveTime; + @ColumnWidth(20) + @ExcelProperty("过期时间") + private Date useEndTime; + @ColumnWidth(20) + @ExcelProperty("使用时间") + private Date useTime; + @ColumnWidth(25) + @ExcelProperty("交易订单号") + private String orderNo; + @ColumnWidth(15) + @ExcelProperty("交易金额") + private BigDecimal orderTotalPrice; + @ColumnWidth(15) + @ExcelProperty("交易优惠") + private BigDecimal orderDiscountPrice; + @ColumnWidth(15) + @ExcelProperty("交易实付") + private BigDecimal orderPayPrice; + +} diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java b/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java index 169237b3..3e20f95c 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java @@ -1,6 +1,7 @@ package com.hai.service; import com.hai.entity.HighDiscountAgentCode; +import com.hai.model.DiscountUseConditionModel; import io.swagger.models.auth.In; import java.util.List; @@ -46,7 +47,7 @@ public interface HighDiscountAgentCodeService { * @param map * @return */ - List> getDiscountUseConditionList(Map map); + List getDiscountUseConditionList(Map map) throws Exception; /** * @Author Sum1Dream 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 c3918ae1..49c5b38d 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 @@ -12,6 +12,7 @@ import com.hai.dao.HighCouponCodeMapper; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighDiscountAgentCodeMapper; import com.hai.entity.*; +import com.hai.model.DiscountUseConditionModel; import com.hai.model.HighUserModel; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; @@ -119,24 +120,21 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe } @Override - public List> getDiscountUseConditionList(Map map) { - try { - if (MapUtils.getLong(map, "receiveTimeS") != null) { - map.put("receiveTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "receiveTimeS")), "yyyy-MM-dd HH:mm:ss")); - } - if (MapUtils.getLong(map, "receiveTimeE") != null) { - map.put("receiveTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "receiveTimeE")), "yyyy-MM-dd HH:mm:ss")); - } + public List getDiscountUseConditionList(Map map) throws Exception { + if (MapUtils.getLong(map, "receiveTimeS") != null) { + map.put("receiveTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "receiveTimeS")), "yyyy-MM-dd HH:mm:ss")); + } + if (MapUtils.getLong(map, "receiveTimeE") != null) { + map.put("receiveTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "receiveTimeE")), "yyyy-MM-dd HH:mm:ss")); + } - if (MapUtils.getLong(map, "useTimeS") != null) { - map.put("useTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "useTimeS")), "yyyy-MM-dd HH:mm:ss")); - } - if (MapUtils.getLong(map, "useTimeE") != null) { - map.put("useTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "useTimeE")), "yyyy-MM-dd HH:mm:ss")); - } - } catch (Exception e) { - e.printStackTrace(); + if (MapUtils.getLong(map, "useTimeS") != null) { + map.put("useTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "useTimeS")), "yyyy-MM-dd HH:mm:ss")); } + if (MapUtils.getLong(map, "useTimeE") != null) { + map.put("useTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "useTimeE")), "yyyy-MM-dd HH:mm:ss")); + } + return highDiscountAgentCodeMapper.getDiscountUseConditionList(map); } diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index ec3f971c..71cd949b 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -110,8 +110,8 @@ unionRsaKey=891f6775fba7f12cc23df7c75e02b39b891f6775fba7f12c #url -#fileUrl=/home/project/hsg/filesystem/ -fileUrl=/Volumes/work/filesystem/ +fileUrl=/home/project/hsg/filesystem/ +#fileUrl=/Volumes/work/filesystem/ #wx wxAppId=wx8d49e2f83025229d