mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 01:01:52 +08:00
优惠券:完善APP优惠券查询接口
This commit is contained in:
parent
a431bccc02
commit
0a3a6825d5
@ -1188,8 +1188,8 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st
|
|||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1166, 2, '折扣', '2', 'promotion_discount_type', 0, 'primary', '', '优惠类型 - 折扣', '1', '2022-11-01 12:46:51', '1', '2022-11-01 12:50:08', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1166, 2, '折扣', '2', 'promotion_discount_type', 0, 'primary', '', '优惠类型 - 折扣', '1', '2022-11-01 12:46:51', '1', '2022-11-01 12:50:08', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1167, 1, '固定日期', '1', 'promotion_coupon_template_validity_type', 0, 'default', '', '优惠劵模板的有限期类型 - 固定日期', '1', '2022-11-02 00:07:34', '1', '2022-11-04 00:07:49', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1167, 1, '固定日期', '1', 'promotion_coupon_template_validity_type', 0, 'default', '', '优惠劵模板的有限期类型 - 固定日期', '1', '2022-11-02 00:07:34', '1', '2022-11-04 00:07:49', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1168, 2, '领取之后', '2', 'promotion_coupon_template_validity_type', 0, 'default', '', '优惠劵模板的有限期类型 - 领取之后', '1', '2022-11-02 00:07:54', '1', '2022-11-04 00:07:52', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1168, 2, '领取之后', '2', 'promotion_coupon_template_validity_type', 0, 'default', '', '优惠劵模板的有限期类型 - 领取之后', '1', '2022-11-02 00:07:54', '1', '2022-11-04 00:07:52', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1169, 1, '通用卷', '1', 'promotion_product_scope', 0, 'default', '', '营销的商品范围 - 全部商品参与', '1', '2022-11-02 00:28:22', '1', '2023-09-01 23:42:49', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1169, 1, '通用券', '1', 'promotion_product_scope', 0, 'default', '', '营销的商品范围 - 全部商品参与', '1', '2022-11-02 00:28:22', '1', '2023-09-01 23:42:49', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1170, 2, '商品卷', '2', 'promotion_product_scope', 0, 'default', '', '营销的商品范围 - 指定商品参与', '1', '2022-11-02 00:28:34', '1', '2023-09-01 23:42:54', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1170, 2, '商品券', '2', 'promotion_product_scope', 0, 'default', '', '营销的商品范围 - 指定商品参与', '1', '2022-11-02 00:28:34', '1', '2023-09-01 23:42:54', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1171, 1, '已领取', '1', 'promotion_coupon_status', 0, 'primary', '', '优惠劵的状态 - 已领取', '1', '2022-11-04 00:15:08', '1', '2022-11-04 19:16:04', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1171, 1, '已领取', '1', 'promotion_coupon_status', 0, 'primary', '', '优惠劵的状态 - 已领取', '1', '2022-11-04 00:15:08', '1', '2022-11-04 19:16:04', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1172, 2, '已使用', '2', 'promotion_coupon_status', 0, 'success', '', '优惠劵的状态 - 已使用', '1', '2022-11-04 00:15:21', '1', '2022-11-04 19:16:08', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1172, 2, '已使用', '2', 'promotion_coupon_status', 0, 'success', '', '优惠劵的状态 - 已使用', '1', '2022-11-04 00:15:21', '1', '2022-11-04 19:16:08', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1173, 3, '已过期', '3', 'promotion_coupon_status', 0, 'info', '', '优惠劵的状态 - 已过期', '1', '2022-11-04 00:15:43', '1', '2022-11-04 19:16:12', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1173, 3, '已过期', '3', 'promotion_coupon_status', 0, 'info', '', '优惠劵的状态 - 已过期', '1', '2022-11-04 00:15:43', '1', '2022-11-04 19:16:12', b'0');
|
||||||
@ -1284,7 +1284,7 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st
|
|||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1355, 5, '抽奖奖励', '5', 'member_experience_biz_type', 0, '', '', NULL, '', '2023-08-22 12:41:01', '', '2023-08-22 12:41:01', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1355, 5, '抽奖奖励', '5', 'member_experience_biz_type', 0, '', '', NULL, '', '2023-08-22 12:41:01', '', '2023-08-22 12:41:01', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1356, 1, '快递发货', '1', 'trade_delivery_type', 0, '', '', '', '1', '2023-08-23 00:04:55', '1', '2023-08-23 00:04:55', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1356, 1, '快递发货', '1', 'trade_delivery_type', 0, '', '', '', '1', '2023-08-23 00:04:55', '1', '2023-08-23 00:04:55', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1357, 2, '用户自提', '2', 'trade_delivery_type', 0, '', '', '', '1', '2023-08-23 00:05:05', '1', '2023-08-23 00:05:05', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1357, 2, '用户自提', '2', 'trade_delivery_type', 0, '', '', '', '1', '2023-08-23 00:05:05', '1', '2023-08-23 00:05:05', b'0');
|
||||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1358, 3, '品类卷', '3', 'promotion_product_scope', 0, 'default', '', '', '1', '2023-09-01 23:43:07', '1', '2023-09-01 23:43:07', b'0');
|
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1358, 3, '品类券', '3', 'promotion_product_scope', 0, 'default', '', '', '1', '2023-09-01 23:43:07', '1', '2023-09-01 23:43:07', b'0');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
@ -68,7 +68,7 @@ public class RewardActivityMatchRespDTO {
|
|||||||
*/
|
*/
|
||||||
private List<Long> couponIds;
|
private List<Long> couponIds;
|
||||||
/**
|
/**
|
||||||
* 赠送的优惠卷数量的数组
|
* 赠送的优惠券数量的数组
|
||||||
*/
|
*/
|
||||||
private List<Integer> couponCounts;
|
private List<Integer> couponCounts;
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ import java.util.Arrays;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum PromotionProductScopeEnum implements IntArrayValuable {
|
public enum PromotionProductScopeEnum implements IntArrayValuable {
|
||||||
|
|
||||||
ALL(1, "通用卷"), // 全部商品
|
ALL(1, "通用券"), // 全部商品
|
||||||
SPU(2, "商品卷"), // 指定商品
|
SPU(2, "商品券"), // 指定商品
|
||||||
CATEGORY(3, "品类卷"), // 指定商品
|
CATEGORY(3, "品类券"), // 指定品类
|
||||||
;
|
;
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray();
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -37,4 +38,10 @@ public class CouponTemplatePageReqVO extends PageParam {
|
|||||||
@InEnum(value = CouponTakeTypeEnum.class, message = "可以领取的类型,必须是 {value}")
|
@InEnum(value = CouponTakeTypeEnum.class, message = "可以领取的类型,必须是 {value}")
|
||||||
private List<Integer> canTakeTypes;
|
private List<Integer> canTakeTypes;
|
||||||
|
|
||||||
|
@Schema(description = "商品范围", example = "1")
|
||||||
|
@InEnum(value = PromotionProductScopeEnum.class, message = "商品范围,必须是 {value}")
|
||||||
|
private Integer productScope;
|
||||||
|
|
||||||
|
@Schema(description = "商品范围编号", example = "1")
|
||||||
|
private Long productScopeValue;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class RewardActivityBaseVO {
|
|||||||
@Schema(description = "赠送的优惠劵编号的数组", example = "1,2,3")
|
@Schema(description = "赠送的优惠劵编号的数组", example = "1,2,3")
|
||||||
private List<Long> couponIds;
|
private List<Long> couponIds;
|
||||||
|
|
||||||
@Schema(description = "赠送的优惠卷数量的数组", example = "1,2,3")
|
@Schema(description = "赠送的优惠券数量的数组", example = "1,2,3")
|
||||||
private List<Integer> couponCounts;
|
private List<Integer> couponCounts;
|
||||||
|
|
||||||
@AssertTrue(message = "优惠劵和数量必须一一对应")
|
@AssertTrue(message = "优惠劵和数量必须一一对应")
|
||||||
|
@ -1,27 +1,31 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon;
|
package cn.iocoder.yudao.module.promotion.controller.app.coupon;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplatePageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template.AppCouponTemplateRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||||
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.coupon.CouponService;
|
||||||
import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService;
|
import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
@Tag(name = "用户 App - 优惠劵模板")
|
@Tag(name = "用户 App - 优惠劵模板")
|
||||||
@RestController
|
@RestController
|
||||||
@ -31,84 +35,45 @@ public class AppCouponTemplateController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CouponTemplateService couponTemplateService;
|
private CouponTemplateService couponTemplateService;
|
||||||
|
@Resource
|
||||||
|
private CouponService couponService;
|
||||||
|
|
||||||
// TODO 芋艿:待实现
|
@Resource
|
||||||
@GetMapping("/list")
|
private ProductSpuApi productSpuApi;
|
||||||
@Operation(summary = "获得优惠劵模版列表")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = "spuId", description = "商品 SPU 编号"), // 目前主要给商品详情使用
|
|
||||||
@Parameter(name = "useType", description = "使用类型"),
|
|
||||||
@Parameter(name = "count", description = "数量", required = true)
|
|
||||||
})
|
|
||||||
public CommonResult<List<AppCouponTemplateRespVO>> getCouponTemplateList(@RequestParam(value = "spuId", required = false) Long spuId,
|
|
||||||
@RequestParam(value = "useType", required = false) Integer useType,
|
|
||||||
@RequestParam(value = "count", required = false, defaultValue = "10") Integer count) {
|
|
||||||
List<AppCouponTemplateRespVO> list = new ArrayList<>();
|
|
||||||
Random random = new Random();
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
AppCouponTemplateRespVO vo = new AppCouponTemplateRespVO();
|
|
||||||
vo.setId(i + 1L);
|
|
||||||
vo.setName("优惠劵" + (i + 1));
|
|
||||||
vo.setTakeLimitCount(random.nextInt(10) + 1);
|
|
||||||
vo.setUsePrice(random.nextInt(100) * 100);
|
|
||||||
vo.setValidityType(random.nextInt(2) + 1);
|
|
||||||
if (vo.getValidityType() == 1) {
|
|
||||||
vo.setValidStartTime(LocalDateTime.now().plusDays(random.nextInt(10)));
|
|
||||||
vo.setValidEndTime(LocalDateTime.now().plusDays(random.nextInt(20) + 10));
|
|
||||||
} else {
|
|
||||||
vo.setFixedStartTerm(random.nextInt(10));
|
|
||||||
vo.setFixedEndTerm(random.nextInt(10) + vo.getFixedStartTerm() + 1);
|
|
||||||
}
|
|
||||||
vo.setDiscountType(random.nextInt(2) + 1);
|
|
||||||
if (vo.getDiscountType() == 1) {
|
|
||||||
vo.setDiscountPercent(null);
|
|
||||||
vo.setDiscountPrice(random.nextInt(50) * 100);
|
|
||||||
vo.setDiscountLimitPrice(null);
|
|
||||||
} else {
|
|
||||||
vo.setDiscountPercent(random.nextInt(90) + 10);
|
|
||||||
vo.setDiscountPrice(null);
|
|
||||||
vo.setDiscountLimitPrice(random.nextInt(200) * 100);
|
|
||||||
}
|
|
||||||
vo.setTakeStatus(random.nextBoolean());
|
|
||||||
list.add(vo);
|
|
||||||
}
|
|
||||||
return success(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO 芋艿:待实现;和 getCouponTemplateList 类似
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得优惠劵模版分页")
|
@Operation(summary = "获得优惠劵模版分页")
|
||||||
public CommonResult<PageResult<AppCouponTemplateRespVO>> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) {
|
public CommonResult<PageResult<AppCouponTemplateRespVO>> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) {
|
||||||
List<AppCouponTemplateRespVO> list = new ArrayList<>();
|
// 1.1 处理查询条件:商品范围编号
|
||||||
Random random = new Random();
|
Long productScopeValue = getaProductScopeValue(pageReqVO);
|
||||||
for (int i = 0; i < 10; i++) {
|
// 1.2 处理查询条件:领取方式=直接领取
|
||||||
AppCouponTemplateRespVO vo = new AppCouponTemplateRespVO();
|
List<Integer> canTakeTypes = Collections.singletonList(CouponTakeTypeEnum.USER.getValue());
|
||||||
vo.setId(i + 1L);
|
// 2. 分页查询
|
||||||
vo.setName("优惠劵" + (i + 1));
|
PageResult<CouponTemplateDO> pageResult = couponTemplateService.getCouponTemplatePage(
|
||||||
vo.setTakeLimitCount(random.nextInt(10) + 1);
|
CouponTemplateConvert.INSTANCE.convert(pageReqVO, canTakeTypes, pageReqVO.getProductScope(), productScopeValue));
|
||||||
vo.setUsePrice(random.nextInt(100) * 100);
|
// 3.1 领取数量
|
||||||
vo.setValidityType(random.nextInt(2) + 1);
|
Map<Long, Integer> couponTakeCountMap = new HashMap<>(0);
|
||||||
if (vo.getValidityType() == 1) {
|
Long userId = getLoginUserId();
|
||||||
vo.setValidStartTime(LocalDateTime.now().plusDays(random.nextInt(10)));
|
if (userId != null) {
|
||||||
vo.setValidEndTime(LocalDateTime.now().plusDays(random.nextInt(20) + 10));
|
List<Long> templateIds = convertList(pageResult.getList(), CouponTemplateDO::getId,
|
||||||
} else {
|
t -> ObjUtil.notEqual(t.getTakeLimitCount(), -1)); // 只查有设置“每人限领个数”的
|
||||||
vo.setFixedStartTerm(random.nextInt(10));
|
couponTakeCountMap = couponService.getTakeCountMapByTemplateIds(templateIds, userId);
|
||||||
vo.setFixedEndTerm(random.nextInt(10) + vo.getFixedStartTerm() + 1);
|
|
||||||
}
|
}
|
||||||
vo.setDiscountType(random.nextInt(2) + 1);
|
// 3.2 拼接返回
|
||||||
if (vo.getDiscountType() == 1) {
|
return success(CouponTemplateConvert.INSTANCE.convertAppPage(pageResult, couponTakeCountMap));
|
||||||
vo.setDiscountPercent(null);
|
|
||||||
vo.setDiscountPrice(random.nextInt(50) * 100);
|
|
||||||
vo.setDiscountLimitPrice(null);
|
|
||||||
} else {
|
|
||||||
vo.setDiscountPercent(random.nextInt(90) + 10);
|
|
||||||
vo.setDiscountPrice(null);
|
|
||||||
vo.setDiscountLimitPrice(random.nextInt(200) * 100);
|
|
||||||
}
|
}
|
||||||
vo.setTakeStatus(random.nextBoolean());
|
|
||||||
list.add(vo);
|
private Long getaProductScopeValue(AppCouponTemplatePageReqVO pageReqVO) {
|
||||||
|
Long productScopeValue = pageReqVO.getSpuId();
|
||||||
|
if (pageReqVO.getProductScope() == null || Objects.equals(pageReqVO.getProductScope(), PromotionProductScopeEnum.ALL.getScope())) {
|
||||||
|
// 通用券:清除商品范围
|
||||||
|
productScopeValue = null;
|
||||||
|
} else if (Objects.equals(pageReqVO.getProductScope(), PromotionProductScopeEnum.CATEGORY.getScope()) && pageReqVO.getSpuId() != null) {
|
||||||
|
// 品类券:查询商品的品类
|
||||||
|
productScopeValue = Optional.ofNullable(productSpuApi.getSpu(pageReqVO.getSpuId()))
|
||||||
|
.map(ProductSpuRespDTO::getCategoryId).orElse(null);
|
||||||
}
|
}
|
||||||
return success(new PageResult<>(list, 20L));
|
return productScopeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,15 @@ public class AppCouponMatchReqVO {
|
|||||||
@NotNull(message = "商品金额不能为空")
|
@NotNull(message = "商品金额不能为空")
|
||||||
private Integer price;
|
private Integer price;
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号的数组", required = true, example = "[1, 2]")
|
@Schema(description = "商品 SPU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
||||||
@NotEmpty(message = "商品 SPU 编号不能为空")
|
@NotEmpty(message = "商品 SPU 编号不能为空")
|
||||||
private List<Long> spuIds;
|
private List<Long> spuIds;
|
||||||
|
|
||||||
@Schema(description = "商品 SKU 编号的数组", required = true, example = "[1, 2]")
|
@Schema(description = "商品 SKU 编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
|
||||||
@NotEmpty(message = "商品 SKU 编号不能为空")
|
@NotEmpty(message = "商品 SKU 编号不能为空")
|
||||||
private List<Long> skuIds;
|
private List<Long> skuIds;
|
||||||
|
|
||||||
@Schema(description = "分类编号的数组", required = true, example = "[10, 20]")
|
@Schema(description = "分类编号的数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[10, 20]")
|
||||||
@NotEmpty(message = "分类编号不能为空")
|
@NotEmpty(message = "分类编号不能为空")
|
||||||
private List<Long> categoryIds;
|
private List<Long> categoryIds;
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template;
|
package cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.template;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
|
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -12,8 +14,10 @@ import lombok.ToString;
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class AppCouponTemplatePageReqVO extends PageParam {
|
public class AppCouponTemplatePageReqVO extends PageParam {
|
||||||
|
|
||||||
@Schema(description = "使用类型", example = "1")
|
@Schema(description = "商品范围", example = "1")
|
||||||
// TODO 芋艿:这里要限制下枚举的使用
|
@InEnum(value = PromotionProductScopeEnum.class, message = "商品范围,必须是 {value}")
|
||||||
private Integer useType;
|
private Integer productScope;
|
||||||
|
|
||||||
|
@Schema(description = "商品标号", example = "1")
|
||||||
|
private Long spuId;
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,25 @@ public interface CouponTemplateConvert {
|
|||||||
|
|
||||||
PageResult<CouponTemplateRespVO> convertPage(PageResult<CouponTemplateDO> page);
|
PageResult<CouponTemplateRespVO> convertPage(PageResult<CouponTemplateDO> page);
|
||||||
|
|
||||||
|
CouponTemplatePageReqVO convert(AppCouponTemplatePageReqVO pageReqVO, List<Integer> canTakeTypes, Integer productScope, Long productScopeValue);
|
||||||
|
|
||||||
|
PageResult<AppCouponTemplateRespVO> convertAppPage(PageResult<CouponTemplateDO> pageResult);
|
||||||
|
|
||||||
|
default PageResult<AppCouponTemplateRespVO> convertAppPage(PageResult<CouponTemplateDO> pageResult, Map<Long, Integer> couponTakeCountMap) {
|
||||||
|
PageResult<AppCouponTemplateRespVO> result = convertAppPage(pageResult);
|
||||||
|
if (MapUtil.isEmpty(couponTakeCountMap)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AppCouponTemplateRespVO vo : result.getList()) {
|
||||||
|
// 每人领取数量无限制
|
||||||
|
if (vo.getTakeLimitCount() == -1) {
|
||||||
|
vo.setTakeStatus(false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 检查已领取数量是否超过限领数量
|
||||||
|
vo.setTakeStatus(MapUtil.getInt(couponTakeCountMap, vo.getId(), 0) >= vo.getTakeLimitCount());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class RewardActivityDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private List<Long> couponIds;
|
private List<Long> couponIds;
|
||||||
/**
|
/**
|
||||||
* 赠送的优惠卷数量的数组
|
* 赠送的优惠券数量的数组
|
||||||
*/
|
*/
|
||||||
private List<Integer> couponCounts;
|
private List<Integer> couponCounts;
|
||||||
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.dal.mysql.coupon;
|
package cn.iocoder.yudao.module.promotion.dal.mysql.coupon;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.coupon.bo.CouponTakeCountBO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.github.yulichang.toolkit.MPJWrappers;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -62,4 +65,12 @@ public interface CouponMapper extends BaseMapperX<CouponDO> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<CouponTakeCountBO> selectCountByUserIdAndTemplateIdIn(Long userId, Collection<Long> templateIds) {
|
||||||
|
return BeanUtil.copyToList(selectMaps(MPJWrappers.lambdaJoin(CouponDO.class)
|
||||||
|
.select(CouponDO::getTemplateId)
|
||||||
|
.selectCount(CouponDO::getId, CouponTakeCountBO::getCount)
|
||||||
|
.eq(CouponDO::getUserId, userId)
|
||||||
|
.in(CouponDO::getTemplateId, templateIds)
|
||||||
|
.groupBy(CouponDO::getTemplateId)), CouponTakeCountBO.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,9 @@ public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> {
|
|||||||
.eqIfPresent(CouponTemplateDO::getStatus, reqVO.getStatus())
|
.eqIfPresent(CouponTemplateDO::getStatus, reqVO.getStatus())
|
||||||
.eqIfPresent(CouponTemplateDO::getDiscountType, reqVO.getDiscountType())
|
.eqIfPresent(CouponTemplateDO::getDiscountType, reqVO.getDiscountType())
|
||||||
.betweenIfPresent(CouponTemplateDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(CouponTemplateDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.eqIfPresent(CouponTemplateDO::getProductScope, reqVO.getProductScope())
|
||||||
|
.and(reqVO.getProductScopeValue() != null, w -> w.apply("FIND_IN_SET({0}, product_scope_values)",
|
||||||
|
reqVO.getProductScopeValue()))
|
||||||
.and(canTakeConsumer != null, canTakeConsumer)
|
.and(canTakeConsumer != null, canTakeConsumer)
|
||||||
.orderByDesc(CouponTemplateDO::getId));
|
.orderByDesc(CouponTemplateDO::getId));
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,15 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.coupon.CouponPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.coupon.bo.CouponTakeCountBO;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠劵 Service 接口
|
* 优惠劵 Service 接口
|
||||||
*
|
*
|
||||||
@ -18,7 +23,7 @@ public interface CouponService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验优惠劵,包括状态、有限期
|
* 校验优惠劵,包括状态、有限期
|
||||||
*
|
* <p>
|
||||||
* 1. 如果校验通过,则返回优惠劵信息
|
* 1. 如果校验通过,则返回优惠劵信息
|
||||||
* 2. 如果校验不通过,则直接抛出业务异常
|
* 2. 如果校验不通过,则直接抛出业务异常
|
||||||
*
|
*
|
||||||
@ -31,9 +36,8 @@ public interface CouponService {
|
|||||||
/**
|
/**
|
||||||
* 校验优惠劵,包括状态、有限期
|
* 校验优惠劵,包括状态、有限期
|
||||||
*
|
*
|
||||||
* @see #validCoupon(Long, Long) 逻辑相同,只是入参不同
|
|
||||||
*
|
|
||||||
* @param coupon 优惠劵
|
* @param coupon 优惠劵
|
||||||
|
* @see #validCoupon(Long, Long) 逻辑相同,只是入参不同
|
||||||
*/
|
*/
|
||||||
void validCoupon(CouponDO coupon);
|
void validCoupon(CouponDO coupon);
|
||||||
|
|
||||||
@ -124,4 +128,23 @@ public interface CouponService {
|
|||||||
takeCoupon(templateId, CollUtil.newHashSet(userId), CouponTakeTypeEnum.REGISTER);
|
takeCoupon(templateId, CollUtil.newHashSet(userId), CouponTakeTypeEnum.REGISTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计会员领取优惠券的数量
|
||||||
|
*
|
||||||
|
* @param templateIds 优惠券模板编号列表
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 领取优惠券的数量
|
||||||
|
*/
|
||||||
|
default Map<Long, Integer> getTakeCountMapByTemplateIds(Collection<Long> templateIds, Long userId) {
|
||||||
|
return convertMap(getTakeCountListByTemplateIds(templateIds, userId), CouponTakeCountBO::getTemplateId, CouponTakeCountBO::getCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计会员领取优惠券的数量
|
||||||
|
*
|
||||||
|
* @param templateIds 优惠券模板编号列表
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @return 领取优惠券的数量
|
||||||
|
*/
|
||||||
|
List<CouponTakeCountBO> getTakeCountListByTemplateIds(Collection<Long> templateIds, Long userId);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.service.coupon;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollStreamUtil;
|
import cn.hutool.core.collection.CollStreamUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@ -18,12 +19,14 @@ import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponMapper;
|
|||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponStatusEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum;
|
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.coupon.bo.CouponTakeCountBO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -175,6 +178,14 @@ public class CouponServiceImpl implements CouponService {
|
|||||||
couponTemplateService.updateCouponTemplateTakeCount(templateId, userIds.size());
|
couponTemplateService.updateCouponTemplateTakeCount(templateId, userIds.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CouponTakeCountBO> getTakeCountListByTemplateIds(Collection<Long> templateIds, Long userId) {
|
||||||
|
if (CollUtil.isEmpty(templateIds)) {
|
||||||
|
return ListUtil.empty();
|
||||||
|
}
|
||||||
|
return couponMapper.selectCountByUserIdAndTemplateIdIn(userId, templateIds);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验优惠券是否可以领取
|
* 校验优惠券是否可以领取
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.service.coupon.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券领取数量 BO
|
||||||
|
*
|
||||||
|
* @author owen
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CouponTakeCountBO {
|
||||||
|
/**
|
||||||
|
* 优惠劵模板编号
|
||||||
|
*/
|
||||||
|
private Long templateId;
|
||||||
|
/**
|
||||||
|
* 领取数量
|
||||||
|
*/
|
||||||
|
private Integer count;
|
||||||
|
}
|
@ -10,7 +10,6 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO;
|
|||||||
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
|
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.github.yulichang.toolkit.LambdaUtils;
|
|
||||||
import com.github.yulichang.toolkit.MPJWrappers;
|
import com.github.yulichang.toolkit.MPJWrappers;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@ -62,7 +61,7 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
|||||||
Integer status) {
|
Integer status) {
|
||||||
List<Map<String, Object>> list = selectMaps(MPJWrappers.lambdaJoin(BrokerageRecordDO.class)
|
List<Map<String, Object>> list = selectMaps(MPJWrappers.lambdaJoin(BrokerageRecordDO.class)
|
||||||
.select(BrokerageRecordDO::getUserId)
|
.select(BrokerageRecordDO::getUserId)
|
||||||
.selectCount(BrokerageRecordDO::getId, LambdaUtils.getName(UserBrokerageSummaryBO::getCount))
|
.selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryBO::getCount)
|
||||||
.selectSum(BrokerageRecordDO::getPrice)
|
.selectSum(BrokerageRecordDO::getPrice)
|
||||||
.in(BrokerageRecordDO::getUserId, userIds)
|
.in(BrokerageRecordDO::getUserId, userIds)
|
||||||
.eq(BrokerageRecordDO::getBizId, bizType)
|
.eq(BrokerageRecordDO::getBizId, bizType)
|
||||||
@ -71,7 +70,7 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> {
|
|||||||
return BeanUtil.copyToList(list, UserBrokerageSummaryBO.class);
|
return BeanUtil.copyToList(list, UserBrokerageSummaryBO.class);
|
||||||
// return selectJoinList(UserBrokerageSummaryBO.class, MPJWrappers.lambdaJoin(BrokerageRecordDO.class)
|
// return selectJoinList(UserBrokerageSummaryBO.class, MPJWrappers.lambdaJoin(BrokerageRecordDO.class)
|
||||||
// .select(BrokerageRecordDO::getUserId)
|
// .select(BrokerageRecordDO::getUserId)
|
||||||
// .selectCount(BrokerageRecordDO::getId, LambdaUtils.getName(UserBrokerageSummaryBO::getCount))
|
// .selectCount(BrokerageRecordDO::getId, UserBrokerageSummaryBO::getCount)
|
||||||
// .selectSum(BrokerageRecordDO::getPrice)
|
// .selectSum(BrokerageRecordDO::getPrice)
|
||||||
// .in(BrokerageRecordDO::getUserId, userIds)
|
// .in(BrokerageRecordDO::getUserId, userIds)
|
||||||
// .eq(BrokerageRecordDO::getBizId, bizType)
|
// .eq(BrokerageRecordDO::getBizId, bizType)
|
||||||
|
@ -8,7 +8,6 @@ import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.Brok
|
|||||||
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO;
|
||||||
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserWithdrawSummaryBO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.github.yulichang.toolkit.LambdaUtils;
|
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
|
|||||||
default List<UserWithdrawSummaryBO> selectCountAndSumPriceByUserIdAndStatus(Collection<Long> userIds, Integer status) {
|
default List<UserWithdrawSummaryBO> selectCountAndSumPriceByUserIdAndStatus(Collection<Long> userIds, Integer status) {
|
||||||
List<Map<String, Object>> list = selectMaps(new MPJLambdaWrapper<BrokerageWithdrawDO>()
|
List<Map<String, Object>> list = selectMaps(new MPJLambdaWrapper<BrokerageWithdrawDO>()
|
||||||
.select(BrokerageWithdrawDO::getUserId)
|
.select(BrokerageWithdrawDO::getUserId)
|
||||||
.selectCount(BrokerageWithdrawDO::getId, LambdaUtils.getName(UserWithdrawSummaryBO::getCount))
|
.selectCount(BrokerageWithdrawDO::getId, UserWithdrawSummaryBO::getCount)
|
||||||
.selectSum(BrokerageWithdrawDO::getPrice)
|
.selectSum(BrokerageWithdrawDO::getPrice)
|
||||||
.in(BrokerageWithdrawDO::getUserId, userIds)
|
.in(BrokerageWithdrawDO::getUserId, userIds)
|
||||||
.eq(BrokerageWithdrawDO::getStatus, status)
|
.eq(BrokerageWithdrawDO::getStatus, status)
|
||||||
@ -54,7 +53,7 @@ public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO
|
|||||||
// selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW
|
// selectJoinList有BUG,会与租户插件冲突:解析SQL时,发生异常 https://gitee.com/best_handsome/mybatis-plus-join/issues/I84GYW
|
||||||
// return selectJoinList(UserWithdrawSummaryBO.class, new MPJLambdaWrapper<BrokerageWithdrawDO>()
|
// return selectJoinList(UserWithdrawSummaryBO.class, new MPJLambdaWrapper<BrokerageWithdrawDO>()
|
||||||
// .select(BrokerageWithdrawDO::getUserId)
|
// .select(BrokerageWithdrawDO::getUserId)
|
||||||
// .selectCount(BrokerageWithdrawDO::getId, LambdaUtils.getName(UserWithdrawSummaryBO::getCount))
|
// .selectCount(BrokerageWithdrawDO::getId, UserWithdrawSummaryBO::getCount)
|
||||||
// .selectSum(BrokerageWithdrawDO::getPrice)
|
// .selectSum(BrokerageWithdrawDO::getPrice)
|
||||||
// .in(BrokerageWithdrawDO::getUserId, userIds)
|
// .in(BrokerageWithdrawDO::getUserId, userIds)
|
||||||
// .eq(BrokerageWithdrawDO::getStatus, status)
|
// .eq(BrokerageWithdrawDO::getStatus, status)
|
||||||
|
Loading…
Reference in New Issue
Block a user