|
@@ -56,6 +56,8 @@ public class PointAccountServiceImpl implements IPointAccountService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private TWxUserService wxUserService;
|
|
private TWxUserService wxUserService;
|
|
|
|
|
|
|
|
|
|
+ private static final Integer ZERO_BALANCE = 0;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 增加用户积分(无账户表版本)
|
|
* 增加用户积分(无账户表版本)
|
|
|
*/
|
|
*/
|
|
@@ -283,6 +285,12 @@ public class PointAccountServiceImpl implements IPointAccountService {
|
|
|
// 1. 获取当前余额 (变动前)
|
|
// 1. 获取当前余额 (变动前)
|
|
|
Integer currentBalance = getBalance(openId);
|
|
Integer currentBalance = getBalance(openId);
|
|
|
|
|
|
|
|
|
|
+ // 计算变动后余额 (快照)
|
|
|
|
|
+ Integer newBalance = currentBalance + points;
|
|
|
|
|
+ if (ObjectUtil.equals(ZERO_BALANCE, newBalance)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 2. 写入积分流水表 (point_user_log)
|
|
// 2. 写入积分流水表 (point_user_log)
|
|
|
PointUserLog log = new PointUserLog();
|
|
PointUserLog log = new PointUserLog();
|
|
|
log.setOpenId(openId);
|
|
log.setOpenId(openId);
|
|
@@ -292,9 +300,6 @@ public class PointAccountServiceImpl implements IPointAccountService {
|
|
|
log.setIsExpired(0);
|
|
log.setIsExpired(0);
|
|
|
log.setActivityName(TaskNameEnum.LOCAL_LIVE_LOTTERY.getInfo());
|
|
log.setActivityName(TaskNameEnum.LOCAL_LIVE_LOTTERY.getInfo());
|
|
|
log.setMonth(DateUtil.format(new Date(), "yyyyMM"));
|
|
log.setMonth(DateUtil.format(new Date(), "yyyyMM"));
|
|
|
-
|
|
|
|
|
- // 计算变动后余额 (快照)
|
|
|
|
|
- Integer newBalance = currentBalance + points;
|
|
|
|
|
log.setBalanceAfter(newBalance);
|
|
log.setBalanceAfter(newBalance);
|
|
|
|
|
|
|
|
boolean saveSuccess = pointUserLogService.save(log);
|
|
boolean saveSuccess = pointUserLogService.save(log);
|
|
@@ -413,7 +418,7 @@ public class PointAccountServiceImpl implements IPointAccountService {
|
|
|
|
|
|
|
|
log.info("成功获取广誉源领取积分,数量: {}", points);
|
|
log.info("成功获取广誉源领取积分,数量: {}", points);
|
|
|
|
|
|
|
|
- return points;
|
|
|
|
|
|
|
+ return ObjectUtil.defaultIfNull(points, 0);
|
|
|
|
|
|
|
|
} catch (ServiceException e) {
|
|
} catch (ServiceException e) {
|
|
|
// 透传业务异常,不要重复包装
|
|
// 透传业务异常,不要重复包装
|