| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422 |
- <?php
- namespace App\Http\Controllers\Admin;
- use App\dao\Estatisticas\RechargeWithDraw;
- use App\Facade\RedisConnect;
- use App\Facade\TableName;
- use App\Http\helper\Helper;
- use App\Http\helper\NumConfig;
- use App\Http\logic\admin\AccountsRecordLogic;
- use App\Http\logic\admin\WithdrawalLogic;
- use App\Models\AccountsInfo;
- use App\Models\AddDrawBase;
- use App\Models\PrivateMail;
- use App\Models\RecordScoreInfo;
- use App\Models\RecordUserDataStatistics;
- use App\Models\SystemStatusInfo;
- use App\Services\CashierMessage;
- use App\Services\CreateLog;
- use App\Services\LogDayStatisticalByDayAndChannel;
- use App\Services\StoredProcedure;
- use App\Utility\SetNXLock;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Redis;
- use Illuminate\Support\Facades\Validator;
- class WithdrawalController extends BaseController
- {
- protected $logic;
- public function __construct()
- {
- $this->logic = new WithdrawalLogic();
- }
- // 待审核列表
- public function waitWithdrawal(Request $request)
- {
- $create_time_sort = $request->create_time_sort ?: '';
- $GameID = (int)$request->get('GameID') ?: '';
- $withdraw_search = (int)$request->get('withdraw_search') ?: '';
- $withdraw = $request->get('withdraw') ?? '';
- $state = $request->get('state') ?? '';
- $start_time = $request->get('start_time') ?? '';
- $end_time = $request->get('end_time') ?? '';
- $final_start_time = $request->get('final_start_time') ?? '';
- $final_end_time = $request->get('final_end_time') ?? '';
- $orderID = $request->get('orderID') ?? '';
- $excel = $request->get('excel') ?? '';
- $Channel = $request->get('Channel');
- $payState = $request->get('payState');
- $PackgeName = $request->PackgeName ?: '';
- $toNormalCs=Redis::get("normalCsOpen")??"close";
- $list = $this->logic->waitWithdrawal($GameID, $withdraw_search, $withdraw, $state, $start_time, $end_time, '', false, $create_time_sort, $orderID, $final_start_time, $final_end_time, $excel, $Channel, $payState, '', 0, '', '', $PackgeName,$toNormalCs=="open"?2:0);
- $list['api_url']='/admin/withdrawal/waitWithdrawal';
- $list['normalCsOpen']=$toNormalCs;
- $list['specialCs']=false;
- return view('admin.Withdrawal.waitWithdrawal', $list);
- }
- public function changeNewWithdrawOpen(Request $request)
- {
- //普通客服开放新用户审核开关
- $toNormalCs=$request->input("normalCsOpen");
- Redis::set("normalCsOpen",$toNormalCs);
- return apiReturnSuc([],"","操作成功:".($toNormalCs=="open"?"开启":"关闭"));
- }
- public function waitWithdrawalNewPlayer(Request $request)
- {
- $toNormalCs=Redis::get("normalCsOpen")??"close";
- $create_time_sort = $request->create_time_sort ?: '';
- $GameID = (int)$request->get('GameID') ?: '';
- $withdraw_search = (int)$request->get('withdraw_search') ?: '';
- $withdraw = $request->get('withdraw') ?? '';
- $state = $request->get('state') ?? '';
- $start_time = $request->get('start_time') ?? '';
- $end_time = $request->get('end_time') ?? '';
- $final_start_time = $request->get('final_start_time') ?? '';
- $final_end_time = $request->get('final_end_time') ?? '';
- $orderID = $request->get('orderID') ?? '';
- $excel = $request->get('excel') ?? '';
- $Channel = $request->get('Channel');
- $payState = $request->get('payState');
- $PackgeName = $request->PackgeName ?: '';
- $list = $this->logic->waitWithdrawal($GameID, $withdraw_search, $withdraw, $state, $start_time, $end_time, '', false, $create_time_sort, $orderID, $final_start_time, $final_end_time, $excel, $Channel, $payState, '', 0, '', '', $PackgeName,1);
- $list['api_url']='/admin/withdrawal/waitWithdrawalNewPlayer';
- $list['normalCsOpen']=$toNormalCs;
- $list['specialCs']=true;
- return view('admin.Withdrawal.waitWithdrawal', $list);
- }
- public function state5List(Request $request){
- $data = $request->all();
- if ($request->isMethod('post')) {
- $ID=$data['OrderId'];
- DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId',$ID)->update(['State'=>1]);
- return json_encode(['id'=>$ID]);
- }
- $list=DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('State','=',5)
- ->get()->toArray();
- // print_r($list);die;
- return view('admin.Withdrawal.statelist', ['list'=>$list]);
- }
- // 提现审核
- public function verify(Request $request)
- {
- $data = $request->all();
- if ($request->isMethod('get')) {
- if ($data['type'] == 'agree') { // 通过
- $open=(int)SystemStatusInfo::OnlyGetCacheValue(SystemStatusInfo::$KEY_WithDrawSwitch);
- $list = $this->logic->verify_agree($data['ids']);
- $list['open']=$open;
- return view('admin.Withdrawal.verify_agree', $list);
- } elseif ($data['type'] == 'refuse') { // 清退
- $list = $this->logic->verify_agree($data['ids']);
- return view('admin.Withdrawal.verify_refuse', $list);
- } elseif ($data['type'] == 'turn_down') { // 拒绝
- $list = $this->logic->verify_agree($data['ids']);
- return view('admin.Withdrawal.turn_down', $list);
- }
- } else {
- $admin_id = $request->session()->get('admin')->id;
- $save = $this->logic->save($data, $admin_id);
- return $save;
- }
- }
- // 已审核提现订单查询
- public function verify_finish(Request $request)
- {
- $GameID = (int)$request->get('GameID') ?: '';
- $withdraw_search = (int)$request->get('withdraw_search') ?: '';
- $withdraw = $request->get('withdraw') ?: '';
- $state = $request->get('state') ?? '';
- $agent = $request->get('agent') ?? '';
- $start_time = $request->get('start_time') ?? '';
- $end_time = $request->get('end_time') ?? '';
- $orderID = $request->get('orderID') ?? '';
- $excel = $request->get('excel') ?? '';
- $final_start_time = $request->get('final_start_time') ?? '';
- $final_end_time = $request->get('final_end_time') ?? '';
- $take_effect = $request->get('take_effect') ?? '';
- $Channel = $request->get('Channel');
- $payState = $request->get('payState');
- $start_time = str_replace('T', ' ', $start_time);
- $end_time = str_replace('T', ' ', $end_time);
- $isEmpty = $request->get('isEmpty') ?: '';
- $PackgeName = $request->PackgeName ?: '';
- $register_start_time = $request->input('register_start_time');
- $register_end_time = $request->input('register_end_time');
- $list = $this->logic->waitWithdrawal($GameID, $withdraw_search, $withdraw, $state, $start_time, $end_time, $agent, true, '', $orderID, $final_start_time, $final_end_time, $excel, $Channel, $payState, $take_effect, $isEmpty, $register_start_time, $register_end_time, $PackgeName,2);
- $list['agents'] = DB::table('agent.dbo.admin_configs')
- ->where('type', 'cash')
- ->get();
- $list['request'] = $request;
- return view('admin.Withdrawal.verify_finish', $list);
- }
- // 提现拒绝
- public function turn_down(Request $request)
- {
- $redis = new RedisConnect();
- $limitKey = 'turn_down';
- $res = $redis->redis()->set($limitKey, 1, 3);
- if (empty($res)) return apiReturnFail('频繁操作');
- $post = $request->post();
- $ids = explode(',', $post['ids']);
- if (count($ids) < 1) {
- return apiReturnFail('数据不存在!');
- }
- foreach ($ids as $val) {
- // 查找订单
- $OrderWithDraw = DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
- ->where('RecordID', $val)
- ->selectRaw('UserID,OrderID,WithDraw,ServiceFee')
- ->first();
- // 修改订单状态 locking=>[2清退不返打码量 3 拒绝返打码量]
- DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
- ->where('RecordID', $val)
- ->update(['State' => -1, 'locking' => 3]);
- $remarks = $post['remarks'] ?? '';
- $admin_id = session('admin')['id'];
- // 添加用户提现操作记录
- (new AccountsRecordLogic())->create_record($val, 1, -2, $remarks, $admin_id, 1);
- $amount = $OrderWithDraw->WithDraw + $OrderWithDraw->ServiceFee;
- PrivateMail::refuseMail($OrderWithDraw->UserID, $OrderWithDraw->OrderID, $amount, true);
- }
- $redis->redis()->del($limitKey);
- return apiReturnSuc();
- }
- // 提现数值修改
- public function config()
- {
- // $fee = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
- // ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
- // $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
- // })
- // ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
- // ->where('si.StatusName', 'WithDrawTax')
- // ->select('StatusValue', 'account', 'create_at')
- // ->first();
- $fee = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
- ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
- $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
- })
- ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
- ->where('si.StatusName', 'WithDrawTax')
- ->select('StatusValue', 'account', 'create_at')
- ->first();
- $artificial = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
- ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
- $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
- })
- ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
- ->where('si.StatusName', 'WithDrawAILimit')
- ->select('StatusValue', 'account', 'create_at')
- ->first();
- $proportion = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
- ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
- $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
- })
- ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
- ->where('si.StatusName', 'WithDrawRate')
- ->select('StatusValue', 'account', 'create_at')
- ->first();
- $WithDrawMin = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
- ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
- $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
- })
- ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
- ->where('si.StatusName', 'WithDrawMin')
- ->select('StatusValue', 'account', 'create_at')
- ->first();
- $WithDrawMax = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
- ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
- $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
- })
- ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
- ->where('si.StatusName', 'WithDrawMax')
- ->select('StatusValue', 'account', 'create_at')
- ->first();
- $WithDrawPoint = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
- ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
- $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
- })
- ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
- ->where('si.StatusName', 'WithDrawPoint')
- ->select('StatusValue', 'account', 'create_at')
- ->first();
- $MaxTXNotRecharge = DB::connection('write')->table('QPAccountsDB.dbo.SystemStatusInfo as si')
- ->leftJoin('agent.dbo.SystemStatusInfo_log as log', function($join) {
- $join->on(DB::raw('si.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'), '=', DB::raw('log.StatusName COLLATE SQL_Latin1_General_CP1_CI_AS'));
- })
- ->leftJoin('agent.dbo.admin_users as au', 'log.admin_id', '=', 'au.id')
- ->where('si.StatusName', 'MaxTXNotRecharge')
- ->select('StatusValue', 'account', 'create_at')
- ->first();
- $fee->StatusValue = number_float(-$fee->StatusValue / NumConfig::NUM_VALUE);
- $artificial->StatusValue = number_float($artificial->StatusValue / NumConfig::NUM_VALUE);
- $proportion->StatusValue = number_float((10000 - $proportion->StatusValue) / NumConfig::NUM_VALUE);
- $WithDrawMin->StatusValue = number_float(($WithDrawMin->StatusValue) / NumConfig::NUM_VALUE);
- $WithDrawMax->StatusValue = number_float(($WithDrawMax->StatusValue) / NumConfig::NUM_VALUE);
- $WithDrawPoint->StatusValue = number_float(($WithDrawPoint->StatusValue) / NumConfig::NUM_VALUE);
- $MaxTXNotRecharge->StatusValue = number_float(($MaxTXNotRecharge->StatusValue) / NumConfig::NUM_VALUE);
- $compact = compact('fee', 'artificial', 'proportion', 'WithDrawMin', 'WithDrawMax', 'WithDrawPoint', 'MaxTXNotRecharge');
- return view('admin.Withdrawal.config', $compact);
- }
- // 提现保底额度
- public function WithDrawPoint(Request $request)
- {
- if ($request->isMethod('post')) {
- $StatusValue = abs((int)$request->StatusValue * 100) ?: '';
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawPoint')->update(['StatusValue' => $StatusValue]);
- $admin_id = session('admin')->id;
- CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
- return apiReturnSuc('success');
- }
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawPoint')->value('StatusValue') / 100 ?? 0;
- return view('admin.Withdrawal.WithDrawPoint', ['info' => $result]);
- }
- // 提现手续费设置
- public function fee(Request $request)
- {
- if ($request->isMethod('post')) {
- $StatusValue = abs((int)$request->StatusValue) ?: '';
- if ($StatusValue > 1000) {
- return apiReturnFail('手续费最大值为1000');
- }
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawTax')->update(['StatusValue' => $StatusValue]);
- $admin_id = session('admin')->id;
- CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
- return apiReturnSuc('success');
- }
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawTax')->value('StatusValue');
- return view('admin.Withdrawal.fee', ['info' => $result]);
- }
- // 提现金额比例设置
- public function artificial(Request $request)
- {
- if ($request->isMethod('post')) {
- $StatusValue = abs((int)$request->StatusValue) ?: '';
- $StatusValue *= 100;
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawAILimit')->update(['StatusValue' => $StatusValue]);
- $admin_id = session('admin')->id;
- CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
- return apiReturnSuc('success');
- }
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawAILimit')->value('StatusValue');
- $result = $result / 100;
- return view('admin.Withdrawal.artificial', ['info' => $result]);
- }
- //人工审核额度设置
- public function proportion(Request $request)
- {
- if ($request->isMethod('post')) {
- $StatusValue = (int)$request->StatusValue ?: '';
- $StatusValue = abs($StatusValue);
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawRate')->update(['StatusValue' => $StatusValue]);
- $admin_id = session('admin')->id;
- CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
- return apiReturnSuc('success');
- }
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawRate')->value('StatusValue');
- return view('admin.Withdrawal.proportion', ['info' => $result]);
- }
- // 0充玩家提现限制最高额度
- public function MaxTXNotRecharge(Request $request)
- {
- if ($request->isMethod('post')) {
- $StatusValue = (int)$request->StatusValue ?: '';
- $StatusValue = $StatusValue * NumConfig::NUM_VALUE;
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'MaxTXNotRecharge')->update(['StatusValue' => $StatusValue]);
- $admin_id = session('admin')->id;
- CreateLog::SystemStatusInfo_log($admin_id, 'MaxTXNotRecharge');
- return apiReturnSuc('success');
- } else {
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'MaxTXNotRecharge')->value('StatusValue');
- $result = $result > 0 ? floatval($result / NumConfig::NUM_VALUE) : 0;
- return view('admin.Withdrawal.max_tx_not_recharge', ['info' => $result]);
- }
- }
- // 查看返回值
- public function show($sn = '')
- {
- $notify = DB::table('QPAccountsDB.dbo.withdraw_notify')->where('order_sn', $sn)->select('extra')->first()->extra ?? '';
- if ($notify) {
- $notify = \GuzzleHttp\json_decode($notify);
- }
- return view('admin.Withdrawal.show', ['info' => $notify]);
- }
- // 提现最大值修改
- public function WithDrawMax(Request $request)
- {
- if ($request->isMethod('post')) {
- $StatusValue = (int)$request->StatusValue ?: '';
- $StatusValue = abs($StatusValue) * NumConfig::NUM_VALUE;
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMax')->update(['StatusValue' => $StatusValue]);
- $admin_id = session('admin')->id;
- CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
- return apiReturnSuc('success');
- }
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMax')->value('StatusValue');
- $result /= 100;
- return view('admin.Withdrawal.WithDrawMax', ['info' => $result]);
- }
- // 提现最小值修改
- public function WithDrawMin(Request $request)
- {
- if ($request->isMethod('post')) {
- $StatusValue = (int)$request->StatusValue ?: '';
- $StatusValue = abs($StatusValue) * NumConfig::NUM_VALUE;
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMin')->update(['StatusValue' => $StatusValue]);
- $admin_id = session('admin')->id;
- CreateLog::SystemStatusInfo_log($admin_id, 'WithDrawPoint');
- return apiReturnSuc('success');
- }
- $result = DB::table('QPAccountsDB.dbo.SystemStatusInfo')->where('StatusName', 'WithDrawMin')->value('StatusValue');
- $result /= 100;
- return view('admin.Withdrawal.WithDrawMin', ['info' => $result]);
- }
- // 风险评估
- public function risk_assessment(Request $request, $UserID)
- {
- $gear = $request->gear ?: '';
- $info = DB::connection('read')->table('QPAccountsDB.dbo.AccountsInfo as ai')
- ->join('QPAccountsDB.dbo.AccountsInfo as ain', 'ai.RegisterIP', 'ain.RegisterIP')
- ->where('ai.UserID', $UserID)
- ->whereNotNull('ai.RegisterIP')
- ->selectRaw('count(1) count,ai.RegisterIP,ai.RegisterDate,ai.GameID,ai.NickName')
- ->groupBy('ai.GameID', 'ai.NickName', 'ai.RegisterIP', 'ai.RegisterDate')
- ->first();
- // 总对局数
- $info->playerNum = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordUserGameCount')
- ->where('UserID', $UserID)
- ->sum('Cnt');
- // 推广佣金已领取 。
- $info->commission = DB::connection('read')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')
- ->where('ScoreType', 53)
- ->where('UserID', $UserID)
- ->selectRaw('IsNull(sum(Score),0) Score')
- ->first()->Score / NumConfig::NUM_VALUE ?? 0;
- // 推广佣金可领取 。
- $waitCommission = DB::connection('read')->table('QPAccountsDB.dbo.UserAgent')
- ->where('UserID', $UserID)
- ->selectRaw('IsNull((Balance1 + Balance2),0) as Balance')
- ->first()->Balance ?? 0;
- $info->waitCommission = $waitCommission > 0 ? $waitCommission / NumConfig::NUM_VALUE : 0;
- //今日彩金 -- 今日提现 -- 今日盈利 -- 今日充值
- $info->today = DB::connection('read')->table('QPRecordDB.dbo.RecordUserDataStatisticsNew')
- ->where('UserID', $UserID)
- ->where('DateID', date('Ymd'))
- ->selectRaw('IsNull(sum(Handsel),0)Handsel,IsNull(sum(Withdraw),0) Withdraw,IsNull((sum(WinScore) + sum(LostScore)), 0) Score,sum(Recharge) Recharge')
- ->first();
- // 全部彩金 -- 总提现 -- 总盈利 -- 总充值
- $info->total = DB::connection('read')->table('QPRecordDB.dbo.RecordUserTotalStatistics')
- ->where('UserID', $UserID)
- ->selectRaw('IsNull(sum(Handsel),0)Handsel,IsNull(sum(Withdraw),0) Withdraw,IsNull((sum(WinScore) + sum(LostScore)) , 0) Score,sum(Recharge) Recharge')
- ->first();
- isset($info->total->Score) && $info->total->Score = number_float($info->total->Score / NumConfig::NUM_VALUE);
- isset($info->total->Handsel) && $info->total->Handsel = number_float($info->total->Handsel / NumConfig::NUM_VALUE);
- isset($info->total->Withdraw) && $info->total->Withdraw = number_float($info->total->Withdraw / NumConfig::NUM_VALUE);
- isset($info->total->Recharge) && $info->total->Recharge = number_float($info->total->Recharge);
- isset($info->today->Score) && $info->today->Score = number_float($info->today->Score / NumConfig::NUM_VALUE);
- isset($info->today->Handsel) && $info->today->Handsel = number_float($info->today->Handsel / NumConfig::NUM_VALUE);
- isset($info->today->Withdraw) && $info->today->Withdraw = number_float($info->today->Withdraw / NumConfig::NUM_VALUE);
- isset($info->today->Recharge) && $info->today->Recharge = number_float($info->today->Recharge);
- // 游戏对局数--分游戏
- $gameCount = DB::connection('read')->table(TableName::QPRecordDB() . 'RecordUserGameCount')
- ->where('UserID', $UserID)
- ->select('Cnt', 'GameID')
- ->pluck('Cnt', 'GameID')->toArray();
- // 提现完成时间
- $info->finalTime = DB::connection('read')->table('QPAccountsDB.dbo.withdraw_notify')->where('user_id', $UserID)->orderByDesc('created_at')->value('finish_at');
- $accountsInfo=new AccountsInfo();
- $info->BankNO=$accountsInfo->sameBankNo($UserID);
- $info->sameWithDrawName=$accountsInfo->sameWithDrawBankNameByUserID($UserID);
- $info->sameWithDrawMail=$accountsInfo->sameWithDrawEmailByUserID($UserID);
- // 用户标签
- $getUserTab = StoredProcedure::getUserTab($UserID);
- $TabType = $getUserTab[0]->TabType ?? '';
- if (!empty($getUserTab) && $TabType == 1) {
- $Type12 = $getUserTab[0]->Type12 ?? 0;
- $userTab = DB::connection('read')->table('QPAccountsDB.dbo.AccountsTabExplain as el')
- ->where('TabID', $Type12)
- ->first()->TypeName;
- }
- return view('admin.Withdrawal.risk_assessment', [
- 'info' => $info,
- 'gear' => $gear,
- 'userTab' => $userTab ?? '',
- 'gameCount' => $gameCount,
- 'gameName'=>config("games.gameName")
- ]);
- }
- // 数据查重
- public function duplicate_checking(Request $request)
- {
- $type = $request->type ?: '';
- $val = $request->val ?: '';
- $list = [];
- switch ($type) {
- case 'RegisterIP':
- $type = '注册IP';
- $list = DB::table('QPAccountsDB.dbo.AccountsInfo')
- ->where('RegisterIP', $val)
- ->where('IsAndroid', 0)
- ->select('GameID', 'UserID')
- ->get();
- break;
- case 'BankNo':
- $type = '卡号';
- $list = DB::table('QPAccountsDB.dbo.AccountWithDrawInfo as di')
- ->join('QPAccountsDB.dbo.AccountsInfo as ai', 'di.UserID', 'ai.UserID')
- ->select('ai.GameID', 'ai.UserID')
- ->where('di.BankNo', $val)
- ->where('IsAndroid', 0)
- ->get();
- break;
- case 'LastLogonIP':
- $type = '登录IP';
- $list = DB::table('QPAccountsDB.dbo.AccountsInfo')
- ->where('LastLogonIP', $val)
- ->where('IsAndroid', 0)
- ->select('GameID', 'UserID')
- ->get();
- break;
- }
- return view('admin.Withdrawal.duplicate_checking', ['list' => $list, 'type' => $type]);
- }
- // 添加备注
- public function remarks(Request $request, $id)
- {
- $remark = $request->remark ?: '';
- $type = $request->type ?: 1;
- $admin_id = session('admin')->id;
- $RecordData = [
- 'admin_id' => $admin_id,
- 'remarks' => $remark,
- 'RecordID' => $id,
- 'create_at' => date('Y-m-d H:i:s'),
- 'update_at' => date('Y-m-d H:i:s'),
- 'type' => $type
- ];
- DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')->updateOrInsert(['RecordID' => $id, 'type' => $type], $RecordData);
- return apiReturnSuc();
- }
- // 提现回收
- public function recovery($id)
- {
- $admin_id = session('admin')->id;
- $first = DB::table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $id)
- ->select('UserID', 'WithDraw', 'State', 'ServiceFee', 'OrderId', 'RecordID', 'locking')
- ->first();
- if (!$first) {
- return apiReturnFail('订单不存在');
- }
- if ($first->State != 1) {
- return apiReturnFail('订单重复操作');
- }
- // 添加提现回收数据
- $data = [
- 'UserID' => $first->UserID,
- 'WithDraw' => $first->WithDraw,
- 'ServiceFee' => $first->ServiceFee,
- 'OrderId' => $first->OrderId,
- 'admin_id' => $admin_id
- ];
- // DB::table('QPAccountsDB.dbo.WithDrawRecovery')->insert($data);
- // 添加提现记录
- $RecordData = [
- 'admin_id' => $admin_id,
- 'before_state' => $first->State,
- 'after_state' => 4,
- 'RecordID' => $first->RecordID,
- 'create_at' => date('Y-m-d H:i:s'),
- 'update_at' => date('Y-m-d H:i:s')
- ];
- // 添加用户提现操作记录
- DB::table('QPAccountsDB.dbo.AccountsRecord')->updateOrInsert(['RecordID' => $first->RecordID, 'type' => 1], $RecordData);
- // 修改订单状态
- DB::table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $first->RecordID)
- ->update(['State' => 4, 'locking' => 0]);
- // 发送邮件
- // $TitleString = 'Your withdrawal order application failed';
- // $TextString = "1.Your withdrawal order: {$first->OrderId} application failed.
- // 2.Reasons for order submission failure:The system has detected malicious cheating on your account and recovered your chips
- // 3.If you have any questions, please contact customer service.
- // ";
- PrivateMail::RecoveryMail($first->UserID,$first->OrderId);
- return apiReturnSuc();
- }
- // 锁定订单
- public function locking($id)
- {
- $first = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $id)->first();
- if (!$first) {
- return apiReturnFail('订单不存在!');
- }
- if ($first->locking == 1) { // 解锁
- DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $id)
- ->update(['locking' => 0]);
- } else { // 加锁
- DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $id)
- ->update(['locking' => 1]);
- }
- return apiReturnSuc();
- }
- // 提现免审
- public function exempt_review()
- {
- $list = DB::connection('read')->table('agent.dbo.withdrawal_position_config as wp')
- ->leftJoin('agent.dbo.admin_configs as cf', function ($join) {
- $join->on('cf.config_value', '=', 'wp.agent');
- $join->where('cf.type', 'cash');
- })
- ->select('wp.*', 'cf.name as agent_name')
- ->paginate(10);
- foreach ($list as $value) {
- // $value->quota = $value->quota / NumConfig::NUM_VALUE;
- // $value->total_quota = $value->total_quota / NumConfig::NUM_VALUE;
- $value->useQuota = DB::connection('read')->table('agent.dbo.withdrawal_position_log')
- ->whereDate('create_at', date('Y-m-d'))
- ->where('config_id', $value->id)
- ->sum('use_quota') / NumConfig::NUM_VALUE;
- }
- return view('admin.Withdrawal.exempt_review', [
- 'list' => $list,
- ]);
- }
- // 免审添加
- public function exempt_review_add(Request $request)
- {
- if ($request->isMethod('get')) {
- $agent = DB::table('agent.dbo.admin_configs')
- ->where('type', 'cash')
- ->where('status', 1)
- ->get();
- return view('admin.Withdrawal.exempt_review_add', [
- 'agent' => $agent
- ]);
- } else {
- $admin_id = session('admin')['id'];
- $post = $request->all();
- if (isset($post['recharge_checkbox'])) {
- $first = DB::table('agent.dbo.withdrawal_position_config')
- ->where('recharge_min', '>=', $post['recharge_min'])
- ->where('recharge_max', '<=', $post['recharge_max'])
- ->first();
- if ($first) {
- return apiReturnFail('已有重复的充值额度档位!');
- }
- }
- $data = [
- 'name' => $post['name'],
- 'recharge_min' => $post['recharge_min'],
- 'recharge_max' => $post['recharge_max'],
- 'type' => $post['type'],
- 'quota' => $post['quota'] ?: 0,
- 'total_quota' => $post['total_quota'],
- 'admin_id' => $admin_id,
- 'status' => $post['status'],
- 'agent' => $post['agent'],
- 'draw_gt_recharge' => $post['draw_gt_recharge'],
- 'draw_total' => $post['draw_total'],
- 'draw_bi' => $post['draw_bi'],
- 'game_time' => $post['game_time'] * 60, // 小时转换分
- 'recharge_checkbox' => isset($post['recharge_checkbox']) ? 1 : 0 // 小时转换分
- ];
- DB::table('agent.dbo.withdrawal_position_config')->insert($data);
- return apiReturnSuc();
- }
- }
- // 免审修改
- public function exempt_review_update(Request $request, $id)
- {
- if ($request->isMethod('get')) {
- // 获取所有代付渠道配置(包括关闭的)
- $agent = DB::table('agent.dbo.admin_configs')
- ->where('type', 'cash')
- ->get();
- $info = DB::table('agent.dbo.withdrawal_position_config')->find($id);
- $info->game_time = $info->game_time > 0 ? $info->game_time / 60 : 0;
- return view('admin.Withdrawal.exempt_review_update', [
- 'info' => $info,
- 'agent' => $agent
- ]);
- } else {
- $admin_id = session('admin')['id'];
- $post = $request->all();
- if (isset($post['recharge_checkbox'])) {
- $first = DB::table('agent.dbo.withdrawal_position_config')
- ->where('recharge_min', '>=', $post['recharge_min'])
- ->where('recharge_max', '<=', $post['recharge_max'])
- ->first();
- if ($first && $id != $first->id) {
- return apiReturnFail('已有重复的充值额度档位!');
- }
- }
- $data = [
- 'name' => $post['name'],
- 'recharge_min' => $post['recharge_min'],
- 'recharge_max' => $post['recharge_max'],
- 'type' => $post['type'],
- 'quota' => $post['quota'] ?: 0,
- 'total_quota' => $post['total_quota'],
- 'admin_id' => $admin_id,
- 'status' => $post['status'],
- 'draw_gt_recharge' => $post['draw_gt_recharge'],
- 'draw_total' => $post['draw_total'],
- 'draw_bi' => $post['draw_bi'],
- 'game_time' => $post['game_time'] * 60, // 小时转换分
- 'recharge_checkbox' => isset($post['recharge_checkbox']) ? 1 : 0
- ];
- DB::table('agent.dbo.withdrawal_position_config')->where('id', $id)->update($data);
- return apiReturnSuc();
- }
- }
- // 提现渠道配置(新增和修改权重)
- public function cashier_channel_config(Request $request)
- {
- if ($request->isMethod('get')) {
- // 获取所有提现渠道
- $list = DB::table('agent.dbo.admin_configs')
- ->leftJoin('agent.dbo.admin_users as u', 'admin_configs.admin_id', '=', 'u.id')
- ->select('admin_configs.*', 'u.account')
- ->where('admin_configs.type', 'cash')
- ->orderBy('admin_configs.id', 'asc')
- ->get();
-
- return view('admin.Withdrawal.cashier_channel_config', ['list' => $list]);
- } else {
- // POST 提交 - 修改权重
- $validator = Validator::make($request->all(), [
- 'config.*.sort' => 'required|int',
- 'config.*.status' => 'required|in:1,-1',
- ]);
-
- if ($validator->fails()) {
- return apiReturnFail($validator->errors()->first());
- }
-
- $config = $request->input('config');
-
- // 验证权重总和
- $opened = array_filter($config, function ($item) {
- return $item['status'] == 1;
- });
-
- if (empty($opened)) {
- return apiReturnFail('至少需要开启一个提现渠道');
- }
-
- if (array_sum(array_column($opened, 'sort')) != 100) {
- return apiReturnFail('权重值分配不正确,开启的渠道权重总和必须为100');
- }
-
- // 更新配置
- foreach ($config as $id => $v) {
- $v['admin_id'] = session('admin')['id'];
- $v['updated_at'] = date('Y-m-d H:i:s');
- if ($v['status'] == -1) {
- $v['sort'] = 0;
- }
- DB::table('agent.dbo.admin_configs')->where('id', $id)->update($v);
- }
-
- return apiReturnSuc();
- }
- }
-
- // 新增提现渠道
- public function cashier_channel_add(Request $request)
- {
- if ($request->isMethod('get')) {
- return view('admin.Withdrawal.cashier_channel_add');
- } else {
- // POST 提交
- $validator = Validator::make($request->all(), [
- 'name' => 'required',
- 'config_value' => 'required',
- 'status' => 'required|in:1,-1',
- ]);
-
- if ($validator->fails()) {
- return apiReturnFail($validator->errors()->first());
- }
-
- // 获取最大ID
- $maxId = DB::table('agent.dbo.admin_configs')->max('id');
-
- $data = [
- 'id' => $maxId + 1,
- 'name' => $request->name,
- 'config_key' => $request->config_key ?: $request->name,
- 'config_value' => $request->config_value,
- 'type' => 'cash',
- 'status' => $request->status,
- 'sort' => (int)($request->sort ?: 0),
- 'remarks' => $request->remarks ?: '',
- 'admin_id' => session('admin')['id'],
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s'),
- ];
-
- try {
- DB::table('agent.dbo.admin_configs')->insert($data);
- return apiReturnSuc();
- } catch (\Exception $e) {
- return apiReturnFail('添加失败:' . $e->getMessage());
- }
- }
- }
-
- // 修改提现渠道
- public function cashier_channel_update(Request $request, $id)
- {
- if ($request->isMethod('get')) {
- $info = DB::table('agent.dbo.admin_configs')
- ->where('id', $id)
- ->where('type', 'cash')
- ->first();
-
- if (!$info) {
- return redirect()->back()->with('error', '渠道不存在');
- }
-
- return view('admin.Withdrawal.cashier_channel_update', ['info' => $info]);
- } else {
- // POST 提交
- $validator = Validator::make($request->all(), [
- 'name' => 'required',
- 'config_value' => 'required',
- 'status' => 'required|in:1,-1',
- ]);
-
- if ($validator->fails()) {
- return apiReturnFail($validator->errors()->first());
- }
-
- $data = [
- 'name' => $request->name,
- 'config_key' => $request->config_key ?: $request->name,
- 'config_value' => $request->config_value,
- 'status' => $request->status,
- 'sort' => (int)($request->sort ?: 0),
- 'remarks' => $request->remarks ?: '',
- 'admin_id' => session('admin')['id'],
- 'updated_at' => date('Y-m-d H:i:s'),
- ];
-
- try {
- DB::table('agent.dbo.admin_configs')
- ->where('id', $id)
- ->where('type', 'cash')
- ->update($data);
- return apiReturnSuc();
- } catch (\Exception $e) {
- return apiReturnFail('修改失败:' . $e->getMessage());
- }
- }
- }
- // 免审开关
- public function block(Request $request, $id)
- {
- $status = $request->status ?: '';
- if (empty($status)) {
- return apiReturnFail('参数错误!');
- }
- DB::table('agent.dbo.withdrawal_position_config')->where('id', $id)->update(['status' => $status]);
- return apiReturnSuc();
- }
- // 用户提充统计
- public function userWithdrawalStatistics(Request $request)
- {
- $date = $request->date ?: date('Y-m-d');
- $excel = $request->excel ?: 0;
- $gameID = $request->GameID ?: '';
- $channel = $request->Channel ?: '';
- [$list, $channelList] = $this->logic->userWithdrawalStatistics($date, $excel, $gameID, $channel);
- return view('admin.Withdrawal.userWithdrawalStatistics', compact('list', 'channelList', 'date', 'gameID','channel'));
- }
- // 回调补偿
- public function compensateNotify($RecordID, Request $request)
- {
- $redisKey = 'Withdrawal_compensateNotify_'.$RecordID;
- $res = SetNXLock::getExclusiveLock($redisKey, 5);
- if (!$res) {
- return apiReturnFail('操作频繁');
- }
- $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $RecordID)
- ->first();
- if (!$withdrawOrder) {
- SetNXLock::release($redisKey);
- return apiReturnFail('订单不存在');
- }
- if ($withdrawOrder->State != 5 && $withdrawOrder->State != 7) {
- SetNXLock::release($redisKey);
- return apiReturnFail('订单状态不正确, 请刷新页面重试');
- }
- Log::info('提现模拟回调', [
- 'recordID' => $RecordID,
- 'params' => $request->all()
- ]);
- /** @var WithdrawalLogic $logic */
- $logic = app()->make(WithdrawalLogic::class);
- $res = $logic->compensateNotify($withdrawOrder);
- SetNXLock::release($redisKey);
- if ($res) {
- return apiReturnSuc();
- }
- return apiReturnFail('修改失败');
- }
- public function monitorOrderFailCall($OrderID, Request $request)
- {
- $redisKey = 'Withdrawal_monitorOrderFailCall_' . $OrderID;
- $res = SetNXLock::getExclusiveLock($redisKey, 5);
- if (!$res) {
- return apiReturnFail('操作频繁');
- }
- $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('OrderId', $OrderID)
- ->first();
- if (!$withdrawOrder) {
- SetNXLock::release($redisKey);
- return apiReturnFail('订单不存在');
- }
- if ($withdrawOrder->State != 5 && $withdrawOrder->State != 7) {
- SetNXLock::release($redisKey);
- return apiReturnFail('订单状态不正确, 请刷新页面重试');
- }
- Log::info('提现手动设置失败', [
- 'OrderID' => $OrderID,
- 'params' => $request->all()
- ]);
- $agent = $withdrawOrder->agent;
- $TakeMoney = $withdrawOrder->WithDraw + $withdrawOrder->ServiceFee;
- $msg = (new CashierMessage())
- ->returnMsg($agent)
- ->msgStr('Encomenda rejeitada pelo banco');
- $bonus = '30000,' . $TakeMoney;
- PrivateMail::failMail($withdrawOrder->UserID, $OrderID, $TakeMoney, $msg, $bonus);
- // 修改订单状态为失败
- $withdraw_data = ['State' => 6, 'agent' => $agent];
- $notify_data = ['state' => 2];
- $RecordData = [
- 'before_state' => $withdrawOrder->State,
- 'after_state' => $withdraw_data['State'] ?? 0,
- 'RecordID' => $withdrawOrder->RecordID,
- 'update_at' => date('Y-m-d H:i:s')
- ];
- // 添加用户提现操作记录
- DB::connection('write')->table('QPAccountsDB.dbo.AccountsRecord')->updateOrInsert(['RecordID' => $withdrawOrder->RecordID, 'type' => 1], $RecordData);
- DB::connection('write')->table('QPAccountsDB.dbo.withdraw_notify')->updateOrInsert(['order_sn' => $OrderID], $notify_data);
- DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('OrderId', $withdrawOrder->OrderId)->update($withdraw_data);
- if (isset($withdraw_data['State']) && $withdraw_data['State'] == 2) {
- // 单控标签
- StoredProcedure::user_label($withdrawOrder->UserID, 2, $TakeMoney);
- // 渠道后台埋点
- (new LogDayStatisticalByDayAndChannel())->updateData($withdrawOrder->UserID, 2);
- }
- SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- public function drawBaseChangeLog(Request $request)
- {
- $query = AddDrawBase::query();
- if ($request->input('GameID')) {
- $userID = AccountsInfo::where('GameID', $request->input('GameID'))->value('UserID');
- $query->where('user_id', intval($userID));
- }
- $officials = DB::table('QPAccountsDB.dbo.IDWhiteUser')->pluck('UserID')->toArray();
- $list = $query->orderBy('id', 'desc')->paginate(20);
- return view('admin.Withdrawal.draw_base_change_log', [
- 'list' => $list,
- 'request' => $request,
- 'officials' => $officials
- ]);
- }
- // 回调补偿
- public function initData($RecordID, Request $request)
- {
- $redisKey = 'Withdrawal_init_'.$RecordID;
- $res = SetNXLock::getExclusiveLock($redisKey, 5);
- if (!$res) {
- return apiReturnFail('操作频繁');
- }
- $withdrawOrder = DB::table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', $RecordID)
- ->first();
- if (!$withdrawOrder) {
- SetNXLock::release($redisKey);
- return apiReturnFail('订单不存在');
- }
- DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $withdrawOrder->RecordID)
- ->update(['State' => 1,'OrderId' => $withdrawOrder->OrderId.rand(1,9)]);
- SetNXLock::release($redisKey);
- return apiReturnSuc();
- }
- /**
- * 同步最新提款账号信息
- * 只针对第三方订单失败(State=6)且金额小于30的订单
- */
- public function syncAccountInfo(Request $request, $RecordID)
- {
- try {
- // 获取订单信息
- $order = DB::connection('read')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $RecordID)
- ->first();
- if (!$order) {
- return apiReturnFail('订单不存在');
- }
- // 检查订单状态和金额
- if ($order->State != 6) {
- return apiReturnFail('只能同步第三方订单失败的订单');
- }
- // 金额小于30(WithDraw字段是decimal(10,2),所以30就是30.00)
- if ($order->WithDraw >= 3000) {
- return apiReturnFail('只能同步金额小于30的订单');
- }
- // 获取最新的账号信息
- $latestInfo = DB::connection('read')->table('QPAccountsDB.dbo.AccountWithDrawInfo')
- ->where('UserID', $order->UserID)
- ->first();
- if (!$latestInfo) {
- return apiReturnFail('用户账号信息不存在');
- }
- // 比较需要同步的字段
- $fieldsToCompare = [
- 'BankUserName',
- 'EmailAddress',
- 'PhoneNumber',
- 'PixNum',
- 'PixType',
- 'BankNO',
- 'AccountsBank',
- 'IFSCNumber',
- 'PANNumber',
- 'AdhaarNumber',
- 'BranchBank'
- ];
- $isSame = true;
- $updateData = [];
- foreach ($fieldsToCompare as $field) {
- $orderValue = trim($order->$field ?? '');
- $latestValue = trim($latestInfo->$field ?? '');
- if ($orderValue !== $latestValue) {
- $isSame = false;
- $updateData[$field] = $latestValue;
- }
- }
- // 如果信息一致,返回失败
- if ($isSame) {
- return apiReturnFail('账号信息一致,无需同步');
- }
- // 更新订单信息
- DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $RecordID)
- ->update($updateData);
- return apiReturnSuc(['updated_fields' => array_keys($updateData)], '同步成功');
- } catch (\Exception $e) {
- Log::error('同步账号信息失败', [
- 'RecordID' => $RecordID,
- 'error' => $e->getMessage()
- ]);
- return apiReturnFail('同步失败:' . $e->getMessage());
- }
- }
- /**
- * 获取订单账号信息(用于编辑)
- */
- public function getAccountInfo($RecordID)
- {
- try {
- $order = DB::connection('read')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $RecordID)
- ->first();
- if (!$order) {
- return apiReturnFail('订单不存在');
- }
- // 检查订单状态
- if ($order->State != 6) {
- return apiReturnFail('只能编辑失败订单的账号信息');
- }
- return apiReturnSuc([
- 'RecordID' => $order->RecordID,
- 'UserID' => $order->UserID,
- 'BankUserName' => $order->BankUserName ?? '',
- 'EmailAddress' => $order->EmailAddress ?? '',
- 'PhoneNumber' => $order->PhoneNumber ?? '',
- 'PixNum' => $order->PixNum ?? '',
- 'PixType' => $order->PixType ?? 0,
- 'BankNO' => $order->BankNO ?? '',
- 'AccountsBank' => $order->AccountsBank ?? '',
- 'IFSCNumber' => $order->IFSCNumber ?? '',
- 'PANNumber' => $order->PANNumber ?? '',
- 'AdhaarNumber' => $order->AdhaarNumber ?? '',
- 'BranchBank' => $order->BranchBank ?? '',
- ]);
- } catch (\Exception $e) {
- Log::error('获取订单账号信息失败', [
- 'RecordID' => $RecordID,
- 'error' => $e->getMessage()
- ]);
- return apiReturnFail('获取信息失败:' . $e->getMessage());
- }
- }
- /**
- * 更新订单账号信息(同时更新OrderWithDraw和AccountWithDrawInfo)
- */
- public function updateAccountInfo(Request $request, $RecordID)
- {
- try {
- $validator = Validator::make($request->all(), [
- 'BankUserName' => 'nullable|string|max:100',
- 'EmailAddress' => 'nullable|string|max:80',
- 'PhoneNumber' => 'nullable|string|max:20',
- 'PixNum' => 'nullable|string|max:32',
- 'PixType' => 'nullable|integer|in:0,1,2,3',
- 'BankNO' => 'nullable|string|max:30',
- 'AccountsBank' => 'nullable|string|max:100',
- 'IFSCNumber' => 'nullable|string|max:20',
- 'PANNumber' => 'nullable|string|max:10',
- 'AdhaarNumber' => 'nullable|string|max:80',
- 'BranchBank' => 'nullable|string|max:100',
- ]);
- if ($validator->fails()) {
- return apiReturnFail($validator->errors()->first());
- }
- // 获取订单信息
- $order = DB::connection('read')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $RecordID)
- ->first();
- if (!$order) {
- return apiReturnFail('订单不存在');
- }
- // 检查订单状态
- if ($order->State != 6) {
- return apiReturnFail('只能编辑失败订单的账号信息');
- }
- // 准备更新数据
- $updateData = [];
- $fields = [
- 'BankUserName', 'EmailAddress', 'PhoneNumber', 'PixNum', 'PixType',
- 'BankNO', 'AccountsBank', 'IFSCNumber', 'PANNumber', 'AdhaarNumber', 'BranchBank'
- ];
- foreach ($fields as $field) {
- if ($request->has($field)) {
- $updateData[$field] = trim($request->input($field, ''));
- }
- }
- if (empty($updateData)) {
- return apiReturnFail('没有需要更新的数据');
- }
- DB::beginTransaction();
- try {
- // 更新 OrderWithDraw 表
- DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')
- ->where('RecordID', $RecordID)
- ->update($updateData);
- // 更新 AccountWithDrawInfo 表
- DB::connection('write')->table('QPAccountsDB.dbo.AccountWithDrawInfo')
- ->where('UserID', $order->UserID)
- ->update($updateData);
- DB::commit();
- // 记录操作日志
- $admin_id = session('admin')->id ?? 0;
- (new AccountsRecordLogic())->create_record($RecordID, $order->State, $order->State, '编辑提款账号信息', $admin_id, 2);
- return apiReturnSuc(['updated_fields' => array_keys($updateData)], '更新成功');
- } catch (\Exception $e) {
- DB::rollBack();
- throw $e;
- }
- } catch (\Exception $e) {
- Log::error('更新订单账号信息失败', [
- 'RecordID' => $RecordID,
- 'error' => $e->getMessage(),
- 'data' => $request->all()
- ]);
- return apiReturnFail('更新失败:' . $e->getMessage());
- }
- }
- public function withdrawRank(Request $request)
- {
- $date = Carbon::now();
- $start_time = $request->input('start_time', $date->format('Y-m-d'));
- $end_time = $request->input('end_time', $date->format('Y-m-d'));
- $where = [];
- !empty($start_time) && $where[] = ['DateID', '>=', Carbon::parse($start_time)->format('Ymd')];
- !empty($end_time) && $where[] = ['DateID', '<', Carbon::parse($end_time)->addDay(1)->format('Ymd')];
- $order_sql = 'Withdraw DESC';
- if (true) {
- $list = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
- ->where('Withdraw', '>', 0)
- ->where($where)
- ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ds.UserID', 'ai.UserID')
- ->leftjoin('QPAccountsDB.dbo.AccountPhone as ap', 'ds.UserID', 'ap.UserID')
- ->select('ai.UserID', 'ai.GameID', 'ai.NickName', 'ai.Channel', 'ap.PhoneNum', 'ai.PlayTimeCount', 'ai.LastLogonDate', 'ai.RegisterDate')
- ->orderByRaw($order_sql)
- ->paginate(10);
- $rechargeSum = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as ds')
- ->where('Withdraw', '>', 0)
- ->where($where)
- ->selectRaw('sum(ds.Withdraw) Withdraw,UserID')
- ->groupBy('UserID')
- ->pluck('Withdraw', 'UserID')->toArray();
- $UserIDs = [];
- foreach ($list as $value) {
- $UserIDs[] = $value->UserID;
- }
- foreach ($list as $key => &$value) {
- $second = $value->PlayTimeCount;
- $day = floor($second / (3600 * 24));
- $second = $second % (3600 * 24);//除去整天之后剩余的时间
- $hour = floor($second / 3600);
- $second = $second % 3600;//除去整小时之后剩余的时间
- $minute = floor($second / 60);
- //返回字符串
- $value->Experience = $day . '天' . $hour . '小时' . $minute . '分';
- $value->type = '玩家';
- $value->rank = $key + 1;
- $value->money = $rechargeSum[$value->UserID] ?? 0;
- $value->money = $value->money /100;
- $value->time = Carbon::parse(now())->diffInDays($value->LastLogonDate, true);
- }
- return view('admin.Withdrawal.rank', [
- 'list' => $list,
- 'end_time' => $end_time,
- 'start_time' => $start_time,
- ]);
- }
- }
- public function nameStatics(){
- // DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
- // ->selectRaw('count(distinct (UserID)) as nums,BankUserName')
- // ->groupBy("BankUserName")
- // ->orderBy("nums","desc");
- $sql = "select nums,BankUserName from (select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName ) s where nums>1";
- // $sql = "select * from OrderWithDraw where BankUserName in (select BankUserName from (select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName ) s where nums>1) order by BankUserName";
- $multiNames = DB::select($sql);
- $sql="select nums,EmailAddress from (select count(distinct (UserID)) as nums,EmailAddress from QPAccountsDB.dbo.OrderWithDraw group by EmailAddress ) s where nums>1";
- $multiEmails = DB::select($sql);
- // $res=DB::table(TableName::QPAccountsDB() . 'OrderWithDraw')
- // ->selectRaw('count(distinct (UserID)) as nums')
- // ->where("EmailAddress","ciceroedsondasilvasantos19@gmail.com")
- // ->first();
- // print_r($res)
- return view('admin.Withdrawal.statics', [
- 'names' => $multiNames,
- 'emails' => $multiEmails,
- ]);
- // select count(distinct (UserID)) as nums,BankUserName from QPAccountsDB.dbo.OrderWithDraw group by BankUserName order by nums desc;
- }
- }
|