Bladeren bron

Merge branch 'master' into dev

Sven_x 1 jaar geleden
bovenliggende
commit
b25acb4586

+ 3 - 37
application/controllers/Adjuststa.php

@@ -4306,7 +4306,7 @@ class Adjuststa extends MY_Controller
         echo $this->getAndroidCE($ae);
     }
     private function getAndroidCE($ae){
-// 2023-05-09 更新AE系数
+// 2023-07-13 更新AE系数
 //- 12>AE,合格系数=-1
 //- 15>AE≥12,合格系数=0
 //- 16>AE≥15,合格系数=1
@@ -4334,23 +4334,6 @@ class Adjuststa extends MY_Controller
             24 => 1.9,
             25 => 2.0,
         ];
-        $d = date('d');
-//        if($d < 8){ // 8号之前用老的
-//            $ceArray = [
-//                7 => 0,
-//                10 => 1,
-//                11 => 1.1,
-//                12 => 1.2,
-//                13 => 1.3,
-//                14 => 1.4,
-//                15 => 1.5,
-//                16 => 1.6,
-//                17 => 1.7,
-//                18 => 1.8,
-//                19 => 1.9,
-//                20 => 2.0,
-//            ];
-//        }
         krsort($ceArray);
         foreach ($ceArray as $k => $value){
             if ($ae >= $k)return $value;
@@ -4358,7 +4341,7 @@ class Adjuststa extends MY_Controller
         return -1;
     }
     private function getIOSCE($ae){
-// 2022-09-01 更新AE系数
+// 2023-07-13 更新AE系数
 //- 10>AE,合格系数=-1
 //- 12>AE≥10,合格系数=0
 //- 13>AE≥12,合格系数=1
@@ -4374,7 +4357,7 @@ class Adjuststa extends MY_Controller
 //- AE≥22,合格系数=2.0
 
         $ceArray = [
-            9 => 0,
+            10 => 0,
             12 => 1,
             13 => 1.1,
             14 => 1.2,
@@ -4387,23 +4370,6 @@ class Adjuststa extends MY_Controller
             21 => 1.9,
             22 => 2.0,
         ];
-        $d = date('d');
-//        if($d < 8){ // 8号之前用老的
-//            $ceArray = [
-//                7 => 0,
-//                10 => 1,
-//                11 => 1.1,
-//                12 => 1.2,
-//                13 => 1.3,
-//                14 => 1.4,
-//                15 => 1.5,
-//                16 => 1.6,
-//                17 => 1.7,
-//                18 => 1.8,
-//                19 => 1.9,
-//                20 => 2.0,
-//            ];
-//        }
         krsort($ceArray);
         foreach ($ceArray as $k => $value){
             if ($ae >= $k)return $value;

+ 17 - 8
application/controllers/Sven.php

@@ -691,6 +691,7 @@ class Sven extends CI_Controller
 
 
     public function inviteActions(){
+        date_default_timezone_set('UTC');
         define("CURRENT_TIMESTAMP", time());
 //        if(CURRENT_TIMESTAMP > 1676887200){
 //            return $this->jsonResponse(__LINE__, 'The event has ended.');
@@ -997,7 +998,10 @@ class Sven extends CI_Controller
                     if(!$res)$this->jsonResponse(__LINE__, 'Wrong operation!');
                     break;
                 default:
-                    $this->jsonResponse(__LINE__, 'Wrong operation!');
+                    $model = new SvenModel();
+                    if(!method_exists($model, $post['action']))$this->jsonResponse(__LINE__, 'Wrong operation!', $post);
+                    $data = $model->{$post['action']}($post);
+
             }
         }catch (\throwable $e){
             $this->jsonResponse($e->getCode(), $e->getMessage(), $data);
@@ -1032,13 +1036,18 @@ class Sven extends CI_Controller
         set_time_limit(0);
         date_default_timezone_set("UTC");
         ini_set('memory_limit', -1);
+        return;
         $uids = $this->getExportUids();
-//        $uids = array_chunk($uids, 10)[0];
         $this->exportDataByUid($uids);
     }
-    public function getExportUids(){
-
-        return $this->exportUids0119();
+    public function getExportUids(): array
+    {
+        $payTable = otable::paidStat();
+        $userTable = otable::userinfo();
+        $sql = "select uid from {$payTable} where uid in (select uid from {$userTable} where createtime >= 1656604800 and lasttime <= 1686499200)";
+        $sql = "select uid from {$userTable} where createtime >= 1656604800 and lasttime <= 1686499200";
+        $users = oo::commonOprDb('gameslave')->getAll($sql, 1);
+        return array_map(function ($v){return $v['uid'];}, $users);
     }
     private function exportUidsOld(){
         $countryCodes = [
@@ -1091,8 +1100,7 @@ class Sven extends CI_Controller
         $gameinfoTbl = otable::gh_gameserver();
         $dynamicTbl = otable::UserDynamicsData();
         $friendTbl = otable::userfriends(1);
-        $paymentTbl = otable::order();
-        $paymentTblOld = otable::summarylist();
+        $payTable = otable::paidStat();
 
 
         $timestamp = time();
@@ -1131,7 +1139,7 @@ class Sven extends CI_Controller
 //            $friendsInfos = oo::commonOprDb('gameslave')->getAll("select * from {$friendTbl} where uid in ({$uidStr}) ", 1);
 //            $friendsInfos = array_column($friendsInfos, null, 'uid');
 
-            $paysql = "select sum(price) as money ,uid from {$paymentTbl} where uid in ({$uidStr})  and  status=4 group by uid";
+            $paysql = "select amount as money ,uid from {$payTable} where uid in ({$uidStr})  group by uid";
             $paymentInfos = oo::commonOprDb('gameslave')->getAll($paysql, 1);
 //            var_dump($paymentInfos);
             $paymentInfos = array_column($paymentInfos, 'money', 'uid');
@@ -1191,6 +1199,7 @@ class Sven extends CI_Controller
 
         echo $datetime . PHP_EOL;
         fclose($f);
+        echo $file . PHP_EOL;
         echo 'ok';
     }
 

+ 8 - 0
application/models/Okeys.php

@@ -2131,4 +2131,12 @@ class okeys extends CI_Model
     public static function exchangeBlessingTexts(){
         return "EXCHNAGE_BLESSING_CONFIG";
     }
+
+    public static function lastLoginTime($uid){
+        return "LASTLOGINTIME:{$uid}";
+    }
+
+    public static function userDayData($date, $uid){
+        return "USER_DAYDATA_NEW:{$date}:{$uid}";
+    }
 }

+ 186 - 0
application/models/SvenModel.php

@@ -2,6 +2,27 @@
 
 class SvenModel extends CI_Model
 {
+    public $wheelRewards = [
+        0   => [ 'propsId' => 18,    'num' => 1,        'pro' => 10,    'cnt' => 10, 'skin' => 0   ],
+        1   => [ 'propsId' => 19,    'num' => 1,        'pro' => 100,   'cnt' => 0,  'skin' => 342 ],
+        2   => [ 'propsId' => 15,    'num' => 500,      'pro' => 120,   'cnt' => 0 , 'skin' => 0   ],
+        3   => [ 'propsId' => 61,    'num' => 1,        'pro' => 40,    'cnt' => 6,  'skin' => 0   ],
+        4   => [ 'propsId' => 19,    'num' => 1,        'pro' => 40,    'cnt' => 8,  'skin' => 338 ],
+        5   => [ 'propsId' => 9,     'num' => 1,        'pro' => 150,   'cnt' => 0,  'skin' => 0   ],
+        6   => [ 'propsId' => 15,    'num' => 1500,     'pro' => 60,    'cnt' => 4,  'skin' => 0   ],
+        7   => [ 'propsId' => 19,    'num' => 1,        'pro' => 80,    'cnt' => 3,  'skin' => 336 ],
+        8   => [ 'propsId' => 15,    'num' => 1000,     'pro' => 80,    'cnt' => 2,  'skin' => 0   ],
+        9   => [ 'propsId' => 23,    'num' => 1,        'pro' => 70,    'cnt' => 4,  'skin' => 60  ],
+        10  => [ 'propsId' => 19,    'num' => 1,        'pro' => 100,   'cnt' => 0,  'skin' => 339 ],
+        11  => [ 'propsId' => 8,     'num' => 100000,   'pro' => 150,   'cnt' => 0,  'skin' => 0   ],
+    ];
+    public $taskRewards = [
+        1   => [ 'propsId' => 15,    'num' => 10,    'finishedCnt' => 10,], // 分享
+        2   => [ 'propsId' => 15,    'num' => 50,    'finishedCnt' => 1,],  // 登录
+        3   => [ 'propsId' => 15,    'num' => 500,   'finishedCnt' => 5,],  // 邀请注册
+        4   => [ 'propsId' => 15,    'num' => 500,   'finishedCnt' => 5,],  // 完成支付
+    ];
+
     static function sendRewardToEmail($msgId, $uid, array $rewards, $days = 7){
         $tb = otable::userSysMail($uid);
         $key = okeys::sysMsgGet($uid);
@@ -479,4 +500,169 @@ class SvenModel extends CI_Model
         }
     }
 
+    // 用户每日体力消耗
+    public function getUserDailySpinsUsed($uid){
+        $date = date('Ymd',CURRENT_TIMESTAMP);
+        $rkey = okeys::userDayData($date, $uid);
+        $hkey = 'cost_spin';
+        return oo::commonOprRedis('statistics')->hGet($rkey, $hkey);
+    }
+
+    // 用户支付数据[cnt => 0, money=>0] 订单数,总金额
+    public function getUserPayments($uid, $begin, $end){
+        $begin = date('Y-m-d', $begin);
+        $end   = date('Y-m-d', $end);
+        $orderTable = otable::gameOrder();
+        $sql = "select * from {$orderTable} where uid={$uid} and created_at >= '{$begin}' and created_at < '{$end}' and status = 4";
+        $payments = oo::commonOprDb('slavedb')->getAll($sql);
+        $paymentMoneys = array_map(function($v){return $v['price'];}, $payments);
+        return [
+            'cnt' => count($payments),
+            'money' =>  array_sum($paymentMoneys)
+        ];
+    }
+
+    // 用户邀请数
+    public function getUserInvite($uid, $begin, $end){
+                $inviteTable = otable::AdJustData();
+        $label = base64_encode($uid);
+        $sql = "select count(1) as cnt from {$inviteTable} where label={$label} and created_at >= {$begin} and created_at < {$end}";
+        $inviteTotal = oo::commonOprDb('slavedb')->getOne($sql);
+        return intval($inviteTotal['cnt']);
+    }
+
+    // 转盘数据
+    public function initWheelData($params){
+        $uid = intval($params['uid']);
+        if(!$uid)throw new Exception('Wrong operation!',__LINE__);
+        $wheelMax = 2;
+        $maxShareTimes = 10;
+        $preWheelSpins = 10000;
+        $date = date('Ymd',CURRENT_TIMESTAMP);
+
+        // 最后登陆时间
+        $todayBegin = strtotime($date);
+        $lastLoginTime = oo::commonOprRedis('games')->get(okeys::lastLoginTime($uid));
+        $todayLogin = $lastLoginTime >= $todayBegin;
+
+        // 查询邀请注册人数
+        $inviteNum = $this->getUserInvite($uid, $todayBegin, $todayBegin + 86400);
+
+        // 支付次数
+        $paymentTotal = $this->getUserPayments($uid, $todayBegin, $todayBegin + 86400);
+
+        // 每日体力消耗
+        $spinsUsed = $this->getUserDailySpinsUsed($uid);
+
+        // 组装返回数据
+        $userDataKey = okeys::fansActKey("USER_DATA:{$uid}:{$date}");   // 每日数据
+        $userRecordsKey = okeys::fansActKey("USER_RECORDS:{$uid}");     // 已转到的奖励
+        $userData = oo::commonOprRedis('games')->hGetAll($userDataKey);
+        $userData['wheelRewards'] = oo::commonOprRedis('games')->get($userRecordsKey);
+        $userData['shareTimes']   =  $userData['shareTimes'] ?? 0;
+        $userData['wheelTimes']   =  $userData['wheelTimes'] ?? 0;
+        $userData['wheelRewards'] =  $userData['wheelRewards'] ? explode(',', $userData['wheelRewards']) : [] ?? 0;
+        foreach ($this->taskRewards as $idx => $reward){
+            $userData["taskRewarded{$idx}"] = $userData["taskRewarded{$idx}"] ?? 0 ;  // 任务领奖次数
+        }
+
+        $userData["taskFinished1"] = min($userData['shareTimes'], $maxShareTimes) ;  // 分享完成次数
+        $userData["taskFinished2"] = $todayLogin ? 1 : 0 ;  // 登录完成
+        $userData["taskFinished3"] = $inviteNum ;  // 邀请注册完成
+        $userData["taskFinished4"] = intval($paymentTotal['cnt']) ; // 支付完成
+        $userData["spinsUsed"] = intval($spinsUsed) ; // 每日体力消耗
+        $userData["wheelTotal"] = min($wheelMax, intval(floor($spinsUsed/$preWheelSpins))) ; // 转盘总次数
+        $userData["wheelLeft"] = max($userData["wheelTotal"]-$userData["wheelTimes"], 0) ; // 转盘剩余次数
+        $userData["dataKey"] = $userDataKey ; // 转盘剩余次数
+
+        return $userData;
+    }
+
+    // 转动转盘
+    public function doWheel($params){
+        $uid = intval($params['uid']);
+        if(!$uid)throw new Exception('Wrong operation!',__LINE__);
+        $date = date('Ymd',CURRENT_TIMESTAMP);
+        $preWheelSpins = 10000;
+        $spinsUsed = $this->getUserDailySpinsUsed($uid);
+        $userDataKey = okeys::fansActKey("USER_DATA:{$uid}:{$date}");
+        $userData = oo::commonOprRedis('games')->hGetAll($userDataKey);
+        $wheelTimes = intval($userData['wheelTimes']);
+
+
+        $userRecordsKey = okeys::fansActKey("USER_RECORDS:{$uid}");
+        $wheelRewards = oo::commonOprRedis('games')->get($userRecordsKey);
+        $wheelRewards = $wheelRewards ? explode(',', $wheelRewards) : []; // 已转到的奖励
+        $wheelTotal = floor($spinsUsed/$preWheelSpins);
+        if($wheelTotal <= $wheelTimes)throw new Exception('Wrong operation!',__LINE__);
+        oo::commonOprRedis('games')->hIncrBy($userDataKey, 'wheelTimes', 1);// 旋转次数+1
+        $rewards = [];
+        $totalProb = 0;
+        foreach ($this->wheelRewards as $idx => $reward){
+            if ($reward['cnt'] <= $wheelTimes && !in_array($idx, $wheelRewards)){ // 达到旋转次数且未转到过
+                $reward['idx'] = $idx;
+                $rewards[] = $reward;
+                $totalProb += $reward['pro'];
+            }
+        }
+        $rand = rand(0, $totalProb);
+        $prizeIdx = -1;
+        foreach ($rewards as $reward){
+            $prizeIdx = $reward['idx'];
+            $pro = $reward['pro'];
+            if($rand <= $pro){
+                break;
+            }
+            $rand-=$pro;
+        }
+        if(empty($this->wheelRewards[$prizeIdx]))throw new Exception('Wrong operation!'.$prizeIdx,__LINE__);
+        $wheelRewards[] = $prizeIdx;
+
+        oo::commonOprRedis('games')->set($userRecordsKey, implode(',', $wheelRewards));
+        oo::commonOprRedis('games')->expire($userDataKey, 86400 * 15);
+        oo::commonOprRedis('games')->expire($userRecordsKey, 86400 * 15);
+        $rewards = [
+            [
+                'propsId' => $this->wheelRewards[$prizeIdx]['propsId'],
+                'num' =>     $this->wheelRewards[$prizeIdx]['num'],
+                'skin' =>    $this->wheelRewards[$prizeIdx]['skin'],
+            ]
+        ];
+        self::sendRewardToEmail(691, $uid, $rewards, 7);
+        return ['idx' => $prizeIdx];
+    }
+
+    // 日常任务领奖
+    public function getDailyTaskReward($params){
+        $uid = intval($params['uid']);
+        $taskId = intval($params['taskId']);
+        if(!$uid)throw new Exception('Wrong operation!',__LINE__);
+        if(empty($this->taskRewards[$taskId]))throw new Exception('Wrong operation!',__LINE__);
+
+        $date = date('Ymd',CURRENT_TIMESTAMP);
+        $userDataKey = okeys::fansActKey("USER_DATA:{$uid}:{$date}");
+        $userData = $this->initWheelData($params);
+        if($userData["taskFinished{$taskId}"] <= $userData["taskRewarded{$taskId}"])throw new Exception('Wrong operation!',__LINE__);
+        oo::commonOprRedis('games')->hIncrBy($userDataKey, "taskRewarded{$taskId}", 1); // 领奖数+1
+        $rewards = [
+            [
+                'propsId' => $this->taskRewards[$taskId]['propsId'],
+                'num' =>     $this->taskRewards[$taskId]['num'],
+            ]
+        ];
+        self::sendRewardToEmail(690, $uid, $rewards, 7);
+        return [];
+    }
+
+    // 分享页面
+    public function shareWheel($params){
+        $uid = intval($params['uid']);
+        if(!$uid)throw new Exception('Wrong operation!',__LINE__);
+
+        $date = date('Ymd',CURRENT_TIMESTAMP);
+        $userDataKey = okeys::fansActKey("USER_DATA:{$uid}:{$date}");
+        oo::commonOprRedis('games')->hIncrBy($userDataKey, "shareTimes", 1); // 分享数+1
+        return [];
+    }
+
 }

+ 3 - 0
application/views/welcome_message.php

@@ -16,6 +16,9 @@
     <link rel="stylesheet" href="<?php echo base_url(); ?>public/js/vendor/bootstrap-datepicker/css/bootstrap-datepicker.standalone.min.css">
     <link rel="stylesheet" href="<?php echo base_url(); ?>public/node_modules/bootstrap-select/dist/css/bootstrap-select.min.css">
     <style type="text/css">
+        .fixed-table-body {
+            width: 101%;
+        }
         .text-red {
             color: red;
         }