From c766f7daa573cc194eee3f7da6b0a4ac2d14fb28 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 20 Sep 2023 01:07:41 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=EF=BC=9A=E7=A0=8D=E4=BB=B7?= =?UTF-8?q?=E3=80=81=E7=A7=92=E6=9D=80=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/date/LocalDateTimeUtils.java | 1 + .../api/combination/CombinationRecordApi.java | 4 +-- .../api/seckill/SeckillActivityApi.java | 1 + .../bargain/BargainActivityController.java | 6 ++-- .../bargain/AppBargainActivityController.java | 20 +++++------ .../seckill/AppSeckillActivityController.java | 33 ++++++++++--------- .../seckill/AppSeckillConfigController.java | 9 +---- .../bargain/BargainActivityConvert.java | 7 +++- .../CombinationActivityConvert.java | 6 ++-- .../SeckillActivityConvert.java | 3 ++ .../mysql/bargain/BargainActivityMapper.java | 2 +- .../SeckillActivityMapper.java | 1 + .../bargain/BargainActivityService.java | 9 +++-- .../bargain/BargainActivityServiceImpl.java | 10 +++--- .../CombinationActivityService.java | 1 + .../CombinationActivityServiceImpl.java | 2 +- .../CombinationRecordServiceImpl.java | 2 +- .../order/bo/TradeBeforeOrderCreateReqBO.java | 2 ++ 18 files changed, 68 insertions(+), 51 deletions(-) diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java index 6eb33d27d..275e9f5a1 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java @@ -50,6 +50,7 @@ public class LocalDateTimeUtils { * @return 指定时间 */ public static LocalDateTime buildTime(String timeStr) { + // TODO @puhui999:这个方法的实现,和 LocalDateTimeUtil.parse() 的差异点是啥呀 return LocalDateTime.of(LocalDate.now(), LocalTime.parse(timeStr)); } diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java index 5f9b5fba8..bf70bb29c 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java @@ -31,7 +31,7 @@ public interface CombinationRecordApi { boolean isCombinationRecordSuccess(Long userId, Long orderId); /** - * 更新拼团状态为 成功 + * 更新拼团状态为【成功】 * * @param userId 用户编号 * @param orderId 订单编号 @@ -39,7 +39,7 @@ public interface CombinationRecordApi { void updateRecordStatusToSuccess(Long userId, Long orderId); /** - * 更新拼团状态为 失败 + * 更新拼团状态为【失败】 * * @param userId 用户编号 * @param orderId 订单编号 diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java index 1e5d50621..ebe4bb0e5 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java @@ -7,6 +7,7 @@ package cn.iocoder.yudao.module.promotion.api.seckill; */ public interface SeckillActivityApi { + // TODO @puhui999:activityId 改成 id 好点哈; /** * 更新秒杀库存 * diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java index e76e94e57..00b66efc5 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.controller.admin.bargain; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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; @@ -25,6 +24,7 @@ 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.util.collection.CollectionUtils.convertList; @Tag(name = "管理后台 - 砍价活动") @RestController @@ -79,7 +79,9 @@ public class BargainActivityController { if (CollUtil.isEmpty(pageResult.getList())) { return success(PageResult.empty(pageResult.getTotal())); } - List spuList = spuApi.getSpuList(CollectionUtils.convertList(pageResult.getList(), BargainActivityDO::getSpuId)); + + // 拼接数据 + List spuList = spuApi.getSpuList(convertList(pageResult.getList(), BargainActivityDO::getSpuId)); return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList)); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java index dd58d0493..72facf935 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageParam; 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.app.bargain.vo.activity.AppBargainActivityDetailRespVO; @@ -25,6 +24,7 @@ import javax.annotation.Resource; import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; @Tag(name = "用户 App - 砍价活动") @RestController @@ -39,27 +39,27 @@ public class AppBargainActivityController { @GetMapping("/page") @Operation(summary = "获得砍价活动分页") public CommonResult> getBargainActivityPage(PageParam pageReqVO) { - PageResult result = bargainActivityService.getBargainActivityAppPage(pageReqVO); + PageResult result = bargainActivityService.getBargainActivityPageForApp(pageReqVO); if (CollUtil.isEmpty(result.getList())) { return success(PageResult.empty(result.getTotal())); } - - List spuList = spuApi.getSpuList(CollectionUtils.convertList(result.getList(), BargainActivityDO::getSpuId)); + // 拼接数据 + List spuList = spuApi.getSpuList(convertList(result.getList(), BargainActivityDO::getSpuId)); return success(BargainActivityConvert.INSTANCE.convertAppPage(result, spuList)); } + // TODO 芋艿:增加 Spring Cache @GetMapping("/list") @Operation(summary = "获得砍价活动列表", description = "用于小程序首页") @Parameter(name = "count", description = "需要展示的数量", example = "6") public CommonResult> getBargainActivityList( @RequestParam(name = "count", defaultValue = "6") Integer count) { - List list = bargainActivityService.getBargainActivityAppList(count); + List list = bargainActivityService.getBargainActivityListForApp(count); if (CollUtil.isEmpty(list)) { return success(BargainActivityConvert.INSTANCE.convertAppList(list)); } - - List spuList = spuApi.getSpuList(CollectionUtils.convertList(list, BargainActivityDO::getSpuId)); - // TODO 芋艿:增加 Spring Cache + // 拼接数据 + List spuList = spuApi.getSpuList(convertList(list, BargainActivityDO::getSpuId)); return success(BargainActivityConvert.INSTANCE.convertAppList(list, spuList)); } @@ -71,9 +71,9 @@ public class AppBargainActivityController { if (activity == null) { return success(null); } - + // 拼接数据 ProductSpuRespDTO spu = spuApi.getSpu(activity.getSpuId()); - return success(BargainActivityConvert.INSTANCE.convert1(activity, spu)); + return success(BargainActivityConvert.INSTANCE.convert(activity, spu)); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java index 8037c36cb..66aa3bd97 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java @@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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.app.seckill.vo.activity.AppSeckillActivityDetailRespVO; @@ -33,8 +32,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_ACTIVITY_FAIL_STATUS_CLOSED; @@ -56,30 +54,33 @@ public class AppSeckillActivityController { @Operation(summary = "获得当前秒杀活动") // 提供给首页使用 // TODO 芋艿:需要增加 spring cache public CommonResult getNowSeckillActivity() { - // 1、获取当前时间处在哪个秒杀阶段 + // 1. 获取当前时间处在哪个秒杀阶段 + // TODO @puhui999:可以考虑在 service 写个方法;这样 controller 不用关注过多逻辑 List configList = configService.getSeckillConfigList(); SeckillConfigDO filteredConfig = findFirst(configList, config -> ObjectUtil.equal(config.getStatus(), CommonStatusEnum.ENABLE.getStatus()) && isBetween(config.getStartTime(), config.getEndTime())); - // 1、1 时段不存在直接返回 null - if (filteredConfig == null) { + if (filteredConfig == null) { // 时段不存在直接返回 null return success(null); } - // 2、查询满足当前阶段的活动 + // 2. 查询满足当前阶段的活动 + // TODO @puhui999:最好直接返回开启的;不多查询数据 List activityList = activityService.getSeckillActivityListByConfigIds(Arrays.asList(filteredConfig.getId())); List filteredList = filterList(activityList, item -> ObjectUtil.equal(item.getStatus(), CommonStatusEnum.ENABLE.getStatus())); - // 2、1 获取 spu 信息 - List spuList = spuApi.getSpuList(CollectionUtils.convertList(filteredList, SeckillActivityDO::getSpuId)); + + // 3. 拼接数据 + List spuList = spuApi.getSpuList(convertList(filteredList, SeckillActivityDO::getSpuId)); return success(SeckillActivityConvert.INSTANCE.convert(filteredConfig, filteredList, spuList)); } @GetMapping("/page") @Operation(summary = "获得秒杀活动分页") public CommonResult> getSeckillActivityPage(AppSeckillActivityPageReqVO pageReqVO) { - // 1、查询满足当前阶段的活动 + // 1. 查询满足当前阶段的活动 PageResult pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO); - // 1、1 获取 spu 信息 - List spuList = spuApi.getSpuList(CollectionUtils.convertList(pageResult.getList(), SeckillActivityDO::getSpuId)); + + // 2. 拼接数据 + List spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId)); return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, spuList)); } @@ -88,15 +89,15 @@ public class AppSeckillActivityController { @Parameter(name = "id", description = "活动编号", required = true, example = "1024") public CommonResult getSeckillActivity(@RequestParam("id") Long id) { // 1、获取当前时间处在哪个秒杀阶段 + // TODO puhui999:这里,和 58 行是雷同的 List configList = configService.getSeckillConfigList(); SeckillConfigDO filteredConfig = findFirst(configList, config -> ObjectUtil.equal(config.getStatus(), CommonStatusEnum.ENABLE.getStatus()) && isBetween(config.getStartTime(), config.getEndTime())); - // 1、1 时段不存在直接返回 null - if (filteredConfig == null) { + if (filteredConfig == null) { // 时段不存在直接返回 null return success(null); } - // 2、获取活动 + // 2. 获取活动 SeckillActivityDO seckillActivity = activityService.getSeckillActivity(id); if (seckillActivity == null) { return success(null); @@ -106,7 +107,7 @@ public class AppSeckillActivityController { throw exception(SECKILL_ACTIVITY_FAIL_STATUS_CLOSED); } - // 3、获取活动商品 + // 3. 拼接数据 List products = activityService.getSeckillProductListByActivityId(seckillActivity.getId()); return success(SeckillActivityConvert.INSTANCE.convert3(seckillActivity, products, filteredConfig)); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java index d55e9ee47..fc30a2f24 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java @@ -32,19 +32,12 @@ public class AppSeckillConfigController { @Operation(summary = "获得秒杀时间段列表") public CommonResult> getSeckillConfigList() { List list = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus()); + // TODO @puhui999:如果这种,不用判空也问题不大; if (CollectionUtil.isEmpty(list)) { return success(Collections.emptyList()); } return success(SeckillConfigConvert.INSTANCE.convertList2(list)); - //return success(Arrays.asList( - // new AppSeckillConfigRespVO().setId(1L).setStartTime("00:00").setEndTime("09:59") - // .setSliderPicUrls(Arrays.asList("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg", - // "https://static.iocoder.cn/mall/132.jpeg")), - // new AppSeckillConfigRespVO().setId(2L).setStartTime("10:00").setEndTime("12:59"), - // new AppSeckillConfigRespVO().setId(2L).setStartTime("13:00").setEndTime("22:59"), - // new AppSeckillConfigRespVO().setId(2L).setStartTime("23:00").setEndTime("23:59") - //)); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java index 8d3df43ac..24297990f 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java @@ -42,9 +42,11 @@ public interface BargainActivityConvert { default PageResult convertPage(PageResult page, List spuList) { PageResult result = convertPage(page); + // 拼接关联属性 Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); List list = CollectionUtils.convertList(result.getList(), item -> { findAndThen(spuMap, item.getSpuId(), spu -> { + // TODO @puhui999:这里可以使用链式哈 item.setPicUrl(spu.getPicUrl()); item.setSpuName(spu.getName()); }); @@ -56,7 +58,7 @@ public interface BargainActivityConvert { AppBargainActivityDetailRespVO convert1(BargainActivityDO bean); - default AppBargainActivityDetailRespVO convert1(BargainActivityDO bean, ProductSpuRespDTO spu) { + default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, ProductSpuRespDTO spu) { AppBargainActivityDetailRespVO detail = convert1(bean); if (spu != null) { detail.setPicUrl(spu.getPicUrl()); @@ -70,9 +72,11 @@ public interface BargainActivityConvert { default PageResult convertAppPage(PageResult page, List spuList) { PageResult result = convertAppPage(page); + // 拼接关联属性 Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); List list = CollectionUtils.convertList(result.getList(), item -> { findAndThen(spuMap, item.getSpuId(), spu -> { + // TODO @puhui999:这里可以使用链式哈 item.setPicUrl(spu.getPicUrl()); item.setMarketPrice(spu.getMarketPrice()); }); @@ -89,6 +93,7 @@ public interface BargainActivityConvert { Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); return CollectionUtils.convertList(activityList, item -> { findAndThen(spuMap, item.getSpuId(), spu -> { + // TODO @puhui999:这里可以使用链式哈 item.setPicUrl(spu.getPicUrl()); item.setMarketPrice(spu.getMarketPrice()); }); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java index a6e086cc2..d95428cd4 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java @@ -94,8 +94,10 @@ public interface CombinationActivityConvert { CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); - default CombinationRecordDO convert1(CombinationRecordCreateReqDTO reqDTO, CombinationActivityDO activity, MemberUserRespDTO user, - ProductSpuRespDTO spu, ProductSkuRespDTO sku) { + default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO, + CombinationActivityDO activity, MemberUserRespDTO user, + ProductSpuRespDTO spu, ProductSkuRespDTO sku) { + // TODO @puhui999:搞成链式的 set;这样会更规整一点; CombinationRecordDO record = convert(reqDTO); record.setVirtualGroup(false); record.setExpireTime(record.getStartTime().plusHours(activity.getLimitDuration())); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java index fcdcb7dd0..e4c4d5e36 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java @@ -98,6 +98,7 @@ public interface SeckillActivityConvert { Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); respVO.setActivities(CollectionUtils.convertList(convertList3(activityList), item -> { findAndThen(spuMap, item.getSpuId(), spu -> { + // TODO @puhui999:可以尝试链式 set 哈; item.setPicUrl(spu.getPicUrl()); item.setMarketPrice(spu.getMarketPrice()); item.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())); @@ -114,6 +115,7 @@ public interface SeckillActivityConvert { Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); List list = CollectionUtils.convertList(result.getList(), item -> { findAndThen(spuMap, item.getSpuId(), spu -> { + // TODO @puhui999:可以尝试链式 set 哈; item.setPicUrl(spu.getPicUrl()); item.setMarketPrice(spu.getMarketPrice()); item.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())); @@ -131,6 +133,7 @@ public interface SeckillActivityConvert { default AppSeckillActivityDetailRespVO convert3(SeckillActivityDO seckillActivity, List products, SeckillConfigDO filteredConfig) { AppSeckillActivityDetailRespVO respVO = convert2(seckillActivity); respVO.setProducts(convertList1(products)); + // TODO @puhui999:可以尝试链式 set 哈; respVO.setStartTime(buildTime(filteredConfig.getStartTime())); respVO.setEndTime(buildTime(filteredConfig.getEndTime())); return respVO; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java index 3fcf2c87f..f098895d2 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java @@ -41,7 +41,7 @@ public interface BargainActivityMapper extends BaseMapperX { default int updateActivityStock(Long id, int count) { return update(null, new LambdaUpdateWrapper() .eq(BargainActivityDO::getId, id) - .gt(BargainActivityDO::getStock, count) + .ge(BargainActivityDO::getStock, count) .setSql("stock = stock - " + count)); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java index d7b90c118..8ce12092f 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java @@ -52,6 +52,7 @@ public interface SeckillActivityMapper extends BaseMapperX { default PageResult selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status) { return selectPage(pageReqVO, new LambdaQueryWrapperX() .eqIfPresent(SeckillActivityDO::getStatus, status) + // TODO 芋艿:对 find in set 的想法; .apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0")); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java index e59e1ce3e..1b3bd35dd 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java @@ -63,19 +63,22 @@ public interface BargainActivityService { */ PageResult getBargainActivityPage(BargainActivityPageReqVO pageReqVO); + // TODO @puhui999:这里可以改成进行中的活动;尽量避免专门为 app 定制,或者类似的名字哈;mapper 那也是 + /** * 获取 APP 端活动分页数据 * * @param pageReqVO 分页请求 * @return 砍价活动分页 */ - PageResult getBargainActivityAppPage(PageParam pageReqVO); + PageResult getBargainActivityPageForApp(PageParam pageReqVO); /** * 获取 APP 端活动展示数据 * * @param count 需要的数量 - * @return + * @return 砍价活动分页 */ - List getBargainActivityAppList(Integer count); + List getBargainActivityListForApp(Integer count); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java index c426cfca3..5aa075250 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java @@ -142,18 +142,20 @@ public class BargainActivityServiceImpl implements BargainActivityService { } @Override - public PageResult getBargainActivityAppPage(PageParam pageReqVO) { + public PageResult getBargainActivityPageForApp(PageParam pageReqVO) { // 只查询进行中,且在时间范围内的 return bargainActivityMapper.selectAppPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); - } @Override - public List getBargainActivityAppList(Integer count) { + public List getBargainActivityListForApp(Integer count) { + // TODO @puhui999:这种 default count 的逻辑,可以放到 controller 哈;然后可以使用 ObjectUtils.default 方法 if (count == null) { count = 6; } - PageResult result = bargainActivityMapper.selectAppPage(new PageParam().setPageSize(count), CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); + // TODO @puhui999:这种不要用 page;会浪费一次 count; + PageResult result = bargainActivityMapper.selectAppPage(new PageParam().setPageSize(count), + CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); return result.getList(); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java index c3e0f5313..3529932a4 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java @@ -74,6 +74,7 @@ public interface CombinationActivityService { /** * 校验是否满足拼团条件 + * 如果不满足,会抛出异常 * * @param activityId 活动编号 * @param userId 用户编号 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java index a9f95fa62..2224bf626 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java @@ -223,6 +223,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE); } // 1.3 校验是否超出单次限购数量 + // TODO puhui999:count > activity.getSingleLimitCount() 会更好理解点; if (activity.getSingleLimitCount() < count) { throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); } @@ -242,7 +243,6 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic if (activity.getTotalLimitCount() < countSum) { throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); } - } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java index be429b7d5..bb62295b8 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java @@ -132,7 +132,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId()); ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId()); ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()); - recordMapper.insert(CombinationActivityConvert.INSTANCE.convert1(reqDTO, activity, user, spu, sku)); + recordMapper.insert(CombinationActivityConvert.INSTANCE.convert(reqDTO, activity, user, spu, sku)); } @Override diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeBeforeOrderCreateReqBO.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeBeforeOrderCreateReqBO.java index d4e421880..077b5a5ef 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeBeforeOrderCreateReqBO.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeBeforeOrderCreateReqBO.java @@ -14,6 +14,8 @@ import javax.validation.constraints.NotNull; @Data public class TradeBeforeOrderCreateReqBO { + // TODO @puhui999:注释也写下哈;bo 还是写注释噢 + @NotNull(message = "订单类型不能为空") private Integer orderType;