Commit eaaeb86a0cefa583233b378d438d2ef07d6c0d7c
1 parent
89c137a9
feat(mes): add MES production task issue API and improve combination record validation
Showing
1 changed file
with
12 additions
and
3 deletions
yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -77,7 +77,6 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 77 | 77 | @Resource |
| 78 | 78 | public SocialClientApi socialClientApi; |
| 79 | 79 | |
| 80 | - // TODO @芋艿:在详细预览下; | |
| 81 | 80 | @Override |
| 82 | 81 | public KeyValue<CombinationActivityDO, CombinationProductDO> validateCombinationRecord( |
| 83 | 82 | Long userId, Long activityId, Long headId, Long skuId, Integer count) { |
| ... | ... | @@ -97,7 +96,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | 98 | // 2. 父拼团是否存在,是否已经满了 |
| 100 | - if (headId != null) { | |
| 99 | + if (isJoinCombination(headId)) { | |
| 101 | 100 | // 2.1. 查询进行中的父拼团 |
| 102 | 101 | CombinationRecordDO record = combinationRecordMapper.selectByHeadId(headId, CombinationRecordStatusEnum.IN_PROGRESS.getStatus()); |
| 103 | 102 | if (record == null) { |
| ... | ... | @@ -153,6 +152,16 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 153 | 152 | return new KeyValue<>(activity, product); |
| 154 | 153 | } |
| 155 | 154 | |
| 155 | + /** | |
| 156 | + * 是否加入已有拼团。 | |
| 157 | + * | |
| 158 | + * 前端开团时可能不传 headId,也可能传 {@link CombinationRecordDO#HEAD_ID_GROUP},都应视为新开团; | |
| 159 | + * 只有传入真实团长记录编号时,才需要按参团校验父拼团。 | |
| 160 | + */ | |
| 161 | + private static boolean isJoinCombination(Long headId) { | |
| 162 | + return headId != null && ObjUtil.notEqual(headId, CombinationRecordDO.HEAD_ID_GROUP); | |
| 163 | + } | |
| 164 | + | |
| 156 | 165 | @Override |
| 157 | 166 | @Transactional(rollbackFor = Exception.class) |
| 158 | 167 | public CombinationRecordDO createCombinationRecord(CombinationRecordCreateReqDTO reqDTO) { |
| ... | ... | @@ -166,7 +175,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 166 | 175 | ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()); |
| 167 | 176 | CombinationRecordDO record = CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku); |
| 168 | 177 | // 2.1. 如果是团长需要设置 headId 为 CombinationRecordDO#HEAD_ID_GROUP |
| 169 | - if (record.getHeadId() == null) { | |
| 178 | + if (!isJoinCombination(record.getHeadId())) { | |
| 170 | 179 | record.setStartTime(LocalDateTime.now()) |
| 171 | 180 | .setExpireTime(LocalDateTime.now().plusHours(keyValue.getKey().getLimitDuration())) |
| 172 | 181 | .setHeadId(CombinationRecordDO.HEAD_ID_GROUP); | ... | ... |