mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 01:01:52 +08:00
Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
# Conflicts: # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
This commit is contained in:
commit
8b480c52cc
@ -5,14 +5,14 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
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.combination.vo.activity.CombinationActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.*;
|
||||
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
|
||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.hutool.core.collection.CollectionUtil.newArrayList;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -36,6 +38,8 @@ public class CombinationActivityController {
|
||||
|
||||
@Resource
|
||||
private CombinationActivityService combinationActivityService;
|
||||
@Resource
|
||||
private CombinationRecordService combinationRecordService;
|
||||
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
@ -77,7 +81,7 @@ public class CombinationActivityController {
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得拼团活动分页")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')")
|
||||
public CommonResult<PageResult<CombinationActivityRespVO>> getCombinationActivityPage(
|
||||
public CommonResult<PageResult<CombinationActivityPageItemRespVO>> getCombinationActivityPage(
|
||||
@Valid CombinationActivityPageReqVO pageVO) {
|
||||
// 查询拼团活动
|
||||
PageResult<CombinationActivityDO> pageResult = combinationActivityService.getCombinationActivityPage(pageVO);
|
||||
@ -85,12 +89,21 @@ public class CombinationActivityController {
|
||||
return success(PageResult.empty(pageResult.getTotal()));
|
||||
}
|
||||
|
||||
// 统计数据
|
||||
Set<Long> activityIds = convertSet(pageResult.getList(), CombinationActivityDO::getId);
|
||||
Map<Long, Integer> groupCountMap = combinationRecordService.getCombinationRecordCountMapByActivity(
|
||||
activityIds, null, CombinationRecordDO.HEAD_ID_GROUP);
|
||||
Map<Long, Integer> groupSuccessCountMap = combinationRecordService.getCombinationRecordCountMapByActivity(
|
||||
activityIds, CombinationRecordStatusEnum.SUCCESS.getStatus(), CombinationRecordDO.HEAD_ID_GROUP);
|
||||
Map<Long, Integer> recordCountMap = combinationRecordService.getCombinationRecordCountMapByActivity(
|
||||
activityIds, null, null);
|
||||
// 拼接数据
|
||||
List<CombinationProductDO> products = combinationActivityService.getCombinationProductsByActivityIds(
|
||||
convertSet(pageResult.getList(), CombinationActivityDO::getId));
|
||||
List<ProductSpuRespDTO> spus = productSpuApi.getSpuList(
|
||||
convertSet(pageResult.getList(), CombinationActivityDO::getSpuId));
|
||||
return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products, spus));
|
||||
return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products,
|
||||
groupCountMap, groupSuccessCountMap, recordCountMap, spus));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,6 +48,9 @@ public class CombinationActivityBaseVO {
|
||||
@NotNull(message = "开团人数不能为空")
|
||||
private Integer userSize;
|
||||
|
||||
@Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
private Boolean virtualGroup = false; // TODO @puhui999:这个字段界面没做呀。
|
||||
|
||||
@Schema(description = "限制时长(小时)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "限制时长不能为空")
|
||||
private Integer limitDuration;
|
||||
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 拼团活动的分页项 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CombinationActivityPageItemRespVO extends CombinationActivityBaseVO {
|
||||
|
||||
@Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<CombinationProductRespVO> products;
|
||||
|
||||
// ========== 商品字段 ==========
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取
|
||||
example = "618大促")
|
||||
private String spuName;
|
||||
@Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
||||
example = "https://www.iocoder.cn/xx.png")
|
||||
private String picUrl;
|
||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
||||
example = "50")
|
||||
private Integer marketPrice;
|
||||
|
||||
// ========== 统计字段 ==========
|
||||
|
||||
@Schema(description = "开团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "33")
|
||||
private Integer groupCount;
|
||||
|
||||
@Schema(description = "成团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
|
||||
private Integer groupSuccessCount;
|
||||
|
||||
@Schema(description = "购买次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer recordCount;
|
||||
|
||||
}
|
@ -15,8 +15,7 @@ public class CombinationActivityPageReqVO extends PageParam {
|
||||
@Schema(description = "拼团名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "活动状态:0开启 1关闭", example = "0")
|
||||
@Schema(description = "活动状态", example = "0")
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@ -20,30 +18,12 @@ public class CombinationActivityRespVO extends CombinationActivityBaseVO {
|
||||
@Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大促")
|
||||
private String spuName;
|
||||
|
||||
@Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
private Integer userSize;
|
||||
|
||||
@Schema(description = "开团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "33")
|
||||
private Integer totalCount;
|
||||
|
||||
@Schema(description = "成团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
|
||||
private Integer successCount;
|
||||
|
||||
@Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
private Integer virtualGroup;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<CombinationProductRespVO> products;
|
||||
|
||||
|
@ -18,16 +18,6 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO {
|
||||
@Schema(description = "秒杀活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取
|
||||
example = "618大促")
|
||||
private String spuName;
|
||||
@Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
||||
example = "https://www.iocoder.cn/xx.png")
|
||||
private String picUrl;
|
||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
||||
example = "50")
|
||||
private Integer marketPrice;
|
||||
|
||||
@Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<SeckillProductRespVO> products;
|
||||
|
||||
@ -52,4 +42,16 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO {
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
// ========== 商品字段 ==========
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取
|
||||
example = "618大促")
|
||||
private String spuName;
|
||||
@Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
||||
example = "https://www.iocoder.cn/xx.png")
|
||||
private String picUrl;
|
||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
||||
example = "50")
|
||||
private Integer marketPrice;
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppB
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
|
||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -52,6 +54,9 @@ public class AppBargainActivityController {
|
||||
|
||||
@Resource
|
||||
private BargainActivityService bargainActivityService;
|
||||
@Resource
|
||||
private BargainRecordService bargainRecordService;
|
||||
|
||||
@Resource
|
||||
private ProductSpuApi spuApi;
|
||||
|
||||
@ -94,8 +99,9 @@ public class AppBargainActivityController {
|
||||
return success(null);
|
||||
}
|
||||
// 拼接数据
|
||||
Integer successUserCount = bargainRecordService.getBargainRecordUserCount(id, BargainRecordStatusEnum.SUCCESS.getStatus());
|
||||
ProductSpuRespDTO spu = spuApi.getSpu(activity.getSpuId());
|
||||
return success(BargainActivityConvert.INSTANCE.convert(activity, spu));
|
||||
return success(BargainActivityConvert.INSTANCE.convert(activity, successUserCount, spu));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,27 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.bargain;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainHelpConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "用户 App - 砍价助力")
|
||||
@ -27,6 +33,9 @@ public class AppBargainHelpController {
|
||||
@Resource
|
||||
private BargainHelpService bargainHelpService;
|
||||
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建砍价助力", description = "给拼团记录砍一刀") // 返回结果为砍价金额,单位:分
|
||||
public CommonResult<Integer> createBargainHelp(@RequestBody AppBargainHelpCreateReqVO reqVO) {
|
||||
@ -36,18 +45,18 @@ public class AppBargainHelpController {
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得砍价助力列表")
|
||||
// TODO 芋艿:swagger
|
||||
@Parameter(name = "recordId", description = "砍价记录编号", required = true, example = "111")
|
||||
public CommonResult<List<AppBargainHelpRespVO>> getBargainHelpList(@RequestParam("recordId") Long recordId) {
|
||||
List<AppBargainHelpRespVO> list = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
AppBargainHelpRespVO vo = new AppBargainHelpRespVO();
|
||||
vo.setNickname("用户" + i);
|
||||
vo.setAvatar("https://www.iocoder.cn/avatar/" + i + ".jpg");
|
||||
vo.setReducePrice((i + 1) * 100);
|
||||
vo.setCreateTime(LocalDateTime.now());
|
||||
list.add(vo);
|
||||
List<BargainHelpDO> helps = bargainHelpService.getBargainHelpListByRecordId(recordId);
|
||||
if (CollUtil.isEmpty(helps)) {
|
||||
return success(Collections.emptyList());
|
||||
}
|
||||
return success(list);
|
||||
helps.sort((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime())); // 倒序展示
|
||||
|
||||
// 拼接数据
|
||||
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(
|
||||
convertSet(helps, BargainHelpDO::getUserId));
|
||||
return success(BargainHelpConvert.INSTANCE.convertList(helps, userMap));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.bargain;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
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.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
@ -19,16 +19,18 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityD
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
|
||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService;
|
||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService;
|
||||
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -47,6 +49,8 @@ public class AppBargainRecordController {
|
||||
private BargainRecordService bargainRecordService;
|
||||
@Resource
|
||||
private BargainActivityService bargainActivityService;
|
||||
@Resource
|
||||
private BargainHelpService bargainHelpService;
|
||||
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
@ -78,23 +82,55 @@ public class AppBargainRecordController {
|
||||
|
||||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得砍价记录的明细")
|
||||
// TODO 芋艿:swagger;id 和 activityId 二选一
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "砍价记录编号", example = "111"), // 场景一:查看指定的砍价记录
|
||||
@Parameter(name = "activityId", description = "砍价活动编号", example = "222") // 场景二:查看指定的砍价活动
|
||||
})
|
||||
public CommonResult<AppBargainRecordDetailRespVO> 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.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(2)));
|
||||
return success(detail);
|
||||
// 1. 查询砍价记录 + 砍价活动
|
||||
Assert.isTrue(id != null || activityId != null, "砍价记录编号和活动编号不能同时为空");
|
||||
BargainRecordDO record = id != null ? bargainRecordService.getBargainRecord(id)
|
||||
: bargainRecordService.getLastBargainRecord(getLoginUserId(), activityId);
|
||||
if (activityId == null || record != null) {
|
||||
activityId = record.getActivityId();
|
||||
}
|
||||
// 2. 查询助力记录
|
||||
Long userId = getLoginUserId();
|
||||
Integer helpAction = getHelpAction(userId, record, activityId);
|
||||
// 3. 如果是自己的订单,则查询订单信息
|
||||
TradeOrderRespDTO order = record != null && record.getOrderId() != null && record.getUserId().equals(getLoginUserId())
|
||||
? tradeOrderApi.getOrder(record.getOrderId()) : null;
|
||||
// TODO 继续查询别的字段
|
||||
|
||||
// 拼接返回
|
||||
return success(BargainRecordConvert.INSTANCE.convert02(record, helpAction, order));
|
||||
}
|
||||
|
||||
private Integer getHelpAction(Long userId, BargainRecordDO record, Long activityId) {
|
||||
// 0.1 如果没有活动,无法帮砍
|
||||
if (activityId == null) {
|
||||
return null;
|
||||
}
|
||||
// 0.2 如果是自己的砍价记录,无法帮砍
|
||||
if (record != null && record.getUserId().equals(userId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 1. 判断是否已经助力
|
||||
if (record != null
|
||||
&& bargainHelpService.getBargainHelp(record.getId(), userId) != null) {
|
||||
return AppBargainRecordDetailRespVO.HELP_ACTION_SUCCESS;
|
||||
}
|
||||
// 2. 判断是否满助力
|
||||
BargainActivityDO activity = bargainActivityService.getBargainActivity(activityId);
|
||||
if (activity != null
|
||||
&& bargainHelpService.getBargainHelpCountByActivity(activityId, userId) >= activity.getBargainCount()) {
|
||||
return AppBargainRecordDetailRespVO.HELP_ACTION_FULL;
|
||||
}
|
||||
// 3. 允许助力
|
||||
return AppBargainRecordDetailRespVO.HELP_ACTION_NONE;
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@ -45,10 +45,13 @@ public class AppBargainActivityDetailRespVO {
|
||||
@Schema(description = "商品单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") // 从 SPU 的 unit 读取,然后转换
|
||||
private String unitName;
|
||||
|
||||
@Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "200")
|
||||
private Integer bargainFirstPrice;
|
||||
|
||||
@Schema(description = "砍价最低金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer bargainPrice;
|
||||
private Integer bargainMinPrice;
|
||||
|
||||
@Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer successCount;
|
||||
private Integer successUserCount;
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class AppBargainHelpRespVO {
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "助力用户的昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private String nickname;
|
||||
|
||||
|
@ -3,8 +3,6 @@ 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 {
|
||||
@ -13,21 +11,44 @@ public class AppBargainRecordDetailRespVO {
|
||||
public static final int HELP_ACTION_FULL = 2; // 帮砍动作 - 未帮砍,无法帮砍(可帮砍次数已满)
|
||||
public static final int HELP_ACTION_SUCCESS = 3; // 帮砍动作 - 已帮砍
|
||||
|
||||
// ========== 砍价记录 ==========
|
||||
|
||||
@Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
private Long spuId;
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
private Long activityId;
|
||||
|
||||
@Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
||||
private Integer bargainFirstPrice;
|
||||
|
||||
@Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
||||
private Integer bargainPrice;
|
||||
private Integer price;
|
||||
private Integer payPrice;
|
||||
|
||||
@Schema(description = "砍价记录状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
private LocalDateTime expireTime;
|
||||
// ========== 订单相关 ========== 注意:只有是自己的砍价记录,才会返回,保证隐私性
|
||||
|
||||
@Schema(description = "订单编号", example = "1024")
|
||||
private Long orderId;
|
||||
|
||||
@Schema(description = "支付状态", example = "true")
|
||||
private Boolean payStatus;
|
||||
|
||||
@Schema(description = "支付订单编号", example = "1024")
|
||||
private Long payOrderId;
|
||||
|
||||
// ========== 助力记录 ==========
|
||||
|
||||
private Integer helpAction;
|
||||
|
||||
}
|
||||
|
@ -61,12 +61,11 @@ public interface BargainActivityConvert {
|
||||
|
||||
AppBargainActivityDetailRespVO convert1(BargainActivityDO bean);
|
||||
|
||||
default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, ProductSpuRespDTO spu) {
|
||||
AppBargainActivityDetailRespVO detail = convert1(bean);
|
||||
default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, Integer successUserCount, ProductSpuRespDTO spu) {
|
||||
AppBargainActivityDetailRespVO detail = convert1(bean).setSuccessUserCount(successUserCount);
|
||||
if (spu != null) {
|
||||
detail.setPicUrl(spu.getPicUrl());
|
||||
detail.setMarketPrice(spu.getMarketPrice());
|
||||
detail.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
||||
detail.setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())
|
||||
.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit()));
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
@ -4,10 +4,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.help.BargainHelpRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBargainHelpRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -31,4 +33,14 @@ public interface BargainHelpConvert {
|
||||
}
|
||||
PageResult<BargainHelpRespVO> convertPage(PageResult<BargainHelpDO> page);
|
||||
|
||||
default List<AppBargainHelpRespVO> convertList(List<BargainHelpDO> helps,
|
||||
Map<Long, MemberUserRespDTO> userMap) {
|
||||
List<AppBargainHelpRespVO> helpVOs = convertList02(helps);
|
||||
helpVOs.forEach(help ->
|
||||
MapUtils.findAndThen(userMap, help.getUserId(),
|
||||
user -> help.setNickname(user.getNickname()).setAvatar(user.getAvatar())));
|
||||
return helpVOs;
|
||||
}
|
||||
List<AppBargainHelpRespVO> convertList02(List<BargainHelpDO> helps);
|
||||
|
||||
}
|
||||
|
@ -6,12 +6,14 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
|
||||
import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -82,4 +84,9 @@ public interface BargainRecordConvert {
|
||||
return summary;
|
||||
}
|
||||
|
||||
@Mapping(source = "record.id", target = "id")
|
||||
@Mapping(source = "record.userId", target = "userId")
|
||||
@Mapping(source = "record.status", target = "status")
|
||||
AppBargainRecordDetailRespVO convert02(BargainRecordDO record, Integer helpAction, TradeOrderRespDTO order);
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO;
|
||||
@ -54,19 +55,27 @@ public interface CombinationActivityConvert {
|
||||
|
||||
List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list);
|
||||
|
||||
PageResult<CombinationActivityRespVO> convertPage(PageResult<CombinationActivityDO> page);
|
||||
|
||||
default PageResult<CombinationActivityRespVO> convertPage(PageResult<CombinationActivityDO> page,
|
||||
List<CombinationProductDO> productList,
|
||||
List<ProductSpuRespDTO> spuList) {
|
||||
default PageResult<CombinationActivityPageItemRespVO> convertPage(PageResult<CombinationActivityDO> page,
|
||||
List<CombinationProductDO> productList,
|
||||
Map<Long, Integer> groupCountMap,
|
||||
Map<Long, Integer> groupSuccessCountMap,
|
||||
Map<Long, Integer> recordCountMap,
|
||||
List<ProductSpuRespDTO> spuList) {
|
||||
PageResult<CombinationActivityPageItemRespVO> pageResult = convertPage(page);
|
||||
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
||||
PageResult<CombinationActivityRespVO> pageResult = convertPage(page);
|
||||
pageResult.getList().forEach(item -> {
|
||||
MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()));
|
||||
MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl())
|
||||
.setMarketPrice(spu.getMarketPrice()));
|
||||
item.setProducts(convertList2(productList));
|
||||
// 设置统计字段
|
||||
item.setGroupCount(groupCountMap.getOrDefault(item.getId(), 0))
|
||||
.setGroupSuccessCount(groupSuccessCountMap.getOrDefault(item.getId(), 0))
|
||||
.setRecordCount(recordCountMap.getOrDefault(item.getId(), 0));
|
||||
});
|
||||
return pageResult;
|
||||
}
|
||||
PageResult<CombinationActivityPageItemRespVO> convertPage(PageResult<CombinationActivityDO> page);
|
||||
|
||||
List<CombinationProductRespVO> convertList2(List<CombinationProductDO> productDOs);
|
||||
|
||||
|
@ -59,22 +59,10 @@ public class CombinationActivityDO extends BaseDO {
|
||||
* 几人团
|
||||
*/
|
||||
private Integer userSize;
|
||||
/**
|
||||
* 开团组数
|
||||
*/
|
||||
private Integer totalCount;
|
||||
/**
|
||||
* 成团组数
|
||||
*/
|
||||
private Integer successCount;
|
||||
/**
|
||||
* 参与人数
|
||||
*/
|
||||
private Integer orderUserCount;
|
||||
/**
|
||||
* 虚拟成团
|
||||
*/
|
||||
private Integer virtualGroup;
|
||||
private Boolean virtualGroup;
|
||||
/**
|
||||
* 活动状态
|
||||
*
|
||||
|
@ -28,6 +28,11 @@ import java.time.LocalDateTime;
|
||||
@AllArgsConstructor
|
||||
public class CombinationRecordDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 团长编号 - 团长
|
||||
*/
|
||||
public static final Integer HEAD_ID_GROUP = 0;
|
||||
|
||||
/**
|
||||
* 编号,主键自增
|
||||
*/
|
||||
@ -84,6 +89,8 @@ public class CombinationRecordDO extends BaseDO {
|
||||
* 团长编号
|
||||
*
|
||||
* 关联 {@link CombinationRecordDO#getId()}
|
||||
*
|
||||
* 如果是团长,则它的值是 {@link #HEAD_ID_GROUP}
|
||||
*/
|
||||
private Long headId;
|
||||
/**
|
||||
|
@ -72,4 +72,9 @@ public interface BargainHelpMapper extends BaseMapperX<BargainHelpDO> {
|
||||
.orderByDesc(BargainHelpDO::getId));
|
||||
}
|
||||
|
||||
default List<BargainHelpDO> selectListByRecordId(Long recordId) {
|
||||
return selectList(new LambdaQueryWrapperX<BargainHelpDO>()
|
||||
.eq(BargainHelpDO::getRecordId, recordId));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -41,6 +42,14 @@ public interface BargainRecordMapper extends BaseMapperX<BargainRecordDO> {
|
||||
.eq(BargainRecordDO::getStatus, status));
|
||||
}
|
||||
|
||||
default BargainRecordDO selectLastByUserIdAndActivityId(Long userId, Long activityId) {
|
||||
return selectOne(new LambdaQueryWrapper<>(BargainRecordDO.class)
|
||||
.eq(BargainRecordDO::getUserId, userId)
|
||||
.eq(BargainRecordDO::getActivityId, activityId)
|
||||
.orderByDesc(BargainRecordDO::getId)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
|
||||
default Long selectCountByUserIdAndActivityIdAndStatus(
|
||||
Long userId, Long activityId, Integer status) {
|
||||
return selectCount(new LambdaQueryWrapper<>(BargainRecordDO.class)
|
||||
@ -71,9 +80,16 @@ public interface BargainRecordMapper extends BaseMapperX<BargainRecordDO> {
|
||||
record -> MapUtil.getInt(record, "userCount" ));
|
||||
}
|
||||
|
||||
@Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record WHERE status = #{status}")
|
||||
@Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record " +
|
||||
"WHERE status = #{status}")
|
||||
Integer selectUserCountByStatus(@Param("status") Integer status);
|
||||
|
||||
@Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record " +
|
||||
"WHERE activity_id = #{activityId} " +
|
||||
"AND status = #{status}")
|
||||
Integer selectUserCountByActivityIdAndStatus(@Param("activityId") Long activityId,
|
||||
@Param("status") Integer status);
|
||||
|
||||
default PageResult<BargainRecordDO> selectPage(BargainRecordPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BargainRecordDO>()
|
||||
.eqIfPresent(BargainRecordDO::getStatus, reqVO.getStatus())
|
||||
@ -101,7 +117,7 @@ public interface BargainRecordMapper extends BaseMapperX<BargainRecordDO> {
|
||||
* @return 更新数量
|
||||
*/
|
||||
default int updateOrderIdById(Long id, Long orderId) {
|
||||
return update(new BargainRecordDO().setOrderId(orderId),
|
||||
return update(new BargainRecordDO().setOrderId(orderId).setEndTime(LocalDateTime.now()),
|
||||
new LambdaQueryWrapper<>(BargainRecordDO.class)
|
||||
.eq(BargainRecordDO::getId, id)
|
||||
.isNull(BargainRecordDO::getOrderId));
|
||||
|
@ -1,16 +1,23 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.combination;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordReqPageVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 拼团记录 Mapper
|
||||
@ -95,6 +102,24 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
||||
.last("LIMIT " + count));
|
||||
}
|
||||
|
||||
default Map<Long, Integer> selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(Collection<Long> activityIds,
|
||||
Integer status, Integer headId) {
|
||||
// SQL count 查询
|
||||
List<Map<String, Object>> result = selectMaps(new QueryWrapper<CombinationRecordDO>()
|
||||
.select("COUNT(DISTINCT(user_id)) AS recordCount, activity_id AS activityId")
|
||||
.in("activity_id", activityIds)
|
||||
.eq(status != null, "status", status)
|
||||
.eq(headId != null, "head_id", headId)
|
||||
.groupBy("activity_id"));
|
||||
if (CollUtil.isEmpty(result)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
// 转换数据
|
||||
return CollectionUtils.convertMap(result,
|
||||
record -> MapUtil.getLong(record, "activityId"),
|
||||
record -> MapUtil.getInt(record, "recordCount" ));
|
||||
}
|
||||
|
||||
static LocalDateTime[] builderQueryTime(Integer dateType) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime[] createTime = null; // 全部时间段
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.help.AppBarga
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainHelpDO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -40,6 +41,15 @@ public interface BargainHelpService {
|
||||
*/
|
||||
Map<Long, Integer> getBargainHelpUserCountMapByRecord(Collection<Long> recordIds);
|
||||
|
||||
/**
|
||||
* 【砍价活动】获得用户的助力次数
|
||||
*
|
||||
* @param activityId 活动编号
|
||||
* @param userId 用户编号
|
||||
* @return 助力次数
|
||||
*/
|
||||
Long getBargainHelpCountByActivity(Long activityId, Long userId);
|
||||
|
||||
/**
|
||||
* 获得砍价助力分页
|
||||
*
|
||||
@ -48,4 +58,21 @@ public interface BargainHelpService {
|
||||
*/
|
||||
PageResult<BargainHelpDO> getBargainHelpPage(BargainHelpPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得指定砍价记录编号,对应的砍价助力列表
|
||||
*
|
||||
* @param recordId 砍价记录编号
|
||||
* @return 砍价助力列表
|
||||
*/
|
||||
List<BargainHelpDO> getBargainHelpListByRecordId(Long recordId);
|
||||
|
||||
/**
|
||||
* 获得助力记录
|
||||
*
|
||||
* @param recordId 砍价记录编号
|
||||
* @param userId 用户编号
|
||||
* @return 助力记录
|
||||
*/
|
||||
BargainHelpDO getBargainHelp(Long recordId, Long userId);
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -114,9 +115,24 @@ public class BargainHelpServiceImpl implements BargainHelpService {
|
||||
return bargainHelpMapper.selectUserCountMapByRecordId(recordIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getBargainHelpCountByActivity(Long activityId, Long userId) {
|
||||
return bargainHelpMapper.selectCountByUserIdAndActivityId(userId, activityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BargainHelpDO> getBargainHelpPage(BargainHelpPageReqVO pageReqVO) {
|
||||
return bargainHelpMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BargainHelpDO> getBargainHelpListByRecordId(Long recordId) {
|
||||
return bargainHelpMapper.selectListByRecordId(recordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BargainHelpDO getBargainHelp(Long recordId, Long userId) {
|
||||
return bargainHelpMapper.selectByUserIdAndRecordId(userId, recordId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,6 +73,15 @@ public interface BargainRecordService {
|
||||
*/
|
||||
BargainRecordDO getBargainRecord(Long id);
|
||||
|
||||
/**
|
||||
* 获得用户在当前砍价活动中的最后一条砍价记录
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param activityId 砍价记录编号
|
||||
* @return 砍价记录
|
||||
*/
|
||||
BargainRecordDO getLastBargainRecord(Long userId, Long activityId);
|
||||
|
||||
/**
|
||||
* 获得砍价人数 Map
|
||||
*
|
||||
@ -83,13 +92,22 @@ public interface BargainRecordService {
|
||||
Map<Long, Integer> getBargainRecordUserCountMap(Collection<Long> activityIds, @Nullable Integer status);
|
||||
|
||||
/**
|
||||
* 获得砍价人数 Map
|
||||
* 获得砍价人数
|
||||
*
|
||||
* @param status 砍价记录状态
|
||||
* @return 砍价人数
|
||||
*/
|
||||
Integer getBargainRecordUserCount(Integer status);
|
||||
|
||||
/**
|
||||
* 获得砍价人数
|
||||
*
|
||||
* @param activityId 砍价活动编号
|
||||
* @param status 砍价记录状态
|
||||
* @return 砍价人数
|
||||
*/
|
||||
Integer getBargainRecordUserCount(Long activityId, Integer status);
|
||||
|
||||
/**
|
||||
* 【管理员】获得砍价记录分页
|
||||
*
|
||||
|
@ -114,6 +114,11 @@ public class BargainRecordServiceImpl implements BargainRecordService {
|
||||
return bargainRecordMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BargainRecordDO getLastBargainRecord(Long userId, Long activityId) {
|
||||
return bargainRecordMapper.selectLastByUserIdAndActivityId(userId, activityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Integer> getBargainRecordUserCountMap(Collection<Long> activityIds, @Nullable Integer status) {
|
||||
return bargainRecordMapper.selectUserCountByActivityIdsAndStatus(activityIds, status);
|
||||
@ -124,6 +129,11 @@ public class BargainRecordServiceImpl implements BargainRecordService {
|
||||
return bargainRecordMapper.selectUserCountByStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getBargainRecordUserCount(Long activityId, Integer status) {
|
||||
return bargainRecordMapper.selectUserCountByActivityIdAndStatus(activityId, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BargainRecordDO> getBargainRecordPage(BargainRecordPageReqVO pageReqVO) {
|
||||
return bargainRecordMapper.selectPage(pageReqVO);
|
||||
|
@ -101,7 +101,7 @@ public interface CombinationActivityService {
|
||||
PageResult<CombinationActivityDO> getCombinationActivityPage(PageParam pageParam);
|
||||
|
||||
/**
|
||||
* 获取指定活动指定 sku 编号的商品
|
||||
* 获取指定活动、指定 sku 编号的商品
|
||||
*
|
||||
* @param activityId 活动编号
|
||||
* @param skuId sku 编号
|
||||
|
@ -65,13 +65,11 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
|
||||
|
||||
// 插入拼团活动
|
||||
CombinationActivityDO activity = CombinationActivityConvert.INSTANCE.convert(createReqVO)
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus())
|
||||
.setTotalCount(0).setSuccessCount(0).setOrderUserCount(0).setVirtualGroup(0);
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
combinationActivityMapper.insert(activity);
|
||||
// 插入商品
|
||||
List<CombinationProductDO> products = CombinationActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity);
|
||||
combinationProductMapper.insertBatch(products);
|
||||
// 返回
|
||||
return activity.getId();
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,13 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationA
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// todo @PUHUI:方法名,还是带下 Combination 哈
|
||||
/**
|
||||
* 拼团记录 Service 接口
|
||||
*
|
||||
@ -159,4 +163,16 @@ public interface CombinationRecordService {
|
||||
*/
|
||||
PageResult<CombinationRecordDO> getBargainRecordPage(CombinationRecordReqPageVO pageVO);
|
||||
|
||||
/**
|
||||
* 【拼团活动】获得拼团记录数量 Map
|
||||
*
|
||||
* @param activityIds 活动记录编号数组
|
||||
* @param status 拼团状态,允许空
|
||||
* @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置
|
||||
* @return 拼团记录数量 Map
|
||||
*/
|
||||
Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
||||
@Nullable Integer status,
|
||||
@Nullable Integer headId);
|
||||
|
||||
}
|
||||
|
@ -27,9 +27,12 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
@ -205,6 +208,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
|
||||
@Override
|
||||
public CombinationRecordDO getCombinationRecord(Long userId, Long orderId) {
|
||||
// TODO puhui999:这里直接获得,不适合调用校验的接口;
|
||||
return validateCombinationRecord(userId, orderId);
|
||||
}
|
||||
|
||||
@ -267,4 +271,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
return recordMapper.selectPage(pageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
||||
@Nullable Integer status, @Nullable Integer headId) {
|
||||
return recordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,14 @@ public interface TradeOrderApi {
|
||||
*/
|
||||
List<TradeOrderRespDTO> getOrderList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得订单
|
||||
*
|
||||
* @param id 订单编号
|
||||
* @return 订单
|
||||
*/
|
||||
TradeOrderRespDTO getOrder(Long id);
|
||||
|
||||
// TODO 芋艿:看看是不是可以删除掉;
|
||||
/**
|
||||
* 获取订单状态
|
||||
|
@ -34,6 +34,11 @@ public class TradeOrderApiImpl implements TradeOrderApi {
|
||||
return TradeOrderConvert.INSTANCE.convertList04(tradeOrderQueryService.getOrderList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TradeOrderRespDTO getOrder(Long id) {
|
||||
return TradeOrderConvert.INSTANCE.convert(tradeOrderQueryService.getOrder(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getOrderStatus(Long id) {
|
||||
TradeOrderDO order = tradeOrderQueryService.getOrder(id);
|
||||
|
@ -39,6 +39,7 @@ import cn.iocoder.yudao.module.trade.service.price.bo.TradePriceCalculateRespBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.Named;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -262,6 +263,7 @@ public interface TradeOrderConvert {
|
||||
return bo;
|
||||
}
|
||||
|
||||
@Named("convertList04")
|
||||
List<TradeOrderRespDTO> convertList04(List<TradeOrderDO> list);
|
||||
|
||||
@Mappings({
|
||||
|
@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
// TODO @puhui999:单测可以后补下
|
||||
/**
|
||||
* 拼团活动的 {@link TradePriceCalculator} 实现类
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user