提交代码

dev-discount
胡锐 2 years ago
parent 38fc6ea5f6
commit 9170a7ca25
  1. 125
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java
  2. 106
      hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapperExt.java
  3. 58
      hai-service/src/main/java/com/hai/model/DiscountUseConditionModel.java
  4. 3
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  5. 8
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  6. 4
      hai-service/src/main/resources/dev/commonConfig.properties

@ -17,13 +17,16 @@ import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil; import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator; import com.hai.common.utils.IDGenerator;
import com.hai.common.utils.PageUtil;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.QrCodeType; import com.hai.enum_type.QrCodeType;
import com.hai.model.DiscountUseConditionModel;
import com.hai.model.HighOrderModel; import com.hai.model.HighOrderModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.order.model.OrderCouponModel;
import com.hai.service.*; import com.hai.service.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; 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) @RequestMapping(value="/getDiscountAgentList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询列表") @ApiOperation(value = "查询列表")
@ -235,10 +213,10 @@ public class HighDiscountAgentRelController {
@RequestMapping(value="/getDiscountUseConditionList",method = RequestMethod.GET) @RequestMapping(value="/getDiscountUseConditionList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询优惠券使用情况") @ApiOperation(value = "查询优惠券使用情况")
public ResponseData getDiscountUseConditionList(@RequestParam(name = "discountId", required = false) Long discountId, public ResponseData getDiscountUseConditionList(@RequestParam(name = "agentId", required = false) Long agentId,
@RequestParam(name = "discountName", required = false) String discountName, @RequestParam(name = "discountId", required = false) Long discountId,
@RequestParam(name = "storeName", required = false) String storeName, @RequestParam(name = "status", required = false) String status,
@RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "userPhone", required = false) String userPhone,
@RequestParam(name = "receiveTimeS", required = false) Long receiveTimeS, @RequestParam(name = "receiveTimeS", required = false) Long receiveTimeS,
@RequestParam(name = "receiveTimeE", required = false) Long receiveTimeE, @RequestParam(name = "receiveTimeE", required = false) Long receiveTimeE,
@RequestParam(name = "useTimeS", required = false) Long useTimeS, @RequestParam(name = "useTimeS", required = false) Long useTimeS,
@ -251,17 +229,18 @@ public class HighDiscountAgentRelController {
try { try {
SessionObject sessionObject = userCenter.getSessionObject(request); SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); 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<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
if (userInfoModel.getBsCompany() != null) {
map.put("agentId", agentId);
} else if (userInfoModel.getHighAgent() != null) {
map.put("agentId", userInfoModel.getHighAgent().getId()); map.put("agentId", userInfoModel.getHighAgent().getId());
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
map.put("discountId", discountId); map.put("discountId", discountId);
map.put("discountName", discountName);
map.put("storeName", storeName);
map.put("status", status); map.put("status", status);
map.put("userPhone", userPhone);
map.put("receiveTimeS", receiveTimeS); map.put("receiveTimeS", receiveTimeS);
map.put("receiveTimeE", receiveTimeE); map.put("receiveTimeE", receiveTimeE);
map.put("useTimeS", useTimeS); map.put("useTimeS", useTimeS);
@ -278,6 +257,55 @@ public class HighDiscountAgentRelController {
} }
} }
@RequestMapping(value="/exportDiscountUseCondition",method = RequestMethod.GET)
@ResponseBody
@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<String, Object> map = new HashMap<>();
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("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 -> getDiscountUseConditionList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getDiscountCodeById",method = RequestMethod.GET) @RequestMapping(value="/getDiscountCodeById",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询优惠券码 详情") @ApiOperation(value = "查询优惠券码 详情")
@ -298,7 +326,7 @@ public class HighDiscountAgentRelController {
log.error("HighDiscountController -> getDiscountCodeById() error!",e); log.error("HighDiscountController -> getDiscountCodeById() error!",e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value="/getDiscountStatus",method = RequestMethod.POST) @RequestMapping(value="/getDiscountStatus",method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ -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);
}
}
} }

@ -1,6 +1,7 @@
package com.hai.dao; package com.hai.dao;
import com.hai.entity.HighDiscountAgentCode; import com.hai.entity.HighDiscountAgentCode;
import com.hai.model.DiscountUseConditionModel;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.JdbcType;
@ -32,61 +33,56 @@ public interface HighDiscountAgentCodeMapperExt {
void insertListCode(@Param(value = "list") List<HighDiscountAgentCode> discountAgentCodeList); void insertListCode(@Param(value = "list") List<HighDiscountAgentCode> discountAgentCodeList);
@Select({"<script>" + @Select({"<script>" +
" SELECT" + " select * FROM ( " +
" a.id," + " select " +
" a.`status`," + " a.id discountAgentCodeId, " +
" a.create_time createTime," + " c.discount_name discountName, " +
" c.discountId," + " case c.discount_type when 1 then '满减' when 2 then '抵扣' when 3 then '折扣' else '未知' end discountType, " +
" c.discountName," + " c.discount_price discountPrice, " +
" b.receiveTime," + " insert(b.phone, 4, 4, '****') userPhone, " +
" b.useEndTime," + " b.create_time receiveTime, " +
" b.useTime," + " b.use_end_time useEndTime, " +
" b.userId," + " b.use_time useTime, " +
" b.userName," + " case a.`status` " +
" insert(b.userPhone, 4, 4, '****') userPhone," + " when 1 then '待领取' " +
" b.storeName" + " when 2 then '待使用' " +
" FROM" + " when 3 then '已使用' " +
" high_discount_agent_code a" + " when 4 then '已过期' " +
" LEFT JOIN (" + " when 5 then '已分配' " +
" SELECT" + " end discountUseStatus, " +
" du.discount_agent_code_id," + " d.order_no orderNo, " +
" du.create_time receiveTime," + " d.total_price orderTotalPrice, " +
" du.use_end_time useEndTime," + " (d.total_price - d.pay_price) orderDiscountPrice, " +
" du.use_time useTime," + " d.pay_price orderPayPrice " +
" u.id userId," + " from (select id,status,discount_agent_id from high_discount_agent_code " +
" u.`name` userName," + " where discount_agent_id in (select id from high_discount_agent_rel where agent_id = #{param.agentId}" +
" u.phone userPhone," + " <if test='param.discountId != null'> and discount_id = #{param.discountId} </if> )) a " +
" c.store_name storeName" + " " +
" FROM" + " LEFT JOIN (select ur.discount_agent_code_id,ur.id,ur.create_time,ur.use_time,ur.use_end_time,u.phone " +
" high_discount_user_rel du" + " from high_discount_user_rel ur " +
" LEFT JOIN high_user u ON u.id = du.user_id " + " LEFT JOIN high_user u on u.id = ur.user_id " +
" LEFT JOIN (select a.mem_discount_id,b.store_name from (select b.id,a.mem_discount_id from high_order a" + " ) b on b.discount_agent_code_id = a.id " +
" left join high_child_order b on a.id = b.order_id " + " " +
" where a.mem_discount_id is not null " + " LEFT JOIN (select mem_discount_id,order_no,total_price,pay_price " +
" and a.order_status in (2,3,4,6,7)" + " 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 " +
" and b.giveaway_type = 0) a,high_coupon_code b where a.id = b.child_order_id GROUP BY a.mem_discount_id) c on c.mem_discount_id = du.id" + " " +
" GROUP BY" + " LEFT JOIN (select a.id, b.id discount_id,b.discount_name,b.discount_type,b.discount_price " +
" du.id " + " 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 " +
" ) b ON b.discount_agent_code_id = a.id " + " " +
" LEFT JOIN (select " + " where 1 = 1 <if test='param.userPhone != null'> <![CDATA[ AND b.phone = #{param.userPhone} ]]> </if> " +
" ca.id discountAgentCodeId," + " ORDER BY a.id desc " +
" hd.id discountId," + " " +
" hd.discount_name discountName from high_discount_agent_code ca,high_discount_agent_rel cb,high_discount hd " + " ) discountData " +
" where ca.discount_agent_id = cb.id and cb.discount_id = hd.id) c on c.discountAgentCodeId = a.id" + " where 1 = 1 " +
" WHERE" + " <if test='param.receiveTimeS != null'> <![CDATA[ AND receiveTime >= #{param.receiveTimeS} ]]> </if> " +
" a.discount_agent_id IN (SELECT id FROM high_discount_agent_rel WHERE agent_id = #{param.agentId} and status = 1)" + " <if test='param.receiveTimeE != null'> <![CDATA[ AND receiveTime <= #{param.receiveTimeE} ]]> </if> " +
" <if test='param.status != null'> and a.`status` = #{param.status} </if> " + " <if test='param.useTimeS != null'> <![CDATA[ AND useTime >= #{param.useTimeS} ]]> </if> " +
" <if test='param.discountId != null'> and c.discountId = #{param.discountId} </if> " + " <if test='param.useTimeE != null'> <![CDATA[ AND useTime <= #{param.useTimeE} ]]> </if> " +
" <if test='param.discountName != null'> and c.discountName like concat('%',#{param.discountName},'%') </if> " + " <if test='param.idS != null'> <![CDATA[ AND discountAgentCodeId >= #{param.idS} ]]> </if> " +
" <if test='param.storeName != null'> and b.storeName like concat('%',#{param.storeName},'%') </if> " + " <if test='param.idE != null'> <![CDATA[ AND discountAgentCodeId <= #{param.idE} ]]> </if> " +
" <if test='param.receiveTimeS != null'> <![CDATA[ and b.receiveTime >= #{param.receiveTimeS} ]]> </if> " + " <if test='param.status != null'> <![CDATA[ AND discountUseStatus = #{param.status} ]]> </if> " +
" <if test='param.receiveTimeE != null'> <![CDATA[ and b.receiveTime <= #{param.receiveTimeE} ]]> </if> " + "</script>" })
" <if test='param.useTimeS != null'> <![CDATA[ and b.useTime >= #{param.useTimeS} ]]> </if> " + List<DiscountUseConditionModel> getDiscountUseConditionList(@Param("param") Map<String, Object> param);
" <if test='param.useTimeE != null'> <![CDATA[ and b.useTime <= #{param.useTimeE} ]]> </if> " +
" <if test='param.idS != null'> <![CDATA[ and a.id >= #{param.idS} ]]> </if> " +
" <if test='param.idE != null'> <![CDATA[ and a.id <= #{param.idE} ]]> </if> " +
"</script>"})
List<Map<String,Object>> getDiscountUseConditionList(@Param("param") Map<String, Object> param);
@Select(" select * from high_discount_agent_code where discount_agent_id = #{discountAgentId} and status = 1 limit #{num} " ) @Select(" select * from high_discount_agent_code where discount_agent_id = #{discountAgentId} and status = 1 limit #{num} " )
@Results({ @Results({

@ -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;
}

@ -1,6 +1,7 @@
package com.hai.service; package com.hai.service;
import com.hai.entity.HighDiscountAgentCode; import com.hai.entity.HighDiscountAgentCode;
import com.hai.model.DiscountUseConditionModel;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import java.util.List; import java.util.List;
@ -46,7 +47,7 @@ public interface HighDiscountAgentCodeService {
* @param map * @param map
* @return * @return
*/ */
List<Map<String, Object>> getDiscountUseConditionList(Map<String,Object> map); List<DiscountUseConditionModel> getDiscountUseConditionList(Map<String,Object> map) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream

@ -12,6 +12,7 @@ import com.hai.dao.HighCouponCodeMapper;
import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighCouponCodeOtherMapper;
import com.hai.dao.HighDiscountAgentCodeMapper; import com.hai.dao.HighDiscountAgentCodeMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.DiscountUseConditionModel;
import com.hai.model.HighUserModel; import com.hai.model.HighUserModel;
import com.hai.service.*; import com.hai.service.*;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
@ -119,8 +120,7 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
} }
@Override @Override
public List<Map<String, Object>> getDiscountUseConditionList(Map<String, Object> map) { public List<DiscountUseConditionModel> getDiscountUseConditionList(Map<String, Object> map) throws Exception {
try {
if (MapUtils.getLong(map, "receiveTimeS") != null) { if (MapUtils.getLong(map, "receiveTimeS") != null) {
map.put("receiveTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "receiveTimeS")), "yyyy-MM-dd HH:mm:ss")); map.put("receiveTimeS", DateUtil.date2String(new Date(MapUtils.getLong(map, "receiveTimeS")), "yyyy-MM-dd HH:mm:ss"));
} }
@ -134,9 +134,7 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
if (MapUtils.getLong(map, "useTimeE") != null) { if (MapUtils.getLong(map, "useTimeE") != null) {
map.put("useTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "useTimeE")), "yyyy-MM-dd HH:mm:ss")); map.put("useTimeE", DateUtil.date2String(new Date(MapUtils.getLong(map, "useTimeE")), "yyyy-MM-dd HH:mm:ss"));
} }
} catch (Exception e) {
e.printStackTrace();
}
return highDiscountAgentCodeMapper.getDiscountUseConditionList(map); return highDiscountAgentCodeMapper.getDiscountUseConditionList(map);
} }

@ -110,8 +110,8 @@ unionRsaKey=891f6775fba7f12cc23df7c75e02b39b891f6775fba7f12c
#url #url
#fileUrl=/home/project/hsg/filesystem/ fileUrl=/home/project/hsg/filesystem/
fileUrl=/Volumes/work/filesystem/ #fileUrl=/Volumes/work/filesystem/
#wx #wx
wxAppId=wx8d49e2f83025229d wxAppId=wx8d49e2f83025229d

Loading…
Cancel
Save