浏览代码

fix: 企业承接新增积分包,return失败信息时,积分余额没有回退的问题修复

lixuesong 1 年之前
父节点
当前提交
69c9a50854

+ 14 - 16
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmScorePackageController.java

@@ -1753,7 +1753,7 @@ public class WmScorePackageController {
 		boolean relatedScoreId = StrUtil.isNotBlank(wmScorePackage.getRelationScoreId()) && Integer.parseInt(wmScorePackage.getRelationScoreId()) > 0;
 		boolean relatedScoreId = StrUtil.isNotBlank(wmScorePackage.getRelationScoreId()) && Integer.parseInt(wmScorePackage.getRelationScoreId()) > 0;
 		LocalDateTime now = LocalDateTime.now();
 		LocalDateTime now = LocalDateTime.now();
 		SysDeptRecharge deptRecharge = null;
 		SysDeptRecharge deptRecharge = null;
-		int currentScore = 0;
+
 		if (!relatedScoreId) {
 		if (!relatedScoreId) {
 			// 校验 发包积分 < 积分充值分配的积分 则可以发包
 			// 校验 发包积分 < 积分充值分配的积分 则可以发包
 			deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery()
 			deptRecharge = sysDeptRechargeMapper.selectOne(Wrappers.<SysDeptRecharge>lambdaQuery()
@@ -1768,20 +1768,6 @@ public class WmScorePackageController {
 						wmScorePackage.getScore(), deptRecharge.getScore(), limitScore);
 						wmScorePackage.getScore(), deptRecharge.getScore(), limitScore);
 				throw new RuntimeException(String.format("积分余额:%s。积分不足", deptRecharge.getScore()));
 				throw new RuntimeException(String.format("积分余额:%s。积分不足", deptRecharge.getScore()));
 			}
 			}
-
-			// 更新积分充值信息
-			currentScore = deptRecharge.getScore() - wmScorePackage.getScore();
-			int updateRecharge = 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::getUpdateTime, now)
-					.set(SysDeptRecharge::getUpdateUser, userId));
-			if (updateRecharge <= 0) {
-				log.warn("更新积分充值信息失败");
-				throw new RuntimeException("操作失败,请重试");
-			}
 		}
 		}
 
 
 		wmScorePackage.setTypeid("");
 		wmScorePackage.setTypeid("");
@@ -2042,7 +2028,19 @@ public class WmScorePackageController {
 		}
 		}
 
 
 		if (!relatedScoreId) {
 		if (!relatedScoreId) {
-			// 查询关联操作对象
+			// 更新积分充值信息
+			int currentScore = deptRecharge.getScore() - wmScorePackage.getScore();
+			int updateRecharge = 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::getUpdateTime, now)
+					.set(SysDeptRecharge::getUpdateUser, userId));
+			if (updateRecharge <= 0) {
+				log.warn("更新积分充值信息失败");
+				throw new RuntimeException("操作失败,请重试");
+			}
 			// 更新积分充值记录
 			// 更新积分充值记录
 			SysDeptRechargeRecord rechargeRecord = new SysDeptRechargeRecord();
 			SysDeptRechargeRecord rechargeRecord = new SysDeptRechargeRecord();
 			rechargeRecord.setDeptId(deptId);
 			rechargeRecord.setDeptId(deptId);