Forráskód Böngészése

Merge branch 'master' of iqiyoo:zhuishuyun_wap

onlinetest 6 éve
szülő
commit
9a811f66e4

+ 71 - 85
app/Console/Commands/BookTest.php

@@ -5,6 +5,7 @@ namespace App\Console\Commands;
 use App\Modules\Book\Services\BookSubscribleChapterService;
 use App\Modules\Subscribe\Services\ChapterOrderService;
 use App\Modules\YunQi\Models\BookUser;
+use App\Modules\YunQi\Models\YqUserBidRelation;
 use GuzzleHttp\Client;
 use Illuminate\Console\Command;
 
@@ -319,98 +320,83 @@ class BookTest extends Command
     private function you2(){
         $sql1 = 'TRUNCATE yq_stats';
         DB::update($sql1);
-        $result = [];
+
         $info = BookUser::where('type','ENABLE')->select('bid','uid','type','updated_at')
-            ->orderBy('updated_at')->limit(1000)->get();
+            ->orderBy('updated_at')->limit(1500)->get();
         $info2 = BookUser::where('type','GROUP_1')
-            ->select('bid','uid','type','updated_at')->orderBy('updated_at')->limit(1000)->get();
+            ->select('bid','uid','type','updated_at')->orderBy('updated_at')->limit(1500)->get();
+        $this->you2Type($info,'GROUP_2');
+        $this->you2Type($info2,'GROUP_1');
+    }
+
+
+    private function you2Type($info,$type){
+        $result = [];
+        $chapter_model = new ChapterOrder();
         foreach ($info as $item){
-            $bid_price = Order::where('uid',$item->uid)
-                ->where('status','PAID')
-                ->where('created_at','>=',$item->updated_at)
-                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
-                ->where('from_bid',$item->bid)
-                ->sum('price');
-            $all_price = Order::where('uid',$item->uid)
-                ->where('status','PAID')
-                ->where('created_at','>=',$item->updated_at)
-                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
-                ->sum('price');
-            $chapter_model = new ChapterOrder();
+            $to_bids = YqUserBidRelation::where('uid',$item->uid)->select('to_bid','created_at')->get()->pluck('created_at','to_bid')->all();
+            $from_bid = YqUserBidRelation::where('uid',$item->uid)->select('from_bid','created_at')->get()->pluck('created_at','from_bid')->all();
             $chapter_model->setCurrentTable($item->uid);
-            $chapter_fee = $chapter_model->where('uid', $item->uid)
-                ->where('bid', $item->bid)
-                ->where('created_at','>=',$item->updated_at)
-                ->sum('fee');
-            $all_fee = $chapter_model->where('uid', $item->uid)
-                ->where('created_at','>=',$item->updated_at)
-                ->sum('fee');
-            $books = DB::table('book_configs')->where('bid',$item->bid)->select('book_name')->first();
-            if($books){
-                $book_name = $books->book_name;
-            }else{
-                $book_name = 'un';
+            if($to_bids){
+                foreach ($to_bids as $to_bid=>$time){
+                    if(!$to_bid) continue;
+                    $fee = $chapter_model->where('uid',$item->uid)
+                        ->where('bid',$to_bid)
+                        ->where('created_at','>=',$time)
+                        ->sum('fee');
+                    $amount = Order::where('uid',$item->uid)
+                        ->where('from_bid',$to_bid)
+                        ->where('created_at','>=',$time)
+                        ->where('status','PAID')
+                        ->sum('price');
+                    $result[] = [
+                        'bid'=>$to_bid,
+                        'uid'=>$item->uid,
+                        'fee'=>$fee,
+                        'amount'=>$amount,
+                        'start_time'=>$time,
+                        'type'=>'to',
+                        'group'=>$type,
+                        'created_at'=>date('Y-m-d H:i:s'),
+                        'updated_at'=>date('Y-m-d H:i:s')
+                    ];
+                }
+                if($result){
+                    DB::table('yq_stats2')->insert($result);
+                    $result = [];
+                }
             }
-            $result[] = [
-                'uid'=>$item->uid,
-                'type'=>$item->type,
-                'amount'=>$bid_price?$bid_price:0,
-                'fee'=>$chapter_fee?$chapter_fee:0,
-                'bid'=>$item->bid,
-                'total_amount'=>$all_price?$all_price:0,
-                'total_fee'=>$all_fee?$all_fee:0,
-                'book_name'=>$book_name
-            ];
-        }
-        DB::table('yq_stats')->insert($result);
-        $result = [];
-        $item = null;
-        foreach ($info2 as $item){
-            $all_price = Order::where('uid',$item->uid)
-                ->where('status','PAID')
-                ->where('created_at','>=',$item->updated_at)
-                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
-                ->sum('price');
-            $chapter_model = new ChapterOrder();
-            $chapter_model->setCurrentTable($item->uid);
-            $all = $chapter_model->where('uid', $item->uid)
-                ->where('created_at','>=',$item->updated_at)
-                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
-                ->groupBy('bid')
-                ->select(DB::raw('sum(fee) as fee'),'bid','book_name')
-                ->orderBy('fee','desc')
-                ->first();
-            $all_fee = 0;
-            $bid = 0;
-            $book_name = '';
-            if($all){
-                $all_fee = $all->fee;
-                $bid = $all->bid;
-                $book_name = $all->book_name;
+
+            if($from_bid){
+                foreach ($from_bid as $to_bid=>$time){
+                    if(!$to_bid) continue;
+                    $fee = $chapter_model->where('uid',$item->uid)
+                        ->where('bid',$to_bid)
+                        ->where('created_at','>=',$time)
+                        ->sum('fee');
+                    $amount = Order::where('uid',$item->uid)
+                        ->where('from_bid',$to_bid)
+                        ->where('created_at','>=',$time)
+                        ->where('status','PAID')
+                        ->sum('price');
+                    $result[] = [
+                        'bid'=>$to_bid,
+                        'uid'=>$item->uid,
+                        'fee'=>$fee,
+                        'amount'=>$amount,
+                        'start_time'=>$time,
+                        'type'=>'from',
+                        'group'=>$type,
+                        'created_at'=>date('Y-m-d H:i:s'),
+                        'updated_at'=>date('Y-m-d H:i:s')
+                    ];
+                }
+                if($result){
+                    DB::table('yq_stats2')->insert($result);
+                    $result = [];
+                }
             }
-            $bid_price = Order::where('uid',$item->uid)
-                ->where('status','PAID')
-                ->where('created_at','>=',$item->updated_at)
-                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
-                ->where('from_bid',$bid)
-                ->sum('price');
-            $chapter_fee = $chapter_model->where('uid', $item->uid)
-                ->where('bid', $bid)
-                ->where('created_at','>=',$item->updated_at)
-                ->where('created_at','<=',date('Y-m-d H:i:s',strtotime($item->updated_at)+86400))
-                ->sum('fee');
-            $result[] = [
-                'uid'=>$item->uid,
-                'type'=>$item->type,
-                'amount'=>$bid_price?$bid_price:0,
-                'fee'=>$chapter_fee,
-                'bid'=>$bid,
-                'total_amount'=>$all_price?$all_price:0,
-                'total_fee'=>$all_fee?$all_fee:0,
-                'book_name'=>$book_name
-            ];
         }
-        DB::table('yq_stats')->insert($result);
     }
 
 }

+ 2 - 2
app/Http/Controllers/Wap/Book/ChapterController.php

@@ -1040,9 +1040,9 @@ class ChapterController extends BaseController
             }
             //Log::info($price_rate);
             $fee = ceil($chapter->size * $price_rate);
-            if($this->isRaisePrice()){
+            /*if($this->isRaisePrice()){
                 $fee = round($chapter->size * 0.018);
-            }
+            }*/
         }
         //首个计费章节书币价格以35书币为基准,低于35提升至35,原价高于35书币,维持原价
         if (isset($chapter->sequence) && isset($book_info->vip_seq)) {

+ 22 - 1
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\Channel\Services\ChannelService;
 use App\Modules\Statistic\Services\AdVisitStatService;
 use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
 use App\Modules\User\Services\UserService;
@@ -222,6 +223,13 @@ class OrdersController extends BaseController
                 $template_id = $t;
             }
         }
+
+        //男频站点 支付模板
+        if( ($male_site_template = $this->maleSite($this->distribution_channel_id)) ){
+            //\Log::info('$male_site_template is: '.$male_site_template);
+            $template_id = $male_site_template;
+        }
+
         if( ($compare_id = $this->templateCompare()) ){
             $template_id = $compare_id;
         }
@@ -622,7 +630,8 @@ class OrdersController extends BaseController
         if(!$start_time){
             return 0;
         }
-        if(!in_array($this->distribution_channel_id,[2,14,211])){
+        //if(!in_array($this->distribution_channel_id,[2,14,211,155,4427,4488,256,691,146,255,722,4364,5,202,318,4237,266,196,273,4236,148,8,4241,160,271,4053,123,4334,4487,4593,695,4025,4426,4174])){
+        if(!in_array($this->distribution_channel_id,[2,14,123,211,5,8,160,4236,4237,4241])){
             return 0;
         }
         $user = $this->_user_info;
@@ -650,4 +659,16 @@ class OrdersController extends BaseController
         return $template_id;
     }
 
+    private function maleSite($distribution_channel_id){
+        $info = ChannelService::getChannelCompanyInfo($distribution_channel_id);
+        //\Log::info('maleSite info is:');
+        //\Log::info($info);
+        if($info && isset($info->fans_gender)){
+            if($info->fans_gender == 1){
+                return 1;
+            }
+        }
+        return 0;
+    }
+
 }

+ 49 - 2
app/Http/Controllers/Wap/Pay/OrdersController.php

@@ -270,7 +270,7 @@ class OrdersController extends Controller
         }
         $from_bid = ReadRecordService::getSimpleFirstReadRecord($uid);
         $inner_send_order_id = ReadRecordService::getInnerSendOrderId($uid);
-        $result = $this->createUnPayOrder([
+        $init_order = [
             'distribution_channel_id' => $distribution_channel_id,
             'uid' => $uid,
             'product_id' => $product_id,
@@ -287,7 +287,14 @@ class OrdersController extends Controller
             'from_type' => $fromtype,
             'activity_id' => $activity_id,
             'inner_send_order_id'=>$inner_send_order_id
-        ]);
+        ];
+        $result = $this->createUnPayOrder($init_order);
+
+        //订单创建成功后增加统计
+        if($result)
+        {
+            $this->orderCreated($init_order);
+        }
 
         if ($request->get('suid')) {
             $this->createSubstituteOrder($result->id, $uid, $request->get('suid'));
@@ -357,6 +364,40 @@ class OrdersController extends Controller
         }
         return false;
     }
+
+    //订单创建后统计
+    private function orderCreated($init_order)
+    {
+        try {
+            if(isset($init_order['pay_merchant_id']))
+            {
+                $key = 'pay_merchant:'.$init_order['pay_merchant_id'];
+                Redis::hincrby($key,'unpaid_num',1);
+                Redis::hset($key,'last_create_time', time());
+            }
+
+        }catch (\Exception $e)
+        {
+
+        }
+    }
+
+    //订单回调后统计
+    private function orderPaid($init_order)
+    {
+        try {
+            if(isset($init_order['pay_merchant_id']))
+            {
+                $key = 'pay_merchant:'.$init_order['pay_merchant_id'];
+                Redis::hset($key,'unpaid_num',0);
+            }
+
+        }catch (\Exception $e)
+        {
+
+        }
+    }
+
     public function reportError(Request $request)
     {
         $data = $request->post('data');
@@ -1191,6 +1232,12 @@ class OrdersController extends Controller
                     }
                 }
             }
+
+            if(isset($order->pay_merchant_id) && $order->pay_merchant_id)//临时统计队列清0 用于报警
+            {
+                $key = 'pay_merchant:'.$order->pay_merchant_id;
+                Redis::hset($key,'unpaid_num',0);
+            }
         }catch (\Exception $e){}
 
     }

+ 47 - 17
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -749,11 +749,11 @@ class WelcomeController extends BaseController
             }
             //活动未开始
             if (time() < strtotime($activity_info->start_time)) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
             //活动结束
             if (time() > strtotime($activity_info->end_time)) {
-                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
+                return view('pay.order.longactivitysixtyeight', ['url' => '###', 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
             }
 
             if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
@@ -1577,21 +1577,21 @@ class WelcomeController extends BaseController
             $redirect_url = $request->input('redirect_url');
             $redirect_url = urldecode($redirect_url);
         }
-        $least_charge_amount = Order::select('id','price')
-            ->where('uid',$this->uid)
-            ->where('status','PAID')
-            ->where('created_at','>=',strtotime($activity_info->start_time)-60*86400)
+        $least_charge_amount = Order::select('id', 'price')
+            ->where('uid', $this->uid)
+            ->where('status', 'PAID')
+            ->where('created_at', '>=', strtotime($activity_info->start_time) - 60 * 86400)
             ->max('price');
         $type = 'litter';
-        $product_ids = [3962,3963];
+        $product_ids = [3962, 3963];
         $img = [
-            'litter'=>[
+            'litter' => [
                 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/8-active.png',
                 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/8.png',
                 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23-active.png',
                 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23.png',
             ],
-            'big'=>[
+            'big' => [
                 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23-active.png',
                 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/23.png',
                 'https://cdn-novel.iycdm.com/h5/activity-2019-01-17/58-active.png',
@@ -1599,21 +1599,21 @@ class WelcomeController extends BaseController
             ],
 
         ];
-        if($least_charge_amount && $least_charge_amount>=30){
+        if ($least_charge_amount && $least_charge_amount >= 30) {
             $type = 'big';
-            $product_ids = [3960,3961];
+            $product_ids = [3960, 3961];
         }
 
         //未开始
-        if(time() < strtotime($activity_info->start_time)){
-             return view('pay.order.greatColdActivity', ['url' => ['javascript:void(0)','javascript:void(0)'], 'code' => -1, 'type' => $type,'img'=>$img]);
+        if (time() < strtotime($activity_info->start_time)) {
+            return view('pay.order.greatColdActivity', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -1, 'type' => $type, 'img' => $img]);
         }
         //结束
-        if(time() > strtotime($activity_info->end_time)){
-            return view('pay.order.greatColdActivity', ['url' => ['javascript:void(0)','javascript:void(0)'], 'code' => -2, 'type' => $type,'img'=>$img]);
+        if (time() > strtotime($activity_info->end_time)) {
+            return view('pay.order.greatColdActivity', ['url' => ['javascript:void(0)', 'javascript:void(0)'], 'code' => -2, 'type' => $type, 'img' => $img]);
         }
         $url = [];
-        foreach ($product_ids as $product_id){
+        foreach ($product_ids as $product_id) {
             $param = [
                 'uid' => $this->uid,
                 'distribution_channel_id' => $this->distribution_channel_id,
@@ -1626,6 +1626,36 @@ class WelcomeController extends BaseController
             $url[] = env('CREATE_PAY_URL') . '?' . http_build_query($param);
         }
 
-        return view('pay.order.greatColdActivity', ['url' => $url, 'code' => 0, 'type' => $type,'img'=>$img]);
+        return view('pay.order.greatColdActivity', ['url' => $url, 'code' => 0, 'type' => $type, 'img' => $img]);
+    }
+
+    public function channelYearActivity(Request $request)
+    {
+        $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
+        $id = 2628;
+        $activity_info = ActivityService::getById($id);
+        if ($activity_info && $activity_info->product_id) {
+            $from = $request->input('fromtype', 'main');
+            $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
+            $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
+            $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
+            $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
+            Redis::sadd($uv_key, $this->uid);
+            Redis::hincrby($pv_key, date('Y-m-d'), 1);
+
+            $param = [
+                'uid' => $this->uid,
+                'distribution_channel_id' => $this->distribution_channel_id,
+                'product_id' => $activity_info->product_id,
+                'activity_id' => $activity_info->id,
+                'fromtype' => $from,
+                'limit' => 30,
+                'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
+            ];
+            $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
+            return view('pay.order.channelYearActivity', ['url' => $url]);
+        }
+        $url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
+        return redirect()->to($url);
     }
 }

+ 1 - 0
app/Http/Routes/Wap/WapRoutes.php

@@ -194,6 +194,7 @@ Route::group(['domain'=>env('WAP_DOMAIN'),'namespace'=>'App\Http\Controllers\Wap
         Route::get('sale/thanksGivingDayActivity','Web\WelcomeController@thanksGivingDayActivity');
 
         Route::get('sale/greatcold','Web\WelcomeController@greatColdActivity');
+        Route::get('sale/customvip','Web\WelcomeController@channelYearActivity');
         //继续阅读
         Route::get('continue','User\ReadRecordController@latestRead');
 

+ 91 - 0
resources/views/pay/order/channelYearActivity.blade.php

@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8" />
+    <meta
+            name="viewport"
+            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
+    />
+    <link rel=icon type=image/png href="data:image/png;base64,iVBORw0KGgo=">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+    <title>尊享畅读会员</title>
+    <style>
+        html,
+        body {
+            margin: 0 auto;
+            padding: 0;
+            max-width: 450px;
+            font-size: 100px;
+        }
+
+        html {
+            background: #1c263b;
+        }
+
+        .main_box {
+            font-size: 0;
+            position: relative;
+        }
+
+        .main_box img {
+            width: 100%;
+        }
+
+        .time {
+            font-size: .14rem;
+            font-weight: bold;
+            text-align: center;
+            color: #fff;
+        }
+
+        .recharge-item {
+            font-size: 0;
+            width: 90%;
+            margin: .3rem auto;
+        }
+
+        .recharge_box_one {
+            width: 85%;
+            margin: 0 auto;
+            position: absolute;
+            top: 78%;
+            left: 50%;
+            transform: translateX(-50%);
+        }
+
+        .main_box img,
+        a {
+            -webkit-tap-highlight-color: transparent;
+            text-decoration: none;
+            color: currentColor;
+        }
+
+        .recharge_box_one p {
+            font-size: .22rem;
+            box-shadow:0px 11px 18px 0px rgba(28,35,55,0.26);
+            color: #584124;
+            text-align: center;
+            font-weight: bolder;
+            border-radius: 50px;
+            background: #f3f2ec;
+            padding: .08rem 0;
+            font-family: system, "Microsoft Yahei";
+        }
+
+        .d_none {
+            display: none;
+        }
+    </style>
+</head>
+
+<body>
+<main class="main_box">
+    <img src="https://cdn-novel.iycdm.com/h5/activity-channel-year/bg.jpg" alt="" />
+    <div class="recharge_box_one">
+        <a href="{{$url}}" class="beginning">
+            <p>开通VIP</p>
+        </a>
+    </div>
+</main>
+</body>
+</html>