mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
订单中心+营销活动:完善部分 TODO 提到的问题
This commit is contained in:
parent
c25bf38f50
commit
2591ab5d36
@ -68,6 +68,14 @@ public class CommonResult<T> implements Serializable {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> CommonResult<T> success(T data, String msg) {
|
||||||
|
CommonResult<T> result = new CommonResult<>();
|
||||||
|
result.code = GlobalErrorCodeConstants.SUCCESS.getCode();
|
||||||
|
result.data = data;
|
||||||
|
result.msg = msg;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSuccess(Integer code) {
|
public static boolean isSuccess(Integer code) {
|
||||||
return Objects.equals(code, GlobalErrorCodeConstants.SUCCESS.getCode());
|
return Objects.equals(code, GlobalErrorCodeConstants.SUCCESS.getCode());
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.promotion.api.bargain.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
// TODO @芋艿:这块要在看看
|
// TODO @芋艿:这块要在看看
|
||||||
@ -40,17 +39,7 @@ public class BargainRecordCreateReqDTO {
|
|||||||
*/
|
*/
|
||||||
@NotNull(message = "订单编号不能为空")
|
@NotNull(message = "订单编号不能为空")
|
||||||
private Long orderId;
|
private Long orderId;
|
||||||
// TODO @puhui999:spuName、picUrl、 之类字段不用传递;
|
|
||||||
/**
|
|
||||||
* 商品名字
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "商品名字不能为空")
|
|
||||||
private String spuName;
|
|
||||||
/**
|
|
||||||
* 商品图片
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "商品图片不能为空")
|
|
||||||
private String picUrl;
|
|
||||||
/**
|
/**
|
||||||
* 砍价商品单价
|
* 砍价商品单价
|
||||||
*/
|
*/
|
||||||
@ -61,17 +50,7 @@ public class BargainRecordCreateReqDTO {
|
|||||||
*/
|
*/
|
||||||
@NotNull(message = "商品原价不能为空")
|
@NotNull(message = "商品原价不能为空")
|
||||||
private Integer price;
|
private Integer price;
|
||||||
// TODO @puhui999:nickname、avatar 不用传递,去查询;
|
|
||||||
/**
|
|
||||||
* 用户昵称
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "用户昵称不能为空")
|
|
||||||
private String nickname;
|
|
||||||
/**
|
|
||||||
* 用户头像
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "用户头像不能为空")
|
|
||||||
private String avatar;
|
|
||||||
/**
|
/**
|
||||||
* 开团状态:进行中 砍价成功 砍价失败
|
* 开团状态:进行中 砍价成功 砍价失败
|
||||||
*/
|
*/
|
||||||
|
@ -2,9 +2,9 @@ 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.CombinationRecordRespDTO;
|
||||||
import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordUpdateStatusReqDTO;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// TODO @芋艿:后面也再撸撸这几个接口
|
// TODO @芋艿:后面也再撸撸这几个接口
|
||||||
@ -51,13 +51,29 @@ public interface CombinationRecordApi {
|
|||||||
*/
|
*/
|
||||||
void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount);
|
void validateCombinationLimitCount(Long activityId, Integer count, Integer sumCount);
|
||||||
|
|
||||||
// TODO @puhui999:是不是搞成具体的方法,拼团成功,拼团失败,这种方法;
|
/**
|
||||||
|
* 更新拼团状态为 成功
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param orderId 订单编号
|
||||||
|
*/
|
||||||
|
void updateRecordStatusToSuccess(Long userId, Long orderId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新开团记录状态
|
* 更新拼团状态为 失败
|
||||||
*
|
*
|
||||||
* @param reqDTO 请求 DTO
|
* @param userId 用户编号
|
||||||
|
* @param orderId 订单编号
|
||||||
*/
|
*/
|
||||||
void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO);
|
void updateRecordStatusToFailed(Long userId, Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新拼团状态为 进行中
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param orderId 订单编号
|
||||||
|
* @param startTime 开始时间
|
||||||
|
*/
|
||||||
|
void updateRecordStatusToInProgress(Long userId, Long orderId, LocalDateTime startTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.api.combination.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拼团记录的更新状态 Request DTO
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CombinationRecordUpdateStatusReqDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户编号
|
|
||||||
*/
|
|
||||||
@NotNull(message = "用户编号不能为空")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单编号
|
|
||||||
*/
|
|
||||||
@NotNull(message = "订单编号不能为空")
|
|
||||||
private Long orderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开团状态:正在开团 拼团成功 拼团失败
|
|
||||||
*/
|
|
||||||
@NotNull(message = "开团状态不能为空")
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 团开始时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime startTime;
|
|
||||||
|
|
||||||
}
|
|
@ -51,7 +51,7 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
// ========== 秒杀活动 1013008000 ==========
|
// ========== 秒杀活动 1013008000 ==========
|
||||||
ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1013008000, "秒杀活动不存在");
|
ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1013008000, "秒杀活动不存在");
|
||||||
ErrorCode SECKILL_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013008002, "存在商品参加了其它秒杀活动");
|
ErrorCode SECKILL_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1013008002, "存在商品参加了其它秒杀活动,秒杀时段冲突");
|
||||||
ErrorCode SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1013008003, "秒杀活动已关闭,不能修改");
|
ErrorCode SECKILL_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1013008003, "秒杀活动已关闭,不能修改");
|
||||||
ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013008004, "秒杀活动未关闭或未结束,不能删除");
|
ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013008004, "秒杀活动未关闭或未结束,不能删除");
|
||||||
ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1013008005, "秒杀活动已关闭,不能重复关闭");
|
ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1013008005, "秒杀活动已关闭,不能重复关闭");
|
||||||
|
@ -2,13 +2,13 @@ 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.CombinationRecordRespDTO;
|
||||||
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.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.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,12 +43,19 @@ public class CombinationRecordApiImpl implements CombinationRecordApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCombinationRecordStatus(CombinationRecordUpdateStatusReqDTO reqDTO) {
|
public void updateRecordStatusToSuccess(Long userId, Long orderId) {
|
||||||
if (null == reqDTO.getStartTime()) {
|
recordService.updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordStatusEnum.SUCCESS.getStatus(), userId, orderId);
|
||||||
recordService.updateCombinationRecordStatusByUserIdAndOrderId(reqDTO);
|
|
||||||
} else {
|
|
||||||
recordService.updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(reqDTO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRecordStatusToFailed(Long userId, Long orderId) {
|
||||||
|
recordService.updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordStatusEnum.FAILED.getStatus(), userId, orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRecordStatusToInProgress(Long userId, Long orderId, LocalDateTime startTime) {
|
||||||
|
recordService.updateRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordStatusEnum.IN_PROGRESS.getStatus(),
|
||||||
|
userId, orderId, startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -86,11 +86,11 @@ public class CombinationRecordDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Boolean virtualGroup;
|
private Boolean virtualGroup;
|
||||||
/**
|
/**
|
||||||
* 过期时间,单位:小时
|
* 过期时间
|
||||||
*
|
*
|
||||||
* 关联 {@link CombinationActivityDO#getLimitDuration()}
|
* {@link CombinationRecordDO#getStartTime()} + {@link CombinationActivityDO#getLimitDuration()} 计算
|
||||||
*/
|
*/
|
||||||
private Integer expireTime;
|
private LocalDateTime expireTime;
|
||||||
/**
|
/**
|
||||||
* 开始时间 (订单付款后开始的时间)
|
* 开始时间 (订单付款后开始的时间)
|
||||||
*/
|
*/
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.service.combination;
|
package cn.iocoder.yudao.module.promotion.service.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.CombinationRecordUpdateStatusReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,9 +16,11 @@ public interface CombinationRecordService {
|
|||||||
/**
|
/**
|
||||||
* 更新拼团状态
|
* 更新拼团状态
|
||||||
*
|
*
|
||||||
* @param reqDTO 请求 DTO
|
* @param status 状态
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param orderId 订单编号
|
||||||
*/
|
*/
|
||||||
void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO);
|
void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建拼团记录
|
* 创建拼团记录
|
||||||
@ -30,9 +32,12 @@ public interface CombinationRecordService {
|
|||||||
/**
|
/**
|
||||||
* 更新拼团状态和开始时间
|
* 更新拼团状态和开始时间
|
||||||
*
|
*
|
||||||
* @param reqDTO 请求 DTO
|
* @param status 状态
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param orderId 订单编号
|
||||||
|
* @param startTime 开始时间
|
||||||
*/
|
*/
|
||||||
void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO);
|
void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得拼团状态
|
* 获得拼团状态
|
||||||
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.combination;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
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.CombinationRecordUpdateStatusReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||||
@ -21,6 +20,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
|||||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
// TODO 芋艿:等拼团记录做完,完整 review 下
|
// TODO 芋艿:等拼团记录做完,完整 review 下
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼团记录 Service 实现类
|
* 拼团记录 Service 实现类
|
||||||
*
|
*
|
||||||
@ -38,27 +38,27 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateCombinationRecordStatusByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) {
|
public void updateCombinationRecordStatusByUserIdAndOrderId(Integer status, Long userId, Long orderId) {
|
||||||
// 校验拼团是否存在
|
// 校验拼团是否存在
|
||||||
CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId());
|
CombinationRecordDO recordDO = validateCombinationRecord(userId, orderId);
|
||||||
|
|
||||||
// 更新状态
|
// 更新状态
|
||||||
recordDO.setStatus(reqDTO.getStatus());
|
recordDO.setStatus(status);
|
||||||
recordMapper.updateById(recordDO);
|
recordMapper.updateById(recordDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateCombinationRecordStatusAndStartTimeByUserIdAndOrderId(CombinationRecordUpdateStatusReqDTO reqDTO) {
|
public void updateRecordStatusAndStartTimeByUserIdAndOrderId(Integer status, Long userId, Long orderId, LocalDateTime startTime) {
|
||||||
CombinationRecordDO recordDO = validateCombinationRecord(reqDTO.getUserId(), reqDTO.getOrderId());
|
CombinationRecordDO recordDO = validateCombinationRecord(userId, orderId);
|
||||||
// 更新状态
|
// 更新状态
|
||||||
recordDO.setStatus(reqDTO.getStatus());
|
recordDO.setStatus(status);
|
||||||
// 更新开始时间
|
// 更新开始时间
|
||||||
recordDO.setStartTime(reqDTO.getStartTime());
|
recordDO.setStartTime(startTime);
|
||||||
recordMapper.updateById(recordDO);
|
recordMapper.updateById(recordDO);
|
||||||
|
|
||||||
// 更新拼团参入人数
|
// 更新拼团参入人数
|
||||||
List<CombinationRecordDO> recordDOs = recordMapper.selectListByHeadIdAndStatus(recordDO.getHeadId(), reqDTO.getStatus());
|
List<CombinationRecordDO> recordDOs = recordMapper.selectListByHeadIdAndStatus(recordDO.getHeadId(), status);
|
||||||
if (CollUtil.isNotEmpty(recordDOs)) {
|
if (CollUtil.isNotEmpty(recordDOs)) {
|
||||||
recordDOs.forEach(item -> {
|
recordDOs.forEach(item -> {
|
||||||
item.setUserCount(recordDOs.size());
|
item.setUserCount(recordDOs.size());
|
||||||
@ -115,8 +115,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
// 2. 创建拼团记录
|
// 2. 创建拼团记录
|
||||||
CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO);
|
CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO);
|
||||||
record.setVirtualGroup(false);
|
record.setVirtualGroup(false);
|
||||||
// TODO @puhui999:过期时间,应该是 Date 哈;
|
record.setExpireTime(record.getStartTime().plusHours(activity.getLimitDuration()));
|
||||||
record.setExpireTime(activity.getLimitDuration());
|
|
||||||
record.setUserSize(activity.getUserSize());
|
record.setUserSize(activity.getUserSize());
|
||||||
recordMapper.insert(record);
|
recordMapper.insert(record);
|
||||||
}
|
}
|
||||||
|
@ -92,15 +92,9 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
if (activityId != null) { // 排除自己
|
if (activityId != null) { // 排除自己
|
||||||
activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId));
|
activityList.removeIf(item -> ObjectUtil.equal(item.getId(), activityId));
|
||||||
}
|
}
|
||||||
// TODO @puhui999:一个 spu,参与两个活动应该没关系,关键是活动时间不充能重叠;
|
// 2.2 过滤出所有 configIds 有交集的活动,判断是否存在重叠
|
||||||
// 2.2 过滤出所有 spuId 有交集的活动,判断是否存在重叠
|
List<SeckillActivityDO> activityDOs = filterList(activityList, s -> containsAny(s.getConfigIds(), configIds));
|
||||||
List<SeckillActivityDO> activityDOs1 = filterList(activityList, s -> ObjectUtil.equal(s.getSpuId(), spuId));
|
if (isNotEmpty(activityDOs)) {
|
||||||
if (isNotEmpty(activityDOs1)) {
|
|
||||||
throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS);
|
|
||||||
}
|
|
||||||
// 2.3 过滤出所有 configIds 有交集的活动,判断是否存在重叠
|
|
||||||
List<SeckillActivityDO> activityDOs2 = filterList(activityList, s -> containsAny(s.getConfigIds(), configIds));
|
|
||||||
if (isNotEmpty(activityDOs2)) {
|
|
||||||
throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS);
|
throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.util;
|
package cn.iocoder.yudao.module.promotion.util;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动工具类
|
* 活动工具类
|
||||||
@ -31,21 +22,4 @@ public class PromotionUtils {
|
|||||||
return LocalDateTimeUtils.beforeNow(endTime) ? CommonStatusEnum.DISABLE.getStatus() : CommonStatusEnum.ENABLE.getStatus();
|
return LocalDateTimeUtils.beforeNow(endTime) ? CommonStatusEnum.DISABLE.getStatus() : CommonStatusEnum.ENABLE.getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验商品 sku 是否都存在
|
|
||||||
*
|
|
||||||
* @param skus 数据库中的商品 skus
|
|
||||||
* @param products 需要校验的商品
|
|
||||||
* @param func 获取需要校验的商品的 skuId
|
|
||||||
*/
|
|
||||||
public static <T> void validateProductSkuAllExists(List<ProductSkuRespDTO> skus, List<T> products, Function<T, Long> func) {
|
|
||||||
// 校验 sku 个数是否一致
|
|
||||||
Set<Long> skuIdsSet = CollectionUtils.convertSet(products, func);
|
|
||||||
Set<Long> skuIdsSet1 = CollectionUtils.convertSet(skus, ProductSkuRespDTO::getId);
|
|
||||||
// 校验 skuId 是否存在
|
|
||||||
if (anyMatch(skuIdsSet, s -> !skuIdsSet1.contains(s))) {
|
|
||||||
throw exception(SKU_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.AFTER_SALE_NOT_FOUND;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 售后订单")
|
@Tag(name = "管理后台 - 售后订单")
|
||||||
@RestController
|
@RestController
|
||||||
@ -76,6 +77,9 @@ public class TradeAfterSaleController {
|
|||||||
public CommonResult<TradeAfterSaleDetailRespVO> getOrderDetail(@RequestParam("id") Long id) {
|
public CommonResult<TradeAfterSaleDetailRespVO> getOrderDetail(@RequestParam("id") Long id) {
|
||||||
// 查询订单
|
// 查询订单
|
||||||
TradeAfterSaleDO afterSale = afterSaleService.getAfterSale(id);
|
TradeAfterSaleDO afterSale = afterSaleService.getAfterSale(id);
|
||||||
|
if (afterSale == null) {
|
||||||
|
return success(null, AFTER_SALE_NOT_FOUND.getMsg());
|
||||||
|
}
|
||||||
// 查询订单
|
// 查询订单
|
||||||
TradeOrderDO order = tradeOrderQueryService.getOrder(afterSale.getOrderId());
|
TradeOrderDO order = tradeOrderQueryService.getOrder(afterSale.getOrderId());
|
||||||
// 查询订单项
|
// 查询订单项
|
||||||
@ -92,7 +96,11 @@ public class TradeAfterSaleController {
|
|||||||
TradeAfterSaleLogRespDTO respVO = new TradeAfterSaleLogRespDTO();
|
TradeAfterSaleLogRespDTO respVO = new TradeAfterSaleLogRespDTO();
|
||||||
respVO.setId((long) i);
|
respVO.setId((long) i);
|
||||||
respVO.setUserId((long) i);
|
respVO.setUserId((long) i);
|
||||||
respVO.setUserType(1);
|
respVO.setUserType(i % 2 == 0 ? 2 : 1);
|
||||||
|
// 模拟系统操作
|
||||||
|
if (i == 2) {
|
||||||
|
respVO.setUserType(3);
|
||||||
|
}
|
||||||
respVO.setAfterSaleId(id);
|
respVO.setAfterSaleId(id);
|
||||||
respVO.setOrderId((long) i);
|
respVO.setOrderId((long) i);
|
||||||
respVO.setOrderItemId((long) i);
|
respVO.setOrderItemId((long) i);
|
||||||
|
@ -35,7 +35,7 @@ public class TradeAfterSaleDetailRespVO extends TradeAfterSaleBaseVO {
|
|||||||
/**
|
/**
|
||||||
* 售后日志
|
* 售后日志
|
||||||
*/
|
*/
|
||||||
private List<TradeAfterSaleLogRespVO> afterSaleLog;
|
private List<TradeAfterSaleLogRespVO> logs;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 交易订单的详情的订单项目")
|
@Schema(description = "管理后台 - 交易订单的详情的订单项目")
|
||||||
@Data
|
@Data
|
||||||
|
@ -26,24 +26,23 @@ public class TradeOrderDetailRespVO extends TradeOrderBaseVO {
|
|||||||
private MemberUserRespVO user;
|
private MemberUserRespVO user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO 订单操作日志, 先模拟一波;返回 logs,简洁,然后复数哈
|
* TODO 订单操作日志, 先模拟一波
|
||||||
*/
|
*/
|
||||||
private List<OrderLog> orderLog;
|
private List<OrderLog> logs;
|
||||||
|
|
||||||
// TODO @puhui999:swagger 注解
|
@Schema(description = "管理后台 - 交易订单的操作日志")
|
||||||
@Data
|
@Data
|
||||||
public static class OrderLog {
|
public static class OrderLog {
|
||||||
|
|
||||||
/**
|
@Schema(description = "操作详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "订单发货")
|
||||||
* 内容
|
|
||||||
*/
|
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
/**
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023-06-01 10:50:20")
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
private Integer userType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 交易订单的详情的订单项目")
|
@Schema(description = "管理后台 - 交易订单的详情的订单项目")
|
||||||
|
@ -78,7 +78,7 @@ public interface TradeAfterSaleConvert {
|
|||||||
// 处理订单信息
|
// 处理订单信息
|
||||||
respVO.setOrder(convert(order));
|
respVO.setOrder(convert(order));
|
||||||
// 处理售后日志
|
// 处理售后日志
|
||||||
respVO.setAfterSaleLog(convertList1(logs));
|
respVO.setLogs(convertList1(logs));
|
||||||
return respVO;
|
return respVO;
|
||||||
}
|
}
|
||||||
List<TradeAfterSaleLogRespVO> convertList1(List<TradeAfterSaleLogRespDTO> list);
|
List<TradeAfterSaleLogRespVO> convertList1(List<TradeAfterSaleLogRespDTO> list);
|
||||||
|
@ -93,6 +93,7 @@ public interface TradeOrderConvert {
|
|||||||
items.forEach(item -> item.setIncrCount(-item.getIncrCount()));
|
items.forEach(item -> item.setIncrCount(-item.getIncrCount()));
|
||||||
return new ProductSkuUpdateStockReqDTO(items);
|
return new ProductSkuUpdateStockReqDTO(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ProductSkuUpdateStockReqDTO.Item> convertList(List<TradeOrderItemDO> list);
|
List<ProductSkuUpdateStockReqDTO.Item> convertList(List<TradeOrderItemDO> list);
|
||||||
|
|
||||||
@Mappings({
|
@Mappings({
|
||||||
@ -151,9 +152,10 @@ public interface TradeOrderConvert {
|
|||||||
TradeOrderDetailRespVO.OrderLog orderLog = new TradeOrderDetailRespVO.OrderLog();
|
TradeOrderDetailRespVO.OrderLog orderLog = new TradeOrderDetailRespVO.OrderLog();
|
||||||
orderLog.setContent("订单操作" + i);
|
orderLog.setContent("订单操作" + i);
|
||||||
orderLog.setCreateTime(LocalDateTime.now());
|
orderLog.setCreateTime(LocalDateTime.now());
|
||||||
|
orderLog.setUserType(i % 2 == 0 ? 2 : 1);
|
||||||
orderLogs.add(orderLog);
|
orderLogs.add(orderLog);
|
||||||
}
|
}
|
||||||
orderVO.setOrderLog(orderLogs);
|
orderVO.setLogs(orderLogs);
|
||||||
return orderVO;
|
return orderVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,12 +90,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TradeAfterSaleDO getAfterSale(Long id) {
|
public TradeAfterSaleDO getAfterSale(Long id) {
|
||||||
TradeAfterSaleDO afterSale = tradeAfterSaleMapper.selectById(id);
|
return tradeAfterSaleMapper.selectById(id);
|
||||||
// TODO @puhui999;读不到,不要这里报错哈;交给前端报错;一般是读取信息不到,message 提示,然后 close tab;
|
|
||||||
if (afterSale == null) {
|
|
||||||
throw exception(AFTER_SALE_NOT_FOUND);
|
|
||||||
}
|
|
||||||
return afterSale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 芋艿:拼团失败,要不要发起售后的方式退款?还是走取消逻辑?
|
// TODO 芋艿:拼团失败,要不要发起售后的方式退款?还是走取消逻辑?
|
||||||
|
@ -28,7 +28,6 @@ import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
|||||||
import cn.iocoder.yudao.module.promotion.api.bargain.BargainRecordApi;
|
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.CombinationRecordRespDTO;
|
||||||
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;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||||
@ -352,8 +351,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||||||
// 1、拼团活动
|
// 1、拼团活动
|
||||||
if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
|
||||||
// 更新拼团状态 TODO puhui999:订单支付失败或订单支付过期删除这条拼团记录
|
// 更新拼团状态 TODO puhui999:订单支付失败或订单支付过期删除这条拼团记录
|
||||||
combinationRecordApi.updateCombinationRecordStatus(new CombinationRecordUpdateStatusReqDTO().setUserId(order.getUserId())
|
combinationRecordApi.updateRecordStatusToInProgress(order.getUserId(), order.getId(), LocalDateTime.now());
|
||||||
.setOrderId(order.getId()).setStatus(CombinationRecordStatusEnum.IN_PROGRESS.getStatus()).setStartTime(LocalDateTime.now()));
|
|
||||||
}
|
}
|
||||||
// TODO 芋艿:发送订单变化的消息
|
// TODO 芋艿:发送订单变化的消息
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user