|
@@ -32,8 +32,8 @@ class ChapterController extends BaseController
|
|
|
|
|
|
public function getCatalog(Request $request, $bid)
|
|
public function getCatalog(Request $request, $bid)
|
|
{
|
|
{
|
|
- $bid = BookService::decodeBidStatic($bid);
|
|
|
|
- $lists = ChapterService::getChapterLists($bid);
|
|
|
|
|
|
+ $bid = BookService::decodeBidStatic($bid);
|
|
|
|
+ $lists = ChapterService::getChapterLists($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
if (!$book_info) {
|
|
if (!$book_info) {
|
|
return response()->error('PARAM_ERROR');
|
|
return response()->error('PARAM_ERROR');
|
|
@@ -45,7 +45,7 @@ class ChapterController extends BaseController
|
|
|
|
|
|
public function getCatalogPerPage(Request $request, $bid)
|
|
public function getCatalogPerPage(Request $request, $bid)
|
|
{
|
|
{
|
|
- $bid = BookService::decodeBidStatic($bid);
|
|
|
|
|
|
+ $bid = BookService::decodeBidStatic($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
if (!$book_info) {
|
|
if (!$book_info) {
|
|
return response()->error('PARAM_ERROR');
|
|
return response()->error('PARAM_ERROR');
|
|
@@ -57,7 +57,7 @@ class ChapterController extends BaseController
|
|
if ($page_size >= 20) $page_size = 20;
|
|
if ($page_size >= 20) $page_size = 20;
|
|
|
|
|
|
// $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);
|
|
|
|
|
|
@@ -71,53 +71,53 @@ class ChapterController extends BaseController
|
|
|
|
|
|
//渠道自定义vip章节
|
|
//渠道自定义vip章节
|
|
//$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
|
|
//$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
|
|
- $vip_sequence = BookService::getVipSequence($bid,$this->distribution_channel_id,$this->send_order_id);
|
|
|
|
- list($is_split,$is_change_chapter_name) = BookService::splitContent($bid);
|
|
|
|
|
|
+ $vip_sequence = BookService::getVipSequence($bid, $this->distribution_channel_id, $this->send_order_id);
|
|
|
|
+ list($is_split, $is_change_chapter_name) = BookService::splitContent($bid);
|
|
$change_chapter_name = 0;
|
|
$change_chapter_name = 0;
|
|
- 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();
|
|
$account = $this->getAccount();
|
|
switch ($book_info->charge_type) {
|
|
switch ($book_info->charge_type) {
|
|
case 'BOOK':
|
|
case 'BOOK':
|
|
- $price = $this->getPriceNew($book_info,0, $account);
|
|
|
|
|
|
+ $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;
|
|
$v->next_price = 0;
|
|
$v->next_price = 0;
|
|
$v->is_need_charge = $v->is_vip ? $is_need_charge : false;
|
|
$v->is_need_charge = $v->is_vip ? $is_need_charge : false;
|
|
- $v->price = $price;
|
|
|
|
|
|
+ $v->price = $price;
|
|
|
|
|
|
// 限免判断
|
|
// 限免判断
|
|
if ($isFree) {
|
|
if ($isFree) {
|
|
$v->is_need_charge = false;
|
|
$v->is_need_charge = false;
|
|
- $v->price = 0;
|
|
|
|
|
|
+ $v->price = 0;
|
|
}
|
|
}
|
|
- if($vip_sequence){
|
|
|
|
- if($v->sequence >= $vip_sequence){
|
|
|
|
|
|
+ if ($vip_sequence) {
|
|
|
|
+ if ($v->sequence >= $vip_sequence) {
|
|
$v->is_vip = 1;
|
|
$v->is_vip = 1;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$v->is_vip = 0;
|
|
$v->is_vip = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//拆章
|
|
//拆章
|
|
- if($change_chapter_name){
|
|
|
|
- $v->name = '第'.$v->sequence.'章';
|
|
|
|
|
|
+ if ($change_chapter_name) {
|
|
|
|
+ $v->name = '第' . $v->sequence . '章';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
$chapterIds = $this->getChapterIds($chapters);
|
|
$chapterIds = $this->getChapterIds($chapters);
|
|
- $rules = ['check' => 0,'paycid' => []];
|
|
|
|
- if (!$isFree && !empty($chapterIds)){
|
|
|
|
- $rules = $this->getHandelData($bid,$chapterIds);
|
|
|
|
|
|
+ $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($v->sequence >= $vip_sequence){
|
|
|
|
|
|
+ if ($vip_sequence) {
|
|
|
|
+ if ($v->sequence >= $vip_sequence) {
|
|
$v->is_vip = 1;
|
|
$v->is_vip = 1;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$v->is_vip = 0;
|
|
$v->is_vip = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -125,10 +125,10 @@ class ChapterController extends BaseController
|
|
// 限免判断
|
|
// 限免判断
|
|
if ($isFree) {
|
|
if ($isFree) {
|
|
$v->is_need_charge = false;
|
|
$v->is_need_charge = false;
|
|
- $v->price = 0;
|
|
|
|
|
|
+ $v->price = 0;
|
|
} else {
|
|
} else {
|
|
- $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->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;
|
|
@@ -143,12 +143,12 @@ class ChapterController extends BaseController
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
// }
|
|
- $v->next_chapter_status = $this->isSubscribe($v->id,$rules);
|
|
|
|
|
|
+ $v->next_chapter_status = $this->isSubscribe($v->id, $rules);
|
|
$v->next_price = $v->price;
|
|
$v->next_price = $v->price;
|
|
|
|
|
|
//拆章
|
|
//拆章
|
|
- if($change_chapter_name){
|
|
|
|
- $v->name = '第'.$v->sequence.'章';
|
|
|
|
|
|
+ if ($change_chapter_name) {
|
|
|
|
+ $v->name = '第' . $v->sequence . '章';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -163,46 +163,46 @@ class ChapterController extends BaseController
|
|
|
|
|
|
//渠道自定义vip章节
|
|
//渠道自定义vip章节
|
|
//$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
|
|
//$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
|
|
- $vip_sequence = BookService::getVipSequence($bid,$this->distribution_channel_id,$this->send_order_id);
|
|
|
|
- list($is_split,$is_change_chapter_name) = BookService::splitContent($bid);
|
|
|
|
|
|
+ $vip_sequence = BookService::getVipSequence($bid, $this->distribution_channel_id, $this->send_order_id);
|
|
|
|
+ list($is_split, $is_change_chapter_name) = BookService::splitContent($bid);
|
|
$change_chapter_name = 0;
|
|
$change_chapter_name = 0;
|
|
- 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;
|
|
}
|
|
}
|
|
switch ($book_info->charge_type) {
|
|
switch ($book_info->charge_type) {
|
|
case 'BOOK':
|
|
case 'BOOK':
|
|
- $price = $this->getPrice($book_info);
|
|
|
|
|
|
+ $price = $this->getPrice($book_info);
|
|
$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;
|
|
$v->next_price = 0;
|
|
$v->next_price = 0;
|
|
$v->is_need_charge = $v->is_vip ? $is_need_charge : false;
|
|
$v->is_need_charge = $v->is_vip ? $is_need_charge : false;
|
|
- $v->price = $price;
|
|
|
|
|
|
+ $v->price = $price;
|
|
|
|
|
|
// 限免判断
|
|
// 限免判断
|
|
if ($isFree) {
|
|
if ($isFree) {
|
|
$v->is_need_charge = false;
|
|
$v->is_need_charge = false;
|
|
- $v->price = 0;
|
|
|
|
|
|
+ $v->price = 0;
|
|
}
|
|
}
|
|
- if($vip_sequence){
|
|
|
|
- if($v->sequence >= $vip_sequence){
|
|
|
|
|
|
+ if ($vip_sequence) {
|
|
|
|
+ if ($v->sequence >= $vip_sequence) {
|
|
$v->is_vip = 1;
|
|
$v->is_vip = 1;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$v->is_vip = 0;
|
|
$v->is_vip = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//拆章
|
|
//拆章
|
|
- if($change_chapter_name){
|
|
|
|
- $v->name = '第'.$v->sequence.'章';
|
|
|
|
|
|
+ if ($change_chapter_name) {
|
|
|
|
+ $v->name = '第' . $v->sequence . '章';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
foreach ($chapters as $v) {
|
|
foreach ($chapters as $v) {
|
|
- if($vip_sequence){
|
|
|
|
- if($v->sequence >= $vip_sequence){
|
|
|
|
|
|
+ if ($vip_sequence) {
|
|
|
|
+ if ($v->sequence >= $vip_sequence) {
|
|
$v->is_vip = 1;
|
|
$v->is_vip = 1;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$v->is_vip = 0;
|
|
$v->is_vip = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -210,23 +210,23 @@ class ChapterController extends BaseController
|
|
// 限免判断
|
|
// 限免判断
|
|
if ($isFree) {
|
|
if ($isFree) {
|
|
$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->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->is_need_charge = $v->is_vip ? $this->isChapterNeedCharge($bid, $v->id, $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);
|
|
|
|
|
|
+ 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_chapter_status = $next_chapter_order_status['next_chapter_status'];
|
|
$v->next_price = $next_chapter_order_status['next_price'];
|
|
$v->next_price = $next_chapter_order_status['next_price'];
|
|
}
|
|
}
|
|
|
|
|
|
//拆章
|
|
//拆章
|
|
- if($change_chapter_name){
|
|
|
|
- $v->name = '第'.$v->sequence.'章';
|
|
|
|
|
|
+ if ($change_chapter_name) {
|
|
|
|
+ $v->name = '第' . $v->sequence . '章';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -236,62 +236,62 @@ class ChapterController extends BaseController
|
|
|
|
|
|
public function index(Request $request, $bid, $cid)
|
|
public function index(Request $request, $bid, $cid)
|
|
{
|
|
{
|
|
- $send_order_id = $request->header('send_order_id', '');
|
|
|
|
- $package = $request->header('x-package', '');
|
|
|
|
|
|
+ $send_order_id = $request->header('send_order_id', '');
|
|
|
|
+ $package = $request->header('x-package', '');
|
|
//每次绑定用户和派单的关系
|
|
//每次绑定用户和派单的关系
|
|
- $this->bindSendOrderId($this->uid,$send_order_id);
|
|
|
|
|
|
+ $this->bindSendOrderId($this->uid, $send_order_id);
|
|
$oldbid = $bid;
|
|
$oldbid = $bid;
|
|
- $bid = BookService::decodeBidStatic($bid);
|
|
|
|
|
|
+ $bid = BookService::decodeBidStatic($bid);
|
|
//获取图书信息
|
|
//获取图书信息
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
if (empty($book_info))
|
|
if (empty($book_info))
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
|
|
|
$this->book_info = $book_info;
|
|
$this->book_info = $book_info;
|
|
- $book_auth = BookConfigService::bookCopyright($bid,$this->distribution_channel_id);
|
|
|
|
|
|
+ $book_auth = BookConfigService::bookCopyright($bid, $this->distribution_channel_id);
|
|
|
|
|
|
- if($book_auth == 2){
|
|
|
|
|
|
+ if ($book_auth == 2) {
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
}
|
|
}
|
|
|
|
|
|
//yuyuedu、xinghe 快应用这两个cp的书屏蔽下 wutong,wutong2,wutong3下所有内容都不放快应用
|
|
//yuyuedu、xinghe 快应用这两个cp的书屏蔽下 wutong,wutong2,wutong3下所有内容都不放快应用
|
|
- if(in_array($book_info->cp_source,getHiddenCp($package)) && $book_auth != 1){
|
|
|
|
|
|
+ if (in_array($book_info->cp_source, getHiddenCp($package)) && $book_auth != 1) {
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
}
|
|
}
|
|
|
|
|
|
- if($this->distribution_channel_id == 7477 && $bid == 13765){
|
|
|
|
|
|
+ if ($this->distribution_channel_id == 7477 && $bid == 13765) {
|
|
$book_info->is_on_shelf = 2;
|
|
$book_info->is_on_shelf = 2;
|
|
}
|
|
}
|
|
$special = get_special_bid();
|
|
$special = get_special_bid();
|
|
- if (in_array($this->distribution_channel_id,[9487,9390]) && in_array($book_info->bid,$special)){
|
|
|
|
|
|
+ if (in_array($this->distribution_channel_id, [9487, 9390]) && in_array($book_info->bid, $special)) {
|
|
$book_info->is_on_shelf = 2;
|
|
$book_info->is_on_shelf = 2;
|
|
}
|
|
}
|
|
|
|
|
|
- if($bid == 58886){
|
|
|
|
|
|
+ if ($bid == 58886) {
|
|
$book_info->is_on_shelf = 0;
|
|
$book_info->is_on_shelf = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!in_array($book_info->is_on_shelf, [1,2])) {
|
|
|
|
|
|
+ if (!in_array($book_info->is_on_shelf, [1, 2])) {
|
|
if ($book_info->is_on_shelf != 4) {
|
|
if ($book_info->is_on_shelf != 4) {
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
}
|
|
}
|
|
//补充操作:如果该用户未订阅该下架的书籍则删除其阅读记录(书架不予显示)
|
|
//补充操作:如果该用户未订阅该下架的书籍则删除其阅读记录(书架不予显示)
|
|
//判断是否属于包年用户
|
|
//判断是否属于包年用户
|
|
$year_account = YearOrderService::getRecord($this->uid);
|
|
$year_account = YearOrderService::getRecord($this->uid);
|
|
- if(!$year_account){
|
|
|
|
|
|
+ if (!$year_account) {
|
|
//获取书籍充值类型
|
|
//获取书籍充值类型
|
|
$charge_type = $book_info->charge_type;
|
|
$charge_type = $book_info->charge_type;
|
|
- if($charge_type == 'BOOK'){
|
|
|
|
|
|
+ if ($charge_type == 'BOOK') {
|
|
//是否购买过该书,购买过则不删除
|
|
//是否购买过该书,购买过则不删除
|
|
- $res = BookOrderService::getRecordByuidBid($this->uid,$bid);
|
|
|
|
- }elseif($charge_type == 'CHAPTER'){
|
|
|
|
|
|
+ $res = BookOrderService::getRecordByuidBid($this->uid, $bid);
|
|
|
|
+ } elseif ($charge_type == 'CHAPTER') {
|
|
//是否购买过该书章节,购买过则不删除
|
|
//是否购买过该书章节,购买过则不删除
|
|
- $res = ChapterOrderService::checkBookIsOrdered($this->uid,$bid);
|
|
|
|
- }else{
|
|
|
|
|
|
+ $res = ChapterOrderService::checkBookIsOrdered($this->uid, $bid);
|
|
|
|
+ } else {
|
|
$res = false;
|
|
$res = false;
|
|
}
|
|
}
|
|
if (!$res) {
|
|
if (!$res) {
|
|
- ReadRecordService::delReadRecordStatic($this->uid,[$bid]);
|
|
|
|
|
|
+ ReadRecordService::delReadRecordStatic($this->uid, [$bid]);
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
return response()->error('QAPP_OFF_SHELF');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -299,9 +299,9 @@ class ChapterController extends BaseController
|
|
|
|
|
|
//wutong,wutong2,wutong3下所有内容都不放快应用
|
|
//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;
|
|
$this->book_info = $book_info;
|
|
//获取章节信息
|
|
//获取章节信息
|
|
@@ -309,21 +309,21 @@ class ChapterController extends BaseController
|
|
|
|
|
|
if (!$chapter) {
|
|
if (!$chapter) {
|
|
//短推长
|
|
//短推长
|
|
- $combination_chapter = $this->chapterNotExists($bid,$cid);
|
|
|
|
- if($combination_chapter){
|
|
|
|
|
|
+ $combination_chapter = $this->chapterNotExists($bid, $cid);
|
|
|
|
+ if ($combination_chapter) {
|
|
$chapter = $combination_chapter;
|
|
$chapter = $combination_chapter;
|
|
$bid = $chapter->bid;
|
|
$bid = $chapter->bid;
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$oldbid = \Hashids::encode($bid);
|
|
$oldbid = \Hashids::encode($bid);
|
|
$this->book_info = $book_info;
|
|
$this->book_info = $book_info;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- list($is_split,$is_change_chapter_name) = BookService::splitContent($bid);
|
|
|
|
- if($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name) ){
|
|
|
|
- $chapter->name = '第'.$chapter->sequence.'章';
|
|
|
|
|
|
+ list($is_split, $is_change_chapter_name) = BookService::splitContent($bid);
|
|
|
|
+ if ($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name)) {
|
|
|
|
+ $chapter->name = '第' . $chapter->sequence . '章';
|
|
}
|
|
}
|
|
|
|
|
|
$is_next_day = date('Y-m-d', strtotime($this->user_info->created_at)) == date('Y-m-d', strtotime('-1 days'));
|
|
$is_next_day = date('Y-m-d', strtotime($this->user_info->created_at)) == date('Y-m-d', strtotime('-1 days'));
|
|
@@ -333,11 +333,11 @@ class ChapterController extends BaseController
|
|
}
|
|
}
|
|
//自定义vip章节
|
|
//自定义vip章节
|
|
//$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
|
|
//$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
|
|
- $vip_sequence = BookService::getVipSequence($bid,$this->distribution_channel_id,$this->send_order_id);
|
|
|
|
- if($vip_sequence){
|
|
|
|
- if($chapter->sequence >= $vip_sequence){
|
|
|
|
|
|
+ $vip_sequence = BookService::getVipSequence($bid, $this->distribution_channel_id, $this->send_order_id);
|
|
|
|
+ if ($vip_sequence) {
|
|
|
|
+ if ($chapter->sequence >= $vip_sequence) {
|
|
$chapter->is_vip = 1;
|
|
$chapter->is_vip = 1;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$chapter->is_vip = 0;
|
|
$chapter->is_vip = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -374,12 +374,12 @@ class ChapterController extends BaseController
|
|
'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
|
|
'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
|
|
]);
|
|
]);
|
|
if ($chapter->is_vip == 1) {
|
|
if ($chapter->is_vip == 1) {
|
|
- $fee = $this->getPrice($book_info, $chapter->size);
|
|
|
|
|
|
+ $fee = $this->getPrice($book_info, $chapter->size);
|
|
$now = date('Y-m-d');
|
|
$now = date('Y-m-d');
|
|
Redis::hincrby('qapp:book:free:virtual:' . $free->id, $now, $fee);
|
|
Redis::hincrby('qapp:book:free:virtual:' . $free->id, $now, $fee);
|
|
Redis::sadd('qapp:free:virtual' . $now, $free->id);
|
|
Redis::sadd('qapp:free:virtual' . $now, $free->id);
|
|
- Redis::sadd('qapp:free:virtual:uids'.$now.$free->id,$this->uid);
|
|
|
|
- Redis::sadd('qapp:free:virtual:uids'.$free->id,$this->uid);
|
|
|
|
|
|
+ Redis::sadd('qapp:free:virtual:uids' . $now . $free->id, $this->uid);
|
|
|
|
+ Redis::sadd('qapp:free:virtual:uids' . $free->id, $this->uid);
|
|
}
|
|
}
|
|
return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
}
|
|
}
|
|
@@ -406,21 +406,21 @@ class ChapterController extends BaseController
|
|
//未付费 要提醒
|
|
//未付费 要提醒
|
|
$user_info = $this->user_info;
|
|
$user_info = $this->user_info;
|
|
//未付费 余额不足
|
|
//未付费 余额不足
|
|
- $fee = $this->getPrice($book_info, $chapter->size);
|
|
|
|
|
|
+ $fee = $this->getPrice($book_info, $chapter->size);
|
|
$data = [
|
|
$data = [
|
|
- 'book_id' => $oldbid,
|
|
|
|
- 'book_name' => $book_info->book_name,
|
|
|
|
- 'chapter_name' => $chapter->name,
|
|
|
|
- 'chapter_id' => $cid,
|
|
|
|
- 'pay_type' => $book_info->charge_type,
|
|
|
|
- 'fee' => $fee,
|
|
|
|
- 'user_balance' => $user_info->balance,
|
|
|
|
- 'product_id' => $book_info->product_id,
|
|
|
|
- 'uid' => $this->uid,
|
|
|
|
|
|
+ 'book_id' => $oldbid,
|
|
|
|
+ 'book_name' => $book_info->book_name,
|
|
|
|
+ 'chapter_name' => $chapter->name,
|
|
|
|
+ 'chapter_id' => $cid,
|
|
|
|
+ 'pay_type' => $book_info->charge_type,
|
|
|
|
+ 'fee' => $fee,
|
|
|
|
+ 'user_balance' => $user_info->balance,
|
|
|
|
+ 'product_id' => $book_info->product_id,
|
|
|
|
+ 'uid' => $this->uid,
|
|
'distribution_channel_id' => $this->distribution_channel_id,
|
|
'distribution_channel_id' => $this->distribution_channel_id,
|
|
- 'is_discount' => 0,
|
|
|
|
- 'discount_fee' => '',
|
|
|
|
- 'discount' => ''
|
|
|
|
|
|
+ 'is_discount' => 0,
|
|
|
|
+ 'discount_fee' => '',
|
|
|
|
+ 'discount' => ''
|
|
|
|
|
|
];
|
|
];
|
|
|
|
|
|
@@ -433,8 +433,8 @@ class ChapterController extends BaseController
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!$this->send_order_id){
|
|
|
|
- if($book_info->charge_type == 'BOOK'){
|
|
|
|
|
|
+ if (!$this->send_order_id) {
|
|
|
|
+ if ($book_info->charge_type == 'BOOK') {
|
|
return response()->error('QAPP_BOOK_BUY', $data);
|
|
return response()->error('QAPP_BOOK_BUY', $data);
|
|
}/*else{
|
|
}/*else{
|
|
return response()->error('QAPP_CHAPTER_BUY', $data);
|
|
return response()->error('QAPP_CHAPTER_BUY', $data);
|
|
@@ -458,17 +458,17 @@ class ChapterController extends BaseController
|
|
]);
|
|
]);
|
|
//限免统计
|
|
//限免统计
|
|
$free_book = BookConfigService::getByBidNoFilter($bid);
|
|
$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)){
|
|
|
|
|
|
+ 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');
|
|
$now = date('Y-m-d');
|
|
Redis::hincrby('qapp:book:free:actuality:' . $free_book->id, $now, $fee);
|
|
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' . $now, $free_book->id);
|
|
- Redis::sadd('qapp:free:actuality:uids'.$now.$free_book->id,$this->uid);
|
|
|
|
|
|
+ Redis::sadd('qapp:free:actuality:uids' . $now . $free_book->id, $this->uid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if($this->uid == 247081369){
|
|
|
|
|
|
+ if ($this->uid == 247081369) {
|
|
$item = itemTransform(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
$item = itemTransform(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
myLog('xueqi')->info($item);
|
|
myLog('xueqi')->info($item);
|
|
}
|
|
}
|
|
@@ -487,13 +487,13 @@ class ChapterController extends BaseController
|
|
|
|
|
|
public function pay(Request $request, $bid, $cid)
|
|
public function pay(Request $request, $bid, $cid)
|
|
{
|
|
{
|
|
- $remind = (int)$request->input('remind');
|
|
|
|
- $oldbid = $bid;
|
|
|
|
- $bid = BookService::decodeBidStatic($bid);
|
|
|
|
|
|
+ $remind = (int)$request->input('remind');
|
|
|
|
+ $oldbid = $bid;
|
|
|
|
+ $bid = BookService::decodeBidStatic($bid);
|
|
$book_info = BookConfigService::getBookById($bid);;
|
|
$book_info = BookConfigService::getBookById($bid);;
|
|
if (empty($book_info)) response()->error('QAPP_SYS_ERROR');
|
|
if (empty($book_info)) response()->error('QAPP_SYS_ERROR');
|
|
$this->book_info = $book_info;
|
|
$this->book_info = $book_info;
|
|
- if($this->distribution_channel_id == 7477 && $bid == 13765){
|
|
|
|
|
|
+ if ($this->distribution_channel_id == 7477 && $bid == 13765) {
|
|
$book_info->is_on_shelf = 2;
|
|
$book_info->is_on_shelf = 2;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -505,14 +505,14 @@ class ChapterController extends BaseController
|
|
//获取章节
|
|
//获取章节
|
|
$chapter = ChapterService::getChapterNameById($cid, $bid);
|
|
$chapter = ChapterService::getChapterNameById($cid, $bid);
|
|
if (!$chapter) {
|
|
if (!$chapter) {
|
|
- $combination_chapter = $this->chapterNotExists($bid,$cid);
|
|
|
|
- if($combination_chapter){
|
|
|
|
|
|
+ $combination_chapter = $this->chapterNotExists($bid, $cid);
|
|
|
|
+ if ($combination_chapter) {
|
|
$chapter = $combination_chapter;
|
|
$chapter = $combination_chapter;
|
|
$bid = $chapter->bid;
|
|
$bid = $chapter->bid;
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$oldbid = \Hashids::encode($bid);
|
|
$oldbid = \Hashids::encode($bid);
|
|
$this->book_info = $book_info;
|
|
$this->book_info = $book_info;
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -550,14 +550,14 @@ class ChapterController extends BaseController
|
|
'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
|
|
'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
|
|
]);
|
|
]);
|
|
$free_book = BookConfigService::getByBidNoFilter($bid);
|
|
$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)){
|
|
|
|
|
|
+ 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');
|
|
$now = date('Y-m-d');
|
|
- $fee = $this->getPrice($book_info, $chapter->size);
|
|
|
|
|
|
+ $fee = $this->getPrice($book_info, $chapter->size);
|
|
Redis::hincrby('qapp:book:free:actuality:' . $free_book->id, $now, $fee);
|
|
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' . $now, $free_book->id);
|
|
- Redis::sadd('qapp:free:actuality:uids'.$now.$free_book->id,$this->uid);
|
|
|
|
|
|
+ Redis::sadd('qapp:free:actuality:uids' . $now . $free_book->id, $this->uid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -567,19 +567,19 @@ class ChapterController extends BaseController
|
|
$fee = $this->getPrice($book_info, $chapter->size);
|
|
$fee = $this->getPrice($book_info, $chapter->size);
|
|
|
|
|
|
$data = [
|
|
$data = [
|
|
- 'book_id' => $oldbid,
|
|
|
|
- 'book_name' => $book_info->book_name,
|
|
|
|
- 'chapter_name' => $chapter->name,
|
|
|
|
- 'chapter_id' => $cid,
|
|
|
|
- 'pay_type' => $book_info->charge_type,
|
|
|
|
- 'fee' => $fee,
|
|
|
|
- 'user_balance' => $this->user_info['balance'],
|
|
|
|
- 'product_id' => $book_info->product_id,
|
|
|
|
- 'uid' => $this->uid,
|
|
|
|
|
|
+ 'book_id' => $oldbid,
|
|
|
|
+ 'book_name' => $book_info->book_name,
|
|
|
|
+ 'chapter_name' => $chapter->name,
|
|
|
|
+ 'chapter_id' => $cid,
|
|
|
|
+ 'pay_type' => $book_info->charge_type,
|
|
|
|
+ 'fee' => $fee,
|
|
|
|
+ 'user_balance' => $this->user_info['balance'],
|
|
|
|
+ 'product_id' => $book_info->product_id,
|
|
|
|
+ 'uid' => $this->uid,
|
|
'distribution_channel_id' => $this->distribution_channel_id,
|
|
'distribution_channel_id' => $this->distribution_channel_id,
|
|
- 'is_discount' => 0,
|
|
|
|
- 'discount_fee' => '',
|
|
|
|
- 'discount' => ''
|
|
|
|
|
|
+ 'is_discount' => 0,
|
|
|
|
+ 'discount_fee' => '',
|
|
|
|
+ 'discount' => ''
|
|
];
|
|
];
|
|
if ($book_info->charge_type == 'BOOK') {
|
|
if ($book_info->charge_type == 'BOOK') {
|
|
return response()->error('QAPP_BOOK_INSUFFICIENT_BALANCE', $data);
|
|
return response()->error('QAPP_BOOK_INSUFFICIENT_BALANCE', $data);
|
|
@@ -625,27 +625,34 @@ class ChapterController extends BaseController
|
|
if (!$chapter_content) return false;
|
|
if (!$chapter_content) return false;
|
|
$chapter->content = trim(str_replace($chapter_content->name, '', $chapter_content->content));
|
|
$chapter->content = trim(str_replace($chapter_content->name, '', $chapter_content->content));
|
|
// 格式特殊处理
|
|
// 格式特殊处理
|
|
- $qian=array(" "," ","\t");
|
|
|
|
- $hou=array("","","");
|
|
|
|
|
|
+ $qian = array(" ", " ", "\t");
|
|
|
|
+ $hou = array("", "", "");
|
|
// 去掉所有空格
|
|
// 去掉所有空格
|
|
- $chapter->content = str_replace($qian,$hou,$chapter->content);
|
|
|
|
|
|
+ $chapter->content = str_replace($qian, $hou, $chapter->content);
|
|
// 2换行变1换行
|
|
// 2换行变1换行
|
|
$chapter->content = str_replace("\n\n", "\n", $chapter->content);
|
|
$chapter->content = str_replace("\n\n", "\n", $chapter->content);
|
|
$chapter->content = str_replace("\r\n\r\n", "\r\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);
|
|
|
|
|
|
+
|
|
|
|
+ // \Log::info('getChapter_chapter:'.$bid.' cid:'.$cid);
|
|
|
|
+ // \Log::info($chapter->content);
|
|
//统计点击率
|
|
//统计点击率
|
|
- $key = 'book_click_num_bid_' . $bid;
|
|
|
|
|
|
+ $key = 'book_click_num_bid_' . $bid;
|
|
$field = date('Y-m-d');
|
|
$field = date('Y-m-d');
|
|
- $old = Redis::hget($key, $field);
|
|
|
|
|
|
+ $old = Redis::hget($key, $field);
|
|
if (!$old) $old = 0;
|
|
if (!$old) $old = 0;
|
|
Redis::hset($key, $field, $old + 1);
|
|
Redis::hset($key, $field, $old + 1);
|
|
- $force_add_desk_type = $this->addDesktopType($bid, $chapter->sequence);
|
|
|
|
|
|
+ [$force_add_desk_type,$is_need_query_send_order] = $this->addDesktopType($bid, $chapter->sequence);
|
|
$chapter->force_add_desk_type = $force_add_desk_type;
|
|
$chapter->force_add_desk_type = $force_add_desk_type;
|
|
|
|
+ $force_add_work_wecaht_type = 0;
|
|
|
|
+ $force_add_work_wecaht_url = "";
|
|
|
|
+ if($is_need_query_send_order){
|
|
|
|
+ [$force_add_work_wecaht_type, $force_add_work_wecaht_url] = $this->addWorkWechatType($chapter->sequence);
|
|
|
|
+ }
|
|
|
|
+ $chapter->force_add_work_wecaht_type = $force_add_work_wecaht_type;
|
|
|
|
+ $chapter->force_add_work_wecaht_url = $force_add_work_wecaht_url;
|
|
//统计
|
|
//统计
|
|
$this->stats();
|
|
$this->stats();
|
|
- $next_chapter_order_status = $this->nextChapterOrderStatus($bid,$chapter->next_cid);
|
|
|
|
|
|
+ $next_chapter_order_status = $this->nextChapterOrderStatus($bid, $chapter->next_cid);
|
|
$chapter->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
|
|
$chapter->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
|
|
$chapter->next_price = $next_chapter_order_status['next_price'];
|
|
$chapter->next_price = $next_chapter_order_status['next_price'];
|
|
$chapter->charge_type = $this->book_info->charge_type;
|
|
$chapter->charge_type = $this->book_info->charge_type;
|
|
@@ -654,62 +661,64 @@ class ChapterController extends BaseController
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private function nextChapterOrderStatus($bid,$cid){
|
|
|
|
|
|
+ private function nextChapterOrderStatus($bid, $cid)
|
|
|
|
+ {
|
|
$chapter = ChapterService::getChapterNameById($cid, $bid);
|
|
$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];
|
|
|
|
|
|
+ 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];
|
|
|
|
|
|
+ $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];
|
|
|
|
|
|
+ $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){
|
|
|
|
- return ;
|
|
|
|
|
|
+ private function userBookCombination($chapter)
|
|
|
|
+ {
|
|
|
|
+ if ($chapter->prev_cid && $chapter->next_cid) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- if($chapter->next_cid == 0 && $this->book_info->charge_type == 'BOOK'){
|
|
|
|
- $bid = UserBookCombinationConfigService::selectAndSave($this->uid,$this->book_info->bid);
|
|
|
|
- if($bid){
|
|
|
|
|
|
+ if ($chapter->next_cid == 0 && $this->book_info->charge_type == 'BOOK') {
|
|
|
|
+ $bid = UserBookCombinationConfigService::selectAndSave($this->uid, $this->book_info->bid);
|
|
|
|
+ if ($bid) {
|
|
$bookInfo = BookConfigService::getBookById($bid);
|
|
$bookInfo = BookConfigService::getBookById($bid);
|
|
$chapter->next_cid = $bookInfo->first_cid;
|
|
$chapter->next_cid = $bookInfo->first_cid;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if($chapter->prev_cid == 0 && $this->book_info->charge_type == 'CHAPTER'){
|
|
|
|
- $bid = UserBookCombinationConfigService::getShortBookFromLongBid($this->uid,$this->book_info->bid);
|
|
|
|
- if($bid){
|
|
|
|
|
|
+ if ($chapter->prev_cid == 0 && $this->book_info->charge_type == 'CHAPTER') {
|
|
|
|
+ $bid = UserBookCombinationConfigService::getShortBookFromLongBid($this->uid, $this->book_info->bid);
|
|
|
|
+ if ($bid) {
|
|
$bookInfo = BookConfigService::getBookById($bid);
|
|
$bookInfo = BookConfigService::getBookById($bid);
|
|
$chapter->prev_cid = $bookInfo->last_cid;
|
|
$chapter->prev_cid = $bookInfo->last_cid;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private function chapterNotExists($bid,$cid)
|
|
|
|
|
|
+ private function chapterNotExists($bid, $cid)
|
|
{
|
|
{
|
|
//1.全局图书组合配置
|
|
//1.全局图书组合配置
|
|
$combination = BookConfigService::getCombinationInfo($bid);
|
|
$combination = BookConfigService::getCombinationInfo($bid);
|
|
- if($combination){
|
|
|
|
|
|
+ if ($combination) {
|
|
$chapter = ChapterService::getChapterNameByIdNoCheck($cid);
|
|
$chapter = ChapterService::getChapterNameByIdNoCheck($cid);
|
|
- if($chapter){
|
|
|
|
|
|
+ if ($chapter) {
|
|
return $chapter;
|
|
return $chapter;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
//2.用户图书组合配置
|
|
//2.用户图书组合配置
|
|
- if($this->book_info->charge_type == 'CHAPTER'){
|
|
|
|
- $user_combination = UserBookCombinationConfigService::getShortBookFromLongBook($this->uid,$bid);
|
|
|
|
- }else{
|
|
|
|
- $user_combination = UserBookCombinationConfigService::getLongBookFromShortBook($this->uid,$bid);
|
|
|
|
|
|
+ if ($this->book_info->charge_type == 'CHAPTER') {
|
|
|
|
+ $user_combination = UserBookCombinationConfigService::getShortBookFromLongBook($this->uid, $bid);
|
|
|
|
+ } else {
|
|
|
|
+ $user_combination = UserBookCombinationConfigService::getLongBookFromShortBook($this->uid, $bid);
|
|
}
|
|
}
|
|
- if($user_combination){
|
|
|
|
|
|
+ if ($user_combination) {
|
|
$chapter = ChapterService::getChapterNameByIdNoCheck($cid);
|
|
$chapter = ChapterService::getChapterNameByIdNoCheck($cid);
|
|
- if($chapter){
|
|
|
|
|
|
+ if ($chapter) {
|
|
return $chapter;
|
|
return $chapter;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
@@ -730,26 +739,26 @@ class ChapterController extends BaseController
|
|
{
|
|
{
|
|
if ($book_info['charge_type'] == 'BOOK') {
|
|
if ($book_info['charge_type'] == 'BOOK') {
|
|
$data = [
|
|
$data = [
|
|
- 'uid' => $this->uid,
|
|
|
|
- 'fee' => $fee,
|
|
|
|
- 'u' => $this->send_order_id,
|
|
|
|
|
|
+ 'uid' => $this->uid,
|
|
|
|
+ 'fee' => $fee,
|
|
|
|
+ 'u' => $this->send_order_id,
|
|
'distribution_channel_id' => $this->distribution_channel_id,
|
|
'distribution_channel_id' => $this->distribution_channel_id,
|
|
- 'bid' => $book_info->bid,
|
|
|
|
- 'book_name' => $book_info->book_name,
|
|
|
|
- 'send_order_id' => $this->send_order_id,
|
|
|
|
|
|
+ 'bid' => $book_info->bid,
|
|
|
|
+ 'book_name' => $book_info->book_name,
|
|
|
|
+ 'send_order_id' => $this->send_order_id,
|
|
];
|
|
];
|
|
return BookOrderService::addOrderRecodeAndDecrUserBalance($data, $this->uid);
|
|
return BookOrderService::addOrderRecodeAndDecrUserBalance($data, $this->uid);
|
|
} else {
|
|
} else {
|
|
$data = [
|
|
$data = [
|
|
- 'uid' => $this->uid,
|
|
|
|
- 'fee' => $fee,
|
|
|
|
- 'cid' => $chapter_id,
|
|
|
|
- 'bid' => $book_info->bid,
|
|
|
|
|
|
+ 'uid' => $this->uid,
|
|
|
|
+ 'fee' => $fee,
|
|
|
|
+ 'cid' => $chapter_id,
|
|
|
|
+ 'bid' => $book_info->bid,
|
|
'distribution_channel_id' => $this->distribution_channel_id,
|
|
'distribution_channel_id' => $this->distribution_channel_id,
|
|
- 'book_name' => $book_info->book_name,
|
|
|
|
- 'chapter_name' => $chapter_name,
|
|
|
|
- 'send_order_id' => $this->send_order_id,
|
|
|
|
- 'is_remind' => $is_remind
|
|
|
|
|
|
+ 'book_name' => $book_info->book_name,
|
|
|
|
+ 'chapter_name' => $chapter_name,
|
|
|
|
+ 'send_order_id' => $this->send_order_id,
|
|
|
|
+ 'is_remind' => $is_remind
|
|
];
|
|
];
|
|
if ($is_remind) {
|
|
if ($is_remind) {
|
|
$this->addOrderRemind($book_info->bid);
|
|
$this->addOrderRemind($book_info->bid);
|
|
@@ -841,10 +850,10 @@ class ChapterController extends BaseController
|
|
// 获取投放后台账号,
|
|
// 获取投放后台账号,
|
|
$account = '';
|
|
$account = '';
|
|
$account_send_order = $this->getNowSendOrderInfo();
|
|
$account_send_order = $this->getNowSendOrderInfo();
|
|
- if($account_send_order){
|
|
|
|
- $account = isset($account_send_order['account'])?$account_send_order['account']:'';
|
|
|
|
|
|
+ if ($account_send_order) {
|
|
|
|
+ $account = isset($account_send_order['account']) ? $account_send_order['account'] : '';
|
|
}
|
|
}
|
|
- $fee = BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size,$account);
|
|
|
|
|
|
+ $fee = BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size, $account);
|
|
return $fee;
|
|
return $fee;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -855,7 +864,7 @@ class ChapterController extends BaseController
|
|
* @param $chapter_size
|
|
* @param $chapter_size
|
|
* @return float
|
|
* @return float
|
|
*/
|
|
*/
|
|
- private function getPriceNew($book_info, $chapter_size = 0,$account="")
|
|
|
|
|
|
+ private function getPriceNew($book_info, $chapter_size = 0, $account = "")
|
|
{
|
|
{
|
|
if ($book_info->charge_type == 'BOOK') {
|
|
if ($book_info->charge_type == 'BOOK') {
|
|
if (BookOrderService::isHasBookOrder($this->uid)) {
|
|
if (BookOrderService::isHasBookOrder($this->uid)) {
|
|
@@ -866,7 +875,7 @@ class ChapterController extends BaseController
|
|
return 899;
|
|
return 899;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- return BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size,$account);
|
|
|
|
|
|
+ return BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size, $account);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -876,12 +885,13 @@ class ChapterController extends BaseController
|
|
* @return mixed|string
|
|
* @return mixed|string
|
|
* date 2022/10/20 11:29
|
|
* date 2022/10/20 11:29
|
|
*/
|
|
*/
|
|
- protected function getAccount(){
|
|
|
|
|
|
+ protected function getAccount()
|
|
|
|
+ {
|
|
|
|
|
|
$account = '';
|
|
$account = '';
|
|
$account_send_order = $this->getNowSendOrderInfo();
|
|
$account_send_order = $this->getNowSendOrderInfo();
|
|
- if($account_send_order){
|
|
|
|
- $account = isset($account_send_order['account'])?$account_send_order['account']:'';
|
|
|
|
|
|
+ if ($account_send_order) {
|
|
|
|
+ $account = isset($account_send_order['account']) ? $account_send_order['account'] : '';
|
|
}
|
|
}
|
|
return $account;
|
|
return $account;
|
|
}
|
|
}
|
|
@@ -895,14 +905,14 @@ class ChapterController extends BaseController
|
|
if (!UserDeepReadTagService::isAddTag($this->uid, $book_info->bid)) {
|
|
if (!UserDeepReadTagService::isAddTag($this->uid, $book_info->bid)) {
|
|
try {
|
|
try {
|
|
UserDeepReadTagService::addTag([
|
|
UserDeepReadTagService::addTag([
|
|
- 'uid' => $this->uid,
|
|
|
|
- 'bid' => $book_info->bid,
|
|
|
|
- 'book_name' => $book_info->book_name,
|
|
|
|
- 'category_id' => $book_info->category_id,
|
|
|
|
- 'category_name' => $book_info->category_name,
|
|
|
|
- 'sex_preference' => $book_info->channel_name ? $book_info->channel_name : '',
|
|
|
|
|
|
+ 'uid' => $this->uid,
|
|
|
|
+ 'bid' => $book_info->bid,
|
|
|
|
+ 'book_name' => $book_info->book_name,
|
|
|
|
+ 'category_id' => $book_info->category_id,
|
|
|
|
+ 'category_name' => $book_info->category_name,
|
|
|
|
+ 'sex_preference' => $book_info->channel_name ? $book_info->channel_name : '',
|
|
'distribution_channel_id' => $this->distribution_channel_id ? $this->distribution_channel_id : '0',
|
|
'distribution_channel_id' => $this->distribution_channel_id ? $this->distribution_channel_id : '0',
|
|
- 'send_order_id' => $this->send_order_id,
|
|
|
|
|
|
+ 'send_order_id' => $this->send_order_id,
|
|
]);
|
|
]);
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
}
|
|
}
|
|
@@ -961,52 +971,72 @@ class ChapterController extends BaseController
|
|
{
|
|
{
|
|
$deault_force_add_desk_type = 0;
|
|
$deault_force_add_desk_type = 0;
|
|
$send_order_id = $this->GetBindSendOrderId($this->uid);
|
|
$send_order_id = $this->GetBindSendOrderId($this->uid);
|
|
|
|
+ $is_need_query_order = 0;
|
|
if ($send_order_id) {
|
|
if ($send_order_id) {
|
|
$send_order_info = SendOrderService::getById($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) return [$deault_force_add_desk_type,$is_need_query_order];
|
|
if ($send_order_info->book_id == $bid) {
|
|
if ($send_order_info->book_id == $bid) {
|
|
|
|
+ $is_need_query_order = 1;
|
|
// 派单书籍和观看书籍一致,并设置了强加桌,判断当前章节和设置的强加桌章节
|
|
// 派单书籍和观看书籍一致,并设置了强加桌,判断当前章节和设置的强加桌章节
|
|
if ($send_order_info->force_add_desk_type == 1 && $send_order_info->force_add_desk_seq) {
|
|
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) ) {
|
|
|
|
|
|
+ if ($sequence >= ($send_order_info->force_add_desk_seq - 1)) {
|
|
$force_add_desk_type = $send_order_info->force_add_desk_type;
|
|
$force_add_desk_type = $send_order_info->force_add_desk_type;
|
|
- return $force_add_desk_type;
|
|
|
|
|
|
+ return [$force_add_desk_type,$is_need_query_order];
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
if ($send_order_info->force_add_desk_type == 2) {
|
|
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) {
|
|
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;
|
|
$force_add_desk_type = $send_order_info->force_add_desk_type;
|
|
- return $force_add_desk_type;
|
|
|
|
|
|
+ return [$force_add_desk_type,$is_need_query_order];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if($send_order_info->force_add_desk_type == 3){
|
|
|
|
|
|
+ if ($send_order_info->force_add_desk_type == 3) {
|
|
//弱加桌+强加桌 ,即强加桌章节之前的章节均弱加桌,之后的章节显示强加桌:
|
|
//弱加桌+强加桌 ,即强加桌章节之前的章节均弱加桌,之后的章节显示强加桌:
|
|
$need_sequence = $send_order_info->force_add_desk_seq;
|
|
$need_sequence = $send_order_info->force_add_desk_seq;
|
|
- if(!$need_sequence){
|
|
|
|
|
|
+ if (!$need_sequence) {
|
|
$need_sequence = $this->book_info->force_subscribe_chapter_seq;
|
|
$need_sequence = $this->book_info->force_subscribe_chapter_seq;
|
|
}
|
|
}
|
|
- if( $sequence >= ( $need_sequence-1 ) ){
|
|
|
|
|
|
+ if ($sequence >= ($need_sequence - 1)) {
|
|
//之后的章节显示强加桌
|
|
//之后的章节显示强加桌
|
|
- return 1;
|
|
|
|
- }else{
|
|
|
|
|
|
+ return [1,$is_need_query_order];
|
|
|
|
+ } else {
|
|
////强加桌章节之前的章节均弱加桌
|
|
////强加桌章节之前的章节均弱加桌
|
|
- return 2;
|
|
|
|
|
|
+ return [2,$is_need_query_order];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return $deault_force_add_desk_type;
|
|
|
|
|
|
+ return [$deault_force_add_desk_type,$is_need_query_order];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//无派单,或者派单书籍与 此次书籍不一致,直接使用 原书籍的默认强关章节
|
|
//无派单,或者派单书籍与 此次书籍不一致,直接使用 原书籍的默认强关章节
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
if ($book_info && $book_info->force_subscribe_chapter_seq) {
|
|
if ($book_info && $book_info->force_subscribe_chapter_seq) {
|
|
- if ($sequence >= ($book_info->force_subscribe_chapter_seq - 1) ) {
|
|
|
|
- return 2;
|
|
|
|
|
|
+ if ($sequence >= ($book_info->force_subscribe_chapter_seq - 1)) {
|
|
|
|
+ return [2,$is_need_query_order];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return $deault_force_add_desk_type;
|
|
|
|
|
|
+ return [$deault_force_add_desk_type,$is_need_query_order];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private function addWorkWechatType($sequence)
|
|
|
|
+ {
|
|
|
|
+ $deault_force_add_desk_type = 0;
|
|
|
|
+ $work_wechat_url = "";
|
|
|
|
+ $send_order_id = $this->GetBindSendOrderId($this->uid);
|
|
|
|
+ if ($send_order_id) {
|
|
|
|
+ $send_order_info = QappSendOrder::getSendOrderById($send_order_id);
|
|
|
|
+ if (!$send_order_info) return [$deault_force_add_desk_type, $work_wechat_url];
|
|
|
|
+ if(in_array($send_order_info['force_add_work_wecaht_type'],[1,2]) && $send_order_info['force_add_work_wecaht_seq'] <= ($sequence+1)){
|
|
|
|
+ $deault_force_add_desk_type =$send_order_info['force_add_work_wecaht_type'];
|
|
|
|
+ $work_wechat_url =$send_order_info['force_add_work_wecaht_url'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return [$deault_force_add_desk_type, $work_wechat_url];
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* [bindSendOrderId description]
|
|
* [bindSendOrderId description]
|
|
* @param [type] $uid [description]
|
|
* @param [type] $uid [description]
|
|
@@ -1016,7 +1046,7 @@ class ChapterController extends BaseController
|
|
public function bindSendOrderId($uid, $send_order_id)
|
|
public function bindSendOrderId($uid, $send_order_id)
|
|
{
|
|
{
|
|
if ($send_order_id) {
|
|
if ($send_order_id) {
|
|
- $res = Redis::hset('book_read_chapter:' . $uid,'send_order_id', $send_order_id);
|
|
|
|
|
|
+ $res = Redis::hset('book_read_chapter:' . $uid, 'send_order_id', $send_order_id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1039,8 +1069,8 @@ class ChapterController extends BaseController
|
|
private function getChapterIds($chapters): array
|
|
private function getChapterIds($chapters): array
|
|
{
|
|
{
|
|
$list = [];
|
|
$list = [];
|
|
- if($chapters){
|
|
|
|
- foreach ($chapters as $v){
|
|
|
|
|
|
+ if ($chapters) {
|
|
|
|
+ foreach ($chapters as $v) {
|
|
$list[] = $v->id;
|
|
$list[] = $v->id;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1054,20 +1084,20 @@ class ChapterController extends BaseController
|
|
$uid = $this->uid;
|
|
$uid = $this->uid;
|
|
$res = YearOrderService::getRecord($uid);
|
|
$res = YearOrderService::getRecord($uid);
|
|
if ($res) {
|
|
if ($res) {
|
|
- return $handle = ['check' => 0,'paycid' => []];
|
|
|
|
|
|
+ return $handle = ['check' => 0, 'paycid' => []];
|
|
}
|
|
}
|
|
$res = null;
|
|
$res = null;
|
|
|
|
|
|
//单本订购记录
|
|
//单本订购记录
|
|
$res = BookOrderService::getRecordByuidBid($uid, $bid);
|
|
$res = BookOrderService::getRecordByuidBid($uid, $bid);
|
|
if ($res) {
|
|
if ($res) {
|
|
- return $handle = ['check' => 0,'paycid' => []];
|
|
|
|
|
|
+ return $handle = ['check' => 0, 'paycid' => []];
|
|
}
|
|
}
|
|
|
|
|
|
//章节订购记录
|
|
//章节订购记录
|
|
$chapterOrder = new ChapterOrderService();
|
|
$chapterOrder = new ChapterOrderService();
|
|
- $res = $chapterOrder->getOrdersByChapterIds($uid, $bid, $chapterIds);
|
|
|
|
- return $handle = ['check' => 1,'paycid' => $res];
|
|
|
|
|
|
+ $res = $chapterOrder->getOrdersByChapterIds($uid, $bid, $chapterIds);
|
|
|
|
+ return $handle = ['check' => 1, 'paycid' => $res];
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1078,17 +1108,17 @@ class ChapterController extends BaseController
|
|
* @return bool
|
|
* @return bool
|
|
* date 2022/10/20 16:08
|
|
* date 2022/10/20 16:08
|
|
*/
|
|
*/
|
|
- private function isChapterNeedChargeNew($cid,$rules,$price = 0): bool
|
|
|
|
|
|
+ private function isChapterNeedChargeNew($cid, $rules, $price = 0): bool
|
|
{
|
|
{
|
|
- if($rules['check'] != 1){
|
|
|
|
|
|
+ if ($rules['check'] != 1) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- if (empty($rules['paycid']) || !in_array($cid,$rules['paycid'])){
|
|
|
|
|
|
+ if (empty($rules['paycid']) || !in_array($cid, $rules['paycid'])) {
|
|
$user_info = $this->user_info;
|
|
$user_info = $this->user_info;
|
|
return $user_info['balance'] < $price;
|
|
return $user_info['balance'] < $price;
|
|
- }else{
|
|
|
|
- return false;
|
|
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1100,16 +1130,16 @@ class ChapterController extends BaseController
|
|
* @return int
|
|
* @return int
|
|
* date 2022/11/02 17:19
|
|
* date 2022/11/02 17:19
|
|
*/
|
|
*/
|
|
- private function isSubscribe($cid,$rules): int
|
|
|
|
|
|
+ private function isSubscribe($cid, $rules): int
|
|
{
|
|
{
|
|
- if($rules['check'] != 1){
|
|
|
|
|
|
+ if ($rules['check'] != 1) {
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
- if (empty($rules['paycid']) || !in_array($cid,$rules['paycid'])){
|
|
|
|
|
|
+ if (empty($rules['paycid']) || !in_array($cid, $rules['paycid'])) {
|
|
return 2;
|
|
return 2;
|
|
- }else{
|
|
|
|
- return 1;
|
|
|
|
|
|
+ } else {
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|