|
@@ -38,6 +38,7 @@ class ChapterController extends BaseController
|
|
|
if (!$book_info) {
|
|
|
return response()->error('PARAM_ERROR');
|
|
|
}
|
|
|
+ $this->book_info = $book_info;
|
|
|
$lists = $this->getChapterCatalog($bid, $lists, $book_info);
|
|
|
return response()->collection(new ChapterListTransformer, $lists);
|
|
|
}
|
|
@@ -49,6 +50,7 @@ class ChapterController extends BaseController
|
|
|
if (!$book_info) {
|
|
|
return response()->error('PARAM_ERROR');
|
|
|
}
|
|
|
+ $this->book_info = $book_info;
|
|
|
$page_size = $request->input('page_size', 15);
|
|
|
if ($page_size >= 100) $page_size = 100;
|
|
|
$res = ChapterService::getChapterListsPage($bid, $page_size);
|
|
@@ -74,6 +76,8 @@ class ChapterController extends BaseController
|
|
|
$price = $this->getPrice($book_info);
|
|
|
$is_need_charge = $this->isBookNeedCharge($bid, $price);
|
|
|
foreach ($chapters as $v) {
|
|
|
+ $v->next_chapter_status = 0;
|
|
|
+ $v->next_price = 0;
|
|
|
$v->is_need_charge = $v->is_vip ? $is_need_charge : false;
|
|
|
$v->price = $price;
|
|
|
|
|
@@ -97,6 +101,14 @@ class ChapterController extends BaseController
|
|
|
break;
|
|
|
default:
|
|
|
foreach ($chapters as $v) {
|
|
|
+ if($vip_sequence){
|
|
|
+ if($v->sequence >= $vip_sequence){
|
|
|
+ $v->is_vip = 1;
|
|
|
+ }else{
|
|
|
+ $v->is_vip = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 限免判断
|
|
|
if ($isFree) {
|
|
|
$v->is_need_charge = false;
|
|
@@ -105,13 +117,15 @@ class ChapterController extends BaseController
|
|
|
$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;
|
|
|
}
|
|
|
- if($vip_sequence){
|
|
|
- if($v->sequence >= $vip_sequence){
|
|
|
- $v->is_vip = 1;
|
|
|
- }else{
|
|
|
- $v->is_vip = 0;
|
|
|
- }
|
|
|
+ //下一章付费信息
|
|
|
+ $v->next_chapter_status = 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($change_chapter_name){
|
|
|
$v->name = '第'.$v->sequence.'章';
|
|
@@ -124,6 +138,9 @@ class ChapterController extends BaseController
|
|
|
|
|
|
public function index(Request $request, $bid, $cid)
|
|
|
{
|
|
|
+ $send_order_id = $request->header('send_order_id', '');
|
|
|
+ //每次绑定用户和派单的关系
|
|
|
+ $this->bindSendOrderId($this->uid,$send_order_id);
|
|
|
$oldbid = $bid;
|
|
|
$bid = BookService::decodeBidStatic($bid);
|
|
|
//获取图书信息
|
|
@@ -131,23 +148,29 @@ class ChapterController extends BaseController
|
|
|
if (empty($book_info))
|
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
|
|
|
- //yuyuedu、xinghe 快应用这两个cp的书屏蔽下
|
|
|
- if(in_array($book_info->cp_source,['yuyuedu','xinghe','dingtian','dingtian3'])){
|
|
|
+ $this->book_info = $book_info;
|
|
|
+
|
|
|
+ //yuyuedu、xinghe 快应用这两个cp的书屏蔽下 wutong,wutong2,wutong3下所有内容都不放快应用
|
|
|
+ if(in_array($book_info->cp_source,getHiddenCp())){
|
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
}
|
|
|
|
|
|
if($this->distribution_channel_id == 7477 && $bid == 13765){
|
|
|
$book_info->is_on_shelf = 2;
|
|
|
}
|
|
|
+ if($bid == 58886){
|
|
|
+ $book_info->is_on_shelf = 0;
|
|
|
+ }
|
|
|
+
|
|
|
if (!in_array($book_info->is_on_shelf, [1,2])) {
|
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
|
}
|
|
|
|
|
|
//wutong,wutong2,wutong3下所有内容都不放快应用
|
|
|
|
|
|
- if(in_array($book_info->cp_source,['wutong','wutong2','wutong3','youyan2'])){
|
|
|
- return response()->error('QAPP_OFF_SHELF');
|
|
|
- }
|
|
|
+// if(in_array($book_info->cp_source,['wutong','wutong2','wutong3','youyan2'])){
|
|
|
+// return response()->error('QAPP_OFF_SHELF');
|
|
|
+// }
|
|
|
|
|
|
$this->book_info = $book_info;
|
|
|
//获取章节信息
|
|
@@ -276,6 +299,14 @@ class ChapterController extends BaseController
|
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
}
|
|
|
}
|
|
|
+ if(!$this->send_order_id){
|
|
|
+ if($book_info->charge_type == 'BOOK'){
|
|
|
+ return response()->error('QAPP_BOOK_BUY', $data);
|
|
|
+ }/*else{
|
|
|
+ return response()->error('QAPP_CHAPTER_BUY', $data);
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+
|
|
|
//付费 不提醒
|
|
|
if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, 0)) {
|
|
|
UserTaskService::addUserTaskQueue($this->uid, BaseTask::read, UserTaskService::judge_trigger);
|
|
@@ -303,6 +334,10 @@ class ChapterController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if($this->uid == 247081369){
|
|
|
+ $item = itemTransform(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
|
+ myLog('xueqi')->info($item);
|
|
|
+ }
|
|
|
return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
|
} else {
|
|
|
if ($book_info->charge_type == 'BOOK') {
|
|
@@ -323,7 +358,7 @@ class ChapterController extends BaseController
|
|
|
$bid = BookService::decodeBidStatic($bid);
|
|
|
$book_info = BookConfigService::getBookById($bid);;
|
|
|
if (empty($book_info)) response()->error('QAPP_SYS_ERROR');
|
|
|
-
|
|
|
+ $this->book_info = $book_info;
|
|
|
if($this->distribution_channel_id == 7477 && $bid == 13765){
|
|
|
$book_info->is_on_shelf = 2;
|
|
|
}
|
|
@@ -348,11 +383,50 @@ class ChapterController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if ($this->getOrderRecord($bid, $cid)) {
|
|
|
+ ReadRecordService::addReadLog($this->uid, [
|
|
|
+ 'distribution_channel_id' => $this->distribution_channel_id,
|
|
|
+ 'bid' => $bid,
|
|
|
+ 'cid' => $chapter->id,
|
|
|
+ 'uid' => $this->uid,
|
|
|
+ 'send_order_id' => $this->send_order_id,
|
|
|
+ 'sequence' => $chapter->sequence,
|
|
|
+ ]);
|
|
|
+ ReadRecordService::addReadRecord([
|
|
|
+ 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
|
|
|
+ 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
|
|
|
+ ]);
|
|
|
+
|
|
|
+
|
|
|
+ return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
|
+ }
|
|
|
+
|
|
|
if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, $remind)) {
|
|
|
+ UserTaskService::addUserTaskQueue($this->uid, BaseTask::read, UserTaskService::judge_trigger);
|
|
|
+ ReadRecordService::addReadLog($this->uid, [
|
|
|
+ 'distribution_channel_id' => $this->distribution_channel_id,
|
|
|
+ 'bid' => $bid,
|
|
|
+ 'cid' => $chapter->id,
|
|
|
+ 'uid' => $this->uid,
|
|
|
+ 'send_order_id' => $this->send_order_id,
|
|
|
+ 'sequence' => $chapter->sequence,
|
|
|
+ ]);
|
|
|
ReadRecordService::addReadRecord([
|
|
|
'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
|
|
|
'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
|
|
|
]);
|
|
|
+ $free_book = BookConfigService::getByBidNoFilter($bid);
|
|
|
+ if($free_book) {
|
|
|
+ if(strtotime($free_book->end_time)+7*86400 >= strtotime(date('Y-m-d'))) {
|
|
|
+ if(Redis::Sismember('qapp:free:virtual:uids'.$free_book->id,$this->uid)){
|
|
|
+ $now = date('Y-m-d');
|
|
|
+ $fee = $this->getPrice($book_info, $chapter->size);
|
|
|
+ Redis::hincrby('qapp:book:free:actuality:' . $free_book->id, $now, $fee);
|
|
|
+ Redis::sadd('qapp:free:actuality' . $now, $free_book->id);
|
|
|
+ Redis::sadd('qapp:free:actuality:uids'.$now.$free_book->id,$this->uid);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
|
} else {
|
|
@@ -416,6 +490,17 @@ class ChapterController extends BaseController
|
|
|
$chapter_content = ChapterService::getChapter($bid, $cid);
|
|
|
if (!$chapter_content) return false;
|
|
|
$chapter->content = trim(str_replace($chapter_content->name, '', $chapter_content->content));
|
|
|
+ // 格式特殊处理
|
|
|
+ $qian=array(" "," ","\t");
|
|
|
+ $hou=array("","","");
|
|
|
+ // 去掉所有空格
|
|
|
+ $chapter->content = str_replace($qian,$hou,$chapter->content);
|
|
|
+ // 2换行变1换行
|
|
|
+ $chapter->content = str_replace("\n\n", "\n", $chapter->content);
|
|
|
+ $chapter->content = str_replace("\r\n\r\n", "\r\n", $chapter->content);
|
|
|
+
|
|
|
+// \Log::info('getChapter_chapter:'.$bid.' cid:'.$cid);
|
|
|
+// \Log::info($chapter->content);
|
|
|
//统计点击率
|
|
|
$key = 'book_click_num_bid_' . $bid;
|
|
|
$field = date('Y-m-d');
|
|
@@ -426,9 +511,29 @@ class ChapterController extends BaseController
|
|
|
$chapter->force_add_desk_type = $force_add_desk_type;
|
|
|
//统计
|
|
|
$this->stats();
|
|
|
+ $next_chapter_order_status = $this->nextChapterOrderStatus($bid,$chapter->next_cid);
|
|
|
+ $chapter->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
|
|
|
+ $chapter->next_price = $next_chapter_order_status['next_price'];
|
|
|
+ $chapter->charge_type = $this->book_info->charge_type;
|
|
|
$this->userBookCombination($chapter);
|
|
|
return $chapter;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private function nextChapterOrderStatus($bid,$cid){
|
|
|
+ $chapter = ChapterService::getChapterNameById($cid, $bid);
|
|
|
+ if(!$chapter || $chapter->is_vip == 0 || $this->book_info->charge_type == 'BOOK'){
|
|
|
+ return ['next_chapter_status'=>0,'next_price'=>0];
|
|
|
+ }
|
|
|
+
|
|
|
+ $is_paid = $this->getOrderRecord($bid,$cid);
|
|
|
+ if($is_paid){
|
|
|
+ return ['next_chapter_status'=>1,'next_price'=>0];
|
|
|
+ }
|
|
|
+ $fee = $this->getPrice($this->book_info, $chapter->size);
|
|
|
+ return ['next_chapter_status'=>2,'next_price'=>$fee];
|
|
|
+ }
|
|
|
+
|
|
|
//短续长
|
|
|
private function userBookCombination($chapter){
|
|
|
if($chapter->prev_cid && $chapter->next_cid){
|
|
@@ -605,7 +710,7 @@ class ChapterController extends BaseController
|
|
|
$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);
|
|
|
+ //\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);
|
|
@@ -687,28 +792,65 @@ class ChapterController extends BaseController
|
|
|
//加桌类型
|
|
|
private function addDesktopType($bid, $sequence)
|
|
|
{
|
|
|
- $force_add_desk_type = 0;
|
|
|
- \log::info('force_add_desk_log:uid:'.$this->uid);
|
|
|
- $send_order_id = ReadRecordService::getSendOrderId($this->uid);
|
|
|
- if (!$send_order_id) return $force_add_desk_type;
|
|
|
- \log::info('force_add_desk_log:send_order_id:'.$send_order_id);
|
|
|
- $send_order_info = SendOrderService::getById($send_order_id);
|
|
|
- if (!$send_order_info) return $force_add_desk_type;
|
|
|
- \log::info('force_add_desk_log:book_id:'.$send_order_info->book_id.' bid:'.$bid.' sequence:'.$sequence);
|
|
|
- if ($send_order_info->book_id == $bid) {
|
|
|
- \log::info(' force_add_desk_type:'.$send_order_info->force_add_desk_type);
|
|
|
- if ($send_order_info->force_add_desk_type == 1 && $send_order_info->force_add_desk_seq) {
|
|
|
- \log::info('force_add_desk_seq:'.$send_order_info->force_add_desk_seq);
|
|
|
- if ($sequence >= $send_order_info->force_add_desk_seq) {
|
|
|
- $force_add_desk_type = $send_order_info->force_add_desk_type;
|
|
|
+ $deault_force_add_desk_type = 0;
|
|
|
+ $send_order_id = $this->GetBindSendOrderId($this->uid);
|
|
|
+ if ($send_order_id) {
|
|
|
+ $send_order_info = SendOrderService::getById($send_order_id);
|
|
|
+ if (!$send_order_info) return $deault_force_add_desk_type;
|
|
|
+ if ($send_order_info->book_id == $bid) {
|
|
|
+ // 派单书籍和观看书籍一致,并设置了强加桌,判断当前章节和设置的强加桌章节
|
|
|
+ if ($send_order_info->force_add_desk_type == 1 && $send_order_info->force_add_desk_seq) {
|
|
|
+ //在设置的强加桌章节前一章开始
|
|
|
+ if ($sequence >= ($send_order_info->force_add_desk_seq - 1) ) {
|
|
|
+ $force_add_desk_type = $send_order_info->force_add_desk_type;
|
|
|
+ return $force_add_desk_type;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
- if ($send_order_info->force_add_desk_type == 2) {
|
|
|
- if ($sequence >= $this->book_info->force_subscribe_chapter_seq && $sequence <= $this->book_info->force_subscribe_chapter_seq + 3) {
|
|
|
- $force_add_desk_type = $send_order_info->force_add_desk_type;
|
|
|
+ if ($send_order_info->force_add_desk_type == 2) {
|
|
|
+ if ($sequence >= $this->book_info->force_subscribe_chapter_seq && $sequence <= $this->book_info->force_subscribe_chapter_seq + 3) {
|
|
|
+ $force_add_desk_type = $send_order_info->force_add_desk_type;
|
|
|
+ return $force_add_desk_type;
|
|
|
+ }
|
|
|
}
|
|
|
+ return $deault_force_add_desk_type;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //无派单,或者派单书籍与 此次书籍不一致,直接使用 原书籍的默认强关章节
|
|
|
+ $book_info = BookConfigService::getBookById($bid);
|
|
|
+ if ($book_info && $book_info->force_subscribe_chapter_seq) {
|
|
|
+ if ($sequence >= ($book_info->force_subscribe_chapter_seq - 1) ) {
|
|
|
+ return 1;
|
|
|
}
|
|
|
}
|
|
|
- return $force_add_desk_type;
|
|
|
+ return $deault_force_add_desk_type;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * [bindSendOrderId description]
|
|
|
+ * @param [type] $uid [description]
|
|
|
+ * @param [type] $send_order_id [description]
|
|
|
+ * @return [type] [description]
|
|
|
+ */
|
|
|
+ public function bindSendOrderId($uid, $send_order_id)
|
|
|
+ {
|
|
|
+ if ($send_order_id) {
|
|
|
+ $res = Redis::hset('book_read_chapter:' . $uid,'send_order_id', $send_order_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * [bindSendOrderId description]
|
|
|
+ * @param [type] $uid [description]
|
|
|
+ * @param [type] $send_order_id [description]
|
|
|
+ * @return [type] [description]
|
|
|
+ */
|
|
|
+ public function GetBindSendOrderId($uid)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $send_order_id = Redis::hget('book_read_chapter:' . $uid, 'send_order_id');
|
|
|
+ if ($send_order_id)
|
|
|
+ return (int)$send_order_id;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ }
|
|
|
}
|
|
|
}
|