|
@@ -54,7 +54,7 @@ class ChapterController extends BaseController
|
|
$page_size = $request->input('page_size', 15);
|
|
$page_size = $request->input('page_size', 15);
|
|
|
|
|
|
if ($page_size >= 100) $page_size = 100;
|
|
if ($page_size >= 100) $page_size = 100;
|
|
- $page_size = 15;
|
|
|
|
|
|
+ // $page_size = 15;
|
|
$res = ChapterService::getChapterListsPage($bid, $page_size);
|
|
$res = ChapterService::getChapterListsPage($bid, $page_size);
|
|
|
|
|
|
$lists = $this->getChapterCatalog($bid, $res, $book_info);
|
|
$lists = $this->getChapterCatalog($bid, $res, $book_info);
|
|
@@ -75,10 +75,10 @@ class ChapterController extends BaseController
|
|
if($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name) ){
|
|
if($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name) ){
|
|
$change_chapter_name = 1;
|
|
$change_chapter_name = 1;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ $account = $this->getAccount();
|
|
switch ($book_info->charge_type) {
|
|
switch ($book_info->charge_type) {
|
|
case 'BOOK':
|
|
case 'BOOK':
|
|
- $price = $this->getPrice($book_info);
|
|
|
|
|
|
+ $price = $this->getPriceNew($book_info,0, $account);
|
|
$is_need_charge = $this->isBookNeedCharge($bid, $price);
|
|
$is_need_charge = $this->isBookNeedCharge($bid, $price);
|
|
foreach ($chapters as $v) {
|
|
foreach ($chapters as $v) {
|
|
$v->next_chapter_status = 0;
|
|
$v->next_chapter_status = 0;
|
|
@@ -105,6 +105,12 @@ class ChapterController extends BaseController
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
|
|
+ $chapterIds = $this->getChapterIds($chapters);
|
|
|
|
+ $rules = ['check' => 0,'paycid' => []];
|
|
|
|
+ if (!$isFree && !empty($chapterIds)){
|
|
|
|
+ $rules = $this->getHandelData($bid,$chapterIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
foreach ($chapters as $v) {
|
|
foreach ($chapters as $v) {
|
|
if($vip_sequence){
|
|
if($vip_sequence){
|
|
if($v->sequence >= $vip_sequence){
|
|
if($v->sequence >= $vip_sequence){
|
|
@@ -119,17 +125,24 @@ class ChapterController extends BaseController
|
|
$v->is_need_charge = false;
|
|
$v->is_need_charge = false;
|
|
$v->price = 0;
|
|
$v->price = 0;
|
|
} else {
|
|
} else {
|
|
- $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;
|
|
|
|
|
|
+ $v->price = $v->is_vip ? $this->getPriceNew($book_info, $v->size,$account) : 0;
|
|
|
|
+ $v->is_need_charge = $v->is_vip ? $this->isChapterNeedChargeNew($v->id,$rules,$v->price) : false;
|
|
}
|
|
}
|
|
- //下一章付费信息
|
|
|
|
|
|
+ // //下一章付费信息
|
|
$v->next_chapter_status = 0;
|
|
$v->next_chapter_status = 0;
|
|
$v->next_price = 0;
|
|
$v->next_price = 0;
|
|
- if($v->is_vip){
|
|
|
|
- $next_chapter_order_status = $this->nextChapterOrderStatus($bid,$v->next_cid);
|
|
|
|
- $v->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
|
|
|
|
- $v->next_price = $next_chapter_order_status['next_price'];
|
|
|
|
- }
|
|
|
|
|
|
+ // if($v->is_vip){
|
|
|
|
+ // if(in_array($v->next_price,$chapterIds)){
|
|
|
|
+ //
|
|
|
|
+ // }else{
|
|
|
|
+ // $next_chapter_order_status = $this->nextChapterOrderStatus($bid,$v->next_cid);
|
|
|
|
+ // $v->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
|
|
|
|
+ // $v->next_price = $next_chapter_order_status['next_price'];
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // }
|
|
|
|
+ $v->next_chapter_status = $v->is_need_charge == true ? 2:1;
|
|
|
|
+ $v->next_price = $v->price;
|
|
|
|
|
|
//拆章
|
|
//拆章
|
|
if($change_chapter_name){
|
|
if($change_chapter_name){
|
|
@@ -828,6 +841,42 @@ class ChapterController extends BaseController
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 计算价格
|
|
|
|
+ * @param $book_info
|
|
|
|
+ * @param $chapter_size
|
|
|
|
+ * @return float
|
|
|
|
+ */
|
|
|
|
+ private function getPriceNew($book_info, $chapter_size = 0,$account="")
|
|
|
|
+ {
|
|
|
|
+ if ($book_info->charge_type == 'BOOK') {
|
|
|
|
+ if (BookOrderService::isHasBookOrder($this->uid)) {
|
|
|
|
+ $this->is_first_book_order = 0;
|
|
|
|
+ return 1399;
|
|
|
|
+ } else {
|
|
|
|
+ $this->is_first_book_order = 1;
|
|
|
|
+ return 899;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size,$account);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取投放后台账号,
|
|
|
|
+ * name: getAccount
|
|
|
|
+ * @return mixed|string
|
|
|
|
+ * date 2022/10/20 11:29
|
|
|
|
+ */
|
|
|
|
+ protected function getAccount(){
|
|
|
|
+
|
|
|
|
+ $account = '';
|
|
|
|
+ $account_send_order = $this->getNowSendOrderInfo();
|
|
|
|
+ if($account_send_order){
|
|
|
|
+ $account = isset($account_send_order['account'])?$account_send_order['account']:'';
|
|
|
|
+ }
|
|
|
|
+ return $account;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 用户添加标签
|
|
* 用户添加标签
|
|
@@ -978,4 +1027,60 @@ class ChapterController extends BaseController
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private function getChapterIds($chapters): array
|
|
|
|
+ {
|
|
|
|
+ $list = [];
|
|
|
|
+ if($chapters){
|
|
|
|
+ foreach ($chapters as $v){
|
|
|
|
+ $list[] = $v->id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return $list;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function getHandelData(int $bid, array $chapterIds): array
|
|
|
|
+ {
|
|
|
|
+ $uid = $this->uid;
|
|
|
|
+ $res = YearOrderService::getRecord($uid);
|
|
|
|
+ if ($res) {
|
|
|
|
+ return $handle = ['check' => 0,'paycid' => []];
|
|
|
|
+ }
|
|
|
|
+ $res = null;
|
|
|
|
+
|
|
|
|
+ //单本订购记录
|
|
|
|
+ $res = BookOrderService::getRecordByuidBid($uid, $bid);
|
|
|
|
+ if ($res) {
|
|
|
|
+ return $handle = ['check' => 0,'paycid' => []];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //章节订购记录
|
|
|
|
+ $chapterOrder = new ChapterOrderService();
|
|
|
|
+ $res = $chapterOrder->getOrdersByChapterIds($uid, $bid, $chapterIds);
|
|
|
|
+ return $handle = ['check' => 1,'paycid' => $res];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 判断是否需要充值
|
|
|
|
+ * name: isChapterNeedChargeNew
|
|
|
|
+ * @param $cid
|
|
|
|
+ * @param $rules
|
|
|
|
+ * @return bool
|
|
|
|
+ * date 2022/10/20 16:08
|
|
|
|
+ */
|
|
|
|
+ private function isChapterNeedChargeNew($cid,$rules,$price = 0): bool
|
|
|
|
+ {
|
|
|
|
+ if($rules['check'] != 1){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (empty($rules['paycid']) || !in_array($cid,$rules['paycid'])){
|
|
|
|
+ $user_info = $this->user_info;
|
|
|
|
+ return $user_info['balance'] < $price;
|
|
|
|
+ }else{
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|