wupengfei 3 年之前
父節點
當前提交
2377ed1ac8
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      addons/common.php

+ 6 - 5
addons/common.php

@@ -1,16 +1,17 @@
 <?php
 use think\Db;
 use think\Exception;
-
+use app\common\model\MoneyLog;
 // 更新会员余额
 function user_rebate($user_id,$balance,$source,$related_id=0,$from_user= 0,$desc=''){
     $user_info = Db::table('fa_user')->find($user_id);
     $balance_data=[
         'user_id' => $user_id ,
-        'balance' => $balance ,
-        'surplus' => bcadd($user_info['money'],$balance,2) ,
+        'money' => $balance ,
+        'before' => $user_info['money'] ,
+        'after' => bcadd($user_info['money'],$balance,2) ,
         'source' =>  $source ,
-        'desc' =>  $desc ,
+        'memo' =>  $desc ,
         'create_time' => date('Y-m-d H:i:s'),
         'related_id' => $related_id,
         'from_user' => $from_user,
@@ -18,7 +19,7 @@ function user_rebate($user_id,$balance,$source,$related_id=0,$from_user= 0,$desc
     Db::startTrans();
     try {
         Db::table('fa_user')->where('id',$user_id)->update(['money'=>$balance_data['surplus']]);
-        Db::table('lmt_user_balance_info')->insert($balance_data);
+        MoneyLog::create($balance_data);
     }catch (Exception $e){
         Db::rollback();
     }