|
@@ -3000,74 +3000,14 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
// 更新父级积分包
|
|
|
WmScorePackage updateParentPackage = new WmScorePackage();
|
|
|
updateParentPackage.setId(parentScorePackage.getId());
|
|
|
- updateParentPackage.setKfpjf(recoveryScore);
|
|
|
+ updateParentPackage.setKfpjf(parentScorePackage.getKfpjf() + recoveryScore);
|
|
|
updateParentPackage.setUpdateTime(now);
|
|
|
updateParentPackage.setUpdateUser(userId);
|
|
|
- log.info("父级积分包更新参数:{}", updateParentPackage);
|
|
|
+ log.info("回收整包的积分值到大包的参数:{}", updateParentPackage);
|
|
|
this.updateById(updateParentPackage);
|
|
|
} else {
|
|
|
- // 更新该企业的余额
|
|
|
- SysDeptRecharge deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery()
|
|
|
- .eq(SysDeptRecharge::getDeptId, deptId));
|
|
|
- if (deptRecharge == null) {
|
|
|
- throw new RuntimeException("没有配置企业余额信息");
|
|
|
- }
|
|
|
-
|
|
|
- // 如果是通过积分充值的积分发的包,则回收积分
|
|
|
- SysDeptRechargeRecord rechargeRecord = sysDeptRechargeRecordMapper.selectOne(Wrappers.<SysDeptRechargeRecord>lambdaQuery()
|
|
|
- .eq(SysDeptRechargeRecord::getPackageId, packageId)
|
|
|
- .in(SysDeptRechargeRecord::getType, RechargeRecordType.SEND_PACKAGE_DEPT, RechargeRecordType.SEND_PACKAGE_PERSONAL));
|
|
|
-
|
|
|
- if (rechargeRecord != null) {
|
|
|
- log.info("终止积分包,更新积分余额信息");
|
|
|
- int currentScore = deptRecharge.getScore() + recoveryScore;
|
|
|
- // 更新企业配置的积分信息
|
|
|
- int update = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
- .eq(SysDeptRecharge::getId, rechargeRecord.getRechargeId())
|
|
|
- .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
- .set(SysDeptRecharge::getScore, currentScore)
|
|
|
- .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
- .set(SysDeptRecharge::getUpdateUser, userId)
|
|
|
- .set(SysDeptRecharge::getUpdateTime, LocalDateTime.now()));
|
|
|
- if (update <= 0) {
|
|
|
- throw new RuntimeException("更新余额失败");
|
|
|
- }
|
|
|
- // 新增积分记录
|
|
|
- SysDeptRechargeRecord newRechargeRecord = new SysDeptRechargeRecord();
|
|
|
- newRechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
- newRechargeRecord.setChangeScore(recoveryScore);
|
|
|
- newRechargeRecord.setCurrentScore(currentScore);
|
|
|
- newRechargeRecord.setType(RechargeRecordType.RECOVERY);
|
|
|
- newRechargeRecord.setDeptId(deptRecharge.getDeptId());
|
|
|
- newRechargeRecord.setRelationDeptId(rechargeRecord.getRelationDeptId());
|
|
|
- newRechargeRecord.setPackageId(packageId);
|
|
|
- newRechargeRecord.setCreateUser(userId);
|
|
|
- sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
- } else {
|
|
|
- log.info("终止积分包,更新积分配置信息(历史积分包处理)");
|
|
|
- int currentScore = deptRecharge.getScore() + recoveryScore;
|
|
|
- // 更新企业配置的积分信息
|
|
|
- int update = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
- .eq(SysDeptRecharge::getId, deptRecharge.getId())
|
|
|
- .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
- .set(SysDeptRecharge::getScore, currentScore)
|
|
|
- .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
- .set(SysDeptRecharge::getUpdateUser, userId)
|
|
|
- .set(SysDeptRecharge::getUpdateTime, LocalDateTime.now()));
|
|
|
- if (update <= 0) {
|
|
|
- throw new RuntimeException("更新余额失败");
|
|
|
- }
|
|
|
- // 新增积分记录
|
|
|
- SysDeptRechargeRecord newRechargeRecord = new SysDeptRechargeRecord();
|
|
|
- newRechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
- newRechargeRecord.setChangeScore(recoveryScore);
|
|
|
- newRechargeRecord.setCurrentScore(currentScore);
|
|
|
- newRechargeRecord.setType(RechargeRecordType.RECOVERY);
|
|
|
- newRechargeRecord.setDeptId(deptRecharge.getDeptId());
|
|
|
- newRechargeRecord.setPackageId(packageId);
|
|
|
- newRechargeRecord.setCreateUser(userId);
|
|
|
- sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
- }
|
|
|
+ // 更新积分余额信息
|
|
|
+ this.updateDeptRecharge(packageId, recoveryScore);
|
|
|
}
|
|
|
|
|
|
return Boolean.TRUE;
|
|
@@ -3083,16 +3023,22 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean terminatePackageForDept(String packageId, UpmsType.TerminatePackageType terminatePackageType) {
|
|
|
+ Integer userId = SecurityUtils.getUser().getId();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+
|
|
|
WmScorePackage scorePackage = this.getById(packageId);
|
|
|
if (!StrUtil.equalsAny(scorePackage.getTypeid(), "0", "1", "2")) {
|
|
|
throw new RuntimeException("请选择企业承接的大包");
|
|
|
}
|
|
|
|
|
|
- int relatedPackageCount = this.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
- .eq(WmScorePackage::getRelationScoreId, packageId)
|
|
|
- .ne(WmScorePackage::getScorePackageStatus, ScorePackageStatusEnum.TERMINATED.val()));
|
|
|
- if (relatedPackageCount > 0 || !scorePackage.getScore().equals(scorePackage.getKfpjf())) {
|
|
|
- throw new RuntimeException("积分包已被分派,请联系下属CSO终止关联积分包后再进行次操作");
|
|
|
+ if (UpmsType.TerminatePackageType.ALL.equals(terminatePackageType)) {
|
|
|
+ // 全部终止的校验
|
|
|
+ int relatedPackageCount = this.count(Wrappers.<WmScorePackage>lambdaQuery()
|
|
|
+ .eq(WmScorePackage::getRelationScoreId, packageId)
|
|
|
+ .ne(WmScorePackage::getScorePackageStatus, ScorePackageStatusEnum.TERMINATED.val()));
|
|
|
+ if (relatedPackageCount > 0 || !scorePackage.getScore().equals(scorePackage.getKfpjf())) {
|
|
|
+ throw new RuntimeException("积分包已被分派,请联系下属CSO终止关联积分包后再进行次操作");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 更新积分包状态
|
|
@@ -3102,17 +3048,48 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
updateEntity.setEnableType(terminatePackageType.getEnableType());
|
|
|
updateEntity.setEnableFlag(EnableEnum.DISABLE.val());
|
|
|
updateEntity.setScorePackageStatus(ScorePackageStatusEnum.TERMINATED.val());
|
|
|
- updateEntity.setUpdateTime(LocalDateTime.now());
|
|
|
- updateEntity.setUpdateUser(SecurityUtils.getUser().getId());
|
|
|
+ updateEntity.setUpdateTime(now);
|
|
|
+ updateEntity.setUpdateUser(userId);
|
|
|
log.info("更新积分包参数:{}", updateEntity);
|
|
|
this.updateById(updateEntity);
|
|
|
|
|
|
- // 回收可分配积分值
|
|
|
- int recoveryScore = scorePackage.getKfpjf();
|
|
|
+ if (UpmsType.TerminatePackageType.REMAIN.equals(terminatePackageType)) {
|
|
|
+ // 剩余回收: 回收可分配积分值
|
|
|
+ int recoveryScore = scorePackage.getKfpjf();
|
|
|
+
|
|
|
+ // 如果关联了大包 回收整包的积分值到大包的可分配积分值。如果没有关联大包,回收整包积分值到该企业的余额
|
|
|
+ boolean relatedScoreId = StrUtil.isNotBlank(scorePackage.getRelationScoreId()) && Integer.parseInt(scorePackage.getRelationScoreId()) > 0;
|
|
|
+ if (relatedScoreId) {
|
|
|
+ WmScorePackage parentPackage = this.getById(scorePackage.getRelationScoreId());
|
|
|
+ // 更新父级积分包
|
|
|
+ WmScorePackage updateParentPackage = new WmScorePackage();
|
|
|
+ updateParentPackage.setId(scorePackage.getRelationScoreId());
|
|
|
+ updateParentPackage.setKfpjf(parentPackage.getKfpjf() + recoveryScore);
|
|
|
+ updateParentPackage.setUpdateTime(now);
|
|
|
+ updateParentPackage.setUpdateUser(userId);
|
|
|
+ log.info("回收整包的积分值到大包的参数:{}", updateParentPackage);
|
|
|
+ this.updateById(updateParentPackage);
|
|
|
+ } else {
|
|
|
+ // 更新积分余额信息
|
|
|
+ this.updateDeptRecharge(packageId, recoveryScore);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新积分余额信息
|
|
|
+ *
|
|
|
+ * @param packageId 积分包id
|
|
|
+ * @param recoveryScore 回收积分值
|
|
|
+ */
|
|
|
+ private void updateDeptRecharge(String packageId, int recoveryScore) {
|
|
|
Integer userId = SecurityUtils.getUser().getId();
|
|
|
Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
- // 如果是通过积分充值的积分发的包,则回收积分
|
|
|
+
|
|
|
+ // 积分余额信息
|
|
|
SysDeptRecharge deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery()
|
|
|
.eq(SysDeptRecharge::getDeptId, deptId));
|
|
|
if (deptRecharge == null) {
|
|
@@ -3122,63 +3099,30 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
SysDeptRechargeRecord rechargeRecord = sysDeptRechargeRecordMapper.selectOne(Wrappers.<SysDeptRechargeRecord>lambdaQuery()
|
|
|
.eq(SysDeptRechargeRecord::getPackageId, packageId)
|
|
|
.in(SysDeptRechargeRecord::getType, RechargeRecordType.SEND_PACKAGE_DEPT, RechargeRecordType.SEND_PACKAGE_PERSONAL));
|
|
|
- if (rechargeRecord != null) {
|
|
|
- int currentScore = deptRecharge.getScore() + recoveryScore;
|
|
|
- // 更新企业配置的积分信息
|
|
|
- log.info("终止积分包,更新积分配置信息:id={},score={}", rechargeRecord.getRechargeId(), currentScore);
|
|
|
- int update = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
- .eq(SysDeptRecharge::getId, rechargeRecord.getRechargeId())
|
|
|
- .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
- .set(SysDeptRecharge::getScore, currentScore)
|
|
|
- .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
- .set(SysDeptRecharge::getUpdateUser, userId)
|
|
|
- .set(SysDeptRecharge::getUpdateTime, now));
|
|
|
- if (update <= 0) {
|
|
|
- throw new RuntimeException("更新余额失败");
|
|
|
- }
|
|
|
- // 新增积分记录
|
|
|
- SysDeptRechargeRecord newRechargeRecord = new SysDeptRechargeRecord();
|
|
|
- newRechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
- newRechargeRecord.setChangeScore(recoveryScore);
|
|
|
- newRechargeRecord.setCurrentScore(currentScore);
|
|
|
- newRechargeRecord.setType(RechargeRecordType.RECOVERY);
|
|
|
- newRechargeRecord.setDeptId(deptRecharge.getDeptId());
|
|
|
- newRechargeRecord.setRelationDeptId(rechargeRecord.getRelationDeptId());
|
|
|
- newRechargeRecord.setPackageId(packageId);
|
|
|
- newRechargeRecord.setCreateUser(userId);
|
|
|
- newRechargeRecord.setCreateTime(now);
|
|
|
- sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
- } else {
|
|
|
- // 数据历史处理:如果是源头包,则回收积分包到积分充值余额
|
|
|
- boolean relatedScoreId = StrUtil.isNotBlank(scorePackage.getRelationScoreId()) && Integer.parseInt(scorePackage.getRelationScoreId()) > 0;
|
|
|
- if (!relatedScoreId) {
|
|
|
- int currentScore = deptRecharge.getScore() + recoveryScore;
|
|
|
- // 更新企业配置的积分信息
|
|
|
- log.info("终止积分包,更新积分配置信息(历史积分包处理):id={},score={}", deptRecharge.getId(), currentScore);
|
|
|
- int update = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
- .eq(SysDeptRecharge::getId, deptRecharge.getId())
|
|
|
- .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
- .set(SysDeptRecharge::getScore, currentScore)
|
|
|
- .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
- .set(SysDeptRecharge::getUpdateUser, userId)
|
|
|
- .set(SysDeptRecharge::getUpdateTime, now));
|
|
|
- if (update <= 0) {
|
|
|
- throw new RuntimeException("更新余额失败");
|
|
|
- }
|
|
|
- // 新增积分记录
|
|
|
- SysDeptRechargeRecord newRechargeRecord = new SysDeptRechargeRecord();
|
|
|
- newRechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
- newRechargeRecord.setChangeScore(recoveryScore);
|
|
|
- newRechargeRecord.setCurrentScore(currentScore);
|
|
|
- newRechargeRecord.setType(RechargeRecordType.RECOVERY);
|
|
|
- newRechargeRecord.setDeptId(deptRecharge.getDeptId());
|
|
|
- newRechargeRecord.setPackageId(packageId);
|
|
|
- newRechargeRecord.setCreateUser(userId);
|
|
|
- newRechargeRecord.setCreateTime(now);
|
|
|
- sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return Boolean.TRUE;
|
|
|
+ int currentScore = deptRecharge.getScore() + recoveryScore;
|
|
|
+ // 更新企业配置的积分信息
|
|
|
+ log.info("终止积分包,更新积分余额信息:deptId={},score={},changeScore={}", deptId, currentScore, recoveryScore);
|
|
|
+ int update = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
+ .eq(SysDeptRecharge::getId, deptRecharge.getId())
|
|
|
+ .eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
+ .set(SysDeptRecharge::getScore, currentScore)
|
|
|
+ .set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
|
+ .set(SysDeptRecharge::getUpdateUser, userId)
|
|
|
+ .set(SysDeptRecharge::getUpdateTime, now));
|
|
|
+ if (update <= 0) {
|
|
|
+ throw new RuntimeException("更新余额失败");
|
|
|
+ }
|
|
|
+ // 新增积分记录
|
|
|
+ SysDeptRechargeRecord newRechargeRecord = new SysDeptRechargeRecord();
|
|
|
+ newRechargeRecord.setRechargeId(deptRecharge.getId());
|
|
|
+ newRechargeRecord.setChangeScore(recoveryScore);
|
|
|
+ newRechargeRecord.setCurrentScore(currentScore);
|
|
|
+ newRechargeRecord.setType(RechargeRecordType.RECOVERY);
|
|
|
+ newRechargeRecord.setDeptId(deptRecharge.getDeptId());
|
|
|
+ newRechargeRecord.setRelationDeptId(rechargeRecord.getRelationDeptId());
|
|
|
+ newRechargeRecord.setPackageId(packageId);
|
|
|
+ newRechargeRecord.setCreateUser(userId);
|
|
|
+ newRechargeRecord.setCreateTime(now);
|
|
|
+ sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
}
|
|
|
}
|