mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
拼团活动:完善 review 提到的问题
This commit is contained in:
parent
2e559ebe06
commit
2c0f1121ca
@ -29,8 +29,9 @@ public interface CombinationRecordApi {
|
||||
* 创建开团记录
|
||||
*
|
||||
* @param reqDTO 请求 DTO
|
||||
* @return 开团记录编号
|
||||
*/
|
||||
void createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
|
||||
Long createCombinationRecord(@Valid CombinationRecordCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 查询拼团记录是否成功
|
||||
|
@ -29,8 +29,8 @@ public class CombinationRecordApiImpl implements CombinationRecordApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
recordService.createCombinationRecord(reqDTO);
|
||||
public Long createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
return recordService.createCombinationRecord(reqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,8 +49,9 @@ public interface CombinationRecordService {
|
||||
* 创建拼团记录
|
||||
*
|
||||
* @param reqDTO 创建信息
|
||||
* @return 开团记录编号
|
||||
*/
|
||||
void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO);
|
||||
Long createCombinationRecord(CombinationRecordCreateReqDTO reqDTO);
|
||||
|
||||
/**
|
||||
* 获得拼团记录
|
||||
@ -87,7 +88,7 @@ public interface CombinationRecordService {
|
||||
/**
|
||||
* 获取拼团记录数
|
||||
*
|
||||
* @param status 状态-允许为空
|
||||
* @param status 状态-允许为空
|
||||
* @param virtualGroup 是否虚拟成团-允许为空
|
||||
* @return 记录数
|
||||
*/
|
||||
|
@ -31,7 +31,8 @@ import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.afterNow;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.beforeNow;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
@ -163,7 +164,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
public Long createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) {
|
||||
// 1. 校验拼团活动
|
||||
KeyValue<CombinationActivityDO, CombinationProductDO> keyValue = validateCombinationRecord(reqDTO.getUserId(),
|
||||
reqDTO.getActivityId(), reqDTO.getHeadId(), reqDTO.getSkuId(), reqDTO.getCount());
|
||||
@ -173,34 +174,19 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId());
|
||||
ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId());
|
||||
CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku);
|
||||
// TODO @puhui:有 head 的情况下,以 head 结束为准
|
||||
// 3. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP
|
||||
record.setHeadId(record.getHeadId() == null ? CombinationRecordDO.HEAD_ID_GROUP : record.getHeadId());
|
||||
recordMapper.insert(record);
|
||||
|
||||
// 3. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP
|
||||
// TODO @puhui999:是不是只要是团长,record 设置了就好啦,不用 update。。。。
|
||||
if (ObjUtil.equal(CombinationRecordDO.HEAD_ID_GROUP, reqDTO.getHeadId())) {
|
||||
recordMapper.updateById(new CombinationRecordDO().setId(record.getId()).setHeadId(CombinationRecordDO.HEAD_ID_GROUP));
|
||||
return;
|
||||
if (ObjUtil.equal(CombinationRecordDO.HEAD_ID_GROUP, record.getHeadId())) {
|
||||
return record.getId();
|
||||
}
|
||||
|
||||
// TODO 这里要不要弄成异步的;不用异步哈,就是事务好了;
|
||||
// 4、更新拼团相关信息到订单
|
||||
updateOrderCombinationInfo(record.getOrderId(), record.getActivityId(), record.getId(), record.getHeadId());
|
||||
tradeOrderApi.updateOrderCombinationInfo(record.getOrderId(), record.getActivityId(), record.getId(), record.getHeadId());
|
||||
// 4、更新拼团记录
|
||||
updateCombinationRecordWhenCreate(reqDTO.getHeadId(), keyValue.getKey());
|
||||
}
|
||||
|
||||
// TODO @puhui999:这个更新,放到 trade 那就好了;createCombinationRecord 返回一个 recordId;
|
||||
/**
|
||||
* 更新拼团相关信息到订单
|
||||
*
|
||||
* @param orderId 订单编号
|
||||
* @param activityId 拼团活动编号
|
||||
* @param combinationRecordId 拼团记录编号
|
||||
* @param headId 团长编号
|
||||
*/
|
||||
private void updateOrderCombinationInfo(Long orderId, Long activityId, Long combinationRecordId, Long headId) {
|
||||
tradeOrderApi.updateOrderCombinationInfo(orderId, activityId, combinationRecordId, headId);
|
||||
return record.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user