소스 검색

Merge branch 'master' of iqiyoo:zhuishuyun_wap

onlinetest 6 년 전
부모
커밋
8457ff32fb

+ 187 - 0
app/Console/Commands/CheckOrderStatus.php

@@ -0,0 +1,187 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Jobs\SendTexts;
+use App\Modules\SendOrder\Services\SendOrderService;
+use App\Modules\Subscribe\Services\YearOrderService;
+use App\Modules\User\Models\UserMonthSign;
+use App\Modules\User\Services\UserMonthService;
+use App\Modules\User\Services\UserService;
+use Illuminate\Console\Command;
+use App\Modules\Subscribe\Services\OrderService;
+use Redis;
+use Log;
+use DB;
+
+class CheckOrderStatus extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'checkOrderStatus {--uid= : the uid}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Command description';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        //$this->checkOne(157286149);
+        $uid = $this->option('uid');
+        if($uid) {
+            $this->checkOne($uid);
+        }else{
+            $result = UserMonthSign::where('created_at','>=',date('Y-m-d H:i:s',time()-1800))->select('uid')->get();
+            if($result->isNotEmpty()){
+                foreach ($result as $item){
+                    $this->checkOne($item->uid);
+                }
+            }
+        }
+    }
+    public function checkOne($uid){
+        //int $user_id,int $plan_id,string $app_id,string $key,string $app_secret
+        $plan_id = env('MONTH_ORDER_PLAN_ID');
+        $app_id = env('MONTH_ORDER_APPID');
+        $key = env('MONTH_ORDER_KEY');
+        $app_secret = env('MONTH_ORDER_APP_SECRET');
+        $result = UserMonthService::checkOrderStatus($uid,$plan_id,$app_id,$key,$app_secret);
+
+        if(isset($result['code']) && !$result['code']){
+            echo sprintf('sign fail ,uid is :%s',$uid).PHP_EOL;
+            return '';
+        }
+        //print_r($result);
+        $trade_no = $result['trade_no'];
+        $out_trade_no = $result['out_trade_no'];
+        $money = $result['money'];
+        if(empty($trade_no) || empty($out_trade_no) || empty($money)){
+            Log::info(sprintf('uid is : %s,order is not exist',$uid));
+            echo sprintf('uid is : %s,order is not exist',$uid).PHP_EOL;
+            return '';
+        }
+        Log::info($result);
+        if (!UserMonthService::getOrderByOrder($trade_no, $out_trade_no)) {
+            Log::info('deal uid is :'.$uid);
+            UserMonthService::createLOrder($uid, $plan_id, $money, $trade_no, $out_trade_no);
+            $this->addOrderAndVip($uid, $out_trade_no, $trade_no, $money);
+        }
+    }
+
+    private function addOrderAndVip($uid, $out_trade_no, $trade_no, $price)
+    {
+
+        $order_info = OrderService::getByTradeNo($out_trade_no);
+        //订单已经存在
+        if ($order_info) {
+            return;
+        }
+        $user_info = UserService::getById($uid);
+        if (!$user_info) return;
+        $this->createOrder($uid, $user_info->distribution_channel_id, 0, $price, $out_trade_no, $trade_no);
+        YearOrderService::save_month_order([
+            'uid' => $uid,
+            'distribution_channel_id' => $user_info->distribution_channel_id,
+            'fee' => $price / 100,
+            'send_order_id' => 0
+        ]);
+    }
+
+    private function createOrder($uid, $distribution_channel_id, $product_id, $price, $trade_no, $transaction_id)
+    {
+        $count = OrderService::getUserChargeTimes($uid);
+        $count = $count + 1;
+        $send_order_id = 0;
+        try {
+            $send_order_id = (int)Redis::hget('book_read:' . $uid, 'send_order_id');
+        } catch (\Exception $e) {
+        }
+        $send_order_name = '';
+        if ($send_order_id) {
+            $send_order_info = SendOrderService::getById($send_order_id);
+            if ($send_order_info && isset($send_order_info->name) && !empty($send_order_info->name)) {
+                $send_order_name = $send_order_info->name;
+            }
+        }
+        $init_order = [
+            'distribution_channel_id' => $distribution_channel_id,
+            'uid' => $uid,
+            'product_id' => 6826,
+            'price' => $price / 100,
+            'pay_type' => $count,
+            'trade_no' => $trade_no,
+            'pay_merchant_source' => 'MONTH',
+            'pay_merchant_id' => 99,
+            'create_ip' => '',
+            'send_order_id' => $send_order_id,
+            'send_order_name' => $send_order_name,
+            'order_type' => 'RECHARGE',
+            'from_bid' => '0',
+            'from_type' => 'auto_month',
+            'activity_id' => 0,
+            'inner_send_order_id' => '',
+            'status' => 'PAID',
+            'transaction_id' => $transaction_id,
+            'pay_end_at' => date('Y-m-d H:i:s')
+        ];
+        OrderService::save_order($init_order);
+    }
+
+    protected function successPayPushMsg($uid)
+    {
+        try {
+            $force_sub_info = DB::table('force_subscribe_users')->where('uid', $uid)->where('is_subscribed', 1)->first();
+            $data = UserService::getById($uid);
+            if (!$force_sub_info) {
+                return;
+            }
+
+            $content_format = "包月购买成功通知:\r\n购买类型: 30元包月\r\n包月特权:\r\n 💝 全站所有作品免费阅读\r\n 💝 全站无广告\r\n 💝 阅读管家1对1服务\r\n为保障包月权益,请<a href='%s'>置顶公众号</a> ";
+
+            $delay = 0;
+            $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($data->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/continue';;
+            $top_url = 'https://help.zhuishuyun.com/top.html';
+
+            $content = sprintf($content_format, $url, $top_url);
+
+            $res['openid'] = $force_sub_info->openid;
+            $res['appid'] = $force_sub_info->appid;
+            $res['content'] = $content;
+            $res['type'] = 'one_task';
+            $res['send_time'] = date("Y-m-d H:i:s");
+            $res['task_id'] = md5('month_pay_success_push');
+            $send_data = array(
+                'send_time' => date("Y-m-d H:i:s"),
+                'data' => $res
+            );
+            dispatch((new SendTexts($send_data))->onConnection('rabbitmq')->delay($delay)->onQueue('send_texts_list'));
+
+
+        } catch (\Exception $e) {
+            Log::error('pay_success_push error');
+            Log::error($e);
+        }
+        return;
+    }
+}

+ 160 - 0
app/Console/Commands/selectCrmSites.php

@@ -0,0 +1,160 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use DB;
+
+class selectCrmSites extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'selectCrmSites';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Command description';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $result = $this->selectSites();
+        $data = [];
+        $times = DB::table('crm_other_channels')->max('times');
+        $times = $times?$times:0;
+        $i = 1;
+        foreach ($result as $item){
+            $data[] = [
+                'distribution_channel_id'=>$item,
+                'times'=>$times+1,
+                'created_at'=>date('Y-m-d H:i:s'),
+                'updated_at'=>date('Y-m-d H:i:s')
+            ];
+            if($i% 100 == 0){
+                DB::table('crm_other_channels')->insert($data);
+                $data = [];
+            }
+            $i++;
+        }
+
+        if($data){
+            DB::table('crm_other_channels')->insert($data);
+        }
+    }
+
+    public function selectSites(){
+        $distribution_channel_id = $this->getSiteNoRegister();
+        $setServiceSites = $this->getSiteSetServices();
+        $opTenCompanyInfo = $this->getTopTenCompanySite();
+        $innerSites = $this->getInnerSite();
+        $result = [];
+        foreach ($distribution_channel_id as $item){
+            //去除设置了二维码的站点
+            if(in_array($item,$setServiceSites)) continue;
+            //去除内部站点
+            if(in_array($item,$innerSites)) continue;
+            //1个月的流水排名前十公司排除
+            if(in_array($item,$opTenCompanyInfo)) continue;
+
+            $result[] = $item;
+        }
+        return $result;
+    }
+
+    public function getTopTenCompanySite(){
+        $data = $this->getTopTenCompanyInfo();
+        $res = [];
+        foreach ($data as $v){
+            $res = array_merge($res,$v['distribution_channel_id']);
+        }
+        return $res;
+    }
+    //最近1个月的流水排名前十公司
+    public function getTopTenCompanyInfo(){
+        //order_day_stats
+        $sql = 'SELECT company_id,GROUP_CONCAT( DISTINCT a.distribution_channel_id) as distribution_channel_id,GROUP_CONCAT(DISTINCT b.channel_user_id) as channel_user_ids ,SUM(a.total_recharge_amount) as total_recharge_amount  FROM order_day_stats a JOIN 
+distribution_channels b on a.distribution_channel_id = b.id 
+JOIN channel_users c on  b.channel_user_id = c.id
+where a.date >= date(DATE_ADD(NOW(),INTERVAL -1 MONTH))
+and c.company_id not in (1,2,3,18,760)
+GROUP BY c.company_id
+ORDER BY total_recharge_amount desc 
+LIMIT 10';
+        $result = DB::select($sql);
+        $data = [];
+        foreach ($result as $item){
+            $data[] = [
+                'company_id'=>$item->company_id,
+                'distribution_channel_id'=>explode(',',$item->distribution_channel_id),
+                'channel_user_ids'=>explode(',',$item->channel_user_ids),
+                'total_recharge_amount'=>$item->total_recharge_amount
+            ];
+        }
+        $res = [];
+        foreach ($data as $v){
+            $res = array_merge($res,$v['distribution_channel_id']);
+        }
+
+        return $data;
+    }
+
+    //内部账号
+    public function getInnerSite():array{
+        $sql = 'SELECT distribution_channels.id FROM distribution_channels JOIN channel_users on distribution_channels.channel_user_id = channel_users.id 
+where channel_users.company_id in (1,2,3,18,760)';
+        $result = DB::select($sql);
+        $data = [];
+        foreach ($result as $item){
+            $data[] = $item->id;
+        }
+        return $data;
+    }
+
+    //最近两周没有新增注册用户的其他渠道站点(小于100)
+    public function getSiteNoRegister():array{
+        $sql = 'SELECT distribution_channel_id,COUNT(users.id) FROM users 
+JOIN distribution_channels on users.distribution_channel_id = distribution_channels.id
+WHERE users.created_at >= date(DATE_ADD(NOW(),INTERVAL -2 WEEK))
+and distribution_channels.created_at <= date(DATE_ADD(NOW(),INTERVAL -1 MONTH))
+and distribution_channel_id >0
+GROUP BY distribution_channel_id
+HAVING COUNT(users.id) <100';
+        $result = DB::select($sql);
+        $data = [];
+        foreach ($result as $item){
+            $data[] = $item->distribution_channel_id;
+        }
+        return $data;
+    }
+
+    //站点所用客服二维码为平台官方
+    public function getSiteSetServices():array{
+        $sql = 'SELECT distribution_channel_id FROM distribution_channel_settings';
+        $result = DB::select($sql);
+        $data = [];
+        foreach ($result as $item){
+            $data[] = $item->distribution_channel_id;
+        }
+        return $data;
+    }
+}

+ 4 - 1
app/Console/Kernel.php

@@ -24,7 +24,8 @@ class Kernel extends ConsoleKernel
         Commands\YqBook::class,
         Commands\channelCpcCode::class,
         Commands\updateFromNewYunqi::class,
-        Commands\InnerOuterWeixinStats::class
+        Commands\InnerOuterWeixinStats::class,
+        Commands\CheckOrderStatus::class,
     ];
 
     /**
@@ -38,5 +39,7 @@ class Kernel extends ConsoleKernel
         $schedule->command('book:update')->dailyAt('06:00');
 
         $schedule->command('book:update')->dailyAt('18:00');
+
+        $schedule->command('checkOrderStatus')->everyFiveMinutes();
     }
 }

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

@@ -556,7 +556,6 @@ class ChapterController extends BaseController
         $fee = $this->getPrice($book_info, $chapter);
         //广告
         if($this->isUserInAdSample() && $ad_status && $ad_status == 1 && $user_info->balance < $fee){
-            $this->getChapter();
             if($special_user_log && $special_user_log == $this->uid){
                 $my_log = myLog('special');
                 $my_log->info('ad-----in--------------------');
@@ -571,8 +570,12 @@ class ChapterController extends BaseController
                 }
             }*/
             //$this->chapter->is_show_ad = 0;
-            $this->bookOrderOrChapterOrder($book_info, $cid, 0, $chapter->name, 1);
-            return response()->item(new ChapterTransformer, $this->chapter);
+            $result = AdVisitStatService::getInfoV2($this->uid, $cid, ['UNLOCK', 'UNLOCK_2']);
+            if ($result){
+                $this->getChapter();
+                $this->bookOrderOrChapterOrder($book_info, $cid, 0, $chapter->name, 1);
+                return response()->item(new ChapterTransformer, $this->chapter);
+            }
         }
         if($special_user_log && $special_user_log == $this->uid){
             $my_log = myLog('special');

+ 114 - 62
app/Http/Controllers/Wap/Pay/MonthOrderController.php

@@ -8,6 +8,8 @@
 
 namespace App\Http\Controllers\Wap\Pay;
 
+use App\Jobs\SendTexts;
+use App\Modules\OfficialAccount\Services\OfficialAccountService;
 use App\Modules\SendOrder\Services\SendOrderService;
 use App\Modules\Subscribe\Models\Order;
 use App\Modules\Subscribe\Services\OrderService;
@@ -19,11 +21,13 @@ use Illuminate\Routing\Controller;
 use Illuminate\Http\Request;
 use Log;
 use Redis;
+use DB;
 
 class MonthOrderController extends Controller
 {
 
-    public function getH5RedirectUrl(Request $request){
+    public function getH5RedirectUrl(Request $request)
+    {
         $app_id = 'Aekgrv87yo5wxnl715';
         $app_secret = '57gwsnd158ib2sn7wluq5716brp8fzm';
         $key = 'sn7wluq5716brp8fzm';
@@ -31,16 +35,17 @@ class MonthOrderController extends Controller
         $plan_id = 39603;
         $user_id = 10008;
         $ip = _getIp();
-        $sign = _sign(compact('app_id','app_secret','plan_id','user_id','ip'),$key.$key);
+        $sign = _sign(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip'), $key . $key);
         $sign = strtoupper($sign);
         $client = new  Client();
-        Log::info(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
-        $url = 'http://pap.manyuedu.org/h5.php?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
+        Log::info(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign'));
+        $url = 'http://pap.manyuedu.org/h5.php?' . http_build_query(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign'));
         //$url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
         return $client->get($url)->getBody()->getContents();
     }
 
-    public function getWechatRedirectUrl(Request $request){
+    public function getWechatRedirectUrl(Request $request)
+    {
         $app_id = 'Aekgrv87yo5wxnl715';
         $app_secret = '57gwsnd158ib2sn7wluq5716brp8fzm';
         $key = 'sn7wluq5716brp8fzm';
@@ -48,17 +53,18 @@ class MonthOrderController extends Controller
         $plan_id = 39603;
         $user_id = 10008;
         $ip = _getIp();
-        $sign = _sign(compact('app_id','app_secret','plan_id','user_id','ip'),$key.$key);
+        $sign = _sign(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip'), $key . $key);
         $sign = strtoupper($sign);
         $client = new  Client();
-        Log::info(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
+        Log::info(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign'));
         //$url = 'http://pap.manyuedu.org/h5.php?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
-        $url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
+        $url = 'http://pap.manyuedu.org/?' . http_build_query(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign'));
         return $client->get($url)->getBody()->getContents();
     }
 
 
-    public function signCallBack(Request $request){
+    public function signCallBack(Request $request)
+    {
         Log::info('signCallBack------------------------------------------signCallBack');
         Log::info($request->all());
         Log::info($request->getMethod());
@@ -68,59 +74,61 @@ class MonthOrderController extends Controller
         $plan_id = $request->post('plan_id');
         $user_id = $request->post('user_id');
         $change_type = $request->post('change_type');
-        if($check = checkParam($request->except('_url'),['app_id','plan_id','user_id','change_type'])){
-            return response()->error('PARAM_EMPTY',['msg'=>$check]);
+        if ($check = checkParam($request->except('_url'), ['app_id', 'plan_id', 'user_id', 'change_type'])) {
+            //return response()->error('PARAM_EMPTY', ['msg' => $check]);
+            return response('fail');
         }
-        $sign = _sign(compact('app_id','plan_id','user_id','change_type'),$key.$key);
+        $sign = _sign(compact('app_id', 'plan_id', 'user_id', 'change_type'), $key . $key);
         $sign = strtoupper($sign);
         $user_info = UserService::getById($user_id);
-        if(!$user_info){
-            Log::error('signCallBack user is not exist,uid is :'.$user_id);
+        if (!$user_info) {
+            Log::error('signCallBack user is not exist,uid is :' . $user_id);
             return response('fail');
         }
-        if($sign == $request->post('sign')){
-            UserMonthService::createSign($user_id,$plan_id,$change_type,$user_info->openid);
+        if ($sign == $request->post('sign')) {
+            UserMonthService::createSign($user_id, $plan_id, $change_type, $user_info->openid);
         }
         Log::info('signCallBack-------------------end-----------------------signCallBack');
         return response('success');
     }
 
 
-    public function orderCallBackV2(Request $request){
+    public function orderCallBackV2(Request $request)
+    {
         Log::info('orderCallBack------------------------------------------orderCallBack');
         Log::info($request->all());
         Log::info($request->getMethod());
 
         $key = env('MONTH_ORDER_KEY');//'sn7wluq5716brp8fzm';
         $app_id = $request->post('app_id');
-        $plan_id = $request->post('plan_id',0);
+        $plan_id = $request->post('plan_id', 0);
         $user_id = $request->post('user_id');
         $total_fee = $request->post('total_fee');
         $trade_no = $request->post('trade_no');
         $out_trade_no = $request->post('out_trade_no');
-        if($check = checkParam($request->except('_url'),['app_id','user_id','total_fee','trade_no','out_trade_no'])){
-            return response()->error('PARAM_EMPTY',['msg'=>$check]);
+        if ($check = checkParam($request->except('_url'), ['app_id', 'user_id', 'total_fee', 'trade_no', 'out_trade_no'])) {
+            return response()->error('PARAM_EMPTY', ['msg' => $check]);
         }
-        $sign = _sign(compact('app_id','user_id','total_fee','trade_no','out_trade_no'),$key.$key);
+        $sign = _sign(compact('app_id', 'user_id', 'total_fee', 'trade_no', 'out_trade_no'), $key . $key);
         $sign = strtoupper($sign);
-        Log::info('self sign is: '.$sign);
+        Log::info('self sign is: ' . $sign);
         $order_info = Order::find($user_id);
-        if(!$order_info){
-            Log::error('month order not exist !!!order is :'.$trade_no);
+        if (!$order_info) {
+            Log::error('month order not exist !!!order is :' . $trade_no);
             return response('fail');
         }
-        if($order_info->status == 'PAID'){
-            Log::error('month order had deal !!!, order is :'.$trade_no);
+        if ($order_info->status == 'PAID') {
+            Log::error('month order had deal !!!, order is :' . $trade_no);
             return response('fail');
         }
         //if($sign == $request->post('sign')){
-        if(!UserMonthService::getOrderByOrder($trade_no,$out_trade_no)){
-            UserMonthService::createLOrder($order_info->uid,$plan_id,$total_fee,$trade_no,$out_trade_no);
+        if (!UserMonthService::getOrderByOrder($trade_no, $out_trade_no)) {
+            UserMonthService::createLOrder($order_info->uid, $plan_id, $total_fee, $trade_no, $out_trade_no);
             $order_info->transaction_id = $trade_no;
             $order_info->status = 'PAID';
             $order_info->pay_end_at = date('Y-m-d H:i:s');
             $order_info->save();
-            self::addOrderAndVipV2($order_info->uid,$total_fee);
+            self::addOrderAndVipV2($order_info->uid, $total_fee);
         }
         //}
 
@@ -128,27 +136,29 @@ class MonthOrderController extends Controller
         return response('success');
     }
 
-    public function orderCallBack(Request $request){
+    public function orderCallBack(Request $request)
+    {
         Log::info('orderCallBack------------------------------------------orderCallBack');
         Log::info($request->all());
         Log::info($request->getMethod());
 
         $key = env('MONTH_ORDER_KEY');//'sn7wluq5716brp8fzm';
         $app_id = $request->post('app_id');
-        $plan_id = $request->post('plan_id',0);
+        $plan_id = $request->post('plan_id', 0);
         $user_id = $request->post('user_id');
         $total_fee = $request->post('total_fee');
         $trade_no = $request->post('trade_no');
         $out_trade_no = $request->post('out_trade_no');
-        if($check = checkParam($request->except('_url'),['app_id','user_id','total_fee','trade_no','out_trade_no'])){
-            return response()->error('PARAM_EMPTY',['msg'=>$check]);
+        if ($check = checkParam($request->except('_url'), ['app_id', 'user_id', 'total_fee', 'trade_no', 'out_trade_no'])) {
+            return response()->error('PARAM_EMPTY', ['msg' => $check]);
         }
-        $sign = _sign(compact('app_id','user_id','total_fee','trade_no','out_trade_no'),$key.$key);
+        $sign = _sign(compact('app_id', 'user_id', 'total_fee', 'trade_no', 'out_trade_no'), $key . $key);
         $sign = strtoupper($sign);
         //if($sign == $request->post('sign')){
-        if(!UserMonthService::getOrderByOrder($trade_no,$out_trade_no)){
-            UserMonthService::createLOrder($user_id,$plan_id,$total_fee,$trade_no,$out_trade_no);
-            self::addOrderAndVip($user_id,$out_trade_no,$trade_no,$total_fee);
+        if (!UserMonthService::getOrderByOrder($trade_no, $out_trade_no)) {
+            UserMonthService::createLOrder($user_id, $plan_id, $total_fee, $trade_no, $out_trade_no);
+            $this->addOrderAndVip($user_id, $out_trade_no, $trade_no, $total_fee);
+            //$this->successPayPushMsg($user_id);
         }
         //}
 
@@ -157,39 +167,42 @@ class MonthOrderController extends Controller
     }
 
 
-    private function addOrderAndVip($uid,$out_trade_no,$trade_no,$price){
+    private function addOrderAndVip($uid, $out_trade_no, $trade_no, $price)
+    {
 
         $order_info = OrderService::getByTradeNo($out_trade_no);
         //订单已经存在
-        if($order_info){
-            return ;
+        if ($order_info) {
+            return;
         }
         $user_info = UserService::getById($uid);
-        if(!$user_info) return ;
-        $this->createOrder($uid,$user_info->distribution_channel_id,0,$price,$out_trade_no,$trade_no);
+        if (!$user_info) return;
+        $this->createOrder($uid, $user_info->distribution_channel_id, 0, $price, $out_trade_no, $trade_no);
         YearOrderService::save_month_order([
-            'uid'=>$uid,
-            'distribution_channel_id'=>$user_info->distribution_channel_id,
-            'fee'=>$price / 100,
-            'send_order_id'=>0
+            'uid' => $uid,
+            'distribution_channel_id' => $user_info->distribution_channel_id,
+            'fee' => $price / 100,
+            'send_order_id' => 0
         ]);
     }
 
-    private function addOrderAndVipV2($uid,$price){
+    private function addOrderAndVipV2($uid, $price)
+    {
 
 
         $user_info = UserService::getById($uid);
-        if(!$user_info) return ;
+        if (!$user_info) return;
 
         YearOrderService::save_month_order([
-            'uid'=>$uid,
-            'distribution_channel_id'=>$user_info->distribution_channel_id,
-            'fee'=>$price / 100,
-            'send_order_id'=>0
+            'uid' => $uid,
+            'distribution_channel_id' => $user_info->distribution_channel_id,
+            'fee' => $price / 100,
+            'send_order_id' => 0
         ]);
     }
 
-    private function createOrder($uid,$distribution_channel_id,$product_id,$price,$trade_no,$transaction_id){
+    private function createOrder($uid, $distribution_channel_id, $product_id, $price, $trade_no, $transaction_id)
+    {
         $count = OrderService::getUserChargeTimes($uid);
         $count = $count + 1;
         $send_order_id = 0;
@@ -221,34 +234,73 @@ class MonthOrderController extends Controller
             'from_type' => 'auto_month',
             'activity_id' => 0,
             'inner_send_order_id' => '',
-            'status'=>'PAID',
-            'transaction_id'=>$transaction_id,
-            'pay_end_at'=>date('Y-m-d H:i:s')
+            'status' => 'PAID',
+            'transaction_id' => $transaction_id,
+            'pay_end_at' => date('Y-m-d H:i:s')
         ];
         OrderService::save_order($init_order);
     }
 
-    public function wait(Request $request){
+    public function wait(Request $request)
+    {
         //$user_cookie = \Cookie::get(env('COOKIE_AUTH_WEB_WECHAT'));
         //$uid = $user_cookie ? decrypt($user_cookie) : null;
         $r = $request->get('r');
         $r = urldecode($r);
-        return view('pay.order.monthpaywait',['url'=>$r]);
+        return view('pay.order.monthpaywait', ['url' => $r]);
     }
 
-    public function issuccess(Request $request){
+    public function issuccess(Request $request)
+    {
         $uid = \Cookie::get(env('COOKIE_AUTH_WEB_WECHAT'));
         //$uid = $user_cookie ? decrypt($user_cookie) : null;
-        if(!$uid){
+        if (!$uid) {
             return response()->success();
         }
         $last = UserMonthService::getLastOrder($uid);
-        if(!$last){
+        if (!$last) {
             return response()->error('WAP_SYS_ERROR');
         }
-        if(time()-strtotime($last->created_at) <20){
+        if (time() - strtotime($last->created_at) < 20) {
             return response()->success();
         }
         return response()->error('WAP_SYS_ERROR');
     }
+
+    protected function successPayPushMsg($uid)
+    {
+        try {
+            $force_sub_info = DB::table('force_subscribe_users')->where('uid', $uid)->where('is_subscribed', 1)->first();
+            $data = UserService::getById($uid);
+            if (!$force_sub_info) {
+                return;
+            }
+
+            $content_format = "包月购买成功通知:\r\n购买类型: 30元包月\r\n包月特权:\r\n 💝 全站所有作品免费阅读\r\n 💝 全站无广告\r\n 💝 阅读管家1对1服务\r\n为保障包月权益,请<a href='%s'>置顶公众号</a> ";
+
+            $delay = 0;
+            $url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($data->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/continue';;
+            $top_url = 'https://help.zhuishuyun.com/top.html';
+
+            $content = sprintf($content_format, $url, $top_url);
+
+            $res['openid'] = $force_sub_info->openid;
+            $res['appid'] = $force_sub_info->appid;
+            $res['content'] = $content;
+            $res['type'] = 'one_task';
+            $res['send_time'] = date("Y-m-d H:i:s");
+            $res['task_id'] = md5('month_pay_success_push');
+            $send_data = array(
+                'send_time' => date("Y-m-d H:i:s"),
+                'data' => $res
+            );
+            dispatch((new SendTexts($send_data))->onConnection('rabbitmq')->delay($delay)->onQueue('send_texts_list'));
+
+
+        } catch (\Exception $e) {
+            Log::error('pay_success_push error');
+            Log::error($e);
+        }
+        return;
+    }
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 16 - 2
app/Http/Controllers/Wap/Pay/OrdersController.php


+ 4 - 2
app/Http/Controllers/Wap/User/CoflController.php

@@ -103,13 +103,15 @@ class CoflController extends Controller
         $source = $request->get('wx','none');
         $type = 'CRM';
         if($uri == 'freethrhcurrency'){
-            $fee = 300;
+            //$fee = 300;
+            $fee = 500;
             $this->stats('reward_300',$crm);
         }elseif($uri == 'wfreecurrency'){
             $fee = 200;
             $type = 'WCRM';
         }elseif ($uri == 'frocefreethrhcurrency'){
-            $fee = 200;
+            //$fee = 200;
+            $fee = 500;
             $type = 'CRM_FORCE';
         }
         else{

+ 3 - 3
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -2150,7 +2150,7 @@ class WelcomeController extends BaseController
         }
         //Log::info('guidePersonalAccount555555555555555');
         if($charge){
-            return ['title'=>'点击领取200书币>>','link'=>'/guidestrem?uid='.$this->uid];
+            return ['title'=>'您有500书币待领取>>','link'=>'/guidestrem?uid='.$this->uid];
         }
         return '';
     }
@@ -2198,8 +2198,8 @@ class WelcomeController extends BaseController
                 return [
                     'price'=>'30元',
                     'text' => '30元包月 全站万本精彩小说免费看',
-                    //'link'=> generateMonthOrderUrl($this->uid)
-                    'link'=> '/rmonthpay'
+                    'link'=> generateMonthOrderUrl($this->uid)
+                    //'link'=> '/rmonthpay'
                 ];
             }
         }

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

@@ -22,7 +22,7 @@ Route::group(['domain'=>env('PAY_WAP_DOMAIN'),'namespace'=>'App\Http\Controllers
     Route::get('monthpay/getH5RedirectUrl','Pay\MonthOrderController@getH5RedirectUrl');
     Route::get('monthpay/getWechatRedirectUrl','Pay\MonthOrderController@getWechatRedirectUrl');
     Route::any('monthpay/signcallback','Pay\MonthOrderController@signCallBack');
-    Route::post('monthpay/ordercallback','Pay\MonthOrderController@orderCallBackV2');
+    Route::post('monthpay/ordercallback','Pay\MonthOrderController@orderCallBack');
 
 });
 Route::group(['domain'=>env('OFFICIAL_AUTH_FOMAIN'),'namespace'=>'App\Http\Controllers\Wap'],function(){

+ 5 - 3
app/Modules/Book/Models/BookConfig.php

@@ -74,9 +74,11 @@ class BookConfig extends Model
                     //$res = $res->where('book_configs.book_name', 'like', '%' . $v . '%');
                     $res = $res->where(function ($query) use ($v) {
                         $query->where('book_configs.book_name', 'like', '%' . $v . '%');
-                            $roles_bids = BookRoleService::getBidsByRole($v);
-                            if(count($roles_bids)>0) {
-                                $query->orWhereIn('book_configs.bid',$roles_bids);
+                            if(mb_strlen($v)<=5) {
+                                $roles_bids = BookRoleService::getBidsByRole($v);
+                                if(count($roles_bids)>0) {
+                                    $query->orWhereIn('book_configs.bid',$roles_bids);
+                                }
                             }
                     });
                     //->orWhere('books.intro', 'like', '%' . $v . '%')

+ 13 - 0
app/Modules/OfficialAccount/Services/OfficialAccountService.php

@@ -658,4 +658,17 @@ class OfficialAccountService
     {
         return OfficialAccount::getBusinessChannelData($channels, $distribution_channel_name, $official_account_name,$isAll);
     }
+
+    /**
+     * 获取置顶地址
+     */
+    static function getTopUrl($service_type_info = 2)
+    {
+        if($service_type_info == 1)
+        {
+            return 'https://help.'. env('WECHAT_CUSTOM_HOST') .'.com/top2.html';
+        }else{
+            return 'https://help.'. env('WECHAT_CUSTOM_HOST') .'.com/top.html';
+        }
+    }
 }

+ 12 - 0
app/Modules/User/Services/UserMonthService.php

@@ -10,6 +10,7 @@ namespace App\Modules\User\Services;
 
 use App\Modules\User\Models\UserMonthOrder;
 use App\Modules\User\Models\UserMonthSign;
+use GuzzleHttp\Client;
 
 class UserMonthService
 {
@@ -57,4 +58,15 @@ class UserMonthService
         $info = $model->where('trade_no',$trade_no)->first();
         return $info;
     }
+
+    public static function checkOrderStatus(int $user_id,int $plan_id,string $app_id,string $key,string $app_secret){
+        $pay_year = date('Y');
+        $pay_month = date('m');
+        $sign = strtoupper(_sign(compact('app_id','app_secret','user_id','plan_id','pay_year','pay_month'),$key.$key));
+        $client = new Client();
+        $url = 'http://pap.manyuedu.org/checkpay.php?';
+        $url .= http_build_query(compact('user_id','app_secret','app_id','plan_id','pay_year','pay_month','sign'));
+        $result = $client->request('post',$url)->getBody()->getContents();
+        return json_decode($result,true);
+    }
 }

+ 115 - 0
app/Modules/User/Services/UserService.php

@@ -8,8 +8,16 @@
 
 namespace App\Modules\User\Services;
 
+use App\Modules\Book\Models\BookGiftsSend;
+use App\Modules\Book\Models\UserShelfBooks;
+use App\Modules\Book\Services\UserShelfBooksService;
+use App\Modules\Subscribe\Models\BookOrder;
+use App\Modules\Subscribe\Models\ChapterOrder;
+use App\Modules\Subscribe\Services\BookOrderService;
+use App\Modules\Subscribe\Services\ChapterOrderService;
 use App\Modules\User\Models\User;
 use App\Modules\User\Models\UserEnv;
+use App\Modules\User\Models\UserSign;
 use DB;
 use App\Jobs\ActionTrigger;
 use App\Modules\OfficialAccount\Models\DistributionSelfDefineConfig;
@@ -359,4 +367,111 @@ WHERE u.openid in (SELECT openid from users WHERE  id = %s)";
     {
         return UserEnv::recordUA($ua,$uid);
     }
+
+    public static function transfer(int $from,int $to,int $distribution_channel_id){
+        //阅读记录迁移***************************************
+        $record = Redis::hgetall('book_read:'.$from);
+        $not_uid_key = ['last_read','sign_counts','sign_info','sign_day'];
+        $data = [];
+        foreach ($record as $k=>$item){
+            if(is_numeric($k) || in_array($k,$not_uid_key)){
+                $data[$k] = $item;
+            }
+        }
+        if($data) Redis::hmset('book_read:'.$to,$data);
+        //签到记录
+        $user_sign_model = new UserSign();
+        $user_sign_model->setCurrentTable(date('Ym'));
+        $sign_record = $user_sign_model->where('uid',$from)->select('price','sign_time','day','created_at')->orderBy('sign_time','desc')->get();
+        $temp = [];
+        if($sign_record){
+            foreach ($sign_record as $item){
+                $temp[] = [
+                    'uid'=>$to,
+                    'price'=>$item->price,
+                    'day'=>$item->day,
+                    'sign_time'=>$item->sign_time,
+                    'created_at'=>$item->created_at,
+                    'updated_at'=>date('Y-m-d H:i:s'),
+                ];
+            }
+            DB::table('user_sign'.date('Ym'))->insert($temp);
+        }
+        //订阅记录(按本)
+        $book_order = BookOrder::where('uid',$from)->where('bid','>',0)->get();
+        if($book_order){
+            $temp = [];
+            foreach ($book_order as $book){
+                $temp[] = [
+                    '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'),
+                ];
+            }
+            DB::table('book_orders')->insert($temp);
+        }
+        //订阅记录(按章)
+        $chapter_order_record = ChapterOrderService::getRecordByUid($from,'','',true);
+        if($chapter_order_record){
+            $temp = [];
+            $i = 1;
+            $chapter_model = new ChapterOrder();
+            $chapter_model->setCurrentTable($to);
+            foreach ($chapter_order_record as $chapter_order){
+                $temp[] = [
+                    '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')
+                ];
+            }
+            $chapter_model->insert($temp);
+        }
+        //打赏记录
+        $gift_result = BookGiftsSend::where('uid',$from)->get();
+        if($gift_result){
+            $tmp = [];
+            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'=>$g->cost,
+                    'cost_reward'=>$g->cost_reward,
+                    'cost_recharge'=>$g->cost_recharge,
+                    'created_at'=>$g->created_at,
+                    'updated_at'=>date('Y-m-d H:i:s')
+                ];
+            }
+            DB::table('book_gifts_send')->insert($tmp);
+        }
+        //书架
+        $result = UserShelfBooks::where('uid',$from)->get();
+        if($result){
+            $tmp = [];
+            foreach ($result as $s){
+                $tmp[] = [
+                    'uid'=>$to,
+                    'distribution_channel_id'=>$distribution_channel_id,
+                    'bid'=>$s->bid,
+                    'created_at'=>$s->created_at,
+                    'updated_at'=>date('Y-m-d H:i:s')
+                ];
+            }
+            DB::table('user_shelf_books')->insert($tmp);
+        }
+    }
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4 - 27
resources/views/wap/index.blade.php