| xqd
@@ -0,0 +1,44 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Admin\Actions\backstage\User;
|
|
|
+
|
|
|
+use App\Models\UserBalanceLog;
|
|
|
+use App\User;
|
|
|
+use Encore\Admin\Actions\RowAction;
|
|
|
+use Encore\Admin\Auth\Permission;
|
|
|
+use Illuminate\Database\Eloquent\Model;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+
|
|
|
+class AddMoney extends RowAction
|
|
|
+{
|
|
|
+ public $name = '后台充值金额';
|
|
|
+
|
|
|
+ public function handle(Model $model,Request $request)
|
|
|
+ {
|
|
|
+ // $model ...
|
|
|
+ $money = request('add_money');
|
|
|
+ $change_money = $money*100;
|
|
|
+ $after_money = $this->row->balance+$change_money;
|
|
|
+ $arr = [
|
|
|
+ 'user_id' => $this->row->id,
|
|
|
+ 'admin_user_id' => \Admin::user()->id,
|
|
|
+ 'type' => 3,
|
|
|
+ 'relation_id' => 0,
|
|
|
+ 'before_balance' => $this->row->balance,
|
|
|
+ 'change_balance' => '+'.$change_money,
|
|
|
+ 'after_balance' => $after_money,
|
|
|
+ 'remark' => '后台充值',
|
|
|
+ 'created_at' => date('Y-m-d H:i:s',time()),
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s',time()),
|
|
|
+
|
|
|
+ ];
|
|
|
+// dd($arr);
|
|
|
+ UserBalanceLog::create($arr);
|
|
|
+ User::where('id',$this->row->id)->update(['balance'=>$after_money]);
|
|
|
+ return $this->response()->success('后台充值成功')->refresh();
|
|
|
+ }
|
|
|
+ public function form(){
|
|
|
+ $this->text('add_money','充值金额');
|
|
|
+ }
|
|
|
+
|
|
|
+}
|