validate([ 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1'], 'member_id' => ['nullable', 'string', 'min:1'], 'status' => ['nullable', 'integer', 'min:0', 'max:3'] ]); $page = request()->input('page', 1); $limit = request()->input('limit', 10); $params['type'] = 2; $query = PaymentOrder::query(); $where = PaymentOrderService::getWhere($params); $count = $query->where($where)->count(); $list = $query->where($where) ->with(['userInfo']) ->orderBy('created_at', 'desc') ->forpage($page, $limit)->get(); // foreach ($list as &$item) { // $item['exchange_rate'] = floatval($item['exchange_rate']); // $item['after_balance'] = floatval($item['after_balance']); // $item['service_charge'] = floatval($item['service_charge']); // $item['amount'] = floatval($item['amount']); // $item['to_account'] = floatval($item['to_account']); // $item['to_account_usdt'] = floatval(bcdiv($item['to_account'], $item['exchange_rate'], 4)); // } $result = ['total' => $count, 'data' => $list]; } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error(intval($e->getCode())); } return $this->success($result); } public function setNote() { try { $params = request()->validate([ 'id' => ['required', 'integer', 'min:1'], 'admin_note' => ['required', 'string', 'min:1', 'max:120'], ]); $w = WithdrawModel::where('id', $params['id'])->first(); if (!$w) throw new Exception("记录不存在", HttpStatus::CUSTOM_ERROR); $w->admin_note = $params['admin_note']; $w->save(); } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage()); } return $this->success(); } public function index() { try { $params = request()->validate([ 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1'], 'member_id' => ['nullable', 'string', 'min:1'], 'status' => ['nullable', 'integer', 'min:0', 'max:2'] ]); $page = request()->input('page', 1); $limit = request()->input('limit', 10); $query = WithdrawModel::query(); $where = WithdrawService::getWhere($params); $count = $query->where($where)->count(); $list = $query->where($where) ->with(['member']) ->orderBy('created_at', 'desc') ->forpage($page, $limit)->get(); foreach ($list as &$item) { $item['exchange_rate'] = floatval($item['exchange_rate']); $item['after_balance'] = floatval($item['after_balance']); $item['service_charge'] = floatval($item['service_charge']); $item['amount'] = floatval($item['amount']); $item['to_account'] = floatval($item['to_account']); $item['exchange_rate'] = $item['exchange_rate'] == 0 ? 7.3 : $item['exchange_rate']; $item['to_account_usdt'] = floatval(bcdiv($item['to_account'], $item['exchange_rate'], 4)); } $result = ['total' => $count, 'data' => $list]; } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error(intval($e->getCode())); } return $this->success($result); } /** * @api {post} /admin/withdraw/setStatus 通过|拒绝 * @apiGroup 提现管理 * * @apiUse result * @apiUse header * @apiVersion 1.0.0 * * @apiParam {string} id 提现表ID * @apiParam {int} status 状态 * - 1 通过 * - 2 拒绝 */ public function setStatus() { DB::beginTransaction(); try { request()->validate([ 'id' => ['required', 'string', 'min:1'], 'status' => ['required', 'integer', 'min:1', 'max:2'] ]); $id = request()->input('id'); $status = request()->input('status'); $w = WithdrawService::findOne(['id' => $id, 'status' => 0]); if (!$w) throw new Exception("数据不存在", HttpStatus::CUSTOM_ERROR); // 汇率 $rate = $w->exchange_rate ?? 1; if ($status == 1) { $w->status = 1; $w->save(); } else if ($status == 2) { $rate_rmb_amount = bcmul($w->amount, $rate, 2); // 提现金额 折合RMB $w->status = 2; $w->save(); $wallet = WalletService::findOne(['member_id' => $w->member_id]); $afterBalance = bcadd($wallet->available_balance, $rate_rmb_amount, 10); BalanceLogService::addLog( $w->member_id, $w->rate_rmb_amount, $wallet->available_balance, $afterBalance, '提现', $w->id, '' ); $wallet->available_balance = $afterBalance; $wallet->save(); } $arr = ['⏳️申请中', '✅️成功', '❌️失败']; $text = "📢 提现结果通知\n\n"; $temp = floatval($w->service_charge); $text .= "手续费:{$temp} USDT\n"; $temp = floatval($w->amount); $text .= "提现金额:{$temp} USDT\n"; $temp = floatval($w->to_account); $text .= "到账金额:{$temp} USDT\n"; $text .= "提现地址:{$w->address}\n\n"; $text .= "状态:{$arr[$w->status]}\n"; if ($w->remark) $text .= "说明:{$w->remark}"; $res = WithdrawService::notify([ 'chat_id' => $w->member_id, 'text' => $text, ]); DB::commit(); } catch (ValidationException $e) { DB::rollBack(); return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { DB::rollBack(); return $this->error(intval($e->getCode()), $e->getMessage()); } return $this->success($res); } }