zz 6 лет назад
Родитель
Сommit
0aa242635f

+ 34 - 0
app/Http/Controllers/Wap/Order/OrdersController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Wap\Order;
 
 use App\Http\Controllers\Wap\BaseController;
 use App\Modules\Statistic\Services\AdVisitStatService;
+use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
 use App\Modules\User\Services\UserService;
 use App\Modules\Book\Services\BookService;
 use App\Modules\Channel\Services\PayTemplateService;
@@ -221,6 +222,9 @@ class OrdersController extends BaseController
                 $template_id = $t;
             }
         }
+        if( ($compare_id = $this->templateCompare()) ){
+            $template_id = $compare_id;
+        }
         \Log::info('recordFirstIntoPayPage:$template_id:' . $template_id);
         $res = ProductService::getChargeProduct($template_id);
         if (!$res) {
@@ -613,4 +617,34 @@ class OrdersController extends BaseController
         return $template_id;
     }
 
+    private function templateCompare(){
+        $start_time = env('TEMPLATE_COMPARE_START_TIME',0);
+        if(!in_array($this->distribution_channel_id,[2,14,211])){
+            return 0;
+        }
+        $user = $this->_user_info;
+        if(strtotime($user->created_at) < $start_time){
+            return 0;
+        }
+
+        $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPARE');
+        if($user){
+            $template_id = $user->attach;
+        }else{
+            $template_id = random_int(2,4);
+            DataAnalysisSelectUserService::create(
+                $this->uid,
+                $this->distribution_channel_id,
+                'TEMPLATE_COMPARE',
+                -1, $template_id);
+        }
+
+        //BookOrderService
+        if($template_id == 3 && !OrderService::isPaidUser($this->uid)){
+            $template_id = 2;
+        }
+
+        return $template_id;
+    }
+
 }

+ 1 - 1
app/Modules/Statistic/Services/DataAnalysisSelectUserService.php

@@ -45,7 +45,7 @@ class DataAnalysisSelectUserService
         try {
             return DataAnalysisSelectUser::where('uid', $uid)
                 ->where('type', $type)
-                ->select('uid')
+                ->select('uid','attach')
                 ->first();
         } catch (\Exception $e) {
         }