|
@@ -14,6 +14,7 @@ use App\Modules\Book\Services\UserShelfBooksService;
|
|
|
use App\Modules\Book\Services\ChapterService;
|
|
|
use App\Modules\Subscribe\Services\BookOrderService;
|
|
|
use App\Modules\Subscribe\Services\ChapterOrderService;
|
|
|
+use App\Modules\Subscribe\Services\YearOrderService;
|
|
|
use App\Modules\User\Services\ReadRecordService;
|
|
|
use Hashids;
|
|
|
use Log;
|
|
@@ -115,10 +116,10 @@ class BookController extends BaseController
|
|
|
$last_chapter = ChapterService::getChapterNameById($book_info['last_cid'], $bid);
|
|
|
$book_info['last_chapter_is_vip'] = $last_chapter['is_vip'];
|
|
|
$book_info['is_need_charge'] = true;
|
|
|
- try{
|
|
|
+ try {
|
|
|
$book_info['is_need_charge'] = $this->isNeedCharge($bid, $last_chapter, $book_info);
|
|
|
- }catch (\Exception $e){
|
|
|
- \Log::info('bid is :'.$bid);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ \Log::info('bid is :' . $bid);
|
|
|
}
|
|
|
$record = ReadRecordService::getBookReadRecordStatic($this->uid, $bid);
|
|
|
if ($record) {
|
|
@@ -129,11 +130,39 @@ class BookController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取订购记录
|
|
|
+ * @param $book_info
|
|
|
+ * @param $chapter_id
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ protected function getOrderRecord($bid, $chapter_id)
|
|
|
+ {
|
|
|
+ //包年记录
|
|
|
+ $uid = $this->uid;
|
|
|
+ $res = YearOrderService::getRecord($uid);
|
|
|
+ if ($res) return true;
|
|
|
+ $res = null;
|
|
|
+
|
|
|
+ //单本订购记录
|
|
|
+ $res = BookOrderService::getRecordByuidBid($uid, $bid);
|
|
|
+ if ($res) return true;
|
|
|
+ $res = null;
|
|
|
+
|
|
|
+ //章节订购记录
|
|
|
+ $chapterOrder = new ChapterOrderService();
|
|
|
+
|
|
|
+ if ($chapterOrder->checkIsOrdered($uid, $bid, $chapter_id)) return true;
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 判断是否需要充值
|
|
|
*/
|
|
|
private function isBookNeedCharge(int $bid, float $price)
|
|
|
{
|
|
|
- $book_order = BookOrderService::getRecordByuidBid($this->uid, $bid);
|
|
|
+ $book_order = $this->getOrderRecord($bid, 0);
|
|
|
if ($book_order) {
|
|
|
return false;
|
|
|
} else {
|
|
@@ -147,8 +176,8 @@ class BookController extends BaseController
|
|
|
*/
|
|
|
private function isChapterNeedCharge(int $bid, int $cid, float $price)
|
|
|
{
|
|
|
- $chapter_order = ChapterOrderService::checkIsOrderedStatic($this->uid, $bid, $cid);
|
|
|
- if ($chapter_order) {
|
|
|
+ $book_order = $this->getOrderRecord($bid, $cid);
|
|
|
+ if ($book_order) {
|
|
|
return false;
|
|
|
} else {
|
|
|
$user_info = $this->user_info;
|