Bläddra i källkod

资金流水log

skyfffire 1 månad sedan
förälder
incheckning
1b5f78ecb1
1 ändrade filer med 34 tillägg och 0 borttagningar
  1. 34 0
      src/main/java/modules/withdraw/WithdrawService.java

+ 34 - 0
src/main/java/modules/withdraw/WithdrawService.java

@@ -3,6 +3,7 @@ package modules.withdraw;
 import com.alibaba.fastjson.JSONObject;
 import com.jfinal.plugin.activerecord.Db;
 import common.jfinal.AppConfig;
+import common.model.DepositLog;
 import common.model.User;
 import common.model.Withdraw;
 import common.utils.http.MyRet;
@@ -44,6 +45,17 @@ public class WithdrawService {
                 withdraw.setCreateTime(System.currentTimeMillis());
                 withdraw.setUpdateTime(System.currentTimeMillis());
                 withdraw.setIsDeleted(0);
+
+                // 保存资金流水
+                DepositLog l = new DepositLog();
+                l.set("create_time", System.currentTimeMillis());
+                l.set("is_deleted", 0);
+                l.set("description", "用户提现:" + amount); // 描述中带上百分比
+                l.set("amount", -amount);
+                l.set("user_id", user.getLong("id"));
+                if (!l.save()) {
+                    throw new RuntimeException("资金流水记录创建失败: " + user.getId());
+                }
                 
                 if (!withdraw.save()) {
                     throw new RuntimeException("提现单据保存失败");
@@ -92,6 +104,17 @@ public class WithdrawService {
                     if (!withdraw.update()) {
                         throw new RuntimeException("单据状态更新失败");
                     }
+
+                    // 保存资金流水
+                    DepositLog l = new DepositLog();
+                    l.set("create_time", System.currentTimeMillis());
+                    l.set("is_deleted", 0);
+                    l.set("description", "慧用工转款失败退还"); // 描述中带上百分比
+                    l.set("amount", withdraw.getAmount());
+                    l.set("user_id", user.getLong("id"));
+                    if (!l.save()) {
+                        throw new RuntimeException("资金流水记录创建失败: " + user.getId());
+                    }
                     
                     return true;
                 });
@@ -131,6 +154,17 @@ public class WithdrawService {
                 if (!withdraw.update()) {
                     throw new RuntimeException("提现单据保存失败");
                 }
+
+                // 管理员拒绝
+                DepositLog l = new DepositLog();
+                l.set("create_time", System.currentTimeMillis());
+                l.set("is_deleted", 0);
+                l.set("description", "管理员拒绝提现,请查看原因"); // 描述中带上百分比
+                l.set("amount", withdraw.getAmount());
+                l.set("user_id", user.getLong("id"));
+                if (!l.save()) {
+                    throw new RuntimeException("资金流水记录创建失败: " + user.getId());
+                }
                 
                 return true;
             });