Przeglądaj źródła

Merge branch 'kuaiyingyong' into quickapp_fly

fly 4 lat temu
rodzic
commit
70b64ae14d

+ 1 - 1
app/Http/Controllers/QuickApp/Activity/ActivityController.php

@@ -208,7 +208,7 @@ class ActivityController extends BaseController
         // 获取用户信息
         $user        = User::getUser($this->uid);
         $sendOrderId = getProp($user, 'send_order_id');
-        
+
         // 用户派单的信息是否跟创建该活动的子账号一致
         $qappAccountId = (int)getProp($activity, 'qapp_account_id');
         if ($qappAccountId && $sendOrderId) {

+ 1 - 1
app/Http/Controllers/QuickApp/Activity/Transformers/ReBuildData.php

@@ -51,7 +51,7 @@ class ReBuildData
 
             // 支付产品信息
             $product = collect($products)->firstWhere('id', $productId);
-            $price   = getProp($product, 'price');
+            $price   = (float)getProp($product, 'price');
             $total   = $price * 100 + (int)getProp($product, 'given');
 
             $result[] = [

+ 5 - 5
app/Http/Controllers/QuickApp/User/UserShelfBooksController.php

@@ -65,12 +65,12 @@ class UserShelfBooksController extends BaseController
         if (checkParam($param, ['bid'])) {
             return response()->error('LACK_PARAM');
         }
-
-        $param['uid']                     = $this->uid;
-        $param['bid']                     = Hashids::decode($param['bid'])[0];
-        $param['distribution_channel_id'] = $this->distribution_channel_id;
-        $res                              = UserShelfBooksService::create($param);
+        $res = true;
         try {
+            $param['uid']                     = $this->uid;
+            $param['bid']                     = Hashids::decode($param['bid'])[0];
+            $param['distribution_channel_id'] = $this->distribution_channel_id;
+            $res                              = UserShelfBooksService::create($param);
         } catch (\Exception $e) {
             return response()->error('QAPP_PARAM_ERROR');
         }

+ 8 - 1
app/Http/Controllers/QuickApp/WelcomeController.php

@@ -27,13 +27,20 @@ class WelcomeController extends BaseController
             $send_order              = SendOrderService::getSendOrderStatic($this->send_order_id);
             $distribution_channel_id = $send_order->distribution_channel_id;
             $qappPackage             = QappPackageService::getPackage($distribution_channel_id);
+
+            $showGzh     = 0;
+            $sendOrderId = $this->send_order_id;
+            if ($sendOrderId && in_array($sendOrderId, explode(',', env('SHOW_GZH_SEND_ORDER_IDS')))) {
+                $showGzh = 1;
+            }
             if ($send_order && $qappPackage) {
                 $this->sendOrderStatistic($send_order);//统计
                 return view('qapp.welcome')->with([
                     'package'       => $qappPackage->package,
                     'hash_bid'      => Hashids::encode($send_order->book_id),
                     'cid'           => $send_order->chapter_id,
-                    'send_order_id' => $this->send_order_id
+                    'send_order_id' => $this->send_order_id,
+                    'show_gzh'      => $showGzh
                 ]);
             }
         }

+ 48 - 23
app/Modules/AdPosition/Services/AdPositionService.php

@@ -26,7 +26,7 @@ class AdPositionService
             return [];
         }
 
-        // 获取广告位
+        // 获取所有有效广告位
         $positions = AdPosition::getAllValidAdPositions();
         if (empty($positions)) {
             return [];
@@ -39,6 +39,9 @@ class AdPositionService
             return [];
         }
 
+        // 获取用户相关数据
+        $userData = $this->getUserFilterData($uid);
+
         // 针对分配数据筛选出优先级最高的分配任务
         $result     = [];
         $dispatches = collect($dispatches)->groupBy('ad_position_id')->all();
@@ -47,17 +50,27 @@ class AdPositionService
             $positionId = getProp($position, 'id');
             $ident      = getProp($position, 'ident');
 
-            // 获取优先级最高的任务
+            // 获取对应广告位所有任务
             $validDispatches = getProp($dispatches, $positionId, []);
-            $validDispatch   = $validDispatches ? $validDispatches[0] : [];
-            if (empty($validDispatch)) {
+            if (empty($validDispatches)) {
                 continue;
             }
 
-            // 过滤条件判断
-            $filterContentJson = getProp($validDispatch, 'filter_condition');
-            $matchFilter       = $this->filterDispatch($uid, $filterContentJson);
-            if (!$matchFilter) {
+            // 根据优先级循环匹配,直到匹配到为止
+            $validDispatches = collect($validDispatches)->sortByDesc('priority')->all();
+            $validDispatch   = [];
+            foreach ($validDispatches as $value) {
+                // 过滤条件判断
+                $filterContentJson = getProp($value, 'filter_condition');
+                $matchFilter       = $this->filterDispatch($filterContentJson, $userData);
+                if ($matchFilter) {
+                    $validDispatch = $value;
+                    break;
+                }
+            }
+
+            // 判断
+            if (empty($validDispatch)) {
                 continue;
             }
 
@@ -69,16 +82,35 @@ class AdPositionService
     }
 
     /**
-     * 过滤条件筛选
+     * 用户的数据
      * @param $uid
+     * @return array
+     */
+    private function getUserFilterData($uid): array
+    {
+        // 获取用户信息
+        $user         = QappUser::getUserByUid($uid);
+        $registerAt   = getProp($user, 'created_at');
+        $registerUnix = strtotime($registerAt);
+
+        // 获取用户付费情况
+        $order  = OrderService::getUserLastestOrder($uid);
+        $isPaid = $order ? 1 : 0;
+
+        return compact('registerUnix', 'isPaid');
+    }
+
+    /**
+     * 过滤条件筛选
      * @param $filterContentJson
+     * @param $userData
      * @return bool
      */
-    private function filterDispatch($uid, $filterContentJson): bool
+    private function filterDispatch($filterContentJson, $userData): bool
     {
         // 过滤条件
         $filterContent = json_decode($filterContentJson, true);
-        if (empty($uid) || empty($filterContentJson) || empty($filterContent)) {
+        if (empty($userData) || empty($filterContentJson) || empty($filterContent)) {
             return true;
         }
 
@@ -88,11 +120,7 @@ class AdPositionService
         if ($registerAtArr) {
             // 默认值
             $registerFilter = false;
-
-            // 获取用户信息
-            $user         = QappUser::getUserByUid($uid);
-            $registerAt   = getProp($user, 'created_at');
-            $registerUnix = strtotime($registerAt);
+            $registerUnix   = $userData['registerUnix'];
 
             // 循环条件,满足一条即可
             foreach ($registerAtArr as $register) {
@@ -111,20 +139,17 @@ class AdPositionService
 
         // 判断付费情况
         $paidFilter = true;
-        if (isset($filterContent['isPaid'])) {
-            // 默认值
-            $paidFilter = false;
-
+        if (getProp($filterContent, 'isPaid') !== '') {
             // 获取用户付费情况
-            $order = OrderService::getUserLastestOrder($uid);
+            $isPaid = getProp($userData, 'isPaid', 0);
 
             // 有付费
-            if ($order && $filterContent['isPaid']) {
+            if ($isPaid && getProp($filterContent, 'isPaid') === 1) {
                 $paidFilter = true;
             }
 
             // 未付费
-            if (!$order && !$filterContent['isPaid']) {
+            if (!$isPaid && getProp($filterContent, 'isPaid') === 0) {
                 $paidFilter = true;
             }
         }

+ 2 - 0
app/Modules/Trade/Pay/OrderPaySuccess.php

@@ -31,6 +31,8 @@ class OrderPaySuccess
                 $app = new YearOrderPaySuccess($order);
             } elseif ($order->order_type == 'BOOK') {
                 $app = new BookOrderPaySuccess($order);
+            } elseif ($order->order_type == 'QUARTER') {
+                $app = new QuarterOrderPaySuccess($order);
             } elseif ($order->order_type == 'RECHARGE') {
                 $app = new RechargeOrderPaySuccess($order);
             }

+ 46 - 0
app/Modules/Trade/Pay/QuarterOrderPaySuccess.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace App\Modules\Trade\Pay;
+
+use App\Modules\Subscribe\Models\Order;
+use App\Modules\Subscribe\Models\YearOrder;
+
+
+class QuarterOrderPaySuccess extends PaySuccessAbstract
+{
+    private $year_order;
+
+    public function __construct(Order $order)
+    {
+        parent::__construct($order);
+        $this->year_order = [];
+        $this->year_order['uid'] = $order->uid;
+        $this->year_order['distribution_channel_id'] = $order->distribution_channel_id;
+        $this->year_order['fee'] = $order->price;
+        $this->year_order['send_order_id'] = $order->send_order_id;
+    }
+
+    protected function handlePayProcess()
+    {
+        $this->year_order['begin_time'] = date('Y-m-d H:i:s');
+        $this->year_order['end_time'] = date('Y-m-d H:i:s', strtotime('+92 day'));
+        $old = YearOrder::where('uid', $this->year_order['uid'])->select('id', 'uid', 'u', 'begin_time', 'end_time', 'fee')->first();
+        if ($old) {
+            //如果包过年
+            if (strtotime($old->end_time) > time()) {
+                //旧的包年没过期
+                $old->end_time = date('Y-m-d H:i:s', strtotime($old->end_time) + 86400 * 92);
+                $old->fee = $old->fee + $this->year_order['fee'];
+                $old->save();
+            } else {
+                //旧的包年过期了
+                $old->end_time = date('Y-m-d H:i:s', strtotime('+92 day'));
+                $old->fee = $old->fee + $this->year_order['fee'];
+                $old->save();
+            }
+            return $old;
+        } else {
+            return YearOrder::firstOrCreate($this->year_order);
+        }
+    }
+}

Plik diff jest za duży
+ 354 - 317
resources/views/qapp/welcome.blade.php