Commit 6f762f21d3c5989de892a218f00c1b1372d3dca6
Committed by
Gitee
!1120 【功能优化】商城
Merge pull request !1120 from puhui999/develop
Showing
9 changed files
with
46 additions
and
49 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessageListReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | +import jakarta.validation.constraints.Max; | |
| 5 | +import jakarta.validation.constraints.Min; | |
| 4 | 6 | import jakarta.validation.constraints.NotNull; |
| 5 | 7 | import lombok.Data; |
| 6 | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| ... | ... | @@ -13,6 +15,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 13 | 15 | @Data |
| 14 | 16 | public class KeFuMessageListReqVO { |
| 15 | 17 | |
| 18 | + private static final Integer PAGE_SIZE = 10; | |
| 19 | + | |
| 16 | 20 | @Schema(description = "会话编号", example = "12580") |
| 17 | 21 | @NotNull(message = "会话编号不能为空") |
| 18 | 22 | private Long conversationId; |
| ... | ... | @@ -21,4 +25,10 @@ public class KeFuMessageListReqVO { |
| 21 | 25 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 22 | 26 | private LocalDateTime createTime; |
| 23 | 27 | |
| 28 | + @Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 29 | + @NotNull(message = "每页条数不能为空") | |
| 30 | + @Min(value = 1, message = "每页条数最小值为 1") | |
| 31 | + @Max(value = 100, message = "每页条数最大值为 100") | |
| 32 | + private Integer pageSize = PAGE_SIZE; | |
| 33 | + | |
| 24 | 34 | } |
| 25 | 35 | \ No newline at end of file | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/vo/activity/PointActivityPageReqVO.java
| ... | ... | @@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | import lombok.EqualsAndHashCode; |
| 7 | 7 | import lombok.ToString; |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | - | |
| 10 | -import java.time.LocalDateTime; | |
| 11 | - | |
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | 8 | |
| 14 | 9 | @Schema(description = "管理后台 - 积分商城活动分页 Request VO") |
| 15 | 10 | @Data |
| ... | ... | @@ -17,20 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 17 | 12 | @ToString(callSuper = true) |
| 18 | 13 | public class PointActivityPageReqVO extends PageParam { |
| 19 | 14 | |
| 20 | - @Schema(description = "积分商城活动商品", example = "19509") | |
| 21 | - private Long spuId; | |
| 22 | - | |
| 23 | 15 | @Schema(description = "活动状态", example = "2") |
| 24 | 16 | private Integer status; |
| 25 | 17 | |
| 26 | - @Schema(description = "备注", example = "你说的对") | |
| 27 | - private String remark; | |
| 28 | - | |
| 29 | - @Schema(description = "排序") | |
| 30 | - private Integer sort; | |
| 31 | - | |
| 32 | - @Schema(description = "创建时间") | |
| 33 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 34 | - private LocalDateTime[] createTime; | |
| 35 | - | |
| 36 | 18 | } |
| 37 | 19 | \ No newline at end of file | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java
| ... | ... | @@ -9,6 +9,8 @@ import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuM |
| 9 | 9 | import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO; |
| 10 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; |
| 11 | 11 | import cn.iocoder.yudao.module.promotion.service.kefu.KeFuMessageService; |
| 12 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 13 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | |
| 12 | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -18,8 +20,12 @@ import org.springframework.validation.annotation.Validated; |
| 18 | 20 | import org.springframework.web.bind.annotation.*; |
| 19 | 21 | |
| 20 | 22 | import java.util.List; |
| 23 | +import java.util.Map; | |
| 21 | 24 | |
| 22 | 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 27 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; | |
| 28 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 23 | 29 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 24 | 30 | |
| 25 | 31 | @Tag(name = "用户 APP - 客服消息") |
| ... | ... | @@ -30,6 +36,8 @@ public class AppKeFuMessageController { |
| 30 | 36 | |
| 31 | 37 | @Resource |
| 32 | 38 | private KeFuMessageService kefuMessageService; |
| 39 | + @Resource | |
| 40 | + private AdminUserApi adminUserApi; | |
| 33 | 41 | |
| 34 | 42 | @PostMapping("/send") |
| 35 | 43 | @Operation(summary = "发送客服消息") |
| ... | ... | @@ -52,8 +60,14 @@ public class AppKeFuMessageController { |
| 52 | 60 | @Operation(summary = "获得客服消息列表") |
| 53 | 61 | @PreAuthenticated |
| 54 | 62 | public CommonResult<List<KeFuMessageRespVO>> getKefuMessageList(@Valid AppKeFuMessagePageReqVO pageReqVO) { |
| 55 | - List<KeFuMessageDO> pageResult = kefuMessageService.getKeFuMessageList(pageReqVO, getLoginUserId()); | |
| 56 | - return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class)); | |
| 63 | + List<KeFuMessageDO> list = kefuMessageService.getKeFuMessageList(pageReqVO, getLoginUserId()); | |
| 64 | + | |
| 65 | + // 拼接数据 | |
| 66 | + List<KeFuMessageRespVO> result = BeanUtils.toBean(list, KeFuMessageRespVO.class); | |
| 67 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result, | |
| 68 | + item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId)); | |
| 69 | + result.forEach(item -> findAndThen(userMap, item.getSenderId(), user -> item.setSenderAvatar(user.getAvatar()))); | |
| 70 | + return success(result); | |
| 57 | 71 | } |
| 58 | 72 | |
| 59 | 73 | } |
| 60 | 74 | \ No newline at end of file | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessagePageReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | +import jakarta.validation.constraints.Max; | |
| 5 | +import jakarta.validation.constraints.Min; | |
| 6 | +import jakarta.validation.constraints.NotNull; | |
| 4 | 7 | import lombok.Data; |
| 5 | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| 6 | 9 | |
| ... | ... | @@ -12,6 +15,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 12 | 15 | @Data |
| 13 | 16 | public class AppKeFuMessagePageReqVO { |
| 14 | 17 | |
| 18 | + private static final Integer PAGE_SIZE = 10; | |
| 19 | + | |
| 15 | 20 | @Schema(description = "会话编号", example = "12580") |
| 16 | 21 | private Long conversationId; |
| 17 | 22 | |
| ... | ... | @@ -19,4 +24,10 @@ public class AppKeFuMessagePageReqVO { |
| 19 | 24 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 20 | 25 | private LocalDateTime createTime; |
| 21 | 26 | |
| 27 | + @Schema(description = "每页条数,最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 28 | + @NotNull(message = "每页条数不能为空") | |
| 29 | + @Min(value = 1, message = "每页条数最小值为 1") | |
| 30 | + @Max(value = 100, message = "每页条数最大值为 100") | |
| 31 | + private Integer pageSize = PAGE_SIZE; | |
| 32 | + | |
| 22 | 33 | } |
| 23 | 34 | \ No newline at end of file | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/vo/AppPointActivityRespVO.java
| ... | ... | @@ -4,8 +4,6 @@ import com.alibaba.excel.annotation.ExcelProperty; |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | - | |
| 9 | 7 | @Schema(description = "用户 App - 积分商城活动 Response VO") |
| 10 | 8 | @Data |
| 11 | 9 | public class AppPointActivityRespVO { |
| ... | ... | @@ -30,20 +28,6 @@ public class AppPointActivityRespVO { |
| 30 | 28 | @ExcelProperty("积分商城活动总库存") |
| 31 | 29 | private Integer totalStock; |
| 32 | 30 | |
| 33 | - // TODO @puhui999:只返回必要的字段,例如说 remark、sort、createTime 应该是不需要的呢。也可以看看别的也不需要哈。 | |
| 34 | - | |
| 35 | - @Schema(description = "备注", example = "你说的对") | |
| 36 | - @ExcelProperty("备注") | |
| 37 | - private String remark; | |
| 38 | - | |
| 39 | - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 40 | - @ExcelProperty("排序") | |
| 41 | - private Integer sort; | |
| 42 | - | |
| 43 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 44 | - @ExcelProperty("创建时间") | |
| 45 | - private LocalDateTime createTime; | |
| 46 | - | |
| 47 | 31 | // ========== 商品字段 ========== |
| 48 | 32 | |
| 49 | 33 | @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| ... | ... | @@ -217,7 +217,7 @@ public interface CombinationActivityConvert { |
| 217 | 217 | List<CombinationRecordDO> createRecords = new ArrayList<>(count); |
| 218 | 218 | for (int i = 0; i < count; i++) { |
| 219 | 219 | // 基础信息和团长保持一致 |
| 220 | - CombinationRecordDO newRecord = convert5(headRecord); | |
| 220 | + CombinationRecordDO newRecord = convert5(headRecord).setHeadId(headRecord.getId()); | |
| 221 | 221 | // 虚拟信息 |
| 222 | 222 | newRecord.setCount(0) // 会单独更新下,在后续的 Service 逻辑里 |
| 223 | 223 | .setUserId(0L).setNickname("").setAvatar("").setOrderId(0L); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuMessageMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.dal.mysql.kefu; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | |
| 5 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; |
| 7 | 7 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| ... | ... | @@ -28,11 +28,11 @@ public interface KeFuMessageMapper extends BaseMapperX<KeFuMessageDO> { |
| 28 | 28 | * @return 消息列表 |
| 29 | 29 | */ |
| 30 | 30 | default List<KeFuMessageDO> selectList(KeFuMessageListReqVO reqVO) { |
| 31 | - return selectList(new LambdaQueryWrapperX<KeFuMessageDO>() | |
| 32 | - .eqIfPresent(KeFuMessageDO::getConversationId, reqVO.getConversationId()) | |
| 33 | - .ltIfPresent(KeFuMessageDO::getCreateTime, reqVO.getCreateTime()) | |
| 34 | - .orderByDesc(KeFuMessageDO::getCreateTime) | |
| 35 | - .last("limit 10")); // TODO @puhui999:使用 limitN 哈。然后 10 通过 reqVO 传递。 | |
| 31 | + return selectList(new QueryWrapperX<KeFuMessageDO>() | |
| 32 | + .eqIfPresent("conversation_id", reqVO.getConversationId()) | |
| 33 | + .ltIfPresent("create_time", reqVO.getCreateTime()) | |
| 34 | + .orderByDesc("create_time") | |
| 35 | + .limitN(reqVO.getPageSize())); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | default List<KeFuMessageDO> selectListByConversationIdAndUserTypeAndReadStatus(Long conversationId, Integer userType, | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/point/PointActivityMapper.java
| ... | ... | @@ -19,12 +19,8 @@ public interface PointActivityMapper extends BaseMapperX<PointActivityDO> { |
| 19 | 19 | |
| 20 | 20 | default PageResult<PointActivityDO> selectPage(PointActivityPageReqVO reqVO) { |
| 21 | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<PointActivityDO>() |
| 22 | - .eqIfPresent(PointActivityDO::getSpuId, reqVO.getSpuId()) | |
| 23 | 22 | .eqIfPresent(PointActivityDO::getStatus, reqVO.getStatus()) |
| 24 | - .eqIfPresent(PointActivityDO::getRemark, reqVO.getRemark()) | |
| 25 | - .eqIfPresent(PointActivityDO::getSort, reqVO.getSort()) | |
| 26 | - .betweenIfPresent(PointActivityDO::getCreateTime, reqVO.getCreateTime()) | |
| 27 | - .orderByDesc(PointActivityDO::getId)); | |
| 23 | + .orderByDesc(PointActivityDO::getSort)); | |
| 28 | 24 | } |
| 29 | 25 | |
| 30 | 26 | /** | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -375,7 +375,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 375 | 375 | CombinationRecordDO updateRecord = new CombinationRecordDO().setId(item.getId()) |
| 376 | 376 | .setStatus(status.getStatus()).setEndTime(now); |
| 377 | 377 | if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 |
| 378 | - updateRecord.setUserCount(updateRecord.getUserSize()); | |
| 378 | + updateRecord.setUserCount(records.size()); | |
| 379 | 379 | } |
| 380 | 380 | updateRecords.add(updateRecord); |
| 381 | 381 | }); | ... | ... |