|
@@ -93,11 +93,11 @@ public class PointsService implements PointsServiceInterface {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** @return 系统积分余额 */
|
|
|
|
|
|
|
+ /** @return CF值余额 */
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public int awardSystemPoints(Long memberId, int amount, String reason) {
|
|
|
|
|
|
|
+ public int awardCfPoints(Long memberId, int amount, String reason) {
|
|
|
if (amount <= 0) {
|
|
if (amount <= 0) {
|
|
|
- throw new IllegalArgumentException("系统积分数量必须为正数");
|
|
|
|
|
|
|
+ throw new IllegalArgumentException("CF值数量必须为正数");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
FamilyMember child = familyMemberMapper.selectById(memberId);
|
|
FamilyMember child = familyMemberMapper.selectById(memberId);
|
|
@@ -105,11 +105,8 @@ public class PointsService implements PointsServiceInterface {
|
|
|
throw new RuntimeException("孩子不存在");
|
|
throw new RuntimeException("孩子不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- int newSystemPoints = (child.getSystemPoints() == null ? 0 : child.getSystemPoints()) + amount;
|
|
|
|
|
- child.setSystemPoints(newSystemPoints);
|
|
|
|
|
-
|
|
|
|
|
- int newTotal = (child.getTotalPoints() == null ? 0 : child.getTotalPoints()) + amount;
|
|
|
|
|
- child.setTotalPoints(newTotal);
|
|
|
|
|
|
|
+ int newCfPoints = (child.getSystemPoints() == null ? 0 : child.getSystemPoints()) + amount;
|
|
|
|
|
+ child.setSystemPoints(newCfPoints);
|
|
|
|
|
|
|
|
child.setUpdatedAt(new Date());
|
|
child.setUpdatedAt(new Date());
|
|
|
familyMemberMapper.updateById(child);
|
|
familyMemberMapper.updateById(child);
|
|
@@ -118,39 +115,39 @@ public class PointsService implements PointsServiceInterface {
|
|
|
log.setChildId(memberId);
|
|
log.setChildId(memberId);
|
|
|
log.setAmount(amount);
|
|
log.setAmount(amount);
|
|
|
log.setType("earn");
|
|
log.setType("earn");
|
|
|
- log.setCategory("system");
|
|
|
|
|
|
|
+ log.setCategory("cf");
|
|
|
log.setDescription(reason);
|
|
log.setDescription(reason);
|
|
|
log.setCreatedAt(new Date());
|
|
log.setCreatedAt(new Date());
|
|
|
pointsLogMapper.insert(log);
|
|
pointsLogMapper.insert(log);
|
|
|
|
|
|
|
|
- return newSystemPoints;
|
|
|
|
|
|
|
+ return newCfPoints;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 打卡返积分(复用 awardSystemPoints 逻辑,仅 category 不同)
|
|
|
|
|
|
|
+ * 打卡返积分(平台发放,计入 CF值),仅 category 不同)
|
|
|
*/
|
|
*/
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public int awardCheckinPoints(Long memberId, int amount, String reason) {
|
|
public int awardCheckinPoints(Long memberId, int amount, String reason) {
|
|
|
- return awardSystemPoints(memberId, amount, reason);
|
|
|
|
|
|
|
+ return awardCfPoints(memberId, amount, reason);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 心愿兑换扣除积分(家长审批通过后调用)
|
|
|
|
|
|
|
+ * 心愿兑换扣除CF值(家长审批通过后调用)
|
|
|
* @param memberId 孩子ID
|
|
* @param memberId 孩子ID
|
|
|
* @param amount 扣除数量
|
|
* @param amount 扣除数量
|
|
|
* @return true=扣除成功, false=余额不足
|
|
* @return true=扣除成功, false=余额不足
|
|
|
*/
|
|
*/
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public boolean deductForWish(Long memberId, Integer amount) {
|
|
|
|
|
|
|
+ public boolean deductForWishCf(Long memberId, Integer amount) {
|
|
|
if (amount == null || amount <= 0) {
|
|
if (amount == null || amount <= 0) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- return deductSystemPoints(memberId, amount, "心愿兑换扣除") >= 0;
|
|
|
|
|
|
|
+ return deductCfPoints(memberId, amount, "心愿兑换扣除") >= 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** @return 扣除后余额,余额不足返回-1 */
|
|
/** @return 扣除后余额,余额不足返回-1 */
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public int deductSystemPoints(Long memberId, int amount, String reason) {
|
|
|
|
|
|
|
+ public int deductCfPoints(Long memberId, int amount, String reason) {
|
|
|
if (amount <= 0) {
|
|
if (amount <= 0) {
|
|
|
throw new IllegalArgumentException("扣除数量必须为正数");
|
|
throw new IllegalArgumentException("扣除数量必须为正数");
|
|
|
}
|
|
}
|
|
@@ -160,16 +157,13 @@ public class PointsService implements PointsServiceInterface {
|
|
|
throw new RuntimeException("孩子不存在");
|
|
throw new RuntimeException("孩子不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- int currentSystem = child.getSystemPoints() == null ? 0 : child.getSystemPoints();
|
|
|
|
|
- if (currentSystem < amount) {
|
|
|
|
|
|
|
+ int currentCf = child.getSystemPoints() == null ? 0 : child.getSystemPoints();
|
|
|
|
|
+ if (currentCf < amount) {
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- int newSystemPoints = currentSystem - amount;
|
|
|
|
|
- child.setSystemPoints(newSystemPoints);
|
|
|
|
|
-
|
|
|
|
|
- int newTotal = (child.getTotalPoints() == null ? 0 : child.getTotalPoints()) - amount;
|
|
|
|
|
- child.setTotalPoints(newTotal);
|
|
|
|
|
|
|
+ int newCfPoints = currentCf - amount;
|
|
|
|
|
+ child.setSystemPoints(newCfPoints);
|
|
|
|
|
|
|
|
child.setUpdatedAt(new Date());
|
|
child.setUpdatedAt(new Date());
|
|
|
familyMemberMapper.updateById(child);
|
|
familyMemberMapper.updateById(child);
|
|
@@ -178,15 +172,15 @@ public class PointsService implements PointsServiceInterface {
|
|
|
log.setChildId(memberId);
|
|
log.setChildId(memberId);
|
|
|
log.setAmount(-amount);
|
|
log.setAmount(-amount);
|
|
|
log.setType("spend");
|
|
log.setType("spend");
|
|
|
- log.setCategory("system");
|
|
|
|
|
|
|
+ log.setCategory("cf");
|
|
|
log.setDescription(reason);
|
|
log.setDescription(reason);
|
|
|
log.setCreatedAt(new Date());
|
|
log.setCreatedAt(new Date());
|
|
|
pointsLogMapper.insert(log);
|
|
pointsLogMapper.insert(log);
|
|
|
|
|
|
|
|
- return newSystemPoints;
|
|
|
|
|
|
|
+ return newCfPoints;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public int getSystemPointsBalance(Long memberId) {
|
|
|
|
|
|
|
+ public int getCfPointsBalance(Long memberId) {
|
|
|
FamilyMember child = familyMemberMapper.selectById(memberId);
|
|
FamilyMember child = familyMemberMapper.selectById(memberId);
|
|
|
if (child == null) {
|
|
if (child == null) {
|
|
|
return 0;
|
|
return 0;
|
|
@@ -207,18 +201,18 @@ public class PointsService implements PointsServiceInterface {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 检查并发放心愿兑换奖励
|
|
|
|
|
|
|
+ * 检查并发放CF值奖励
|
|
|
* @param memberId 孩子ID
|
|
* @param memberId 孩子ID
|
|
|
- * @param amount 奖励积分
|
|
|
|
|
- * @return 发放后系统积分余额,余额不足返回-1
|
|
|
|
|
|
|
+ * @param amount 奖励CF值
|
|
|
|
|
+ * @return 发放后CF值余额,余额不足返回-1
|
|
|
*/
|
|
*/
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public int checkAndGrantReward(Long memberId, int amount) {
|
|
|
|
|
- int currentBalance = getSystemPointsBalance(memberId);
|
|
|
|
|
|
|
+ public int checkAndGrantCfReward(Long memberId, int amount) {
|
|
|
|
|
+ int currentBalance = getCfPointsBalance(memberId);
|
|
|
if (currentBalance < amount) {
|
|
if (currentBalance < amount) {
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
- return awardSystemPoints(memberId, amount, "心愿兑换奖励");
|
|
|
|
|
|
|
+ return awardCfPoints(memberId, amount, "心愿兑换奖励");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|