mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
订单:
1. review 发货 2. review 拼团逻辑
This commit is contained in:
parent
60171ce7e4
commit
159c74ce15
@ -18,7 +18,7 @@ public interface BargainRecordApi {
|
||||
*
|
||||
* @param reqDTO 请求 DTO
|
||||
*/
|
||||
void createRecord(@Valid BargainRecordCreateReqDTO reqDTO);
|
||||
void createBargainRecord(@Valid BargainRecordCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 查询砍价是否成功
|
||||
@ -27,6 +27,6 @@ public interface BargainRecordApi {
|
||||
* @param orderId 订单编号
|
||||
* @return 砍价是否成功
|
||||
*/
|
||||
boolean validateRecordSuccess(Long userId, Long orderId);
|
||||
boolean isBargainRecordSuccess(Long userId, Long orderId);
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public interface CombinationRecordApi {
|
||||
*
|
||||
* @param reqDTO 请求 DTO
|
||||
*/
|
||||
void createRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
|
||||
void createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 查询拼团记录是否成功
|
||||
@ -30,7 +30,7 @@ public interface CombinationRecordApi {
|
||||
* @param orderId 订单编号
|
||||
* @return 拼团是否成功
|
||||
*/
|
||||
boolean validateRecordSuccess(Long userId, Long orderId);
|
||||
boolean isCombinationRecordSuccess(Long userId, Long orderId);
|
||||
|
||||
/**
|
||||
* 获取拼团记录
|
||||
|
@ -1,9 +1,8 @@
|
||||
package cn.iocoder.yudao.module.promotion.api.combination.dto;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 拼团记录 Response DTO
|
||||
*
|
||||
@ -15,32 +14,28 @@ public class CombinationRecordRespDTO {
|
||||
/**
|
||||
* 拼团活动编号
|
||||
*/
|
||||
@NotNull(message = "拼团活动编号不能为空")
|
||||
private Long activityId;
|
||||
/**
|
||||
* spu 编号
|
||||
* SPU 编号
|
||||
*/
|
||||
@NotNull(message = "spu 编号不能为空")
|
||||
private Long spuId;
|
||||
/**
|
||||
* sku 编号
|
||||
* SKU 编号
|
||||
*/
|
||||
@NotNull(message = "sku 编号不能为空")
|
||||
private Long skuId;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
@NotNull(message = "订单编号不能为空")
|
||||
private Long orderId;
|
||||
/**
|
||||
* 开团状态:正在开团 拼团成功 拼团失败
|
||||
* 开团状态
|
||||
*
|
||||
* 枚举 {@link CombinationRecordStatusEnum}
|
||||
*/
|
||||
@NotNull(message = "开团状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -62,22 +62,26 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013010002, "拼团活动已关闭不能修改");
|
||||
ErrorCode COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013010003, "拼团活动未关闭或未结束,不能删除");
|
||||
ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013010004, "拼团不存在");
|
||||
ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013010005, "拼团失败,已参与过该拼团");
|
||||
ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = 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 ==========
|
||||
ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013011000, "砍价活动不存在");
|
||||
ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013011001, "存在商品参加了其它砍价活动");
|
||||
ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013011002, "砍价活动已关闭不能修改");
|
||||
ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013011003, "砍价活动未关闭或未结束,不能删除");
|
||||
ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013011004, "砍价记录不存在");
|
||||
ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013011005, "砍价失败,已参与过该砍价");
|
||||
ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011006, "砍价失败,父砍价不存在");
|
||||
ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013011007, "砍价失败,砍价人数已满");
|
||||
// ========== 拼团记录 1013011000 ==========
|
||||
ErrorCode COMBINATION_RECORD_EXISTS = new ErrorCode(1013011000, "拼团失败,已参与过该拼团");
|
||||
ErrorCode COMBINATION_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013011001, "拼团失败,父拼团不存在");
|
||||
ErrorCode COMBINATION_RECORD_USER_FULL = new ErrorCode(1013011002, "拼团失败,拼团人数已满");
|
||||
ErrorCode COMBINATION_RECORD_FAILED_HAVE_JOINED = new ErrorCode(1013011003, "拼团失败,已参与其它拼团");
|
||||
ErrorCode COMBINATION_RECORD_FAILED_TIME_END = new ErrorCode(1013011004, "拼团失败,活动已经结束");
|
||||
ErrorCode COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED = new ErrorCode(1013011005, "拼团失败,单次限购超出");
|
||||
ErrorCode COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED = new ErrorCode(1013011006, "拼团失败,单次限购超出");
|
||||
|
||||
// ========== 砍价活动 1013012000 ==========
|
||||
ErrorCode BARGAIN_ACTIVITY_NOT_EXISTS = new ErrorCode(1013012000, "砍价活动不存在");
|
||||
ErrorCode BARGAIN_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013012001, "存在商品参加了其它砍价活动");
|
||||
ErrorCode BARGAIN_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013012002, "砍价活动已关闭不能修改");
|
||||
ErrorCode BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013012003, "砍价活动未关闭或未结束,不能删除");
|
||||
|
||||
// ========== 砍价记录 1013013000 ==========
|
||||
ErrorCode BARGAIN_RECORD_NOT_EXISTS = new ErrorCode(1013013000, "砍价记录不存在");
|
||||
ErrorCode BARGAIN_RECORD_EXISTS = new ErrorCode(1013013001, "砍价失败,已参与过该砍价");
|
||||
ErrorCode BARGAIN_RECORD_HEAD_NOT_EXISTS = new ErrorCode(1013013002, "砍价失败,父砍价不存在");
|
||||
ErrorCode BARGAIN_RECORD_USER_FULL = new ErrorCode(1013013003, "砍价失败,砍价人数已满");
|
||||
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ import org.springframework.stereotype.Service;
|
||||
public class BargainRecordApiImpl implements BargainRecordApi {
|
||||
|
||||
@Override
|
||||
public void createRecord(BargainRecordCreateReqDTO reqDTO) {
|
||||
public void createBargainRecord(BargainRecordCreateReqDTO reqDTO) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateRecordSuccess(Long userId, Long orderId) {
|
||||
public boolean isBargainRecordSuccess(Long userId, Long orderId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,12 @@ public class CombinationRecordApiImpl implements CombinationRecordApi {
|
||||
private CombinationRecordService recordService;
|
||||
|
||||
@Override
|
||||
public void createRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
recordService.createCombinationRecord(reqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateRecordSuccess(Long userId, Long orderId) {
|
||||
public boolean isCombinationRecordSuccess(Long userId, Long orderId) {
|
||||
return CombinationRecordStatusEnum.isSuccess(recordService.getCombinationRecord(userId, orderId).getStatus());
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.bargain;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
||||
@ -32,13 +31,10 @@ public class BargainActivityController {
|
||||
@Resource
|
||||
private BargainActivityService activityService;
|
||||
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建砍价活动")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:bargain-activity:create')")
|
||||
public CommonResult<Long> createBargainActivity(@Valid @RequestBody BargainActivityBaseVO createReqVO) {
|
||||
public CommonResult<Long> createBargainActivity(@Valid @RequestBody BargainActivityCreateReqVO createReqVO) {
|
||||
return success(activityService.createBargainActivity(createReqVO));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
|
||||
|
||||
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 BargainActivityCreateReqVO extends BargainActivityBaseVO {
|
||||
|
||||
}
|
@ -15,7 +15,7 @@ public class BargainActivityPageReqVO extends PageParam {
|
||||
@Schema(description = "砍价名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "活动状态:0开启 1关闭", example = "0")
|
||||
@Schema(description = "活动状态", example = "0")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ public interface CombinationActivityConvert {
|
||||
|
||||
CombinationProductRespVO convert(CombinationProductDO bean);
|
||||
|
||||
default CombinationActivityRespVO convert(CombinationActivityDO bean, List<CombinationProductDO> productDOs) {
|
||||
return convert(bean).setProducts(convertList2(productDOs));
|
||||
default CombinationActivityRespVO convert(CombinationActivityDO activity, List<CombinationProductDO> products) {
|
||||
return convert(activity).setProducts(convertList2(products));
|
||||
}
|
||||
|
||||
List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list);
|
||||
|
@ -40,24 +40,24 @@ public interface SeckillActivityConvert {
|
||||
|
||||
PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page);
|
||||
|
||||
default PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page, List<SeckillProductDO> seckillProducts, List<ProductSpuRespDTO> spuList) {
|
||||
Map<Long, ProductSpuRespDTO> spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId);
|
||||
default PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page,
|
||||
List<SeckillProductDO> seckillProducts,
|
||||
List<ProductSpuRespDTO> spuList) {
|
||||
PageResult<SeckillActivityRespVO> pageResult = convertPage(page);
|
||||
// 拼接商品
|
||||
Map<Long, ProductSpuRespDTO> spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId);
|
||||
pageResult.getList().forEach(item -> {
|
||||
MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> {
|
||||
item.setSpuName(spu.getName());
|
||||
item.setPicUrl(spu.getPicUrl());
|
||||
});
|
||||
|
||||
item.setProducts(convertList2(seckillProducts));
|
||||
MapUtils.findAndThen(spuMap, item.getSpuId(),
|
||||
spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()));
|
||||
});
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
SeckillActivityDetailRespVO convert1(SeckillActivityDO seckillActivity);
|
||||
SeckillActivityDetailRespVO convert1(SeckillActivityDO activity);
|
||||
|
||||
default SeckillActivityDetailRespVO convert(SeckillActivityDO seckillActivity, List<SeckillProductDO> seckillProducts) {
|
||||
return convert1(seckillActivity).setProducts(convertList2(seckillProducts));
|
||||
default SeckillActivityDetailRespVO convert(SeckillActivityDO activity, List<SeckillProductDO> products) {
|
||||
return convert1(activity).setProducts(convertList2(products));
|
||||
}
|
||||
|
||||
@Mappings({
|
||||
@ -77,6 +77,6 @@ public interface SeckillActivityConvert {
|
||||
return CollectionUtils.convertList(products, item -> convert(activity, item).setActivityStatus(activity.getStatus()));
|
||||
}
|
||||
|
||||
List<SeckillProductRespVO> convertList2(List<SeckillProductDO> productDOs);
|
||||
List<SeckillProductRespVO> convertList2(List<SeckillProductDO> list);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.bargain;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -38,7 +39,6 @@ public class BargainActivityDO extends BaseDO {
|
||||
* 活动开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 活动结束时间
|
||||
*/
|
||||
@ -46,6 +46,8 @@ public class BargainActivityDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 活动状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
@ -65,11 +67,15 @@ public class BargainActivityDO extends BaseDO {
|
||||
* 砍价底价,单位:分
|
||||
*/
|
||||
private Integer bargainPrice;
|
||||
/**
|
||||
* 砍价活动库存
|
||||
*/
|
||||
private Integer stock;
|
||||
|
||||
/**
|
||||
* 达到该人数,才能砍到低价
|
||||
*/
|
||||
private Integer userSize;
|
||||
|
||||
/**
|
||||
* 最大帮砍次数
|
||||
*/
|
||||
@ -79,22 +85,14 @@ public class BargainActivityDO extends BaseDO {
|
||||
* 总限购数量
|
||||
*/
|
||||
private Integer totalLimitCount;
|
||||
|
||||
/**
|
||||
* 砍价活动库存
|
||||
*/
|
||||
private Integer stock;
|
||||
|
||||
/**
|
||||
* 用户每次砍价的最小金额,单位:分
|
||||
*/
|
||||
private Integer randomMinPrice;
|
||||
|
||||
/**
|
||||
* 用户每次砍价的最大金额,单位:分
|
||||
*/
|
||||
private Integer randomMaxPrice;
|
||||
|
||||
/**
|
||||
* 砍价成功数量
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.bargain;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
@ -21,7 +21,7 @@ public interface BargainActivityService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createBargainActivity(@Valid BargainActivityBaseVO createReqVO);
|
||||
Long createBargainActivity(@Valid BargainActivityCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新砍价活动
|
||||
|
@ -1,22 +1,16 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.bargain;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
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.spu.ProductSpuApi;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
|
||||
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.dal.dataobject.bargain.BargainActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainRecordMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -27,7 +21,6 @@ import java.util.List;
|
||||
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.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.promotion.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@ -39,62 +32,27 @@ import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
@Validated
|
||||
public class BargainActivityServiceImpl implements BargainActivityService {
|
||||
|
||||
|
||||
@Resource
|
||||
private BargainActivityMapper bargainActivityMapper;
|
||||
@Resource
|
||||
private BargainRecordMapper recordMapper;
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
|
||||
@Resource
|
||||
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
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createBargainActivity(BargainActivityBaseVO createReqVO) {
|
||||
public Long createBargainActivity(BargainActivityCreateReqVO createReqVO) {
|
||||
// 校验商品 SPU 是否存在是否参加的别的活动
|
||||
validateBargainConflict(createReqVO.getSpuId(), null);
|
||||
// 获取所选 spu下的所有 sku
|
||||
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(createReqVO.getSpuId()));
|
||||
validateSku(createReqVO.getSkuId(), skus);
|
||||
// 校验商品 sku 是否存在
|
||||
validateSku(createReqVO.getSkuId());
|
||||
|
||||
// 插入砍价活动
|
||||
BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO);
|
||||
// TODO 营销相关属性初始化 砍价成功更新相关属性
|
||||
activityDO.setSuccessCount(0);
|
||||
activityDO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
BargainActivityDO activityDO = BargainActivityConvert.INSTANCE.convert(createReqVO)
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus()).setSuccessCount(0);
|
||||
bargainActivityMapper.insert(activityDO);
|
||||
// 返回
|
||||
return activityDO.getId();
|
||||
}
|
||||
|
||||
private void validateBargainConflict(Long spuId, Long activityId) {
|
||||
// 校验商品 spu 是否存在
|
||||
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(CollUtil.newArrayList(spuId));
|
||||
if (CollUtil.isEmpty(spuList)) {
|
||||
throw exception(SPU_NOT_EXISTS);
|
||||
}
|
||||
// 查询所有开启的砍价活动
|
||||
List<BargainActivityDO> activityDOs = bargainActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
// 更新时排除自己
|
||||
if (activityId != null) {
|
||||
activityDOs.removeIf(item -> ObjectUtil.equal(item.getId(), activityId));
|
||||
}
|
||||
// 校验商品 spu 是否参加了其它活动
|
||||
if (anyMatch(activityDOs, s -> ObjectUtil.equal(s.getId(), spuId))) {
|
||||
throw exception(BARGAIN_ACTIVITY_SPU_CONFLICTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateBargainActivity(BargainActivityUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
BargainActivityDO activityDO = validateBargainActivityExists(updateReqVO.getId());
|
||||
@ -104,15 +62,31 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
||||
}
|
||||
// 校验商品冲突
|
||||
validateBargainConflict(updateReqVO.getSpuId(), updateReqVO.getId());
|
||||
// 获取所选 spu下的所有 sku
|
||||
List<ProductSkuRespDTO> skus = productSkuApi.getSkuListBySpuId(CollectionUtil.newArrayList(updateReqVO.getSpuId()));
|
||||
// 校验商品 sku 是否存在
|
||||
validateSku(updateReqVO.getSkuId(), skus);
|
||||
validateSku(updateReqVO.getSkuId());
|
||||
|
||||
// 更新
|
||||
BargainActivityDO updateObj = BargainActivityConvert.INSTANCE.convert(updateReqVO);
|
||||
bargainActivityMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
private void validateBargainConflict(Long spuId, Long activityId) {
|
||||
// 查询所有开启的砍价活动
|
||||
List<BargainActivityDO> activityList = bargainActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
if (activityId != null) { // 更新时排除自己
|
||||
activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId));
|
||||
}
|
||||
// 校验商品 spu 是否参加了其它活动
|
||||
if (anyMatch(activityList, activity -> ObjectUtil.equal(activity.getSpuId(), spuId))) {
|
||||
throw exception(BARGAIN_ACTIVITY_SPU_CONFLICTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateSku(Long skuId) {
|
||||
ProductSkuRespDTO sku = productSkuApi.getSku(skuId);
|
||||
if (sku == null) {
|
||||
throw exception(SKU_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -139,7 +113,7 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
||||
|
||||
@Override
|
||||
public BargainActivityDO getBargainActivity(Long id) {
|
||||
return validateBargainActivityExists(id);
|
||||
return bargainActivityMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,6 +16,7 @@ public class TradeOrderDeliveryReqVO {
|
||||
@NotNull(message = "订单编号不能为空")
|
||||
private Long id;
|
||||
|
||||
// TODO @puhui999:可以去掉 type;如果无需发货,则 logisticsId 传递 0;logisticsNo 传递空串
|
||||
@Schema(description = "发货类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@InEnum(DeliveryTypeEnum.class)
|
||||
@NotNull(message = "发货类型不能为空")
|
||||
@ -29,5 +30,4 @@ public class TradeOrderDeliveryReqVO {
|
||||
@NotEmpty(message = "发货物流单号不能为空")
|
||||
private String logisticsNo;
|
||||
|
||||
|
||||
}
|
||||
|
@ -150,7 +150,8 @@ public class AppTradeOrderController {
|
||||
@Operation(summary = "确认交易订单收货")
|
||||
@Parameter(name = "id", description = "交易订单编号")
|
||||
public CommonResult<Boolean> takeOrder(@RequestParam("id") Long id) {
|
||||
return success(tradeOrderService.receiveOrder(getLoginUserId(), id));
|
||||
tradeOrderService.receiveOrder(getLoginUserId(), id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/cancel")
|
||||
|
@ -66,9 +66,8 @@ public interface TradeOrderService {
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param id 订单编号
|
||||
* @return 成功/失败
|
||||
*/
|
||||
Boolean receiveOrder(Long userId, Long id);
|
||||
void receiveOrder(Long userId, Long id);
|
||||
|
||||
/**
|
||||
* 获得指定编号的交易订单
|
||||
|
@ -190,7 +190,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
CollectionUtils.getSumValue(tradeOrderItemDOS, TradeOrderItemDO::getCount, Integer::sum), orderItemDO.getCount());
|
||||
}
|
||||
|
||||
combinationRecordApi.createRecord(TradeOrderConvert.INSTANCE.convert(order, orderItemDO, createReqVO, user));
|
||||
combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItemDO, createReqVO, user));
|
||||
}
|
||||
// TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除
|
||||
if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) {
|
||||
@ -392,10 +392,10 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
return new KeyValue<>(order, payOrder);
|
||||
}
|
||||
|
||||
// TODO @芋艿:后续在 review 下发货逻辑
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deliveryOrder(Long userId, TradeOrderDeliveryReqVO deliveryReqVO) {
|
||||
// TODO @puhui999:只有选择快递的,才可以发货
|
||||
// 1.1 校验并获得交易订单(可发货)
|
||||
TradeOrderDO order = validateOrderDeliverable(deliveryReqVO.getId());
|
||||
TradeOrderDO updateOrderObj = new TradeOrderDO();
|
||||
@ -412,6 +412,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
}
|
||||
updateOrderObj.setLogisticsId(deliveryReqVO.getLogisticsId()).setLogisticsNo(deliveryReqVO.getLogisticsNo()).setDeliveryType(DeliveryTypeEnum.EXPRESS.getMode());
|
||||
}
|
||||
// TODO @puhui999:无需发货时,更新 logisticsId 为 0;
|
||||
// 2.2 无需发货
|
||||
if (Objects.equals(deliveryReqVO.getType(), DeliveryTypeEnum.NULL.getMode())) {
|
||||
updateOrderObj.setLogisticsId(null).setLogisticsNo("").setDeliveryType(DeliveryTypeEnum.NULL.getMode());
|
||||
@ -458,14 +459,14 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
// 订单类型:拼团
|
||||
if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
||||
// 校验订单拼团是否成功
|
||||
if (combinationRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) {
|
||||
if (combinationRecordApi.isCombinationRecordSuccess(order.getUserId(), order.getId())) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_COMBINATION_RECORD_STATUS_NOT_SUCCESS);
|
||||
}
|
||||
}
|
||||
// 订单类类型:砍价
|
||||
if (Objects.equals(TradeOrderTypeEnum.BARGAIN.getType(), order.getType())) {
|
||||
// 校验订单砍价是否成功
|
||||
if (bargainRecordApi.validateRecordSuccess(order.getUserId(), order.getId())) {
|
||||
if (bargainRecordApi.isBargainRecordSuccess(order.getUserId(), order.getId())) {
|
||||
throw exception(ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS);
|
||||
}
|
||||
}
|
||||
@ -474,7 +475,7 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean receiveOrder(Long userId, Long id) {
|
||||
public void receiveOrder(Long userId, Long id) {
|
||||
// 校验并获得交易订单(可收货)
|
||||
TradeOrderDO order = validateOrderReceivable(userId, id);
|
||||
|
||||
@ -489,7 +490,6 @@ public class TradeOrderServiceImpl implements TradeOrderService {
|
||||
// TODO 芋艿:lili 发送订单变化的消息
|
||||
|
||||
// TODO 芋艿:lili 发送商品被购买完成的数据
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user