|
@@ -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();
|
|
|
}
|