소스 검색

change:变量类型强制转换;

Wang Chen 4 년 전
부모
커밋
0c1bb76771
2개의 변경된 파일79개의 추가작업 그리고 75개의 파일을 삭제
  1. 1 1
      app/Modules/User/Services/QappUserService.php
  2. 78 74
      app/Modules/User/Services/UserService.php

+ 1 - 1
app/Modules/User/Services/QappUserService.php

@@ -56,7 +56,7 @@ class QappUserService
         $time  = strtotime("+1 month");
         $time  = strtotime("+1 month");
         $token = JWTAuth::fromUser($user);
         $token = JWTAuth::fromUser($user);
         if ($data['send_order_id']) {
         if ($data['send_order_id']) {
-            UserService::setUserSendOrder($uid, $data['send_order_id']);
+            UserService::setUserSendOrder((int)$uid, (int)$data['send_order_id']);
         }
         }
         // 新注册统计
         // 新注册统计
         if ($isNewRegister && $qapp_user) {
         if ($isNewRegister && $qapp_user) {

+ 78 - 74
app/Modules/User/Services/UserService.php

@@ -32,13 +32,17 @@ class UserService
 {
 {
     public static function setUserSendOrder(int $uid, int $send_order_id)
     public static function setUserSendOrder(int $uid, int $send_order_id)
     {
     {
+        if (empty($uid) || empty($send_order_id)) {
+            return false;
+        }
+
         return Redis::hset('book_read:' . $uid, 'send_order_id', $send_order_id);
         return Redis::hset('book_read:' . $uid, 'send_order_id', $send_order_id);
     }
     }
 
 
     public static function getUserSendOrder(int $uid)
     public static function getUserSendOrder(int $uid)
     {
     {
         $send_order_id = Redis::hGet('book_read:' . $uid, 'send_order_id');
         $send_order_id = Redis::hGet('book_read:' . $uid, 'send_order_id');
-        $send_order_id = (int) ($send_order_id ? $send_order_id : 0);
+        $send_order_id = (int)($send_order_id ? $send_order_id : 0);
         return $send_order_id;
         return $send_order_id;
     }
     }
 
 
@@ -53,7 +57,7 @@ class UserService
                 dispatch($job)->onConnection('rabbitmq')->onQueue('qapp_user_add_desk')->delay(now()->addMinutes(3));
                 dispatch($job)->onConnection('rabbitmq')->onQueue('qapp_user_add_desk')->delay(now()->addMinutes(3));
             }
             }
             QappUserAddDestop::create([
             QappUserAddDestop::create([
-                'uid' => $uid,
+                'uid'    => $uid,
                 'status' => $status
                 'status' => $status
             ]);
             ]);
         }
         }
@@ -144,8 +148,8 @@ class UserService
 
 
     /**
     /**
      * 更新用户信息
      * 更新用户信息
-     * @param  int $id 用户ID
-     * @param  array $params 可传 province、city、country、headimgurl、sex
+     * @param int   $id 用户ID
+     * @param array $params 可传 province、city、country、headimgurl、sex
      * @return boolen
      * @return boolen
      */
      */
     static function updateInfo($id, $params)
     static function updateInfo($id, $params)
@@ -229,8 +233,8 @@ class UserService
     /**
     /**
      * 查询渠道某段时间注册用户总数
      * 查询渠道某段时间注册用户总数
      * @param array $channelIds
      * @param array $channelIds
-     * @param $startDate
-     * @param $endDate
+     * @param       $startDate
+     * @param       $endDate
      * @return mixed
      * @return mixed
      */
      */
     static function getChannelsDayToDayTotal($channelIds, $startDate = '', $endDate = '')
     static function getChannelsDayToDayTotal($channelIds, $startDate = '', $endDate = '')
@@ -275,7 +279,7 @@ class UserService
     static function getCompanyDayTotal($date, $company_id)
     static function getCompanyDayTotal($date, $company_id)
     {
     {
         $end_date = date('Y-m-d', strtotime($date) + 86400);
         $end_date = date('Y-m-d', strtotime($date) + 86400);
-        $info = User::leftjoin('distribution_channels', 'distribution_channels.id', '=', 'users.distribution_channel_id')
+        $info     = User::leftjoin('distribution_channels', 'distribution_channels.id', '=', 'users.distribution_channel_id')
             ->leftjoin('channel_users', 'channel_users.id', '=', 'distribution_channels.channel_user_id')
             ->leftjoin('channel_users', 'channel_users.id', '=', 'distribution_channels.channel_user_id')
             ->where([
             ->where([
                 ['users.created_at', '>=', $date],
                 ['users.created_at', '>=', $date],
@@ -332,8 +336,8 @@ class UserService
                 //     			$pay_merchant_id = env('YCSD_CALL_PAY_MERCHANT_ID');
                 //     			$pay_merchant_id = env('YCSD_CALL_PAY_MERCHANT_ID');
 
 
                 // 当前默认
                 // 当前默认
-                $pay_merchant_id = Redis::get('YCSD_CALL_PAY_MERCHANT_ID');
-                $channel = Channel::getById($distribution_channel_id);
+                $pay_merchant_id         = Redis::get('YCSD_CALL_PAY_MERCHANT_ID');
+                $channel                 = Channel::getById($distribution_channel_id);
                 $current_pay_merchant_id = isset($channel->pay_merchant_id) ? $channel->pay_merchant_id : '';
                 $current_pay_merchant_id = isset($channel->pay_merchant_id) ? $channel->pay_merchant_id : '';
                 \Log::info('action_call_ycsd:' . $distribution_channel_id . ' $pay_merchant_id:' . $pay_merchant_id . ' $current_pay_merchant_id:' . $current_pay_merchant_id);
                 \Log::info('action_call_ycsd:' . $distribution_channel_id . ' $pay_merchant_id:' . $pay_merchant_id . ' $current_pay_merchant_id:' . $current_pay_merchant_id);
                 if ($current_pay_merchant_id != $pay_merchant_id) {
                 if ($current_pay_merchant_id != $pay_merchant_id) {
@@ -355,25 +359,25 @@ class UserService
                 \Log::info('action_call_ycsd:' . $distribution_channel_id);
                 \Log::info('action_call_ycsd:' . $distribution_channel_id);
             }
             }
 
 
-            $data = [];
-            $data['send_time'] = date("Y-m-d H:i:s");
+            $data                = [];
+            $data['send_time']   = date("Y-m-d H:i:s");
             $data['action_type'] = $action_type;
             $data['action_type'] = $action_type;
             if ($action_type == 'Register') {
             if ($action_type == 'Register') {
-                $data['openid'] =  $param['openid'];
-                $data['uid'] = $param['uid'];
+                $data['openid'] = $param['openid'];
+                $data['uid']    = $param['uid'];
             } elseif ($action_type == 'CreateOrder') {
             } elseif ($action_type == 'CreateOrder') {
-                $data['orderSn'] =  $param['order_sn'];
-                $data['amount'] = $param['amount'];
-                $data['openid'] =  $param['openid'];
-                $data['uid'] = $param['uid'];
+                $data['orderSn'] = $param['order_sn'];
+                $data['amount']  = $param['amount'];
+                $data['openid']  = $param['openid'];
+                $data['uid']     = $param['uid'];
             } elseif ($action_type == 'CallBackOrder') {
             } elseif ($action_type == 'CallBackOrder') {
-                $data['orderSn'] =  $param['order_sn'];
-                $data['openid'] =  $param['openid'];
+                $data['orderSn'] = $param['order_sn'];
+                $data['openid']  = $param['openid'];
             }
             }
 
 
             $send_data = array(
             $send_data = array(
                 'send_time' => date("Y-m-d H:i:s"),
                 'send_time' => date("Y-m-d H:i:s"),
-                'data' => $data
+                'data'      => $data
             );
             );
             \Log::info('PushUserActionToQueue_openid:' . $data['openid'] . ' action_type:' . $action_type);
             \Log::info('PushUserActionToQueue_openid:' . $data['openid'] . ' action_type:' . $action_type);
             \Log::info('$send_data');
             \Log::info('$send_data');
@@ -395,7 +399,7 @@ class UserService
         $sql_format = "SELECT u.id,f.subscribe_time,(SELECT id from orders where uid = u.id and `status` = 'PAID' LIMIT 1)as oid  FROM users u
         $sql_format = "SELECT u.id,f.subscribe_time,(SELECT id from orders where uid = u.id and `status` = 'PAID' LIMIT 1)as oid  FROM users u
 JOIN force_subscribe_users f on u.id = f.uid and f.is_subscribed= 1
 JOIN force_subscribe_users f on u.id = f.uid and f.is_subscribed= 1
 WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
 WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
-        $result = DB::select(sprintf($sql_format, $uid));
+        $result     = DB::select(sprintf($sql_format, $uid));
         if (!$result) return false;
         if (!$result) return false;
 
 
         $is_has_force_subscribe_three_days = false;
         $is_has_force_subscribe_three_days = false;
@@ -421,13 +425,13 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
             return;
             return;
         }
         }
         $from_user = self::getById($from);
         $from_user = self::getById($from);
-        $to_user = self::getById($to);
+        $to_user   = self::getById($to);
         if (!$from_user) return;
         if (!$from_user) return;
         if (!$to_user) return;
         if (!$to_user) return;
         //阅读记录迁移***************************************
         //阅读记录迁移***************************************
-        $record = Redis::hgetall('book_read:' . $from);
+        $record      = Redis::hgetall('book_read:' . $from);
         $not_uid_key = ['last_read', 'sign_counts', 'sign_info', 'sign_day'];
         $not_uid_key = ['last_read', 'sign_counts', 'sign_info', 'sign_day'];
-        $data = [];
+        $data        = [];
         foreach ($record as $k => $item) {
         foreach ($record as $k => $item) {
             if (is_numeric($k) || in_array($k, $not_uid_key)) {
             if (is_numeric($k) || in_array($k, $not_uid_key)) {
                 $data[$k] = $item;
                 $data[$k] = $item;
@@ -463,13 +467,13 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
             foreach ($book_order as $book) {
             foreach ($book_order as $book) {
                 $temp[] = [
                 $temp[] = [
                     'distribution_channel_id' => $distribution_channel_id,
                     'distribution_channel_id' => $distribution_channel_id,
-                    'bid' => $book->bid,
-                    'book_name' => $book->book_name,
-                    'uid' => $to,
-                    'u' => $book->u,
-                    'fee' => 0,
-                    'created_at' => $book->created_at,
-                    'updated_at' => date('Y-m-d H:i:s'),
+                    'bid'                     => $book->bid,
+                    'book_name'               => $book->book_name,
+                    'uid'                     => $to,
+                    'u'                       => $book->u,
+                    'fee'                     => 0,
+                    'created_at'              => $book->created_at,
+                    'updated_at'              => date('Y-m-d H:i:s'),
                 ];
                 ];
             }
             }
             //\Log::info('book_order  is');
             //\Log::info('book_order  is');
@@ -479,23 +483,23 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
         //订阅记录(按章)
         //订阅记录(按章)
         $chapter_order_record = ChapterOrderService::getRecordByUid($from, '', '', true);
         $chapter_order_record = ChapterOrderService::getRecordByUid($from, '', '', true);
         if ($chapter_order_record) {
         if ($chapter_order_record) {
-            $temp = [];
-            $i = 1;
+            $temp          = [];
+            $i             = 1;
             $chapter_model = new ChapterOrder();
             $chapter_model = new ChapterOrder();
             $chapter_model->setCurrentTable($to);
             $chapter_model->setCurrentTable($to);
 
 
             foreach ($chapter_order_record as $chapter_order) {
             foreach ($chapter_order_record as $chapter_order) {
                 $temp[] = [
                 $temp[] = [
                     'distribution_channel_id' => $distribution_channel_id,
                     'distribution_channel_id' => $distribution_channel_id,
-                    'bid' => $chapter_order->bid,
-                    'cid' => $chapter_order->cid,
-                    'chapter_name' => $chapter_order->chapter_name,
-                    'book_name' => $chapter_order->book_name,
-                    'uid' => $to,
-                    'send_order_id' => 0,
-                    'fee' => 0,
-                    'created_at' => $chapter_order->created_at,
-                    'updated_at' => date('Y-m-d H:i:s')
+                    'bid'                     => $chapter_order->bid,
+                    'cid'                     => $chapter_order->cid,
+                    'chapter_name'            => $chapter_order->chapter_name,
+                    'book_name'               => $chapter_order->book_name,
+                    'uid'                     => $to,
+                    'send_order_id'           => 0,
+                    'fee'                     => 0,
+                    'created_at'              => $chapter_order->created_at,
+                    'updated_at'              => date('Y-m-d H:i:s')
                 ];
                 ];
                 if ($i % 100 == 0) {
                 if ($i % 100 == 0) {
                     $chapter_model->insert($temp);
                     $chapter_model->insert($temp);
@@ -512,17 +516,17 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
         if ($gift_result) {
         if ($gift_result) {
             $tmp = [];
             $tmp = [];
             foreach ($gift_result as $g) {
             foreach ($gift_result as $g) {
-                $tmp[] =  [
-                    'uid' => $to,
-                    'gift_id' => $g->gift_id,
-                    'bid' => $g->bid,
-                    'icon' => $g->icon,
-                    'name_desc' => $g->name_desc,
-                    'cost' => 0,
-                    'cost_reward' => $g->cost_reward,
+                $tmp[] = [
+                    'uid'           => $to,
+                    'gift_id'       => $g->gift_id,
+                    'bid'           => $g->bid,
+                    'icon'          => $g->icon,
+                    'name_desc'     => $g->name_desc,
+                    'cost'          => 0,
+                    'cost_reward'   => $g->cost_reward,
                     'cost_recharge' => $g->cost_recharge,
                     'cost_recharge' => $g->cost_recharge,
-                    'created_at' => $g->created_at,
-                    'updated_at' => date('Y-m-d H:i:s')
+                    'created_at'    => $g->created_at,
+                    'updated_at'    => date('Y-m-d H:i:s')
                 ];
                 ];
             }
             }
             //\Log::info('book gift   is');
             //\Log::info('book gift   is');
@@ -535,11 +539,11 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
             $tmp = [];
             $tmp = [];
             foreach ($result as $s) {
             foreach ($result as $s) {
                 $tmp[] = [
                 $tmp[] = [
-                    'uid' => $to,
+                    'uid'                     => $to,
                     'distribution_channel_id' => $distribution_channel_id,
                     'distribution_channel_id' => $distribution_channel_id,
-                    'bid' => $s->bid,
-                    'created_at' => $s->created_at,
-                    'updated_at' => date('Y-m-d H:i:s')
+                    'bid'                     => $s->bid,
+                    'created_at'              => $s->created_at,
+                    'updated_at'              => date('Y-m-d H:i:s')
                 ];
                 ];
             }
             }
             //\Log::info('user book shelf  is');
             //\Log::info('user book shelf  is');
@@ -550,14 +554,14 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
         $result = DB::table('year_orders')->where('uid', $from)->where('end_time', '>=', date('Y-m-d H:i:s'))->first();
         $result = DB::table('year_orders')->where('uid', $from)->where('end_time', '>=', date('Y-m-d H:i:s'))->first();
         if ($result) {
         if ($result) {
             DB::table('year_orders')->insert([
             DB::table('year_orders')->insert([
-                'uid' => $to,
-                'begin_time' => $result->begin_time,
-                'end_time' => $result->end_time,
+                'uid'                     => $to,
+                'begin_time'              => $result->begin_time,
+                'end_time'                => $result->end_time,
                 'distribution_channel_id' => $distribution_channel_id,
                 'distribution_channel_id' => $distribution_channel_id,
-                'send_order_id' => $result->send_order_id,
-                'fee' => $result->fee,
-                'created_at' => date('Y-m-d H:i:s'),
-                'updated_at' => $result->updated_at,
+                'send_order_id'           => $result->send_order_id,
+                'fee'                     => $result->fee,
+                'created_at'              => date('Y-m-d H:i:s'),
+                'updated_at'              => $result->updated_at,
             ]);
             ]);
             //\Log::info('year_orders  is');
             //\Log::info('year_orders  is');
             //print_r($result);
             //print_r($result);
@@ -565,19 +569,19 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
 
 
         //书币
         //书币
 
 
-        $to_user->balance += $from_user->balance;
-        $to_user->reward_balance +=   $from_user->balance;
-        $to_user->nickname = $from_user->nickname;
-        $to_user->sex = $from_user->sex;
-        $to_user->head_img = $from_user->head_img;
-        $to_user->country = $from_user->country;
-        $to_user->city = $from_user->city;
-        $to_user->province = $from_user->province;
+        $to_user->balance        += $from_user->balance;
+        $to_user->reward_balance += $from_user->balance;
+        $to_user->nickname       = $from_user->nickname;
+        $to_user->sex            = $from_user->sex;
+        $to_user->head_img       = $from_user->head_img;
+        $to_user->country        = $from_user->country;
+        $to_user->city           = $from_user->city;
+        $to_user->province       = $from_user->province;
         $to_user->save();
         $to_user->save();
         DB::table('crm_transfer')->insert([
         DB::table('crm_transfer')->insert([
-            'from_uid' => $from,
-            'to_uid' => $to,
-            'is_enable' => 1,
+            'from_uid'   => $from,
+            'to_uid'     => $to,
+            'is_enable'  => 1,
             'created_at' => date('Y-m-d H:i:s'),
             'created_at' => date('Y-m-d H:i:s'),
             'updated_at' => date('Y-m-d H:i:s')
             'updated_at' => date('Y-m-d H:i:s')
         ]);
         ]);