Przeglądaj źródła

钱包操作规范化

lizhen_gitee 1 rok temu
rodzic
commit
e8a541d93c

+ 1 - 5
application/admin/model/User.php

@@ -2,7 +2,6 @@
 
 namespace app\admin\model;
 
-use app\common\model\MoneyLog;
 use app\common\model\ScoreLog;
 use think\Model;
 
@@ -45,10 +44,7 @@ class User extends Model
 
         self::beforeUpdate(function ($row) {
             $changedata = $row->getChangedData();
-            /*if (isset($changedata['money'])) {
-                $origin = $row->getOriginData();
-                MoneyLog::create(['user_id' => $row['id'], 'money' => $changedata['money'] - $origin['money'], 'before' => $origin['money'], 'after' => $changedata['money'], 'memo' => '管理员变更金额']);
-            }*/
+
             if (isset($changedata['score'])) {
                 $origin = $row->getOriginData();
                 ScoreLog::create(['user_id' => $row['id'], 'score' => $changedata['score'] - $origin['score'], 'before' => $origin['score'], 'after' => $changedata['score'], 'memo' => '管理员变更积分']);

+ 1 - 1
application/api/controller/Live.php

@@ -52,7 +52,7 @@ class Live extends Common
 
         $user_id = 319;
         // 统计用户所有兑换记录和提现记录 是否与余额匹配
-        $moneylog = \app\common\model\UserMoneyLog::where(["user_id" => $user_id, "mode" => "+"])->sum("money");
+        $moneylog = \app\common\model\UserMoneyLog::where(["user_id" => $user_id, "mode" => "+"])->sum('value');
         $withdraw = \app\common\model\UserWithdrawalLog::where(["user_id" => $user_id, "status" => ["in", [0, 1]]])->sum("money");
         $withdraw = bcdiv($withdraw, 100,2);
         $sum = bcsub($moneylog, $withdraw,2);

+ 1 - 1
application/api/controller/Money.php

@@ -1254,7 +1254,7 @@ class Money extends Common
     {
         if (!$user_id) return false;
         // 统计用户所有兑换记录和提现记录 是否与余额匹配
-        $moneylog = \app\common\model\UserMoneyLog::where(["user_id" => $user_id, "mode" => "+"])->sum("money");
+        $moneylog = \app\common\model\UserMoneyLog::where(["user_id" => $user_id, "mode" => "+"])->sum('value');
         $withdraw = \app\common\model\UserWithdrawalLog::where(["user_id" => $user_id, "status" => ["in", [0, 1]]])->sum("money");
         $withdraw = bcdiv($withdraw, 100,2);
         $sum = bcsub($moneylog, $withdraw,2);

+ 0 - 1
application/api/controller/Withdraw.php

@@ -2,7 +2,6 @@
 
 namespace app\api\controller;
 
-use addons\recharge\model\MoneyLog;
 use app\common\library\Sms;
 use app\api\controller\Common;
 use think\Db;

+ 2 - 2
application/common/model/User.php

@@ -85,7 +85,7 @@ class User extends Model
      * @param int    $user_id 会员ID
      * @param string $memo    备注
      */
-    public static function money($money, $user_id, $memo)
+    /*public static function money($money, $user_id, $memo)
     {
         return;//作废
         $user = self::get($user_id);
@@ -98,7 +98,7 @@ class User extends Model
             //写入日志
             MoneyLog::create(['user_id' => $user_id, 'money' => $money, 'before' => $before, 'after' => $after, 'detail' => $memo]);
         }
-    }
+    }*/
 
     /**
      * 变更会员积分

+ 0 - 32
application/common/model/UserMoneyLog.php

@@ -15,38 +15,6 @@ class UserMoneyLog extends Model
     // 定义时间戳字段名
     protected $createTime = 'createtime';
 
-    /**
-     * 添加资金流水记录
-     */
-    public function addRecord($user_id, $value, $mode = "+", $before = 0, $detail = "")
-    {
-        abort(500,'接口作废');return false;
-        if (!$user_id || !$value) {
-            return false;
-        }
-//        $data = [
-//            "user_id"       => $user_id,
-//            "money"         => $value,
-//            "mode"          => $mode,
-//            "before"        => $before,
-//            "after"        => $before+$value,
-//            "detail"        => $detail,
-//            "createtime"    => time()
-//        ];
-//        return $this->insert($data);
 
-        $time = time();
-
-        $after = 0;
-        switch ($mode) {
-            case '+':
-                $after = $before + $value;
-                break;
-            case '-':
-                $after = $before - $value;
-                break;
-        }
-        return self::execute("INSERT INTO `hx_user_money_log` (`user_id` , `money` , `mode`, `before` , `after` , `detail`, `createtime`) VALUES ($user_id,$value,'$mode',$before,$after,'$detail',$time)");
-    }
 
 }

+ 1 - 0
application/extra/wallet.php

@@ -20,6 +20,7 @@ return [
     ],
     'moneyname' => [
         'jewel'    => '钻石',
+        'money'    => '余额',
     ],
 
 ];

+ 0 - 1
application/index/controller/Withdraw.php

@@ -2,7 +2,6 @@
 
 namespace app\index\controller;
 
-use addons\recharge\model\MoneyLog;
 use app\common\controller\Frontend;
 use think\Db;
 use think\Exception;