| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738 |
- <?php
- namespace App\Http\Controllers\Game;
- use App\dao\Estatisticas\RechargeWithDraw;
- use App\Facade\TableName;
- use App\Game\GlobalUserInfo;
- use App\Game\RePayConfig;
- use App\Game\Services\AgentService;
- use App\Game\Services\LZCompressor\LZString as LZ;
- use App\Game\Services\OuroGameService;
- use App\Game\Services\RouteService;
- use App\Game\Services\ServerService;
- use App\Game\WebActivity;
- use App\Game\WebChannelConfig;
- use App\Http\Controllers\Controller;
- use App\Game\RedEnvelopeConfig;
- use App\Game\RedEnvelopeLog;
- use App\Http\helper\Helper;
- use App\Http\helper\NumConfig;
- use App\Jobs\AfEvent;
- use App\Models\AccountsInfo;
- use App\Models\Order;
- use App\Models\PrivateMail;
- use App\Models\RecordUserDataStatistics;
- use App\Models\Treasure\GameScoreInfo;
- use App\Notification\TelegramBot;
- use App\Services\OrderServices;
- use App\Services\PayConfig;
- use App\Services\SmartFastPay;
- use App\Services\StoredProcedure;
- use App\Util;
- use Illuminate\Http\Request;
- use Carbon\Carbon;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Hash;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Redis;
- use PDO;
- class ActivityController extends Controller
- {
- public function index()
- {
- }
- public function List(Request $request)
- {
- return apiReturnSuc(['list'=>WebActivity::query()->whereRaw(RouteService::getStateToWhereRaw($request))->get()->toArray()]);
- }
- public function GetProtectNum(Request $request)
- {
- $user=$request->user();
- if(ServerService::GetGlobalServerInfoByGUID($user->GlobalUID)['Subsite']=='Europe'){
- //欧洲暂时封闭
- return apiReturnSuc();
- }
- $UserID=$user->UserID;
- $res=DB::connection('sqlsrv')->select("exec QPAccountsDB.dbo.GSP_GP_QueryProtect $UserID");
- return apiReturnSuc($res);
- }
- public function AddProtectNum(Request $request)
- {
- $user=$request->user();
- $UserID=$user->UserID;
- if(ServerService::GetGlobalServerInfoByGUID($user->GlobalUID)['Subsite']=='Europe'){
- //欧洲暂时封闭
- return apiReturnSuc();
- }
- $dbh = DB::connection()->getPdo();
- $sql="
- set nocount on use QPAccountsDB;
- DECLARE @return_value INT;
- EXEC @return_value = QPAccountsDB.dbo.GSP_GP_AddProtect @dwUserID = $UserID;
- SELECT @return_value as ReturnValue;";
- $stmt = $dbh->prepare($sql);
- $stmt->execute();
- $result = $stmt->fetch(\PDO::FETCH_ASSOC);
- // dd($user,$result);
- // 获取返回值和错误描述
- $returnValue = $result['ReturnValue']??0;
- // $result=DB::connection('sqlsrv')->select('EXEC @return_value = QPAccountsDB.dbo.GSP_GP_AddProtect @dwUserID = '.$UserID.'; SELECT @return_value AS ReturnValue;');
- // 获取返回值
- // $returnValue = $result[1]->ReturnValue;
- if ($returnValue == 0) {
- return apiReturnSuc($result);
- } else if ($returnValue == 1) {
- return apiReturnFail(['web.protect.score_limit','Score limit reached']);
- } else if ($returnValue == 3) {
- return apiReturnFail(['web.protect.times_limit','Protect times limit reached']);
- } else {
- return apiReturnFail(['web.withdraw.try_again_later','Unknown error']);
- }
- }
- public function GetCheckInInfoConfig(Request $request)
- {
- $user=$request->user();
- $UserID=$user->UserID;
- $res=DB::connection('sqlsrv')->select("exec QPAccountsDB.dbo.GSP_GP_GetUserSignInInfo $UserID");
- $res2=DB::table('QPAccountsDB.dbo.UserSignInInfo')->where('UserID',$UserID)->first();
- $max=count($res);
- $res2=(array)$res2;
- if($res2['NextDayNumber']>$max) {
- $res2['NextDayNumber']= $res2['NextDayNumber'] % $max + 1;
- $res2['RecordDay']='';
- for($i=0;$i<$max;$i++) {
- $res2['RecordDay'].=$i<($res2['NextDayNumber']-1)?'1':'0';
- }
- }
- $res2['config']=$res;
- return apiReturnSuc($res2);
- }
- public function GetCheckInInfo(Request $request)
- {
- $user=$request->user();
- $UserID=$user->UserID;
- try {
- // 定义输出参数
- $errorDescribe = '';
- // 调用存储过程
- // $result = DB::connection('sqlsrv')->select('
- // use QPAccountsDB;
- // DECLARE @strErrorDescribe NVARCHAR(127);
- // DECLARE @return_value INT;
- // EXEC @return_value = QPAccountsDB.dbo.GSP_GP_UserSignIn @dwUserID = $UserID, @strErrorDescribe = @strErrorDescribe OUTPUT;
- // SELECT @return_value as ReturnValue, @strErrorDescribe as ErrorDescribe;
- // ', [$UserID]);
- //
- $dbh = DB::connection()->getPdo();
- $sql="
- set nocount on use QPAccountsDB;
- DECLARE @strErrorDescribe NVARCHAR(127);
- DECLARE @return_value INT;
- EXEC @return_value = QPAccountsDB.dbo.GSP_GP_UserSignIn @dwUserID = $UserID, @strErrorDescribe = @strErrorDescribe OUTPUT;
- SELECT @return_value as ReturnValue, @strErrorDescribe as ErrorDescribe;";
- $stmt = $dbh->prepare($sql);
- $stmt->execute();
- $result = $stmt->fetch(\PDO::FETCH_ASSOC);
- // dd($user,$result);
- // 获取返回值和错误描述
- $returnValue = $result['ReturnValue']??0;
- // $errorDescribe = $result['ErrorDescribe'];
- // 根据返回值和错误描述处理
- switch ($returnValue) {
- case 1:
- return apiReturnFail(['web.checkin.user_signin_error', 'Failed to get user sign-in information']);
- case 2:
- return apiReturnFail(['web.checkin.user_already_signed_in', 'You have already signed in today']);
- case 3:
- return apiReturnFail(['web.checkin.signin_event_ended', 'The sign-in activity has ended']);
- case 4:
- return apiReturnFail(['web.checkin.signin_data_error', 'Failed to read sign-in data']);
- case 5:
- return apiReturnFail(['web.checkin.recharge_required', 'Recharge is required to sign in'],[],777);
- case 0:
- return apiReturnSuc($result);
- default:
- return apiReturnFail(['web.checkin.unknown_error', 'Unknown error']);
- }
- } catch (\Exception $e) {
- TelegramBot::getDefault()->sendProgramNotify("Game Checkin:", $e->getMessage());
- // 捕获异常并返回错误响应
- return apiReturnFail(['web.checkin.exception_occurred', 'An error occurred while processing your request'], [], 500);
- }
- }
- public function RedConfig(Request $request){
- $config=Redis::get("RedEnvelopeConfig");
- if(!$config){
- $config=RedEnvelopeConfig::query()->get();
- Redis::set("RedEnvelopeConfig",json_encode($config));
- Redis::expire("RedEnvelopeConfig",600);
- }else{
- $config=json_decode($config,true);
- }
- return apiReturnSuc($config);
- }
- public function RedCheck(Request $request)
- {
- $maxRedpack=24680;
- $currentDateTime = Carbon::now();
- $currentTime = $currentDateTime->format('H:i:s');
- // 查找当前时间段内的红包配置
- $config = RedEnvelopeConfig::where('StartTime', '<=', $currentTime)
- ->where('EndTime', '>=', $currentTime)
- ->first();
- if ($config) {
- $getted=false;
- if($request->user()) {
- $userID=$request->user()->UserID;
- $checkKey = "redpack_$userID";
- $getted=Redis::exists($checkKey);
- }
- return apiReturnSuc(['status' => $getted?-1:1,'max'=>$maxRedpack]);
- } else {
- // 计算下一个红包时间
- $nextConfig = RedEnvelopeConfig::where('StartTime', '>', $currentTime)
- ->orderBy('StartTime', 'asc')
- ->first();
- if (!$nextConfig) {
- // 如果今天没有更多红包时间段,则查找明天的第一个红包时间段
- $nextConfig = RedEnvelopeConfig::orderBy('StartTime', 'asc')->first();
- $nextTime = Carbon::tomorrow()->setTimeFromTimeString($nextConfig->StartTime);
- } else {
- $nextTime = Carbon::today()->setTimeFromTimeString($nextConfig->StartTime);
- }
- $diffMinutes = $currentDateTime->diffInSeconds($nextTime);
- return apiReturnSuc(['status' => 0,'max'=>$maxRedpack, 'next_in_seconds' => $diffMinutes],['activity.redpack.please_wait','Please wait until next time.']);
- }
- }
- public function RedReceive(Request $request)
- {
- return apiReturnSuc(['status' => -1,'amount'=>0]);
- $user=$request->user();
- $userID = $user->UserID;
- $currentDateTime = Carbon::now();
- $currentTime = $currentDateTime->format('H:i:s');
- $checkKey="redpack_$userID";
- if(Redis::exists($checkKey)){
- return apiReturnSuc(['status' => -1,'amount'=>0]);
- }
- // 查找当前时间段内的红包配置
- $config = RedEnvelopeConfig::where('StartTime', '<=', $currentTime)
- ->where('EndTime', '>=', $currentTime)
- ->first();
- if ($config) {
- // 在红包活动时间段内,生成红包金额
- $amount = $this->generateRedEnvelopeAmount($user,$config);
- if(is_array($amount))return $amount;
- // 记录领取日志
- RedEnvelopeLog::create([
- 'UserID' => $userID,
- 'ReceivedAt' => $currentDateTime,
- 'Amount' => $amount,
- 'Comment' => '红包雨活动'
- ]);
- Redis::set($checkKey,1);
- Redis::expire($checkKey,3600);
- return apiReturnSuc(['amount' => $amount,'status' => 1]);
- } else {
- // 不在红包活动时间段内
- return apiReturnFail(['web.activity.redpack_not_available','There is no RedPack']);
- }
- }
- /**
- * @param $user
- * @param RedEnvelopeConfig $config
- * @return array|int
- */
- private function generateRedEnvelopeAmount($user, $config)
- {
- //超过限额
- if($config->PrizePool>=3000){
- return 0;
- }
- $UserID=$user->UserID;
- // $recharinfo=DB::connection('write')->table('QPAccountsDB.dbo.YN_VIPAccount')
- // ->where('UserID', $UserID)->first();
- // // 根据用户的充值金额决定红包金额
- $userTotal = DB::connection('write')->table('QPRecordDB.dbo.RecordUserTotalStatistics')
- ->where('UserID', $UserID)
- ->first();
- $deposit = 0;
- $withdraw = 0;
- $revenue = 0;
- if($userTotal){
- $deposit = $userTotal->Recharge;
- $withdraw = $userTotal->Withdraw;
- $revenue = $userTotal->Revenue;
- }
- $amount = 0;
- if ($deposit == 0) {
- // 未充值用户无法领取红包
- return apiReturnFail(['web.activity.redpack_no_recharge', 'message' => 'You need deposit first!']);
- } elseif ($deposit < 50) {
- // 50以下
- if (rand(1, 100) <= 50) {
- $amount=0;
- } else {
- $amount = rand(1, 2);
- }
- } elseif ($deposit < 100) {
- // 50-100
- if (rand(1, 100) <= 40) {
- $amount=0;
- } else {
- $amount = rand(1, 5);
- }
- } elseif ($deposit < 500) {
- // 100-500
- if (rand(1, 100) <= 25) {
- $amount=0;
- } else {
- $amount = rand(5, 10);
- }
- } elseif ($deposit < 1000) {
- // 500-1000
- if (rand(1, 100) <= 20) {
- $amount=0;
- } else {
- $amount = rand(5, 15);
- }
- } elseif ($deposit < 5000) {
- // 1000-5000
- if (rand(1, 100) <= 10) {
- $amount=0;
- } else {
- $amount = rand(10, 30);
- }
- } elseif ($deposit < 20000) {
- // 5000-20000
- $amount = rand(20, 100);
- } elseif ($deposit < 200000) {
- // 20000-200000
- $amount = rand(100, 150);
- } else {
- // 200000以上
- $amount = rand(100, 300);
- }
- if($amount){
- //平台资产》充 减半
- if($withdraw + $revenue > $deposit*100 && $deposit>1000){
- $rate = max(($withdraw + $revenue) / ($deposit*100) * 2,2);
- $amount = intval($amount/$rate);
- }
- //出》入 0
- if($withdraw > $deposit*100){
- $amount = 0;
- }
- }
- if($amount){
- $config->increment('PrizePool', $amount);
- OuroGameService::AddScore($UserID,$amount*NumConfig::NUM_VALUE,OuroGameService::REASON_RedEnvelope);
- // OuroGameService::AddDrawBase($UserID,$amount*100,2);
- }
- return $amount;
- }
- public function repayFirst()
- {
- $str="10014268,2000,BRA2851903748065310014268
- 10014270,2000,BRA2855489212693610014270
- 10014271,2000,BRA2852393071882610014271
- 10014274,1000,BRA2853030100749910014274
- 10014276,1000,BRA2853245554392310014276
- 10014277,2000,BRA2853344779876810014277
- 10014277,2000,BRA2855290186893810014277
- 10014277,2000,BRA2864525856913410014277
- 10014281,1000,BRA2854641828657010014281
- 10014282,2000,BRA2854744724737410014282
- 10014285,2000,BRA2855039889866610014285
- 10014287,2000,BRA2855391649287010014287
- 10014288,1000,BRA2855464384803010014288
- 10014292,2000,BRA2856246492161510014292
- 10014297,1000,BRA2857229048633010014297
- 10014300,2000,BRA2858261561088610014300
- 10014301,2000,BRA2858433689840310014301
- 10014302,1000,BRA2858522897364510014302
- 10014305,2000,BRA2859083559189210014305
- 10014306,2000,BRA2859074387476010014306
- 10014308,2000,BRA2859253433784710014308
- 10014309,2000,BRA2859266221396810014309
- 10014311,1000,BRA2859721671820010014311
- 10014314,2000,BRA2860714714541810014314
- 10014316,2000,BRA2861078506701410014316
- 10014318,2000,BRA2861340050408610014318
- 10014324,2000,BRA2863987369403910014324
- 10014326,2000,BRA2862573151411810014326
- 10014327,2000,BRA2862997500499910014327
- 10014330,1000,BRA2863297592217210014330
- 10014332,2000,BRA2863120608306010014332
- 10014335,1000,BRA2975317980447310014335
- 10014339,2000,BRA2864730304211810014339
- 10014351,2000,BRA2869670282797610014351
- 10014352,2000,BRA2971319703907510014352
- 10014358,2000,BRA2973553150552010014358
- 10014372,2000,BRA2995159192410010014372
- 10014373,2000,BRA2995376698241510014373
- 10014375,2000,BRA2996350286730710014375
- 10014383,2000,BRA2902200217093410014383";
- $arr=explode("\n",$str);
- $sort=[];
- $g201 = DB::table('agent.dbo.recharge_gear')->where('gift_id', 201)->select('gift_id', 'money', 'give', 'favorable_price', 'second_give')->first();
- $g211 = DB::table('agent.dbo.recharge_gear')->where('gift_id', 211)->select('gift_id', 'money', 'give', 'favorable_price', 'second_give')->first();
- foreach ($arr as $k=>$v){
- [$UserID,$amount,$sn]=explode(',',$v);
- if(isset($sort[$UserID]))continue;
- $sort[$UserID]=$amount;
- if($amount==1000)$first=$g201;
- else $first=$g211;
- if ($first && $first->second_give > 0) {
- $bonus = '30000,' . $amount;
- PrivateMail::sendMail(2, $UserID, "Suplemento de erro de primeiro depósito", "Nós adicionamos para você, por favor, aceite.", $bonus, $sn, $amount);
- $fpkey = 'Firstpay_' . $UserID;
- $data = (array)$first;
- $data['buytime'] = time();
- $data['czReason'] = 1;
- $data['cjReason'] = 45;
- Redis::set($fpkey, json_encode($data));
- DB::table(TableName::agent() . 'guide_payment')->updateOrInsert([
- 'UserID' => $UserID,
- 'GiftID' => $amount==1000?201:211,
- 'CreateTime' => now()
- ], ['UserID' => $UserID]);
- }
- }
- dd($sort);
- }
- public static function decrypt($str){
- if (!isset($str)||!$str||empty($str)) {
- # code...
- return '';
- }
- $str=implode("+",explode(" ",$str));
- try {
- $destr=LZ::decompressFromBase64($str);
- }catch (\Exception $exception){
- Util::WriteLog('gamelz',$str);
- TelegramBot::getDefault()->sendProgramNotify("Game LZ decrypt:".$str);
- TelegramBot::getDefault()->sendProgramNotify("Game LZ decrypt:", $exception->getMessage().$exception->getTraceAsString());
- $destr=$str;
- }
- return $destr;
- }
- public function test(Request $request){
- // $this->repayFirst();
- // $config=RouteService::getChannelConfig($request);
- //
- // dd($config->toArray());
- dd(1);
- $countrys=['COL','PER','ARG','ECU','CHL'];
- $service = new SmartFastPay();
- $country=$request->input('country','');
- if(!empty($country)) {
- $json = $service->curlGet('https://api.smartfastpay.com/documents-type?country=' . $country);
- // 将 JSON 字符串转换为 PHP 数组
- $decodedJson = json_decode($json, true);
- // 获取 data 部分
- $data = $decodedJson['data'] ?? [];
- // 传递数据到视图
- return view('other.datatable', compact('data', 'country'));
- }else{
- $datas=[];
- foreach ($countrys as $country){
- $json = $service->curlGet('https://api.smartfastpay.com/documents-type?country=' . $country);
- // 将 JSON 字符串转换为 PHP 数组
- $decodedJson = json_decode($json, true);
- // 获取 data 部分
- $data = $decodedJson['data'] ?? [];
- $datas[$country]=$data;
- }
- // echo json_encode($datas);die;
- return view('other.datatables', compact('datas'));
- }
- // $user = GlobalUserInfo::getGameUserInfoToWeb('UserID',$user_id);
- // LoginController::CheckTimeBonus($user);
- // $datas = RePayConfig::CacheDatas();
- //
- // if (isset($datas) && is_array($datas) && count($datas)) {
- // $datas = array_filter($datas, function ($v) use ($user) {
- // return $user['Score'] < $v['LessThan'];
- // });
- // }
- // dd($user,$datas,date("Y-m-d H:i:s",$user['bonus_pack']['settime']));
- //
- // dd(Util::validateCpf('47285044171'));
- // $newid=AccountsInfo::whereBetween('UserID',[10000,100000])->max('UserID')??10000;
- // TelegramBot::getDefault()->sendMsgWithEnv('test123');
- // Log::error("test123");
- // AgentService::SetUserAgent("5ce7c4e17c-b53b-eb1a-0004581854",4581854,"fw9tdk");
- // AgentService::recordPerformance(4581854,100*NumConfig::NUM_VALUE);
- // OuroGameService::notifyWebHall(4478930,"",'pay_finish',["Golds"=>1000,"PayNum"=>10]);
- // $key='ingame_state_'.$request->input('uid');
- // $exist=Redis::exists($key);
- // $ingame_state=Redis::get($key)??-1;
- //
- // exit(json_encode(compact('exist','ingame_state')));
- // DB::connection('write')->select("SET NOCOUNT ON use QPRecordDB exec GSP_GP_AddUserLogin $UserID");
- /*try {
- $str='N4IgRgZgDiBcIAYD2A5KATFAbAqgWQEEBnARgBcAnLAJQBUBRAdQEcQAaEIgSwHMA7OCACmATwBSGLgEkAbFIDWZABJ4AVugDCKVVgAidMQDEAyo0MAWAIoAvABZ50ANQDuAN0byxAIQAKtBFwAMhpiAEwAmowAHiQAWsayUlixAMaB1igajqHoPimq1F4AhnxYtCm0UuaxhjS01mJI6ADM1HyMSmJKjoYojLGhjq4AGhoAnM7UAOJQac2GEQC26OFCWFgkAPJTZEQ4Lq4oSoYIxoaOKEX0bbHD1JdTWGTGfFA+YDhYAKwDKQg4dz4KXkUGajkY6BEsWsCDGUi4zi4YDMqikqiQXBQ1nkX3CixwCG0OBIKFoOJQoXo1jw+JEeGxzk2DGa4R0qk2uhwGX6XCZPAyunoUMW4QQsUWsVU4qkzXF2nC1h4zlZ6ExoRw5lJlmaKC4YjG7BAKUEX1ChoA+uhBIsLWRBCQAOyhBAIB1jZqu0IyL7m8wkULmsYkL6GgCuRUEeCQ1i46yKAHovgA6BAAAgAFIEuHxQ1EANypgh8dAUDHoVMkZoF4x4AC0UzGAA4SF4AJSFqBQLBCRhCMAAaS4ZETzQdSeaMgz/aUtDwgTYqawXHkQlTUyEwKQ7Y0tlLiyE8ZIJBkKdPaajYFjq+MRQgRQoXBHY4nIAAvkA===';
- $destr=LZ::decompressFromBase64($str);
- // dd($destr);
- }catch (\Exception $exception){
- TelegramBot::getDefault()->sendProgramNotify("Game LZ decrypt:", $exception->getMessage().$exception->getTraceAsString());
- $destr=$str;
- }
- return $destr;*/
- // $pass='$2y$10$THuv5qMoBlCi2uIZLiR7k.7j/ixywIgZ/th49pJKxtkQjBz4mBtlm';
- // return json_encode(['res'=>Hash::check('',$pass)]);
- /* $users=GlobalUserInfo::where("RegisterDate",'>','2024-06-18')->get();
- foreach ($users as $user){
- $UserID=$user->UserID;
- $startDate=Carbon::parse($user->RegisterDate)->format('Ymd');
- $endDate=Carbon::parse($user->LastLogonDate)->format('Ymd');
- for($i=$startDate;$i<=$endDate;$i++){
- // DB::table('QPRecordDB.dbo.RecordUserLogin')->insert(['UserID'=>$UserID,'DateID'=>$i,'Cnt'=>1]);
- }
- }*/
- }
- public function tes11t()
- {
- $dbh = DB::connection()->getPdo();
- $sql="SELECT ID,UserID,ChangeScore
- FROM QPRecordDB.dbo.RecordUserScoreChange t
- WHERE UpdateTime>'2024-06-05 03:53:12' and UpdateTime<'2024-06-05 09:57:19' and ChangeScore>=1000 and Reason=1 order by UpdateTime";
- // echo $sql;die;
- $stmt = $dbh->prepare($sql);
- $stmt->execute();
- $addmoneys = $stmt->fetchAll(\PDO::FETCH_ASSOC);
- $asorts=[];
- foreach ($addmoneys as $addmoney) {
- if(!isset($asorts[$addmoney['UserID']]))$asorts[$addmoney['UserID']]=[];
- $asorts[$addmoney['UserID']][]=$addmoney;
- }
- $orders=Order::whereRaw('id>9978316 and id<9979949 and pay_status=1 and payment_sn is null')->get();
- $osorts=[];
- foreach ($orders as $order){
- if(!isset($osorts[$order->UserID]))$osorts[$order->UserID]=[];
- $osorts[$order->UserID][]=(array)$order;
- }
- $channels=[];
- foreach ($osorts as $UserID=>$osort) {
- if(isset($asorts[$UserID])){
- $asort=$asorts[$UserID];
- if(count($asort)>count($osort)){
- $ChangeScore=0;
- foreach ($asort as $k=>$v){
- $ChangeScore+=$v['ChangeScore'];
- }
- $pay=0;
- foreach ($osort as $k=>$v){
- $pay+=$order['amount'];
- }
- $Channel = DB::connection('write')->table(TableName::QPAccountsDB() . 'AccountsInfo')
- ->where('UserID', $UserID)->select('Channel', 'RegisterDate')->first();
- echo json_encode([$UserID,count($asort),$ChangeScore,count($osort),$pay,($ChangeScore-$pay)/100,$Channel])."\r\n";
- if(!isset($channels[$Channel->Channel]))$channels[$Channel->Channel]=['NewPayPeple'=>0,'OldUserPayCount'=>0,'PayPeple'=>0,'PayCount'=>0,'PayTotal'=>0,'OldUserPayBi'=>0,'OldUserPaySum'=>0,'NewPayPepleBi'=>0,'NewPayTotal'=>0];
- if(date('Ymd',strtotime($Channel->RegisterDate))!='20240605'){
- $channels[$Channel->Channel]['OldUserPayCount']+=count($asort)-1;
- }else{
- $channels[$Channel->Channel]['NewPayPeple']+=count($asort)-count($osort);
- }
- $channels[$Channel->Channel]['PayPeple']+=count($asort)-1;
- // if(date('Ymd',strtotime($Channel->RegisterDate))!='20240605'){
- // $channels[$Channel->Channel]['OldUserPayBi']+=count($asort)-count($osort);
- // $channels[$Channel->Channel]['OldUserPaySum']+=($ChangeScore-$pay);
- // }else{
- // $channels[$Channel->Channel]['NewPayPepleBi']+=count($asort)-count($osort);
- // $channels[$Channel->Channel]['NewPayTotal']+=($ChangeScore-$pay);
- // }
- // $channels[$Channel->Channel]['PayCount']+=count($asort)-count($osort);
- // $channels[$Channel->Channel]['PayTotal']+=($ChangeScore-$pay);
- // $callback = DB::table(TableName::agent() . 'UserCallBack')->where('UserID', $UserID)->first();
- // if($callback)DB::table(TableName::agent() . 'UserCallBack')->where('UserID', $UserID)->decrement('recharge',($ChangeScore-$pay));
- // DB::table('QPRecordDB.dbo.RecordUserTotalStatistics')->where('UserID',$UserID)->increment('Recharge',($ChangeScore-$pay)/100);
- //
- // DB::connection('write')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')->where('ScoreType', 1)
- // ->where('UserID', $UserID)
- // ->where('DateID', 20240605)
- // ->decrement('ScoreCount',count($asort)-count($osort));
- // DB::connection('write')->table('QPRecordDB.dbo.RecordUserScoreStatisticsNew')->where('ScoreType', 1)
- // ->where('UserID', $UserID)
- // ->where('DateID', 20240605)
- // ->decrement('Score',($ChangeScore-$pay));
- $total=$ChangeScore-$pay;
- while($total>0){
- $arr=array_shift($asort);
- $ID=$arr['ID'];
- $ChangeScore=$arr['ChangeScore'];
- echo $ID."|".$ChangeScore."\r\n";
- $total-=$ChangeScore;
- // DB::table('QPRecordDB.dbo.RecordUserScoreChange')->where('ID',$ID)->delete();
- }
- }
- }
- }
- // print_r($channels);
- // ->updateOrInsert(['Channel' => -1, 'DateID' => $dateID], ['OldUserPayCount' => DB::raw("OldUserPayCount+$addPayPeple"), 'OldUserPayBi' => DB::raw('OldUserPayBi+1'), 'OldUserPaySum' => DB::raw("OldUserPaySum+$money")]);
- // ->updateOrInsert(['Channel' => -1, 'DateID' => $dateID], ['NewPayPeple' => DB::raw("NewPayPeple+$addPayPeple"), 'NewPayPepleBi' => DB::raw('NewPayPepleBi+1'), 'NewPayTotal' => DB::raw("NewPayTotal+$money")]);
- // print_r($channels);
- // foreach ($channels as $Channel=>$ChannelData){
- // DB::connection('write')->table(TableName::QPRecordDB() . 'RecordPlatformData')
- // ->where('DateID', '20240605')
- // ->where('Channel', -1)->update([
- // 'OldUserPayBi'=>DB::raw("OldUserPayBi-$ChannelData[OldUserPayBi]"),
- // 'OldUserPaySum'=>DB::raw("OldUserPaySum-$ChannelData[OldUserPaySum]"),
- // 'NewPayPepleBi'=>DB::raw("NewPayPepleBi-$ChannelData[NewPayPepleBi]"),
- // 'NewPayTotal'=>DB::raw("NewPayTotal-$ChannelData[NewPayTotal]")
- // ]);
- // DB::connection('write')->table(TableName::QPRecordDB() . 'RecordPlatformData')
- // ->where('DateID', '20240605')
- // ->where('Channel', $Channel)->update([
- // 'OldUserPayBi'=>DB::raw("OldUserPayBi-$ChannelData[OldUserPayBi]"),
- // 'OldUserPaySum'=>DB::raw("OldUserPaySum-$ChannelData[OldUserPaySum]"),
- // 'NewPayPepleBi'=>DB::raw("NewPayPepleBi-$ChannelData[NewPayPepleBi]"),
- // 'NewPayTotal'=>DB::raw("NewPayTotal-$ChannelData[NewPayTotal]")
- // ]);
- //
- // }
- foreach ($channels as $Channel=>$ChannelData){
- // DB::connection('write')->table(TableName::QPRecordDB() . 'RecordPlatformData')
- // ->where('DateID', '20240605')
- // ->where('Channel', -1)->update([
- // 'NewPayPeple'=>DB::raw("NewPayPeple-$ChannelData[NewPayPeple]"),
- // 'OldUserPayCount'=>DB::raw("OldUserPayCount-$ChannelData[OldUserPayCount]"),
- // 'PayPeple'=>DB::raw("PayPeple-$ChannelData[PayPeple]"),
- // ]);
- // DB::connection('write')->table(TableName::QPRecordDB() . 'RecordPlatformData')
- // ->where('DateID', '20240605')
- // ->where('Channel', $Channel)->update([
- // 'NewPayPeple'=>DB::raw("NewPayPeple-$ChannelData[NewPayPeple]"),
- // 'OldUserPayCount'=>DB::raw("OldUserPayCount-$ChannelData[OldUserPayCount]"),
- // 'PayPeple'=>DB::raw("PayPeple-$ChannelData[PayPeple]"),
- // ]);
- }
- // UPDATE RecordPlatformData SET PayTotal=PayTotal+@Cnt,PayPeple=PayPeple+@PayPeple,PayCount=PayCount+1 WHERE DateID=@DateID AND Channel=-1
- //
- //
- // UPDATE RecordPlatformData SET PayTotal=PayTotal+@Cnt,PayPeple=PayPeple+@PayPeple,PayCount=PayCount+1 WHERE DateID=@DateID AND Channel=@Channel
- die;
- }
- }
|