mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-29 18:51:53 +08:00
砍价活动: 完善 app 端获取活动分页、列表、详情接口
This commit is contained in:
parent
a10d77cdfe
commit
af6016bba5
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.product.api.spu.dto;
|
package cn.iocoder.yudao.module.product.api.spu.dto;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
|
||||||
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -31,6 +30,12 @@ public class ProductSpuRespDTO {
|
|||||||
* 关键字
|
* 关键字
|
||||||
*/
|
*/
|
||||||
private String keyword;
|
private String keyword;
|
||||||
|
/**
|
||||||
|
* 单位
|
||||||
|
*
|
||||||
|
* 对应 product_unit 数据字典
|
||||||
|
*/
|
||||||
|
private Integer unit;
|
||||||
/**
|
/**
|
||||||
* 商品简介
|
* 商品简介
|
||||||
*/
|
*/
|
||||||
|
@ -77,6 +77,10 @@
|
|||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -3,6 +3,9 @@ package cn.iocoder.yudao.module.promotion.controller.admin.bargain;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
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.framework.common.util.collection.CollectionUtils;
|
||||||
|
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.admin.bargain.vo.BargainActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
|
||||||
@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@ -30,6 +34,8 @@ public class BargainActivityController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BargainActivityService activityService;
|
private BargainActivityService activityService;
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi spuApi;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建砍价活动")
|
@Operation(summary = "创建砍价活动")
|
||||||
@ -73,7 +79,8 @@ public class BargainActivityController {
|
|||||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
return success(PageResult.empty(pageResult.getTotal()));
|
return success(PageResult.empty(pageResult.getTotal()));
|
||||||
}
|
}
|
||||||
return success(BargainActivityConvert.INSTANCE.convertPage(activityService.getBargainActivityPage(pageVO)));
|
List<ProductSpuRespDTO> spuList = spuApi.getSpuList(CollectionUtils.convertList(pageResult.getList(), BargainActivityDO::getSpuId));
|
||||||
|
return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.app.bargain;
|
package cn.iocoder.yudao.module.promotion.controller.app.bargain;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
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.bargain.vo.activity.AppBargainActivityDetailRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert;
|
||||||
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
|
||||||
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.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;
|
||||||
@ -14,8 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.time.Duration;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -25,86 +31,49 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
@RequestMapping("/promotion/bargain-activity")
|
@RequestMapping("/promotion/bargain-activity")
|
||||||
@Validated
|
@Validated
|
||||||
public class AppBargainActivityController {
|
public class AppBargainActivityController {
|
||||||
|
@Resource
|
||||||
|
private BargainActivityService bargainActivityService;
|
||||||
|
@Resource
|
||||||
|
private ProductSpuApi spuApi;
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得砍价活动活动") // TODO 芋艿:只查询进行中,且在时间范围内的
|
@Operation(summary = "获得砍价活动分页")
|
||||||
// TODO 芋艿:缺少 swagger 注解
|
|
||||||
public CommonResult<PageResult<AppBargainActivityRespVO>> getBargainActivityPage(PageParam pageReqVO) {
|
public CommonResult<PageResult<AppBargainActivityRespVO>> getBargainActivityPage(PageParam pageReqVO) {
|
||||||
List<AppBargainActivityRespVO> activityList = new ArrayList<>();
|
PageResult<BargainActivityDO> result = bargainActivityService.getBargainActivityAppPage(pageReqVO);
|
||||||
AppBargainActivityRespVO activity1 = new AppBargainActivityRespVO();
|
if (CollUtil.isEmpty(result.getList())) {
|
||||||
activity1.setId(1L);
|
return success(PageResult.empty(result.getTotal()));
|
||||||
activity1.setName("618 大砍价");
|
}
|
||||||
activity1.setSpuId(2048L);
|
|
||||||
activity1.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
|
|
||||||
activity1.setMarketPrice(50);
|
|
||||||
activity1.setBargainPrice(100);
|
|
||||||
activity1.setStartTime(LocalDateTimeUtils.addTime(Duration.ofDays(-2)));
|
|
||||||
activity1.setEndTime(LocalDateTimeUtils.addTime(Duration.ofDays(1)));
|
|
||||||
activity1.setStock(10);
|
|
||||||
activityList.add(activity1);
|
|
||||||
|
|
||||||
AppBargainActivityRespVO activity2 = new AppBargainActivityRespVO();
|
List<ProductSpuRespDTO> spuList = spuApi.getSpuList(CollectionUtils.convertList(result.getList(), BargainActivityDO::getSpuId));
|
||||||
activity2.setId(2L);
|
return success(BargainActivityConvert.INSTANCE.convertAppPage(result, spuList));
|
||||||
activity2.setName("双十一砍价");
|
|
||||||
activity2.setSpuId(4096L);
|
|
||||||
activity2.setPicUrl("https://static.iocoder.cn/mall/132.jpeg");
|
|
||||||
activity2.setMarketPrice(100);
|
|
||||||
activity2.setBargainPrice(200);
|
|
||||||
activity2.setStartTime(LocalDateTimeUtils.addTime(Duration.ofDays(-2)));
|
|
||||||
activity2.setEndTime(LocalDateTimeUtils.addTime(Duration.ofDays(1)));
|
|
||||||
activity2.setStock(0);
|
|
||||||
activityList.add(activity2);
|
|
||||||
|
|
||||||
return success(new PageResult<>(activityList, 10L));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获得砍价活动列表", description = "用于小程序首页")
|
@Operation(summary = "获得砍价活动列表", description = "用于小程序首页")
|
||||||
// TODO 芋艿:增加 Spring Cache
|
@Parameter(name = "count", description = "需要展示的数量", example = "6")
|
||||||
// TODO 芋艿:缺少 swagger 注解
|
|
||||||
public CommonResult<List<AppBargainActivityRespVO>> getBargainActivityList(
|
public CommonResult<List<AppBargainActivityRespVO>> getBargainActivityList(
|
||||||
@RequestParam(name = "count", defaultValue = "6") Integer count) {
|
@RequestParam(name = "count", defaultValue = "6") Integer count) {
|
||||||
List<AppBargainActivityRespVO> activityList = new ArrayList<>();
|
List<BargainActivityDO> list = bargainActivityService.getBargainActivityAppList(count);
|
||||||
AppBargainActivityRespVO activity1 = new AppBargainActivityRespVO();
|
if (CollUtil.isEmpty(list)) {
|
||||||
activity1.setId(1L);
|
return success(BargainActivityConvert.INSTANCE.convertAppList(list));
|
||||||
activity1.setName("618 大砍价");
|
}
|
||||||
activity1.setSpuId(2048L);
|
|
||||||
activity1.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
|
|
||||||
activity1.setMarketPrice(50);
|
|
||||||
activity1.setBargainPrice(100);
|
|
||||||
activityList.add(activity1);
|
|
||||||
|
|
||||||
AppBargainActivityRespVO activity2 = new AppBargainActivityRespVO();
|
List<ProductSpuRespDTO> spuList = spuApi.getSpuList(CollectionUtils.convertList(list, BargainActivityDO::getSpuId));
|
||||||
activity2.setId(2L);
|
// TODO 芋艿:增加 Spring Cache
|
||||||
activity2.setName("双十一砍价");
|
return success(BargainActivityConvert.INSTANCE.convertAppList(list, spuList));
|
||||||
activity2.setSpuId(4096L);
|
|
||||||
activity2.setPicUrl("https://static.iocoder.cn/mall/132.jpeg");
|
|
||||||
activity2.setMarketPrice(100);
|
|
||||||
activity2.setBargainPrice(200);
|
|
||||||
activityList.add(activity2);
|
|
||||||
|
|
||||||
return success(activityList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-detail")
|
@GetMapping("/get-detail")
|
||||||
@Operation(summary = "获得砍价活动详情")
|
@Operation(summary = "获得砍价活动详情")
|
||||||
// TODO 芋艿:缺少 swagger 注解
|
@Parameter(name = "id", description = "活动编号", example = "1")
|
||||||
public CommonResult<AppBargainActivityDetailRespVO> getBargainActivityDetail(@RequestParam("id") Long id) {
|
public CommonResult<AppBargainActivityDetailRespVO> getBargainActivityDetail(@RequestParam("id") Long id) {
|
||||||
AppBargainActivityDetailRespVO activity = new AppBargainActivityDetailRespVO();
|
BargainActivityDO activity = bargainActivityService.getBargainActivity(id);
|
||||||
activity.setId(2L);
|
if (activity == null) {
|
||||||
activity.setName("618 大砍价");
|
return success(null);
|
||||||
activity.setSpuId(2048L);
|
}
|
||||||
activity.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
|
|
||||||
activity.setMarketPrice(50);
|
ProductSpuRespDTO spu = spuApi.getSpu(activity.getSpuId());
|
||||||
activity.setBargainPrice(100);
|
return success(BargainActivityConvert.INSTANCE.convert1(activity, spu));
|
||||||
activity.setStock(10);
|
|
||||||
activity.setUnitName("件");
|
|
||||||
activity.setPrice(40);
|
|
||||||
activity.setStartTime(LocalDateTimeUtils.addTime(Duration.ofDays(-2)));
|
|
||||||
activity.setEndTime(LocalDateTimeUtils.addTime(Duration.ofDays(-10)));
|
|
||||||
activity.setDescription("我吃西红柿");
|
|
||||||
activity.setSuccessCount(10);
|
|
||||||
return success(activity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class AppBargainActivityDetailRespVO {
|
|||||||
@Schema(description = "商品单位", required = true, example = "个") // 从 SPU 的 unit 读取,然后转换
|
@Schema(description = "商品单位", required = true, example = "个") // 从 SPU 的 unit 读取,然后转换
|
||||||
private String unitName;
|
private String unitName;
|
||||||
|
|
||||||
@Schema(description = "砍价最低金额,单位:分", required = true, example = "100") // 从砍价商品里取最低价
|
@Schema(description = "砍价最低金额,单位:分", required = true, example = "100")
|
||||||
private Integer bargainPrice;
|
private Integer bargainPrice;
|
||||||
|
|
||||||
@Schema(description = "砍价成功数量", required = true, example = "100")
|
@Schema(description = "砍价成功数量", required = true, example = "100")
|
||||||
|
@ -36,7 +36,7 @@ public class AppBargainActivityRespVO {
|
|||||||
@Schema(description = "商品市场价,单位:分", required = true, example = "50") // 从 SPU 的 marketPrice 读取
|
@Schema(description = "商品市场价,单位:分", required = true, example = "50") // 从 SPU 的 marketPrice 读取
|
||||||
private Integer marketPrice;
|
private Integer marketPrice;
|
||||||
|
|
||||||
@Schema(description = "砍价最低金额,单位:分", required = true, example = "100") // 从砍价商品里取最低价
|
@Schema(description = "砍价最低金额,单位:分", required = true, example = "100")
|
||||||
private Integer bargainPrice;
|
private Integer bargainPrice;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.convert.bargain;
|
package cn.iocoder.yudao.module.promotion.convert.bargain;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼团活动 Convert
|
* 拼团活动 Convert
|
||||||
@ -30,4 +40,60 @@ public interface BargainActivityConvert {
|
|||||||
|
|
||||||
PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page);
|
PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page);
|
||||||
|
|
||||||
|
default PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page, List<ProductSpuRespDTO> spuList) {
|
||||||
|
PageResult<BargainActivityRespVO> result = convertPage(page);
|
||||||
|
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||||
|
List<BargainActivityRespVO> list = CollectionUtils.convertList(result.getList(), item -> {
|
||||||
|
findAndThen(spuMap, item.getSpuId(), spu -> {
|
||||||
|
item.setPicUrl(spu.getPicUrl());
|
||||||
|
item.setSpuName(spu.getName());
|
||||||
|
});
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
result.setList(list);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppBargainActivityDetailRespVO convert1(BargainActivityDO bean);
|
||||||
|
|
||||||
|
default AppBargainActivityDetailRespVO convert1(BargainActivityDO bean, ProductSpuRespDTO spu) {
|
||||||
|
AppBargainActivityDetailRespVO detail = convert1(bean);
|
||||||
|
if (spu != null) {
|
||||||
|
detail.setPicUrl(spu.getPicUrl());
|
||||||
|
detail.setMarketPrice(spu.getMarketPrice());
|
||||||
|
detail.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
||||||
|
}
|
||||||
|
return detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
PageResult<AppBargainActivityRespVO> convertAppPage(PageResult<BargainActivityDO> page);
|
||||||
|
|
||||||
|
default PageResult<AppBargainActivityRespVO> convertAppPage(PageResult<BargainActivityDO> page, List<ProductSpuRespDTO> spuList) {
|
||||||
|
PageResult<AppBargainActivityRespVO> result = convertAppPage(page);
|
||||||
|
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||||
|
List<AppBargainActivityRespVO> list = CollectionUtils.convertList(result.getList(), item -> {
|
||||||
|
findAndThen(spuMap, item.getSpuId(), spu -> {
|
||||||
|
item.setPicUrl(spu.getPicUrl());
|
||||||
|
item.setMarketPrice(spu.getMarketPrice());
|
||||||
|
});
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
result.setList(list);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AppBargainActivityRespVO> convertAppList(List<BargainActivityDO> list);
|
||||||
|
|
||||||
|
default List<AppBargainActivityRespVO> convertAppList(List<BargainActivityDO> list, List<ProductSpuRespDTO> spuList) {
|
||||||
|
List<AppBargainActivityRespVO> activityList = convertAppList(list);
|
||||||
|
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||||
|
return CollectionUtils.convertList(activityList, item -> {
|
||||||
|
findAndThen(spuMap, item.getSpuId(), spu -> {
|
||||||
|
item.setPicUrl(spu.getPicUrl());
|
||||||
|
item.setMarketPrice(spu.getMarketPrice());
|
||||||
|
});
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.dal.mysql.bargain;
|
package cn.iocoder.yudao.module.promotion.dal.mysql.bargain;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
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;
|
||||||
@ -8,6 +9,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityD
|
|||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,4 +45,11 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
|
|||||||
.setSql("stock = stock - " + count));
|
.setSql("stock = stock - " + count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PageResult<BargainActivityDO> selectAppPage(PageParam pageReqVO, Integer status, LocalDateTime now) {
|
||||||
|
return selectPage(pageReqVO, new LambdaQueryWrapperX<BargainActivityDO>()
|
||||||
|
.eq(BargainActivityDO::getStatus, status)
|
||||||
|
.le(BargainActivityDO::getStartTime, now)
|
||||||
|
.ge(BargainActivityDO::getEndTime, now));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.service.bargain;
|
package cn.iocoder.yudao.module.promotion.service.bargain;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||||
@ -7,6 +8,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActi
|
|||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 砍价活动 Service 接口
|
* 砍价活动 Service 接口
|
||||||
@ -61,4 +63,19 @@ public interface BargainActivityService {
|
|||||||
*/
|
*/
|
||||||
PageResult<BargainActivityDO> getBargainActivityPage(BargainActivityPageReqVO pageReqVO);
|
PageResult<BargainActivityDO> getBargainActivityPage(BargainActivityPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 APP 端活动分页数据
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页请求
|
||||||
|
* @return 砍价活动分页
|
||||||
|
*/
|
||||||
|
PageResult<BargainActivityDO> getBargainActivityAppPage(PageParam pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 APP 端活动展示数据
|
||||||
|
*
|
||||||
|
* @param count 需要的数量
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BargainActivityDO> getBargainActivityAppList(Integer count);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.service.bargain;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||||
@ -16,6 +17,7 @@ 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.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -113,9 +115,9 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
|||||||
// 校验存在
|
// 校验存在
|
||||||
BargainActivityDO activityDO = validateBargainActivityExists(id);
|
BargainActivityDO activityDO = validateBargainActivityExists(id);
|
||||||
// 校验状态
|
// 校验状态
|
||||||
if (ObjectUtil.equal(activityDO.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
//if (ObjectUtil.equal(activityDO.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||||
throw exception(BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END);
|
// throw exception(BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END);
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
bargainActivityMapper.deleteById(id);
|
bargainActivityMapper.deleteById(id);
|
||||||
@ -139,4 +141,20 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
|||||||
return bargainActivityMapper.selectPage(pageReqVO);
|
return bargainActivityMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<BargainActivityDO> getBargainActivityAppPage(PageParam pageReqVO) {
|
||||||
|
// 只查询进行中,且在时间范围内的
|
||||||
|
return bargainActivityMapper.selectAppPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BargainActivityDO> getBargainActivityAppList(Integer count) {
|
||||||
|
if (count == null) {
|
||||||
|
count = 6;
|
||||||
|
}
|
||||||
|
PageResult<BargainActivityDO> result = bargainActivityMapper.selectAppPage(new PageParam().setPageSize(count), CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now());
|
||||||
|
return result.getList();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
|||||||
public class CombinationRecordServiceImpl implements CombinationRecordService {
|
public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@Lazy
|
||||||
private CombinationActivityService combinationActivityService;
|
private CombinationActivityService combinationActivityService;
|
||||||
@Resource
|
@Resource
|
||||||
private CombinationRecordMapper recordMapper;
|
private CombinationRecordMapper recordMapper;
|
||||||
|
Loading…
Reference in New Issue
Block a user