|
@@ -19,7 +19,6 @@ package com.qunzhixinxi.hnqz.admin.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.csp.sentinel.util.StringUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
@@ -58,6 +57,7 @@ import com.qunzhixinxi.hnqz.common.data.datascope.DataScope;
|
|
|
import com.qunzhixinxi.hnqz.common.security.service.HnqzUser;
|
|
|
import com.qunzhixinxi.hnqz.common.security.util.SecurityUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -82,6 +82,7 @@ import static com.qunzhixinxi.hnqz.admin.enums.ReportEnum.REPORT_STATUS_END;
|
|
|
* @author gaoyanng
|
|
|
* @date 2020-06-25 23:35:42
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper, WmScorePackage> implements WmScorePackageService {
|
|
@@ -2493,10 +2494,11 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
* 拆包
|
|
|
*
|
|
|
* @param unpackDTO 拆包参数
|
|
|
+ * @return 是否成功
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void unpack(UnpackDTO unpackDTO) {
|
|
|
+ public Boolean unpack(UnpackDTO unpackDTO) {
|
|
|
// 原积分包
|
|
|
WmScorePackage scorePackage = this.getById(unpackDTO.getScorePackageId());
|
|
|
if (scorePackage == null) {
|
|
@@ -2530,6 +2532,9 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
}
|
|
|
// 已选择的任务
|
|
|
List<WmTask> selectTaskList = wmTaskMapper.selectBatchIds(unpackDTO.getSelectTaskIds());
|
|
|
+ if (CollUtil.isEmpty(selectTaskList)) {
|
|
|
+ throw new RuntimeException("已选择的任务不存在");
|
|
|
+ }
|
|
|
// 校验已选择的任务分值
|
|
|
int selectTaskScore = selectTaskList.stream().mapToInt(WmTask::getScore).sum();
|
|
|
if (!unpackDTO.getSelectTaskScore().equals(selectTaskScore)) {
|
|
@@ -2576,8 +2581,21 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
newScorePackage.setReceiveDate(now);
|
|
|
newScorePackage.setScore(unpackDTO.getNewPackageScore());
|
|
|
newScorePackage.setScorePackageName(String.format("%s-1", scorePackage.getScorePackageName(), "1"));
|
|
|
+ newScorePackage.setRemark(String.format("拆包自原积分包id=%s", unpackDTO.getScorePackageId()));
|
|
|
+ log.info("创建新积分包参数:{}", newScorePackage);
|
|
|
this.save(newScorePackage);
|
|
|
|
|
|
+ // 更新原积分包包值
|
|
|
+ WmScorePackage updateOldPackage = new WmScorePackage();
|
|
|
+ updateOldPackage.setId(unpackDTO.getScorePackageId());
|
|
|
+ updateOldPackage.setScore(remainPackageScore);
|
|
|
+ updateOldPackage.setUpdateTime(now);
|
|
|
+ updateOldPackage.setUpdateUser(operatorId);
|
|
|
+ updateOldPackage.setRemark(String.format("%s; 原积分包值%s更新为%s",
|
|
|
+ StrUtil.emptyIfNull(updateOldPackage.getRemark()), scorePackage.getScore(), remainPackageScore));
|
|
|
+ log.info("更新原积分包参数:{}", updateOldPackage);
|
|
|
+ this.updateById(updateOldPackage);
|
|
|
+
|
|
|
// 原领包记录
|
|
|
WmScorePackageStatus oldScorePackageStatus = wmScorePackageStatusService.getOne(Wrappers.<WmScorePackageStatus>lambdaQuery()
|
|
|
.eq(WmScorePackageStatus::getPackageId, unpackDTO.getScorePackageId())
|
|
@@ -2591,6 +2609,7 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
newScorePackageStatus.setCreateUser(operatorId);
|
|
|
newScorePackageStatus.setUpdateUser(null);
|
|
|
newScorePackageStatus.setUpdateTime(null);
|
|
|
+ log.info("创建新领包记录参数:{}", newScorePackage);
|
|
|
wmScorePackageStatusService.save(newScorePackageStatus);
|
|
|
|
|
|
// 任务关联到新积分包
|
|
@@ -2600,8 +2619,11 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
updateTask.setScorePackageId(newScorePackage.getId());
|
|
|
updateTask.setUpdateUser(String.valueOf(operatorId));
|
|
|
updateTask.setUpdateTime(now);
|
|
|
-// updateTask.set
|
|
|
+ updateTask.setExtIds(Collections.singletonList(String.format("拆包任务,原积分包id=%s", unpackDTO.getScorePackageId())));
|
|
|
+ log.info("更新任务参数:{}", updateTask);
|
|
|
+ wmTaskMapper.updateById(updateTask);
|
|
|
});
|
|
|
- // TODO
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
}
|
|
|
}
|