Parcourir la source

Merge branch 'stabble' of iqiyoo:zhuishuyun_wap into stabble

onlinetest il y a 6 ans
Parent
commit
d850d0a1d5

+ 23 - 3
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -13,6 +13,7 @@ use App\Modules\Statistic\Services\DataAnalysisChapterService;
 use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
 use App\Modules\Statistic\Services\WapVisitStatService;
 use App\Modules\Subscribe\Services\OrderService;
+use App\Modules\User\Services\ForceSubscribeUserIService;
 use App\Modules\User\Services\ReadRecordStatsService;
 use App\Modules\YunQi\Services\BookUserService;
 use Illuminate\Http\Request;
@@ -70,6 +71,10 @@ class ChapterController extends BaseController
     //强关时间
     private $force_subscribe_time = null;
 
+    //关注的appid
+    private  $need_subscribe_appid;
+    private  $need_subscribe_name;
+
     /**
      * @apiVersion 1.0.0
      * @apiDescription 章节列表不分页
@@ -585,8 +590,8 @@ class ChapterController extends BaseController
                     $my_log = myLog('special');
                     $my_log->info('balance lack remind');
                 }
-                //return response()->error('WAP_BOOK_BALANCE_PAY', $data);
-                return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
+                return response()->error('WAP_BOOK_BALANCE_PAY', $data);
+                //return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
             } else {
                 if($special_user_log && $special_user_log == $this->uid){
                     $my_log = myLog('special');
@@ -829,12 +834,17 @@ class ChapterController extends BaseController
 
     private function forceSubscribe()
     {
+        if($this->need_subscribe_appid){
+            $src = $this->getRcodeInfo(['appid' => $this->need_subscribe_appid], $this->book_info->bid);
+            if (empty($src)) return false;
+            $url = '/subscribe/qrcode?img=' . urlencode($src) . '&title=' . $this->need_subscribe_name . '&uid=' . $this->uid;
+            return ['error_type' => 'WAP_NOT_SUBSCRIBE', 'data' => ['src' => $url, 'head_img' => '']];
+        }
         //获取公众号信息
         $officialAccount = $this->getOfficialAccount();
         if (!$officialAccount || empty($officialAccount->appid)) {
             return false;
         }
-
         //如果是链接强关,则跳转
         $sub_type = $this->getSubscribeType($officialAccount->appid, $this->book_info->bid);
 
@@ -1079,6 +1089,16 @@ class ChapterController extends BaseController
      */
     protected function getSubscribe()
     {
+        if($this->send_order_id &&
+            in_array($this->distribution_channel_id,explode(',',env('INNER_CHANNEL_SUB','1'))) &&
+            ($send_order_info = SendOrderService::getById($this->send_order_id)) &&
+            $send_order_info->promotion_type == 'EXTERNAL'
+        ){
+            $subscribe_info = ForceSubscribeUserIService::subscribes($this->uid,$this->distribution_channel_id,$this->send_order_id);
+            $this->need_subscribe_appid = $subscribe_info['appid'];
+            $this->need_subscribe_name = $subscribe_info['name'];
+            return $subscribe_info['is_subscribed'];
+        }
         $res = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
         if ($res) {
             $this->force_subscribe_time = isset($res->created_at)?$res->created_at:null;

+ 19 - 7
app/Http/Controllers/Wap/Order/OrdersController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\Wap\Order;
 
 use App\Http\Controllers\Wap\BaseController;
+use App\Modules\Book\Services\BookConfigService;
 use App\Modules\Channel\Services\ChannelService;
 use App\Modules\Cpa\Services\AdvertiseUserQueueService;
 use App\Modules\Cpa\Services\AdvertiseUsersService;
@@ -199,13 +200,23 @@ class OrdersController extends BaseController
         //}
         \Log::info('order:$template_id:' . $template_id);
         \Log::info('order:$distribution_channel_id:' . ($this->distribution_channel_id));
-
+        $book_config = null;
+        if($bid){
+            $bid = Hashids::decode($bid)[0];
+            //$book = BookService::getBookById($bid);
+            $book_config = BookConfigService::getBookById($bid);
+        }
         if ($template_id == 2) { //模板2只有在长篇小说过来的用户才显示
             //部分渠道需要2元模板不管哪个入口进来都展示
             $exclude_channels = explode(',', env('PRICE_TWO_SHOW_ALL_CHANNEL'));
             if(!in_array($this->distribution_channel_id,$exclude_channels))
             {
-                if ($bid) {
+                if($book_config){
+                    if($book_config->charge_type == 'BOOK') $template_id = 1;
+                }else{
+                    $template_id = 1;
+                }
+                /*if ($bid) {
                     $bid = Hashids::decode($bid)[0];
                     \Log::info('order:$bid:' . $bid);
                     $book = BookService::getBookById($bid);
@@ -215,10 +226,10 @@ class OrdersController extends BaseController
                     }
                 } else {
                     $template_id = 1;
-                }
+                }*/
             }
         }
-        if($temp){
+        /*if($temp){
             $temp_bid = 0;
             try{
                 $temp_bid =  Hashids::decode($temp)[0];
@@ -228,7 +239,7 @@ class OrdersController extends BaseController
             if ($t) {
                 $template_id = $t;
             }
-        }
+        }*/
 
         //男频站点 支付模板
         if( ($male_site_template = $this->maleSite($this->distribution_channel_id)) ){
@@ -285,9 +296,10 @@ class OrdersController extends BaseController
         }
         //\Log::info('ad-tu:uid:'.$uid.':'.$appad);
         foreach ($res as $v) {
-            if($appad && $v->price == 100){
-                //continue;
+            if($template_id == 7 && $book_config && $book_config->charge_type == 'BOOK' && $v->price == 2){
+                continue;
             }
+
             if ($v->type == 'NEW_USER' && $is_first_recharge) {
                 if (env('NO_NEW_USER_CHARGE') &&
                     in_array(

+ 38 - 31
app/Modules/User/Services/ForceSubscribeUserIService.php

@@ -14,67 +14,74 @@ use Redis;
 
 class ForceSubscribeUserIService
 {
+    private static $official_name = [];
 
-    public static function subscribes($uid,$distribution_channel_id,$send_order_id){
+    public static function subscribes($uid, $distribution_channel_id, $send_order_id)
+    {
         $subscribe_info = self::getUserSubscribes($uid);
         //没关注
-        if($subscribe_info->isNotEmpty() &&
-            $subscribe_info->search(function ($item,$k)use ($send_order_id) {  return $item->send_order_id == $send_order_id;}) !== false ){
-            return ['is_subscribed'=>true,'appid'=>''];
+        if ($subscribe_info->isNotEmpty() &&
+            $subscribe_info->search(
+                function ($item, $k) use ($send_order_id) {
+                    return $item->send_order_id == $send_order_id;
+                }
+            ) !== false
+        ) {
+            return ['is_subscribed' => true, 'appid' => '','name'=>''];
         }
         $subscribe_appdis = $subscribe_info->pluck('appid')->all();
-        echo '$subscribe_appdis'.PHP_EOL;
-        print_r($subscribe_appdis);
+
         $useable_appdis = self::getOfficialAccount($distribution_channel_id);
-        echo '$useable_appdis'.PHP_EOL;
-        print_r($useable_appdis);
+
         //没有可用的公众号
-        if(empty($useable_appdis)) return ['is_subscribed'=>true,'appid'=>''];
-        echo '2222222222222222222222'.PHP_EOL;
+        if (empty($useable_appdis)) return ['is_subscribed' => true, 'appid' => '','name'=>''];
         $appids = collect($useable_appdis)->diff($subscribe_appdis)->toArray();
-        if($appids){
-            echo '33333333333333333333'.PHP_EOL;
-            return ['is_subscribed'=>false,'appid'=>$appids[0]];
+        if ($appids) {
+            return ['is_subscribed' => false, 'appid' => $appids[0],'name'=>self::$official_name[$appids[0]]];
         }
-        return ['is_subscribed'=>true,'appid'=>''];
+        return ['is_subscribed' => true, 'appid' => '','name'=>''];
     }
 
     //用户强关公众号
-    public static function getUserSubscribes($uid){
-       return  ForceSubscribeUsers::where('uid',$uid)->where('is_subscribed',1)->select('appid','send_order_id')->get();
+    public static function getUserSubscribes($uid)
+    {
+        return ForceSubscribeUsers::where('uid', $uid)->where('is_subscribed', 1)->select('appid', 'send_order_id')->get();
     }
 
     //可用公众号
-    public static function getOfficialAccount($distribution_channel_id){
-        $result =  OfficialAccount::where('distribution_channel_id',$distribution_channel_id)
-            ->where('is_auth',1)
-            ->where('is_enabled',1)
-            ->where('subscribe_top_num','>',0)
-            ->where('subscribe_day_maximum','>',0)
+    public static function getOfficialAccount($distribution_channel_id)
+    {
+        $result = OfficialAccount::where('distribution_channel_id', $distribution_channel_id)
+            ->where('is_auth', 1)
+            ->where('is_enabled', 1)
+            ->where('subscribe_top_num', '>', 0)
+            ->where('subscribe_day_maximum', '>', 0)
             ->orderBy('sort_no', 'desc')
-            ->select('appid','subscribe_top_num','subscribe_day_maximum')
+            ->select('appid', 'subscribe_top_num', 'subscribe_day_maximum','nickname')
             ->get();
-        if($result->isEmpty()) return [];
+        if ($result->isEmpty()) return [];
         $data = [];
-        foreach ($result as $value){
+        foreach ($result as $value) {
+            self::$official_name[$value->appid] = $value->nickname;
             $fans_stats = self::getOfficialAccountFanStats($value->appid);
             {
                 $fans_stats['day_fans'] < $value->subscribe_day_maximum
-                && $fans_stats['all_fans'] < $value->subscribe_top_num && array_push($data,$value->appid);
+                && $fans_stats['all_fans'] < $value->subscribe_top_num && array_push($data, $value->appid);
             }
         }
         return $data;
     }
 
     //粉丝数
-    public static function getOfficialAccountFanStats($appid){
+    public static function getOfficialAccountFanStats($appid)
+    {
         $total_fans_cancel_nums = (int)Redis::hget('day_appid_fans_nums_appid:cancel:' . $appid, 'total');
 
-        $total_fan_info = Redis::hmget('day_appid_fans_nums_appid:add:' . $appid,['total',date('Y-m-d')]);
-        $total_fans_add_nums = $total_fan_info[0]?$total_fan_info[0]:0;
-        $day_fans = $total_fan_info[1]?$total_fan_info[1]:0;
+        $total_fan_info = Redis::hmget('day_appid_fans_nums_appid:add:' . $appid, ['total', date('Y-m-d')]);
+        $total_fans_add_nums = $total_fan_info[0] ? $total_fan_info[0] : 0;
+        $day_fans = $total_fan_info[1] ? $total_fan_info[1] : 0;
         $all_fans = $total_fans_add_nums - $total_fans_cancel_nums;
-        return compact('day_fans','all_fans');
+        return compact('day_fans', 'all_fans');
     }
 
     public static function getForceSubscribeByUidOpenid($uid) {