## 报单赠送修改
This commit is contained in:
parent
6f707b6fa2
commit
7b339259d6
|
@ -45,14 +45,14 @@ public class AcDeclarationGiftRecordController extends BaseController {
|
|||
@GetMapping("/list")
|
||||
public TableDataInfo directPushUpgradeList(AcDeclarationListParam param) {
|
||||
startPage();
|
||||
return getDataTable(acDeclarationGiftRecordService.queryList(param));
|
||||
return getDataTable(acDeclarationGiftRecordService.selectDeclarationList(param));
|
||||
}
|
||||
|
||||
@Log(module = EOperationModule.AC_DECLARATION_GIFT_LIST_EXPORT, business = EOperationBusiness.AC_DECLARATION_GIFT_LIST_EXPORT, method = EOperationMethod.SELECT)
|
||||
@PostMapping("/listExport")
|
||||
public void export(AcDeclarationListParam param, HttpServletResponse response) {
|
||||
startPage();
|
||||
List<AcDeclarationListVO> list = acDeclarationGiftRecordService.queryList(param);
|
||||
List<AcDeclarationListVO> list = acDeclarationGiftRecordService.selectDeclarationList(param);
|
||||
ExcelUtil<AcDeclarationListVO> util = new ExcelUtil<>(AcDeclarationListVO.class);
|
||||
util.exportExcel(response, list, "报单赠送数据导出");
|
||||
}
|
||||
|
|
|
@ -18,4 +18,6 @@ import java.util.List;
|
|||
public interface AcDeclarationGiftDetailMapper extends BaseMapper<AcDeclarationGiftDetail> {
|
||||
|
||||
List<AcDeclarationProductParam> listByPKRuleId(@Param("pkId") Long pkId);
|
||||
|
||||
List<AcDeclarationProductParam> listByPKRuleIds(@Param("ruleIds") List<Long> ruleIds);
|
||||
}
|
||||
|
|
|
@ -19,4 +19,6 @@ import java.util.List;
|
|||
public interface AcDeclarationGiftRecordMapper extends BaseMapper<AcDeclarationGiftRecord> {
|
||||
|
||||
List<AcDeclarationListVO> queryList(AcDeclarationListParam param);
|
||||
|
||||
List<AcDeclarationListVO> selectDeclarationList(AcDeclarationListParam param);
|
||||
}
|
||||
|
|
|
@ -4,39 +4,46 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AcDeclarationListParam {
|
||||
|
||||
/**
|
||||
* 活动名称
|
||||
*/
|
||||
private String actName;
|
||||
|
||||
/**
|
||||
* 会员编号
|
||||
* 报单中心会员编号
|
||||
*/
|
||||
private String referenceCode;
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String referenceName;
|
||||
/**
|
||||
* 报单权限
|
||||
*/
|
||||
private Integer registerAuthority;
|
||||
/**
|
||||
* 新会员编号
|
||||
*/
|
||||
private String memberCode;
|
||||
|
||||
|
||||
/**
|
||||
* 开始活动开始时间
|
||||
* 姓名
|
||||
*/
|
||||
private String startActStartDate;
|
||||
|
||||
private String memberName;
|
||||
/**
|
||||
* 开始活动结束时间
|
||||
* 订单编号
|
||||
*/
|
||||
private String startActEndDate;
|
||||
|
||||
private String orderCode;
|
||||
/**
|
||||
* 结束活动开始时间
|
||||
* 订单支付开始时间
|
||||
*/
|
||||
private String endActStartDate;
|
||||
|
||||
private Data creationStartTime;
|
||||
/**
|
||||
* 结束活动结束时间
|
||||
* 订单支付结束时间
|
||||
*/
|
||||
private String endActEndDate;
|
||||
private Data creationEndTime;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.hzs.activity.declaration.param;
|
||||
|
||||
|
||||
import com.hzs.common.core.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -13,14 +14,24 @@ public class AcDeclarationProductParam {
|
|||
* 产品主键
|
||||
*/
|
||||
private Integer pkProduct;
|
||||
|
||||
/**
|
||||
* 活动规则主键
|
||||
*/
|
||||
private Long pkRuleId;
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
@Excel(name = "产品主键")
|
||||
private String productName;
|
||||
/**
|
||||
* 产品编号
|
||||
*/
|
||||
@Excel(name = "产品编号")
|
||||
private String productCode;
|
||||
/**
|
||||
* 产品规格(逗号分隔)
|
||||
*/
|
||||
@Excel(name = "产品规格")
|
||||
private String specsName;
|
||||
|
||||
/**
|
||||
|
@ -31,5 +42,6 @@ public class AcDeclarationProductParam {
|
|||
/**
|
||||
* 数量
|
||||
*/
|
||||
@Excel(name = "数量")
|
||||
private Long quantity;
|
||||
}
|
||||
|
|
|
@ -17,4 +17,6 @@ import java.util.List;
|
|||
public interface IAcDeclarationGiftDetailService extends IService<AcDeclarationGiftDetail> {
|
||||
|
||||
List<AcDeclarationProductParam> listByPKRuleId(Long pkId);
|
||||
|
||||
List<AcDeclarationProductParam> listByPKRuleIds(List<Long> ruleIds);
|
||||
}
|
||||
|
|
|
@ -18,5 +18,6 @@ import java.util.List;
|
|||
*/
|
||||
public interface IAcDeclarationGiftRecordService extends IService<AcDeclarationGiftRecord> {
|
||||
|
||||
List<AcDeclarationListVO> queryList(AcDeclarationListParam param);
|
||||
|
||||
List<AcDeclarationListVO> selectDeclarationList(AcDeclarationListParam param);
|
||||
}
|
||||
|
|
|
@ -25,4 +25,9 @@ public class AcDeclarationGiftDetailServiceImpl extends ServiceImpl<AcDeclaratio
|
|||
public List<AcDeclarationProductParam> listByPKRuleId(Long pkId) {
|
||||
return baseMapper.listByPKRuleId(pkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AcDeclarationProductParam> listByPKRuleIds(List<Long> ruleIds) {
|
||||
return baseMapper.listByPKRuleIds(ruleIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package com.hzs.activity.declaration.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.hzs.activity.add.param.AcAddUpgradeListParam;
|
||||
import com.hzs.activity.declaration.mapper.AcDeclarationGiftDetailMapper;
|
||||
import com.hzs.activity.declaration.mapper.AcDeclarationGiftRecordMapper;
|
||||
import com.hzs.activity.declaration.param.AcDeclarationListParam;
|
||||
import com.hzs.activity.declaration.param.AcDeclarationProductParam;
|
||||
import com.hzs.activity.declaration.service.IAcDeclarationGiftDetailService;
|
||||
import com.hzs.activity.declaration.service.IAcDeclarationGiftRecordService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.hzs.activity.declaration.vo.AcDeclarationGiftDetail;
|
||||
import com.hzs.activity.declaration.vo.AcDeclarationGiftRecord;
|
||||
import com.hzs.activity.declaration.vo.AcDeclarationListVO;
|
||||
import com.hzs.common.core.enums.ERegistrationAuthority;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -24,13 +31,61 @@ import java.util.List;
|
|||
@Service
|
||||
public class AcDeclarationGiftRecordServiceImpl extends ServiceImpl<AcDeclarationGiftRecordMapper, AcDeclarationGiftRecord> implements IAcDeclarationGiftRecordService {
|
||||
|
||||
@Autowired
|
||||
private IAcDeclarationGiftDetailService iAcDeclarationGiftDetailService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<AcDeclarationListVO> queryList(AcDeclarationListParam param) {
|
||||
List<AcDeclarationListVO> acDeclarationListVOS = baseMapper.queryList(param);
|
||||
acDeclarationListVOS.forEach(item->{
|
||||
// 将注册权限实际值注入
|
||||
item.setRegisterAuthorityVal(ERegistrationAuthority.getEnumByValue(item.getRegisterAuthority()).getLabel());
|
||||
});
|
||||
return acDeclarationListVOS;
|
||||
public List<AcDeclarationListVO> selectDeclarationList(AcDeclarationListParam param) {
|
||||
// 一次性查询所有主记录
|
||||
List<AcDeclarationListVO> voList = baseMapper.selectDeclarationList(param);
|
||||
if (voList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 提取所有规则主键
|
||||
List<Long> ruleIds = voList.stream()
|
||||
.map(AcDeclarationListVO::getPkRuleId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量查询明细
|
||||
List<AcDeclarationProductParam> allDetails = iAcDeclarationGiftDetailService.listByPKRuleIds(ruleIds);
|
||||
|
||||
// 按规则ID分组
|
||||
Map<Long, List<AcDeclarationProductParam>> detailMap = allDetails.stream()
|
||||
.collect(Collectors.groupingBy(AcDeclarationProductParam::getPkRuleId));
|
||||
|
||||
// 组装数据
|
||||
voList.forEach(item -> {
|
||||
// 绑定明细列表
|
||||
List<AcDeclarationProductParam> productList = detailMap.getOrDefault(item.getPkRuleId(), new ArrayList<>());
|
||||
item.setAcDeclarationProductParamList(productList);
|
||||
|
||||
// 报单权限转义
|
||||
item.setRegisterAuthorityVal(
|
||||
Optional.ofNullable(ERegistrationAuthority.getEnumByValue(item.getRegisterAuthority()))
|
||||
.map(ERegistrationAuthority::getLabel)
|
||||
.orElse("未知")
|
||||
);
|
||||
|
||||
// 拼接产品信息字符串
|
||||
if (!productList.isEmpty()) {
|
||||
String giftInfo = productList.stream()
|
||||
.map(p -> String.format("%s(%s) x%d",
|
||||
p.getProductName(),
|
||||
p.getSpecsName(),
|
||||
p.getQuantity()))
|
||||
.collect(Collectors.joining(";"));
|
||||
item.setGiftProductInfo(giftInfo);
|
||||
} else {
|
||||
item.setGiftProductInfo("无赠送产品");
|
||||
}
|
||||
});
|
||||
|
||||
return voList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,75 +1,88 @@
|
|||
package com.hzs.activity.declaration.vo;
|
||||
|
||||
import com.alibaba.nacos.shaded.org.checkerframework.checker.formatter.qual.Format;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.hzs.activity.declaration.param.AcDeclarationConfigParam;
|
||||
import com.hzs.activity.declaration.param.AcDeclarationProductParam;
|
||||
import com.hzs.common.core.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AcDeclarationListVO {
|
||||
|
||||
/**
|
||||
* 活动配置主键
|
||||
*/
|
||||
private Long pkRuleId;
|
||||
/**
|
||||
* 活动名称
|
||||
*/
|
||||
@Excel(name = "活动名称")
|
||||
private String actName;
|
||||
/**
|
||||
* 会员编号
|
||||
* 报单中心会员编号
|
||||
*/
|
||||
@Excel(name = "会员编号")
|
||||
private String memberCode;
|
||||
@Excel(name = "报单中心会员编号")
|
||||
private String referenceCode;
|
||||
/**
|
||||
* 会员名称
|
||||
* 姓名
|
||||
*/
|
||||
@Excel(name = "会员名称")
|
||||
private String memberName;
|
||||
|
||||
@Excel(name = "报单中心会员名称")
|
||||
private String referenceName;
|
||||
/**
|
||||
* 注册权限
|
||||
* 报单权限
|
||||
*/
|
||||
private Integer registerAuthority;
|
||||
/**
|
||||
* 注册权限实际值
|
||||
* 报单权限实际值
|
||||
*/
|
||||
@Excel(name = "注册权限")
|
||||
@Excel(name = "报单权限")
|
||||
private String registerAuthorityVal;
|
||||
|
||||
|
||||
/**
|
||||
* 活动开始时间
|
||||
* 新会员编号
|
||||
*/
|
||||
@Excel(name = "活动开始时间", dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date actStartDate;
|
||||
|
||||
@Excel(name = "新会员编号")
|
||||
private String memberCode;
|
||||
/**
|
||||
* 活动结束时间
|
||||
* 姓名
|
||||
*/
|
||||
@Excel(name = "活动结束时间", dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date actEndDate;
|
||||
|
||||
@Excel(name = "新会员名称")
|
||||
private String memberName;
|
||||
/**
|
||||
* 创建时间
|
||||
* 订单编号
|
||||
*/
|
||||
@Excel(name = "创建时间", dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date creationTime;
|
||||
|
||||
@Excel(name = "订单编号")
|
||||
private String orderCode;
|
||||
/**
|
||||
* 产品名称
|
||||
* 订单支付时间
|
||||
*/
|
||||
@Excel(name = "订单支付时间",dateFormat = "yyyy-HH-mm")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date payTime;
|
||||
/**
|
||||
* 指定等级实际值
|
||||
*/
|
||||
@Excel(name = "产品名称")
|
||||
private String productName;
|
||||
|
||||
@Excel(name = "数量")
|
||||
private Integer quantity;
|
||||
|
||||
@Excel(name = "指定等级")
|
||||
private String specifyLevelVal;
|
||||
|
||||
/**
|
||||
* 指定等级
|
||||
*/
|
||||
private Integer specifyLevel;
|
||||
/**
|
||||
* 产品信息
|
||||
*/
|
||||
private List<AcDeclarationProductParam> acDeclarationProductParamList;
|
||||
|
||||
/**
|
||||
* 产品信息字符串(拼接导出用)
|
||||
*/
|
||||
@Excel(name = "赠送产品信息")
|
||||
private String giftProductInfo;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
<select id="listByPKRuleId" resultType="com.hzs.activity.declaration.param.AcDeclarationProductParam">
|
||||
SELECT
|
||||
adgd.*,
|
||||
bp.PRODUCT_NAME
|
||||
bp.PRODUCT_NAME,
|
||||
bp.PRODUCT_CODE
|
||||
FROM
|
||||
AC_DECLARATION_GIFT_DETAIL adgd
|
||||
LEFT JOIN BD_PRODUCT bp ON adgd.PK_PRODUCT = bp.PK_ID
|
||||
|
@ -39,5 +40,20 @@
|
|||
adgd.PK_RULE_ID = #{ pkId }
|
||||
AND adgd.DEL_FLAG = 0
|
||||
</select>
|
||||
<select id="listByPKRuleIds" resultType="com.hzs.activity.declaration.param.AcDeclarationProductParam">
|
||||
SELECT
|
||||
adgd.*,
|
||||
bp.PRODUCT_NAME,
|
||||
bp.PRODUCT_CODE
|
||||
FROM
|
||||
AC_DECLARATION_GIFT_DETAIL adgd
|
||||
LEFT JOIN BD_PRODUCT bp ON adgd.PK_PRODUCT = bp.PK_ID
|
||||
WHERE
|
||||
adgd.PK_RULE_ID in
|
||||
<foreach collection="ruleIds" item="items" open="(" close=")" separator=",">
|
||||
#{items}
|
||||
</foreach>
|
||||
AND adgd.DEL_FLAG = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -67,5 +67,55 @@
|
|||
AND abc.ACT_END_DATE <= TO_DATE(SUBSTR(#{endActEndDate},1,10), 'YYYY-MM-DD')
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectDeclarationList" resultType="com.hzs.activity.declaration.vo.AcDeclarationListVO">
|
||||
SELECT
|
||||
adgr.PK_RULE_ID,
|
||||
abc.ACT_NAME,
|
||||
cm.MEMBER_CODE AS referenceCode,
|
||||
cm.MEMBER_NAME AS referenceName,
|
||||
cm.REGISTER_AUTHORITY,
|
||||
cmm.MEMBER_CODE AS memberCode,
|
||||
cmm.MEMBER_NAME AS memberName,
|
||||
so.ORDER_CODE,
|
||||
so.PAY_TIME,
|
||||
bg.GRADE_NAME AS specifyLevelVal
|
||||
FROM
|
||||
AC_DECLARATION_GIFT_RECORD adgr
|
||||
LEFT JOIN AC_DECLARATION_GIFT_CONFIG adgc ON adgr.PK_RULE_ID = adgc.PK_ID
|
||||
LEFT JOIN BD_GRADE bg ON adgc.SPECIFY_LEVEL = bg.PK_ID
|
||||
LEFT JOIN SA_ORDER so ON adgr.ORDER_CODE = so.ORDER_CODE
|
||||
LEFT JOIN CU_MEMBER cm ON so.PK_REFERENCE = cm.PK_ID
|
||||
LEFT JOIN CU_MEMBER cmm ON so.PK_MEMBER = cmm.PK_ID
|
||||
LEFT JOIN AC_BASE_CONFIG abc ON adgr.PK_BASE_ID = abc.PK_ID
|
||||
WHERE
|
||||
so.ORDER_STATUS = 1 AND so.DEL_FLAG = 0
|
||||
<if test="actName != null and actName != ''">
|
||||
AND abc.ACT_NAME = #{actName}
|
||||
</if>
|
||||
<if test="referenceCode != null and referenceCode != ''">
|
||||
AND cm.member_code = #{referenceCode}
|
||||
</if>
|
||||
<if test="referenceName != null and referenceName != ''">
|
||||
AND cm.member_name = #{referenceName}
|
||||
</if>
|
||||
<if test="registerAuthority != null and registerAuthority != ''">
|
||||
AND cm.REGISTER_AUTHORITY = #{registerAuthority}
|
||||
</if>
|
||||
<if test="memberCode != null and memberCode != ''">
|
||||
AND cmm.member_code = #{memberCode}
|
||||
</if>
|
||||
<if test="memberName != null and memberName != ''">
|
||||
AND cmm.member_name = #{memberName}
|
||||
</if>
|
||||
<if test="orderCode != null and orderCode != ''">
|
||||
AND so.order_code = #{orderCode}
|
||||
</if>
|
||||
<if test="creationStartTime!= null and creationStartTime != ''">
|
||||
AND adgr.CREATION_TIME >= #{creationStartTime}
|
||||
</if>
|
||||
<if test="creationEndTime!= null and creationEndTime != ''">
|
||||
AND adgr.CREATION_TIME <= #{creationEndTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue