ChapterController.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. <?php
  2. namespace App\Http\Controllers\QuickApp\Book;
  3. use App\Modules\SendOrder\Models\SendOrder;
  4. use App\Modules\SendOrder\Services\SendOrderService;
  5. use App\Modules\Statistic\Services\WapVisitStatService;
  6. use App\Modules\User\Services\UserBookCombinationConfigService;
  7. use Illuminate\Http\Request;
  8. use App\Http\Controllers\QuickApp\BaseController;
  9. use Redis;
  10. use App\Modules\Book\Services\ChapterService;
  11. use App\Modules\User\Services\ReadRecordService;
  12. use App\Http\Controllers\QuickApp\Book\Transformers\ChapterTransformer;
  13. use App\Modules\Book\Services\BookConfigService;
  14. use App\Http\Controllers\QuickApp\Book\Transformers\ChapterListTransformer;
  15. use App\Jobs\UserRententionJob;
  16. use App\Modules\Book\Services\BookService;
  17. use App\Modules\Subscribe\Services\BookOrderService;
  18. use App\Modules\Subscribe\Services\ChapterOrderService;
  19. use App\Modules\Subscribe\Services\YearOrderService;
  20. use App\Modules\OfficialAccount\Services\ForceSubscribeService;
  21. use App\Modules\Subscribe\Services\ChapterReminderService;
  22. use App\Modules\User\Services\UserDeepReadTagService;
  23. use App\Modules\UserTask\Services\BaseTask;
  24. use App\Modules\UserTask\Services\UserTaskService;
  25. use App\Modules\SendOrder\Models\QappSendOrder;
  26. class ChapterController extends BaseController
  27. {
  28. private $book_info;
  29. public function getCatalog(Request $request, $bid)
  30. {
  31. $bid = BookService::decodeBidStatic($bid);
  32. $lists = ChapterService::getChapterLists($bid);
  33. $book_info = BookConfigService::getBookById($bid);
  34. if (!$book_info) {
  35. return response()->error('PARAM_ERROR');
  36. }
  37. $this->book_info = $book_info;
  38. $lists = $this->getChapterCatalog($bid, $lists, $book_info);
  39. return response()->collection(new ChapterListTransformer, $lists);
  40. }
  41. public function getCatalogPerPage(Request $request, $bid)
  42. {
  43. $bid = BookService::decodeBidStatic($bid);
  44. $book_info = BookConfigService::getBookById($bid);
  45. if (!$book_info) {
  46. return response()->error('PARAM_ERROR');
  47. }
  48. $this->book_info = $book_info;
  49. $page_size = $request->input('page_size', 15);
  50. // if ($page_size >= 100) $page_size = 100;
  51. if ($page_size >= 20) $page_size = 20;
  52. // $page_size = 15;
  53. $res = ChapterService::getChapterListsPage($bid, $page_size);
  54. $lists = $this->getChapterCatalog($bid, $res, $book_info);
  55. return response()->pagination(new ChapterListTransformer, $lists);
  56. }
  57. private function getChapterCatalog(int $bid, $chapters, $book_info)
  58. {
  59. // 查询书籍是否限免
  60. $isFree = BookConfigService::judgeBookIsFree($bid);
  61. //渠道自定义vip章节
  62. //$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
  63. $vip_sequence = BookService::getVipSequence($bid, $this->distribution_channel_id, $this->send_order_id);
  64. list($is_split, $is_change_chapter_name) = BookService::splitContent($bid);
  65. $change_chapter_name = 0;
  66. if ($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name)) {
  67. $change_chapter_name = 1;
  68. }
  69. $account = $this->getAccount();
  70. $work_wechat_info = $this->getWorkWechatInfo($bid);
  71. switch ($book_info->charge_type) {
  72. case 'BOOK':
  73. $price = $this->getPriceNew($book_info, 0, $account);
  74. $is_need_charge = $this->isBookNeedCharge($bid, $price);
  75. foreach ($chapters as $v) {
  76. $v->next_chapter_status = 0;
  77. $v->next_price = 0;
  78. $v->is_need_charge = $v->is_vip ? $is_need_charge : false;
  79. $v->price = $price;
  80. if ($work_wechat_info['force_add_work_wechat_type'] > 0 && $v->sequence >= $work_wechat_info['force_add_work_wechat_seq']){
  81. $v->force_add_work_wechat_type = $work_wechat_info['force_add_work_wechat_type'];
  82. $v->force_add_work_wechat_url = $work_wechat_info['force_add_work_wechat_url'];
  83. }else{
  84. $v->force_add_work_wechat_type = 0;
  85. $v->force_add_work_wechat_url = "";
  86. }
  87. // 限免判断
  88. if ($isFree) {
  89. $v->is_need_charge = false;
  90. $v->price = 0;
  91. }
  92. if ($vip_sequence) {
  93. if ($v->sequence >= $vip_sequence) {
  94. $v->is_vip = 1;
  95. } else {
  96. $v->is_vip = 0;
  97. }
  98. }
  99. //拆章
  100. if ($change_chapter_name) {
  101. $v->name = '第' . $v->sequence . '章';
  102. }
  103. }
  104. break;
  105. default:
  106. $chapterIds = $this->getChapterIds($chapters);
  107. $rules = ['check' => 0, 'paycid' => []];
  108. if (!$isFree && !empty($chapterIds)) {
  109. $rules = $this->getHandelData($bid, $chapterIds);
  110. }
  111. foreach ($chapters as $v) {
  112. if ($vip_sequence) {
  113. if ($v->sequence >= $vip_sequence) {
  114. $v->is_vip = 1;
  115. } else {
  116. $v->is_vip = 0;
  117. }
  118. }
  119. if ($work_wechat_info['force_add_work_wechat_type'] > 0 && $v->sequence >= $work_wechat_info['force_add_work_wechat_seq']){
  120. $v->force_add_work_wechat_type = $work_wechat_info['force_add_work_wechat_type'];
  121. $v->force_add_work_wechat_url = $work_wechat_info['force_add_work_wechat_url'];
  122. }else{
  123. $v->force_add_work_wechat_type = 0;
  124. $v->force_add_work_wechat_url = "";
  125. }
  126. // 限免判断
  127. if ($isFree) {
  128. $v->is_need_charge = false;
  129. $v->price = 0;
  130. } else {
  131. $v->price = $v->is_vip ? $this->getPriceNew($book_info, $v->size, $account) : 0;
  132. $v->is_need_charge = $v->is_vip ? $this->isChapterNeedChargeNew($v->id, $rules, $v->price) : false;
  133. }
  134. // //下一章付费信息
  135. $v->next_chapter_status = 0;
  136. $v->next_price = 0;
  137. // if($v->is_vip){
  138. // if(in_array($v->next_price,$chapterIds)){
  139. //
  140. // }else{
  141. // $next_chapter_order_status = $this->nextChapterOrderStatus($bid,$v->next_cid);
  142. // $v->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
  143. // $v->next_price = $next_chapter_order_status['next_price'];
  144. // }
  145. //
  146. // }
  147. $v->next_chapter_status = $this->isSubscribe($v->id, $rules);
  148. $v->next_price = $v->price;
  149. //拆章
  150. if ($change_chapter_name) {
  151. $v->name = '第' . $v->sequence . '章';
  152. }
  153. }
  154. break;
  155. }
  156. return $chapters;
  157. }
  158. private function getChapterCatalogOld(int $bid, $chapters, $book_info)
  159. {
  160. // 查询书籍是否限免
  161. $isFree = BookConfigService::judgeBookIsFree($bid);
  162. //渠道自定义vip章节
  163. //$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
  164. $vip_sequence = BookService::getVipSequence($bid, $this->distribution_channel_id, $this->send_order_id);
  165. list($is_split, $is_change_chapter_name) = BookService::splitContent($bid);
  166. $change_chapter_name = 0;
  167. if ($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name)) {
  168. $change_chapter_name = 1;
  169. }
  170. switch ($book_info->charge_type) {
  171. case 'BOOK':
  172. $price = $this->getPrice($book_info);
  173. $is_need_charge = $this->isBookNeedCharge($bid, $price);
  174. foreach ($chapters as $v) {
  175. $v->next_chapter_status = 0;
  176. $v->next_price = 0;
  177. $v->is_need_charge = $v->is_vip ? $is_need_charge : false;
  178. $v->price = $price;
  179. // 限免判断
  180. if ($isFree) {
  181. $v->is_need_charge = false;
  182. $v->price = 0;
  183. }
  184. if ($vip_sequence) {
  185. if ($v->sequence >= $vip_sequence) {
  186. $v->is_vip = 1;
  187. } else {
  188. $v->is_vip = 0;
  189. }
  190. }
  191. //拆章
  192. if ($change_chapter_name) {
  193. $v->name = '第' . $v->sequence . '章';
  194. }
  195. }
  196. break;
  197. default:
  198. foreach ($chapters as $v) {
  199. if ($vip_sequence) {
  200. if ($v->sequence >= $vip_sequence) {
  201. $v->is_vip = 1;
  202. } else {
  203. $v->is_vip = 0;
  204. }
  205. }
  206. // 限免判断
  207. if ($isFree) {
  208. $v->is_need_charge = false;
  209. $v->price = 0;
  210. } else {
  211. $v->price = $v->is_vip ? $this->getPrice($book_info, $v->size) : 0;
  212. $v->is_need_charge = $v->is_vip ? $this->isChapterNeedCharge($bid, $v->id, $v->price) : false;
  213. }
  214. //下一章付费信息
  215. $v->next_chapter_status = 0;
  216. $v->next_price = 0;
  217. if ($v->is_vip) {
  218. $next_chapter_order_status = $this->nextChapterOrderStatus($bid, $v->next_cid);
  219. $v->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
  220. $v->next_price = $next_chapter_order_status['next_price'];
  221. }
  222. //拆章
  223. if ($change_chapter_name) {
  224. $v->name = '第' . $v->sequence . '章';
  225. }
  226. }
  227. break;
  228. }
  229. return $chapters;
  230. }
  231. public function index(Request $request, $bid, $cid)
  232. {
  233. $send_order_id = $request->header('send_order_id', '');
  234. $package = $request->header('x-package', '');
  235. //每次绑定用户和派单的关系
  236. $this->bindSendOrderId($this->uid, $send_order_id);
  237. $oldbid = $bid;
  238. $bid = BookService::decodeBidStatic($bid);
  239. //获取图书信息
  240. $book_info = BookConfigService::getBookById($bid);
  241. if (empty($book_info))
  242. return response()->error('QAPP_SYS_ERROR');
  243. $this->book_info = $book_info;
  244. $book_auth = BookConfigService::bookCopyright($bid, $this->distribution_channel_id);
  245. if ($book_auth == 2) {
  246. return response()->error('QAPP_OFF_SHELF');
  247. }
  248. //yuyuedu、xinghe 快应用这两个cp的书屏蔽下 wutong,wutong2,wutong3下所有内容都不放快应用
  249. if (in_array($book_info->cp_source, getHiddenCp($package)) && $book_auth != 1) {
  250. return response()->error('QAPP_OFF_SHELF');
  251. }
  252. if ($this->distribution_channel_id == 7477 && $bid == 13765) {
  253. $book_info->is_on_shelf = 2;
  254. }
  255. $special = get_special_bid();
  256. if (in_array($this->distribution_channel_id, [9487, 9390]) && in_array($book_info->bid, $special)) {
  257. $book_info->is_on_shelf = 2;
  258. }
  259. if ($bid == 58886) {
  260. $book_info->is_on_shelf = 0;
  261. }
  262. // 华为整改强制下架
  263. if ($this->distribution_channel_id == 13131 && in_array($bid,[13762,65327,66643])){
  264. $book_info->is_on_shelf = 4;
  265. }
  266. if (!in_array($book_info->is_on_shelf, [1, 2])) {
  267. if ($book_info->is_on_shelf != 4) {
  268. return response()->error('QAPP_OFF_SHELF');
  269. }
  270. //补充操作:如果该用户未订阅该下架的书籍则删除其阅读记录(书架不予显示)
  271. //判断是否属于包年用户
  272. $year_account = YearOrderService::getRecord($this->uid);
  273. if (!$year_account) {
  274. //获取书籍充值类型
  275. $charge_type = $book_info->charge_type;
  276. if ($charge_type == 'BOOK') {
  277. //是否购买过该书,购买过则不删除
  278. $res = BookOrderService::getRecordByuidBid($this->uid, $bid);
  279. } elseif ($charge_type == 'CHAPTER') {
  280. //是否购买过该书章节,购买过则不删除
  281. $res = ChapterOrderService::checkBookIsOrdered($this->uid, $bid);
  282. } else {
  283. $res = false;
  284. }
  285. if (!$res) {
  286. ReadRecordService::delReadRecordStatic($this->uid, [$bid]);
  287. return response()->error('QAPP_OFF_SHELF');
  288. }
  289. }
  290. }
  291. //wutong,wutong2,wutong3下所有内容都不放快应用
  292. // if(in_array($book_info->cp_source,['wutong','wutong2','wutong3','youyan2'])){
  293. // return response()->error('QAPP_OFF_SHELF');
  294. // }
  295. $this->book_info = $book_info;
  296. //获取章节信息
  297. $chapter = ChapterService::getChapterNameById($cid, $bid);
  298. if (!$chapter) {
  299. //短推长
  300. $combination_chapter = $this->chapterNotExists($bid, $cid);
  301. if ($combination_chapter) {
  302. $chapter = $combination_chapter;
  303. $bid = $chapter->bid;
  304. $book_info = BookConfigService::getBookById($bid);
  305. $oldbid = \Hashids::encode($bid);
  306. $this->book_info = $book_info;
  307. } else {
  308. return response()->error('QAPP_SYS_ERROR');
  309. }
  310. }
  311. list($is_split, $is_change_chapter_name) = BookService::splitContent($bid);
  312. if ($is_split && ($book_info->channel_name == '男频' || $is_change_chapter_name)) {
  313. $chapter->name = '第' . $chapter->sequence . '章';
  314. }
  315. $is_next_day = date('Y-m-d', strtotime($this->user_info->created_at)) == date('Y-m-d', strtotime('-1 days'));
  316. if ($is_next_day) {
  317. $job = new UserRententionJob($this->uid, now(), $this->user_info->created_at);
  318. dispatch($job)->onConnection('rabbitmq')->onQueue('user_rentention_queue');
  319. }
  320. //自定义vip章节
  321. //$vip_sequence = Redis::hget('channel:chapterfee:setting:' . $this->distribution_channel_id, $bid);
  322. $vip_sequence = BookService::getVipSequence($bid, $this->distribution_channel_id, $this->send_order_id);
  323. if ($vip_sequence) {
  324. if ($chapter->sequence >= $vip_sequence) {
  325. $chapter->is_vip = 1;
  326. } else {
  327. $chapter->is_vip = 0;
  328. }
  329. }
  330. if ($chapter->is_vip == 0) {
  331. ReadRecordService::addReadLog($this->uid, [
  332. 'distribution_channel_id' => $this->distribution_channel_id,
  333. 'bid' => $bid,
  334. 'cid' => $chapter->id,
  335. 'uid' => $this->uid,
  336. 'send_order_id' => $this->send_order_id,
  337. 'sequence' => $chapter->sequence,
  338. ]);
  339. ReadRecordService::addReadRecord([
  340. 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  341. 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
  342. ]);
  343. return response()->item(new ChapterTransformer, $this->getChapter($bid, $chapter->id, $chapter));
  344. }
  345. // 书籍是否限免
  346. $free = BookConfigService::judgeBookIsFree($bid);
  347. if ($free) {
  348. ReadRecordService::addReadLog($this->uid, [
  349. 'distribution_channel_id' => $this->distribution_channel_id,
  350. 'bid' => $bid,
  351. 'cid' => $chapter->id,
  352. 'uid' => $this->uid,
  353. 'send_order_id' => $this->send_order_id,
  354. 'sequence' => $chapter->sequence,
  355. ]);
  356. ReadRecordService::addReadRecord([
  357. 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  358. 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
  359. ]);
  360. if ($chapter->is_vip == 1) {
  361. $fee = $this->getPrice($book_info, $chapter->size);
  362. $now = date('Y-m-d');
  363. Redis::hincrby('qapp:book:free:virtual:' . $free->id, $now, $fee);
  364. Redis::sadd('qapp:free:virtual' . $now, $free->id);
  365. Redis::sadd('qapp:free:virtual:uids' . $now . $free->id, $this->uid);
  366. Redis::sadd('qapp:free:virtual:uids' . $free->id, $this->uid);
  367. }
  368. return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
  369. }
  370. //已经付费
  371. if ($this->getOrderRecord($bid, $cid)) {
  372. ReadRecordService::addReadLog($this->uid, [
  373. 'distribution_channel_id' => $this->distribution_channel_id,
  374. 'bid' => $bid,
  375. 'cid' => $chapter->id,
  376. 'uid' => $this->uid,
  377. 'send_order_id' => $this->send_order_id,
  378. 'sequence' => $chapter->sequence,
  379. ]);
  380. ReadRecordService::addReadRecord([
  381. 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  382. 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
  383. ]);
  384. return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
  385. }
  386. //未付费 要提醒
  387. $user_info = $this->user_info;
  388. //未付费 余额不足
  389. $fee = $this->getPrice($book_info, $chapter->size);
  390. $data = [
  391. 'book_id' => $oldbid,
  392. 'book_name' => $book_info->book_name,
  393. 'chapter_name' => $chapter->name,
  394. 'chapter_id' => $cid,
  395. 'pay_type' => $book_info->charge_type,
  396. 'fee' => $fee,
  397. 'user_balance' => $user_info->balance,
  398. 'product_id' => $book_info->product_id,
  399. 'uid' => $this->uid,
  400. 'distribution_channel_id' => $this->distribution_channel_id,
  401. 'is_discount' => 0,
  402. 'discount_fee' => '',
  403. 'discount' => ''
  404. ];
  405. if ($user_info['balance'] < $fee) {
  406. if ($book_info->charge_type == 'BOOK') {
  407. return response()->error('QAPP_BOOK_INSUFFICIENT_BALANCE', $data);
  408. } elseif ($book_info->charge_type == 'CHAPTER') {
  409. return response()->error('QAPP_CHAPTER_INSUFFICIENT_BALANCE', $data);
  410. } else {
  411. return response()->error('QAPP_SYS_ERROR');
  412. }
  413. }
  414. if (!$this->send_order_id) {
  415. if ($book_info->charge_type == 'BOOK') {
  416. return response()->error('QAPP_BOOK_BUY', $data);
  417. }/*else{
  418. return response()->error('QAPP_CHAPTER_BUY', $data);
  419. }*/
  420. }
  421. //付费 不提醒
  422. if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, 0)) {
  423. UserTaskService::addUserTaskQueue($this->uid, BaseTask::read, UserTaskService::judge_trigger);
  424. ReadRecordService::addReadLog($this->uid, [
  425. 'distribution_channel_id' => $this->distribution_channel_id,
  426. 'bid' => $bid,
  427. 'cid' => $chapter->id,
  428. 'uid' => $this->uid,
  429. 'send_order_id' => $this->send_order_id,
  430. 'sequence' => $chapter->sequence,
  431. ]);
  432. ReadRecordService::addReadRecord([
  433. 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  434. 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
  435. ]);
  436. //限免统计
  437. $free_book = BookConfigService::getByBidNoFilter($bid);
  438. if ($free_book) {
  439. if (strtotime($free_book->end_time) + 7 * 86400 >= strtotime(date('Y-m-d'))) {
  440. if (Redis::Sismember('qapp:free:virtual:uids' . $free_book->id, $this->uid)) {
  441. $now = date('Y-m-d');
  442. Redis::hincrby('qapp:book:free:actuality:' . $free_book->id, $now, $fee);
  443. Redis::sadd('qapp:free:actuality' . $now, $free_book->id);
  444. Redis::sadd('qapp:free:actuality:uids' . $now . $free_book->id, $this->uid);
  445. }
  446. }
  447. }
  448. if ($this->uid == 247081369) {
  449. $item = itemTransform(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
  450. myLog('xueqi')->info($item);
  451. }
  452. return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
  453. } else {
  454. if ($book_info->charge_type == 'BOOK') {
  455. return response()->error('QAPP_BOOK_INSUFFICIENT_BALANCE', $data);
  456. } elseif ($book_info->charge_type == 'CHAPTER') {
  457. return response()->error('QAPP_CHAPTER_INSUFFICIENT_BALANCE', $data);
  458. } else {
  459. return response()->error('QAPP_SYS_ERROR');
  460. }
  461. }
  462. }
  463. public function pay(Request $request, $bid, $cid)
  464. {
  465. $remind = (int)$request->input('remind');
  466. $oldbid = $bid;
  467. $bid = BookService::decodeBidStatic($bid);
  468. $book_info = BookConfigService::getBookById($bid);;
  469. if (empty($book_info)) response()->error('QAPP_SYS_ERROR');
  470. $this->book_info = $book_info;
  471. if ($this->distribution_channel_id == 7477 && $bid == 13765) {
  472. $book_info->is_on_shelf = 2;
  473. }
  474. if ($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3) {
  475. if (!$this->isBookOrdered($bid)) {
  476. response()->error('QAPP_OFF_SHELF');
  477. }
  478. }
  479. //获取章节
  480. $chapter = ChapterService::getChapterNameById($cid, $bid);
  481. if (!$chapter) {
  482. $combination_chapter = $this->chapterNotExists($bid, $cid);
  483. if ($combination_chapter) {
  484. $chapter = $combination_chapter;
  485. $bid = $chapter->bid;
  486. $book_info = BookConfigService::getBookById($bid);
  487. $oldbid = \Hashids::encode($bid);
  488. $this->book_info = $book_info;
  489. } else {
  490. return response()->error('QAPP_SYS_ERROR');
  491. }
  492. }
  493. if ($this->getOrderRecord($bid, $cid)) {
  494. ReadRecordService::addReadLog($this->uid, [
  495. 'distribution_channel_id' => $this->distribution_channel_id,
  496. 'bid' => $bid,
  497. 'cid' => $chapter->id,
  498. 'uid' => $this->uid,
  499. 'send_order_id' => $this->send_order_id,
  500. 'sequence' => $chapter->sequence,
  501. ]);
  502. ReadRecordService::addReadRecord([
  503. 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  504. 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
  505. ]);
  506. return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
  507. }
  508. if ($this->balancePay($book_info, $cid, $chapter->size, $chapter->name, $remind)) {
  509. UserTaskService::addUserTaskQueue($this->uid, BaseTask::read, UserTaskService::judge_trigger);
  510. ReadRecordService::addReadLog($this->uid, [
  511. 'distribution_channel_id' => $this->distribution_channel_id,
  512. 'bid' => $bid,
  513. 'cid' => $chapter->id,
  514. 'uid' => $this->uid,
  515. 'send_order_id' => $this->send_order_id,
  516. 'sequence' => $chapter->sequence,
  517. ]);
  518. ReadRecordService::addReadRecord([
  519. 'uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  520. 'cid' => $cid, 'chapter_name' => $chapter->name, 'sequence' => $chapter->sequence
  521. ]);
  522. $free_book = BookConfigService::getByBidNoFilter($bid);
  523. if ($free_book) {
  524. if (strtotime($free_book->end_time) + 7 * 86400 >= strtotime(date('Y-m-d'))) {
  525. if (Redis::Sismember('qapp:free:virtual:uids' . $free_book->id, $this->uid)) {
  526. $now = date('Y-m-d');
  527. $fee = $this->getPrice($book_info, $chapter->size);
  528. Redis::hincrby('qapp:book:free:actuality:' . $free_book->id, $now, $fee);
  529. Redis::sadd('qapp:free:actuality' . $now, $free_book->id);
  530. Redis::sadd('qapp:free:actuality:uids' . $now . $free_book->id, $this->uid);
  531. }
  532. }
  533. }
  534. return response()->item(new ChapterTransformer, $this->getChapter($bid, $cid, $chapter));
  535. } else {
  536. $fee = $this->getPrice($book_info, $chapter->size);
  537. $data = [
  538. 'book_id' => $oldbid,
  539. 'book_name' => $book_info->book_name,
  540. 'chapter_name' => $chapter->name,
  541. 'chapter_id' => $cid,
  542. 'pay_type' => $book_info->charge_type,
  543. 'fee' => $fee,
  544. 'user_balance' => $this->user_info['balance'],
  545. 'product_id' => $book_info->product_id,
  546. 'uid' => $this->uid,
  547. 'distribution_channel_id' => $this->distribution_channel_id,
  548. 'is_discount' => 0,
  549. 'discount_fee' => '',
  550. 'discount' => ''
  551. ];
  552. if ($book_info->charge_type == 'BOOK') {
  553. return response()->error('QAPP_BOOK_INSUFFICIENT_BALANCE', $data);
  554. } elseif ($book_info->charge_type == 'CHAPTER') {
  555. return response()->error('QAPP_CHAPTER_INSUFFICIENT_BALANCE', $data);
  556. } else {
  557. return response()->error('QAPP_SYS_ERROR');
  558. }
  559. }
  560. }
  561. /**
  562. * 余额支付
  563. * @param $book_info
  564. * @param $chapter_id
  565. * @param $chapter_size
  566. * @return bool
  567. */
  568. protected function balancePay($book_info, $chapter_id, $chapter_size, $chapter_name, $is_remind)
  569. {
  570. $fee = $this->getPrice($book_info, $chapter_size);
  571. if ((int)$this->user_info['balance'] >= $fee) {
  572. if ($this->bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)) {
  573. return true;
  574. }
  575. return false;
  576. } else {
  577. return false;
  578. }
  579. }
  580. /**
  581. * 获取章节内容
  582. * @param $bid
  583. * @param $cid
  584. * @return bool|mixed
  585. */
  586. protected function getChapter($bid, $cid, $chapter)
  587. {
  588. $chapter_content = ChapterService::getChapter($bid, $cid);
  589. if (!$chapter_content) return false;
  590. $chapter->content = trim(str_replace($chapter_content->name, '', $chapter_content->content));
  591. // 格式特殊处理
  592. $qian = array(" ", " ", "\t");
  593. $hou = array("", "", "");
  594. // 去掉所有空格
  595. $chapter->content = str_replace($qian, $hou, $chapter->content);
  596. // 2换行变1换行
  597. $chapter->content = str_replace("\n\n", "\n", $chapter->content);
  598. $chapter->content = str_replace("\r\n\r\n", "\r\n", $chapter->content);
  599. // \Log::info('getChapter_chapter:'.$bid.' cid:'.$cid);
  600. // \Log::info($chapter->content);
  601. //统计点击率
  602. $key = 'book_click_num_bid_' . $bid;
  603. $field = date('Y-m-d');
  604. $old = Redis::hget($key, $field);
  605. if (!$old) $old = 0;
  606. Redis::hset($key, $field, $old + 1);
  607. [$force_add_desk_type,$is_need_query_send_order] = $this->addDesktopType($bid, $chapter->sequence);
  608. $chapter->force_add_desk_type = $force_add_desk_type;
  609. $force_add_work_wechat_type = 0;
  610. $force_add_work_wechat_url = "";
  611. if($is_need_query_send_order){
  612. [$force_add_work_wechat_type, $force_add_work_wechat_url] = $this->addWorkWechatType($chapter->sequence);
  613. }
  614. $chapter->force_add_work_wechat_type = $force_add_work_wechat_type;
  615. $chapter->force_add_work_wechat_url = $force_add_work_wechat_url;
  616. //统计
  617. $this->stats();
  618. $next_chapter_order_status = $this->nextChapterOrderStatus($bid, $chapter->next_cid);
  619. $chapter->next_chapter_status = $next_chapter_order_status['next_chapter_status'];
  620. $chapter->next_price = $next_chapter_order_status['next_price'];
  621. $chapter->charge_type = $this->book_info->charge_type;
  622. $this->userBookCombination($chapter);
  623. return $chapter;
  624. }
  625. private function nextChapterOrderStatus($bid, $cid)
  626. {
  627. $chapter = ChapterService::getChapterNameById($cid, $bid);
  628. if (!$chapter || $chapter->is_vip == 0 || $this->book_info->charge_type == 'BOOK') {
  629. return ['next_chapter_status' => 0, 'next_price' => 0];
  630. }
  631. $is_paid = $this->getOrderRecord($bid, $cid);
  632. if ($is_paid) {
  633. return ['next_chapter_status' => 1, 'next_price' => 0];
  634. }
  635. $fee = $this->getPrice($this->book_info, $chapter->size);
  636. return ['next_chapter_status' => 2, 'next_price' => $fee];
  637. }
  638. //短续长
  639. private function userBookCombination($chapter)
  640. {
  641. if ($chapter->prev_cid && $chapter->next_cid) {
  642. return;
  643. }
  644. if ($chapter->next_cid == 0 && $this->book_info->charge_type == 'BOOK') {
  645. $bid = UserBookCombinationConfigService::selectAndSave($this->uid, $this->book_info->bid);
  646. if ($bid) {
  647. $bookInfo = BookConfigService::getBookById($bid);
  648. $chapter->next_cid = $bookInfo->first_cid;
  649. }
  650. }
  651. if ($chapter->prev_cid == 0 && $this->book_info->charge_type == 'CHAPTER') {
  652. $bid = UserBookCombinationConfigService::getShortBookFromLongBid($this->uid, $this->book_info->bid);
  653. if ($bid) {
  654. $bookInfo = BookConfigService::getBookById($bid);
  655. $chapter->prev_cid = $bookInfo->last_cid;
  656. }
  657. }
  658. }
  659. private function chapterNotExists($bid, $cid)
  660. {
  661. //1.全局图书组合配置
  662. $combination = BookConfigService::getCombinationInfo($bid);
  663. if ($combination) {
  664. $chapter = ChapterService::getChapterNameByIdNoCheck($cid);
  665. if ($chapter) {
  666. return $chapter;
  667. }
  668. return false;
  669. }
  670. //2.用户图书组合配置
  671. if ($this->book_info->charge_type == 'CHAPTER') {
  672. $user_combination = UserBookCombinationConfigService::getShortBookFromLongBook($this->uid, $bid);
  673. } else {
  674. $user_combination = UserBookCombinationConfigService::getLongBookFromShortBook($this->uid, $bid);
  675. }
  676. if ($user_combination) {
  677. $chapter = ChapterService::getChapterNameByIdNoCheck($cid);
  678. if ($chapter) {
  679. return $chapter;
  680. }
  681. return false;
  682. }
  683. return false;
  684. }
  685. /**
  686. * 添加订购记录
  687. * @param $book_info
  688. * @param $chapter_id
  689. * @param $fee
  690. * @return bool
  691. */
  692. protected function bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)
  693. {
  694. if ($book_info['charge_type'] == 'BOOK') {
  695. $data = [
  696. 'uid' => $this->uid,
  697. 'fee' => $fee,
  698. 'u' => $this->send_order_id,
  699. 'distribution_channel_id' => $this->distribution_channel_id,
  700. 'bid' => $book_info->bid,
  701. 'book_name' => $book_info->book_name,
  702. 'send_order_id' => $this->send_order_id,
  703. ];
  704. return BookOrderService::addOrderRecodeAndDecrUserBalance($data, $this->uid);
  705. } else {
  706. $data = [
  707. 'uid' => $this->uid,
  708. 'fee' => $fee,
  709. 'cid' => $chapter_id,
  710. 'bid' => $book_info->bid,
  711. 'distribution_channel_id' => $this->distribution_channel_id,
  712. 'book_name' => $book_info->book_name,
  713. 'chapter_name' => $chapter_name,
  714. 'send_order_id' => $this->send_order_id,
  715. 'is_remind' => $is_remind
  716. ];
  717. if ($is_remind) {
  718. $this->addOrderRemind($book_info->bid);
  719. }
  720. return ChapterOrderService::addOrderAndDecrUserBalance($data, $this->uid);
  721. }
  722. }
  723. protected function addOrderRemind($bid)
  724. {
  725. if (ChapterReminderService::checkIsNoReminder($this->uid, $bid)) {
  726. return true;
  727. } else {
  728. ChapterReminderService::add($this->uid, $bid);
  729. return true;
  730. }
  731. }
  732. /**
  733. * 是否订购提醒
  734. * @param $chapter_id
  735. * @return bool
  736. */
  737. protected function isOrderRemind($bid)
  738. {
  739. $is_no_reminder = ChapterReminderService::checkIsNoReminder($this->uid, $bid) ? 1 : 0;
  740. return $is_no_reminder == 0;
  741. }
  742. /**
  743. * 用户是否关注
  744. * @param $uid
  745. * @return bool
  746. */
  747. protected function getSubscribe()
  748. {
  749. $res = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
  750. if ($res) return true;
  751. return false;
  752. }
  753. /**
  754. * 获取订购记录
  755. * @param $book_info
  756. * @param $chapter_id
  757. * @return bool
  758. */
  759. protected function getOrderRecord($bid, $chapter_id)
  760. {
  761. //包年记录
  762. $uid = $this->uid;
  763. $res = YearOrderService::getRecord($uid);
  764. if ($res) return true;
  765. $res = null;
  766. //单本订购记录
  767. $res = BookOrderService::getRecordByuidBid($uid, $bid);
  768. if ($res) return true;
  769. $res = null;
  770. //章节订购记录
  771. $chapterOrder = new ChapterOrderService();
  772. if ($chapterOrder->checkIsOrdered($uid, $bid, $chapter_id)) return true;
  773. return false;
  774. }
  775. /**
  776. * 计算价格
  777. * @param $book_info
  778. * @param $chapter_size
  779. * @return float
  780. */
  781. private function getPrice($book_info, $chapter_size = 0)
  782. {
  783. if ($book_info->charge_type == 'BOOK') {
  784. if (BookOrderService::isHasBookOrder($this->uid)) {
  785. $this->is_first_book_order = 0;
  786. return 1399;
  787. } else {
  788. $this->is_first_book_order = 1;
  789. return 899;
  790. }
  791. } else {
  792. // 获取投放后台账号,
  793. $account = '';
  794. $account_send_order = $this->getNowSendOrderInfo();
  795. if ($account_send_order) {
  796. $account = isset($account_send_order['account']) ? $account_send_order['account'] : '';
  797. }
  798. $fee = BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size, $account);
  799. return $fee;
  800. }
  801. }
  802. /**
  803. * 计算价格
  804. * @param $book_info
  805. * @param $chapter_size
  806. * @return float
  807. */
  808. private function getPriceNew($book_info, $chapter_size = 0, $account = "")
  809. {
  810. if ($book_info->charge_type == 'BOOK') {
  811. if (BookOrderService::isHasBookOrder($this->uid)) {
  812. $this->is_first_book_order = 0;
  813. return 1399;
  814. } else {
  815. $this->is_first_book_order = 1;
  816. return 899;
  817. }
  818. } else {
  819. return BookService::getPrice($book_info, $this->distribution_channel_id, $chapter_size, $account);
  820. }
  821. }
  822. /**
  823. * 获取投放后台账号,
  824. * name: getAccount
  825. * @return mixed|string
  826. * date 2022/10/20 11:29
  827. */
  828. protected function getAccount()
  829. {
  830. $account = '';
  831. $account_send_order = $this->getNowSendOrderInfo();
  832. if ($account_send_order) {
  833. $account = isset($account_send_order['account']) ? $account_send_order['account'] : '';
  834. }
  835. return $account;
  836. }
  837. /**
  838. * 用户添加标签
  839. * @param $book_info
  840. */
  841. protected function addTag($book_info)
  842. {
  843. if (!UserDeepReadTagService::isAddTag($this->uid, $book_info->bid)) {
  844. try {
  845. UserDeepReadTagService::addTag([
  846. 'uid' => $this->uid,
  847. 'bid' => $book_info->bid,
  848. 'book_name' => $book_info->book_name,
  849. 'category_id' => $book_info->category_id,
  850. 'category_name' => $book_info->category_name,
  851. 'sex_preference' => $book_info->channel_name ? $book_info->channel_name : '',
  852. 'distribution_channel_id' => $this->distribution_channel_id ? $this->distribution_channel_id : '0',
  853. 'send_order_id' => $this->send_order_id,
  854. ]);
  855. } catch (\Exception $e) {
  856. }
  857. }
  858. }
  859. protected function isBookOrdered($bid)
  860. {
  861. $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $bid);
  862. if ($chapter_order) return true;
  863. $res = BookOrderService::getRecordByuidBid($this->uid, $bid);
  864. if ($res) return true;
  865. return false;
  866. }
  867. /**
  868. * 判断是否需要充值
  869. */
  870. private function isBookNeedCharge(int $bid, float $price)
  871. {
  872. $book_order = $this->getOrderRecord($bid, 0);
  873. if ($book_order) {
  874. return false;
  875. } else {
  876. $user_info = $this->user_info;
  877. return $user_info['balance'] < $price;
  878. }
  879. }
  880. /**
  881. * 判断章节是否需要充值
  882. */
  883. private function isChapterNeedCharge(int $bid, int $cid, float $price)
  884. {
  885. $book_order = $this->getOrderRecord($bid, $cid);
  886. if ($book_order) {
  887. return false;
  888. } else {
  889. $user_info = $this->user_info;
  890. return $user_info['balance'] < $price;
  891. }
  892. }
  893. private function stats()
  894. {
  895. //阅读器统计
  896. WapVisitStatService::recordReaderUvAndPv($this->uid, $this->distribution_channel_id);
  897. }
  898. //加桌类型
  899. private function addDesktopType($bid, $sequence)
  900. {
  901. $deault_force_add_desk_type = 0;
  902. $send_order_id = $this->GetBindSendOrderId($this->uid);
  903. $is_need_query_order = 0;
  904. if ($send_order_id) {
  905. $send_order_info = SendOrderService::getById($send_order_id);
  906. if (!$send_order_info) return [$deault_force_add_desk_type,$is_need_query_order];
  907. if ($send_order_info->book_id == $bid) {
  908. $is_need_query_order = 1;
  909. // 派单书籍和观看书籍一致,并设置了强加桌,判断当前章节和设置的强加桌章节
  910. if ($send_order_info->force_add_desk_type == 1 && $send_order_info->force_add_desk_seq) {
  911. //在设置的强加桌章节前一章开始
  912. if ($sequence >= ($send_order_info->force_add_desk_seq - 1)) {
  913. $force_add_desk_type = $send_order_info->force_add_desk_type;
  914. return [$force_add_desk_type,$is_need_query_order];
  915. }
  916. }
  917. if ($send_order_info->force_add_desk_type == 2) {
  918. if ($sequence >= $this->book_info->force_subscribe_chapter_seq && $sequence <= $this->book_info->force_subscribe_chapter_seq + 3) {
  919. $force_add_desk_type = $send_order_info->force_add_desk_type;
  920. return [$force_add_desk_type,$is_need_query_order];
  921. }
  922. }
  923. if ($send_order_info->force_add_desk_type == 3) {
  924. //弱加桌+强加桌 ,即强加桌章节之前的章节均弱加桌,之后的章节显示强加桌:
  925. $need_sequence = $send_order_info->force_add_desk_seq;
  926. if (!$need_sequence) {
  927. $need_sequence = $this->book_info->force_subscribe_chapter_seq;
  928. }
  929. if ($sequence >= ($need_sequence - 1)) {
  930. //之后的章节显示强加桌
  931. return [1,$is_need_query_order];
  932. } else {
  933. ////强加桌章节之前的章节均弱加桌
  934. return [2,$is_need_query_order];
  935. }
  936. }
  937. return [$deault_force_add_desk_type,$is_need_query_order];
  938. }
  939. }
  940. //无派单,或者派单书籍与 此次书籍不一致,直接使用 原书籍的默认强关章节
  941. $book_info = BookConfigService::getBookById($bid);
  942. if ($book_info && $book_info->force_subscribe_chapter_seq) {
  943. if ($sequence >= ($book_info->force_subscribe_chapter_seq - 1)) {
  944. return [2,$is_need_query_order];
  945. }
  946. }
  947. return [$deault_force_add_desk_type,$is_need_query_order];
  948. }
  949. private function addWorkWechatType($sequence)
  950. {
  951. $deault_force_add_desk_type = 0;
  952. $work_wechat_url = "";
  953. $send_order_id = $this->GetBindSendOrderId($this->uid);
  954. if ($send_order_id) {
  955. $send_order_info = QappSendOrder::getSendOrderById($send_order_id);
  956. if (!$send_order_info) return [$deault_force_add_desk_type, $work_wechat_url];
  957. if($send_order_info['force_add_work_wechat_status'] == 1 && $send_order_info['force_add_work_wechat_seq'] <= ($sequence+1)){
  958. $deault_force_add_desk_type =$send_order_info['force_add_work_wechat_type'];
  959. $work_wechat_url =$send_order_info['force_add_work_wechat_url'];
  960. }
  961. }
  962. return [$deault_force_add_desk_type, $work_wechat_url];
  963. }
  964. /**
  965. * [bindSendOrderId description]
  966. * @param [type] $uid [description]
  967. * @param [type] $send_order_id [description]
  968. * @return [type] [description]
  969. */
  970. public function bindSendOrderId($uid, $send_order_id)
  971. {
  972. if ($send_order_id) {
  973. $res = Redis::hset('book_read_chapter:' . $uid, 'send_order_id', $send_order_id);
  974. }
  975. }
  976. /**
  977. * [bindSendOrderId description]
  978. * @param [type] $uid [description]
  979. * @param [type] $send_order_id [description]
  980. * @return [type] [description]
  981. */
  982. public function GetBindSendOrderId($uid)
  983. {
  984. try {
  985. $send_order_id = Redis::hget('book_read_chapter:' . $uid, 'send_order_id');
  986. if ($send_order_id)
  987. return (int)$send_order_id;
  988. } catch (\Exception $e) {
  989. }
  990. }
  991. private function getChapterIds($chapters): array
  992. {
  993. $list = [];
  994. if ($chapters) {
  995. foreach ($chapters as $v) {
  996. $list[] = $v->id;
  997. }
  998. }
  999. return $list;
  1000. }
  1001. private function getHandelData(int $bid, array $chapterIds): array
  1002. {
  1003. $uid = $this->uid;
  1004. $res = YearOrderService::getRecord($uid);
  1005. if ($res) {
  1006. return $handle = ['check' => 0, 'paycid' => []];
  1007. }
  1008. $res = null;
  1009. //单本订购记录
  1010. $res = BookOrderService::getRecordByuidBid($uid, $bid);
  1011. if ($res) {
  1012. return $handle = ['check' => 0, 'paycid' => []];
  1013. }
  1014. //章节订购记录
  1015. $chapterOrder = new ChapterOrderService();
  1016. $res = $chapterOrder->getOrdersByChapterIds($uid, $bid, $chapterIds);
  1017. return $handle = ['check' => 1, 'paycid' => $res];
  1018. }
  1019. /**
  1020. * 判断是否需要充值
  1021. * name: isChapterNeedChargeNew
  1022. * @param $cid
  1023. * @param $rules
  1024. * @return bool
  1025. * date 2022/10/20 16:08
  1026. */
  1027. private function isChapterNeedChargeNew($cid, $rules, $price = 0): bool
  1028. {
  1029. if ($rules['check'] != 1) {
  1030. return false;
  1031. }
  1032. if (empty($rules['paycid']) || !in_array($cid, $rules['paycid'])) {
  1033. $user_info = $this->user_info;
  1034. return $user_info['balance'] < $price;
  1035. } else {
  1036. return false;
  1037. }
  1038. }
  1039. /*****
  1040. * 是否订阅
  1041. * name: isSubscribe
  1042. * @param $cid
  1043. * @param $rules
  1044. * @return int
  1045. * date 2022/11/02 17:19
  1046. */
  1047. private function isSubscribe($cid, $rules): int
  1048. {
  1049. if ($rules['check'] != 1) {
  1050. return 1;
  1051. }
  1052. if (empty($rules['paycid']) || !in_array($cid, $rules['paycid'])) {
  1053. return 2;
  1054. } else {
  1055. return 1;
  1056. }
  1057. }
  1058. private function getWorkWechatInfo($bid)
  1059. {
  1060. $info = ['force_add_work_wechat_type' => 0,'force_add_work_wechat_url' => "",'force_add_work_wechat_seq' => 0];
  1061. $send_order_id = $this->GetBindSendOrderId($this->uid);
  1062. if ($send_order_id) {
  1063. $send_order_info = QappSendOrder::getSendOrderById($send_order_id);
  1064. if (!$send_order_info) return $info;
  1065. $send_order_bid = SendOrder::where(['id' => $send_order_id])->value('book_id');
  1066. if($send_order_info['force_add_work_wechat_status'] == 1 && $send_order_bid == $bid){
  1067. $info['force_add_work_wechat_type'] = $send_order_info['force_add_work_wechat_type'];
  1068. $info['force_add_work_wechat_url'] = $send_order_info['force_add_work_wechat_url'];
  1069. $info['force_add_work_wechat_seq'] = $send_order_info['force_add_work_wechat_seq'];
  1070. }else{
  1071. return $info;
  1072. }
  1073. }
  1074. return $info;
  1075. }
  1076. }