find($id); // 判断订单状态 if ($res['status'] !== 0) { return false; } $uid = $res['uid']; $num = $res['num']; $user = User::find($uid); // 开启事务 DB::beginTransaction(); try { $user->update_wallet_and_log(1, 'usable_balance', $num, UserWallet::asset_account, 'recharge', '手动充值'); DB::table('user_wallet_recharge') ->insert([ 'user_id' => $uid, 'username' => $user->username, 'coin_id' => 1, 'coin_name' => 'USDT', 'datetime' => time(), 'amount' => $num, 'status' => 1, 'type' => 1, 'account_type' => 1, 'note' => '手动上分' ]); DB::table('recharge_manual') ->where('id', $id) ->update([ 'id' => $id, 'status' => 1 ]); DB::commit(); return true; } catch (\Exception $e) { DB::rollBack(); throw new ApiException($e->getMessage()); return false; } } /** * @description: 拒绝充值 * @param {*} * @return {*} */ public function reject($id) { // 更改手动充值状态 $q1 = DB::table('recharge_manual') ->where('id', $id) ->update(['status' => 2]); if (!$q1) { return false; } return true; } // 关联表 public function user() { return $this->belongsTo(User::class, 'uid', 'user_id'); } }