소스 검색

Merge branch 'gift'

zz 6 년 전
부모
커밋
3b9e13c5c6
3개의 변경된 파일142개의 추가작업 그리고 118개의 파일을 삭제
  1. 9 3
      app/Http/Controllers/Wap/Order/OrdersController.php
  2. 6 115
      app/Http/Controllers/Wap/Pay/OrdersController.php
  3. 127 0
      app/Modules/Book/Services/BookGiftsService.php

+ 9 - 3
app/Http/Controllers/Wap/Order/OrdersController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\Wap\Order;
 
+use App\Modules\Book\Services\BookGiftsService;
 use App\Modules\Subscribe\Models\Order;
 use App\Http\Controllers\Wap\BaseController;
 use App\Modules\Book\Services\BookConfigService;
@@ -14,6 +15,7 @@ use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
 use App\Modules\User\Services\ForceSubscribeUserIService;
 use App\Modules\User\Services\UserDivisionCpcPropertyService;
 use App\Modules\User\Services\UserDivisionPropertyService;
+use App\Modules\User\Services\UserGiftService;
 use App\Modules\User\Services\UserService;
 use App\Modules\Book\Services\BookService;
 use App\Modules\Channel\Services\PayTemplateService;
@@ -282,6 +284,7 @@ class OrdersController extends BaseController
                 }
             }
         }
+        $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) {
@@ -305,7 +308,8 @@ class OrdersController extends BaseController
                     'today_special' => false,
                     'save_text' => round($v->given / 100, 1) . '元',
                     'product_id' => $v->id,
-                    'show_free_ads' => $appad
+                    'show_free_ads' => $appad,
+                    'gift'=>BookGiftsService::chargeGiveGift($property,$v->price,$v->type)
                 ];
                 $data[] = $temp;
             } elseif ($v->type == 'YEAR_ORDER') {
@@ -322,7 +326,8 @@ class OrdersController extends BaseController
                     'today_special' => $outstandingYearOrder,
                     'save_text' => $save_text,
                     'product_id' => $v->id,
-                    'show_free_ads' => $appad
+                    'show_free_ads' => $appad,
+                    'gift'=>BookGiftsService::chargeGiveGift($property,$v->price,$v->type)
                 ];
                 $data[] = $temp;
             } else {
@@ -345,7 +350,8 @@ class OrdersController extends BaseController
                     'today_special' => ($v->is_default == 1 && $outstandingYearOrder == false) ? true : false,
                     'save_text' => $save_text,
                     'product_id' => $v->id,
-                    'show_free_ads' => $appad
+                    'show_free_ads' => $appad,
+                    'gift'=>BookGiftsService::chargeGiveGift($property,$v->price,$v->type)
                 ];
                 $data[] = $temp;
             }

+ 6 - 115
app/Http/Controllers/Wap/Pay/OrdersController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\Wap\Pay;
 
 use App\Admin\Models\User;
+use App\Modules\Book\Services\BookGiftsService;
 use App\Modules\Book\Services\ChapterService;
 use App\Modules\OfficialAccount\Services\OfficialAccountService;
 use App\Modules\Subscribe\Services\OrderParamService;
@@ -1472,9 +1473,9 @@ class OrdersController extends Controller
             if ($force_sub_info) {
                 //$content_format = "您好,你已经成功充值\r\n\r\n会员:%s\r\n会员ID:%s\r\n充值金额:%s\r\n充值状态:充值成功\r\n如有疑问,请点击用户中心-联系客服\r\n\r\n><a href='%s'>点击继续阅读上次阅读</a>";
                 if (SubstituteOrderService::getByOrderId($order_id)) {
-                    $content_format = "代充值客服消息:\r\n\r\n你好,您的好友为你代付成功\r\n会员:%s\r\n会员ID:%s\r\n代付金额:%s\r\n充值状态:充值成功\r\n如有疑问,请点击用户中心-联系客服\r\n\r\n><a href='%s'>点击继续阅读上次阅读</a>";
+                    $content_format = "代充值客服消息:\r\n\r\n你好,您的好友为你代付成功\r\n会员:%s\r\n会员ID:%s\r\n代付金额:%s\r\n充值状态:充值成功\r\n如有疑问,请点击用户中心-联系客服\r\n赠送的礼物道具在阅读页-送礼物\r\n\r\n><a href='%s'>点击继续阅读上次阅读</a>";
                 } else {
-                    $content_format = "您好,你已经成功充值\r\n\r\n会员:%s\r\n会员ID:%s\r\n充值金额:%s\r\n充值状态:充值成功\r\n如有疑问,请点击用户中心-联系客服\r\n\r\n><a href='%s'>点击继续阅读上次阅读</a>";
+                    $content_format = "您好,你已经成功充值\r\n\r\n会员:%s\r\n会员ID:%s\r\n充值金额:%s\r\n充值状态:充值成功\r\n如有疑问,请点击用户中心-联系客服\r\n赠送的礼物道具在阅读页-送礼物\r\n\r\n><a href='%s'>点击继续阅读上次阅读</a>";
                 }
                 if ($product_info->type == 'YEAR_ORDER') {
                     $money_text = $product_info->price . '元(尊贵的年费VIP会员)';
@@ -1797,120 +1798,10 @@ class OrdersController extends Controller
     }
 
     private function chargeGiveGift($uid,$property,$price,$charge_type){
-        if(!$property) return ;
-        if($property == 'none' || $property == 'low'){
-            $gift = [];
-            if($price == 2){
-                $gift = [['gift_id'=>6,'num'=>1]];
-            }
-            if($price == 18){
-                $gift = [['gift_id'=>6,'num'=>1],['gift_id'=>7,'num'=>1]];
-            }
-            if($price == 30){
-                $gift = [
-                    ['gift_id'=>6,'num'=>1],
-                    ['gift_id'=>7,'num'=>1],
-                    ['gift_id'=>1,'num'=>1]
-                ];
-            }
-            if($price == 50){
-                $gift = [
-                    ['gift_id'=>6,'num'=>1],
-                    ['gift_id'=>7,'num'=>1],
-                    ['gift_id'=>1,'num'=>1],
-                    ['gift_id'=>3,'num'=>1]
-                ];
-            }
-            if($price == 100){
-                $gift = [
-                    ['gift_id'=>7,'num'=>1],
-                    ['gift_id'=>1,'num'=>1],
-                    ['gift_id'=>3,'num'=>1],
-                    ['gift_id'=>2,'num'=>1]
-                ];
-            }
-            if($price == 200){
-                $gift = [
-                    ['gift_id'=>7,'num'=>1],
-                    ['gift_id'=>1,'num'=>1],
-                    ['gift_id'=>3,'num'=>1],
-                    ['gift_id'=>2,'num'=>1],
-                    ['gift_id'=>8,'num'=>1]
-                ];
-            }
-            if($charge_type == 'YEAR_ORDER'){
-                $gift = [
-                    ['gift_id'=>1,'num'=>1],
-                    ['gift_id'=>2,'num'=>1],
-                    ['gift_id'=>3,'num'=>1],
-                    ['gift_id'=>6,'num'=>1],
-                    ['gift_id'=>7,'num'=>1],
-                    ['gift_id'=>8,'num'=>1]
-                ];
-            }
-            if($gift){
-                UserGiftService::addGift($uid,$gift);
-            }
-            return ;
+        $gift = BookGiftsService::chargeGiveGift($property,$price,$charge_type);
+        if($gift){
+            UserGiftService::addGift($uid,$gift);
         }
-
-        if($property == 'high' || $property == 'medium'){
-            $gift = [];
-            if($price == 18){
-                $gift = [
-                    ['gift_id'=>6,'num'=>1],
-                    ['gift_id'=>1,'num'=>1],
-                    ['gift_id'=>7,'num'=>1]
-                ];
-            }
-            if($price == 30){
-                $gift = [
-                    ['gift_id'=>6,'num'=>1],
-                    ['gift_id'=>7,'num'=>1],
-                    ['gift_id'=>1,'num'=>2]
-                ];
-            }
-            if($price == 50){
-                $gift = [
-                    ['gift_id'=>6,'num'=>2],
-                    ['gift_id'=>7,'num'=>2],
-                    ['gift_id'=>1,'num'=>2],
-                    ['gift_id'=>3,'num'=>1]
-                ];
-            }
-            if($price == 100){
-                $gift = [
-                    ['gift_id'=>7,'num'=>3],
-                    ['gift_id'=>1,'num'=>2],
-                    ['gift_id'=>3,'num'=>1],
-                    ['gift_id'=>2,'num'=>1]
-                ];
-            }
-            if($price == 200){
-                $gift = [
-                    ['gift_id'=>7,'num'=>1],
-                    ['gift_id'=>1,'num'=>1],
-                    ['gift_id'=>3,'num'=>1],
-                    ['gift_id'=>2,'num'=>1],
-                    ['gift_id'=>8,'num'=>1]
-                ];
-            }
-            if($charge_type == 'YEAR_ORDER'){
-                $gift = [
-                    ['gift_id'=>1,'num'=>2],
-                    ['gift_id'=>2,'num'=>2],
-                    ['gift_id'=>3,'num'=>2],
-                    ['gift_id'=>6,'num'=>2],
-                    ['gift_id'=>7,'num'=>2],
-                    ['gift_id'=>8,'num'=>2]
-                ];
-            }
-            if($gift){
-                UserGiftService::addGift($uid,$gift);
-            }
-            return ;
-        }
-
         return ;
     }
 }

+ 127 - 0
app/Modules/Book/Services/BookGiftsService.php

@@ -130,5 +130,132 @@ class BookGiftsService
         return BookGiftsStatsByGift::getStats();
     }
 
+    public static function chargeGiveGift($property,$price,$charge_type){
+        if(!$property) return [];
+        $gift_info = [
+            1=>['name_desc'=>'黄金玫瑰','cost'=>200,'icon'=>'https://yqcdn.iycdm.com/wap/present/20181016/3.png'],
+            2=>['name_desc'=>'文学奖','cost'=>800,'icon'=>'https://yqcdn.iycdm.com/wap/present/20181016/5.png'],
+            3=>['name_desc'=>'锦囊','cost'=>500,'icon'=>'https://yqcdn.iycdm.com/wap/present/20181016/4.png'],
+            4=>['name_desc'=>'小皮鞭','cost'=>200,'icon'=>'https://yqcdn.iycdm.com/wap/present/20181016/6.png'],
+            5=>['name_desc'=>'催更票','cost'=>100,'icon'=>'https://yqcdn.iycdm.com/wap/present/20181016/1.png'],
+            6=>['name_desc'=>'点个赞','cost'=>50,'icon'=>'https://yqcdn.iycdm.com/wap/present/20181016/2.png'],
+            7=>['name_desc'=>'文房四宝','cost'=>100,'icon'=>'https://cdn-novel.iycdm.com/h5/20181107/four_literature_tools.png'],
+            8=>['name_desc'=>'至尊大神','cost'=>1800,'icon'=>'https://cdn-novel.iycdm.com/h5/20181107/literature_emprior.png'],
+        ];
+        if($property == 'none' || $property == 'low'){
+            $gift = [];
+            if($price <18 && $price >=2){
+                $gift = [['gift_id'=>6,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']];
+            }elseif ($price <30){
+                $gift = [['gift_id'=>6,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']];
+            }elseif($price < 50 ){
+                $gift = [
+                    ['gift_id'=>6,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }elseif ($price <100){
+                $gift = [
+                    ['gift_id'=>6,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>3,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }elseif ($price <200){
+                $gift = [
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>3,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>2,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }elseif ($price >=200){
+                $gift = [
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>3,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>2,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>8,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }
+            if($charge_type == 'YEAR_ORDER'){
+                $gift = [
+                    ['gift_id'=>1,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>2,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>3,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>6,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>8,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }
+            if($gift){
+                foreach ($gift as $item){
+                    $item['name_desc'] = $gift_info[$item['gift_id']];
+                    $item['cost'] = $gift_info[$item['cost']];
+                    $item['icon'] = $gift_info[$item['icon']];
+                }
+            }
+            return $gift;
+        }
+
+        if($property == 'high' || $property == 'medium'){
+            $gift = [];
+            if($price <30 && $price >=18){
+                $gift = [
+                    ['gift_id'=>6,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }elseif($price < 50 ){
+                $gift = [
+                    ['gift_id'=>6,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }elseif ($price <100){
+                $gift = [
+                    ['gift_id'=>6,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>7,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>3,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }elseif ($price <200){
+                $gift = [
+                    ['gift_id'=>7,'num'=>3,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>3,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>2,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
 
+            }elseif ($price >=200){
+                $gift = [
+                    ['gift_id'=>7,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>1,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>3,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>2,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>8,'num'=>1,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }
+            if($charge_type == 'YEAR_ORDER'){
+                $gift = [
+                    ['gift_id'=>1,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>2,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>3,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>6,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>7,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>''],
+                    ['gift_id'=>8,'num'=>2,'name_desc'=>'','cost'=>'','icon'=>'']
+                ];
+            }
+            if($gift){
+                foreach ($gift as $item){
+                    $item['name_desc'] = $gift_info[$item['gift_id']];
+                    $item['cost'] = $gift_info[$item['cost']];
+                    $item['icon'] = $gift_info[$item['icon']];
+                }
+            }
+            return $gift;
+        }
+
+        return [];
+    }
 }