mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-12-02 04:01:52 +08:00
fix: 完善订单发货逻辑、重构砍价活动、完善拼团记录创建逻辑
This commit is contained in:
parent
be2ee905df
commit
651725e3e8
@ -14,10 +14,19 @@ import javax.validation.Valid;
|
|||||||
public interface BargainRecordApi {
|
public interface BargainRecordApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建开团记录
|
* 创建砍价记录
|
||||||
*
|
*
|
||||||
* @param reqDTO 请求 DTO
|
* @param reqDTO 请求 DTO
|
||||||
*/
|
*/
|
||||||
void createRecord(@Valid BargainRecordCreateReqDTO reqDTO);
|
void createRecord(@Valid BargainRecordCreateReqDTO reqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询砍价是否成功
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param orderId 订单编号
|
||||||
|
* @return 砍价是否成功
|
||||||
|
*/
|
||||||
|
boolean validateRecordSuccess(Long userId, Long orderId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.api.combination;
|
package cn.iocoder.yudao.module.promotion.api.combination;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
// TODO @芋艿:后面也再撸撸这几个接口
|
// TODO @芋艿:后面也再撸撸这几个接口
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼团记录 API 接口
|
* 拼团记录 API 接口
|
||||||
*
|
*
|
||||||
@ -18,7 +21,7 @@ public interface CombinationRecordApi {
|
|||||||
*
|
*
|
||||||
* @param reqDTO 请求 DTO
|
* @param reqDTO 请求 DTO
|
||||||
*/
|
*/
|
||||||
void createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
|
void createRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询拼团记录是否成功
|
* 查询拼团记录是否成功
|
||||||
@ -27,7 +30,26 @@ public interface CombinationRecordApi {
|
|||||||
* @param orderId 订单编号
|
* @param orderId 订单编号
|
||||||
* @return 拼团是否成功
|
* @return 拼团是否成功
|
||||||
*/
|
*/
|
||||||
boolean isCombinationRecordSuccess(Long userId, Long orderId);
|
boolean validateRecordSuccess(Long userId, Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取拼团记录
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param activityId 活动编号
|
||||||
|
* @return 拼团记录列表
|
||||||
|
*/
|
||||||
|
List<CombinationRecordRespDTO> getRecordListByUserIdAndActivityId(Long userId, Long activityId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证组合限制数
|
||||||
|
* 校验是否满足限购要求
|
||||||
|
*
|
||||||
|
* @param count 本次购买数量
|
||||||
|
* @param sumCount 已购买数量合计
|
||||||
|
* @param activityId 活动编号
|
||||||
|
*/
|
||||||
|
void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount);
|
||||||
|
|
||||||
// TODO @puhui999:是不是搞成具体的方法,拼团成功,拼团失败,这种方法;
|
// TODO @puhui999:是不是搞成具体的方法,拼团成功,拼团失败,这种方法;
|
||||||
|
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.api.combination.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团记录 Response DTO
|
||||||
|
*
|
||||||
|
* @author HUIHUI
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CombinationRecordRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团活动编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "拼团活动编号不能为空")
|
||||||
|
private Long activityId;
|
||||||
|
/**
|
||||||
|
* spu 编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "spu 编号不能为空")
|
||||||
|
private Long spuId;
|
||||||
|
/**
|
||||||
|
* sku 编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "sku 编号不能为空")
|
||||||
|
private Long skuId;
|
||||||
|
/**
|
||||||
|
* 用户编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "用户编号不能为空")
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 订单编号
|
||||||
|
*/
|
||||||
|
@NotNull(message = "订单编号不能为空")
|
||||||
|
private Long orderId;
|
||||||
|
/**
|
||||||
|
* 开团状态:正在开团 拼团成功 拼团失败
|
||||||
|
*/
|
||||||
|
@NotNull(message = "开团状态不能为空")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
@ -67,17 +67,18 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013010004, "拼团不存在");
|
ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013010004, "拼团不存在");
|
||||||
ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013010005, "拼团失败,已参与过该拼团");
|
ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013010005, "拼团失败,已参与过该拼团");
|
||||||
ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013010006, "拼团失败,父拼团不存在");
|
ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013010006, "拼团失败,父拼团不存在");
|
||||||
ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1013010006, "拼团失败,拼团人数已满");
|
ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1013010007, "拼团失败,拼团人数已满");
|
||||||
|
ErrorCode COMBINATION_RECORD_FAILED_HAVE_JOINED = new ErrorCode(1013010008, "拼团失败,已参与其它拼团");
|
||||||
|
ErrorCode COMBINATION_RECORD_FAILED_TIME_END = new ErrorCode(1013010009, "拼团失败,活动已经结束");
|
||||||
|
ErrorCode COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1013010010, "拼团失败,单次限购超出");
|
||||||
|
ErrorCode COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED = new ErrorCode(1013010011, "拼团失败,单次限购超出");
|
||||||
|
|
||||||
// ========== 砍价活动 1013011000 ==========
|
// ========== 砍价活动 1013011000 ==========
|
||||||
ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013011000, "砍价活动不存在");
|
ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013011000, "砍价活动不存在");
|
||||||
ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动");
|
ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动");
|
||||||
ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改");
|
ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改");
|
||||||
ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除");
|
ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除");
|
||||||
|
ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价记录不存在");
|
||||||
// TODO @puhui999:拆分成砍价记录
|
|
||||||
|
|
||||||
ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价不存在");
|
|
||||||
ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价");
|
ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价");
|
||||||
ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在");
|
ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在");
|
||||||
ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013011007, "砍价失败,砍价人数已满");
|
ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013011007, "砍价失败,砍价人数已满");
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.api.combination;
|
package cn.iocoder.yudao.module.promotion.api.combination;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService;
|
import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼团活动 API 实现类
|
* 拼团活动 API 实现类
|
||||||
@ -20,15 +23,25 @@ public class CombinationRecordApiImpl implements CombinationRecordApi {
|
|||||||
private CombinationRecordService recordService;
|
private CombinationRecordService recordService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
public void createRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||||
recordService.createCombinationRecord(reqDTO);
|
recordService.createCombinationRecord(reqDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCombinationRecordSuccess(Long userId, Long orderId) {
|
public boolean validateRecordSuccess(Long userId, Long orderId) {
|
||||||
return CombinationRecordStatusEnum.isSuccess(recordService.getCombinationRecord(userId, orderId).getStatus());
|
return CombinationRecordStatusEnum.isSuccess(recordService.getCombinationRecord(userId, orderId).getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CombinationRecordRespDTO> getRecordListByUserIdAndActivityId(Long userId, Long activityId) {
|
||||||
|
return CombinationActivityConvert.INSTANCE.convert(recordService.getRecordListByUserIdAndActivityId(userId, activityId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount) {
|
||||||
|
recordService.validateCombinationLimitCount(activityId, count, sumCount);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO) {
|
public void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO) {
|
||||||
if (null == reqDTO.getStartTime()) {
|
if (null == reqDTO.getStartTime()) {
|
||||||
|
@ -3,13 +3,11 @@ package cn.iocoder.yudao.module.promotion.controller.admin.bargain;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.ProductSpuApi;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert;
|
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.dal.dataobject.bargain.BargainProductDO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
|
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@ -20,12 +18,8 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static cn.hutool.core.collection.CollectionUtil.newArrayList;
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 砍价活动")
|
@Tag(name = "管理后台 - 砍价活动")
|
||||||
@RestController
|
@RestController
|
||||||
@ -68,9 +62,7 @@ public class BargainActivityController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')")
|
@PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')")
|
||||||
public CommonResult<BargainActivityRespVO> getBargainActivity(@RequestParam("id") Long id) {
|
public CommonResult<BargainActivityRespVO> getBargainActivity(@RequestParam("id") Long id) {
|
||||||
BargainActivityDO activity = activityService.getBargainActivity(id);
|
return success(BargainActivityConvert.INSTANCE.convert(activityService.getBargainActivity(id)));
|
||||||
List<BargainProductDO> products = activityService.getBargainProductsByActivityIds(newArrayList(id));
|
|
||||||
return success(BargainActivityConvert.INSTANCE.convert(activity, products));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@ -78,14 +70,7 @@ public class BargainActivityController {
|
|||||||
@PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')")
|
@PreAuthorize("@ss.hasPermission('promotion:bargain-activity:query')")
|
||||||
public CommonResult<PageResult<BargainActivityRespVO>> getBargainActivityPage(
|
public CommonResult<PageResult<BargainActivityRespVO>> getBargainActivityPage(
|
||||||
@Valid BargainActivityPageReqVO pageVO) {
|
@Valid BargainActivityPageReqVO pageVO) {
|
||||||
// 查询砍价活动
|
return success(BargainActivityConvert.INSTANCE.convertPage(activityService.getBargainActivityPage(pageVO)));
|
||||||
PageResult<BargainActivityDO> pageResult = activityService.getBargainActivityPage(pageVO);
|
|
||||||
// 拼接数据
|
|
||||||
Set<Long> activityIds = convertSet(pageResult.getList(), BargainActivityDO::getId);
|
|
||||||
Set<Long> spuIds = convertSet(pageResult.getList(), BargainActivityDO::getSpuId);
|
|
||||||
return success(BargainActivityConvert.INSTANCE.convertPage(pageResult,
|
|
||||||
activityService.getBargainProductsByActivityIds(activityIds),
|
|
||||||
spuApi.getSpuList(spuIds)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
|
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -26,6 +26,22 @@ public class BargainActivityBaseVO {
|
|||||||
@NotNull(message = "砍价商品不能为空")
|
@NotNull(message = "砍价商品不能为空")
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
|
||||||
|
@Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
||||||
|
@NotNull(message = "商品 skuId 不能为空")
|
||||||
|
private Long skuId;
|
||||||
|
|
||||||
|
@Schema(description = "砍价起始价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
||||||
|
@NotNull(message = "砍价起始价格不能为空")
|
||||||
|
private Integer bargainFirstPrice;
|
||||||
|
|
||||||
|
@Schema(description = "砍价底价", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
||||||
|
@NotNull(message = "砍价底价不能为空")
|
||||||
|
private Integer bargainPrice;
|
||||||
|
|
||||||
|
@Schema(description = "活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
||||||
|
@NotNull(message = "活动库存不能为空")
|
||||||
|
private Integer stock;
|
||||||
|
|
||||||
@Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218")
|
@Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "16218")
|
||||||
@NotNull(message = "总限购数量不能为空")
|
@NotNull(message = "总限购数量不能为空")
|
||||||
private Integer totalLimitCount;
|
private Integer totalLimitCount;
|
@ -1,14 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product;
|
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 砍价商品更新 Request VO")
|
@Schema(description = "管理后台 - 砍价活动创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class BargainProductUpdateReqVO extends BargainProductBaseVO {
|
public class BargainActivityCreateReqVO extends BargainActivityBaseVO {
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 砍价活动分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class BargainActivityPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "砍价名称", example = "赵六")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "活动状态:0开启 1关闭", example = "0")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
@ -1,24 +1,18 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
|
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductRespVO;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 砍价活动 Response VO")
|
@Schema(description = "管理后台 - 砍价活动 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class BargainActivityRespVO extends BargainActivityBaseVO {
|
public class BargainActivityRespVO extends BargainActivityBaseVO {
|
||||||
|
|
||||||
// TODO @puhui999:example 补全
|
|
||||||
|
|
||||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促")
|
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促")
|
||||||
private String spuName;
|
private String spuName;
|
||||||
|
|
||||||
@ -28,18 +22,14 @@ public class BargainActivityRespVO extends BargainActivityBaseVO {
|
|||||||
@Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901")
|
@Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "砍价成功数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "999")
|
||||||
private Integer successCount;
|
private Integer successCount;
|
||||||
|
|
||||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||||
@NotNull(message = "活动状态不能为空")
|
@NotNull(message = "活动状态不能为空")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "砍价商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@Valid
|
|
||||||
private List<BargainProductRespVO> products;
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,14 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
|
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductUpdateReqVO;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 砍价活动更新 Request VO")
|
@Schema(description = "管理后台 - 砍价活动更新 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@ -20,8 +17,4 @@ public class BargainActivityUpdateReqVO extends BargainActivityBaseVO {
|
|||||||
@NotNull(message = "活动编号不能为空")
|
@NotNull(message = "活动编号不能为空")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "砍价商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@Valid
|
|
||||||
private List<BargainProductUpdateReqVO> products;
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,22 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductCreateReqVO;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 砍价活动创建 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BargainActivityCreateReqVO extends BargainActivityBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "砍价商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@Valid
|
|
||||||
private List<BargainProductCreateReqVO> products;
|
|
||||||
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 砍价活动分页 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BargainActivityPageReqVO extends PageParam {
|
|
||||||
|
|
||||||
@Schema(description = "砍价名称", example = "赵六")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号关联 ProductSpuDO 的 id", example = "14016")
|
|
||||||
private Long spuId;
|
|
||||||
|
|
||||||
@Schema(description = "总限购数量", example = "16218")
|
|
||||||
private Integer totalLimitCount;
|
|
||||||
|
|
||||||
@Schema(description = "单次限购数量", example = "28265")
|
|
||||||
private Integer singleLimitCount;
|
|
||||||
|
|
||||||
@Schema(description = "开始时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] startTime;
|
|
||||||
|
|
||||||
@Schema(description = "结束时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] endTime;
|
|
||||||
|
|
||||||
@Schema(description = "开团人数")
|
|
||||||
private Integer userSize;
|
|
||||||
|
|
||||||
@Schema(description = "开团组数")
|
|
||||||
private Integer totalNum;
|
|
||||||
|
|
||||||
@Schema(description = "成团组数")
|
|
||||||
private Integer successNum;
|
|
||||||
|
|
||||||
@Schema(description = "参与人数", example = "25222")
|
|
||||||
private Integer orderUserCount;
|
|
||||||
|
|
||||||
@Schema(description = "虚拟成团")
|
|
||||||
private Integer virtualGroup;
|
|
||||||
|
|
||||||
@Schema(description = "活动状态:0开启 1关闭", example = "0")
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
@Schema(description = "限制时长(小时)")
|
|
||||||
private Integer limitDuration;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] createTime;
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 砍价商品 Base VO,提供给添加、修改、详细的子 VO 使用
|
|
||||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class BargainProductBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "商品 spuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "123")
|
|
||||||
@NotNull(message = "商品 spuId 不能为空")
|
|
||||||
private Long spuId;
|
|
||||||
|
|
||||||
@Schema(description = "商品 skuId", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
|
||||||
@NotNull(message = "商品 skuId 不能为空")
|
|
||||||
private Long skuId;
|
|
||||||
|
|
||||||
@Schema(description = "砍价起始价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
|
||||||
@NotNull(message = "砍价起始价格不能为空")
|
|
||||||
private Integer bargainFirstPrice;
|
|
||||||
|
|
||||||
@Schema(description = "砍价底价", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
|
||||||
@NotNull(message = "砍价底价不能为空")
|
|
||||||
private Integer bargainPrice;
|
|
||||||
|
|
||||||
@Schema(description = "活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "23")
|
|
||||||
@NotNull(message = "活动库存不能为空")
|
|
||||||
private Integer stock;
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
// TODO @puhui999:是不是应该把 BargainProductCreateReqVO 和 BargainProductUpdateReqVO 合并在一起哈。就是一个 SaveReqVO
|
|
||||||
@Schema(description = "管理后台 - 砍价商品创建 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BargainProductCreateReqVO extends BargainProductBaseVO {
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 砍价商品 Response VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class BargainProductRespVO extends BargainProductBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "28322")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
}
|
|
@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 拼团活动分页 Request VO")
|
@Schema(description = "管理后台 - 拼团活动分页 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@ -20,46 +15,8 @@ public class CombinationActivityPageReqVO extends PageParam {
|
|||||||
@Schema(description = "拼团名称", example = "赵六")
|
@Schema(description = "拼团名称", example = "赵六")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号关联 ProductSpuDO 的 id", example = "14016")
|
|
||||||
private Long spuId;
|
|
||||||
|
|
||||||
@Schema(description = "总限购数量", example = "16218")
|
|
||||||
private Integer totalLimitCount;
|
|
||||||
|
|
||||||
@Schema(description = "单次限购数量", example = "28265")
|
|
||||||
private Integer singleLimitCount;
|
|
||||||
|
|
||||||
@Schema(description = "开始时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] startTime;
|
|
||||||
|
|
||||||
@Schema(description = "结束时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] endTime;
|
|
||||||
|
|
||||||
@Schema(description = "开团人数")
|
|
||||||
private Integer userSize;
|
|
||||||
|
|
||||||
@Schema(description = "开团组数")
|
|
||||||
private Integer totalNum;
|
|
||||||
|
|
||||||
@Schema(description = "成团组数")
|
|
||||||
private Integer successNum;
|
|
||||||
|
|
||||||
@Schema(description = "参与人数", example = "25222")
|
|
||||||
private Integer orderUserCount;
|
|
||||||
|
|
||||||
@Schema(description = "虚拟成团")
|
|
||||||
private Integer virtualGroup;
|
|
||||||
|
|
||||||
@Schema(description = "活动状态:0开启 1关闭", example = "0")
|
@Schema(description = "活动状态:0开启 1关闭", example = "0")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "限制时长(小时)")
|
|
||||||
private Integer limitDuration;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
private LocalDateTime[] createTime;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.convert.bargain;
|
package cn.iocoder.yudao.module.promotion.convert.bargain;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductBaseVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductRespVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductUpdateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO;
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.Mappings;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼团活动 Convert
|
* 拼团活动 Convert
|
||||||
@ -38,57 +26,8 @@ public interface BargainActivityConvert {
|
|||||||
|
|
||||||
BargainActivityRespVO convert(BargainActivityDO bean);
|
BargainActivityRespVO convert(BargainActivityDO bean);
|
||||||
|
|
||||||
BargainProductRespVO convert(BargainProductDO bean);
|
|
||||||
|
|
||||||
default BargainActivityRespVO convert(BargainActivityDO bean, List<BargainProductDO> productDOs) {
|
|
||||||
return convert(bean).setProducts(convertList2(productDOs));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<BargainActivityRespVO> convertList(List<BargainActivityDO> list);
|
List<BargainActivityRespVO> convertList(List<BargainActivityDO> list);
|
||||||
|
|
||||||
PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page);
|
PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page);
|
||||||
|
|
||||||
default PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page,
|
|
||||||
List<BargainProductDO> productList,
|
|
||||||
List<ProductSpuRespDTO> spuList) {
|
|
||||||
Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
|
|
||||||
PageResult<BargainActivityRespVO> pageResult = convertPage(page);
|
|
||||||
pageResult.getList().forEach(item -> {
|
|
||||||
MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> {
|
|
||||||
item.setSpuName(spu.getName());
|
|
||||||
item.setPicUrl(spu.getPicUrl());
|
|
||||||
});
|
|
||||||
item.setProducts(convertList2(productList));
|
|
||||||
});
|
|
||||||
return pageResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<BargainProductRespVO> convertList2(List<BargainProductDO> productDOs);
|
|
||||||
|
|
||||||
// TODO @puhui999:参数改成 activity、product 会不会干净一点哈
|
|
||||||
@Mappings({
|
|
||||||
@Mapping(target = "id", ignore = true),
|
|
||||||
@Mapping(target = "activityId", source = "activityDO.id"),
|
|
||||||
@Mapping(target = "spuId", source = "activityDO.spuId"),
|
|
||||||
@Mapping(target = "skuId", source = "vo.skuId"),
|
|
||||||
@Mapping(target = "bargainFirstPrice", source = "vo.bargainFirstPrice"),
|
|
||||||
@Mapping(target = "bargainPrice", source = "vo.bargainPrice"),
|
|
||||||
@Mapping(target = "stock", source = "vo.stock"),
|
|
||||||
@Mapping(target = "activityStartTime", source = "activityDO.startTime"),
|
|
||||||
@Mapping(target = "activityEndTime", source = "activityDO.endTime")
|
|
||||||
})
|
|
||||||
BargainProductDO convert(BargainActivityDO activityDO, BargainProductBaseVO vo);
|
|
||||||
|
|
||||||
default List<BargainProductDO> convertList(List<? extends BargainProductBaseVO> products, BargainActivityDO activityDO) {
|
|
||||||
return CollectionUtils.convertList(products, item -> convert(activityDO, item).setActivityStatus(activityDO.getStatus()));
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<BargainProductDO> convertList(List<BargainProductUpdateReqVO> updateProductVOs,
|
|
||||||
List<BargainProductDO> products, BargainActivityDO activity) {
|
|
||||||
Map<Long, Long> productMap = convertMap(products, BargainProductDO::getSkuId, BargainProductDO::getId);
|
|
||||||
return CollectionUtils.convertList(updateProductVOs, updateProductVO -> convert(activity, updateProductVO)
|
|
||||||
.setId(productMap.get(updateProductVO.getSkuId()))
|
|
||||||
.setActivityStatus(activity.getStatus()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|||||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
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.api.combination.dto.CombinationRecordCreateReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO;
|
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.CombinationActivityUpdateReqVO;
|
||||||
@ -93,4 +94,6 @@ public interface CombinationActivityConvert {
|
|||||||
|
|
||||||
CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO);
|
CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO);
|
||||||
|
|
||||||
|
List<CombinationRecordRespDTO> convert(List<CombinationRecordDO> bean);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,18 @@ public class BargainActivityDO extends BaseDO {
|
|||||||
* 商品 SPU 编号
|
* 商品 SPU 编号
|
||||||
*/
|
*/
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
/**
|
||||||
|
* 商品 SKU 编号
|
||||||
|
*/
|
||||||
|
private Long skuId;
|
||||||
|
/**
|
||||||
|
* 砍价起始价格,单位分
|
||||||
|
*/
|
||||||
|
private Integer bargainFirstPrice;
|
||||||
|
/**
|
||||||
|
* 砍价底价,单位:分
|
||||||
|
*/
|
||||||
|
private Integer bargainPrice;
|
||||||
/**
|
/**
|
||||||
* 达到该人数,才能砍到低价
|
* 达到该人数,才能砍到低价
|
||||||
*/
|
*/
|
||||||
@ -70,7 +81,7 @@ public class BargainActivityDO extends BaseDO {
|
|||||||
private Integer totalLimitCount;
|
private Integer totalLimitCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 砍价库存
|
* 砍价活动库存
|
||||||
*/
|
*/
|
||||||
private Integer stock;
|
private Integer stock;
|
||||||
|
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 砍价商品 DO
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@TableName("promotion_bargain_product")
|
|
||||||
@KeySequence("promotion_bargain_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class BargainProductDO extends BaseDO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编号
|
|
||||||
*/
|
|
||||||
@TableId
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 砍价活动编号
|
|
||||||
*/
|
|
||||||
private Long activityId;
|
|
||||||
/**
|
|
||||||
* 商品 SPU 编号
|
|
||||||
*/
|
|
||||||
private Long spuId;
|
|
||||||
/**
|
|
||||||
* 商品 SKU 编号
|
|
||||||
*/
|
|
||||||
private Long skuId;
|
|
||||||
/**
|
|
||||||
* 砍价商品状态
|
|
||||||
*
|
|
||||||
* 关联 {@link BargainActivityDO#getStatus()}
|
|
||||||
*/
|
|
||||||
private Integer activityStatus;
|
|
||||||
/**
|
|
||||||
* 活动开始时间点
|
|
||||||
*/
|
|
||||||
private LocalDateTime activityStartTime;
|
|
||||||
/**
|
|
||||||
* 活动结束时间点
|
|
||||||
*/
|
|
||||||
private LocalDateTime activityEndTime;
|
|
||||||
/**
|
|
||||||
* 砍价起始价格,单位分
|
|
||||||
*/
|
|
||||||
private Integer bargainFirstPrice;
|
|
||||||
/**
|
|
||||||
* 砍价底价,单位:分
|
|
||||||
*/
|
|
||||||
private Integer bargainPrice;
|
|
||||||
/**
|
|
||||||
* 活动库存
|
|
||||||
*/
|
|
||||||
private Integer stock;
|
|
||||||
|
|
||||||
}
|
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.bargain;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@ -20,6 +20,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
|
|||||||
default PageResult<BargainActivityDO> selectPage(BargainActivityPageReqVO reqVO) {
|
default PageResult<BargainActivityDO> selectPage(BargainActivityPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<BargainActivityDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<BargainActivityDO>()
|
||||||
.likeIfPresent(BargainActivityDO::getName, reqVO.getName())
|
.likeIfPresent(BargainActivityDO::getName, reqVO.getName())
|
||||||
|
.eqIfPresent(BargainActivityDO::getStatus, reqVO.getStatus())
|
||||||
.orderByDesc(BargainActivityDO::getId));
|
.orderByDesc(BargainActivityDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.dal.mysql.bargain;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 砍价商品 Mapper
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface BargainProductMapper extends BaseMapperX<BargainProductDO> {
|
|
||||||
|
|
||||||
default List<BargainProductDO> selectListByActivityIds(Collection<Long> ids) {
|
|
||||||
return selectList(BargainProductDO::getActivityId, ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -20,6 +20,7 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi
|
|||||||
default PageResult<CombinationActivityDO> selectPage(CombinationActivityPageReqVO reqVO) {
|
default PageResult<CombinationActivityDO> selectPage(CombinationActivityPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<CombinationActivityDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<CombinationActivityDO>()
|
||||||
.likeIfPresent(CombinationActivityDO::getName, reqVO.getName())
|
.likeIfPresent(CombinationActivityDO::getName, reqVO.getName())
|
||||||
|
.eqIfPresent(CombinationActivityDO::getStatus, reqVO.getStatus())
|
||||||
.orderByDesc(CombinationActivityDO::getId));
|
.orderByDesc(CombinationActivityDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,18 +20,20 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
|||||||
CombinationRecordDO::getOrderId, orderId);
|
CombinationRecordDO::getOrderId, orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @puhui999 selectByUserIdAndActivityId
|
default List<CombinationRecordDO> selectListByUserIdAndStatus(Long userId, Integer status) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||||
|
.eq(CombinationRecordDO::getUserId, userId)
|
||||||
|
.eq(CombinationRecordDO::getStatus, status));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 查询拼团记录
|
* 查询拼团记录
|
||||||
*
|
*
|
||||||
* @param headId 团长编号
|
* @param headId 团长编号
|
||||||
* @param activityId 活动编号
|
|
||||||
* @return 拼团记录
|
* @return 拼团记录
|
||||||
*/
|
*/
|
||||||
default CombinationRecordDO selectRecordByHeadId(Long headId, Long activityId, Integer status) {
|
default CombinationRecordDO selectOneByHeadId(Long headId, Integer status) {
|
||||||
return selectOne(new LambdaQueryWrapperX<CombinationRecordDO>()
|
return selectOne(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||||
.eq(CombinationRecordDO::getUserId, headId)
|
.eq(CombinationRecordDO::getId, headId)
|
||||||
.eq(CombinationRecordDO::getActivityId, activityId)
|
|
||||||
.eq(CombinationRecordDO::getStatus, status));
|
.eq(CombinationRecordDO::getStatus, status));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,4 +47,16 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
|||||||
return selectList(CombinationRecordDO::getStatus, status);
|
return selectList(CombinationRecordDO::getStatus, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询拼团记录
|
||||||
|
*
|
||||||
|
* @param userId 用户 id
|
||||||
|
* @param activityId 活动 id
|
||||||
|
* @return 拼团记录
|
||||||
|
*/
|
||||||
|
default List<CombinationRecordDO> selectListByUserIdAndActivityId(Long userId, Long activityId) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||||
|
.eq(CombinationRecordDO::getUserId, userId)
|
||||||
|
.eq(CombinationRecordDO::getActivityId, activityId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.service.bargain;
|
package cn.iocoder.yudao.module.promotion.service.bargain;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 砍价活动 Service 接口
|
* 砍价活动 Service 接口
|
||||||
@ -56,12 +53,5 @@ public interface BargainActivityService {
|
|||||||
*/
|
*/
|
||||||
PageResult<BargainActivityDO> getBargainActivityPage(BargainActivityPageReqVO pageReqVO);
|
PageResult<BargainActivityDO> getBargainActivityPage(BargainActivityPageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得砍价活动商品列表
|
|
||||||
*
|
|
||||||
* @param ids 砍价活动 ids
|
|
||||||
* @return 砍价活动的商品列表
|
|
||||||
*/
|
|
||||||
List<BargainProductDO> getBargainProductsByActivityIds(Collection<Long> ids);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,31 +10,25 @@ import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
|||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductCreateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.product.BargainProductUpdateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert;
|
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.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainProductDO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper;
|
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainProductMapper;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper;
|
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
|
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS;
|
||||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
|
||||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
import static cn.iocoder.yudao.module.promotion.util.PromotionUtils.validateProductSkuAllExists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 砍价活动 Service 实现类
|
* 砍价活动 Service 实现类
|
||||||
@ -50,38 +44,37 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord
|
|||||||
@Resource
|
@Resource
|
||||||
private BargainRecordMapper recordMapper;
|
private BargainRecordMapper recordMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BargainProductMapper bargainProductMapper;
|
|
||||||
@Resource
|
|
||||||
private ProductSpuApi productSpuApi;
|
private ProductSpuApi productSpuApi;
|
||||||
@Resource
|
@Resource
|
||||||
private ProductSkuApi productSkuApi;
|
private ProductSkuApi productSkuApi;
|
||||||
|
|
||||||
|
private static void validateSku(Long skuId, List<ProductSkuRespDTO> skus) {
|
||||||
|
// 校验商品 sku 是否存在
|
||||||
|
if (!CollectionUtils.convertSet(skus, ProductSkuRespDTO::getId).contains(skuId)) {
|
||||||
|
throw exception(SKU_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) {
|
public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) {
|
||||||
// 校验商品 SPU 是否存在是否参加的别的活动
|
// 校验商品 SPU 是否存在是否参加的别的活动
|
||||||
validateProductBargainConflict(createReqVO.getSpuId(), null);
|
validateBargainConflict(createReqVO.getSpuId(), null);
|
||||||
// 获取所选 spu下的所有 sku
|
// 获取所选 spu下的所有 sku
|
||||||
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(createReqVO.getSpuId()));
|
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(createReqVO.getSpuId()));
|
||||||
// 校验商品 sku 是否存在
|
validateSku(createReqVO.getSkuId(), skus);
|
||||||
validateProductSkuAllExists(skus, createReqVO.getProducts(), BargainProductCreateReqVO::getSkuId);
|
|
||||||
|
|
||||||
// 插入砍价活动
|
// 插入砍价活动
|
||||||
BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO);
|
BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO);
|
||||||
// TODO 营销相关属性初始化 砍价成功更新相关属性
|
// TODO 营销相关属性初始化 砍价成功更新相关属性
|
||||||
activityDO.setSuccessCount(0);
|
activityDO.setSuccessCount(0);
|
||||||
// 活动总库存
|
|
||||||
activityDO.setStock(getSumValue(createReqVO.getProducts(), BargainProductCreateReqVO::getStock, Integer::sum));
|
|
||||||
activityDO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
activityDO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
bargainActivityMapper.insert(activityDO);
|
bargainActivityMapper.insert(activityDO);
|
||||||
// 插入商品
|
|
||||||
List<BargainProductDO> productDOs = BargainActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activityDO);
|
|
||||||
bargainProductMapper.insertBatch(productDOs);
|
|
||||||
// 返回
|
// 返回
|
||||||
return activityDO.getId();
|
return activityDO.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateProductBargainConflict(Long spuId, Long activityId) {
|
private void validateBargainConflict(Long spuId, Long activityId) {
|
||||||
// 校验商品 spu 是否存在
|
// 校验商品 spu 是否存在
|
||||||
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(CollUtil.newArrayList(spuId));
|
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(CollUtil.newArrayList(spuId));
|
||||||
if (CollUtil.isEmpty(spuList)) {
|
if (CollUtil.isEmpty(spuList)) {
|
||||||
@ -109,52 +102,16 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord
|
|||||||
throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE);
|
throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE);
|
||||||
}
|
}
|
||||||
// 校验商品冲突
|
// 校验商品冲突
|
||||||
validateProductBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId());
|
validateBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId());
|
||||||
// 获取所选 spu下的所有 sku
|
// 获取所选 spu下的所有 sku
|
||||||
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(updateReqVO.getSpuId()));
|
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(updateReqVO.getSpuId()));
|
||||||
// 校验商品 sku 是否存在
|
// 校验商品 sku 是否存在
|
||||||
validateProductSkuAllExists(skus, updateReqVO.getProducts(), BargainProductUpdateReqVO::getSkuId);
|
validateSku(updateReqVO.getSkuId(), skus);
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO);
|
BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO);
|
||||||
// 更新活动库存
|
|
||||||
updateObj.setStock(getSumValue(updateReqVO.getProducts(), BargainProductUpdateReqVO::getStock, Integer::sum));
|
|
||||||
bargainActivityMapper.updateById(updateObj);
|
bargainActivityMapper.updateById(updateObj);
|
||||||
// 更新商品
|
|
||||||
updateBargainProduct(updateObj, updateReqVO.getProducts());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新砍价商品
|
|
||||||
*
|
|
||||||
* @param updateObj 更新的活动
|
|
||||||
* @param products 商品配置
|
|
||||||
*/
|
|
||||||
private void updateBargainProduct(BargainActivityDO updateObj, List<BargainProductUpdateReqVO> products) {
|
|
||||||
// 默认全部新增
|
|
||||||
List<BargainProductDO> defaultNewList = BargainActivityConvert.INSTANCE.convertList(products, updateObj);
|
|
||||||
// 数据库中的老数据
|
|
||||||
List<BargainProductDO> oldList = bargainProductMapper.selectListByActivityIds(CollUtil.newArrayList(updateObj.getId()));
|
|
||||||
List<List<BargainProductDO>> lists = CollectionUtils.diffList(oldList, defaultNewList, (oldVal, newVal) -> {
|
|
||||||
boolean same = ObjectUtil.equal(oldVal.getSkuId(), newVal.getSkuId());
|
|
||||||
if (same) {
|
|
||||||
newVal.setId(oldVal.getId());
|
|
||||||
}
|
|
||||||
return same;
|
|
||||||
});
|
|
||||||
|
|
||||||
// create
|
|
||||||
if (CollUtil.isNotEmpty(lists.get(0))) {
|
|
||||||
bargainProductMapper.insertBatch(lists.get(0));
|
|
||||||
}
|
|
||||||
// update
|
|
||||||
if (CollUtil.isNotEmpty(lists.get(1))) {
|
|
||||||
bargainProductMapper.updateBatch(lists.get(1));
|
|
||||||
}
|
|
||||||
// delete
|
|
||||||
if (CollUtil.isNotEmpty(lists.get(2))) {
|
|
||||||
bargainProductMapper.deleteBatchIds(CollectionUtils.convertList(lists.get(2), BargainProductDO::getId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -189,9 +146,4 @@ public class BargainServiceImpl implements BargainActivityService, BargainRecord
|
|||||||
return bargainActivityMapper.selectPage(pageReqVO);
|
return bargainActivityMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<BargainProductDO> getBargainProductsByActivityIds(Collection<Long> ids) {
|
|
||||||
return bargainProductMapper.selectListByActivityIds(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCr
|
|||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品活动记录 service
|
* 商品活动记录 service
|
||||||
*
|
*
|
||||||
@ -41,4 +43,23 @@ public interface CombinationRecordService {
|
|||||||
*/
|
*/
|
||||||
CombinationRecordDO getCombinationRecord(Long userId, Long orderId);
|
CombinationRecordDO getCombinationRecord(Long userId, Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取拼团记录
|
||||||
|
*
|
||||||
|
* @param userId 用户 id
|
||||||
|
* @param activityId 活动 id
|
||||||
|
* @return 拼团记录列表
|
||||||
|
*/
|
||||||
|
List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证组合限制数
|
||||||
|
* 校验是否满足限购要求
|
||||||
|
*
|
||||||
|
* @param count 本次购买数量
|
||||||
|
* @param sumCount 已购买数量合计
|
||||||
|
* @param activityId 活动编号
|
||||||
|
*/
|
||||||
|
void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -68,8 +69,6 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi
|
|||||||
// 校验商品 sku 是否存在
|
// 校验商品 sku 是否存在
|
||||||
validateProductSkuAllExists(skus, createReqVO.getProducts(), CombinationProductCreateReqVO::getSkuId);
|
validateProductSkuAllExists(skus, createReqVO.getProducts(), CombinationProductCreateReqVO::getSkuId);
|
||||||
|
|
||||||
// TODO 艿艿 有个小问题:现在有活动时间和限制时长,活动时间的结束时间早于设置的限制时间怎么算状态比如:
|
|
||||||
// 活动时间 2023-08-05 15:00:00 - 2023-08-05 15:20:00 限制时长 2小时,那么活动时间结束就结束还是加时到满两小时
|
|
||||||
// 插入拼团活动
|
// 插入拼团活动
|
||||||
CombinationActivityDO activityDO = CombinationActivityConvert.INSTANCE.convert(createReqVO);
|
CombinationActivityDO activityDO = CombinationActivityConvert.INSTANCE.convert(createReqVO);
|
||||||
// TODO 营销相关属性初始化 拼团成功更新相关属性
|
// TODO 营销相关属性初始化 拼团成功更新相关属性
|
||||||
@ -201,6 +200,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) {
|
public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) {
|
||||||
// 校验拼团是否存在
|
// 校验拼团是否存在
|
||||||
CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId());
|
CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId());
|
||||||
@ -244,6 +244,7 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||||
// 1.1 校验拼团活动
|
// 1.1 校验拼团活动
|
||||||
CombinationActivityDO activity = validateCombinationActivityExists(reqDTO.getActivityId());
|
CombinationActivityDO activity = validateCombinationActivityExists(reqDTO.getActivityId());
|
||||||
@ -252,9 +253,19 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi
|
|||||||
if (recordDO != null) {
|
if (recordDO != null) {
|
||||||
throw exception(COMBINATION_RECORD_EXISTS);
|
throw exception(COMBINATION_RECORD_EXISTS);
|
||||||
}
|
}
|
||||||
// 1.3 父拼团是否存在,是否已经满了
|
// 1.3 校验用户是否参加了其它拼团
|
||||||
|
List<CombinationRecordDO> recordDOList = recordMapper.selectListByUserIdAndStatus(reqDTO.getUserId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus());
|
||||||
|
if (CollUtil.isNotEmpty(recordDOList)) {
|
||||||
|
throw exception(COMBINATION_RECORD_FAILED_HAVE_JOINED);
|
||||||
|
}
|
||||||
|
// 1.4 校验当前活动是否过期
|
||||||
|
if (LocalDateTime.now().isAfter(activity.getEndTime())) {
|
||||||
|
throw exception(COMBINATION_RECORD_FAILED_TIME_END);
|
||||||
|
}
|
||||||
|
// 1.5 父拼团是否存在,是否已经满了
|
||||||
if (reqDTO.getHeadId() != null) {
|
if (reqDTO.getHeadId() != null) {
|
||||||
CombinationRecordDO recordDO1 = recordMapper.selectRecordByHeadId(reqDTO.getHeadId(), reqDTO.getActivityId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus());
|
// 查询进行中的父拼团
|
||||||
|
CombinationRecordDO recordDO1 = recordMapper.selectOneByHeadId(reqDTO.getHeadId(), CombinationRecordStatusEnum.IN_PROGRESS.getStatus());
|
||||||
if (recordDO1 == null) {
|
if (recordDO1 == null) {
|
||||||
throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS);
|
throw exception(COMBINATION_RECORD_HEAD_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
@ -263,7 +274,6 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi
|
|||||||
throw exception(COMBINATION_RECORD_USER_FULL);
|
throw exception(COMBINATION_RECORD_USER_FULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO @puhui999:应该还有一些校验,后续补噶;例如说,一个团,自己已经参与进去了,不能再参与进去;
|
|
||||||
|
|
||||||
// 2. 创建拼团记录
|
// 2. 创建拼团记录
|
||||||
CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO);
|
CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO);
|
||||||
@ -288,4 +298,22 @@ public class CombinationServiceImpl implements CombinationActivityService, Combi
|
|||||||
return recordMapper.selectListByStatus(status);
|
return recordMapper.selectListByStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CombinationRecordDO> getRecordListByUserIdAndActivityId(Long userId, Long activityId) {
|
||||||
|
return recordMapper.selectListByUserIdAndActivityId(userId, activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount) {
|
||||||
|
// 1.1 校验拼团活动
|
||||||
|
CombinationActivityDO activity = validateCombinationActivityExists(activityId);
|
||||||
|
// 校验是否达到限购总限购标准
|
||||||
|
if ((sumCount + count) > activity.getTotalLimitCount()) {
|
||||||
|
throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED);
|
||||||
|
}
|
||||||
|
// 单次购买是否达到限购标准
|
||||||
|
if (count > activity.getSingleLimitCount()) {
|
||||||
|
throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ public class SeckillConfigServiceImpl implements SeckillConfigService {
|
|||||||
seckillConfigMapper.updateById(updateObj);
|
seckillConfigMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @puhui999: 这个要不合并到更新操作里? 不单独有个操作咧; fix: 更新状态不用那么多必须的参数,更新的时候需要校验时间段
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSeckillConfigStatus(Long id, Integer status) {
|
public void updateSeckillConfigStatus(Long id, Integer status) {
|
||||||
// 校验秒杀时段是否存在
|
// 校验秒杀时段是否存在
|
||||||
|
@ -13,7 +13,6 @@ import org.springframework.context.annotation.Import;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||||
@ -152,19 +151,7 @@ public class CombinationActivityServiceImplTest extends BaseDbUnitTest {
|
|||||||
// 准备参数
|
// 准备参数
|
||||||
CombinationActivityPageReqVO reqVO = new CombinationActivityPageReqVO();
|
CombinationActivityPageReqVO reqVO = new CombinationActivityPageReqVO();
|
||||||
reqVO.setName(null);
|
reqVO.setName(null);
|
||||||
reqVO.setSpuId(null);
|
|
||||||
reqVO.setTotalLimitCount(null);
|
|
||||||
reqVO.setSingleLimitCount(null);
|
|
||||||
reqVO.setStartTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
|
||||||
reqVO.setEndTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
|
||||||
reqVO.setUserSize(null);
|
|
||||||
reqVO.setTotalNum(null);
|
|
||||||
reqVO.setSuccessNum(null);
|
|
||||||
reqVO.setOrderUserCount(null);
|
|
||||||
reqVO.setVirtualGroup(null);
|
|
||||||
reqVO.setStatus(null);
|
reqVO.setStatus(null);
|
||||||
reqVO.setLimitDuration(null);
|
|
||||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
PageResult<CombinationActivityDO> pageResult = combinationActivityService.getCombinationActivityPage(reqVO);
|
PageResult<CombinationActivityDO> pageResult = combinationActivityService.getCombinationActivityPage(reqVO);
|
||||||
|
@ -31,10 +31,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode ORDER_COMMENT_STATUS_NOT_FALSE = new ErrorCode(1011000020, "创建交易订单项的评价失败,订单已评价");
|
ErrorCode ORDER_COMMENT_STATUS_NOT_FALSE = new ErrorCode(1011000020, "创建交易订单项的评价失败,订单已评价");
|
||||||
ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1011000021, "交易订单发货失败,订单已退款或部分退款");
|
ErrorCode ORDER_DELIVERY_FAIL_REFUND_STATUS_NOT_NONE = new ErrorCode(1011000021, "交易订单发货失败,订单已退款或部分退款");
|
||||||
ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000022, "交易订单发货失败,拼团未成功");
|
ErrorCode ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000022, "交易订单发货失败,拼团未成功");
|
||||||
// TODO 已移除订单单独发货
|
ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000023, "交易订单发货失败,砍价未成功");
|
||||||
ErrorCode ORDER_DELIVERY_FAILED_ITEMS_NOT_EMPTY = new ErrorCode(1011000023, "订单发货失败,请选择发货商品");
|
|
||||||
ErrorCode ORDER_DELIVERY_FAILED_ITEM_NOT_EXISTS = new ErrorCode(1011000024, "订单发货失败,所选发货商品不存在");
|
|
||||||
ErrorCode ORDER_DELIVERY_FAILED_ITEM_ALREADY_DELIVERY = new ErrorCode(1011000025, "订单发货失败,所选商品已发货");
|
|
||||||
|
|
||||||
// ========== After Sale 模块 1011000100 ==========
|
// ========== After Sale 模块 1011000100 ==========
|
||||||
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在");
|
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在");
|
||||||
|
@ -29,7 +29,5 @@ public class TradeOrderDeliveryReqVO {
|
|||||||
@NotEmpty(message = "发货物流单号不能为空")
|
@NotEmpty(message = "发货物流单号不能为空")
|
||||||
private String logisticsNo;
|
private String logisticsNo;
|
||||||
|
|
||||||
// =============== 同城配送 ================
|
|
||||||
// TODO
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,7 @@ public class AppTradeOrderController {
|
|||||||
@Operation(summary = "确认交易订单收货")
|
@Operation(summary = "确认交易订单收货")
|
||||||
@Parameter(name = "id", description = "交易订单编号")
|
@Parameter(name = "id", description = "交易订单编号")
|
||||||
public CommonResult<Boolean> takeOrder(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> takeOrder(@RequestParam("id") Long id) {
|
||||||
// TODO @芋艿:未实现,mock 用
|
return success(tradeOrderService.receiveOrder(getLoginUserId(), id));
|
||||||
return success(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/cancel")
|
@DeleteMapping("/cancel")
|
||||||
|
@ -25,6 +25,12 @@ public interface TradeOrderItemMapper extends BaseMapperX<TradeOrderItemDO> {
|
|||||||
return selectList(TradeOrderItemDO::getOrderId, orderIds);
|
return selectList(TradeOrderItemDO::getOrderId, orderIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<TradeOrderItemDO> selectListByOrderIdAnSkuId(Collection<Long> orderIds, Collection<Long> skuIds) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<TradeOrderItemDO>()
|
||||||
|
.in(TradeOrderItemDO::getOrderId, orderIds)
|
||||||
|
.eq(TradeOrderItemDO::getSkuId, skuIds));
|
||||||
|
}
|
||||||
|
|
||||||
default TradeOrderItemDO selectOrderItemByIdAndUserId(Long orderItemId, Long loginUserId) {
|
default TradeOrderItemDO selectOrderItemByIdAndUserId(Long orderItemId, Long loginUserId) {
|
||||||
return selectOne(new LambdaQueryWrapperX<TradeOrderItemDO>()
|
return selectOne(new LambdaQueryWrapperX<TradeOrderItemDO>()
|
||||||
.eq(TradeOrderItemDO::getId, orderItemId)
|
.eq(TradeOrderItemDO::getId, orderItemId)
|
||||||
|
@ -66,8 +66,9 @@ public interface TradeOrderService {
|
|||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param id 订单编号
|
* @param id 订单编号
|
||||||
|
* @return 成功/失败
|
||||||
*/
|
*/
|
||||||
void receiveOrder(Long userId, Long id);
|
Boolean receiveOrder(Long userId, Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得指定编号的交易订单
|
* 获得指定编号的交易订单
|
||||||
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.core.KeyValue;
|
|||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
import cn.iocoder.yudao.module.member.api.address.AddressApi;
|
import cn.iocoder.yudao.module.member.api.address.AddressApi;
|
||||||
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
||||||
@ -22,7 +23,9 @@ import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi;
|
|||||||
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
|
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
|
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi;
|
import cn.iocoder.yudao.module.promotion.api.combination.CombinationRecordApi;
|
||||||
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi;
|
import cn.iocoder.yudao.module.promotion.api.coupon.CouponApi;
|
||||||
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
|
import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponUseReqDTO;
|
||||||
@ -108,6 +111,9 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CombinationRecordApi combinationRecordApi;
|
private CombinationRecordApi combinationRecordApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BargainRecordApi bargainRecordApi;
|
||||||
|
|
||||||
// =================== Order ===================
|
// =================== Order ===================
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -173,8 +179,18 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|||||||
// 拼团
|
// 拼团
|
||||||
if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
||||||
MemberUserRespDTO user = memberUserApi.getUser(userId);
|
MemberUserRespDTO user = memberUserApi.getUser(userId);
|
||||||
|
List<CombinationRecordRespDTO> recordRespDTOS = combinationRecordApi.getRecordListByUserIdAndActivityId(userId, createReqVO.getCombinationActivityId());
|
||||||
// TODO 拼团一次应该只能选择一种规格的商品
|
// TODO 拼团一次应该只能选择一种规格的商品
|
||||||
combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItems.get(0), createReqVO, user));
|
TradeOrderItemDO orderItemDO = orderItems.get(0);
|
||||||
|
if (CollUtil.isNotEmpty(recordRespDTOS)) {
|
||||||
|
List<Long> skuIds = convertList(recordRespDTOS, CombinationRecordRespDTO::getSkuId, item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus()));
|
||||||
|
List<TradeOrderItemDO> tradeOrderItemDOS = tradeOrderItemMapper.selectListByOrderIdAnSkuId(convertList(recordRespDTOS,
|
||||||
|
CombinationRecordRespDTO::getOrderId, item -> ObjectUtil.equals(item.getStatus(), CombinationRecordStatusEnum.SUCCESS.getStatus())), skuIds);
|
||||||
|
combinationRecordApi.validateCombinationLimitCount(createReqVO.getCombinationActivityId(),
|
||||||
|
CollectionUtils.getSumValue(tradeOrderItemDOS, TradeOrderItemDO::getCount, Integer::sum), orderItemDO.getCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
combinationRecordApi.createRecord(TradeOrderConvert.INSTANCE.convert(order, orderItemDO, createReqVO, user));
|
||||||
}
|
}
|
||||||
// TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除
|
// TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除
|
||||||
if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) {
|
if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) {
|
||||||
@ -382,33 +398,23 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|||||||
public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) {
|
public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) {
|
||||||
// 1.1 校验并获得交易订单(可发货)
|
// 1.1 校验并获得交易订单(可发货)
|
||||||
TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
|
TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
|
||||||
|
|
||||||
/* TODO
|
|
||||||
* fix: 首先需要店铺设置配送方式如: 自提 、配送、物流-配送、物流-配送-自提、商家配送
|
|
||||||
* 1.如果店铺有设置配送方式用户只填写收货地址的情况下店家后台自己选择配送方式
|
|
||||||
* 2.如果店铺只支持到店自提那么下单后默认发货不需要物流
|
|
||||||
* 3.如果店铺支持 物流-配送-自提 的情况下后台不需要选择配送方式按前端用户选择的配送方式发货即可
|
|
||||||
*/
|
|
||||||
TradeOrderDO updateOrderObj = new TradeOrderDO();
|
TradeOrderDO updateOrderObj = new TradeOrderDO();
|
||||||
// 判断发货类型
|
// 判断发货类型
|
||||||
// 2.1 快递发货
|
// 2.1 快递发货
|
||||||
if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) {
|
if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.EXPRESS.getMode())) {
|
||||||
// 校验快递公司
|
// 校验快递公司
|
||||||
validateDeliveryExpress(deliveryReqVO);
|
DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId());
|
||||||
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo());
|
if (deliveryExpress == null) {
|
||||||
|
throw exception(EXPRESS_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
// 2.2 用户自提
|
if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
|
||||||
if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.PICK_UP.getMode())) {
|
throw exception(EXPRESS_STATUS_NOT_ENABLE);
|
||||||
// TODO 校验自提门店是否存在
|
|
||||||
// 重置一下确保快递公司和快递单号为空
|
|
||||||
updateOrderObj.setLogisticsId(null).setLogisticsNo("");
|
|
||||||
}
|
}
|
||||||
// 2.3 TODO 芋艿:如果无需发货,需要怎么存储?回复:需要把 deliverType 设置为 DeliveryTypeEnum.NULL
|
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode());
|
||||||
|
}
|
||||||
|
// 2.2 无需发货
|
||||||
if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) {
|
if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) {
|
||||||
// TODO 情况一:正常走发货逻辑和用户自提有点像 不同点:不需要自提门店只需要用户确认收货
|
updateOrderObj.setLogisticsId(null).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode());
|
||||||
// TODO 情况二:用户下单付款后直接确认收货或等待用户确认收货
|
|
||||||
// 重置一下确保快递公司和快递单号为空
|
|
||||||
updateOrderObj.setLogisticsId(null).setLogisticsNo("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新 TradeOrderDO 状态为已发货,等待收货
|
// 更新 TradeOrderDO 状态为已发货,等待收货
|
||||||
@ -428,16 +434,6 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|||||||
// TODO 设计:lili:是不是发货后,才支持售后?
|
// TODO 设计:lili:是不是发货后,才支持售后?
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateDeliveryExpress(TradeOrderDeliveryReqVO deliveryReqVO) {
|
|
||||||
DeliveryExpressDO deliveryExpress = deliveryExpressService.getDeliveryExpress(deliveryReqVO.getLogisticsId());
|
|
||||||
if (deliveryExpress == null) {
|
|
||||||
throw exception(EXPRESS_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
if (deliveryExpress.getStatus().equals(CommonStatusEnum.DISABLE.getStatus())) {
|
|
||||||
throw exception(EXPRESS_STATUS_NOT_ENABLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验交易订单满足被发货的条件
|
* 校验交易订单满足被发货的条件
|
||||||
*
|
*
|
||||||
@ -464,17 +460,23 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|||||||
// 订单类型:拼团
|
// 订单类型:拼团
|
||||||
if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
||||||
// 校验订单拼团是否成功
|
// 校验订单拼团是否成功
|
||||||
if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) {
|
if (combinationRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) {
|
||||||
throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS);
|
throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO puhui999: 校验订单砍价是否成功
|
// 订单类类型:砍价
|
||||||
|
if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) {
|
||||||
|
// 校验订单砍价是否成功
|
||||||
|
if (bargainRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) {
|
||||||
|
throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void receiveOrder(Long userId, Long id) {
|
public Boolean receiveOrder(Long userId, Long id) {
|
||||||
// 校验并获得交易订单(可收货)
|
// 校验并获得交易订单(可收货)
|
||||||
TradeOrderDO order = validateOrderReceivable(userId, id);
|
TradeOrderDO order = validateOrderReceivable(userId, id);
|
||||||
|
|
||||||
@ -490,6 +492,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
|||||||
// TODO 芋艿:lili 发送订单变化的消息
|
// TODO 芋艿:lili 发送订单变化的消息
|
||||||
|
|
||||||
// TODO 芋艿:lili 发送商品被购买完成的数据
|
// TODO 芋艿:lili 发送商品被购买完成的数据
|
||||||
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user