|
@@ -1682,17 +1682,24 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
SysDeptRechargeRecord rechargeRecord = sysDeptRechargeRecordMapper.selectOne(Wrappers.<SysDeptRechargeRecord>lambdaQuery()
|
|
|
.eq(SysDeptRechargeRecord::getPackageId, wmScorePackage.getId())
|
|
|
.in(SysDeptRechargeRecord::getType, RechargeRecordType.SEND_PACKAGE_DEPT, RechargeRecordType.SEND_PACKAGE_PERSONAL));
|
|
|
- if (rechargeRecord != null) {
|
|
|
+
|
|
|
+ boolean relatedScoreId = StrUtil.isNotBlank(wmScorePackage.getRelationScoreId()) && Integer.parseInt(wmScorePackage.getRelationScoreId()) > 0;
|
|
|
+
|
|
|
+ // 积分值相比修改前的变动(相对于积分余额,增加则为负-消耗,减少则为正-回收)
|
|
|
+ int changeScore = oldPackageScore - wmScorePackage.getScore();
|
|
|
+
|
|
|
+ if (!relatedScoreId) {
|
|
|
+ // 没有关联上级积分包的情况
|
|
|
log.info("修改积分包,更新积分配置信息");
|
|
|
Integer userId = SecurityUtils.getUser().getId();
|
|
|
- SysDeptRecharge deptRecharge = sysDeptRechargeMapper.selectById(rechargeRecord.getRechargeId());
|
|
|
+ Integer deptId = SecurityUtils.getUser().getDeptId();
|
|
|
+ SysDeptRecharge deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery()
|
|
|
+ .eq(SysDeptRecharge::getDeptId, deptId));
|
|
|
if (deptRecharge == null) {
|
|
|
log.warn("未配置积分充值信息");
|
|
|
throw new RuntimeException("积分余额:0。积分不足");
|
|
|
}
|
|
|
|
|
|
- // 积分值相比修改前的变动(相对于积分余额,增加则为负-消耗,减少则为正-回收)
|
|
|
- int changeScore = oldPackageScore - wmScorePackage.getScore();
|
|
|
int currentScore = deptRecharge.getScore() + changeScore;
|
|
|
|
|
|
int limitScore = deptRecharge.getScore() + deptRecharge.getOverdrawScore();
|
|
@@ -1705,7 +1712,7 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
|
|
|
// 更新企业配置的积分信息
|
|
|
int update = sysDeptRechargeMapper.update(null, Wrappers.<SysDeptRecharge>lambdaUpdate()
|
|
|
- .eq(SysDeptRecharge::getId, rechargeRecord.getRechargeId())
|
|
|
+ .eq(SysDeptRecharge::getId, deptRecharge.getId())
|
|
|
.eq(SysDeptRecharge::getVersion, deptRecharge.getVersion())
|
|
|
.set(SysDeptRecharge::getScore, currentScore)
|
|
|
.set(SysDeptRecharge::getVersion, deptRecharge.getVersion() + 1)
|
|
@@ -1722,11 +1729,24 @@ public class WmScorePackageServiceImpl extends ServiceImpl<WmScorePackageMapper,
|
|
|
newRechargeRecord.setCurrentScore(currentScore);
|
|
|
newRechargeRecord.setType(RechargeRecordType.RECOVERY);
|
|
|
newRechargeRecord.setDeptId(deptRecharge.getDeptId());
|
|
|
- newRechargeRecord.setRelationDeptId(rechargeRecord.getRelationDeptId());
|
|
|
+ newRechargeRecord.setRelationDeptId(rechargeRecord != null ? rechargeRecord.getRelationDeptId() : null);
|
|
|
newRechargeRecord.setPackageType(RechargeRecordPackageType.TO_PERSON);
|
|
|
newRechargeRecord.setPackageId(wmScorePackage.getId());
|
|
|
newRechargeRecord.setCreateUser(userId);
|
|
|
sysDeptRechargeRecordMapper.insert(newRechargeRecord);
|
|
|
+ } else {
|
|
|
+ if (changeScore < 0) {
|
|
|
+ // 变动积分值为增加,则校验上级可分配积分值
|
|
|
+ List<WmScorePackage> scorePackagekfpjf = this.getScorePackagekfpjf(null, null, new String[]{"0", "1", "2"},
|
|
|
+ new String[]{wmScorePackage.getRelationScoreId()});
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(scorePackagekfpjf)) {
|
|
|
+ int kfpjf = scorePackagekfpjf.get(0).getKfpjf();
|
|
|
+ if (Math.abs(changeScore) > kfpjf) {
|
|
|
+ throw new RuntimeException("可分配积分值不足");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return R.ok();
|