Commit bbee720710fbb79e056ba97336fb36414cefd0f0
1 parent
1b87b8a4
📖 CRM:code review 拼团记录的实现
Showing
11 changed files
with
79 additions
and
17 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryService.java
| ... | ... | @@ -19,10 +19,9 @@ public interface ProductBrowseHistoryService { |
| 19 | 19 | * |
| 20 | 20 | * @param userId 用户编号 |
| 21 | 21 | * @param spuId SPU 编号 |
| 22 | - * @return 编号 | |
| 23 | 22 | */ |
| 24 | 23 | @Async |
| 25 | - Long createBrowseHistory(Long userId, Long spuId); | |
| 24 | + void createBrowseHistory(Long userId, Long spuId); | |
| 26 | 25 | |
| 27 | 26 | /** |
| 28 | 27 | * 隐藏用户商品浏览记录 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryServiceImpl.java
| ... | ... | @@ -26,10 +26,10 @@ public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryServ |
| 26 | 26 | private ProductBrowseHistoryMapper browseHistoryMapper; |
| 27 | 27 | |
| 28 | 28 | @Override |
| 29 | - public Long createBrowseHistory(Long userId, Long spuId) { | |
| 29 | + public void createBrowseHistory(Long userId, Long spuId) { | |
| 30 | 30 | // 用户未登录时不记录 |
| 31 | 31 | if (userId == null) { |
| 32 | - return null; | |
| 32 | + return; | |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // 情况一:同一个商品,只保留最新的一条记录 |
| ... | ... | @@ -50,7 +50,6 @@ public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryServ |
| 50 | 50 | .setUserId(userId) |
| 51 | 51 | .setSpuId(spuId); |
| 52 | 52 | browseHistoryMapper.insert(browseHistory); |
| 53 | - return browseHistory.getId(); | |
| 54 | 53 | } |
| 55 | 54 | |
| 56 | 55 | @Override | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.app.combination; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 6 | +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; | |
| 4 | 7 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO; |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; | |
| 5 | 9 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO; |
| 6 | 10 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO; |
| 7 | 11 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; |
| ... | ... | @@ -13,6 +17,9 @@ import io.swagger.v3.oas.annotations.Operation; |
| 13 | 17 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | 18 | import io.swagger.v3.oas.annotations.Parameters; |
| 15 | 19 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 20 | +import jakarta.annotation.Resource; | |
| 21 | +import jakarta.validation.Valid; | |
| 22 | +import jakarta.validation.constraints.Max; | |
| 16 | 23 | import org.springframework.context.annotation.Lazy; |
| 17 | 24 | import org.springframework.validation.annotation.Validated; |
| 18 | 25 | import org.springframework.web.bind.annotation.GetMapping; |
| ... | ... | @@ -20,8 +27,6 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 20 | 27 | import org.springframework.web.bind.annotation.RequestParam; |
| 21 | 28 | import org.springframework.web.bind.annotation.RestController; |
| 22 | 29 | |
| 23 | -import jakarta.annotation.Resource; | |
| 24 | -import jakarta.validation.constraints.Max; | |
| 25 | 30 | import java.util.Collections; |
| 26 | 31 | import java.util.List; |
| 27 | 32 | import java.util.Objects; |
| ... | ... | @@ -73,8 +78,18 @@ public class AppCombinationRecordController { |
| 73 | 78 | @RequestParam(value = "activityId", required = false) Long activityId, |
| 74 | 79 | @RequestParam("status") Integer status, |
| 75 | 80 | @RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) { |
| 76 | - return success(CombinationActivityConvert.INSTANCE.convertList3( | |
| 77 | - combinationRecordService.getHeadCombinationRecordList(activityId, status, count))); | |
| 81 | + List<CombinationRecordDO> list = combinationRecordService.getHeadCombinationRecordList(activityId, status, count); | |
| 82 | + return success(BeanUtils.toBean(list, AppCombinationRecordRespVO.class)); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @GetMapping("/page") | |
| 86 | + @Operation(summary = "获得我的拼团记录分页") | |
| 87 | + @PreAuthenticated | |
| 88 | + public CommonResult<PageResult<AppCombinationRecordRespVO>> getCombinationRecordPage( | |
| 89 | + @Valid AppCombinationRecordPageReqVO pageReqVO) { | |
| 90 | + PageResult<CombinationRecordDO> pageResult = combinationRecordService.getCombinationRecordPage( | |
| 91 | + getLoginUserId(), pageReqVO); | |
| 92 | + return success(BeanUtils.toBean(pageResult, AppCombinationRecordRespVO.class)); | |
| 78 | 93 | } |
| 79 | 94 | |
| 80 | 95 | @GetMapping("/get-detail") | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; | |
| 6 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 7 | +import lombok.Data; | |
| 8 | +import lombok.EqualsAndHashCode; | |
| 9 | +import lombok.ToString; | |
| 10 | + | |
| 11 | +@Schema(description = "用户 App - 拼团记录分页 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class AppCombinationRecordPageReqVO extends PageParam { | |
| 16 | + | |
| 17 | + @Schema(description = "拼团状态", example = "1") | |
| 18 | + @InEnum(value = CombinationRecordStatusEnum.class, message = "拼团状态必须是 {value}") | |
| 19 | + private Integer status; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/record/AppCombinationRecordRespVO.java
| ... | ... | @@ -33,12 +33,18 @@ public class AppCombinationRecordRespVO { |
| 33 | 33 | @Schema(description = "拼团状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 34 | 34 | private Integer status; |
| 35 | 35 | |
| 36 | + @Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") | |
| 37 | + private Long orderId; | |
| 38 | + | |
| 36 | 39 | @Schema(description = "商品名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是大黄豆") |
| 37 | 40 | private String spuName; |
| 38 | 41 | |
| 39 | 42 | @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") |
| 40 | 43 | private String picUrl; |
| 41 | 44 | |
| 45 | + @Schema(description = "购买的商品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 46 | + private Integer count; | |
| 47 | + | |
| 42 | 48 | @Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| 43 | 49 | private Integer combinationPrice; |
| 44 | 50 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/diy/AppDiyPageController.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| ... | ... | @@ -60,7 +60,6 @@ public interface CombinationActivityConvert { |
| 60 | 60 | |
| 61 | 61 | List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list); |
| 62 | 62 | |
| 63 | - | |
| 64 | 63 | default PageResult<CombinationActivityPageItemRespVO> convertPage(PageResult<CombinationActivityDO> page, |
| 65 | 64 | List<CombinationProductDO> productList, |
| 66 | 65 | Map<Long, Integer> groupCountMap, |
| ... | ... | @@ -125,7 +124,6 @@ public interface CombinationActivityConvert { |
| 125 | 124 | .setNickname(user.getNickname()).setAvatar(user.getAvatar()) |
| 126 | 125 | // 商品信息 |
| 127 | 126 | .setSpuName(spu.getName()).setPicUrl(sku.getPicUrl()); |
| 128 | - | |
| 129 | 127 | } |
| 130 | 128 | |
| 131 | 129 | List<AppCombinationActivityRespVO> convertAppList(List<CombinationActivityDO> list); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| ... | ... | @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 9 | 9 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; |
| 10 | +import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; | |
| 10 | 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 11 | 12 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 12 | 13 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -143,4 +144,11 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO |
| 143 | 144 | return selectList(CombinationRecordDO::getHeadId, headId); |
| 144 | 145 | } |
| 145 | 146 | |
| 147 | + default PageResult<CombinationRecordDO> selectPage(Long userId, AppCombinationRecordPageReqVO pageReqVO) { | |
| 148 | + LambdaQueryWrapperX<CombinationRecordDO> queryWrapper = new LambdaQueryWrapperX<CombinationRecordDO>() | |
| 149 | + .eq(CombinationRecordDO::getUserId, userId) | |
| 150 | + .eqIfPresent(CombinationRecordDO::getStatus, pageReqVO.getStatus()); | |
| 151 | + return selectPage(pageReqVO, queryWrapper); | |
| 152 | + } | |
| 153 | + | |
| 146 | 154 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| ... | ... | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 6 | 6 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; |
| 7 | 7 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; | |
| 8 | 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| 9 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; |
| 10 | 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| ... | ... | @@ -163,4 +164,13 @@ public interface CombinationRecordService { |
| 163 | 164 | */ |
| 164 | 165 | KeyValue<Integer, Integer> expireCombinationRecord(); |
| 165 | 166 | |
| 167 | + /** | |
| 168 | + * 获得拼团记录分页数据 | |
| 169 | + * | |
| 170 | + * @param userId 用户编号 | |
| 171 | + * @param pageReqVO 分页请求 | |
| 172 | + * @return 拼团记录分页数据 | |
| 173 | + */ | |
| 174 | + PageResult<CombinationRecordDO> getCombinationRecordPage(Long userId, AppCombinationRecordPageReqVO pageReqVO); | |
| 175 | + | |
| 166 | 176 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 16 | 16 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 17 | 17 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationValidateJoinRespDTO; |
| 18 | 18 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO; |
| 19 | +import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO; | |
| 19 | 20 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; |
| 20 | 21 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| 21 | 22 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; |
| ... | ... | @@ -23,14 +24,14 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationR |
| 23 | 24 | import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper; |
| 24 | 25 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 25 | 26 | import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; |
| 27 | +import jakarta.annotation.Nullable; | |
| 28 | +import jakarta.annotation.Resource; | |
| 26 | 29 | import lombok.extern.slf4j.Slf4j; |
| 27 | 30 | import org.springframework.context.annotation.Lazy; |
| 28 | 31 | import org.springframework.stereotype.Service; |
| 29 | 32 | import org.springframework.transaction.annotation.Transactional; |
| 30 | 33 | import org.springframework.validation.annotation.Validated; |
| 31 | 34 | |
| 32 | -import jakarta.annotation.Nullable; | |
| 33 | -import jakarta.annotation.Resource; | |
| 34 | 35 | import java.time.LocalDateTime; |
| 35 | 36 | import java.util.*; |
| 36 | 37 | |
| ... | ... | @@ -159,7 +160,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 159 | 160 | // 2.1. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP |
| 160 | 161 | if (record.getHeadId() == null) { |
| 161 | 162 | record.setStartTime(LocalDateTime.now()) |
| 162 | - .setExpireTime(keyValue.getKey().getStartTime().plusHours(keyValue.getKey().getLimitDuration())) | |
| 163 | + .setExpireTime(LocalDateTime.now().plusHours(keyValue.getKey().getLimitDuration())) | |
| 163 | 164 | .setHeadId(CombinationRecordDO.HEAD_ID_GROUP); |
| 164 | 165 | } else { |
| 165 | 166 | // 2.2.有团长的情况下需要设置开始时间和过期时间为团长的 |
| ... | ... | @@ -408,6 +409,11 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 408 | 409 | return records; |
| 409 | 410 | } |
| 410 | 411 | |
| 412 | + @Override | |
| 413 | + public PageResult<CombinationRecordDO> getCombinationRecordPage(Long userId, AppCombinationRecordPageReqVO pageReqVO) { | |
| 414 | + return combinationRecordMapper.selectPage(userId, pageReqVO); | |
| 415 | + } | |
| 416 | + | |
| 411 | 417 | /** |
| 412 | 418 | * 获得自身的代理对象,解决 AOP 生效问题 |
| 413 | 419 | * | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
| ... | ... | @@ -21,18 +21,17 @@ import com.google.common.collect.Maps; |
| 21 | 21 | import io.swagger.v3.oas.annotations.Operation; |
| 22 | 22 | import io.swagger.v3.oas.annotations.Parameter; |
| 23 | 23 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 24 | +import jakarta.annotation.Resource; | |
| 25 | +import jakarta.validation.Valid; | |
| 24 | 26 | import lombok.extern.slf4j.Slf4j; |
| 25 | 27 | import org.springframework.validation.annotation.Validated; |
| 26 | 28 | import org.springframework.web.bind.annotation.*; |
| 27 | 29 | |
| 28 | -import jakarta.annotation.Resource; | |
| 29 | -import jakarta.validation.Valid; | |
| 30 | 30 | import java.util.List; |
| 31 | 31 | import java.util.Map; |
| 32 | 32 | |
| 33 | 33 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 34 | 34 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 35 | -import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; | |
| 36 | 35 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 37 | 36 | |
| 38 | 37 | @Tag(name = "用户 App - 交易订单") | ... | ... |