Ejemplo n.º 1
0
 public function destroy(Request $request, $id)
 {
     empty($id) && !empty($request->input('id')) && ($id = $request->input('id'));
     $id = (array) $id;
     foreach ($id as $v) {
         $withdraw = Withdraw::find($v);
         $withdraw->canceled();
     }
     return $this->success('', count($id) > 5, compact('id'));
 }
Ejemplo n.º 2
0
    {
        $transaction && DB::beginTransaction();
        $withdraw = static::where($this->getKeyName(), $this->getKey())->lockForUpdate()->first();
        if ($withdraw->audit != static::INIT) {
            $transaction && DB::rollback();
            return false;
        }
        if (!$dealing) {
            //归还金额
            foreach ($withdraw->bills()->lockForUpdate()->get() as $stat) {
                if (!$stat->deal(false, false)) {
                    $transaction && DB::rollBack();
                    return false;
                }
            }
        }
        $withdraw->audit = $dealing ? static::FINISHED : static::NOPASS;
        $withdraw->save();
        $transaction && DB::commit();
        return true;
    }
}
Withdraw::creating(function ($withdraw) {
    $withdraw->counter_fee = round($withdraw->money * app('config')->get('site.withdraw_counter_percent'), 2);
});
Withdraw::created(function ($withdraw) {
    //提现
    $withdraw->bills()->create(['value' => -$withdraw->money, 'uid' => $withdraw->uid, 'event' => Bill::WITHDRAWALS]);
    //手续费
    $withdraw->bills()->create(['value' => -$withdraw->counter_fee, 'uid' => $withdraw->uid, 'event' => Bill::HANDLINGFEE]);
});