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 | package cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message; | 1 | package cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | +import jakarta.validation.constraints.Max; | ||
| 5 | +import jakarta.validation.constraints.Min; | ||
| 4 | import jakarta.validation.constraints.NotNull; | 6 | import jakarta.validation.constraints.NotNull; |
| 5 | import lombok.Data; | 7 | import lombok.Data; |
| 6 | import org.springframework.format.annotation.DateTimeFormat; | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| @@ -13,6 +15,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | @@ -13,6 +15,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | ||
| 13 | @Data | 15 | @Data |
| 14 | public class KeFuMessageListReqVO { | 16 | public class KeFuMessageListReqVO { |
| 15 | 17 | ||
| 18 | + private static final Integer PAGE_SIZE = 10; | ||
| 19 | + | ||
| 16 | @Schema(description = "会话编号", example = "12580") | 20 | @Schema(description = "会话编号", example = "12580") |
| 17 | @NotNull(message = "会话编号不能为空") | 21 | @NotNull(message = "会话编号不能为空") |
| 18 | private Long conversationId; | 22 | private Long conversationId; |
| @@ -21,4 +25,10 @@ public class KeFuMessageListReqVO { | @@ -21,4 +25,10 @@ public class KeFuMessageListReqVO { | ||
| 21 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 25 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 22 | private LocalDateTime createTime; | 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 | \ No newline at end of file | 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,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
| 7 | import lombok.ToString; | 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 | @Schema(description = "管理后台 - 积分商城活动分页 Request VO") | 9 | @Schema(description = "管理后台 - 积分商城活动分页 Request VO") |
| 15 | @Data | 10 | @Data |
| @@ -17,20 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | @@ -17,20 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | ||
| 17 | @ToString(callSuper = true) | 12 | @ToString(callSuper = true) |
| 18 | public class PointActivityPageReqVO extends PageParam { | 13 | public class PointActivityPageReqVO extends PageParam { |
| 19 | 14 | ||
| 20 | - @Schema(description = "积分商城活动商品", example = "19509") | ||
| 21 | - private Long spuId; | ||
| 22 | - | ||
| 23 | @Schema(description = "活动状态", example = "2") | 15 | @Schema(description = "活动状态", example = "2") |
| 24 | private Integer status; | 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 | \ No newline at end of file | 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,6 +9,8 @@ import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuM | ||
| 9 | import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO; | 9 | import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO; |
| 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; |
| 11 | import cn.iocoder.yudao.module.promotion.service.kefu.KeFuMessageService; | 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 | import io.swagger.v3.oas.annotations.Operation; | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | import io.swagger.v3.oas.annotations.Parameter; | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | import io.swagger.v3.oas.annotations.tags.Tag; | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -18,8 +20,12 @@ import org.springframework.validation.annotation.Validated; | @@ -18,8 +20,12 @@ import org.springframework.validation.annotation.Validated; | ||
| 18 | import org.springframework.web.bind.annotation.*; | 20 | import org.springframework.web.bind.annotation.*; |
| 19 | 21 | ||
| 20 | import java.util.List; | 22 | import java.util.List; |
| 23 | +import java.util.Map; | ||
| 21 | 24 | ||
| 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 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 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | 29 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 24 | 30 | ||
| 25 | @Tag(name = "用户 APP - 客服消息") | 31 | @Tag(name = "用户 APP - 客服消息") |
| @@ -30,6 +36,8 @@ public class AppKeFuMessageController { | @@ -30,6 +36,8 @@ public class AppKeFuMessageController { | ||
| 30 | 36 | ||
| 31 | @Resource | 37 | @Resource |
| 32 | private KeFuMessageService kefuMessageService; | 38 | private KeFuMessageService kefuMessageService; |
| 39 | + @Resource | ||
| 40 | + private AdminUserApi adminUserApi; | ||
| 33 | 41 | ||
| 34 | @PostMapping("/send") | 42 | @PostMapping("/send") |
| 35 | @Operation(summary = "发送客服消息") | 43 | @Operation(summary = "发送客服消息") |
| @@ -52,8 +60,14 @@ public class AppKeFuMessageController { | @@ -52,8 +60,14 @@ public class AppKeFuMessageController { | ||
| 52 | @Operation(summary = "获得客服消息列表") | 60 | @Operation(summary = "获得客服消息列表") |
| 53 | @PreAuthenticated | 61 | @PreAuthenticated |
| 54 | public CommonResult<List<KeFuMessageRespVO>> getKefuMessageList(@Valid AppKeFuMessagePageReqVO pageReqVO) { | 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 | \ No newline at end of file | 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 | package cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message; | 1 | package cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 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 | import lombok.Data; | 7 | import lombok.Data; |
| 5 | import org.springframework.format.annotation.DateTimeFormat; | 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,6 +15,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ | ||
| 12 | @Data | 15 | @Data |
| 13 | public class AppKeFuMessagePageReqVO { | 16 | public class AppKeFuMessagePageReqVO { |
| 14 | 17 | ||
| 18 | + private static final Integer PAGE_SIZE = 10; | ||
| 19 | + | ||
| 15 | @Schema(description = "会话编号", example = "12580") | 20 | @Schema(description = "会话编号", example = "12580") |
| 16 | private Long conversationId; | 21 | private Long conversationId; |
| 17 | 22 | ||
| @@ -19,4 +24,10 @@ public class AppKeFuMessagePageReqVO { | @@ -19,4 +24,10 @@ public class AppKeFuMessagePageReqVO { | ||
| 19 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 24 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 20 | private LocalDateTime createTime; | 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 | \ No newline at end of file | 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,8 +4,6 @@ import com.alibaba.excel.annotation.ExcelProperty; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | 6 | ||
| 7 | -import java.time.LocalDateTime; | ||
| 8 | - | ||
| 9 | @Schema(description = "用户 App - 积分商城活动 Response VO") | 7 | @Schema(description = "用户 App - 积分商城活动 Response VO") |
| 10 | @Data | 8 | @Data |
| 11 | public class AppPointActivityRespVO { | 9 | public class AppPointActivityRespVO { |
| @@ -30,20 +28,6 @@ public class AppPointActivityRespVO { | @@ -30,20 +28,6 @@ public class AppPointActivityRespVO { | ||
| 30 | @ExcelProperty("积分商城活动总库存") | 28 | @ExcelProperty("积分商城活动总库存") |
| 31 | private Integer totalStock; | 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 | @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 | 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,7 +217,7 @@ public interface CombinationActivityConvert { | ||
| 217 | List<CombinationRecordDO> createRecords = new ArrayList<>(count); | 217 | List<CombinationRecordDO> createRecords = new ArrayList<>(count); |
| 218 | for (int i = 0; i < count; i++) { | 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 | newRecord.setCount(0) // 会单独更新下,在后续的 Service 逻辑里 | 222 | newRecord.setCount(0) // 会单独更新下,在后续的 Service 逻辑里 |
| 223 | .setUserId(0L).setNickname("").setAvatar("").setOrderId(0L); | 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 | package cn.iocoder.yudao.module.promotion.dal.mysql.kefu; | 1 | package cn.iocoder.yudao.module.promotion.dal.mysql.kefu; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 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 | import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO; | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageListReqVO; |
| 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; | 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO; |
| 7 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 7 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| @@ -28,11 +28,11 @@ public interface KeFuMessageMapper extends BaseMapperX<KeFuMessageDO> { | @@ -28,11 +28,11 @@ public interface KeFuMessageMapper extends BaseMapperX<KeFuMessageDO> { | ||
| 28 | * @return 消息列表 | 28 | * @return 消息列表 |
| 29 | */ | 29 | */ |
| 30 | default List<KeFuMessageDO> selectList(KeFuMessageListReqVO reqVO) { | 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 | default List<KeFuMessageDO> selectListByConversationIdAndUserTypeAndReadStatus(Long conversationId, Integer userType, | 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,12 +19,8 @@ public interface PointActivityMapper extends BaseMapperX<PointActivityDO> { | ||
| 19 | 19 | ||
| 20 | default PageResult<PointActivityDO> selectPage(PointActivityPageReqVO reqVO) { | 20 | default PageResult<PointActivityDO> selectPage(PointActivityPageReqVO reqVO) { |
| 21 | return selectPage(reqVO, new LambdaQueryWrapperX<PointActivityDO>() | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<PointActivityDO>() |
| 22 | - .eqIfPresent(PointActivityDO::getSpuId, reqVO.getSpuId()) | ||
| 23 | .eqIfPresent(PointActivityDO::getStatus, reqVO.getStatus()) | 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,7 +375,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { | ||
| 375 | CombinationRecordDO updateRecord = new CombinationRecordDO().setId(item.getId()) | 375 | CombinationRecordDO updateRecord = new CombinationRecordDO().setId(item.getId()) |
| 376 | .setStatus(status.getStatus()).setEndTime(now); | 376 | .setStatus(status.getStatus()).setEndTime(now); |
| 377 | if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 | 377 | if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 |
| 378 | - updateRecord.setUserCount(updateRecord.getUserSize()); | 378 | + updateRecord.setUserCount(records.size()); |
| 379 | } | 379 | } |
| 380 | updateRecords.add(updateRecord); | 380 | updateRecords.add(updateRecord); |
| 381 | }); | 381 | }); |