Browse Source

month test

zz 5 years ago
parent
commit
f6dfc41668

+ 52 - 54
app/Http/Controllers/Wap/Order/OrdersController.php

@@ -196,18 +196,11 @@ class OrdersController extends BaseController
         if (!$this->checkUid()) {
             return response()->error('WAP_NOT_LOGIN');
         }
-        /*if (env('OTHER_PAY_TEMPLATE') &&
-            in_array($this->distribution_channel_id,
-                explode(',', env('OTHER_PAY_TEMPLATE')))
-        ) {
-            $template_id = 3;
-        } else {*/
+
         $bid = $request->input('bid', '');
         $temp = $bid;
         $template_id = PayTemplateService::getPayTemplate($this->distribution_channel_id);
-        //}
-        \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];
@@ -216,18 +209,15 @@ class OrdersController extends BaseController
         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($book_config){
-                    if($book_config->charge_type == 'BOOK') $template_id = 1;
+            if (!in_array($this->distribution_channel_id, $exclude_channels)) {
+                if ($book_config) {
+                    if ($book_config->charge_type == 'BOOK') $template_id = 1;
                 }
             }
         }
 
-
         //男频站点 支付模板
         if (($male_site_template = $this->maleSite($this->distribution_channel_id))) {
-            //\Log::info('$male_site_template is: '.$male_site_template);
             $template_id = $male_site_template;
         }
 
@@ -248,7 +238,7 @@ class OrdersController extends BaseController
             $template_id = 10;
         }*/
         $outstandingYearOrder = $this->outstandingYearOrder($this->uid);
-        \Log::info('recordFirstIntoPayPage:$template_id:' . $template_id);
+
         $res = ProductService::getChargeProduct($template_id);
         if (!$res) {
             return response()->error('WAP_SYS_ERROR');
@@ -267,29 +257,12 @@ class OrdersController extends BaseController
         //$user = $this->_user_info;
         $uid = $this->uid;
         $is_first_recharge = OrderService::judgeUserFirstRecharge($uid);
-        //yqLog('user')->info('user is ',['user'=>$user]);
-        //yqLog('user')->info('user is ',['charge_count'=>$user->charge_count]);
+
         $data = [];
         $appad = 0;
-     /*   if (in_array($this->distribution_channel_id, explode(',', env('ADS_OPEN_SITE')))) {
-            $appad = 0;
-            $my_bid = $bid;
-            if ($appad) {
-                try {
-                    AdvertiseUsersService::addAdAccessRec(['uid' => $this->uid,
-                        'bid' => $my_bid,
-                        'position' => 'RECHARGE',
-                        'created_at' => date('Y-m-d H:i:s'),
-                        'updated_at' => date('Y-m-d H:i:s'),
-                        'remark' => $request->url()
-                    ]);
-                } catch (\Exception $e) {
-                    \Log::error('insert into advertise_access_rec failded:' . $e->getMessage());
-                }
-            }
-        }*/
+
         $property = UserDivisionCpcPropertyService::getUserProperty($this->uid);
-        //\Log::info('ad-tu:uid:'.$uid.':'.$appad);
+
         foreach ($res as $v) {
             if ($template_id == 7 && $book_config && $book_config->charge_type == 'BOOK' && $v->price == 2) {
                 continue;
@@ -307,13 +280,14 @@ class OrdersController extends BaseController
                 $temp = [
                     'price' => (float)$v->price . '元',
                     'is_year_order' => 0,
+                    'is_month_order' => 0,
                     'text' => sprintf('%s+%s书币', $v->price * 100, $v->given),
                     'first_charge' => true,
                     'today_special' => false,
                     'save_text' => round($v->given / 100, 1) . '元',
                     'product_id' => $v->id,
                     'show_free_ads' => $appad,
-                    'gift'=>BookGiftsService::chargeGiveGift($property,$v->price,$v->type)
+                    'gift' => BookGiftsService::chargeGiveGift($property, $v->price, $v->type)
                 ];
                 $data[] = $temp;
             } elseif ($v->type == 'YEAR_ORDER') {
@@ -325,16 +299,38 @@ class OrdersController extends BaseController
                 $temp = [
                     'price' => (int)$v->price . '元',
                     'is_year_order' => 1,
+                    'is_month_order' => 0,
                     'text' => $text,
                     'first_charge' => false,
                     'today_special' => $outstandingYearOrder,
                     'save_text' => $save_text,
                     'product_id' => $v->id,
                     'show_free_ads' => $appad,
-                    'gift'=>BookGiftsService::chargeGiveGift($property,$v->price,$v->type)
+                    'gift' => BookGiftsService::chargeGiveGift($property, $v->price, $v->type)
                 ];
                 $data[] = $temp;
-            } else {
+            } /*elseif ($v->type == 'MOUTH') {
+                if (!$property) $property = 'low';
+                if (in_array($this->distribution_channel_id, explode(',', redisEnv('INNER_SITES')))
+                    && in_array($property, ['low', 'medium'])
+                ) {
+                    $data[] = [
+                        'price' => (int)$v->price . '元',
+                        'is_year_order' => 0,
+                        'is_month_order' => 1,
+                        'text' => sprintf('%s元包月 全站万本精彩小说免费看', (int)$v->price),
+                        'first_charge' => false,
+                        'today_special' => false,
+                        'save_text' => '每月自动续费,可随时关闭',
+                        'product_id' => $v->id,
+                        'show_free_ads' => false,
+                        'link' => generateMonthOrderUrl($this->uid),
+                        'gift' => BookGiftsService::chargeGiveGift($property, $v->price, $v->type)
+                    ];
+                } else {
+                    continue;
+                }
+            }*/ else {
                 if ($v->type == 'NEW_USER') {
                     continue;
                 }
@@ -349,13 +345,14 @@ class OrdersController extends BaseController
                 $temp = [
                     'price' => (float)$v->price . '元',
                     'is_year_order' => 0,
+                    'is_month_order' => 0,
                     'text' => $text,
                     'first_charge' => false,
                     'today_special' => ($v->is_default == 1 && $outstandingYearOrder == false) ? true : false,
                     'save_text' => $save_text,
                     'product_id' => $v->id,
                     'show_free_ads' => $appad,
-                    'gift'=>BookGiftsService::chargeGiveGift($property,$v->price,$v->type)
+                    'gift' => BookGiftsService::chargeGiveGift($property, $v->price, $v->type)
                 ];
                 $data[] = $temp;
             }
@@ -705,11 +702,11 @@ class OrdersController extends BaseController
             return 0;
         }
 
-        $template_10_site = redisEnv('TEMPLATE_10_SITE','');
-        if(!$template_10_site){
+        $template_10_site = redisEnv('TEMPLATE_10_SITE', '');
+        if (!$template_10_site) {
             return 0;
         }
-        if (!in_array($this->distribution_channel_id,explode(',',$template_10_site))) {
+        if (!in_array($this->distribution_channel_id, explode(',', $template_10_site))) {
             return 0;
         }
 
@@ -720,16 +717,16 @@ class OrdersController extends BaseController
 
         $user = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'TEMPLATE_COMPAREV10_2');
         if ($user) {
-            return  $user->attach;
+            return $user->attach;
         } else {
-            if( $this->uid % 2 == 0 ){
+            if ($this->uid % 2 == 0) {
                 DataAnalysisSelectUserService::create(
                     $this->uid,
                     $this->distribution_channel_id,
                     'TEMPLATE_COMPAREV10_2',
                     -1, 10);
                 return 10;
-            }else{
+            } else {
                 DataAnalysisSelectUserService::create(
                     $this->uid,
                     $this->distribution_channel_id,
@@ -750,9 +747,9 @@ class OrdersController extends BaseController
             return 0;
         }
 
-        $template_compare_sites = redisEnv('TEMPLATE_COMPARE_SITES',0);
+        $template_compare_sites = redisEnv('TEMPLATE_COMPARE_SITES', 0);
 
-        if (!in_array($this->distribution_channel_id, explode(',',$template_compare_sites))) {
+        if (!in_array($this->distribution_channel_id, explode(',', $template_compare_sites))) {
             return 0;
         }
         $user = $this->_user_info;
@@ -836,7 +833,7 @@ class OrdersController extends BaseController
         }*/
 
         $exist = DataAnalysisSelectUserService::getByUidAndType($uid, 'OUTSTANDING_YEAR_ORDER_V2');
-        if($exist) return  true;
+        if ($exist) return true;
 
         return false;
 
@@ -848,11 +845,12 @@ class OrdersController extends BaseController
         return $is_show_outstanding_year_order;*/
     }
 
-    public function exchangeList(){
-        foreach ($this->chargeList as &$item){
-            if(!$item->switch_to) continue;
-            $order = Order::where('uid',$this->uid)->where('status','PAID')->where('product_id',$item->id)->first();
-            if($order){
+    public function exchangeList()
+    {
+        foreach ($this->chargeList as &$item) {
+            if (!$item->switch_to) continue;
+            $order = Order::where('uid', $this->uid)->where('status', 'PAID')->where('product_id', $item->id)->first();
+            if ($order) {
                 $change = ProductService::getProductSingle($item->switch_to);
                 $item->id = $change->id;
                 $item->price = $change->price;

+ 6 - 20
app/Http/Controllers/Wap/Pay/MonthOrderController.php

@@ -21,12 +21,6 @@ use Log;
 class MonthOrderController extends Controller
 {
 
-    const APP_ID = 'Aekgrv87yo5wxnl715';
-
-    const  APP_SECRET = '57gwsnd158ib2sn7wluq5716brp8fzm';
-
-    const KEY = 'sn7wluq5716brp8fzm';
-
     public function getH5RedirectUrl(Request $request){
         $app_id = 'Aekgrv87yo5wxnl715';
         $app_secret = '57gwsnd158ib2sn7wluq5716brp8fzm';
@@ -61,22 +55,13 @@ class MonthOrderController extends Controller
         return $client->get($url)->getBody()->getContents();
     }
 
-    private function generateUrl($plan_id,$user_id,$ip){
-        $app_id = self::APP_ID;
-        $app_secret = self::APP_SECRET;
-        $key = self::KEY;
-        $sign = _sign(compact('app_id','app_secret','plan_id','user_id','ip'),$key.$key);
-        $sign = strtoupper($sign);
-        $url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
-        return $url;
-    }
-
 
     public function signCallBack(Request $request){
         Log::info('signCallBack------------------------------------------signCallBack');
         Log::info($request->all());
         Log::info($request->getMethod());
-        $key = 'sn7wluq5716brp8fzm';
+        //$key = 'sn7wluq5716brp8fzm';
+        $key = env('MONTH_ORDER_KEY');
         $app_id = $request->post('app_id');
         $plan_id = $request->post('plan_id');
         $user_id = $request->post('user_id');
@@ -94,7 +79,8 @@ class MonthOrderController extends Controller
         Log::info('orderCallBack------------------------------------------orderCallBack');
         Log::info($request->all());
         Log::info($request->getMethod());
-        $key = 'sn7wluq5716brp8fzm';
+
+        $key = env('MONTH_ORDER_KEY');//'sn7wluq5716brp8fzm';
         $app_id = $request->post('app_id');
         $plan_id = $request->post('plan_id',0);
         $user_id = $request->post('user_id');
@@ -138,12 +124,12 @@ class MonthOrderController extends Controller
         $init_order = [
             'distribution_channel_id' => $distribution_channel_id,
             'uid' => $uid,
-            'product_id' => $product_id,
+            'product_id' => 6826,
             'price' => $price / 100,
             'pay_type' => $count,
             'trade_no' => $trade_no,
             'pay_merchant_source' => 'MONTH',
-            'pay_merchant_id' => 0,
+            'pay_merchant_id' => 99,
             'create_ip' => '',
             'send_order_id' => '',
             'send_order_name' => '',

+ 21 - 1
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -37,6 +37,8 @@ class WelcomeController extends BaseController
 {
 
     private $force_subscribe_info = null;
+
+    private $property = '';
     /**
      * 首页
      */
@@ -187,6 +189,7 @@ class WelcomeController extends BaseController
 
         //用户分割
         $this->userPproperty($user->openid);
+        $month_order_info = $this->monthOrderInfo();
         $options = json_encode([
             'distribution_channel_id' => (int)$this->distribution_channel_id,
             'send_order_id' => $send_order_id,
@@ -232,7 +235,8 @@ class WelcomeController extends BaseController
             'self_pa_ad_switch'=>$adTargetId && $pdd_ad ? 1 : 0,//自有平台广告开关
             'banners'=>$banners,
             'guidepersonalaccount'=>$this->guidePersonalAccount(),
-            'cpc_channel'=>$cpc_channel
+            'cpc_channel'=>$cpc_channel,
+            'month_order_info'=>$month_order_info
         ]);
         if ($this->uid == env('SPECIAL_USER_LOG', 2)) {
             myLog('special')->info('welcome --------------------------');
@@ -2100,11 +2104,13 @@ class WelcomeController extends BaseController
     private function userPproperty($openid){
         $old = UserDivisionCpcPropertyService::userLevel($openid);
         if(!$old) return ;
+        $this->property = $old->property;
         if($old->type != 'NEW') return ;
         $send_data = array(
             'type' => 'visit',
             'data' => ['openid'=>$openid,'uid'=>$this->uid]
         );
+
         try {
             $send = new SendStatisticsList($send_data);
             $job = ($send)->onConnection('rabbitmq')->delay(0)->onQueue('send_statistics_list');
@@ -2181,5 +2187,19 @@ class WelcomeController extends BaseController
             }
         }
     }
+    private function monthOrderInfo(){
+        $property = $this->property;
+        if (!$property) $property = 'low';
+        if (in_array($this->distribution_channel_id, explode(',', redisEnv('OPEN_ORDER_INNER_SITES')))
+            && in_array($property, ['low', 'medium'])
+        ) {
+            return [
+                'price'=>'30元',
+                'text' => '30元包月 全站万本精彩小说免费看',
+                'link'=>generateMonthOrderUrl($this->uid)
+            ];
+        }
+        return '';
+    }
 
 }

+ 12 - 0
app/Libs/Helpers.php

@@ -615,4 +615,16 @@ function specialChannelAuthInfoV2($distribution_channel_id){
         '5764'=>'wxdb47c48bbfa19cb7',
         '5808'=>'wx99b70748c46d0533'
     ];*/
+
+     function generateMonthOrderUrl($user_id){
+        $app_id = env('MONTH_ORDER_APPID');
+        $app_secret = env('MONTH_ORDER_APP_SECRET');
+        $key = env('MONTH_ORDER_KEY');
+        $plan_id = env('MONTH_ORDER_PLAN_ID');
+        $ip = _getIp();
+        $sign = _sign(compact('app_id','app_secret','plan_id','user_id','ip'),$key.$key);
+        $sign = strtoupper($sign);
+        $url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
+        return $url;
+    }
 }

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

@@ -43,7 +43,7 @@ class UserMonthService
 
     public static function getOrderByOrder($trade_no,$out_trade_no){
         $model = new UserMonthOrder();
-        $info = $model->where('trade_no',$trade_no)->orWhere('out_trade_no',$out_trade_no)->first();
+        $info = $model->where('trade_no',$trade_no)->first();
         return $info;
     }
 }