Browse Source

优化draw接口方法

wangzhijun 1 week ago
parent
commit
5a478aa702

+ 9 - 4
nightFragrance-massage/src/main/java/com/ylx/point/service/impl/PointAccountServiceImpl.java

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