posts); foreach ($posts as $post){ $post=$toArr = \GuzzleHttp\json_decode($post, true); $logic = new CashPayLogic(); try { $logic->notify($post); }catch (\Exception $exception){ Util::WriteLog("testerror",$post); // return "fail"; } } echo "hhah";die; return "hahah"; } protected $PhonePrefix = [91, 31, 47, 11, 61, 27]; public function failedValidation(Validator $validator): void { dd($validator->errors()->first()); } public function getDateFromRange($startdate, $enddate) { $stimestamp = strtotime($startdate); $etimestamp = strtotime($enddate); // 计算日期段内有多少天 $days = ($etimestamp - $stimestamp) / 86400 + 1; // 保存每天日期 $date = array(); for ($i = 0; $i < $days; $i++) { $date[] = date('Y-m-d', $stimestamp + (86400 * $i)); } return $date; } public function dateDiff($a, $b) { $datetime_start = date_create(date('Y-m-d', strtotime($a, 1))); $datetime_end = date_create(date('Y-m-d', strtotime($b))); $days = date_diff($datetime_start, $datetime_end)->days; return $days; } public function todayLottery($date) { $ChannelLottery = DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordUserScoreChange as rc') ->whereDate('UpdateTime', $date) ->whereIn('Reason', [21, 33, 36, 37, 42, 44, 45, 49, 51, 52, 72]) ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ai.UserID', 'rc.UserID') ->selectRaw('Isnull(SUM(ChangeScore),0) as ChangeScore,Channel') ->groupBy('Channel') ->get(); return $ChannelLottery; } protected function xiugai() { $date = Carbon::parse('2022-04-02'); $dateID = $date->format('Ymd'); $dao = new \App\dao\RecordPlatformData\RecordPlatformData(); // 申请提现金额,申请人数,申请笔数 $OrderWithDraw = $dao->ApplyWithDraw($date); // 总申请提现金额 $TotalOrderWithDraw = $dao->TotalOrderWithDraw($date); // 提现成功的手续费 $ServiceFee = $dao->WithDrawOkFree($dateID); // 游戏人数 $GameUserCounts = $dao->GameUserCount($dateID); // 新增参游人数 $NewGameUserCounts = $dao->NewGameUserCount($date); // 赠送金币 ===== 增加赠送金币 // $GiveGolds = RecordScoreInfo::todayLottery($date->format('Y-m-d')); $GiveGolds = $this->todayLottery($date->format('Y-m-d')); $RecordPlatformDataModel = new \App\Models\RecordPlatformData(); $list = $RecordPlatformDataModel->where('DateID', $dateID)->where('Channel', '>=', 0)->get(); foreach ($list as $value) { if ($OrderWithDraw->isNotEmpty()) { foreach ($OrderWithDraw as $item) { $data = ['DateID' => $dateID, 'ApplyWithdraw' => $item->WithDraw, 'ApplyWithdrawCount' => $item->UserCount, 'ApplyWithdrawBi' => $item->CountBi]; // 申请提现渠道修改 $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } if ($ServiceFee->isNotEmpty()) { // 提现完成手续费渠道修改 foreach ($ServiceFee as $item) { $data = ['DateID' => $dateID, 'WithdrawFree' => $item->ServiceFee]; $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } // 游戏人数 if ($GameUserCounts->isNotEmpty()) { foreach ($GameUserCounts as $item) { $data = ['DateID' => $dateID, 'GameUserCount' => $item->UserCount]; $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } if ($GiveGolds->isNotEmpty()) { // 赠送金币 foreach ($GiveGolds as $item) { $data = ['DateID' => $dateID, 'GiveGold' => $item->ChangeScore]; $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } if ($NewGameUserCounts->isNotEmpty()) { // 新增游戏人数 foreach ($NewGameUserCounts as $item) { $data = ['DateID' => $dateID, 'NewGameUserCount' => $item->UserCount]; $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } $ARPU = $value->ActivePeple > 0 ? number_format(($value->PayTotal / $value->ActivePeple) / NumConfig::NUM_VALUE) : 0; $ARPPU = $value->PayPeple > 0 ? number_format(($value->PayTotal / $value->PayPeple) / NumConfig::NUM_VALUE) : 0; // 申请提现金额 、 人数 、 笔数 $ApplyWithdraw = $TotalOrderWithDraw->WithDraw ?? 0; $ApplyWithdrawCount = $TotalOrderWithDraw->UserCount ?? 0; $ApplyWithdrawBi = $TotalOrderWithDraw->CountBi ?? 0; // 提现成功手续费 $WithdrawFree = $ServiceFee->sum('ServiceFee'); $GameUserCount = $GameUserCounts->sum('UserCount'); $NewGameUserCount = $NewGameUserCounts->sum('UserCount'); $GiveGold = $GiveGolds->sum('ChangeScore'); $data = compact('ARPPU', 'ARPU', 'ApplyWithdraw', 'WithdrawFree', 'GameUserCount', 'NewGameUserCount', 'GiveGold', 'ApplyWithdrawBi', 'ApplyWithdrawCount'); // $RecordPlatformDataModel->where('DateID', $dateID)->where('Channel', -1)->update($data); } } public function ipCheck() { $ip = config('ipCheck'); $data = collect(json_decode($ip, true)); $ip = '152.235.129.83'; // split3[0] * 1000000000 + split3[1] * 1000000 + split3[2] * 1000 + parseInt(split3[3]); $explode = explode('.', $ip); if (count($explode) < 4) { return false; } $value = $explode[0] * 1000000000 + $explode[1] * 1000000 + $explode[2] * 1000 + (int)$explode[3]; $r = $data ->where('start', '<=', $value) ->where('end', '>=', $value) ->first(); if (empty($r)) { return false; } return true; } public function drawTest(Request $request) { $GameID = (int)$request->GameID; $WithDraw = (int)$request->WithDraw; $UserID = DB::table(TableName::QPAccountsDB() . 'AccountsInfo') ->where('GameID', $GameID) ->value('UserID'); if (empty($UserID)) return apiReturnFail('填写正确用户ID'); if (empty($WithDraw)) return apiReturnFail('缺少提现金额'); $logic = (new ExemptDraw()); $r = $logic->verify($UserID, $WithDraw * 100); if ($r === false) { return apiReturnFail($logic->getError()); } return apiReturnSuc($r); } public function test2() { return '222'; } // 发送http post 请求函数 function http_post_json($url, $jsonStr) { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json; charset=utf-8" , "Content-Length: " . strlen($jsonStr) ) ); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo "\n\n"; echo "响应httpCode=" . $httpCode; echo "\n\n"; echo "响应response=" . $response; echo "\n\n"; return array($httpCode, $response); } public function test3() { // 您的 商户号 $mchNo = "M1653138104"; // 您的 应用ID (AppId) $appId = "6288e2b884585fbd5121389e"; // 您的 代付回调地址 $notifyUrl = "http://8.129.91.11:801/api/winpay/notify"; // 您的 密钥 $secret = "osoQvtr8NwkH2GmzMUQVfYjTXwqnkNStWcPqc7Go2WG6un5RBgdS1Jb9tykKMqFDUbublxE8Imual2kGRNIeKjCqmPLhcDsK7UfaA2CurFJNcLBFFkkg7FIJXEHItipD"; // 代收接口 $url = "https://payy.winpay.biz/api/pay/pay"; // 请求数据 $reqData = [ "amount" => 300000, // 300000 实际等于 3000.00 "mchOrderNo" => "MPhpPayTest" . rand(11111111, 99999999), "wayCode" => "PAYY_WEB", "clientIp" => "210.73.10.148", "customerName" => utf8_encode("Joey"), "customerEmail" => "13800138000@gmail.com", "customerPhone" => "13800138000", "reqTime" => time(), "version" => "1.0", "appId" => $appId, "notifyUrl" => utf8_encode($notifyUrl), "signType" => "MD5", "currency" => "INR", "mchNo" => $mchNo, 'channelExtra' => '{"payType":"PIX"}' ]; //进行排序 ksort($reqData); $str = ""; foreach ($reqData as $k => $v) { $str .= "$k=$v&"; } $str .= "key=$secret"; echo "\n\n"; echo "请求数据排序" . $str; echo "\n\n"; //进行md5加密 $sign = strtoupper(md5($str)); echo "\n\n"; echo "请求数据排序后的签名=" . $sign; echo "\n\n"; // 将 请求数据签名 追加到 请求数据 $reqData["sign"] = $sign; // 将 请求数据数组 转化成 请求数据JSON $jsonStr = json_encode($reqData); echo "\n\n"; echo "请求数据体" . $jsonStr; echo "\n"; // 发送 请求数据JSON 到 代付接口 list($returnCode, $returnContent) = $this->http_post_json($url, $jsonStr); dd($returnCode, $returnContent); } public function _unsetNull($arr) { if ($arr !== null) { if (is_array($arr)) { if (!empty($arr)) { foreach ($arr as $key => $value) { if ($value === null) { $arr[$key] = ''; } else { $arr[$key] = $this->_unsetNull($value); //递归再去执行 } } } else { $arr = ''; } } else { if ($arr === null) { $arr = ''; } //注意三个等号 } } else { $arr = ''; } return $arr; } public function escapeJsonString($value) { $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); $result = str_replace($escapers, $replacements, $value); return $result; } public function test4($a) { $WithdrawalModel = new Withdrawal(); $OrderWithDraw = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw') ->where('State', 1) ->whereRaw('locking = 0') ->orderBy('CreateDate', 'desc') ->get(); dump($OrderWithDraw); foreach ($OrderWithDraw as $value) { if ($value->State != 1) continue; $recharge = DB::connection('write')->table('QPAccountsDB.dbo.YN_VIPAccount')->where('UserID', $value->UserID)->first(); // 如果没有充值过 if (!$recharge) { // 查询免审配置 $config = DB::connection('write')->table('agent.dbo.withdrawal_position_config') ->where('recharge_min', 0) ->where('recharge_max', 0) ->where('status', 1) ->first(); } else { // 充值过 // 查询免审配置 $config = DB::connection('write')->table('agent.dbo.withdrawal_position_config') ->where('recharge_min', '<=', (int)$recharge->Recharge) ->where('recharge_max', '>=', (int)$recharge->Recharge) ->where('status', 1) ->first(); } dump($config); if ($config) { $agent = $config->agent; if (empty($agent)) { // 默认第一家 $agent = DB::connection('write')->table('agent.dbo.admin_configs')->where('config_value', 1)->where('type', 'cash')->where('status', 1)->first()->config_value; } // 验证用户提现方式 $verifyAccountWithdrawal = $WithdrawalModel->AccountWithDrawInfo($value->UserID, $agent); if (!$verifyAccountWithdrawal) { Log::info('不支持的提现格式'); continue; } dump($verifyAccountWithdrawal); if ($config->type == 2) { // 倍数 -- 充值额度 * 倍数 $config->quota = (int)($recharge->Recharge * $config->quota); } // 该用户已经消耗的额度 -- 免审提现额度 -- (申请额度额外加) $use_quota = DB::connection('write')->table('agent.dbo.withdrawal_position_log') ->where('user_id', $value->UserID) //->where('take_effect', 1) ->whereDate('create_at', date('Y-m-d')) ->selectRaw('IsNull(sum(use_quota),0) use_quota') ->first()->use_quota; // 该配置已经消耗的全部额度 -- (申请额度额外加) $all_use_quota = DB::connection('write')->table('agent.dbo.withdrawal_position_log') ->selectRaw('IsNull(sum(use_quota),0) use_quota') ->where('config_id', $config->id) ->whereDate('create_at', date('Y-m-d')) //->where('take_effect', 1) ->first()->use_quota; // 原有额度 + 要提现的金额 $use_quota_after = ($value->WithDraw + $use_quota) / NumConfig::NUM_VALUE; $all_use_quota_after = ($value->WithDraw + $all_use_quota) / NumConfig::NUM_VALUE; dump('---------------------'); dump($use_quota_after); dump($all_use_quota_after); // dump($value->UserID); // dump($config->quota); // dump($config->total_quota); dump('===================================='); // 消耗额度 大于总额度的95%的时候 就人工审核 if ($use_quota_after < $config->quota && $all_use_quota_after < $config->total_quota) { dd(3333); } } dd('不存在'); } } public function affixation($date, $dateID) { $RecordPlatformDataModel = new \App\Models\RecordPlatformData(); $dao = new \App\dao\RecordPlatformData\RecordPlatformData(); // 申请提现金额,申请人数,申请笔数 $OrderWithDraw = $dao->ApplyWithDraw($date); // 总申请提现金额 $TotalOrderWithDraw = $dao->TotalOrderWithDraw($date); // 提现成功的手续费 $ServiceFee = $dao->WithDrawOkFree($dateID); // 游戏人数 $GameUserCounts = $dao->GameUserCount($dateID); // 新增参游人数 $NewGameUserCounts = $dao->NewGameUserCount($date); // 赠送金币 ===== 增加赠送金币 $GiveGolds = RecordScoreInfo::todayLottery($date->format('Y-m-d')); // 充值彩金 $RechargeWinnings = $dao->RechargeWinnings($dateID); // 分享彩金 $ShareWinnings = $dao->ShareWinnings($dateID); // 低保 $Dibao = $dao->Dibao($dateID); $list = $RecordPlatformDataModel->where('DateID', $dateID)->where('Channel', '>=', 0)->get(); foreach ($list as $value) { if (!empty($RechargeWinnings)) { // // 充值彩金 foreach ($RechargeWinnings as $item) { $data = ['DateID' => $dateID, 'RechargeWinnings' => $item->Score]; //$dao->Update($data, $value->Channel, $item->Channel, $dateID); } } if (!empty($ShareWinnings)) { // 分享彩金 foreach ($ShareWinnings as $item) { $data = ['DateID' => $dateID, 'ShareWinnings' => $item->Score]; // $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } if (!empty($Dibao)) { // 低保彩金 foreach ($Dibao as $item) { $data = ['DateID' => $dateID, 'Dibao' => $item->Score]; //$dao->Update($data, $value->Channel, $item->Channel, $dateID); } } $ARPU = $value->ActivePeple > 0 ? number_format(($value->PayTotal / $value->ActivePeple) / NumConfig::NUM_VALUE) : 0; $ARPPU = $value->PayPeple > 0 ? number_format(($value->PayTotal / $value->PayPeple) / NumConfig::NUM_VALUE) : 0; // 申请提现金额 、 人数 、 笔数 $ApplyWithdraw = $TotalOrderWithDraw->WithDraw ?? 0; $ApplyWithdrawCount = $TotalOrderWithDraw->UserCount ?? 0; $ApplyWithdrawBi = $TotalOrderWithDraw->CountBi ?? 0; // 提现成功手续费 $WithdrawFree = $ServiceFee->sum('ServiceFee'); $GameUserCount = $GameUserCounts->sum('UserCount'); $NewGameUserCount = $NewGameUserCounts->sum('UserCount'); $GiveGold = $GiveGolds->sum('ChangeScore'); $RechargeWinningsScore = $RechargeWinnings->sum('Score'); $ShareWinningsScore = $ShareWinnings->sum('Score'); $DibaoScore = $Dibao->sum('Score'); $data = compact('ARPPU', 'ARPU', 'ApplyWithdraw', 'WithdrawFree', 'GameUserCount', 'NewGameUserCount', 'GiveGold', 'ApplyWithdrawBi', 'ApplyWithdrawCount'); $data['RechargeWinnings'] = $RechargeWinningsScore; $data['ShareWinnings'] = $ShareWinningsScore; $data['Dibao'] = $DibaoScore; dd($data); } } public static function requestUrl($request_params) { $client = new Client(['http_errors' => false]); $res = $client->request($request_params['method'], $request_params['url'], [ 'json' => $request_params['params'], ]); $result = $res->getBody()->getContents(); // dd($result); $result = json_decode($result, true); if ($result['status'] == 200) { return $result; } dd('查询失败' . $result['message'], 'error'); return admin_toastr('查询失败' . $result['message'], 'error'); } /** * * @param Request $request * @deprecated * */ public function test(Request $request) { $r = app('account')->today_register(); dd($r); $r = (new AdRecharge())->attribute(8532,'2022-07-18 16:40:47.710',10,1); dd($r); $r = Carbon::parse('2022-07-18 01:00:00')->diff(now())->d; dd($r); $dates = $this->dateDiff('2022-07-14', '2022-07-18'); $date = 20220714; $dao = new \App\dao\RecordPlatformData\RecordPlatformData(); $RecordPlatformDataModel = new \App\Models\RecordPlatformData(); $list = $RecordPlatformDataModel->where('DateID', $date)->where('Channel', '>=', 0)->get(); // 低保 $Dibao = $dao->Dibao($date); foreach ($list as $value) { if ($Dibao->isNotEmpty()) { // 低保彩金 foreach ($Dibao as $item) { $data = ['DateID' => $date, 'Dibao' => $item->Score]; $dao->Update($data, $value->Channel, $item->Channel, $date); } } $DibaoScore = $Dibao->sum('Score'); $data['Dibao'] = $DibaoScore; $RecordPlatformDataModel->where('DateID', $date)->where('Channel', -1)->update($data); } dd(3333333); $AdChannel = 0; // 类别添加 $key = 'adChannel_' . $AdChannel; $redisConnect = (new RedisConnect())->redis(); // dump($key); // dd($redisConnect->exists($key)); if (!$redisConnect->exists($key)) { DB::table(TableName::agent() . 'account_source_class') ->insert([ 'ad_channel' => $AdChannel, 'Source' => 1111 ]); $redisConnect->set($key, $AdChannel); } return; // 查找某几个随机数字 1,3,5 $arr = array_flip($arr); $arr = collect($arr)->get(2)->prev(); dd($arr); DB::connection('write')->table('QPAccountsDB.dbo.YN_VIPAccount') ->where('UserID', 1) ->increment('Recharge', 10); $Source = ''; $AdChannel = 0; preg_match('/\*\d+/', $Source, $result); if (isset($result[0])) { $AdChannel = explode('*', $result[0])[1] ?? 0; } dd($AdChannel); $a = DB::table(TableName::QPRecordDB() . 'RecordPlatformData') ->where('DateID', '<', 20220713) ->whereIn('Channel', [100, 103, 101, 105, 99]) ->selectRaw('sum(PayTotal) PayTotal,sum(DrawTotal) - sum(WithdrawFree)') ->first(); $b = DB::table(TableName::QPRecordDB() . 'RecordPlatformData') ->where('DateID', '<', 20220713) ->where('Channel', 104) ->selectRaw('sum(PayTotal) PayTotal,sum(DrawTotal) - sum(WithdrawFree)') ->first(); $c = DB::table(TableName::QPRecordDB() . 'RecordPlatformData') ->where('DateID', '<', 20220713) ->where('Channel', 106) ->selectRaw('sum(PayTotal) PayTotal,sum(DrawTotal) - sum(WithdrawFree)') ->first(); $d = DB::table(TableName::QPRecordDB() . 'RecordPlatformData') ->where('DateID', '<', 20220713) ->where('Channel', 107) ->selectRaw('sum(PayTotal) PayTotal,sum(DrawTotal) - sum(WithdrawFree)') ->first(); dump($a); dump($b); dump($c); dd($d); $gameCount = (new GamesCount())->gameCount(7427); dd($gameCount); // $json = '{"data":{"amount":"10.00","orderNo":"20220711052458DF566606","message":"Fail","type":"payout","merchantOrderNo":"tx165703845090374930","processAmount":"0","status":"FAILURE"},"signature":"3ce30f9a4136e99bc2ffcd814eddbb90","signature_n":"e8ffdbc78d055301ccad5cc3bcedab7c"}'; // $data= \GuzzleHttp\json_decode($json,true); // $post = $data['data']; // $sign = $data['signature_n']; // dump($sign); // dd((new NutsPay())->md5Sign($post)); // $DateID = Carbon::yesterday()->format('Ymd'); // $DateID = Carbon::now()->format('Ymd'); // 昨天的提现用户,昨日提现多少,昨日充值多少,历史充值多少,历史提现多少 $list = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rn') ->where('DateID', $DateID) ->where('Withdraw', '>', 0) ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rn.UserID', 'ai.UserID') ->select('GameID', 'rn.UserID', 'Withdraw', 'Recharge') ->get(); $UserIDs = []; foreach ($list as $value) { $UserIDs[] = $value->UserID; } $total = DB::table(TableName::QPRecordDB() . 'RecordUserTotalStatistics') ->whereIn('UserID', $UserIDs) ->select('Withdraw', 'Recharge', 'UserID') ->get(); foreach ($list as &$value) { $value->Withdraw = number_float($value->Withdraw / 100); foreach ($total as $val) { if ($val->UserID == $value->UserID) { $value->HisWithdraw = number_float($val->Withdraw / 100); $value->HisRecharge = $val->Recharge; } } unset($value->UserID); } $title = ['会员ID', '今日提现', '今日充值', '历史提现', '历史充值']; $list = json_decode(json_encode($list), true); // downloadExcel($list, $title, '统计' . date('YmdHis')); // // dd('OK'); $query = DB::connection('write')->table('QPAccountsDB.dbo.OrderWithDraw')->where('RecordID', 51)->first(); $RecordID = $query->RecordID; $amount = $query->WithDraw; $accountName = $query->BankUserName; $email = $query->EmailAddress; $email = 'pagsmile_test_success@pagsmile.com'; $phone = $query->PhoneNumber; $PixNum = $query->PixNum; $PixType = $query->PixType; $OrderId = $query->OrderId; $IFSCNumber = $query->IFSCNumber; $BranchBank = $query->BranchBank; $BankNO = $query->BankNO; $r = (new NutsPayCashierLogic())->payment($RecordID, $amount, $accountName, $phone, $email, $OrderId, $PixNum, $PixType, $IFSCNumber, $BranchBank, $BankNO); dd($r); // 老用户充值 $carBob = Carbon::parse('20220524'); $date = $carBob->format('Y-m-d'); $dateID = $carBob->format('Ymd'); $oldRecharge = DB::connection('sqlsrv')->table(TableName::agent() . 'order as rn') ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rn.user_id', '=', 'ai.UserID') ->whereDate('pay_at', $date) ->whereDate('RegisterDate', '<', $date) ->selectRaw('sum(amount) Recharge,count(distinct(rn.user_id)) payCount,count(id) CountBi,Channel') ->groupBy('Channel') ->get(); // 当日注册,当日充值 $newRecharge = DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'AccountsInfo as ai') ->whereDate('RegisterDate', $date) ->join(TableName::agent() . 'order as rn', 'ai.UserID', '=', 'rn.user_id') ->whereDate('pay_at', $date) ->selectRaw('sum(amount) Recharge,count(distinct(rn.user_id)) payCount,count(id) CountBi,Channel') ->groupBy('Channel') ->get(); $dao = new \App\dao\RecordPlatformData\RecordPlatformData(); $list = DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData')->where('DateID', $dateID)->where('Channel', '>=', 0)->get(); foreach ($list as $value) { if ($oldRecharge->isNotEmpty()) { foreach ($oldRecharge as $item) { $data = ['DateID' => $dateID, 'OldUserPaySum' => (int)$item->Recharge, 'OldUserPayCount' => $item->payCount, 'OldUserPayBi' => $item->CountBi]; // 申请提现渠道修改 $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } if ($newRecharge->isNotEmpty()) { foreach ($newRecharge as $item) { $data = ['DateID' => $dateID, 'NewPayTotal' => (int)$item->Recharge, 'NewPayPeple' => $item->payCount, 'NewPayPepleBi' => $item->CountBi]; // 申请提现渠道修改 $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } } $oldRecharge = DB::connection('sqlsrv')->table(TableName::agent() . 'order as rn') ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rn.user_id', '=', 'ai.UserID') ->whereDate('pay_at', $date) ->whereDate('RegisterDate', '<', $date) // ->whereIn('rn.user_id', $userIDs) ->selectRaw('sum(amount) Recharge,count(distinct(rn.user_id)) payCount,count(id) CountBi') ->first(); $data = ['DateID' => $dateID, 'OldUserPaySum' => (int)$oldRecharge->Recharge, 'OldUserPayCount' => $oldRecharge->payCount, 'OldUserPayBi' => $oldRecharge->CountBi]; // 申请提现渠道修改 $dao->Update($data, -1, -1, $dateID); // 当日注册,当日充值 $newRecharge = DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'AccountsInfo as ai') ->whereDate('RegisterDate', $date) ->join(TableName::agent() . 'order as rn', 'ai.UserID', '=', 'rn.user_id') ->whereDate('pay_at', $date) ->selectRaw('sum(amount) Recharge,count(distinct(rn.user_id)) payCount,count(id) CountBi') ->first(); $data = ['DateID' => $dateID, 'NewPayTotal' => (int)$newRecharge->Recharge, 'NewPayPeple' => $newRecharge->payCount, 'NewPayPepleBi' => $newRecharge->CountBi]; $dao->Update($data, -1, -1, $dateID); dd(3333); // $redis = new RedisConnect(); // // $redis->redis()->zincrby('Channel_Fissile_'.date('Ymd'),2,100); // //// $redis->zadd('zset1', 3, 'wangwu'); // dd(1); $this->test3(); $mill_time = microtime(); $timeInfo = explode(' ', $mill_time); $milis_time = sprintf('%d%03d', $timeInfo[1], $timeInfo[0] * 1000); dd($milis_time); return PrivateMail::paySendMail(13308, '订单', 10, 10); // 增加用户金币变化记录 $bool = RecordScoreInfo::addScore(8832, (10 * 100), 1); #充值 if ($bool) { RecordScoreInfo::addScore(8832, (10 * 100), 45); #赠送彩金 } dd($bool); $AfterScore = DB::connection('read')->table('QPTreasureDB.dbo.GameScoreInfo') ->where('UserID', 8832) ->select('Score') ->lockForUpdate() ->first()->Score ?? 0; $RecordScoreInfo = [ 'BeforeScore' => $AfterScore, 'AfterScore' => 100, 'ChangeScore' => 100, 'UserID' => 8832, 'Reason' => 1, 'UpdateTime' => date('Y-m-d H:i:s'), ]; DB::connection('write')->table(TableName::QPRecordDB() . 'RecordUserScoreChange')->lockForUpdate()->insertGetId($RecordScoreInfo); dd($AfterScore); $c = (new RecordScoreInfo()); $a = (new RecordScoreInfo())->addScore(8832, 10, 1); #充值 $b = (new RecordScoreInfo())->addScore(8832, 20, 45); #赠送彩金 return; $dao = new \App\dao\RecordPlatformData\RecordPlatformData(); // $carBob = Carbon::parse(20220509); $date = $carBob->format('Y-m-d'); $dateID = $carBob->format('Ymd'); // // $draw = DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'OrderWithDraw as od') // ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'ai.UserID', 'od.UserID') // ->whereDate('finishDate', $date) // ->selectRaw('IsNull(sum(WithDraw),0) + IsNull(sum(ServiceFee),0) WithDraw,count(distinct(od.UserID)) UserCount,count(RecordID) CountBi,Channel') // ->groupBy('Channel') // ->get(); // $all = DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'OrderWithDraw as od') // ->whereDate('finishDate', $date) // ->selectRaw('IsNull(sum(WithDraw),0) + IsNull(sum(ServiceFee),0) WithDraw,count(distinct(od.UserID)) UserCount,count(RecordID) CountBi') // ->first(); // $dao = new \App\dao\RecordPlatformData\RecordPlatformData(); // $list = DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData')->where('DateID', $dateID)->where('Channel', '>=', 0)->get(); // // foreach ($list as $value) { // // if ($draw->isNotEmpty()) { // foreach ($draw as $item) { // $data = ['DateID' => $dateID, 'Channel' => $item->Channel, 'DrawUserCount' => (int)$item->UserCount, 'DrawBi' => $item->CountBi]; // // 申请提现渠道修改 // $dao->Update($data, $value->Channel, $item->Channel, $dateID); // } // } // // $data = ['DateID' => $dateID, 'Channel' => $all->Channel, 'DrawUserCount' => (int)$all->UserCount, 'DrawBi' => $all->CountBi]; // // 申请提现渠道修改 // $dao->Update($data, -1, -1, $dateID); // // } // // dump($all); // dd($draw); $newRecharge = DB::connection('sqlsrv')->table(TableName::QPAccountsDB() . 'AccountsInfo as ai') ->whereDate('RegisterDate', $date) ->join(TableName::agent() . 'order as rn', 'ai.UserID', '=', 'rn.user_id') ->whereDate('pay_at', $date) ->selectRaw('sum(amount) Recharge,count(distinct(rn.user_id)) payCount,count(id) CountBi,Channel') ->groupBy('Channel') ->get(); $userIDs = DB::connection('sqlsrv')->table(TableName::agent() . 'order') ->where('finished_at', '<', $date . ' 00:00:00') ->pluck('user_id')->toArray(); $oldRecharge = DB::connection('sqlsrv')->table(TableName::agent() . 'order as rn') ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rn.user_id', '=', 'ai.UserID') ->whereDate('pay_at', $date) ->whereIn('rn.user_id', $userIDs) ->selectRaw('sum(amount) Recharge,count(distinct(rn.user_id)) payCount,count(id) CountBi,Channel') ->groupBy('Channel') ->get(); // $RecordPlatformDataModel = new RecordPlatformData(); $dao = new \App\dao\RecordPlatformData\RecordPlatformData(); $list = DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData')->where('DateID', $dateID)->where('Channel', '>=', 0)->get(); foreach ($list as $value) { // if ($newRecharge->isNotEmpty()) { // foreach ($newRecharge as $item) { // $data = ['DateID' => $dateID, 'NewPayTotal' => (int)$item->Recharge, 'NewPayPeple' => $item->payCount, 'NewPayPepleBi' => $item->CountBi]; // // 申请提现渠道修改 // $dao->Update($data, $value->Channel, $item->Channel, $dateID); // } // } if ($oldRecharge->isNotEmpty()) { foreach ($oldRecharge as $item) { $data = ['DateID' => $dateID, 'OldUserPaySum' => (int)$item->Recharge, 'OldUserPayCount' => $item->payCount, 'OldUserPayBi' => $item->CountBi]; // 申请提现渠道修改 $dao->Update($data, $value->Channel, $item->Channel, $dateID); } } } dd(3333); // 当日注册,当日充值 $date = $this->getDateFromRange('2022-05-11', '2022-05-11'); foreach ($date as $item) { $dateID = date('Ymd', strtotime($item)); $newRecharge = DB::table(TableName::QPAccountsDB() . 'AccountsInfo as ai') ->whereDate('RegisterDate', $item) ->join(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rn', 'ai.UserID', 'rn.UserID') ->where('Recharge', '>', 0) ->where('DateID', $dateID) ->selectRaw('sum(Recharge) Recharge,count(ai.UserID) payCount,Channel') ->groupBy('Channel') ->get(); $NewRechargeBi = DB::table(TableName::QPAccountsDB() . 'AccountsInfo as ai') ->whereDate('RegisterDate', $item) ->join(TableName::agent() . 'order', 'ai.UserID', '=', 'order.user_id') ->whereDate('finished_at', $item) ->selectRaw('count(order.id) count,Channel') ->get(); foreach ($newRecharge as $value) { DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData') ->where('Channel', $value->Channel) ->updateOrInsert(['Channel' => $value->Channel, 'DateID' => $dateID], ['Channel' => $value->Channel, 'DateID' => $dateID, 'NewPayPeple' => $value->payCount, 'NewPayTotal' => $value->Recharge * 100]); } foreach ($NewRechargeBi as $value) { DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData') ->where('Channel', $value->Channel) ->updateOrInsert(['Channel' => $value->Channel, 'DateID' => $dateID], ['Channel' => $value->Channel, 'DateID' => $dateID, 'NewPayPepleBi' => $value->count]); } $userIDs = DB::table(TableName::agent() . 'order') ->where('finished_at', '<', $item . ' 00:00:00') ->pluck('user_id')->toArray(); $oldRecharge = DB::table(TableName::QPRecordDB() . 'RecordUserDataStatisticsNew as rn') ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'rn.UserID', 'ai.UserID') ->where('DateID', date('Ymd', strtotime($item))) ->where('Recharge', '>', 0) ->whereIn('rn.UserID', $userIDs) ->selectRaw('sum(Recharge) Recharge,count(rn.UserID) payCount,Channel') ->get(); $oldRechargeBi = DB::table(TableName::agent() . 'order') ->join(TableName::QPAccountsDB() . 'AccountsInfo as ai', 'order.user_id', '=', 'ai.UserID') ->whereDate('finished_at', $item) ->selectRaw('count(order.id) count,Channel') ->get(); foreach ($oldRecharge as $value) { DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData') ->where('Channel', $value->Channel) ->updateOrInsert(['Channel' => $value->Channel, 'DateID' => $dateID], ['Channel' => $value->Channel, 'DateID' => $dateID, 'OldUserPayCount' => $value->payCount, 'OldUserPaySum' => $value->Recharge * 100]); } foreach ($oldRechargeBi as $value) { DB::connection('sqlsrv')->table(TableName::QPRecordDB() . 'RecordPlatformData') ->where('Channel', $value->Channel) ->updateOrInsert(['Channel' => $value->Channel, 'DateID' => $dateID], ['Channel' => $value->Channel, 'DateID' => $dateID, 'OldUserPayBi' => $value->count]); } // $oldRecharge = $oldRecharge->Recharge ?? 0; // $oldRechargeCount = $oldRecharge->payCount ?? 0; // $newRechargeCount = $newRecharge->payCount ?? 0; // $newRecharge = $newRecharge->Recharge ?? 0; // $oldRecharge *= 100; // $newRecharge *= 100; // $data = ['OldUserPayCount' => $oldRechargeCount, 'OldUserPaySum' => $oldRecharge, 'OldUserPayBi' => $oldRechargeBi, // 'NewPayPeple' => $newRechargeCount, 'NewPayTotal' => $newRecharge, 'NewPayPepleBi' => $NewRechargeBi // ]; // DB::table(TableName::QPRecordDB() . 'RecordPlatformData') // ->where('Channel', -1) // ->where('DateID', date('Ymd', strtotime($item))) // ->update($data); } } }