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 new file mode 100644 index 000000000..537350aed --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java @@ -0,0 +1,110 @@ +package cn.iocoder.yudao.module.promotion.controller.app.bargain; + +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.date.LocalDateTimeUtils; +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 io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "用户 App - 砍价活动") +@RestController +@RequestMapping("/promotion/bargain-activity") +@Validated +public class AppBargainActivityController { + + @GetMapping("/page") + @Operation(summary = "获得砍价活动活动") // TODO 芋艿:只查询进行中,且在时间范围内的 + // TODO 芋艿:缺少 swagger 注解 + public CommonResult> getBargainActivityPage(PageParam pageReqVO) { + List activityList = new ArrayList<>(); + AppBargainActivityRespVO activity1 = new AppBargainActivityRespVO(); + activity1.setId(1L); + activity1.setName("618 大砍价"); + activity1.setSpuId(2048L); + activity1.setPicUrl("https://demo26.crmeb.net/uploads/attach/2021/11/15/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(); + activity2.setId(2L); + activity2.setName("双十一砍价"); + activity2.setSpuId(4096L); + activity2.setPicUrl("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKXMYJOomfp7cebz3cIeb8sHk3GGSIJtWEgREe3j7J1WoAbTvIOicpcNdFkWAziatBSMod8b5RyS4CQ/132"); + 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") + @Operation(summary = "获得砍价活动列表", description = "用于小程序首页") + // TODO 芋艿:增加 Spring Cache + // TODO 芋艿:缺少 swagger 注解 + public CommonResult> getBargainActivityList( + @RequestParam(name = "count", defaultValue = "6") Integer count) { + List activityList = new ArrayList<>(); + AppBargainActivityRespVO activity1 = new AppBargainActivityRespVO(); + activity1.setId(1L); + activity1.setName("618 大砍价"); + activity1.setSpuId(2048L); + activity1.setPicUrl("https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg"); + activity1.setMarketPrice(50); + activity1.setBargainPrice(100); + activityList.add(activity1); + + AppBargainActivityRespVO activity2 = new AppBargainActivityRespVO(); + activity2.setId(2L); + activity2.setName("双十一砍价"); + activity2.setSpuId(4096L); + activity2.setPicUrl("https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKXMYJOomfp7cebz3cIeb8sHk3GGSIJtWEgREe3j7J1WoAbTvIOicpcNdFkWAziatBSMod8b5RyS4CQ/132"); + activity2.setMarketPrice(100); + activity2.setBargainPrice(200); + activityList.add(activity2); + + return success(activityList); + } + + @GetMapping("/get-detail") + @Operation(summary = "获得砍价活动详情") + // TODO 芋艿:缺少 swagger 注解 + public CommonResult getBargainActivityDetail(@RequestParam("id") Long id) { + AppBargainActivityDetailRespVO activity = new AppBargainActivityDetailRespVO(); + activity.setId(2L); + activity.setName("618 大砍价"); + activity.setSpuId(2048L); + activity.setPicUrl("https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg"); + activity.setMarketPrice(50); + activity.setBargainPrice(100); + 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); + } + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java new file mode 100644 index 000000000..27d089049 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java @@ -0,0 +1,68 @@ +package cn.iocoder.yudao.module.promotion.controller.app.bargain; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; +import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO; +import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.time.Duration; +import java.util.ArrayList; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "用户 App - 砍价记录") +@RestController +@RequestMapping("/promotion/bargain-record") +@Validated +public class AppBargainRecordController { + + @GetMapping("/get-summary") + @Operation(summary = "获得砍价记录的概要信息", description = "用于小程序首页") + // TODO 芋艿:增加 @Cache 缓存,1 分钟过期 + public CommonResult getBargainRecordSummary() { + AppBargainRecordSummaryRespVO summary = new AppBargainRecordSummaryRespVO(); + summary.setUserCount(1024); + summary.setSuccessRecords(new ArrayList<>()); + AppBargainRecordSummaryRespVO.Record record1 = new AppBargainRecordSummaryRespVO.Record(); + record1.setNickname("王**"); + record1.setAvatar("https://www.iocoder.cn/xxx.jpg"); + record1.setActivityName("天蚕土豆"); + AppBargainRecordSummaryRespVO.Record record2 = new AppBargainRecordSummaryRespVO.Record(); + record2.setNickname("张**"); + record2.setAvatar("https://www.iocoder.cn/yyy.jpg"); + record2.setActivityName("斗罗大陆"); + summary.getSuccessRecords().add(record1); + summary.getSuccessRecords().add(record2); + return success(summary); + } + + @GetMapping("/get-detail") + @Operation(summary = "获得砍价记录的明细") + // TODO 芋艿:swagger;id 和 activityId 二选一 + public CommonResult getBargainRecordDetail( + @RequestParam(value = "id", required = false) Long id, + @RequestParam(value = "activityId", required = false) Long activityId) { + AppBargainRecordDetailRespVO detail = new AppBargainRecordDetailRespVO(); + detail.setId(1L); + detail.setUserId(1L); + detail.setSpuId(1L); + detail.setSkuId(1L); + detail.setPrice(500); + detail.setActivityId(1L); + detail.setBargainPrice(150); + detail.setPrice(200); + detail.setPayPrice(180); + detail.setStatus(1); + detail.setAction(AppBargainRecordDetailRespVO.ACTION_SUCCESS); + detail.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(2))); + return success(detail); + } + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java new file mode 100644 index 000000000..fcff0c86e --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityDetailRespVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "用户 App - 砍价活动的明细 Response VO") +@Data +public class AppBargainActivityDetailRespVO { + + @Schema(description = "砍价活动编号", required = true, example = "1024") + private Long id; + + @Schema(description = "砍价活动名称", required = true, example = "618 大砍价") + private String name; + + @Schema(description = "活动开始时间", required = true) + private LocalDateTime startTime; + + @Schema(description = "活动结束时间", required = true) + private LocalDateTime endTime; + + @Schema(description = "商品 SPU 编号", required = true, example = "2048") + private Long spuId; + + @Schema(description = "商品 SKU 编号", required = true, example = "1024") + private Long skuId; + + @Schema(description = "商品价格,单位:分", required = true, example = "100") + private Integer price; + + @Schema(description = "商品描述", required = true, example = "我要吃西红柿") + private String description; + + @Schema(description = "砍价库存", required = true, example = "512") + private Integer stock; + + @Schema(description = "商品图片", required = true, example = "4096") // 从 SPU 的 picUrl 读取 + private String picUrl; + + @Schema(description = "商品市场价,单位:分", required = true, example = "50") // 从 SPU 的 marketPrice 读取 + private Integer marketPrice; + + @Schema(description = "商品单位", required = true, example = "个") // 从 SPU 的 unit 读取,然后转换 + private String unitName; + + @Schema(description = "砍价最低金额,单位:分", required = true, example = "100") // 从砍价商品里取最低价 + private Integer bargainPrice; + + @Schema(description = "砍价成功数量", required = true, example = "100") + private Integer successCount; + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java new file mode 100644 index 000000000..50778b53d --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "用户 App - 砍价活动 Response VO") +@Data +public class AppBargainActivityRespVO { + + @Schema(description = "砍价活动编号", required = true, example = "1024") + private Long id; + + @Schema(description = "砍价活动名称", required = true, example = "618 大砍价") + private String name; + + @Schema(description = "活动开始时间", required = true) + private LocalDateTime startTime; + + @Schema(description = "活动结束时间", required = true) + private LocalDateTime endTime; + + @Schema(description = "商品 SPU 编号", required = true, example = "2048") + private Long spuId; + + @Schema(description = "商品 SKU 编号", required = true, example = "1024") + private Long skuId; + + @Schema(description = "砍价库存", required = true, example = "512") + private Integer stock; + + @Schema(description = "商品图片", required = true, example = "4096") // 从 SPU 的 picUrl 读取 + private String picUrl; + + @Schema(description = "商品市场价,单位:分", required = true, example = "50") // 从 SPU 的 marketPrice 读取 + private Integer marketPrice; + + @Schema(description = "砍价最低金额,单位:分", required = true, example = "100") // 从砍价商品里取最低价 + private Integer bargainPrice; + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java new file mode 100644 index 000000000..02a9a5dfc --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordDetailRespVO.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "用户 App - 砍价记录的明细 Response VO") +@Data +public class AppBargainRecordDetailRespVO { + + public static final int ACTION_NONE = 1; // 参与动作 - 未参与,可参与 + public static final int ACTION_WAITING = 2; // 参与动作 - 参与中,等待砍价 + public static final int ACTION_SUCCESS = 3; // 参与动作 - 砍价成功,待下单 + public static final int ACTION_ORDER_CREATE = 4; // 参与动作 - 已下单,未付款 + public static final int ACTION_ORDER_PAY = 5; // 参与动作 - 已下单,已付款 + + public static final int HELP_ACTION_NONE = 1; // 帮砍动作 - 未帮砍,可以帮砍 + public static final int HELP_ACTION_FULL = 2; // 帮砍动作 - 未帮砍,无法帮砍(可帮砍次数已满) + public static final int HELP_ACTION_SUCCESS = 3; // 帮砍动作 - 已帮砍 + + private Long id; + private Long userId; + private Long spuId; + private Long skuId; + private Long activityId; + private Integer bargainPrice; + private Integer price; + private Integer payPrice; + private Integer status; + + private LocalDateTime expireTime; + + private Long orderId; // 有且仅在自己的订单才返回 + + private Integer action; + private Integer helpAction; + + // 【未参与】1-可以参与砍价:storeBargainUser 为空; + // 【未参与】2-参与次数已满:storeBargainUser 为空,但是砍价次数已满;storeBargainUser 非空已支付,但是砍价次数已满 TODO 芋艿:这个就不做了 + // 【参与中】3-砍价中:storeBargainUser 非空,人数未满 + // 【参与中】4-已完成:storeBargainUser 非空,未创建订单 + + // 支付的情况; + // 8-已生成订单未支付:storeBargainUser 不为空(status = 3),但是订单未支付; + // 9-已支付:storeBargainUser 不为空(status = 3),且订单已支付; + // 10-取消支付:storeBargainUser 不为空(status = 3),取消支付;【可忽略】 + + // help 的情况; + // 5-可以帮砍:和 3 对应; + // 6-已帮砍:其他人的,有帮砍过; + // 7-帮砍次数已满:其他人的,帮砍次数已满 + + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java new file mode 100644 index 000000000..05439fb26 --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java @@ -0,0 +1,33 @@ +package cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Schema(description = "用户 App - 砍价记录的简要概括 Response VO") +@Data +public class AppBargainRecordSummaryRespVO { + + @Schema(description = "砍价用户数量", required = true, example = "1024") + private Integer userCount; + + @Schema(description = "成功砍价的记录", required = true) // 只返回最近的 7 个 + private List successRecords; + + @Schema(description = "成功砍价记录") + @Data + public static class Record { + + @Schema(description = "用户昵称", required = true, example = "王**") + private String nickname; + + @Schema(description = "用户头像", required = true, example = "https://www.iocoder.cn/xxx.jpg") + private String avatar; + + @Schema(description = "活动名称", required = true, example = "天蚕土豆") + private String activityName; + + } + +} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java index 0c1c8510d..74cd39c5a 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java @@ -29,9 +29,9 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; public class AppCombinationRecordController { @GetMapping("/get-summary") - @Operation(summary = "获得拼团活动的概要信息", description = "用于小程序首页") + @Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页") // TODO 芋艿:增加 @Cache 缓存,1 分钟过期 - public CommonResult getCombinationSummary() { + public CommonResult getCombinationRecordSummary() { AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); summary.setUserCount(1024); summary.setAvatars(new ArrayList<>());