|
@@ -176,4 +176,35 @@ public class PointsService implements PointsServiceInterface {
|
|
|
wrapper.orderByDesc(PointsLog::getCreatedAt);
|
|
wrapper.orderByDesc(PointsLog::getCreatedAt);
|
|
|
return pointsLogMapper.selectPage(pageParam, wrapper);
|
|
return pointsLogMapper.selectPage(pageParam, wrapper);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 检查并发放心愿兑换奖励
|
|
|
|
|
+ * @param childId 孩子ID
|
|
|
|
|
+ * @param amount 奖励积分
|
|
|
|
|
+ * @return 发放后系统积分余额,余额不足返回-1
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public int checkAndGrantReward(Long childId, int amount) {
|
|
|
|
|
+ int currentBalance = getSystemPointsBalance(childId);
|
|
|
|
|
+ if (currentBalance < amount) {
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ return awardSystemPoints(childId, amount, "心愿兑换奖励");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 扣除心愿兑换积分
|
|
|
|
|
+ * @param childId 孩子ID
|
|
|
|
|
+ * @param amount 扣除积分
|
|
|
|
|
+ * @return 扣除成功返回true,余额不足返回false
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public boolean deductForWish(Long childId, int amount) {
|
|
|
|
|
+ int currentBalance = getSystemPointsBalance(childId);
|
|
|
|
|
+ if (currentBalance < amount) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ int result = deductSystemPoints(childId, amount, "心愿兑换扣除");
|
|
|
|
|
+ return result != -1;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|