mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	!685 完善遗留的问题
Merge pull request !685 from puhui999/feature/mall_product
This commit is contained in:
		@@ -34,8 +34,9 @@ public interface ErrorCodeConstants {
 | 
			
		||||
    // ========== 商品 SPU 1-008-005-000 ==========
 | 
			
		||||
    ErrorCode SPU_NOT_EXISTS = new ErrorCode(1_008_005_000, "商品 SPU 不存在");
 | 
			
		||||
    ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1_008_005_001, "商品分类不正确,原因:必须使用第二级的商品分类及以下");
 | 
			
		||||
    ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_002, "商品 SPU【{}】不处于上架状态");
 | 
			
		||||
    ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_003, "商品 SPU 不处于回收站状态");
 | 
			
		||||
    ErrorCode SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1_008_005_002, "商品 SPU 保存失败,原因:优惠卷不存在");
 | 
			
		||||
    ErrorCode SPU_NOT_ENABLE = new ErrorCode(1_008_005_003, "商品 SPU【{}】不处于上架状态");
 | 
			
		||||
    ErrorCode SPU_NOT_RECYCLE = new ErrorCode(1_008_005_004, "商品 SPU 不处于回收站状态");
 | 
			
		||||
 | 
			
		||||
    // ========== 商品 SKU 1-008-006-000 ==========
 | 
			
		||||
    ErrorCode SKU_NOT_EXISTS = new ErrorCode(1_008_006_000, "商品 SKU 不存在");
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,11 @@
 | 
			
		||||
            <artifactId>yudao-module-member-api</artifactId>
 | 
			
		||||
            <version>${revision}</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>cn.iocoder.boot</groupId>
 | 
			
		||||
            <artifactId>yudao-module-promotion-api</artifactId>
 | 
			
		||||
            <version>${revision}</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
 | 
			
		||||
        <!-- 业务组件 -->
 | 
			
		||||
        <dependency>
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
 | 
			
		||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
 | 
			
		||||
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Parameter;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
@@ -43,6 +45,9 @@ public class ProductSpuController {
 | 
			
		||||
    @Resource
 | 
			
		||||
    private ProductSkuService productSkuService;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private CouponTemplateApi couponTemplateApi;
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/create")
 | 
			
		||||
    @Operation(summary = "创建商品 SPU")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('product:spu:create')")
 | 
			
		||||
@@ -87,7 +92,10 @@ public class ProductSpuController {
 | 
			
		||||
        }
 | 
			
		||||
        // 查询商品 SKU
 | 
			
		||||
        List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());
 | 
			
		||||
        return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus));
 | 
			
		||||
        // 查询优惠卷
 | 
			
		||||
        List<CouponTemplateRespDTO> couponTemplateList = couponTemplateApi.getCouponTemplateListByIds(
 | 
			
		||||
                spu.getGiveCouponTemplateIds());
 | 
			
		||||
        return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus, couponTemplateList));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/list-all-simple")
 | 
			
		||||
 
 | 
			
		||||
@@ -96,19 +96,31 @@ public class ProductSpuBaseVO {
 | 
			
		||||
    @NotNull(message = "商品赠送积分不能为空")
 | 
			
		||||
    private Integer giveIntegral;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "赠送的优惠劵编号的数组", example = "[1, 10]") // TODO 这块前端还未实现
 | 
			
		||||
    private List<Long> giveCouponTemplateIds;
 | 
			
		||||
    @Schema(description = "赠送的优惠劵数组包含优惠券编号和名称")
 | 
			
		||||
    private List<GiveCouponTemplate> giveCouponTemplates;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
 | 
			
		||||
    @NotNull(message = "商品分销类型不能为空")
 | 
			
		||||
    private Boolean subCommissionType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]") // TODO 这块前端还未实现
 | 
			
		||||
    @Schema(description = "活动展示顺序", example = "[1, 3, 2, 4, 5]")
 | 
			
		||||
    private List<Integer> activityOrders;
 | 
			
		||||
 | 
			
		||||
    // ========== 统计相关字段 =========
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "虚拟销量", example = "芋道")
 | 
			
		||||
    @Schema(description = "虚拟销量", example = "66")
 | 
			
		||||
    private Integer virtualSalesCount;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "管理后台 - 商品 SPU 赠送的优惠卷")
 | 
			
		||||
    @Data
 | 
			
		||||
    public static class GiveCouponTemplate {
 | 
			
		||||
 | 
			
		||||
        @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
        private Long id;
 | 
			
		||||
 | 
			
		||||
        @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送")
 | 
			
		||||
        private String name;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
 | 
			
		||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
 | 
			
		||||
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO;
 | 
			
		||||
import org.mapstruct.Mapper;
 | 
			
		||||
import org.mapstruct.Mapping;
 | 
			
		||||
import org.mapstruct.Named;
 | 
			
		||||
@@ -100,10 +101,14 @@ public interface ProductSpuConvert {
 | 
			
		||||
 | 
			
		||||
    List<AppProductSpuDetailRespVO.Sku> convertListForGetSpuDetail(List<ProductSkuDO> skus);
 | 
			
		||||
 | 
			
		||||
    default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus) {
 | 
			
		||||
        ProductSpuDetailRespVO detailRespVO = convert03(spu);
 | 
			
		||||
        detailRespVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus));
 | 
			
		||||
        return detailRespVO;
 | 
			
		||||
    List<ProductSpuDetailRespVO.GiveCouponTemplate> convertList04(List<CouponTemplateRespDTO> couponTemplateList);
 | 
			
		||||
 | 
			
		||||
    default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus,
 | 
			
		||||
                                                             List<CouponTemplateRespDTO> couponTemplateList) {
 | 
			
		||||
        ProductSpuDetailRespVO respVO = convert03(spu);
 | 
			
		||||
        respVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus));
 | 
			
		||||
        respVO.setGiveCouponTemplates(convertList04(couponTemplateList));
 | 
			
		||||
        return respVO;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default List<ProductSpuDetailRespVO> convertForSpuDetailRespListVO(List<ProductSpuDO> spus, List<ProductSkuDO> skus) {
 | 
			
		||||
 
 | 
			
		||||
@@ -194,7 +194,7 @@ public class ProductSpuDO extends BaseDO {
 | 
			
		||||
     * 对应 PromotionTypeEnum 枚举
 | 
			
		||||
     */
 | 
			
		||||
    @TableField(typeHandler = JacksonTypeHandler.class)
 | 
			
		||||
    private List<Integer> activityOrders;
 | 
			
		||||
    private List<Integer> activityOrders; // TODO @芋艿: 活动顺序字段长度需要增加
 | 
			
		||||
 | 
			
		||||
    // ========== 统计相关字段 =========
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,10 @@ import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper;
 | 
			
		||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
 | 
			
		||||
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
 | 
			
		||||
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
 | 
			
		||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
 | 
			
		||||
import com.google.common.collect.Maps;
 | 
			
		||||
import org.springframework.context.annotation.Lazy;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
@@ -26,10 +28,10 @@ import org.springframework.validation.annotation.Validated;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue;
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
 | 
			
		||||
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
 | 
			
		||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
 | 
			
		||||
 | 
			
		||||
@@ -52,9 +54,10 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 | 
			
		||||
    private ProductBrandService brandService;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private ProductCategoryService categoryService;
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    @Lazy // 循环依赖,避免报错
 | 
			
		||||
    private ProductPropertyValueService productPropertyValueService;
 | 
			
		||||
    @Lazy
 | 
			
		||||
    private CouponTemplateApi couponTemplateApi;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    @Transactional(rollbackFor = Exception.class)
 | 
			
		||||
@@ -62,6 +65,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 | 
			
		||||
        // 校验分类、品牌
 | 
			
		||||
        validateCategory(createReqVO.getCategoryId());
 | 
			
		||||
        brandService.validateProductBrand(createReqVO.getBrandId());
 | 
			
		||||
        // 校验优惠券
 | 
			
		||||
        Set<Long> giveCouponTemplateIds = convertSet(createReqVO.getGiveCouponTemplates(), ProductSpuCreateReqVO.GiveCouponTemplate::getId);
 | 
			
		||||
        validateCouponTemplate(giveCouponTemplateIds);
 | 
			
		||||
        // 校验 SKU
 | 
			
		||||
        List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus();
 | 
			
		||||
        productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType());
 | 
			
		||||
@@ -69,6 +75,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 | 
			
		||||
        ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO);
 | 
			
		||||
        // 初始化 SPU 中 SKU 相关属性
 | 
			
		||||
        initSpuFromSkus(spu, skuSaveReqList);
 | 
			
		||||
        // 设置优惠券
 | 
			
		||||
        spu.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds));
 | 
			
		||||
        // 插入 SPU
 | 
			
		||||
        productSpuMapper.insert(spu);
 | 
			
		||||
        // 插入 SKU
 | 
			
		||||
@@ -85,6 +93,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 | 
			
		||||
        // 校验分类、品牌
 | 
			
		||||
        validateCategory(updateReqVO.getCategoryId());
 | 
			
		||||
        brandService.validateProductBrand(updateReqVO.getBrandId());
 | 
			
		||||
        // 校验优惠券
 | 
			
		||||
        Set<Long> giveCouponTemplateIds = convertSet(updateReqVO.getGiveCouponTemplates(), ProductSpuUpdateReqVO.GiveCouponTemplate::getId);
 | 
			
		||||
        validateCouponTemplate(giveCouponTemplateIds);
 | 
			
		||||
        // 校验SKU
 | 
			
		||||
        List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus();
 | 
			
		||||
        productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
 | 
			
		||||
@@ -92,6 +103,8 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 | 
			
		||||
        // 更新 SPU
 | 
			
		||||
        ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO);
 | 
			
		||||
        initSpuFromSkus(updateObj, skuSaveReqList);
 | 
			
		||||
        // 设置优惠券
 | 
			
		||||
        updateObj.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds));
 | 
			
		||||
        productSpuMapper.updateById(updateObj);
 | 
			
		||||
        // 批量更新 SKU
 | 
			
		||||
        productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus());
 | 
			
		||||
@@ -125,6 +138,10 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 | 
			
		||||
            // 默认商品浏览量
 | 
			
		||||
            spu.setBrowseCount(0);
 | 
			
		||||
        }
 | 
			
		||||
        // 如果活动顺序为空则默认初始化
 | 
			
		||||
        if (CollUtil.isEmpty(spu.getActivityOrders())) {
 | 
			
		||||
            spu.setActivityOrders(Arrays.stream(PromotionTypeEnum.ARRAYS).boxed().collect(Collectors.toList()));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -140,6 +157,13 @@ public class ProductSpuServiceImpl implements ProductSpuService {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void validateCouponTemplate(Collection<Long> ids) {
 | 
			
		||||
        List<CouponTemplateRespDTO> couponTemplateList = couponTemplateApi.getCouponTemplateListByIds(ids);
 | 
			
		||||
        if (couponTemplateList.size() != ids.size()) {
 | 
			
		||||
            throw exception(SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<ProductSpuDO> validateSpuList(Collection<Long> ids) {
 | 
			
		||||
        if (CollUtil.isEmpty(ids)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,23 @@
 | 
			
		||||
package cn.iocoder.yudao.module.promotion.api.coupon;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO;
 | 
			
		||||
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 优惠劵模版 API 接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author HUIHUI
 | 
			
		||||
 */
 | 
			
		||||
public interface CouponTemplateApi {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得优惠券模版的精简信息列表
 | 
			
		||||
     *
 | 
			
		||||
     * @param ids 优惠券模版编号
 | 
			
		||||
     * @return 优惠券模版的精简信息列表
 | 
			
		||||
     */
 | 
			
		||||
    List<CouponTemplateRespDTO> getCouponTemplateListByIds(Collection<Long> ids);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,30 @@
 | 
			
		||||
package cn.iocoder.yudao.module.promotion.api.coupon.dto;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 优惠券模版 Response DTO
 | 
			
		||||
 *
 | 
			
		||||
 * @author HUIHUI
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
public class CouponTemplateRespDTO {
 | 
			
		||||
    /**
 | 
			
		||||
     * 模板编号,自增唯一
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    private Long id;
 | 
			
		||||
    /**
 | 
			
		||||
     * 优惠劵名
 | 
			
		||||
     */
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 状态
 | 
			
		||||
     *
 | 
			
		||||
     * 枚举 {@link CommonStatusEnum}
 | 
			
		||||
     */
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,40 @@
 | 
			
		||||
package cn.iocoder.yudao.module.promotion.enums.banner;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum;
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Banner Position 枚举
 | 
			
		||||
 *
 | 
			
		||||
 * @author HUIHUI
 | 
			
		||||
 */
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
@Getter
 | 
			
		||||
public enum BannerPositionEnum implements IntArrayValuable {
 | 
			
		||||
 | 
			
		||||
    HOME_POSITION(1, "首页"),
 | 
			
		||||
    SECKILL_POSITION(2, "秒杀活动页"),
 | 
			
		||||
    COMBINATION_POSITION(3, "砍价活动页"),
 | 
			
		||||
    DISCOUNT_POSITION(4, "限时折扣页"),
 | 
			
		||||
    REWARD_POSITION(5, "满减送页");
 | 
			
		||||
 | 
			
		||||
    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BargainRecordStatusEnum::getStatus).toArray();
 | 
			
		||||
    /**
 | 
			
		||||
     * 值
 | 
			
		||||
     */
 | 
			
		||||
    private final Integer position;
 | 
			
		||||
    /**
 | 
			
		||||
     * 名字
 | 
			
		||||
     */
 | 
			
		||||
    private final String name;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int[] array() {
 | 
			
		||||
        return ARRAYS;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,33 @@
 | 
			
		||||
package cn.iocoder.yudao.module.promotion.api.coupon;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 优惠劵模版 API 接口实现类
 | 
			
		||||
 *
 | 
			
		||||
 * @author HUIHUI
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class CouponTemplateApiImpl implements CouponTemplateApi {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private CouponTemplateService couponTemplateService;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<CouponTemplateRespDTO> getCouponTemplateListByIds(Collection<Long> ids) {
 | 
			
		||||
        if (CollUtil.isEmpty(ids)) { // 防御一下
 | 
			
		||||
            return Collections.emptyList();
 | 
			
		||||
        }
 | 
			
		||||
        return CouponTemplateConvert.INSTANCE.convertList(couponTemplateService.getCouponTemplateListByIds(ids));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -27,6 +27,10 @@ public class BannerBaseVO {
 | 
			
		||||
    @NotNull(message = "图片地址不能为空")
 | 
			
		||||
    private String picUrl;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "position", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "position 不能为空")
 | 
			
		||||
    private Integer position;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "排序不能为空")
 | 
			
		||||
    private Integer sort;
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,6 @@ public class BannerPageReqVO extends PageParam {
 | 
			
		||||
    @Schema(description = "标题")
 | 
			
		||||
    private String title;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "状态")
 | 
			
		||||
    @InEnum(CommonStatusEnum.class)
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 
 | 
			
		||||
@@ -56,13 +56,11 @@ public class AppArticleController {
 | 
			
		||||
        return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO @puhui999:add-browse-count 噢;前端 uniapp 也要接下;就是打开文章的时候,调用下这个接口;
 | 
			
		||||
    @PutMapping("/add-browseCount")
 | 
			
		||||
    @PutMapping("/add-browse-count")
 | 
			
		||||
    @Operation(summary = "增加文章浏览量")
 | 
			
		||||
    @Parameter(name = "id", description = "文章编号", example = "1024")
 | 
			
		||||
    public CommonResult<Boolean> addBrowseCount(@RequestParam("id") Long id) {
 | 
			
		||||
        // TODO @puhui999:addArticleBrowseCount
 | 
			
		||||
        articleService.addBrowseCount(id);
 | 
			
		||||
        articleService.addArticleBrowseCount(id);
 | 
			
		||||
        return success(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,18 +2,23 @@ package cn.iocoder.yudao.module.promotion.controller.app.banner;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.service.banner.BannerService;
 | 
			
		||||
import com.google.common.cache.CacheLoader;
 | 
			
		||||
import com.google.common.cache.LoadingCache;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Parameter;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
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.*;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.time.Duration;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/promotion/banner")
 | 
			
		||||
@@ -21,22 +26,39 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
@Validated
 | 
			
		||||
public class AppBannerController {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private BannerService bannerService;
 | 
			
		||||
    /**
 | 
			
		||||
     * {@link AppBannerRespVO} 缓存,通过它异步刷新 {@link #getBannerList0(Integer)} 所要的首页数据
 | 
			
		||||
     */
 | 
			
		||||
    private final LoadingCache<Integer, List<AppBannerRespVO>> bannerListCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
 | 
			
		||||
            new CacheLoader<Integer, List<AppBannerRespVO>>() {
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public List<AppBannerRespVO> load(Integer position) {
 | 
			
		||||
                    return getBannerList0(position);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/list")
 | 
			
		||||
    @Operation(summary = "获得 banner 列表")
 | 
			
		||||
    // todo @芋艿:swagger 注解,待补全
 | 
			
		||||
    // TODO @芋艿:可以增加缓存,提升性能
 | 
			
		||||
    // TODO @芋艿:position = 1 时,首页;position = 10 时,拼团活动页
 | 
			
		||||
    @Parameter(name = "position", description = "Banner position", example = "1")
 | 
			
		||||
    public CommonResult<List<AppBannerRespVO>> getBannerList(@RequestParam("position") Integer position) {
 | 
			
		||||
        List<AppBannerRespVO> bannerList = new ArrayList<>();
 | 
			
		||||
        AppBannerRespVO banner1 = new AppBannerRespVO();
 | 
			
		||||
        banner1.setUrl("https://www.example.com/link1");
 | 
			
		||||
        banner1.setPicUrl("https://api.java.crmeb.net/crmebimage/public/content/2022/08/04/0f78716213f64bfa83f191d51a832cbf73f6axavoy.jpg");
 | 
			
		||||
        bannerList.add(banner1);
 | 
			
		||||
        AppBannerRespVO banner2 = new AppBannerRespVO();
 | 
			
		||||
        banner2.setUrl("https://www.example.com/link2");
 | 
			
		||||
        banner2.setPicUrl("https://api.java.crmeb.net/crmebimage/public/content/2023/01/11/be09e755268b43ee90b0db3a3e1b7132r7a6t2wvsm.jpg");
 | 
			
		||||
        bannerList.add(banner2);
 | 
			
		||||
        return success(bannerList);
 | 
			
		||||
        return success(bannerListCache.getUnchecked(position));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private List<AppBannerRespVO> getBannerList0(Integer position) {
 | 
			
		||||
        List<BannerDO> bannerList = bannerService.getBannerListByPosition(position);
 | 
			
		||||
        return BannerConvert.INSTANCE.convertList01(bannerList);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PutMapping("/add-browse-count")
 | 
			
		||||
    @Operation(summary = "增加 Banner 点击量")
 | 
			
		||||
    @Parameter(name = "id", description = "Banner 编号", example = "1024")
 | 
			
		||||
    public CommonResult<Boolean> addBrowseCount(@RequestParam("id") Long id) {
 | 
			
		||||
        bannerService.addBannerBrowseCount(id);
 | 
			
		||||
        return success(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,13 @@ import javax.validation.constraints.NotNull;
 | 
			
		||||
@Data
 | 
			
		||||
public class AppBannerRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "标题不能为空")
 | 
			
		||||
    private String title;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "跳转链接", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotNull(message = "跳转链接不能为空")
 | 
			
		||||
    private String url;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO;
 | 
			
		||||
import org.mapstruct.Mapper;
 | 
			
		||||
import org.mapstruct.factory.Mappers;
 | 
			
		||||
@@ -25,4 +26,6 @@ public interface BannerConvert {
 | 
			
		||||
 | 
			
		||||
    BannerDO convert(BannerUpdateReqVO updateReqVO);
 | 
			
		||||
 | 
			
		||||
    List<AppBannerRespVO> convertList01(List<BannerDO> bannerList);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.convert.coupon;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.map.MapUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplateRespVO;
 | 
			
		||||
@@ -58,4 +59,6 @@ public interface CouponTemplateConvert {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    List<CouponTemplateRespDTO> convertList(List<CouponTemplateDO> list);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.banner;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum;
 | 
			
		||||
import com.baomidou.mybatisplus.annotation.TableName;
 | 
			
		||||
import lombok.*;
 | 
			
		||||
 | 
			
		||||
@@ -40,14 +42,25 @@ public class BannerDO extends BaseDO {
 | 
			
		||||
    private Integer sort;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 状态 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
 | 
			
		||||
     * 状态 {@link CommonStatusEnum}
 | 
			
		||||
     */
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 定位 {@link BannerPositionEnum}
 | 
			
		||||
     */
 | 
			
		||||
    private Integer position;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 备注
 | 
			
		||||
     */
 | 
			
		||||
    private String memo;
 | 
			
		||||
 | 
			
		||||
    // TODO 芋艿 点击次数。&& 其他数据相关
 | 
			
		||||
    /**
 | 
			
		||||
     * 点击次数
 | 
			
		||||
     */
 | 
			
		||||
    private Integer browseCount;
 | 
			
		||||
 | 
			
		||||
    // TODO 芋艿 其他数据相关
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,11 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Banner Mapper
 | 
			
		||||
 *
 | 
			
		||||
@@ -23,4 +26,14 @@ public interface BannerMapper extends BaseMapperX<BannerDO> {
 | 
			
		||||
                .orderByDesc(BannerDO::getSort));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default void updateBrowseCount(Long id) {
 | 
			
		||||
        update(null, new LambdaUpdateWrapper<BannerDO>()
 | 
			
		||||
                .eq(BannerDO::getId, id)
 | 
			
		||||
                .setSql("browse_count = browse_count + 1"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default List<BannerDO> selectBannerListByPosition(Integer position) {
 | 
			
		||||
        return selectList(new LambdaQueryWrapperX<BannerDO>().eq(BannerDO::getPosition, position));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -86,7 +86,6 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
 | 
			
		||||
                .last("LIMIT " + count));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO @puhui999:是不是返回 BargainActivityDO 更干净哈?分组后返回 DO 的话需要联表查询
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号
 | 
			
		||||
     *
 | 
			
		||||
@@ -102,7 +101,6 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
 | 
			
		||||
                .groupBy("spu_id"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO @puhui999:是不是只要 endTime 小于就可以啦;
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取指定活动编号的活动列表且
 | 
			
		||||
     * 开始时间和结束时间小于给定时间 dateTime 的活动列表
 | 
			
		||||
@@ -115,7 +113,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
 | 
			
		||||
        return selectList(new LambdaQueryWrapperX<BargainActivityDO>()
 | 
			
		||||
                .in(BargainActivityDO::getId, ids)
 | 
			
		||||
                .lt(BargainActivityDO::getStartTime, dateTime)
 | 
			
		||||
                .lt(BargainActivityDO::getEndTime, dateTime)
 | 
			
		||||
                .gt(BargainActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
 | 
			
		||||
                .orderByDesc(BargainActivityDO::getCreateTime));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi
 | 
			
		||||
        return selectList(new LambdaQueryWrapperX<CombinationActivityDO>()
 | 
			
		||||
                .in(CombinationActivityDO::getId, ids)
 | 
			
		||||
                .lt(CombinationActivityDO::getStartTime, dateTime)
 | 
			
		||||
                .lt(CombinationActivityDO::getEndTime, dateTime)
 | 
			
		||||
                .gt(CombinationActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
 | 
			
		||||
                .orderByDesc(CombinationActivityDO::getCreateTime));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,10 +8,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.template.CouponTemplatePageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.function.Consumer;
 | 
			
		||||
 | 
			
		||||
@@ -39,7 +40,11 @@ public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> {
 | 
			
		||||
                .orderByDesc(CouponTemplateDO::getId));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void updateTakeCount(@Param("id") Long id, @Param("incrCount") Integer incrCount);
 | 
			
		||||
    default void updateTakeCount(Long id, Integer incrCount) {
 | 
			
		||||
        update(null, new LambdaUpdateWrapper<CouponTemplateDO>()
 | 
			
		||||
                .eq(CouponTemplateDO::getId, id)
 | 
			
		||||
                .setSql("take_count = take_count + " + incrCount));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default List<CouponTemplateDO> selectListByTakeType(Integer takeType) {
 | 
			
		||||
        return selectList(CouponTemplateDO::getTakeType, takeType);
 | 
			
		||||
@@ -70,4 +75,8 @@ public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> {
 | 
			
		||||
        return canTakeConsumer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default List<CouponTemplateDO> selectListByIds(Collection<Long> ids) {
 | 
			
		||||
        return selectList(new LambdaQueryWrapperX<CouponTemplateDO>().in(CouponTemplateDO::getId, ids));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -103,7 +103,7 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
 | 
			
		||||
        return selectList(new LambdaQueryWrapperX<SeckillActivityDO>()
 | 
			
		||||
                .in(SeckillActivityDO::getId, ids)
 | 
			
		||||
                .lt(SeckillActivityDO::getStartTime, dateTime)
 | 
			
		||||
                .lt(SeckillActivityDO::getEndTime, dateTime)
 | 
			
		||||
                .gt(SeckillActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
 | 
			
		||||
                .orderByDesc(SeckillActivityDO::getCreateTime));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -93,6 +93,6 @@ public interface ArticleService {
 | 
			
		||||
     *
 | 
			
		||||
     * @param id 文章编号
 | 
			
		||||
     */
 | 
			
		||||
    void addBrowseCount(Long id);
 | 
			
		||||
    void addArticleBrowseCount(Long id);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -111,7 +111,7 @@ public class ArticleServiceImpl implements ArticleService {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void addBrowseCount(Long id) {
 | 
			
		||||
    public void addArticleBrowseCount(Long id) {
 | 
			
		||||
        // 校验文章是否存在
 | 
			
		||||
        validateArticleExists(id);
 | 
			
		||||
        // 增加浏览次数
 | 
			
		||||
 
 | 
			
		||||
@@ -46,12 +46,6 @@ public interface BannerService {
 | 
			
		||||
     */
 | 
			
		||||
    BannerDO getBanner(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得所有 Banner列表
 | 
			
		||||
     * @return Banner列表
 | 
			
		||||
     */
 | 
			
		||||
    List<BannerDO> getBannerList();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得 Banner 分页
 | 
			
		||||
     *
 | 
			
		||||
@@ -60,4 +54,19 @@ public interface BannerService {
 | 
			
		||||
     */
 | 
			
		||||
    PageResult<BannerDO> getBannerPage(BannerPageReqVO pageReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 增加 Banner 点击量
 | 
			
		||||
     *
 | 
			
		||||
     * @param id Banner编号
 | 
			
		||||
     */
 | 
			
		||||
    void addBannerBrowseCount(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得 Banner 列表
 | 
			
		||||
     *
 | 
			
		||||
     * @param position 定位
 | 
			
		||||
     * @return Banner 列表
 | 
			
		||||
     */
 | 
			
		||||
    List<BannerDO> getBannerListByPosition(Integer position);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -65,14 +65,22 @@ public class BannerServiceImpl implements BannerService {
 | 
			
		||||
        return bannerMapper.selectById(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<BannerDO> getBannerList() {
 | 
			
		||||
        return bannerMapper.selectList();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public PageResult<BannerDO> getBannerPage(BannerPageReqVO pageReqVO) {
 | 
			
		||||
        return bannerMapper.selectPage(pageReqVO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void addBannerBrowseCount(Long id) {
 | 
			
		||||
        // 校验 Banner 是否存在
 | 
			
		||||
        validateBannerExists(id);
 | 
			
		||||
        // 增加点击次数
 | 
			
		||||
        bannerMapper.updateBrowseCount(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<BannerDO> getBannerListByPosition(Integer position) {
 | 
			
		||||
        return bannerMapper.selectBannerListByPosition(position);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -369,8 +369,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
 | 
			
		||||
                    keyValue.setValue(keyValue.getValue() + 1);
 | 
			
		||||
                }
 | 
			
		||||
            } catch (Exception ignored) { // 处理异常继续循环
 | 
			
		||||
                // TODO @puhui999:拼团过期 or 虚拟成团 可以改成 expireCombinationRecord;因为找方法更容易一些;
 | 
			
		||||
                log.error("[拼团过期 or 虚拟成团][record({}) 处理异常,请进行处理!record 数据是:{}]",
 | 
			
		||||
                log.error("[expireCombinationRecord][record({}) 处理异常,请进行处理!record 数据是:{}]",
 | 
			
		||||
                        record.getId(), JsonUtils.toJsonString(record));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO;
 | 
			
		||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTakeTypeEnum;
 | 
			
		||||
 | 
			
		||||
import javax.validation.Valid;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -91,4 +92,12 @@ public interface CouponTemplateService {
 | 
			
		||||
    List<CouponTemplateDO> getCouponTemplateList(List<Integer> canTakeTypes, Integer productScope,
 | 
			
		||||
                                                 Long productScopeValue, Integer count);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得优惠券模版列表
 | 
			
		||||
     *
 | 
			
		||||
     * @param ids 优惠券模版编号
 | 
			
		||||
     * @return 优惠券模版列表
 | 
			
		||||
     */
 | 
			
		||||
    List<CouponTemplateDO> getCouponTemplateListByIds(Collection<Long> ids);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
@@ -126,4 +127,9 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
 | 
			
		||||
        return couponTemplateMapper.selectList(canTakeTypes, productScope, productScopeValue, count);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<CouponTemplateDO> getCouponTemplateListByIds(Collection<Long> ids) {
 | 
			
		||||
        return couponTemplateMapper.selectListByIds(ids);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper">
 | 
			
		||||
 | 
			
		||||
    <update id="updateTakeCount">
 | 
			
		||||
        UPDATE promotion_coupon_template
 | 
			
		||||
        SET take_count = take_count + #{incrCount}
 | 
			
		||||
        WHERE id = #{id}
 | 
			
		||||
    </update>
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
		Reference in New Issue
	
	Block a user