Browse Source

按章收费,按账户bid级别设置

zhoulj 4 years ago
parent
commit
3712c99d9d

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

@@ -23,6 +23,7 @@ use App\Modules\Subscribe\Services\ChapterReminderService;
 use App\Modules\User\Services\UserDeepReadTagService;
 use App\Modules\UserTask\Services\BaseTask;
 use App\Modules\UserTask\Services\UserTaskService;
+use App\Modules\SendOrder\Models\QappSendOrder;
 
 class ChapterController extends BaseController
 {
@@ -572,7 +573,16 @@ class ChapterController extends BaseController
                 return 899;
             }
         } else {
-            $fee = BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size);
+            // 获取投放后台账号, 
+            $account = '';
+            if(isset($this->user_info->send_order_id) && $this->user_info->send_order_id){
+                $account_send_order = QappSendOrder::getSendOrderById($this->user_info->send_order_id);
+                $account = isset($account_send_order['account'])?$account_send_order['account']:'';
+                
+                \Log::info('getPrice:'.$this->uid.' account:'.$account.' send_order_id:'.$this->user_info->send_order_id);
+            }
+            
+            $fee = BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size,$account);
             return $fee;
         }
     }

+ 33 - 3
app/Modules/Book/Services/BookService.php

@@ -164,22 +164,46 @@ class BookService
         return 0;
     }
 
-    public static function getPrice($book_info,$distribution_channel_id,$size){
+    public static function getPrice($book_info,$distribution_channel_id,$size,$account=''){
+        // 书默认--- 收费类型
         $calculate_price_type = $book_info->calculate_price_type;
+        
+        // 渠道bid--- 收费类型
         $channel_calculate_price_type = Redis::hget('channel:charge_type:setting:' . $distribution_channel_id,  $book_info->bid);
         if($channel_calculate_price_type){
             $calculate_price_type = $channel_calculate_price_type;
         }
+        
+        // 账户bid优先--- 收费类型
+        $channel_account_calculate_price_type = Redis::hget('channel:charge_type:setting:' . $distribution_channel_id.':'.$account,  $book_info->bid);
+        if($channel_account_calculate_price_type){
+             $calculate_price_type = $channel_account_calculate_price_type;
+        }
+        
+        // 渠道bid价格
 	    $distribution_channel_id_price = Redis::hget('channel:price:setting:'.$distribution_channel_id,$book_info->bid);
+	    
+	    // 账户bid默认价格
+	    $distribution_account_channel_id_price = Redis::hget('channel:price:setting:'.$distribution_channel_id.':'.$account, $book_info->bid);
+	    
         //固定价格
         if(strtolower($calculate_price_type) == 'const'){
             $price = (int)$book_info->unit_price;
-	    if($distribution_channel_id_price){
+	        if($distribution_channel_id_price){
                 $price = (int)$distribution_channel_id_price;
             }
+            if($distribution_account_channel_id_price){
+                $price = (int)$distribution_account_channel_id_price;
+            }
+            
+            $price = $price < 30 ? 30 : $price;
+            
+            \Log::info('getprice:book:'.$book_info->bid.' calculate_price_type:'.$calculate_price_type.' distribution_channel_id:'.$distribution_channel_id.' account:'.$account.' price:'.$price);
 
-            return $price < 30 ? 30 : $price;
+            return $price;
         }
+        
+        
         //千字价格
         $channel_fee = self::getChapterPrice($distribution_channel_id);
         if ($channel_fee) {
@@ -194,10 +218,16 @@ class BookService
 	    if($distribution_channel_id_price){
             $price_rate = $distribution_channel_id_price;
         }
+        if($distribution_account_channel_id_price){
+            $price_rate = $distribution_account_channel_id_price;
+        }
 
         $fee = ceil($size * $price_rate);
         if($fee >189) $fee = 189;
         if($fee <37) $fee = 37;
+        
+        \Log::info('getprice:book:'.$book_info->bid.' calculate_price_type:'.$calculate_price_type.' distribution_channel_id:'.$distribution_channel_id.' account:'.$account.' price:'.$fee.' size:'.$size.' $price_rate:'.$price_rate);
+        
         return $fee;
     }