|
@@ -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;
|
|
|
}
|
|
|
|