Browse Source

Merge branch 'kuaiyingyong' into kuaiyingyong_push

Wang Chen 4 years ago
parent
commit
7fec7a5ce6

+ 2 - 2
app/Cache/Activity/ActivityCache.php

@@ -41,7 +41,7 @@ class ActivityCache
      */
     public static function getActivityPv($activityId, $date): int
     {
-        $cacheKey = Utils::getCacheKey('activity.statPv', [$activityId, $date]);
+        $cacheKey = Utils::getCacheKey('activity.statsPv', [$activityId, $date]);
         $exist    = Redis::exists($cacheKey);
         if (!$exist) {
             return 0;
@@ -58,7 +58,7 @@ class ActivityCache
      */
     public static function getActivityUv($activityId, $date): int
     {
-        $cacheKey = Utils::getCacheKey('activity.statUv', [$activityId, $date]);
+        $cacheKey = Utils::getCacheKey('activity.statsUv', [$activityId, $date]);
         $exist    = Redis::exists($cacheKey);
         if (!$exist) {
             return 0;

+ 3 - 3
app/Cache/CacheKeys.php

@@ -23,9 +23,9 @@ class CacheKeys
             'token' => 'Lock:%s', // 锁,token
         ],
         'push'     => [
-            'user'   => 'Push:%s',
-            'statPv' => 'Push:pv:%s:%s',
-            'statUv' => 'Push:uv:%s:%s',
+            'user'    => 'Push:%s',
+            'statsPv' => 'Push:pv:%s:%s',
+            'statsUv' => 'Push:uv:%s:%s',
         ],
         'ad'       => [
             'position' => 'Ad:position'

+ 2 - 2
app/Cache/Push/PushCache.php

@@ -84,7 +84,7 @@ class PushCache
      */
     public static function getPushyPv($pushId, $date): int
     {
-        $cacheKey = Utils::getCacheKey('push.statPv', [$pushId, $date]);
+        $cacheKey = Utils::getCacheKey('push.statsPv', [$pushId, $date]);
         $exist    = Redis::exists($cacheKey);
         if (!$exist) {
             return 0;
@@ -101,7 +101,7 @@ class PushCache
      */
     public static function getPushUv($pushId, $date): int
     {
-        $cacheKey = Utils::getCacheKey('push.statUv', [$pushId, $date]);
+        $cacheKey = Utils::getCacheKey('push.statsUv', [$pushId, $date]);
         $exist    = Redis::exists($cacheKey);
         if (!$exist) {
             return 0;

+ 0 - 72
app/Console/Commands/Push/HwPushTest.php

@@ -1,72 +0,0 @@
-<?php
-
-
-namespace App\Console\Commands\Push;
-
-
-use App\Consts\PushConst;
-use App\Libs\Push\HuaWei\Admin\Constants;
-use App\Libs\Push\HuaWei\HwPushCommon;
-use App\Libs\Push\HuaWei\PushMsgCommon;
-use Illuminate\Console\Command;
-
-class HwPushTest extends Command
-{
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $signature = 'push:hw:test';
-
-    /**
-     * The console command description.
-     *
-     * @var string
-     */
-    protected $description = 'test push';
-
-    /**
-     * Execute the console command.
-     *
-     * @return mixed
-     */
-    public function handle()
-    {
-        $appId     = '102612543';
-        $appSecret = '07c896089f432163421923bdcab83a8da9d386274be43e61d510c27f56c23269';
-        $pushToken = 'AN0R08PKJjTJvCTRCL8hATh5ZxIVHQQOhpQ1JkpyRBjG25pRKbBckpUntQYBLpXNb2SFj8_bGb18uMeCT7KY5ehosiWZlopKUIphPYqeWKJeQcHGrn2fPKUsFEM-72X5Zg';
-
-        $fastAppPushCommon = new HwPushCommon($appId, $appSecret);
-        $fastAppPushCommon->setToken([$pushToken]);
-//        $fastAppPushCommon->subscribeTopic(PushConst::TOPIC_ALL, [$pushToken]);
-//        $fastAppPushCommon->unSubscribeTopic(PushConst::TOPIC_ALL, [$pushToken]);
-//        $result = $fastAppPushCommon->subscribeList($pushToken);
-//        $result            = $fastAppPushCommon->queryPushToken($pushToken);
-        $result = $fastAppPushCommon->sendPushMessage('我是标题', '我是内容', '/');
-        dd($result);
-
-//        $testPushMsgSample = new PushMsgCommon();
-//        $testPushMsgSample->sendPushMsgMessageByMsgType(Constants::PUSHMSG_FASTAPP_MSG_TYPE);
-
-//        $message = '{
-//	"data": "{\"pushtype\":1,\"pushbody\":{\"messageId\":\"111110001\",\"data\":\"test pass-through msg\"}}",
-//	"ssss":"{k1:v1}",
-//	"android": {
-//		"collapse_key": -1,
-//		"urgency": "HIGH",
-//		"ttl": "1448s",
-//		"bi_tag": "Trump",
-//		"fast_app_target": 1
-//	},
-//	"token": [
-//		*push_token*
-//		]
-//}';
-//
-//
-//        $message = str_ireplace("*push_token*", '"' . $testPushMsgSample->fast_push_token . '"', $message);
-//        $testPushMsgSample->sendPushMsgRealMessage(json_decode($message), Constants::PUSHMSG_FASTAPP_MSG_TYPE);
-    }
-
-}

+ 0 - 100
app/Console/Commands/Push/MiPushTest.php

@@ -1,100 +0,0 @@
-<?php
-
-namespace App\Console\Commands\Push;
-
-use App\Libs\Push\XMPush\Builder;
-use App\Libs\Push\XMPush\Constants;
-use App\Libs\Push\XMPush\Message;
-use App\Libs\Push\XMPush\Sender;
-use App\Libs\Push\XMPush\Stats;
-use App\Libs\Push\XMPush\TargetedMessage;
-use App\Libs\Push\XMPush\Tracer;
-use Illuminate\Console\Command;
-
-class MiPushTest extends Command
-{
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $signature = 'push:mi:test';
-
-    /**
-     * 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()
-    {
-        $secret  = 'W0OBbzwRFYE2qfqqzdxV7A==';
-        $package = 'com.beidao.kuaiying.zsy';
-
-        // 常量设置必须在new Sender()方法之前调用
-        Constants::setPackage($package);
-        Constants::setSecret($secret);
-
-        $aliasList = array('alias1', 'alias2');
-        $title     = '测试标题22';
-        $desc      = '这是一条mipush推送消息22';
-        $payload   = '{"test":1,"ok":"It\'s a string"}';
-
-        $sender = new Sender();
-
-        // message1 演示自定义的点击行为
-        $message1 = new Builder();
-        $message1->title($title);  // 通知栏的title
-        $message1->description($desc); // 通知栏的descption
-        $message1->passThrough(0);  // 这是一条通知栏消息,如果需要透传,把这个参数设置成1,同时去掉title和descption两个参数
-        $message1->payload($payload); // 携带的数据,点击后将会通过客户端的receiver中的onReceiveMessage方法传入。
-        $message1->extra(Builder::notifyForeground, 1); // 应用在前台是否展示通知,如果不希望应用在前台时候弹出通知,则设置这个参数为0
-        $message1->notifyId(2); // 通知类型。最多支持0-4 5个取值范围,同样的类型的通知会互相覆盖,不同类型可以在通知栏并存
-        $message1->build();
-        $targetMessage = new TargetedMessage();
-        $targetMessage->setTarget('alias1', TargetedMessage::TARGET_TYPE_ALIAS); // 设置发送目标。可通过regID,alias和topic三种方式发送
-        $targetMessage->setMessage($message1);
-
-        // message2 演示预定义点击行为中的点击直接打开app行为
-        $message2 = new Builder();
-        $message2->title($title);
-        $message2->description($desc);
-        $message2->passThrough(0);
-        $message2->payload($payload); // 对于预定义点击行为,payload会通过点击进入的界面的intent中的extra字段获取,而不会调用到onReceiveMessage方法。
-        $message2->extra(Builder::notifyEffect, 1); // 此处设置预定义点击行为,1为打开app
-        $message2->extra(Builder::notifyForeground, 1);
-        $message2->notifyId(0);
-        $message2->build();
-        $targetMessage2 = new TargetedMessage();
-        $targetMessage2->setTarget('alias2', TargetedMessage::TARGET_TYPE_ALIAS);
-        $targetMessage2->setMessage($message2);
-
-        $targetMessageList = array($targetMessage, $targetMessage2);
-        print_r($sender->send($message1, 'yeCXNzRSIiqLPfeoejM4gaLlpz3Tm8zyOctN+wFx0v6U73mTud4cYEJhEDyCEQrC')->getRaw());
-        //print_r($sender->multiSend($targetMessageList, TargetedMessage::TARGET_TYPE_ALIAS)->getRaw());
-
-        // print_r($sender->sendToAliases($message1, $aliasList)->getRaw());
-        $stats     = new Stats();
-        $startDate = '20200727';
-        $endDate   = '20200728';
-        // print_r($stats->getStats($startDate, $endDate)->getRaw());
-        //$tracer = new Tracer();
-        //print_r($tracer->getMessageStatusById('sdm58749595907489079Yl')->getRaw());
-    }
-}

+ 0 - 67
app/Console/Commands/Push/OppoPushTest.php

@@ -1,67 +0,0 @@
-<?php
-
-
-namespace App\Console\Commands\Push;
-
-
-use App\Consts\PushConst;
-use App\Libs\Push\OPPOPush\OPPOPushCommon;
-use Illuminate\Console\Command;
-use GuzzleHttp\Exception\GuzzleException;
-
-class OppoPushTest extends Command
-{
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $signature = 'push:oppo:test';
-
-    /**
-     * The console command description.
-     *
-     * @var string
-     */
-    protected $description = 'Command description';
-
-    /**
-     * Create a new command instance.
-     *
-     * @return void
-     */
-    public function __construct()
-    {
-        parent::__construct();
-    }
-
-    /**
-     * @throws GuzzleException
-     */
-    public function handle()
-    {
-        // 配置
-        $regId = 'CN_83427bab875a0a40e4da3eeb2055f331';
-        [$appKey, $masterSecret] = ['354f2fba4c834e94a206fca247f132a0', 'ba2d9968c45b489da75e6bde7147b32a'];
-
-        // 初始化
-        $instance = new OPPOPushCommon($appKey, $masterSecret);
-
-        // 查询APP当天发送量的状态
-        $res = $instance->fetchPushPermit();
-        dd($res);
-
-        // 标签相关
-        $tag  = PushConst::TOPIC_ALL;
-        $res1 = $instance->addTags($tag, '全部用户');
-        $res2 = $instance->subscribeTags($regId, $tag);
-        $res3 = $instance->getAllTags($regId);
-        dd($res1, $res2, $res3);
-
-        // 发送消息
-        $messageId = $instance->getMessageId('我是标题11', '我是内容11', '/');
-        $res4      = $instance->broadCastRegIds($messageId, [$regId]);
-        dd($messageId, $res4);
-
-    }
-}

+ 57 - 0
app/Console/Commands/Push/PushStats.php

@@ -0,0 +1,57 @@
+<?php
+
+
+namespace App\Console\Commands\Push;
+
+
+use App\Cache\Push\PushCache;
+use App\Modules\Push\Models\QappPushTask;
+use Illuminate\Console\Command;
+
+class PushStats extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'push:stats';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '推送PVUV统计';
+
+    public function handle()
+    {
+        $date = date('Ymd', strtotime('-1 day'));
+
+        // 获取所有有效的推送任务
+        $tasks = QappPushTask::getAllValidTasks();
+        if (empty($tasks)) {
+            return false;
+        }
+
+        foreach ($tasks as $task) {
+            $pushId = getProp($task, 'id');
+            $pv     = getProp($task, 'pv');
+            $uv     = getProp($task, 'uv');
+
+            // 获取缓存数据
+            $cachePv = PushCache::getPushyPv($pushId, $date);
+            $cacheUv = PushCache::getPushUv($pushId, $date);
+
+            myLog('pushStats')->info('', compact('date', 'pushId', 'pv', 'uv', 'cachePv', 'cacheUv'));
+
+            // 更新pv uv
+            QappPushTask::updatePushTask($pushId, [
+                'pv' => $pv + $cachePv,
+                'uv' => $uv + $cacheUv,
+            ]);
+        }
+
+        return true;
+    }
+}

+ 5 - 3
app/Console/Kernel.php

@@ -5,6 +5,7 @@ namespace App\Console;
 use App\Console\Commands\Push\HwPushTest;
 use App\Console\Commands\Push\MiPushTest;
 use App\Console\Commands\Push\OppoPushTest;
+use App\Console\Commands\Push\PushStats;
 use App\Console\Commands\Push\PushTask;
 use App\Console\Commands\Push\PushTest;
 use Illuminate\Console\Scheduling\Schedule;
@@ -18,9 +19,7 @@ class Kernel extends ConsoleKernel
      * @var array
      */
     protected $commands = [
-        MiPushTest::class,
-        HwPushTest::class,
-        OppoPushTest::class,
+        PushStats::class,
         PushTest::class,
         PushTask::class,
         Commands\Activity\ActivityStats::class,
@@ -53,5 +52,8 @@ class Kernel extends ConsoleKernel
 
         // 每天的活动统计
         $schedule->command('activity:stats')->dailyAt('01:00');
+
+        // 每天的推送统计
+        $schedule->command('push:stats')->dailyAt('00:30');
     }
 }

+ 25 - 1
app/Http/Controllers/QuickApp/Book/ChapterController.php

@@ -58,7 +58,8 @@ class ChapterController extends BaseController
     {
         // 查询书籍是否限免
         $isFree = BookConfigService::judgeBookIsFree($bid);
-
+        //渠道自定义vip章节
+        $vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
         switch ($book_info->charge_type) {
             case 'BOOK':
                 $price          = $this->getPrice($book_info);
@@ -72,6 +73,13 @@ class ChapterController extends BaseController
                         $v->is_need_charge = false;
                         $v->price          = 0;
                     }
+                    if($vip_sequence){
+                        if($v->sequence >= $vip_sequence){
+                            $v->is_vip = 1;
+                        }else{
+                            $v->is_vip = 0;
+                        }
+                    }
                 }
                 break;
             default:
@@ -84,6 +92,13 @@ class ChapterController extends BaseController
                         $v->price          = $v->is_vip ? $this->getPrice($book_info, $v->size) : 0;
                         $v->is_need_charge = $v->is_vip ? $this->isChapterNeedCharge($bid, $v->id, $v->price) : false;
                     }
+                    if($vip_sequence){
+                        if($v->sequence >= $vip_sequence){
+                            $v->is_vip = 1;
+                        }else{
+                            $v->is_vip = 0;
+                        }
+                    }
                 }
                 break;
         }
@@ -110,6 +125,15 @@ class ChapterController extends BaseController
             $job = new UserRententionJob($this->uid, now(), $this->user_info->created_at);
             dispatch($job)->onConnection('rabbitmq')->onQueue('user_rentention_queue');
         }
+        //自定义vip章节
+        $vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
+        if($vip_sequence){
+            if($chapter->sequence >= $vip_sequence){
+                $chapter->is_vip = 1;
+            }else{
+                $chapter->is_vip = 0;
+            }
+        }
 
         if ($chapter->is_vip == 0) {
             ReadRecordService::addReadLog($this->uid, [

+ 5 - 24
app/Http/Controllers/QuickApp/Order/OrdersController.php

@@ -7,9 +7,7 @@ use App\Libs\Utils;
 use App\Modules\Activity\Models\Activity;
 use App\Modules\Statistic\Services\AdVisitStatService;
 use App\Http\Controllers\QuickApp\BaseController;
-use App\Modules\User\Models\QappPackage;
 use Illuminate\Http\Request;
-
 use App\Modules\Subscribe\Services\BookOrderService;
 use App\Modules\Subscribe\Services\ChapterOrderService;
 use App\Modules\Subscribe\Services\OrderService;
@@ -458,6 +456,9 @@ class OrdersController extends BaseController
             }
         }
 
+        // 包名
+        $package = $request->header('x-package', '');
+
         return compact(
             'distribution_channel_id',
             'uid',
@@ -469,7 +470,8 @@ class OrdersController extends BaseController
             'from_bid',
             'from_type',
             'order_type',
-            'activity_id'
+            'activity_id',
+            'package'
         );
     }
 
@@ -506,17 +508,6 @@ class OrdersController extends BaseController
     {
         if ($params = $this->getPayParams($request)) {
             $params['pay_merchant_id'] = $this->app_pay_merchat_id;
-
-            // 针对聚裕的包无法支付的问题(注册时传入了仙女阅读的包名,导致支付时取的支付信息不一致)
-            $package = $request->header('x-package', '');
-            if ($package === 'com.juyu.kuaiying.rmyq') {
-                $packageInfo   = QappPackage::getPackageByPackage($package);
-                $payMerchantId = getProp($packageInfo, 'app_pay_merchat_id');
-                if ($payMerchantId) {
-                    $params['pay_merchant_id'] = $payMerchantId;
-                }
-            }
-
         } else {
             return response()->error('QAPP_PARAM_ERROR');
         }
@@ -566,16 +557,6 @@ class OrdersController extends BaseController
     {
         if ($params = $this->getPayParams($request)) {
             $params['pay_merchant_id'] = $this->h5_pay_merchat_id;
-
-            // 针对聚裕的包无法支付的问题(注册时传入了仙女阅读的包名,导致支付时取的支付信息不一致)
-            $package = $request->header('x-package', '');
-            if ($package === 'com.juyu.kuaiying.rmyq') {
-                $packageInfo   = QappPackage::getPackageByPackage($package);
-                $payMerchantId = getProp($packageInfo, 'h5_pay_merchat_id');
-                if ($payMerchantId) {
-                    $params['pay_merchant_id'] = $payMerchantId;
-                }
-            }
         } else {
             return response()->error('QAPP_PARAM_ERROR');
         }

+ 15 - 11
app/Http/Middleware/QuickAppGetUserFromToken.php

@@ -24,17 +24,25 @@ class QuickAppGetUserFromToken extends BaseMiddleware
      */
     public function handle(Request $request, Closure $next)
     {
-        $version = $request->header('X-Version', '');
+        // 获取头部信息
+        $package     = $request->header('x-package', '');
+        $provider    = $request->header('x-provider', '');
+        $regId       = $request->header('x-regid', '');
+        $pushId      = $request->header('x-pushid', 0);
+        $sendOrderId = $request->header('send-order-id', 0);
+
+        // 判断是否登录
         if (!$token = $this->auth->setRequest($request)->getToken()) {
             return response()->error('QAPP_NOT_LOGIN');
         }
         try {
-            $user          = $this->auth->authenticate($token);
-            $send_order_id = $request->header('send-order-id', 0);
-            if ($send_order_id) {
-                UserService::setUserSendOrder($user->id, $send_order_id);
+            $user = $this->auth->authenticate($token);
+            if ($sendOrderId) {
+                UserService::setUserSendOrder($user->id, $sendOrderId);
             }
-            (new QappUserService)->setGolableUser($user->id);
+
+            // 设置全局信息
+            (new QappUserService)->setGolableUser($user->id, $package);
         } catch (TokenExpiredException $e) {
             return response()->error('QAPP_TOKEN_ERROR');
         } catch (JWTException $e) {
@@ -45,14 +53,10 @@ class QuickAppGetUserFromToken extends BaseMiddleware
         }
 
         // 更新用户reg_id
-        $uid      = $user->id;
-        $package  = $request->header('x-package', '');
-        $provider = $request->header('x-provider', '');
-        $regId    = $request->header('x-regid', '');
+        $uid = $user->id;
         PushService::setUserRegId($uid, $regId, $provider, $package);
 
         // 推送pv、uv统计
-        $pushId = (int)$request->get('push_id', 0);
         if ($pushId) {
             PushCache::incrPushPv($pushId, date('Ymd'));
             PushCache::zAddPushUv($pushId, date('Ymd'), $uid);

+ 15 - 1
app/Modules/Push/Models/QappPushTask.php

@@ -11,7 +11,8 @@ class QappPushTask extends Model
 {
     protected $table = 'qapp_push_task';
     protected $fillable = ['uid', 'package_id', 'type', 'title', 'content', 'url', 'num',
-        'status', 'providers', 'push_time', 'push_filter', 'push_result', 'select_user_status'];
+        'status', 'providers', 'push_time', 'push_filter', 'push_result', 'select_user_status',
+        'qapp_account', 'pv', 'uv'];
 
     /**
      * @param $id
@@ -69,4 +70,17 @@ class QappPushTask extends Model
             ->orderBy('push_time', 'ASC')
             ->first();
     }
+
+    /**
+     * @return mixed
+     */
+    public static function getAllValidTasks()
+    {
+        $result = self::where('status', PushConst::STATUS_SUCCESS)
+            ->where('select_user_status', PushConst::SELECT_USER_OK)
+            ->where('push_time', '<=', date('Y-m-d H:i:s'))
+            ->orderBy('push_time', 'ASC')
+            ->get();
+        return $result ? $result->toArray() : [];
+    }
 }

+ 18 - 9
app/Modules/Trade/Pay/AliOrderArousePay.php

@@ -11,21 +11,30 @@ class AliOrderArousePay extends OrderArousePayAbstract
 {
     public function arouse(array $data)
     {
-        $pay_merchant_id = (int) $data['pay_merchant_id'];
+        $pay_merchant_id = (int)$data['pay_merchant_id'];
+
+        // 订单描述,针对聚裕的包无法支付的问题(注册时传入了仙女阅读的包名,导致支付时取的支付信息不一致)
+        $package = getProp($data, 'package');
+        if ($package && $package === 'com.juyu.kuaiying.rmyq') {
+            $body = $this->getSubjectNameByPackage($package);
+        } else {
+            $body = $this->getSubjectName($data['distribution_channel_id']);
+        }
+
         $ali_param = [
-            'body' => '小说阅读',
-            'subject' => $this->getSubjectName($data['distribution_channel_id']),
-            'out_trade_no' => $data['trade_no'],
+            'body'            => '小说阅读',
+            'subject'         => $body,
+            'out_trade_no'    => $data['trade_no'],
             'timeout_express' => '90m',
-            'total_amount' => $data['price'] / 100,
-            'product_code' => 'QUICK_WAP_WAY',
-            'return_url' => '',
-            'type' => $data['type'],
+            'total_amount'    => $data['price'] / 100,
+            'product_code'    => 'QUICK_WAP_WAY',
+            'return_url'      => '',
+            'type'            => $data['type'],
             'pay_merchant_id' => $pay_merchant_id,
         ];
         try {
             $config = PayMerchantService::findAliPayConfig($pay_merchant_id);
-            $pay = PayFactory::aliPay($config);
+            $pay    = PayFactory::aliPay($config);
             $result = $pay->send($ali_param);
             return $result;
         } catch (Exception $e) {

+ 7 - 0
app/Modules/Trade/Pay/OrderArousePayAbstract.php

@@ -58,4 +58,11 @@ abstract class OrderArousePayAbstract
         $name    = $package ? $package->name : '';
         return "搜索快应用({$name})继续阅读,投诉电话:0571-56680189";
     }
+
+    protected function getSubjectNameByPackage(string $package)
+    {
+        $package = QappPackage::where('package', $package)->select('name')->first();
+        $name    = $package ? $package->name : '';
+        return "搜索快应用({$name})继续阅读,投诉电话:0571-56680189";
+    }
 }

+ 10 - 1
app/Modules/Trade/Pay/WxOrderArousePay.php

@@ -14,12 +14,21 @@ class WxOrderArousePay extends OrderArousePayAbstract
         $pay_merchant_id = (int)$data['pay_merchant_id'];
         $config          = PayMerchantService::findPayConfig($pay_merchant_id);
         $pay             = PayFactory::official($config);
+
+        // 订单描述,针对聚裕的包无法支付的问题(注册时传入了仙女阅读的包名,导致支付时取的支付信息不一致)
+        $package = getProp($data, 'package');
+        if ($package && $package === 'com.juyu.kuaiying.rmyq') {
+            $body = $this->getSubjectNameByPackage($package);
+        } else {
+            $body = $this->getSubjectName($data['distribution_channel_id']);
+        }
+
         try {
             $payOrder = [
                 'trade_type' => $data['trade_type'], // 交易类型
                 'trade_no'   => $data['trade_no'], // 订单号
                 'price'      => $data['price'], // 订单金额,单位:分
-                'body'       => $this->getSubjectName($data['distribution_channel_id']), // 订单描述
+                'body'       => $body, // 订单描述
                 'create_ip'  => _getIp(), // 支付人的 IP
                 'remark'     => $pay_merchant_id
             ];

+ 18 - 7
app/Modules/User/Services/QappUserService.php

@@ -111,9 +111,9 @@ class QappUserService
         }
     }
 
-    public function setGolableUser(int $uid)
+    public function setGolableUser(int $uid, string $package)
     {
-        $user_info                     = $this->getQAppUserByUid($uid);
+        $user_info                     = $this->getQAppUserByUid($uid, $package);
         $qapp_user                     = app()->make('qapp_user');
         $qapp_user->id                 = $user_info->id;
         $qapp_user->uid                = $user_info->uid;
@@ -142,15 +142,26 @@ class QappUserService
 
     /**
      * 根据uid获取快应用用户信息
+     * @param int    $uid
+     * @param string $package
+     * @return mixed
      */
-    public function getQAppUserByUid(int $uid)
+    public function getQAppUserByUid(int $uid, string $package = '')
     {
         $qapp_user = QappUser::where('uid', $uid)->first();
         if ($qapp_user) {
-            $user                          = User::find($uid);
-            $qapp_user->user               = $user;
-            $qapp_user->send_order_id      = UserService::getUserSendOrder($uid);
-            $package_info                  = QappPackage::where('channel_id', $user->distribution_channel_id)->first();
+            $user                     = User::find($uid);
+            $qapp_user->user          = $user;
+            $qapp_user->send_order_id = UserService::getUserSendOrder($uid);
+
+            // 针对聚裕的包无法支付的问题(注册时传入了仙女阅读的包名,导致支付时取的支付信息不一致)
+            if ($package && $package === 'com.juyu.kuaiying.rmyq') {
+                $package_info = QappPackage::where('package', $package)->first();
+            } else {
+                $package_info = QappPackage::where('channel_id', $user->distribution_channel_id)->first();
+            }
+
+            // 支付id
             $qapp_user->app_pay_merchat_id = $package_info->app_pay_merchat_id;
             $qapp_user->h5_pay_merchat_id  = $package_info->h5_pay_merchat_id;
             $qapp_user->ali_pay_merchat_id = $package_info->ali_pay_merchat_id;