|
@@ -10,18 +10,16 @@ use App\Modules\User\Services\ReadRecordService;
|
|
|
use App\Http\Controllers\QuickApp\Book\Transformers\ChapterTransformer;
|
|
|
use App\Modules\Book\Services\BookConfigService;
|
|
|
use App\Http\Controllers\QuickApp\Book\Transformers\ChapterListTransformer;
|
|
|
+use App\Modules\Book\Services\BookService;
|
|
|
use App\Modules\Subscribe\Services\BookOrderService;
|
|
|
use App\Modules\Subscribe\Services\ChapterOrderService;
|
|
|
use App\Modules\Subscribe\Services\YearOrderService;
|
|
|
use App\Modules\OfficialAccount\Services\ForceSubscribeService;
|
|
|
use App\Modules\Subscribe\Services\ChapterReminderService;
|
|
|
-use App\Modules\OfficialAccount\Services\OfficialAccountService;
|
|
|
use Hashids;
|
|
|
-use GuzzleHttp\Client;
|
|
|
-use Log;
|
|
|
-use DB;
|
|
|
use App\Modules\User\Services\UserSignService;
|
|
|
use App\Modules\User\Services\UserDeepReadTagService;
|
|
|
+
|
|
|
class ChapterController extends BaseController
|
|
|
{
|
|
|
|
|
@@ -92,14 +90,11 @@ class ChapterController extends BaseController
|
|
|
* ]
|
|
|
* }
|
|
|
*/
|
|
|
- public function getCatalog(Request $request,$bid)
|
|
|
+ public function getCatalog(Request $request, $bid)
|
|
|
{
|
|
|
-
|
|
|
-// $bid = Hashids::decode($bid)[0];
|
|
|
+ $bid = BookService::decodeBidStatic($bid);
|
|
|
$lists = ChapterService::getChapterLists($bid);
|
|
|
-
|
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
|
-
|
|
|
if (!$book_info) {
|
|
|
return response()->error('PARAM_ERROR');
|
|
|
}
|
|
@@ -112,9 +107,9 @@ class ChapterController extends BaseController
|
|
|
$v->price = $this->getPrice($book_info, $v);
|
|
|
}
|
|
|
|
|
|
- if ($v->sequence==$book_info->force_subscribe_chapter_seq){
|
|
|
+ if ($v->sequence == $book_info->force_subscribe_chapter_seq) {
|
|
|
$v->is_need_subscirb = 1;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$v->is_need_subscirb = 0;
|
|
|
}
|
|
|
}
|
|
@@ -194,31 +189,16 @@ class ChapterController extends BaseController
|
|
|
* }
|
|
|
* }
|
|
|
*/
|
|
|
-// public function getCatalogPerPage(Request $request,$bid){
|
|
|
-// $bid = Hashids::decode($bid)[0];
|
|
|
-// $page_size = $request->input('page_size',15);
|
|
|
-// $res = ChapterService::getChapterListsPage($bid,$page_size);
|
|
|
-// return response()->pagination(new ChapterListTransformer,$res);
|
|
|
-// }
|
|
|
public function getCatalogPerPage(Request $request, $bid)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $bid_array = Hashids::decode($bid);
|
|
|
-// $bid_array = $bid;
|
|
|
- if (isset($bid_array[0])) {
|
|
|
- $bid = $bid_array[0];
|
|
|
- } else {
|
|
|
- return response()->error('PARAM_ERROR');
|
|
|
- }
|
|
|
+ $bid = BookService::decodeBidStatic($bid);
|
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
|
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;
|
|
|
+ if ($page_size >= 100) $page_size = 100;
|
|
|
$res = ChapterService::getChapterListsPage($bid, $page_size);
|
|
|
$is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
|
|
|
foreach ($res as $v) {
|
|
@@ -227,9 +207,9 @@ class ChapterController extends BaseController
|
|
|
if ($is_show_price) {
|
|
|
$v->price = $this->getPrice($book_info, $v);
|
|
|
}
|
|
|
- if ($v->sequence==$book_info->force_subscribe_chapter_seq){
|
|
|
+ if ($v->sequence == $book_info->force_subscribe_chapter_seq) {
|
|
|
$v->is_need_subscirb = 1;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$v->is_need_subscirb = 0;
|
|
|
}
|
|
|
}
|
|
@@ -277,119 +257,118 @@ class ChapterController extends BaseController
|
|
|
* }
|
|
|
* }
|
|
|
*/
|
|
|
- public function index(Request $request,$bid,$cid){
|
|
|
+ public function index(Request $request, $bid, $cid)
|
|
|
+ {
|
|
|
$oldbid = $bid;
|
|
|
- $bid = Hashids::decode($bid)[0];
|
|
|
//获取图书信息
|
|
|
$book_info = BookConfigService::getBookById($bid);
|
|
|
-
|
|
|
-
|
|
|
- if(empty($book_info)) return response()->error('QAPP_SYS_ERROR');
|
|
|
-
|
|
|
- if($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3){
|
|
|
- //return response()->error('QAPP_OFF_SHELF');
|
|
|
- }
|
|
|
+ if (empty($book_info)) return response()->error('QAPP_SYS_ERROR');
|
|
|
//获取章节信息
|
|
|
- $chapter = ChapterService::getChapterNameById($cid,$bid);
|
|
|
- if(!$chapter){
|
|
|
+ $chapter = ChapterService::getChapterNameById($cid, $bid);
|
|
|
+ if (!$chapter) {
|
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
}
|
|
|
|
|
|
- if($chapter->is_vip == 0){
|
|
|
- ReadRecordService::addReadRecord(['uid'=>$this->uid,'bid'=>$bid,'book_name'=>$book_info->book_name,
|
|
|
- 'cid'=>$cid,'chapter_name'=>$chapter->name ]);
|
|
|
+ if ($chapter->is_vip == 0) {
|
|
|
+ ReadRecordService::addReadRecord([
|
|
|
+ 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
|
|
|
+ 'cid' => $cid, 'chapter_name' => $chapter->name
|
|
|
+ ]);
|
|
|
//用户标签
|
|
|
- if($chapter->sequence >= 20){
|
|
|
+ if ($chapter->sequence >= 20) {
|
|
|
$this->addTag($book_info);
|
|
|
}
|
|
|
- return response()->item(new ChapterTransformer,$this->getChapter($bid,$cid,$chapter));
|
|
|
+ return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
|
}
|
|
|
|
|
|
//已经付费
|
|
|
- if($this->getOrderRecord($bid,$cid)){
|
|
|
- ReadRecordService::addReadRecord(['uid'=>$this->uid,'bid'=>$bid,'book_name'=>$book_info->book_name,
|
|
|
- 'cid'=>$cid,'chapter_name'=>$chapter->name ]);
|
|
|
+ if ($this->getOrderRecord($bid, $cid)) {
|
|
|
+ ReadRecordService::addReadRecord([
|
|
|
+ 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
|
|
|
+ 'cid' => $cid, 'chapter_name' => $chapter->name
|
|
|
+ ]);
|
|
|
//用户标签
|
|
|
- if($chapter->sequence >= 20){
|
|
|
+ if ($chapter->sequence >= 20) {
|
|
|
$this->addTag($book_info);
|
|
|
}
|
|
|
- return response()->item(new ChapterTransformer,$this->getChapter($bid,$cid,$chapter));
|
|
|
+ return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
|
}
|
|
|
|
|
|
//未付费 要提醒
|
|
|
$user_info = $this->_user_info;
|
|
|
//未付费 余额不足
|
|
|
- $fee = $this->getPrice($book_info,$chapter->size);
|
|
|
+ $fee = $this->getPrice($book_info, $chapter->size);
|
|
|
$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,
|
|
|
- 'distribution_channel_id'=>$this->distribution_channel_id,
|
|
|
- 'is_discount'=>0,
|
|
|
+ '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,
|
|
|
+ 'is_discount' => 0,
|
|
|
'discount_fee' => '',
|
|
|
- 'discount'=>''
|
|
|
+ 'discount' => ''
|
|
|
|
|
|
];
|
|
|
|
|
|
- if($user_info['balance'] < $fee){
|
|
|
+ if ($user_info['balance'] < $fee) {
|
|
|
//需要提箱
|
|
|
- if($this->isOrderRemind($bid)){
|
|
|
-
|
|
|
- if($book_info->charge_type == 'BOOK'){
|
|
|
- return response()->error('QAPP_BOOK_BALANCE_PAY',$data);
|
|
|
- }else
|
|
|
- if($book_info->charge_type == 'CHAPTER'){
|
|
|
- return response()->error('QAPP_CHAPTER_INSUFFICIENT_BALANCE',$data);
|
|
|
- }else{
|
|
|
- return response()->error('QAPP_SYS_ERROR');
|
|
|
- }
|
|
|
- }else{
|
|
|
+ if ($this->isOrderRemind($bid)) {
|
|
|
+
|
|
|
+ if ($book_info->charge_type == 'BOOK') {
|
|
|
+ return response()->error('QAPP_BOOK_BALANCE_PAY', $data);
|
|
|
+ } else
|
|
|
+ if ($book_info->charge_type == 'CHAPTER') {
|
|
|
+ return response()->error('QAPP_CHAPTER_INSUFFICIENT_BALANCE', $data);
|
|
|
+ } else {
|
|
|
+ return response()->error('QAPP_SYS_ERROR');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
//不需要提醒
|
|
|
- if($book_info->charge_type == 'BOOK'){
|
|
|
- return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY',$data);
|
|
|
- }elseif($book_info->charge_type == 'CHAPTER'){
|
|
|
- return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY',$data);
|
|
|
- }else{
|
|
|
+ if ($book_info->charge_type == 'BOOK') {
|
|
|
+ return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY', $data);
|
|
|
+ } elseif ($book_info->charge_type == 'CHAPTER') {
|
|
|
+ return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY', $data);
|
|
|
+ } else {
|
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if($this->isOrderRemind($bid)){
|
|
|
- //return response()->error('INSUFFICIENT_BALANCE',$data);
|
|
|
- if($book_info->charge_type == 'BOOK'){
|
|
|
- return response()->error('QAPP_BOOK_BUY',$data);
|
|
|
- }else
|
|
|
- if($book_info->charge_type == 'CHAPTER'){
|
|
|
- return response()->error('QAPP_CHAPTER_BUY',$data);
|
|
|
- }else{
|
|
|
- return response()->error('QAPP_SYS_ERROR');
|
|
|
- }
|
|
|
+ if ($this->isOrderRemind($bid)) {
|
|
|
+ if ($book_info->charge_type == 'BOOK') {
|
|
|
+ return response()->error('QAPP_BOOK_BUY', $data);
|
|
|
+ } else
|
|
|
+ if ($book_info->charge_type == 'CHAPTER') {
|
|
|
+ return response()->error('QAPP_CHAPTER_BUY', $data);
|
|
|
+ } else {
|
|
|
+ return response()->error('QAPP_SYS_ERROR');
|
|
|
+ }
|
|
|
}
|
|
|
//付费 不提醒
|
|
|
- if($this->balancePay($book_info,$cid,$chapter->size,$chapter->name,0)){
|
|
|
+ if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, 0)) {
|
|
|
|
|
|
- ReadRecordService::addReadRecord(['uid'=>$this->uid,'bid'=>$bid,'book_name'=>$book_info->book_name,
|
|
|
- 'cid'=>$cid,'chapter_name'=>$chapter->name ]);
|
|
|
+ ReadRecordService::addReadRecord([
|
|
|
+ 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
|
|
|
+ 'cid' => $cid, 'chapter_name' => $chapter->name
|
|
|
+ ]);
|
|
|
//用户标签
|
|
|
- if($chapter->sequence >= 20){
|
|
|
+ if ($chapter->sequence >= 20) {
|
|
|
$this->addTag($book_info);
|
|
|
}
|
|
|
- return response()->item(new ChapterTransformer,$this->getChapter($bid,$cid,$chapter));
|
|
|
- }else{
|
|
|
+ return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
|
+ } else {
|
|
|
|
|
|
//不需要提醒
|
|
|
- if($book_info->charge_type == 'BOOK'){
|
|
|
- return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY',$data);
|
|
|
- }elseif($book_info->charge_type == 'CHAPTER'){
|
|
|
- return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY',$data);
|
|
|
- }else{
|
|
|
+ if ($book_info->charge_type == 'BOOK') {
|
|
|
+ return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY', $data);
|
|
|
+ } elseif ($book_info->charge_type == 'CHAPTER') {
|
|
|
+ return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY', $data);
|
|
|
+ } else {
|
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
}
|
|
|
}
|
|
@@ -437,57 +416,60 @@ class ChapterController extends BaseController
|
|
|
* }
|
|
|
* }
|
|
|
*/
|
|
|
- public function pay(Request $request,$bid,$cid){
|
|
|
- $remind = (int)$request->input('remind');
|
|
|
+ public function pay(Request $request, $bid, $cid)
|
|
|
+ {
|
|
|
+ $remind = (int) $request->input('remind');
|
|
|
$oldbid = $bid;
|
|
|
- $bid = Hashids::decode($bid)[0];
|
|
|
+ $bid = BookService::decodeBidStatic($bid);
|
|
|
$book_info = BookConfigService::getBookById($bid);;
|
|
|
- if(empty($book_info)) response()->error('QAPP_SYS_ERROR');
|
|
|
+ if (empty($book_info)) response()->error('QAPP_SYS_ERROR');
|
|
|
|
|
|
- if($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3){
|
|
|
- if(!$this->isBookOrdered($bid)){
|
|
|
+ if ($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3) {
|
|
|
+ if (!$this->isBookOrdered($bid)) {
|
|
|
response()->error('QAPP_OFF_SHELF');
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
//获取章节
|
|
|
- $chapter = ChapterService::getChapterNameById($cid,$bid);
|
|
|
- if(!$chapter){
|
|
|
+ $chapter = ChapterService::getChapterNameById($cid, $bid);
|
|
|
+ if (!$chapter) {
|
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
}
|
|
|
|
|
|
|
|
|
- if($this->balancePay($book_info,$cid,$chapter->size,$chapter->name,$remind)){
|
|
|
- ReadRecordService::addReadRecord(['uid'=>$this->uid,'bid'=>$bid,'book_name'=>$book_info->book_name,
|
|
|
- 'cid'=>$cid,'chapter_name'=>$chapter->name ]);
|
|
|
+ if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, $remind)) {
|
|
|
+ ReadRecordService::addReadRecord([
|
|
|
+ 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
|
|
|
+ 'cid' => $cid, 'chapter_name' => $chapter->name
|
|
|
+ ]);
|
|
|
//用户标签
|
|
|
- if($chapter->sequence >= 20){
|
|
|
+ if ($chapter->sequence >= 20) {
|
|
|
$this->addTag($book_info);
|
|
|
}
|
|
|
- return response()->item(new ChapterTransformer,$this->getChapter($bid,$cid,$chapter));
|
|
|
- }else{
|
|
|
- $fee = $this->getPrice($book_info,$chapter->size);
|
|
|
+ return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
|
|
|
+ } else {
|
|
|
+ $fee = $this->getPrice($book_info, $chapter->size);
|
|
|
|
|
|
$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,
|
|
|
- 'distribution_channel_id'=>$this->distribution_channel_id,
|
|
|
- 'is_discount'=>0,
|
|
|
+ '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,
|
|
|
+ 'is_discount' => 0,
|
|
|
'discount_fee' => '',
|
|
|
- 'discount'=>''
|
|
|
+ 'discount' => ''
|
|
|
];
|
|
|
//不需要提醒
|
|
|
- if($book_info->charge_type == 'BOOK'){
|
|
|
- return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY',$data);
|
|
|
- }elseif($book_info->charge_type == 'CHAPTER'){
|
|
|
- return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY',$data);
|
|
|
- }else{
|
|
|
+ if ($book_info->charge_type == 'BOOK') {
|
|
|
+ return response()->error('QAPP_BOOK_SECOND_BALANCE_PAY', $data);
|
|
|
+ } elseif ($book_info->charge_type == 'CHAPTER') {
|
|
|
+ return response()->error('QAPP_CHAPTER_SECOND_BALANCE_PAY', $data);
|
|
|
+ } else {
|
|
|
return response()->error('QAPP_SYS_ERROR');
|
|
|
}
|
|
|
}
|
|
@@ -502,17 +484,17 @@ class ChapterController extends BaseController
|
|
|
* @param $chapter_size
|
|
|
* @return bool
|
|
|
*/
|
|
|
- protected function balancePay($book_info,$chapter_id,$chapter_size,$chapter_name,$is_remind){
|
|
|
- $fee = $this->getPrice($book_info,$chapter_size);
|
|
|
- if((int)$this->_user_info['balance'] >= $fee){
|
|
|
- if($this->bookOrderOrChapterOrder($book_info,$chapter_id,$fee,$chapter_name,$is_remind)){
|
|
|
+ protected function balancePay($book_info, $chapter_id, $chapter_size, $chapter_name, $is_remind)
|
|
|
+ {
|
|
|
+ $fee = $this->getPrice($book_info, $chapter_size);
|
|
|
+ if ((int) $this->_user_info['balance'] >= $fee) {
|
|
|
+ if ($this->bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -522,98 +504,68 @@ class ChapterController extends BaseController
|
|
|
* @param $cid
|
|
|
* @return bool|mixed
|
|
|
*/
|
|
|
- protected function getChapter($bid,$cid,$chapter){
|
|
|
- $chapter_content = ChapterService::getChapter($bid,$cid);
|
|
|
- if(!$chapter_content) return false;
|
|
|
- //$chapter->content = $chapter_content->content;
|
|
|
+ protected function getChapter($bid, $cid, $chapter)
|
|
|
+ {
|
|
|
+ $chapter_content = ChapterService::getChapter($bid, $cid);
|
|
|
+ if (!$chapter_content) return false;
|
|
|
$chapter->content = trim(str_replace($chapter_content->name, '', $chapter_content->content));
|
|
|
//统计点击率
|
|
|
- $key = 'book_click_num_bid_'.$bid;
|
|
|
+ $key = 'book_click_num_bid_' . $bid;
|
|
|
$field = date('Y-m-d');
|
|
|
- $old = Redis::hget($key,$field);
|
|
|
- if(!$old) $old = 0;
|
|
|
- Redis::hset($key,$field,$old+1);
|
|
|
- //签到奖励
|
|
|
- /*
|
|
|
- $sign_key = 'sign-'.date('Y-m-d');
|
|
|
- $sign_status = 0;
|
|
|
- if(!Redis::hexists($sign_key,$this->uid)){
|
|
|
- Redis::hset($sign_key,$this->uid,time());
|
|
|
- $sign_status = 1;
|
|
|
- }*/
|
|
|
- $sign_status = $this->userSign($this->uid);
|
|
|
- $chapter->sign_status = $sign_status;
|
|
|
+ $old = Redis::hget($key, $field);
|
|
|
+ if (!$old) $old = 0;
|
|
|
+ Redis::hset($key, $field, $old + 1);
|
|
|
return $chapter;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 签到
|
|
|
- * @param $uid
|
|
|
- * @return int
|
|
|
- */
|
|
|
- protected function userSign($uid){
|
|
|
-
|
|
|
- if($this->distribution_channel_id != 5){
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- $day = date('Y-m-d');
|
|
|
- if(UserSignService::isSign($uid,$day)){
|
|
|
- return 0;
|
|
|
- }
|
|
|
- if(UserSignService::sign($uid,$day)){
|
|
|
- return 1;
|
|
|
- }
|
|
|
- return 0;
|
|
|
-
|
|
|
- }
|
|
|
- /**
|
|
|
* 添加订购记录
|
|
|
* @param $book_info
|
|
|
* @param $chapter_id
|
|
|
* @param $fee
|
|
|
* @return bool
|
|
|
*/
|
|
|
- protected function bookOrderOrChapterOrder($book_info,$chapter_id,$fee,$chapter_name,$is_remind){
|
|
|
+ protected function bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)
|
|
|
+ {
|
|
|
$send_order_id = 0;
|
|
|
- if($book_info['charge_type'] == 'BOOK'){
|
|
|
+ if ($book_info['charge_type'] == 'BOOK') {
|
|
|
$data = [
|
|
|
- 'uid'=>$this->uid,
|
|
|
- 'fee'=>$fee,
|
|
|
- 'u'=>$send_order_id,
|
|
|
- 'distribution_channel_id'=>$this->distribution_channel_id,
|
|
|
- 'bid'=>$book_info->bid,
|
|
|
- 'book_name'=>$book_info->book_name,
|
|
|
- 'send_order_id'=>$send_order_id,
|
|
|
+ 'uid' => $this->uid,
|
|
|
+ 'fee' => $fee,
|
|
|
+ 'u' => $send_order_id,
|
|
|
+ 'distribution_channel_id' => $this->distribution_channel_id,
|
|
|
+ 'bid' => $book_info->bid,
|
|
|
+ 'book_name' => $book_info->book_name,
|
|
|
+ 'send_order_id' => $send_order_id,
|
|
|
];
|
|
|
- return BookOrderService::addOrderRecodeAndDecrUserBalance($data,$this->uid);
|
|
|
- }
|
|
|
- else{
|
|
|
+ return BookOrderService::addOrderRecodeAndDecrUserBalance($data, $this->uid);
|
|
|
+ } else {
|
|
|
$data = [
|
|
|
- 'uid'=>$this->uid,
|
|
|
- 'fee'=>$fee,
|
|
|
- 'cid'=>$chapter_id,
|
|
|
- 'bid'=>$book_info->bid,
|
|
|
- 'distribution_channel_id'=>$this->distribution_channel_id,
|
|
|
- 'book_name'=>$book_info->book_name,
|
|
|
- 'chapter_name'=>$chapter_name,
|
|
|
- 'send_order_id'=>$send_order_id,
|
|
|
- 'is_remind'=>$is_remind
|
|
|
+ 'uid' => $this->uid,
|
|
|
+ 'fee' => $fee,
|
|
|
+ 'cid' => $chapter_id,
|
|
|
+ 'bid' => $book_info->bid,
|
|
|
+ 'distribution_channel_id' => $this->distribution_channel_id,
|
|
|
+ 'book_name' => $book_info->book_name,
|
|
|
+ 'chapter_name' => $chapter_name,
|
|
|
+ 'send_order_id' => $send_order_id,
|
|
|
+ 'is_remind' => $is_remind
|
|
|
];
|
|
|
//print_r($data);
|
|
|
- if($is_remind){
|
|
|
+ if ($is_remind) {
|
|
|
$this->addOrderRemind($book_info->bid);
|
|
|
}
|
|
|
- return ChapterOrderService::addOrderAndDecrUserBalance($data,$this->uid);
|
|
|
+ return ChapterOrderService::addOrderAndDecrUserBalance($data, $this->uid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- protected function addOrderRemind($bid){
|
|
|
- if(ChapterReminderService::checkIsNoReminder($this->uid,$bid)){
|
|
|
+ protected function addOrderRemind($bid)
|
|
|
+ {
|
|
|
+ if (ChapterReminderService::checkIsNoReminder($this->uid, $bid)) {
|
|
|
return true;
|
|
|
- }else{
|
|
|
- ChapterReminderService::add($this->uid,$bid);
|
|
|
+ } else {
|
|
|
+ ChapterReminderService::add($this->uid, $bid);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -622,8 +574,9 @@ class ChapterController extends BaseController
|
|
|
* @param $chapter_id
|
|
|
* @return bool
|
|
|
*/
|
|
|
- protected function isOrderRemind($bid){
|
|
|
- $is_no_reminder = ChapterReminderService::checkIsNoReminder($this->uid,$bid) ? 1 : 0;
|
|
|
+ protected function isOrderRemind($bid)
|
|
|
+ {
|
|
|
+ $is_no_reminder = ChapterReminderService::checkIsNoReminder($this->uid, $bid) ? 1 : 0;
|
|
|
return $is_no_reminder == 0;
|
|
|
}
|
|
|
|
|
@@ -632,9 +585,10 @@ class ChapterController extends BaseController
|
|
|
* @param $uid
|
|
|
* @return bool
|
|
|
*/
|
|
|
- protected function getSubscribe(){
|
|
|
- $res = ForceSubscribeService::forceSubscribeUsersByUid(['uid'=>$this->uid]);
|
|
|
- if($res) return true;
|
|
|
+ protected function getSubscribe()
|
|
|
+ {
|
|
|
+ $res = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
|
|
|
+ if ($res) return true;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -645,22 +599,23 @@ class ChapterController extends BaseController
|
|
|
* @param $chapter_id
|
|
|
* @return bool
|
|
|
*/
|
|
|
- protected function getOrderRecord($bid,$chapter_id){
|
|
|
+ protected function getOrderRecord($bid, $chapter_id)
|
|
|
+ {
|
|
|
//包年记录
|
|
|
$uid = $this->uid;
|
|
|
$res = YearOrderService::getRecord($uid);
|
|
|
- if($res) return true;
|
|
|
+ if ($res) return true;
|
|
|
$res = null;
|
|
|
|
|
|
//单本订购记录
|
|
|
- $res = BookOrderService::getRecordByuidBid($uid,$bid);
|
|
|
- if($res) return true;
|
|
|
+ $res = BookOrderService::getRecordByuidBid($uid, $bid);
|
|
|
+ if ($res) return true;
|
|
|
$res = null;
|
|
|
|
|
|
//章节订购记录
|
|
|
$chapterOrder = new ChapterOrderService();
|
|
|
|
|
|
- if($chapterOrder->checkIsOrdered($uid,$bid,$chapter_id)) return true;
|
|
|
+ if ($chapterOrder->checkIsOrdered($uid, $bid, $chapter_id)) return true;
|
|
|
|
|
|
return false;
|
|
|
}
|
|
@@ -672,10 +627,11 @@ class ChapterController extends BaseController
|
|
|
* @param $chapter_size
|
|
|
* @return float
|
|
|
*/
|
|
|
- protected function getPrice($book_info,$chapter_size){
|
|
|
- if($book_info->charge_type == 'BOOK')
|
|
|
- return $book_info->price*100;
|
|
|
- return ceil($chapter_size/100);
|
|
|
+ protected function getPrice($book_info, $chapter_size)
|
|
|
+ {
|
|
|
+ if ($book_info->charge_type == 'BOOK')
|
|
|
+ return $book_info->price * 100;
|
|
|
+ return ceil($chapter_size / 100);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -685,35 +641,34 @@ class ChapterController extends BaseController
|
|
|
* 用户添加标签
|
|
|
* @param $book_info
|
|
|
*/
|
|
|
- protected function addTag($book_info){
|
|
|
+ protected function addTag($book_info)
|
|
|
+ {
|
|
|
$send_order_id = 0;
|
|
|
- if(!UserDeepReadTagService::isAddTag($this->uid,$book_info->bid)){
|
|
|
- try{
|
|
|
+ if (!UserDeepReadTagService::isAddTag($this->uid, $book_info->bid)) {
|
|
|
+ try {
|
|
|
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:'',
|
|
|
- 'distribution_channel_id'=>$this->distribution_channel_id?$this->distribution_channel_id:'0',
|
|
|
- 'send_order_id'=>$send_order_id,
|
|
|
+ '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',
|
|
|
+ 'send_order_id' => $send_order_id,
|
|
|
]);
|
|
|
- }catch (\Exception $e){
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ } catch (\Exception $e) { }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
- protected function isBookOrdered($bid){
|
|
|
+ protected function isBookOrdered($bid)
|
|
|
+ {
|
|
|
|
|
|
- $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid,$bid);
|
|
|
- if($chapter_order) return true;
|
|
|
+ $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $bid);
|
|
|
+ if ($chapter_order) return true;
|
|
|
|
|
|
- $res = BookOrderService::getRecordByuidBid($this->uid,$bid);
|
|
|
- if($res) return true;
|
|
|
+ $res = BookOrderService::getRecordByuidBid($this->uid, $bid);
|
|
|
+ if ($res) return true;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -744,6 +699,3 @@ class ChapterController extends BaseController
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|