ChapterController.php 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118
  1. <?php
  2. namespace App\Http\Controllers\Wap\Book;
  3. use App\Modules\Book\Models\DataAnalysisBookConfig;
  4. use App\Modules\Book\Services\BookService;
  5. use App\Modules\Book\Services\ChapterCommentsService;
  6. use App\Modules\Book\Services\ChapterShareWechatConfigService;
  7. use App\Modules\Statistic\Models\DataAnalysisSelectUser;
  8. use App\Modules\Statistic\Services\AdVisitStatService;
  9. use App\Modules\Statistic\Services\DataAnalysisChapterService;
  10. use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
  11. use App\Modules\Statistic\Services\WapVisitStatService;
  12. use App\Modules\Subscribe\Services\CrmChapterOrderDetailService;
  13. use App\Modules\Subscribe\Services\CustomChapterOrderService;
  14. use App\Modules\Subscribe\Services\OrderService;
  15. use App\Modules\Subscribe\Models\Order;
  16. use App\Modules\User\Services\CrmUserService;
  17. use App\Modules\User\Services\ForceGuidePersonAccountService;
  18. use App\Modules\User\Services\ForceSubscribeUserIService;
  19. use App\Modules\User\Services\ReadRecordStatsService;
  20. use App\Modules\User\Services\UserBindHkWelfareService;
  21. use App\Modules\User\Services\UserService;
  22. use App\Modules\YunQi\Services\BookUserService;
  23. use Illuminate\Http\Request;
  24. use App\Http\Controllers\Wap\BaseController;
  25. use Cookie;
  26. use Redis;
  27. use App\Modules\Book\Services\ChapterService;
  28. use App\Modules\User\Services\ReadRecordService;
  29. use App\Http\Controllers\Wap\Book\Transformers\ChapterTransformer;
  30. use App\Modules\Book\Services\BookConfigService;
  31. use App\Http\Controllers\Wap\Book\Transformers\ChapterListTransformer;
  32. use App\Modules\Subscribe\Services\BookOrderService;
  33. use App\Modules\Subscribe\Services\ChapterOrderService;
  34. use App\Modules\Subscribe\Services\YearOrderService;
  35. use App\Modules\OfficialAccount\Services\ForceSubscribeService;
  36. use App\Modules\Subscribe\Services\ChapterReminderService;
  37. use App\Modules\OfficialAccount\Services\OfficialAccountService;
  38. use Hashids;
  39. use GuzzleHttp\Client;
  40. use Log;
  41. use DB;
  42. use App\Modules\User\Services\UserSignService;
  43. use App\Modules\SendOrder\Services\SendOrderService;
  44. use App\Modules\User\Services\UserDeepReadTagService;
  45. use App\Modules\Book\Services\BookSubscribleChapterService;
  46. use App\Modules\Channel\Services\ChannelSubscribeSettingService;
  47. class ChapterController extends BaseController
  48. {
  49. /**
  50. * @apiDefine Chapter 章节
  51. */
  52. //用户是否强关
  53. private $is_had_subscribe = false;
  54. //章节是否需要强关
  55. private $is_need_subscribe;
  56. //用户信息
  57. private $user;
  58. //图书信息
  59. private $book_info;
  60. //cid
  61. private $cid;
  62. //加密的bid
  63. private $en_bid;
  64. //章节信息
  65. private $chapter;
  66. //强关时间
  67. private $force_subscribe_time = null;
  68. //关注的appid
  69. private $need_subscribe_appid;
  70. private $need_subscribe_name;
  71. private $is_first_book_order = 0;
  72. /**
  73. * @apiVersion 1.0.0
  74. * @apiDescription 章节列表不分页
  75. * @api {get} books/{bid}/allcatalog 章节列表不分页
  76. * @apiGroup Chapter
  77. * @apiName getCatalog
  78. * @apiSuccess {int} code 状态码
  79. * @apiSuccess {String} msg 信息
  80. * @apiSuccess {object} data 结果集
  81. * @apiSuccess {Array} data.list 分页结果集
  82. * @apiSuccess {Int} data.list.bid bid
  83. * @apiSuccess {Int} data.list.chapter_id 章节id
  84. * @apiSuccess {String} data.list.chapter_name 章节名称
  85. * @apiSuccess {Int} data.list.chapter_sequence 序号
  86. * @apiSuccess {Int} data.list.chapter_is_vip 是否vip
  87. * @apiSuccess {Int} data.list.chapter_size 章节大小
  88. * @apiSuccess {Int} data.list.prev_cid 上一章节id
  89. * @apiSuccess {Int} data.list.next_cid 下一章节
  90. * @apiSuccess {String} data.list.recent_update_at 更新时间
  91. * @apiSuccess {String} data.list.is_need_subscirbe 是否强制关注
  92. * @apiSuccess {String} data.list.is_show_price 是否显示价格
  93. * @apiSuccess {String} data.list.price 价格
  94. * @apiSuccess {object} data.meta 分页信息
  95. * @apiSuccess {Int} data.meta.total 总条数
  96. * @apiSuccess {Int} data.meta.per_page 每页条数
  97. * @apiSuccess {Int} data.meta.current_page 当前页
  98. * @apiSuccess {Int} data.meta.last_page 最后页
  99. * @apiSuccess {String} data.meta.next_page_url 下一页
  100. * @apiSuccess {String} data.meta.prev_page_url 上一页
  101. * @apiSuccessExample {json} Success-Response:
  102. * HTTP/1.1 200 OK
  103. * {
  104. * code: 0,
  105. * msg: "",
  106. * data:
  107. * [
  108. * {
  109. * bid: 5,
  110. * chapter_id: 5,
  111. * chapter_name: "第1240章 不是我",
  112. * chapter_sequence: 1239,
  113. * chapter_is_vip: 1,
  114. * chapter_size: 2422,
  115. * prev_cid: 0,
  116. * next_cid: 0,
  117. * recent_update_at: 2017-11-20 15:01:56,
  118. * is_need_subscirbe: 1,
  119. * },
  120. * {
  121. * bid: 5,
  122. * chapter_id: 5,
  123. * chapter_name: "第1240章 不是我",
  124. * chapter_sequence: 1239,
  125. * chapter_is_vip: 1,
  126. * chapter_size: 2422,
  127. * prev_cid: 0,
  128. * next_cid: 0,
  129. * recent_update_at: 2017-11-20 15:01:56,
  130. * is_need_subscirbe: 1,
  131. * },
  132. * ]
  133. * }
  134. */
  135. public function getCatalog(Request $request, $t, $domain, $bid)
  136. {
  137. if (!$this->checkUid()) {
  138. return response()->error('WAP_NOT_LOGIN');
  139. }
  140. $this->en_bid = $bid;
  141. $bid = Hashids::decode($bid)[0];
  142. $lists = ChapterService::getChapterLists($bid);
  143. $book_info = BookConfigService::getBookById($bid);
  144. if (!$book_info) {
  145. return response()->error('PARAM_ERROR');
  146. }
  147. $this->book_info = $book_info;
  148. $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
  149. foreach ($lists as $v) {
  150. $v->is_show_price = $is_show_price;
  151. $v->price = '';
  152. if ($is_show_price) {
  153. $v->price = $this->getPrice($book_info, $v);
  154. }
  155. }
  156. return response()->collection(new ChapterListTransformer, $lists);
  157. }
  158. /**
  159. * @apiVersion 1.0.0
  160. * @apiDescription 章节列表分页
  161. * @api {get} books/{bid}/catalog 章节列表分页
  162. * @apiGroup Chapter
  163. * @apiName getCatalogPerPage
  164. * @apiParam {Int} page_size 分页大小(默认15)
  165. * @apiParam {Int} page 页码(默认1)
  166. * @apiSuccess {int} code 状态码
  167. * @apiSuccess {String} msg 信息
  168. * @apiSuccess {object} data 结果集
  169. * @apiSuccess {Array} data.list 分页结果集
  170. * @apiSuccess {Int} data.list.bid bid
  171. * @apiSuccess {Int} data.list.chapter_id 章节id
  172. * @apiSuccess {String} data.list.chapter_name 章节名称
  173. * @apiSuccess {Int} data.list.chapter_sequence 序号
  174. * @apiSuccess {Int} data.list.chapter_is_vip 是否vip
  175. * @apiSuccess {Int} data.list.chapter_size 章节大小
  176. * @apiSuccess {Int} data.list.prev_cid 上一章节id
  177. * @apiSuccess {Int} data.list.next_cid 下一章节
  178. * @apiSuccess {String} data.list.recent_update_at 更新时间
  179. * @apiSuccess {String} data.list.is_need_subscirbe 是否强制关注
  180. * @apiSuccess {String} data.list.is_show_price 是否显示价格
  181. * @apiSuccess {String} data.list.price 价格
  182. * @apiSuccess {object} data.meta 分页信息
  183. * @apiSuccess {Int} data.meta.total 总条数
  184. * @apiSuccess {Int} data.meta.per_page 每页条数
  185. * @apiSuccess {Int} data.meta.current_page 当前页
  186. * @apiSuccess {Int} data.meta.last_page 最后页
  187. * @apiSuccess {String} data.meta.next_page_url 下一页
  188. * @apiSuccess {String} data.meta.prev_page_url 上一页
  189. * @apiSuccessExample {json} Success-Response:
  190. * HTTP/1.1 200 OK
  191. * {
  192. * code: 0,
  193. * msg: "",
  194. * data:
  195. * list:[
  196. * {
  197. * bid: 5,
  198. * chapter_id: 5,
  199. * chapter_name: "第1240章 不是我",
  200. * chapter_sequence: 1239,
  201. * chapter_is_vip: 1,
  202. * chapter_size: 2422,
  203. * prev_cid: 0,
  204. * next_cid: 0,
  205. * recent_update_at: 2017-11-20 15:01:56,
  206. * is_need_subscirbe: 1,
  207. * },
  208. * {
  209. * bid: 5,
  210. * chapter_id: 5,
  211. * chapter_name: "第1240章 不是我",
  212. * chapter_sequence: 1239,
  213. * chapter_is_vip: 1,
  214. * chapter_size: 2422,
  215. * prev_cid: 0,
  216. * next_cid: 0,
  217. * recent_update_at: 2017-11-20 15:01:56,
  218. * is_need_subscirbe: 1,
  219. * },
  220. * ]
  221. * meta:{
  222. * total: 1253,
  223. * per_page: 15,
  224. * current_page: 1,
  225. * last_page: 84,
  226. * next_page_url: "http://myapi.cn/api/books/1/chapter?page=2",
  227. * prev_page_url: ""
  228. * }
  229. * }
  230. */
  231. public function getCatalogPerPage(Request $request, $t, $domain, $bid)
  232. {
  233. if (!$this->checkUid()) {
  234. return response()->error('WAP_NOT_LOGIN');
  235. }
  236. $this->en_bid = $bid;
  237. $bid_array = Hashids::decode($bid);
  238. if (isset($bid_array[0])) {
  239. $bid = $bid_array[0];
  240. } else {
  241. return response()->error('PARAM_ERROR');
  242. }
  243. $book_info = BookConfigService::getBookById($bid);
  244. if (!$book_info) {
  245. return response()->error('PARAM_ERROR');
  246. }
  247. $this->book_info = $book_info;
  248. $page_size = $request->input('page_size', 15);
  249. if($page_size>=100) $page_size=100;
  250. $res = ChapterService::getChapterListsPage($bid, $page_size);
  251. $is_show_price = $this->showChapterPrice($bid, $book_info->charge_type);
  252. foreach ($res as $v) {
  253. $v->is_show_price = $is_show_price;
  254. $v->price = '';
  255. if ($is_show_price) {
  256. $v->price = $this->getPrice($book_info, $v);
  257. }
  258. }
  259. return response()->pagination(new ChapterListTransformer, $res);
  260. }
  261. /**
  262. * @apiVersion 1.0.0
  263. * @apiDescription 章节内容
  264. * @api {get} books/{bid}/chapters/{chapter_id} 章节内容
  265. * @apiGroup Chapter
  266. * @apiName index
  267. * @apiSuccess {int} code 状态码
  268. * @apiSuccess {String} msg 信息
  269. * @apiSuccess {object} data 结果集
  270. * @apiSuccess {Int} data.chapter_id 章节id
  271. * @apiSuccess {String} data.chapter_name 章节名称
  272. * @apiSuccess {Int} data.chapter_sequence 序号
  273. * @apiSuccess {Int} data.chapter_is_vip 是否vip
  274. * @apiSuccess {Int} data.chapter_size 章节大小
  275. * @apiSuccess {Int} data.prev_cid 上一章节id
  276. * @apiSuccess {Int} data.next_cid 下一章节
  277. * @apiSuccess {String} data.recent_update_at 更新时间
  278. * @apiSuccess {String} data.chapter_content 章节内容
  279. * @apiSuccess {Int} data.is_need_subscirbe 是否强制关注(删除)
  280. * @apiSuccess {Int} data.is_show_subscribe_link 是否显示底部强关链接
  281. * @apiSuccessExample {json} Success-Response:
  282. * HTTP/1.1 200 OK
  283. * {
  284. * code: 0,
  285. * msg: "",
  286. * data: {
  287. * chapter_id: 5,
  288. * chapter_name: "第1240章 不是我",
  289. * chapter_sequence: 1239,
  290. * chapter_is_vip: 1,
  291. * chapter_size: 2422,
  292. * prev_cid: 0,
  293. * next_cid: 0,
  294. * recent_update_at: 2017-11-20 15:01:56,
  295. * chapter_content: "叶妩被司行霈的阴阳怪气一吓,思路偏得太远了。 她张口结舌,忘记了自己要说什么。",
  296. * }
  297. * }
  298. */
  299. public function index(Request $request, $t, $domain, $bid, $cid)
  300. {
  301. $special_user_log = env('SPECIAL_USER_LOG');
  302. //注意:内部约定用 有此参数不需要强关
  303. $inter_not_need_sub = $request->has('inter_not_need_sub') ? true : false;
  304. $ad_status = $request->get('ad_status');
  305. //$ad_status = 0;
  306. $has_force_show_qrcode_cookie = Cookie::get('force_show_qrcode');
  307. Cookie::queue('force_show_qrcode', 1, -1);
  308. if (!$this->checkUid()) {
  309. myLog('special')->info('chapter index controller---$this->checkUid() fail-------');
  310. return response()->error('WAP_NOT_LOGIN');
  311. }
  312. if($special_user_log && $special_user_log == $this->uid){
  313. $my_log = myLog('special');
  314. $my_log->info('in chapters--------------------------');
  315. $my_log->info('param is');
  316. $my_log->info($request->all());
  317. $my_log->info('$t is: '.$t);
  318. $my_log->info('$domain is: '.$domain);
  319. $my_log->info('$bid is: '.$bid);
  320. $my_log->info('$cid is: '.$cid);
  321. $my_log->info('$uri is: '. $request->path());
  322. }
  323. $this->en_bid = $bid;
  324. $bid = explode(',',$bid)[0];
  325. $bid = Hashids::decode($bid)[0];
  326. if($special_user_log && $special_user_log == $this->uid){
  327. myLog('special')->info('decode bid is: '.$bid);
  328. }
  329. //获取图书信息
  330. $book_info = BookConfigService::getBookById($bid);
  331. if($special_user_log && $special_user_log == $this->uid){
  332. $my_log = myLog('special');
  333. $my_log->info('book_info is ');
  334. $my_log->info($book_info);
  335. }
  336. //是否开启全站按章模式
  337. $global_charge_by_chapter_channels = explode(',',env('GLOBAL_CHARGE_BY_CHAPTER_CHANNEL'));
  338. if(in_array($this->distribution_channel_id,$global_charge_by_chapter_channels))
  339. {
  340. $book_info->charge_type = 'CHAPTER';
  341. }
  342. if (empty($book_info)) return response()->error('WAP_SYS_ERROR');
  343. if($special_user_log && $special_user_log == $this->uid){
  344. $my_log = myLog('special');
  345. $my_log->info('book info ok--------------------------');
  346. }
  347. $this->book_info = $book_info;
  348. $this->cid = $cid;
  349. //下架图书不能看
  350. if ($this->isOffShelf()) {
  351. return response()->error('WAP_OFF_SHELF');
  352. }
  353. if($special_user_log && $special_user_log == $this->uid){
  354. $my_log = myLog('special');
  355. $my_log->info('on shelf ok--------------------------');
  356. }
  357. //获取章节信息
  358. $chapter = ChapterService::getChapterNameById($cid, $bid);
  359. $this->chapter = $chapter;
  360. if($special_user_log && $special_user_log == $this->uid){
  361. $my_log = myLog('special');
  362. $my_log->info('chapters-info--is-----------------------');
  363. $my_log->info($chapter);
  364. }
  365. //章节被删除
  366. if (($is_delete = $this->chapterNotExists())) {
  367. if($special_user_log && $special_user_log == $this->uid){
  368. $my_log = myLog('special');
  369. $my_log->info('chapters-----delete---------------------');
  370. }
  371. return response()->error('WAP_DOMAIN_NOT_MATCH', [
  372. 'url' => $is_delete
  373. ]);
  374. }
  375. if(($result = $this->forceGuidePerson())){
  376. return response()->error('WAP_DOMAIN_NOT_MATCH', [
  377. 'url' => $result
  378. ]);
  379. }
  380. /*//强制导粉
  381. //$force_guide_sites = redisEnv('FORCE_GUIDE_SITES');
  382. //$img = redisEnv('GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  383. list($force_guide_sites,$img) = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  384. if($force_guide_sites &&
  385. $img &&
  386. in_array($this->distribution_channel_id,explode(',',$force_guide_sites)) &&
  387. $this->is_paid &&
  388. ($this->chapter->sequence == 2 || $this->chapter->sequence == 8)&&
  389. !UserBindHkWelfareService::isHasGet($this->uid) &&
  390. ForceGuidePersonAccountService::isShow($this->uid,$bid,$cid)
  391. ){
  392. return response()->error('WAP_DOMAIN_NOT_MATCH', [
  393. 'url' => sprintf('/force/guide?bid=%s&cid=%s&book_name=%s&prev_cid=%s',$this->en_bid,$cid,$book_info->book_name,$this->chapter->prev_cid)
  394. ]);
  395. }*/
  396. if($special_user_log && $special_user_log == $this->uid){
  397. $my_log = myLog('special');
  398. $my_log->info('chapters-----ok---------------------');
  399. }
  400. //获取强关章节数
  401. $subscribe_seq = $this->getSubscribeChapterNum($book_info);
  402. //章节是否需要强关 TRUE:不需要,false:需要
  403. $force_subscribe = $subscribe_seq > $chapter->sequence;
  404. $this->is_need_subscribe = !$force_subscribe;
  405. //图书域名,book_configs表的promotion_domain 要跟当前的主机名匹配 在强关章节后3章
  406. $visit_domain_check_seq = $subscribe_seq + 3;
  407. $is_forced_check_domain = false;
  408. $force_domain_bids = [
  409. 'iycdm.com'=>[5804,5667,5675,5674,5672,5670,5671,6004,5858,5689,5402,5379,5374,5377,5372,5369,5363,5365,5163,5255,4662,4664,4467,4471,4470,4525,4360,4418,4421,4994,4343,4347,4363,4382,4298,4297,4307,4280,4226,4203,4204,4157,4209,4160,4123,4129,4122,4135,4125,4146,4148,4009,4006,4026,4014,4028,4025,4991,4004,3996,3940,3970,3971,3981,3816,3808,3769,3772,3768,3767,3766,3760,3738,3714,3658,3651,4987,3650,3669,3654,3662,3653,3666,3652,3649,3655,3660,3617,2436,2435,2434,3600,3565,3560,3563,3492,3490,3487,3475,3418,3419,3415,3416,3413,3408,3409,3402,3401,3410,3392,3395,3348,3347,3355,3354,3367,3362,3364,3366,3369,2740,2748,6179,2738,2727,2698,2696,5254,5297,5290,5018,4693,4649,4704,4140,4489,4484,4526,4428,4279,4287,3757,3771,3753,3746,3689,3717,3688,3657,3668,3610,2538,3550,3547,3514,3494,3495,3515,3363,3252,2721,2700,2687,2633,2627,2629,1802,4051,937,936,1032,1846,999,1378,4995,99,1479,1511,1516,1596,1595,1952,1954,1957,2021,4152,2615,2061,2119,2168,2333,2399,2600,2573,2323,2324,6378,2145,2136,2039,2008,2015,1692,1504,1495,1508,1503,1550,1594,2567,1803,2383,1842,534,1242,324,466,3616,860,1271,1619,2174,1434,851,1697,907,1547,6753,4891,1345,1547,1782,5127,3963,3730,2693,3609,6059,3944,1580,1574,1696,1965,2401,2632,2737,2757,2617,2403,2437,1587,2102,5770,5769,5768,5764,5766,5761,5767,5760,5262,6282,3551,2699,830,307,4198],
  410. 'leyuee.com'=>[5254,3354,3362,3624,3364,3366,3363,3347,3355,3367,3348,3358]
  411. ];
  412. //强制走指定域名
  413. foreach ($force_domain_bids as $_force_domain=>$_force_domain_bid)
  414. {
  415. if(in_array($bid,$_force_domain_bid))
  416. {
  417. $is_forced_check_domain = true;
  418. $visit_domain_check_seq = 0;
  419. $this->book_info->promotion_domain = $_force_domain;break;
  420. }
  421. }
  422. if ($this->isVisitDomainNotEqualBookDomain($domain, $visit_domain_check_seq, $is_forced_check_domain) ) {
  423. if($special_user_log && $special_user_log == $this->uid){
  424. $my_log = myLog('special');
  425. $my_log->info('book domain not match------------------------');
  426. }
  427. return response()->error('WAP_DOMAIN_NOT_MATCH', [
  428. 'url' => $this->getCorrespondBookUrl()
  429. ]);
  430. }
  431. if($special_user_log && $special_user_log == $this->uid){
  432. $my_log = myLog('special');
  433. $my_log->info('book domain jump--------------------------');
  434. }
  435. $user_info = $this->_user_info;
  436. $this->user = $user_info;
  437. //用户是否强关
  438. $this->is_had_subscribe = $is_had_subscribe = $inter_not_need_sub ? true : $this->getSubscribe();
  439. //判断当前是否有强制显示服务号信息的cookie、已经关注 跳转到服务号信息引导页
  440. if($has_force_show_qrcode_cookie && $is_had_subscribe)
  441. {
  442. if($special_user_log && $special_user_log == $this->uid){
  443. $my_log = myLog('special');
  444. $my_log->info('do not have force show qrcode cookie-------------------------');
  445. }
  446. $force_read_url = '/subscribe/getFromUser';//服务号信息引导页
  447. $force_read_data = ['src' => $force_read_url];
  448. return response()->error('WAP_NOT_SUBSCRIBE', $force_read_data);
  449. }
  450. if($special_user_log && $special_user_log == $this->uid){
  451. $my_log = myLog('special');
  452. $my_log->info('has force show qrcode cookie-ok-------------------------');
  453. }
  454. if ($force_subscribe || $chapter->is_vip == 0) {
  455. //vip前一张和枪管前一张的访问统计
  456. $this->beforeForceSubAndBeforeVipUvAndPv($book_info, $subscribe_seq, $chapter);
  457. }
  458. //不用关注且不是vip章节
  459. if ($force_subscribe && $chapter->is_vip == 0) {
  460. //获取公共号
  461. $officialAccount = $this->getOfficialAccount();
  462. $this->chapter->is_show_subscribe_link = 0;
  463. //非强关,但是设置了弱关,阅读页底部显示强关链接
  464. if ($officialAccount && isset($officialAccount->appid) && !empty($officialAccount->appid)) {
  465. $sub_type = $this->getSubscribeType($officialAccount->appid, $bid);
  466. if (in_array(2, $sub_type['type']) && !$is_had_subscribe) {
  467. $this->chapter->is_show_subscribe_link = 1;
  468. }
  469. }
  470. if($special_user_log && $special_user_log == $this->uid){
  471. $my_log = myLog('special');
  472. $my_log->info('do not force subscribe-and is not vip-------------------------');
  473. }
  474. $this->getChapter();
  475. return response()->item(new ChapterTransformer, $this->chapter);
  476. }
  477. if($special_user_log && $special_user_log == $this->uid){
  478. $my_log = myLog('special');
  479. $my_log->info('11111111111111111111111111111111111111111');
  480. }
  481. //需要强制关注 不是vip章节 已经关注了
  482. if (!$force_subscribe && $chapter->is_vip == 0 && $is_had_subscribe) {
  483. $this->getChapter();
  484. return response()->item(new ChapterTransformer, $this->chapter);
  485. }
  486. if($special_user_log && $special_user_log == $this->uid){
  487. $my_log = myLog('special');
  488. $my_log->info('222222222222222222222222222222222222222');
  489. }
  490. //需要强制关注 没关注
  491. if ((!$force_subscribe) && !$is_had_subscribe) {
  492. $force_data = $this->forceSubscribe();
  493. if ($force_data) {
  494. $this->subscribeStats();
  495. if($special_user_log && $special_user_log == $this->uid){
  496. $my_log = myLog('special');
  497. $my_log->info('need subscribe-------------------------');
  498. }
  499. //阅读记录
  500. ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  501. 'cid' => $cid, 'chapter_name' => $chapter->name]);
  502. return response()->error($force_data['error_type'], $force_data['data']);
  503. }
  504. //取不到公众号则不用强关
  505. if ($chapter->is_vip == 0) {
  506. $this->getChapter();
  507. if($special_user_log && $special_user_log == $this->uid){
  508. $my_log = myLog('special');
  509. $my_log->info('official fail--------------------------');
  510. }
  511. return response()->item(new ChapterTransformer, $this->chapter);
  512. }
  513. }
  514. if($special_user_log && $special_user_log == $this->uid){
  515. $my_log = myLog('special');
  516. $my_log->info('33333333333333333333333333333333333333333');
  517. }
  518. //已经付费
  519. if ($this->getOrderRecord($bid, $cid)) {
  520. $this->getChapter();
  521. if($special_user_log && $special_user_log == $this->uid){
  522. $my_log = myLog('special');
  523. $my_log->info('had order order record--------------------------');
  524. }
  525. return response()->item(new ChapterTransformer, $this->chapter);
  526. }
  527. if($special_user_log && $special_user_log == $this->uid){
  528. $my_log = myLog('special');
  529. $my_log->info('4444444444444444444444444444444444444444444');
  530. }
  531. //获取价格
  532. $fee = $this->getPrice($book_info, $chapter);
  533. //广告
  534. if($this->isUserInAdSample() && $ad_status && $ad_status == 1 && $user_info->balance < $fee){
  535. if($special_user_log && $special_user_log == $this->uid){
  536. $my_log = myLog('special');
  537. $my_log->info('ad-----in--------------------');
  538. }
  539. //广告解锁2张
  540. /*if($this->chapter->next_cid){
  541. $next_chapter = ChapterService::getChapterNameById($this->chapter->next_cid, $bid);
  542. if($next_chapter){
  543. $next_chapter_name = $next_chapter->name;
  544. $this->bookOrderOrChapterOrder($book_info, $this->chapter->next_cid, 0, $next_chapter_name, 1);
  545. AdVisitStatService::create($this->uid,$this->book_info->bid,$this->chapter->next_cid,'UNLOCK_2');
  546. }
  547. }*/
  548. //$this->chapter->is_show_ad = 0;
  549. $result = AdVisitStatService::getInfoV2($this->uid, $cid, ['UNLOCK', 'UNLOCK_2']);
  550. if ($result){
  551. $this->getChapter();
  552. $this->bookOrderOrChapterOrder($book_info, $cid, 0, $chapter->name, 1);
  553. return response()->item(new ChapterTransformer, $this->chapter);
  554. }
  555. }
  556. if($special_user_log && $special_user_log == $this->uid){
  557. $my_log = myLog('special');
  558. $my_log->info('5555555555555555555555555555555555');
  559. }
  560. //以上都是不用付费的情况******************************************************
  561. //未付费
  562. //返回的价格信息
  563. $data = [
  564. 'book_id' => $this->en_bid,
  565. 'book_name' => $book_info->book_name,
  566. 'chapter_name' => $chapter->name,
  567. 'chapter_id' => $cid,
  568. 'pay_type' => $book_info->charge_type,
  569. 'fee' => $fee,
  570. 'user_balance' => $user_info->balance,
  571. 'product_id' => $book_info->product_id,
  572. 'uid' => $this->uid,
  573. 'distribution_channel_id' => $this->distribution_channel_id,
  574. 'is_discount' => 0,
  575. 'discount_fee' => '',
  576. 'discount' => '',
  577. 'is_first_book_order'=>$this->is_first_book_order
  578. ];
  579. if($special_user_log && $special_user_log == $this->uid){
  580. $my_log = myLog('special');
  581. $my_log->info('data is:');
  582. $my_log->info($data);
  583. }
  584. //余额不足 弹窗提醒
  585. if ($user_info['balance'] < $fee) {
  586. if($special_user_log && $special_user_log == $this->uid){
  587. $my_log = myLog('special');
  588. $my_log->info('balance is lack');
  589. $my_log->info('user balance is: '.$user_info['balance']);
  590. $my_log->info('fee is: '.$fee);
  591. }
  592. //$this->smartPushTestBookPayPageUv($bid);
  593. //$this->sendOrderPayPageUv($bid);
  594. //除了单本订购 其他的都不提醒,直接跳转到充值页面
  595. if ($book_info->charge_type == 'CHAPTER') {
  596. if($special_user_log && $special_user_log == $this->uid){
  597. $my_log = myLog('special');
  598. $my_log->info('chapter order balance lack');
  599. }
  600. return response()->error('WAP_CHAPTER_SECOND_BALANCE_PAY', $data);
  601. }
  602. //需要提箱
  603. if ($this->isOrderRemind($bid)) {
  604. if($special_user_log && $special_user_log == $this->uid){
  605. $my_log = myLog('special');
  606. $my_log->info('balance lack remind');
  607. }
  608. return response()->error('WAP_BOOK_BALANCE_PAY', $data);
  609. //return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
  610. } else {
  611. if($special_user_log && $special_user_log == $this->uid){
  612. $my_log = myLog('special');
  613. $my_log->info('balance lack not remind');
  614. }
  615. return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
  616. }
  617. }
  618. if($special_user_log && $special_user_log == $this->uid){
  619. $my_log = myLog('special');
  620. $my_log->info('6666666666666666666666666666666666666');
  621. }
  622. //余额充足 单本弹窗提醒,章节直接扣费
  623. if ($this->isOrderRemind($bid) && $book_info->charge_type == 'BOOK') {
  624. if($special_user_log && $special_user_log == $this->uid){
  625. $my_log = myLog('special');
  626. $my_log->info('balance enough remind');
  627. }
  628. return response()->error('WAP_BOOK_BUY', $data);
  629. }
  630. if($special_user_log && $special_user_log == $this->uid){
  631. $my_log = myLog('special');
  632. $my_log->info('77777777777777777777777777777');
  633. }
  634. //付费 不提醒
  635. if ($this->balancePay($book_info, $chapter, 0)) {
  636. if($special_user_log && $special_user_log == $this->uid){
  637. $my_log = myLog('special');
  638. $my_log->info('balance pay ok-----');
  639. }
  640. $this->getChapter();
  641. return response()->item(new ChapterTransformer, $this->chapter);
  642. } else {
  643. if($special_user_log && $special_user_log == $this->uid){
  644. $my_log = myLog('special');
  645. $my_log->info('balance pay fails!!!!!!!!!!!!!!!!');
  646. }
  647. //付费 异常
  648. return response()->error('WAP_SYS_ERROR');
  649. }
  650. }
  651. /**
  652. * @apiVersion 1.0.0
  653. * @apiDescription 余额支付
  654. * @api {get} books/{bid}/balance/chapterOrders/{cid} 余额支付
  655. * @apiGroup Chapter
  656. * @apiName pay
  657. * @apiParam (Int) remind 提醒
  658. * @apiSuccess {int} code 状态码
  659. * @apiSuccess {String} msg 信息
  660. * @apiSuccess {object} data 结果集
  661. * @apiSuccess {Int} data.chapter_id 章节id
  662. * @apiSuccess {String} data.chapter_name 章节名称
  663. * @apiSuccess {Int} data.chapter_sequence 序号
  664. * @apiSuccess {Int} data.chapter_is_vip 是否vip
  665. * @apiSuccess {Int} data.chapter_size 章节大小
  666. * @apiSuccess {Int} data.prev_cid 上一章节id
  667. * @apiSuccess {Int} data.next_cid 下一章节
  668. * @apiSuccess {String} data.recent_update_at 更新时间
  669. * @apiSuccess {String} data.chapter_content 章节内容
  670. * @apiSuccess {Int} data.is_need_subscirbe 是否强制关注(删除)
  671. * @apiSuccessExample {json} Success-Response:
  672. * HTTP/1.1 200 OK
  673. * {
  674. * code: 0,
  675. * msg: "",
  676. * data: {
  677. * chapter_id: 5,
  678. * chapter_name: "第1240章 不是我",
  679. * chapter_sequence: 1239,
  680. * chapter_is_vip: 1,
  681. * chapter_size: 2422,
  682. * prev_cid: 0,
  683. * next_cid: 0,
  684. * recent_update_at: 2017-11-20 15:01:56,
  685. * chapter_content: "叶妩被司行霈的阴阳怪气一吓,思路偏得太远了。 她张口结舌,忘记了自己要说什么。",
  686. * }
  687. * }
  688. */
  689. public function pay(Request $request, $t, $domain, $bid, $cid)
  690. {
  691. if (!$this->checkUid()) {
  692. return response()->error('NOT_LOGIN');
  693. }
  694. $remind = (int)$request->input('remind');
  695. $this->en_bid = $bid;
  696. $oldbid = $bid;
  697. $bid = Hashids::decode($bid)[0];
  698. $book_info = BookConfigService::getBookById($bid);;
  699. if (empty($book_info)) response()->error('WAP_SYS_ERROR');
  700. //获取章节
  701. $chapter = ChapterService::getChapterNameById($cid, $bid);
  702. if (!$chapter) {
  703. return response()->error('WAP_SYS_ERROR');
  704. }
  705. $this->chapter = $chapter;
  706. $this->book_info = $book_info;
  707. $this->cid = $cid;
  708. if ($this->balancePay($book_info, $chapter, $remind)) {
  709. ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  710. 'cid' => $cid, 'chapter_name' => $chapter->name]);
  711. $this->getChapter();
  712. return response()->item(new ChapterTransformer, $this->chapter);
  713. } else {
  714. $fee = $this->getPrice($book_info, $chapter);
  715. $data = [
  716. 'book_id' => $oldbid,
  717. 'book_name' => $book_info->book_name,
  718. 'chapter_name' => $chapter->name,
  719. 'chapter_id' => $cid,
  720. 'pay_type' => $book_info->charge_type,
  721. 'fee' => $fee,
  722. 'user_balance' => $this->_user_info['balance'],
  723. 'product_id' => $book_info->product_id,
  724. 'uid' => $this->uid,
  725. 'distribution_channel_id' => $this->distribution_channel_id,
  726. 'is_discount' => 0,
  727. 'discount_fee' => '',
  728. 'discount' => '',
  729. 'is_first_book_order'=>$this->is_first_book_order
  730. ];
  731. //不需要提醒
  732. if ($book_info->charge_type == 'BOOK') {
  733. return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
  734. } elseif ($book_info->charge_type == 'CHAPTER') {
  735. return response()->error('WAP_CHAPTER_SECOND_BALANCE_PAY', $data);
  736. } else {
  737. return response()->error('WAP_SYS_ERROR');
  738. }
  739. }
  740. }
  741. /**
  742. * 余额支付
  743. * @param $book_info
  744. * @param $chapter_id
  745. * @param $chapter_size
  746. * @return bool
  747. */
  748. protected function balancePay($book_info, $chapter, $is_remind)
  749. {
  750. $fee = $this->getPrice($book_info, $chapter);
  751. if ((int)$this->_user_info['balance'] >= $fee) {
  752. if ($this->bookOrderOrChapterOrder($book_info, $chapter->id, $fee, $chapter->name, $is_remind)) {
  753. $this->chapterOrderStats($fee);
  754. if($this->user){
  755. $this->user->balance -= $fee;
  756. }
  757. $this->customChapterOrderStats($fee);
  758. $this->crmChapterStats($fee);
  759. return true;
  760. }
  761. }
  762. return false;
  763. }
  764. /**
  765. * 获取章节内容
  766. * @param $bid
  767. * @param $cid
  768. * @return bool|mixed
  769. */
  770. private function getChapter()
  771. {
  772. //初始化 默认字段
  773. $this->initChapterDefaultField();
  774. //章节内容
  775. $chapter_content = ChapterService::getChapter($this->book_info->bid, $this->cid);
  776. //$this->chapter->content = str_replace($chapter_content->name, '', $chapter_content->content);
  777. $this->chapter->content = $chapter_content->content;
  778. //阅读记录
  779. if($this->chapter->sequence >= 2){
  780. ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $this->book_info->bid, 'book_name' => $this->book_info->book_name,
  781. 'cid' => $this->cid, 'chapter_name' => $this->chapter->name]);
  782. }
  783. //统计
  784. $this->chapterStats();
  785. //123特殊强关
  786. $this->specialSubscribeFlag();
  787. //签到奖励
  788. //$this->sign();
  789. //#短篇推送长篇需求#
  790. //$this->shortPushLong();
  791. //#短推长、短推短对比
  792. //$this->shortPushshort();
  793. //阅读器分享
  794. $this->share();
  795. //广告
  796. $this->isShowAd();
  797. //完整阅读纪录 阅读纪录
  798. $this->readRecordOther();
  799. }
  800. /**
  801. * 章节阅读接口需要配置返回的字段
  802. */
  803. private function initChapterDefaultField()
  804. {
  805. if (!$this->chapter) {
  806. return;
  807. }
  808. //内容
  809. $this->chapter->content = '';
  810. //签到默认字段
  811. $this->chapter->sign_days = 1;
  812. $this->chapter->sign_status = 0;
  813. $this->chapter->sign_reard = 0;
  814. $this->chapter->sign_version = 'v1';
  815. $this->chapter->sign_items = [];//只有v2签到才会用到的字段
  816. //#短篇推送长篇需求#
  817. $this->chapter->next_jump = 0;
  818. $this->chapter->next_jump_url = '';
  819. $this->chapter->show_push_title = 0;
  820. $this->chapter->push_title_url = '';
  821. $this->chapter->push_title = [];
  822. //分享
  823. $this->chapter->is_show_share_button = 0;
  824. //阅读底部强关图片 只有123有
  825. $this->chapter->is_had_subscribe = 0;
  826. //广告
  827. $this->chapter->is_show_ad = 0;//可不可点击
  828. $this->chapter->is_visiable_ad = 0;//可不可显示
  829. }
  830. private function sign()
  831. {
  832. //渠道123 未关注的签到放到强关前一章
  833. if ($this->distribution_channel_id == 123 && !$this->is_had_subscribe) {
  834. if ($this->book_info->force_subscribe_chapter_seq - 1 == $this->chapter->sequence) {
  835. $sign_status = $this->userSign($this->uid);
  836. //$sign_status = 0;
  837. $this->chapter->sign_status = $sign_status ? 1 : 0;
  838. $this->chapter->sign_reard = $sign_status;
  839. $this->chapter->sign_days = ReadRecordService::getSignCount($this->uid);
  840. if($this->chapter->sign_days && $this->chapter->sign_days>=8){
  841. $this->chapter->sign_items = $fee_pool = [50,50,120,50,50,50,150];
  842. }else{
  843. $this->chapter->sign_items = $fee_pool = [30,50,120,50,50,50,150];
  844. }
  845. }
  846. } else {
  847. $sign_status = $this->userSign($this->uid);
  848. //$sign_status =0;
  849. $this->chapter->sign_status = $sign_status ? 1 : 0;
  850. $this->chapter->sign_reard = $sign_status;
  851. $this->chapter->sign_days = ReadRecordService::getSignCount($this->uid);
  852. if($this->chapter->sign_days && $this->chapter->sign_days>=8){
  853. $this->chapter->sign_items = $fee_pool = [50,50,120,50,50,50,150];
  854. }else{
  855. $this->chapter->sign_items = $fee_pool = [30,50,120,50,50,50,150];
  856. }
  857. }
  858. }
  859. private function forceSubscribe()
  860. {
  861. if($this->need_subscribe_appid){
  862. $src = $this->getRcodeInfo(['appid' => $this->need_subscribe_appid], $this->book_info->bid);
  863. if (empty($src)) return false;
  864. $url = '/subscribe/qrcode?img=' . urlencode($src) . '&title=' . $this->need_subscribe_name . '&uid=' . $this->uid;
  865. return ['error_type' => 'WAP_NOT_SUBSCRIBE', 'data' => ['src' => $url, 'head_img' => '']];
  866. }
  867. //获取公众号信息
  868. $officialAccount = $this->getOfficialAccount();
  869. if (!$officialAccount || empty($officialAccount->appid)) {
  870. return false;
  871. }
  872. //如果是链接强关,则跳转
  873. $sub_type = $this->getSubscribeType($officialAccount->appid, $this->book_info->bid);
  874. if (in_array(3, $sub_type['type']) && $sub_type['url']) {
  875. return ['error_type' => 'WAP_LINK_SUBSCRIBE', 'data' => ['url' => $sub_type['url']]];
  876. }
  877. //普通强关
  878. if (in_array(1, $sub_type['type'])) {
  879. $src = $this->getRcodeInfo(['appid' => $officialAccount->appid], $this->book_info->bid);
  880. if (empty($src)) return false;
  881. if ($officialAccount->head_img) {
  882. $url = '/subscribe/qrcode?img=' . urlencode($src) . '&title=' . $officialAccount->nickname . '&head_img=' . urlencode($officialAccount->head_img) . '&uid=' . $this->uid;
  883. } else {
  884. $url = '/subscribe/qrcode?img=' . urlencode($src) . '&title=' . $officialAccount->nickname . '&uid=' . $this->uid;
  885. }
  886. return ['error_type' => 'WAP_NOT_SUBSCRIBE', 'data' => ['src' => $url, 'head_img' => $officialAccount->head_img]];
  887. }
  888. return false;
  889. }
  890. //强关页面的统计
  891. private function subscribeStats()
  892. {
  893. if ($this->send_order_id) {
  894. //$this->sendOrderSubscribePageUv($this->book_info->bid);
  895. //强关页面的uv
  896. /*try {
  897. Redis::sadd('subscribe_page_uv' . $this->send_order_id, $this->uid);
  898. Redis::sadd('subscribe_page_uv_send_order_ids', $this->send_order_id);
  899. } catch (\Exception $e) {
  900. }*/
  901. }
  902. }
  903. /**
  904. * 短推长
  905. */
  906. private function shortPushLong()
  907. {
  908. if ($this->book_info->charge_type = 'CHAPTER') return;
  909. $is_has_book_order = BookOrderService::isHasBookOrder($this->uid);
  910. if ($this->chapter->is_vip && $is_has_book_order) {
  911. $this->chapter->show_push_title = 1;
  912. $this->chapter->push_title = DataAnalysisBookConfig::getUserReaderPagePushBook($this->uid, $this->distribution_channel_id);
  913. }
  914. if (!$this->chapter->next_cid && $is_has_book_order) {
  915. $link = DataAnalysisBookConfig::getUserReaderPagePushBook($this->uid, $this->distribution_channel_id, 1);
  916. if ($link && isset($link['link']) && !empty($link['link'])) {
  917. $this->chapter->next_jump = 1;
  918. $this->chapter->next_jump_url = $link['link'];
  919. }
  920. }
  921. }
  922. /**
  923. * 短推长、短推短对比需求
  924. * 目标用户:全站短篇进入新注册且订阅短篇的付费用户
  925. * 方式:根据uid奇偶取用,奇:测试用户1 偶:测试用户2
  926. * 测试用户1:底部链接+完本推荐 均使用短篇小说
  927. * 测试用户2:底部链接+完本推荐 均使用长篇小说
  928. * 目标用户:全站短篇进入新注册且订阅短篇的付费用户
  929. */
  930. private function shortPushshort()
  931. {
  932. //新用户 注册时间大于某个值
  933. if(!$this->user){
  934. return ;
  935. }
  936. if(!env('SHORT_PUSH_SHORT_START_TIME') || strtotime($this->user->created_at) < env('SHORT_PUSH_SHORT_START_TIME')){
  937. return ;
  938. }
  939. //没有派单
  940. if(!$this->user->send_order_id) return ;
  941. //只在vip章节底部显示
  942. if(!$this->chapter->is_vip){
  943. return ;
  944. }
  945. //强关
  946. if(!$this->is_had_subscribe){
  947. return ;
  948. }
  949. //短篇进入
  950. $send_order_info = SendOrderService::getById($this->user->send_order_id);
  951. if(!$send_order_info || $send_order_info->charge_type != 'BOOK'){
  952. return ;
  953. }
  954. //订阅短篇的付费用户
  955. $is_has_book_order = BookOrderService::isHasBookOrder($this->uid);
  956. if(!$is_has_book_order) return ;
  957. //是否付费用户
  958. if(!OrderService::isPaidUser($this->uid)) return ;
  959. $type = $this->uid %2 == 1? 'BOOK':'CHAPTER';
  960. $result = DataAnalysisSelectUserService::create($this->uid, $this->distribution_channel_id, $type, 500, $attach = 'short2s2l');
  961. if(!$result) return ;
  962. //底部链接
  963. $this->chapter->show_push_title = 1;
  964. $this->chapter->push_title = DataAnalysisBookConfig::getUserReaderPagePushBookV2($this->uid, $this->distribution_channel_id,$type);
  965. //完本推荐
  966. if (!$this->chapter->next_cid ) {
  967. $link = DataAnalysisBookConfig::getUserReaderPagePushBookV2($this->uid, $this->distribution_channel_id,$type, 1);
  968. if($link && $link['link']){
  969. $this->chapter->next_jump = 1;
  970. $this->chapter->next_jump_url = $link['link'];
  971. }
  972. }
  973. }
  974. private function share()
  975. {
  976. if ($this->is_had_subscribe && in_array($this->distribution_channel_id, [2, 14, 211,4025,4147,691,123]) && $this->user) {//,4147,691,123,4025
  977. $this->chapter->is_show_share_button = 1;
  978. }
  979. }
  980. /**
  981. * 123 渠道阅读底部强关图片
  982. */
  983. private function specialSubscribeFlag()
  984. {
  985. if ($this->distribution_channel_id == 123 && !$this->is_had_subscribe) {
  986. $this->chapter->is_had_subscribe = 1;
  987. }
  988. }
  989. //订阅统计
  990. private function chapterOrderStats($fee)
  991. {
  992. $day = date('Y--m-d');
  993. try {
  994. Redis::hincrby('wap:chapterandbookorder:bid:' . $this->book_info->bid, $day, $fee);
  995. } catch (\Exception $e) {
  996. }
  997. $this->smartPushTestBook($this->book_info->bid, $fee);
  998. $specialChannelIdStats = env('SPECIAL_CHANNEL_STATS', 211);
  999. if (in_array($this->distribution_channel_id, explode(',', $specialChannelIdStats))) {
  1000. WapVisitStatService::specialChannelIdStatsSave($this->uid, $this->book_info->bid, $fee);
  1001. }
  1002. }
  1003. /**
  1004. * 签到
  1005. * @param $uid
  1006. * @return int
  1007. */
  1008. protected function userSign($uid)
  1009. {
  1010. if (UserSignService::isSign($uid)) {
  1011. //签过到了
  1012. return 0;
  1013. }
  1014. /*if(in_array($this->distribution_channel_id,explode(',',redisEnv('NEW_SIGN_CHANNELS','')))){
  1015. $version = UserSignService::getUserSignVersion($this->uid);
  1016. }else{
  1017. $version = 'v1';
  1018. }*/
  1019. $version = UserSignService::getUserSignVersion($this->uid);
  1020. $this->chapter->sign_version = $version;
  1021. if ($res = UserSignService::signToday($uid,$this->chapter->sign_version)) {
  1022. //$sign_key = 'leyuee:wap:usersigni';
  1023. //Redis::hset($sign_key, $uid, $res);
  1024. return $res;
  1025. }
  1026. return 0;
  1027. }
  1028. /**
  1029. * 添加订购记录
  1030. * @param $book_info
  1031. * @param $chapter_id
  1032. * @param $fee
  1033. * @return bool
  1034. */
  1035. protected function bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)
  1036. {
  1037. if ($book_info['charge_type'] == 'BOOK') {
  1038. $data = [
  1039. 'uid' => $this->uid,
  1040. 'fee' => $fee,
  1041. 'u' => Cookie::get('send_order_id'),
  1042. 'distribution_channel_id' => $this->distribution_channel_id,
  1043. 'bid' => $book_info->bid,
  1044. 'book_name' => $book_info->book_name,
  1045. 'send_order_id' => Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0,
  1046. ];
  1047. return BookOrderService::addOrderRecodeAndDecrUserBalance($data, $this->uid);
  1048. } else {
  1049. $data = [
  1050. 'uid' => $this->uid,
  1051. 'fee' => $fee,
  1052. 'cid' => $chapter_id,
  1053. 'bid' => $book_info->bid,
  1054. 'distribution_channel_id' => $this->distribution_channel_id,
  1055. 'book_name' => $book_info->book_name,
  1056. 'chapter_name' => $chapter_name,
  1057. 'send_order_id' => Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0,
  1058. 'is_remind' => $is_remind
  1059. ];
  1060. //print_r($data);
  1061. if ($is_remind) {
  1062. $this->addOrderRemind($book_info->bid);
  1063. }
  1064. return ChapterOrderService::addOrderAndDecrUserBalance($data, $this->uid);
  1065. }
  1066. }
  1067. protected function addOrderRemind($bid)
  1068. {
  1069. if (ChapterReminderService::checkIsNoReminder($this->uid, $bid)) {
  1070. return true;
  1071. } else {
  1072. ChapterReminderService::add($this->uid, $bid);
  1073. return true;
  1074. }
  1075. }
  1076. /**
  1077. * 是否订购提醒
  1078. * @param $chapter_id
  1079. * @return bool
  1080. */
  1081. protected function isOrderRemind($bid)
  1082. {
  1083. $is_no_reminder = ChapterReminderService::checkIsNoReminder($this->uid, $bid) ? 1 : 0;
  1084. return $is_no_reminder == 0;
  1085. }
  1086. /**
  1087. * 用户是否关注
  1088. * @param $uid
  1089. * @return bool
  1090. */
  1091. protected function getSubscribe()
  1092. {
  1093. $send_order_info = null;
  1094. if(!$this->send_order_id && Redis::hget('channel:setting:'.$this->distribution_channel_id,'no_send_order_subscribe')){
  1095. return true;
  1096. }
  1097. if($this->send_order_id){
  1098. $send_order_info = SendOrderService::getById($this->send_order_id);
  1099. }
  1100. $send_order_subscribe_status = Redis::hget('channel:setting:'.$this->distribution_channel_id,'send_order_subscribe');
  1101. /*if(is_null($send_order_subsribe_status)){
  1102. $send_order_subsribe_status = 0;
  1103. }*/
  1104. //$send_order_subscribe_status = 0;
  1105. if($send_order_subscribe_status &&
  1106. $send_order_info &&
  1107. $send_order_info->promotion_type == 'EXTERNAL' &&
  1108. $send_order_info->send_time &&
  1109. strtotime($send_order_info->send_time) >= 1557712800
  1110. ){
  1111. $subscribe_info = ForceSubscribeUserIService::subscribes($this->uid,$this->distribution_channel_id,$this->send_order_id);
  1112. $this->need_subscribe_appid = $subscribe_info['appid'];
  1113. $this->need_subscribe_name = $subscribe_info['name'];
  1114. return $subscribe_info['is_subscribed'];
  1115. }
  1116. if($send_order_info &&
  1117. $send_order_info->promotion_type == 'INTERNAL' &&
  1118. strtotime($send_order_info->created_at) > 1555488000){
  1119. return true;
  1120. }
  1121. $res = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
  1122. if ($res) {
  1123. $this->force_subscribe_time = isset($res->created_at)?$res->created_at:null;
  1124. return true;
  1125. }
  1126. return false;
  1127. }
  1128. /**
  1129. * 获取公众号信息
  1130. * @param $distribution_channel_id
  1131. */
  1132. protected function getOfficialAccount()
  1133. {
  1134. $distribution_channel_id = $this->distribution_channel_id;
  1135. $res = OfficialAccountService::canUseOfficialAccountByChannelId(compact('distribution_channel_id'));
  1136. if (isset($res->nickname) && !empty($res->nickname)) {
  1137. Cookie::queue('force_subscribe_name', $res->nickname, env('U_COOKIE_EXPIRE'));
  1138. }
  1139. return $res;
  1140. }
  1141. /**
  1142. * 获取二维码
  1143. * @param $param
  1144. * @return bool
  1145. */
  1146. private function getRcodeInfo($param, $bid)
  1147. {
  1148. //return "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGI8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyZEZ0T0ZoSHljM2kxOTUwQU5zY08AAgRF8-xbAwQAjScA";
  1149. $param_need = [
  1150. 'gzh_app_id' => $param['appid'],
  1151. 'scene_id' => $this->uid,
  1152. 'timestamp' => time(),
  1153. ];
  1154. $param_need['sign'] = $this->getSign($param_need);
  1155. $client = new Client(['timeout' => 3.0,]);
  1156. try {
  1157. Log::info('get qrcode url is:' . 'https://zsyauth.aizhuishu.com/api/get_qrcode_url?' . http_build_query($param_need));
  1158. $qrcode_url_res = $client->request('get', 'https://zsyauth.aizhuishu.com/api/get_qrcode_url?' . http_build_query($param_need))->getBody()->getContents();
  1159. if ($qrcode_url_res) {
  1160. $qrcode_url = json_decode($qrcode_url_res, true);
  1161. if ($qrcode_url['code'] == 1) {
  1162. //保存强关时的bid
  1163. if (isset($qrcode_url['data']) && !empty($qrcode_url['data'])) {
  1164. Redis::hset('force_subscribe_from_bid', $param['appid'] . '_' . $this->uid, $bid);
  1165. $send_order_id = Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0;
  1166. Redis::hset('force_subscribe_from_send_order_id', $param['appid'] . '_' . $this->uid, $send_order_id);
  1167. Log::info('uid is' . $this->uid . '--qrcode is:' . $qrcode_url['data']);
  1168. return $qrcode_url['data'];
  1169. }
  1170. }
  1171. }
  1172. } catch (\Exception $e) {
  1173. //\Log::info($e);
  1174. //Redis::sadd('force_subscribe_qrcode:error', $param['appid'] . '_' . time());
  1175. }
  1176. return false;
  1177. }
  1178. /**
  1179. * 获取订购记录
  1180. * @param $book_info
  1181. * @param $chapter_id
  1182. * @return bool
  1183. */
  1184. private function getOrderRecord($bid, $chapter_id)
  1185. {
  1186. //包年记录
  1187. $uid = $this->uid;
  1188. $res = YearOrderService::getRecord($uid);
  1189. if ($res) return true;
  1190. $res = null;
  1191. //单本订购记录
  1192. $res = BookOrderService::getRecordByuidBid($uid, $bid);
  1193. if ($res) return true;
  1194. $res = null;
  1195. //章节订购记录
  1196. $chapterOrder = new ChapterOrderService();
  1197. if ($chapterOrder->checkIsOrdered($uid, $bid, $chapter_id)) return true;
  1198. return false;
  1199. }
  1200. /**
  1201. * 计算价格
  1202. * @param $book_info
  1203. * @param $chapter_size
  1204. * @return float
  1205. */
  1206. private function getPrice($book_info, $chapter)
  1207. {
  1208. if ($book_info->charge_type == 'BOOK') {
  1209. if(BookOrderService::isHasBookOrder($this->uid)){
  1210. $this->is_first_book_order = 0;
  1211. return 1399;
  1212. }else{
  1213. $this->is_first_book_order = 1;
  1214. return 899;
  1215. }
  1216. } else {
  1217. //$fee = ceil($chapter->size/100);
  1218. //$channel_fee = BookService::getChapterPrice()
  1219. $channel_fee = BookService::getChapterPrice($this->distribution_channel_id);
  1220. if ($channel_fee) {
  1221. $price_rate = $channel_fee / 100;
  1222. } else {
  1223. //$price_rate = 0.012;
  1224. $price_rate = env('DEFAULT_CHAPTER_PRICE', 0.015);
  1225. }
  1226. //Log::info($price_rate);
  1227. $fee = ceil($chapter->size * $price_rate);
  1228. /*if($this->isRaisePrice()){
  1229. $fee = round($chapter->size * 0.018);
  1230. }*/
  1231. }
  1232. /*//首个计费章节书币价格以35书币为基准,低于35提升至35,原价高于35书币,维持原价
  1233. if (isset($chapter->sequence) && isset($book_info->vip_seq)) {
  1234. if ($chapter->sequence == $book_info->vip_seq) {
  1235. if ($fee < 35) {
  1236. $fee = 35;
  1237. }
  1238. }
  1239. }
  1240. //$template_10_site = redisEnv('TEMPLATE_10_SITE','');
  1241. list($template_10_site,$template_10_no_abtest_site) = redisEnvMulti('TEMPLATE_10_SITE','TEMPLATE_10_NO_AB_TEST_SITE');
  1242. $start_time = env('TEMPLATE_COMPARE_START_TIME', 0);
  1243. if($start_time && $template_10_site && in_array($this->distribution_channel_id,explode(',',$template_10_site))){
  1244. if($this->uid %2 == 0 && strtotime($this->user->created_at) > $start_time){
  1245. if($fee <37) $fee = 37;
  1246. if($fee >45) $fee = 45;
  1247. }
  1248. }
  1249. if($template_10_no_abtest_site &&
  1250. in_array($this->distribution_channel_id,explode(',',$template_10_no_abtest_site)) &&
  1251. ($info = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'TEMPLATE_COMPAREV10_2')) &&
  1252. $info->attach
  1253. ){
  1254. if($fee <37) $fee = 37;
  1255. if($fee >45) $fee = 45;
  1256. }*/
  1257. if($fee <37) $fee = 37;
  1258. if($fee >60) $fee = 60;
  1259. return $fee;
  1260. }
  1261. //降低付费用户书币价值
  1262. private function isRaisePrice(){
  1263. if(!$this->uid)
  1264. return false;
  1265. if(!$this->user)
  1266. return false;
  1267. if($this->user->balance < 100){
  1268. return false;
  1269. }
  1270. if(!in_array($this->distribution_channel_id,[211,123])){
  1271. return false;
  1272. }
  1273. if(DataAnalysisSelectUserService::getByUidAndType($this->uid,'RAISE')){
  1274. return true;
  1275. }
  1276. return false;
  1277. }
  1278. /**
  1279. * 获取强关章节数
  1280. * @param $book
  1281. * @return int
  1282. */
  1283. private function getSubscribeChapterNum($book)
  1284. {
  1285. $hour = date('G');
  1286. $send_order_info = null;
  1287. if(in_array($this->distribution_channel_id,[123,211]) && $this->send_order_id){
  1288. //开启落地页强关的需求有变,需要在链接实际推广1小时后就开启功能
  1289. $send_order_info = SendOrderService::getById($this->send_order_id);
  1290. if($send_order_info && $send_order_info->send_time && time()-strtotime($send_order_info->send_time) > 3600){
  1291. return 1;
  1292. }
  1293. }
  1294. if($this->send_order_id && $hour <=5 && in_array($this->send_order_id,[392216,392218,415200,415212,415163])){
  1295. return 1;
  1296. }
  1297. if($this->send_order_id && $hour <=5 && time()>1552233600 && in_array($this->send_order_id,[424454,424453,424452,424451,424450,424449,424448,424447,424446,424445,424444,424443,424442,424441,424440,424439,424438,424437,424436,424435,424434,424433,424432,424431,424430])){
  1298. return 1;
  1299. }
  1300. //派单强关
  1301. if ($this->send_order_id) {
  1302. $send_order_info || $send_order_info = SendOrderService::getById($this->send_order_id);
  1303. if ($send_order_info && $send_order_info->book_id == $book->bid && $send_order_info->subscribe_chapter_seq) {
  1304. return $send_order_info->subscribe_chapter_seq;
  1305. }
  1306. }
  1307. $subscribe = BookSubscribleChapterService::getSubcribleChapter($book->bid, $this->distribution_channel_id);
  1308. if ($subscribe) {
  1309. return (isset($subscribe->subscribe_chapter_id) && $subscribe->subscribe_chapter_id > 0) ? $subscribe->subscribe_chapter_id : $book->force_subscribe_chapter_seq;
  1310. }
  1311. return $book->force_subscribe_chapter_seq;
  1312. }
  1313. /**
  1314. * 判断访问的域名和数据库指定的域名是否一致,一致返回false ,不一致 true
  1315. * @param $domain 当前访问的doain
  1316. * @return bool
  1317. */
  1318. private function isVisitDomainNotEqualBookDomain($domain, $check_seq, $is_forced=false)
  1319. {
  1320. if($this->chapter->sequence <= $check_seq) return false;//判断check章节序号
  1321. $book_domain = $this->book_info->promotion_domain;
  1322. if(!$is_forced)
  1323. {
  1324. if ($domain == 'zhuishuyun' && stripos($book_domain, 'leyuee') !== false) {
  1325. return false;
  1326. }
  1327. }
  1328. return stripos($book_domain, $domain) === false;
  1329. }
  1330. //获取对当前图书对应域名的链接
  1331. private function getCorrespondBookUrl()
  1332. {
  1333. $url = sprintf(
  1334. 'https://site%s.%s/reader?bid=%s&cid=%s&send_order_id=%s&fromtype=%s&stats=2&crm=%s',
  1335. $this->en_distribution_channel_id,
  1336. $this->book_info->promotion_domain,
  1337. $this->en_bid,
  1338. $this->cid,
  1339. $this->send_order_id,
  1340. $this->from_type,
  1341. $this->crm
  1342. );
  1343. return $url;
  1344. }
  1345. /**
  1346. * 用户添加标签
  1347. * @param $book_info
  1348. */
  1349. private function addTag($book_info)
  1350. {
  1351. if (!UserDeepReadTagService::isAddTag($this->uid, $book_info->bid)) {
  1352. try {
  1353. UserDeepReadTagService::addTag([
  1354. 'uid' => $this->uid,
  1355. 'bid' => $book_info->bid,
  1356. 'book_name' => $book_info->book_name,
  1357. 'category_id' => $book_info->category_id,
  1358. 'category_name' => $book_info->category_name,
  1359. 'sex_preference' => $book_info->channel_name ? $book_info->channel_name : '',
  1360. 'distribution_channel_id' => $this->distribution_channel_id ? $this->distribution_channel_id : '0',
  1361. 'send_order_id' => Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0,
  1362. ]);
  1363. } catch (\Exception $e) {
  1364. }
  1365. }
  1366. }
  1367. private function newUserRewardRead()
  1368. {
  1369. $count = ChapterOrderService::getUserRecordCount($this->uid);
  1370. return $count > 2;
  1371. }
  1372. private function isBookOrdered($bid)
  1373. {
  1374. $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $bid);
  1375. if ($chapter_order) return true;
  1376. $res = BookOrderService::getRecordByuidBid($this->uid, $bid);
  1377. if ($res) return true;
  1378. return false;
  1379. }
  1380. private function beforeForceSubAndBeforeVipUvAndPv($book, $book_force_seq, $chapter)
  1381. {
  1382. $send_order_id = Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 14;
  1383. $prev_sub_seq = 0;
  1384. if ($book_force_seq) {
  1385. $prev_sub_seq = $book_force_seq - 1;
  1386. }
  1387. $prev_vip_seq = 0;
  1388. $date = date('Y-m-d');
  1389. if (isset($book->vip_seq) && !empty($book->vip_seq)) {
  1390. $prev_vip_seq = $book->vip_seq - 1;
  1391. }
  1392. if ($chapter->sequence == $prev_vip_seq) {
  1393. $uv_key = 'book:' . $book->bid . ':beforevip:uv:date:' . $date . ':send_order_id:' . $send_order_id;
  1394. $pv_key = 'book:' . $book->bid . ':beforevip:pv:send_order_id:' . $send_order_id;
  1395. Redis::hincrby($pv_key, $date, 1);
  1396. Redis::hincrby($pv_key, 'total', 1);
  1397. Redis::sadd($uv_key, $this->uid);
  1398. Redis::sadd('beforevip' . $date, $book->bid . '-' . $send_order_id);
  1399. }
  1400. if ($chapter->sequence == $prev_sub_seq) {
  1401. $uv_key = 'book:' . $book->bid . ':beforeforcesub:uv:date:' . $date . ':send_order_id:' . $send_order_id;
  1402. $pv_key = 'book:' . $book->bid . ':beforeforcesub::pvsend_order_id:' . $send_order_id;
  1403. Redis::hincrby($pv_key, $date, 1);
  1404. Redis::hincrby($pv_key, 'total', 1);
  1405. Redis::sadd($uv_key, $this->uid);
  1406. Redis::sadd('beforeforcesub' . $date, $book->bid . '-' . $send_order_id);
  1407. }
  1408. }
  1409. private function readRecordOther()
  1410. {
  1411. $bid = $this->book_info->bid;
  1412. $cid = $this->cid;
  1413. $distribution_channel_id = $this->distribution_channel_id;
  1414. $send_order_id = $this->send_order_id;
  1415. $from = $this->from_type;
  1416. $sequence = $this->chapter->sequence;
  1417. ReadRecordStatsService::record($this->uid,$bid,$cid,$distribution_channel_id,$send_order_id,$from,$sequence);
  1418. /*$chapter = $this->chapter;
  1419. try {
  1420. $data = [];
  1421. $data['uid'] = $this->uid;
  1422. $data['bid'] = $chapter->bid;
  1423. $data['cid'] = $chapter->id;
  1424. $data['is_vip'] = $chapter->is_vip;
  1425. $data['seq'] = $chapter->sequence;
  1426. $data['created_at'] = date('Y-m-d H:i:s');
  1427. $data['updated_at'] = date('Y-m-d H:i:s');
  1428. DB::table('read_records')->insert($data);
  1429. } catch (\Exception $e) {
  1430. }*/
  1431. }
  1432. /**
  1433. * 下架图书 true:下架不能阅读了, false:可以正常阅读
  1434. * @return bool
  1435. */
  1436. private function isOffShelf()
  1437. {
  1438. $book_info = $this->book_info;
  1439. //针对米玩站点部分图书放开
  1440. $miwan_sites = [4340,4834,4842,4992,5014,5021,5030,5035,5036,5037,5042,5043,5048,5049,5051,5066,5075,5094,5095,5096,5106,5110,5111,5112,5122,5131,5157,5167,5180,5189,5232,5234,5237,5238,5240];
  1441. if(in_array($this->distribution_channel_id,$miwan_sites) && in_array($book_info->bid,[1154,1232,1276,1295,1535,1542,1629,2430,4437,4730]))
  1442. {
  1443. return false;
  1444. }
  1445. if ($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3) {
  1446. return true;
  1447. }
  1448. //屏蔽一本书1042 2626
  1449. if (in_array($book_info->bid, [1042, 2626]) && $this->distribution_channel_id == 123) {
  1450. return true;
  1451. }
  1452. if ($book_info->is_on_shelf == 4) {
  1453. //版权到期,有阅读记录还可以继续阅读,订购
  1454. /*if (!ReadRecordService::getRecordByUidBid($this->uid, $book_info->bid)) {
  1455. return true;
  1456. }*/
  1457. //版权到期,有包年可以继续阅读
  1458. $year_order = YearOrderService::getRecord($this->uid);
  1459. if($year_order){
  1460. return false;
  1461. }
  1462. //1155
  1463. //版权到期,有订购记录还可以继续阅读,订购
  1464. $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $book_info->bid);
  1465. if (!$chapter_order) return true;
  1466. if($book_info->bid == 1155){
  1467. $charge_info = Order::where('uid',$this->uid)
  1468. ->where('price','>=',redisEnv('OFF_SHELF_BOOK_LIMIT_CHARGE',0))
  1469. ->where('from_bid',$book_info->bid)
  1470. ->where('status','PAID')
  1471. ->first();
  1472. if(!$charge_info){
  1473. return true;
  1474. }
  1475. }
  1476. }
  1477. if($book_info->is_on_shelf == 10){
  1478. //Log::info('ddddddddddddddddddddddddddd');
  1479. $yq_book_user = BookUserService::selectUser($this->uid);
  1480. //Log::info($yq_book_user);
  1481. if($yq_book_user && $yq_book_user->type == 'ENABLE'){
  1482. return false;
  1483. }
  1484. return true;
  1485. }
  1486. //crm上架
  1487. if($book_info->is_on_shelf == 5){
  1488. if(!CrmUserService::isCrmUser($this->uid,$this->is_paid)){
  1489. return true;
  1490. }
  1491. }
  1492. return false;
  1493. }
  1494. //章节被删除的情况
  1495. private function chapterNotExists()
  1496. {
  1497. $chapter = $this->chapter;
  1498. $cid = $this->cid;
  1499. if ($chapter) return false;
  1500. //章节不存在的情况
  1501. $no_check = ChapterService::getChapterNameByIdNoCheck($cid);
  1502. $h5_scheme = 'https';
  1503. if (!$no_check) {
  1504. //章节真正不存在的情况
  1505. $url = $h5_scheme . '://' . _domain() . '/catalog?id=' . $this->en_bid;
  1506. return $url;
  1507. }
  1508. //章节被删除的情况
  1509. // if ($no_check->next_cid) {
  1510. // $url = $h5_scheme . '://' . _domain() . '/reader?bid=' . $this->en_bid . '&cid=' . $no_check->next_cid;
  1511. // return $url;
  1512. // }
  1513. //章节被删除的是最后一章的情况
  1514. $url = $h5_scheme . '://' . _domain() . '/catalog?id=' . $this->en_bid;// . '&sequence=' . $no_check->sequence;
  1515. return $url;
  1516. }
  1517. /**
  1518. * 深度阅读
  1519. * @param $chapter
  1520. */
  1521. private function deepReadRecord()
  1522. {
  1523. if (!env('ON_BOOK_UV_PV', false)) {
  1524. return;
  1525. }
  1526. $chapter = $this->chapter;
  1527. $key = 'book:' . $chapter->bid . ':deepread:uv';
  1528. $chapter_key = 'book:' . $chapter->bid . ':chapterseq:' . $chapter->sequence;
  1529. if (Redis::scard($key) > 50000) {
  1530. if (Redis::Sismember($key, $this->uid)) {
  1531. Redis::sadd($chapter_key, $this->uid);
  1532. }
  1533. } else {
  1534. Redis::sadd($key, $this->uid);
  1535. Redis::sadd($chapter_key, $this->uid);
  1536. }
  1537. }
  1538. /**
  1539. * 强关类型
  1540. * @param $appid
  1541. * @return array
  1542. */
  1543. private function getSubscribeType($appid, $bid)
  1544. {
  1545. $send_order_id = Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0;
  1546. $sub_setting = ChannelSubscribeSettingService::getSubscribeTypeByAppId($appid);
  1547. if (!$sub_setting) return ['type' => [1], 'url' => ''];
  1548. $types = explode(',', $sub_setting->force_subscribe_type);
  1549. $url = '';
  1550. if (in_array(3, $types) && !empty($sub_setting->resource_url)) {
  1551. $h5_scheme = env('H5_SCHEME', 'https');
  1552. $url = $h5_scheme . '://' . _domain() . '/subscribeauth/?uid=' . $this->uid . '&distribution_channel_id=' . $this->distribution_channel_id . '&appid=' . $appid . '&bid=' . $bid . '&send_order_id=' . $send_order_id;
  1553. }
  1554. return ['type' => $types, 'url' => $url];
  1555. }
  1556. private function showChapterPrice($bid, $charge_type)
  1557. {
  1558. if ($charge_type == 'BOOK') {
  1559. return false;
  1560. }
  1561. $show_chapter_price_bid = env('SHOW_CHAPTER_PRICE_BID', 'all');
  1562. if ($show_chapter_price_bid != 'all') {
  1563. $show_chapter_price_bid_array = explode(',', $show_chapter_price_bid);
  1564. if (!in_array($bid, $show_chapter_price_bid_array)) {
  1565. return false;
  1566. }
  1567. }
  1568. $show_chapter_price_channel = env('SHOW_CHAPTER_PRICE_CHANNEL', '');
  1569. if (!$show_chapter_price_channel) {
  1570. return false;
  1571. }
  1572. if ($show_chapter_price_channel == 'all') {
  1573. return true;
  1574. }
  1575. $show_chapter_price_channel_array = explode(',', $show_chapter_price_channel);
  1576. if (in_array($this->distribution_channel_id, $show_chapter_price_channel_array)) {
  1577. return true;
  1578. }
  1579. return false;
  1580. }
  1581. /**
  1582. * 阅读统计
  1583. */
  1584. private function chapterStats()
  1585. {
  1586. $chapter = $this->chapter;
  1587. $bid = $this->book_info->bid;
  1588. //派单精确统计
  1589. if ($chapter->sequence <= 30) {
  1590. //$this->sendOrderChapterUv($bid, $chapter->sequence);
  1591. }
  1592. //智能推送 测书统计章节uv
  1593. if ($chapter->sequence <= 60) {
  1594. //测书数据 由30改到60 2018-11-26 18:00
  1595. if($this->book_info->test_status == 1){
  1596. $this->smartPushTestBookChapterUv($bid, $chapter->sequence); //2019-07-09 10:30 cancel
  1597. }
  1598. }
  1599. //智能推送 测书统计第二章 uv
  1600. if ($chapter->sequence == 2) {
  1601. $this->smartPushTestBookSecondChapterUv($bid);
  1602. }
  1603. // 统计前5张uv 会放在book_five_chapter_uv表中,脚本在 \App\Console\Commands\BookTest::data1里面
  1604. // 作用早忘记了
  1605. $field = date('Y-m-d');
  1606. /*
  1607. if ($chapter->sequence <= 5 && $this->send_order_id) {
  1608. try {
  1609. Redis::sadd(sprintf('book_before_five_uv_%s_%s_%s', $field, $bid, $chapter->sequence), $this->uid);
  1610. Redis::sadd('book_before_five_uvs', sprintf('%s_%s_%s', $field, $bid, $chapter->sequence));
  1611. } catch (\Exception $e) {
  1612. }
  1613. }*/
  1614. //统计点击率
  1615. $key = 'book_click_num_bid_' . $bid;
  1616. try {
  1617. Redis::HINCRBY($key, $field, 1);
  1618. } catch (\Exception $e) {
  1619. }
  1620. //阅读页面pvuv
  1621. $this->recordReaderUvAndPv();
  1622. }
  1623. private function smartPushTestBook($bid, $balance)
  1624. {
  1625. $smart_bid = ReadRecordService::getSmartPush($this->uid);
  1626. if ($smart_bid && in_array($bid, $smart_bid)) {
  1627. $field = sprintf('%s_amount', $bid);
  1628. try {
  1629. Redis::HINCRBY('smart_push_test_book', $field, $balance);
  1630. Redis::sadd('smart_push_test_book_user_count' . $bid, $this->uid);
  1631. } catch (\Exception $e) {
  1632. }
  1633. }
  1634. }
  1635. private function smartPushTestBookSecondChapterUv($bid)
  1636. {
  1637. $smart_bid = ReadRecordService::getSmartPush($this->uid);
  1638. if ($smart_bid && in_array($bid, $smart_bid)) {
  1639. try {
  1640. Redis::sadd('smart_push_test_book_second_uv' . $bid, $this->uid);
  1641. } catch (\Exception $e) {
  1642. }
  1643. }
  1644. }
  1645. private function smartPushTestBookChapterUv($bid, $sequence)
  1646. {
  1647. $smart_bid = ReadRecordService::getSmartPush($this->uid);
  1648. if ($smart_bid && in_array($bid, $smart_bid)) {
  1649. try {
  1650. $key = 'smartPushTestBookChapterUv:bid:%s:seq:%s';
  1651. Redis::sadd(sprintf($key, $bid, $sequence), $this->uid);
  1652. } catch (\Exception $e) {
  1653. }
  1654. }
  1655. }
  1656. /**
  1657. * 测书 智能推送统计
  1658. * @param $bid
  1659. */
  1660. private function smartPushTestBookPayPageUv($bid)
  1661. {
  1662. $smart_bid = ReadRecordService::getSmartPush($this->uid);
  1663. if ($smart_bid && in_array($bid, $smart_bid)) {
  1664. try {
  1665. $key = 'smartPushTestBookPayPageUv:bid:%s';
  1666. Redis::sadd(sprintf($key, $bid), $this->uid);
  1667. } catch (\Exception $e) {
  1668. }
  1669. }
  1670. }
  1671. /**
  1672. * 派单精确统计--章节
  1673. * @param $bid
  1674. * @param $sequence
  1675. */
  1676. private function sendOrderChapterUv($bid, $sequence)
  1677. {
  1678. if ($this->send_order_id) {
  1679. $send_order_bid = Redis::hget('sendOrderIdToBid', $this->send_order_id);
  1680. if (!$send_order_bid) {
  1681. $send_order_info = SendOrderService::getById($this->send_order_id);
  1682. if ($send_order_info) {
  1683. $send_order_bid = $send_order_info->book_id;
  1684. Redis::hset('sendOrderIdToBid', $this->send_order_id, $send_order_bid . '-' . time());
  1685. }
  1686. } else {
  1687. $send_order_bid_arr = explode('-', $send_order_bid);
  1688. $send_order_bid = $send_order_bid_arr[0];
  1689. }
  1690. if ($send_order_bid && $send_order_bid == $bid) {
  1691. try {
  1692. $key = 'accurateSendOrderChapterUv:bid:%s:seq:%s:sendorderid:' . $this->send_order_id;
  1693. Redis::sadd(sprintf($key, $bid, $sequence), $this->uid);
  1694. } catch (\Exception $e) {
  1695. }
  1696. }
  1697. }
  1698. }
  1699. /**
  1700. * 派单精确统计--强关页面uv
  1701. * @param $bid
  1702. */
  1703. private function sendOrderSubscribePageUv($bid)
  1704. {
  1705. if ($this->send_order_id) {
  1706. $send_order_bid = Redis::hget('sendOrderIdToBid', $this->send_order_id);
  1707. if (!$send_order_bid) {
  1708. $send_order_info = SendOrderService::getById($this->send_order_id);
  1709. if ($send_order_info) {
  1710. $send_order_bid = $send_order_info->book_id;
  1711. Redis::hset('sendOrderIdToBid', $this->send_order_id, $send_order_bid . '-' . time());
  1712. }
  1713. } else {
  1714. $send_order_bid_arr = explode('-', $send_order_bid);
  1715. $send_order_bid = $send_order_bid_arr[0];
  1716. }
  1717. if ($send_order_bid && $send_order_bid == $bid) {
  1718. try {
  1719. $key = 'accurateSendOrderSubscribePageUv:bid:%s:sendorderid:' . $this->send_order_id;
  1720. Redis::sadd(sprintf($key, $bid), $this->uid);
  1721. } catch (\Exception $e) {
  1722. }
  1723. }
  1724. }
  1725. }
  1726. /**
  1727. * 派单精确统计--支付页面uv
  1728. * @param $bid
  1729. */
  1730. private function sendOrderPayPageUv($bid)
  1731. {
  1732. if ($this->send_order_id) {
  1733. $send_order_bid = Redis::hget('sendOrderIdToBid', $this->send_order_id);
  1734. if (!$send_order_bid) {
  1735. $send_order_info = SendOrderService::getById($this->send_order_id);
  1736. if ($send_order_info) {
  1737. $send_order_bid = $send_order_info->book_id;
  1738. Redis::hset('sendOrderIdToBid', $this->send_order_id, $send_order_bid . '-' . time());
  1739. }
  1740. } else {
  1741. $send_order_bid_arr = explode('-', $send_order_bid);
  1742. $send_order_bid = $send_order_bid_arr[0];
  1743. }
  1744. if ($send_order_bid && $send_order_bid == $bid) {
  1745. try {
  1746. $key = 'accurateSendOrderPayPageUv:bid:%s:send_order_id:' . $this->send_order_id;
  1747. Redis::sadd(sprintf($key, $bid), $this->uid);
  1748. } catch (\Exception $e) {
  1749. }
  1750. }
  1751. }
  1752. }
  1753. private function recordReaderUvAndPv()
  1754. {
  1755. WapVisitStatService::recordReaderUvAndPv($this->uid, $this->distribution_channel_id);
  1756. }
  1757. //用户是否在广告样本中
  1758. private function isUserInAdSample(){
  1759. /*$res = DataAnalysisSelectUserService::getByUidAndType($this->uid,'AD_V2');
  1760. if($res){
  1761. return true;
  1762. }else{
  1763. return false;
  1764. }*/
  1765. $is_ad_user = Cookie::get('cpc_ad_status');
  1766. if($is_ad_user && $is_ad_user == 'show') return true;
  1767. return false;
  1768. }
  1769. //阅读页面底部是否显示广告
  1770. private function isShowAd(){
  1771. if (in_array($this->uid, explode(',', env('TEST_CPC_UID')))) {
  1772. $this->chapter->is_visiable_ad = 1;
  1773. if($this->chapter->is_vip){
  1774. $this->chapter->is_show_ad = 1;
  1775. }
  1776. return ;
  1777. }
  1778. $ad_status = env('AD_STATUS',1);
  1779. if(!$ad_status){
  1780. return ;
  1781. }
  1782. if(!$this->is_had_subscribe){
  1783. return ;
  1784. }
  1785. //if(!in_array($this->distribution_channel_id,[2,5,8,14,123,146,148,155,160,196,202,211,255,256,266,271,273,318,691,695,722,4025,4053,4174,4236,4237,4241,4334,4364,4426,4427,4487,4488,4593,4742,4889,4891,5204])){
  1786. $cpc_status = Redis::hget('channel:setting:'.$this->distribution_channel_id,'cpc_status');
  1787. if($cpc_status === '0'){
  1788. return ;
  1789. }
  1790. //按章付费才显示
  1791. if($this->book_info->charge_type != 'CHAPTER'){
  1792. return ;
  1793. }
  1794. //用户是否在广告样本中
  1795. //if(!$this->isUserInAdSample()) return ;
  1796. $is_ad_user = Cookie::get('cpc_ad_status');
  1797. if(!$is_ad_user || $is_ad_user != 'show') return ;
  1798. $cid = 0;
  1799. if($this->chapter && $this->chapter->next_cid){
  1800. $cid = $this->chapter->next_cid;
  1801. }
  1802. if(!$cid){
  1803. return ;
  1804. }
  1805. //付费用户没有广告
  1806. if(OrderService::isPaidUser($this->uid)) return ;
  1807. //如果下一张已经付费,广告不显示
  1808. /*$exists = AdVisitStatService::getByUid($this->uid);
  1809. if(!$exists){
  1810. if($this->uid %2 == 0){
  1811. DataAnalysisSelectUserService::create($this->uid,$this->distribution_channel_id,'AD_TEST_3',-1,'unshow');
  1812. return ;
  1813. }else{
  1814. DataAnalysisSelectUserService::create($this->uid,$this->distribution_channel_id,'AD_TEST_3',-1,'show');
  1815. }
  1816. }*/
  1817. //广告都显示
  1818. $this->chapter->is_visiable_ad = 1;
  1819. AdVisitStatService::create($this->uid,$this->book_info->bid,$this->cid,'EXPOSURE');
  1820. if($this->getOrderRecord($this->book_info->bid, $cid)){
  1821. return ;
  1822. }
  1823. $next_chapter = ChapterService::getChapterNameById($cid, $this->book_info->bid);
  1824. //下一章事vip的话 才显示广告
  1825. if(!$next_chapter || !$next_chapter->is_vip){
  1826. return ;
  1827. }
  1828. $price = $this->getPrice($this->book_info,$next_chapter);
  1829. $flag = $price > $this->user->balance;
  1830. if( $flag ){
  1831. $this->chapter->is_show_ad = 1;
  1832. AdVisitStatService::create($this->uid,$this->book_info->bid,$this->cid,'CAN_CLICK');
  1833. }
  1834. }
  1835. private function crmChapterStats($fee){
  1836. $crm = Cookie::get('crm');
  1837. if(!$crm)return ;
  1838. try{
  1839. CrmChapterOrderDetailService::create($this->uid,$fee,$this->book_info->bid,$crm);
  1840. }catch (\Exception $e){}
  1841. }
  1842. private function customChapterOrderStats($fee)
  1843. {
  1844. //custom_290824
  1845. Log::info('customChapterOrderStats start');
  1846. Log::info($this->from_type);
  1847. if(strpos($this->from_type,'custom') === false){
  1848. return ;
  1849. }
  1850. $customer_id= str_ireplace('custom_','',$this->from_type);
  1851. Log::info($customer_id);
  1852. if(!$customer_id || !is_numeric($customer_id)) return ;
  1853. $info = Redis::hget('latestcustomerinfo',$customer_id);
  1854. if(!$info) return ;
  1855. Log::info($info);
  1856. $info_array = json_decode($info,1);
  1857. Log::info($info_array);
  1858. $customer_bid = isset($info_array['bid'])?$info_array['bid']:0;
  1859. $customer_send_time = isset($info_array['send_time'])?$info_array['send_time']:0;
  1860. if(!$customer_bid || !$customer_send_time) return ;
  1861. CustomChapterOrderService::create([
  1862. 'distribution_channel_id'=>$this->distribution_channel_id,
  1863. 'bid'=>$this->book_info->bid,
  1864. 'cid'=>$this->cid,
  1865. 'book_name'=>$this->book_info->book_name,
  1866. 'chapter_name'=>$this->chapter->name,
  1867. 'uid'=>$this->uid,
  1868. 'send_order_id'=>$this->send_order_id,
  1869. 'fee'=>$fee,
  1870. 'charge_balance'=>0,
  1871. 'reward_balance'=>0,
  1872. 'custom_id'=>$customer_id,
  1873. 'flag'=>$customer_bid == $this->book_info->bid?1:0,
  1874. 'send_time'=>$customer_send_time
  1875. ]);
  1876. }
  1877. private function forceGuidePerson(){
  1878. //强制导粉
  1879. //$force_guide_sites = redisEnv('FORCE_GUIDE_SITES');
  1880. //$img = redisEnv('GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  1881. $flag = 1;
  1882. if(Redis::SISMEMBER('crm:out_channel_sites',$this->distribution_channel_id)){
  1883. $img = redisEnv('OUT_FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  1884. $force_guide_sites = $this->distribution_channel_id;
  1885. $group = 'OUT_FORCE';
  1886. $flag = Cookie::get('is_force_out_guide');
  1887. $flag = $flag?$flag:0;
  1888. }else{
  1889. list($force_guide_sites,$img) = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  1890. $group = 'FORCE';
  1891. }
  1892. if($flag && $force_guide_sites &&
  1893. $img &&
  1894. in_array($this->distribution_channel_id,explode(',',$force_guide_sites)) &&
  1895. $this->is_paid &&
  1896. ($this->chapter->sequence == 2 || $this->chapter->sequence == 8)&&
  1897. !UserBindHkWelfareService::isHasGet($this->uid) &&
  1898. ForceGuidePersonAccountService::isShow($this->uid,$this->book_info->bid,$this->cid)
  1899. ){
  1900. return sprintf('/force/guide?bid=%s&cid=%s&book_name=%s&prev_cid=%s',$this->en_bid,$this->cid,$this->book_info->book_name,$this->chapter->prev_cid);
  1901. }
  1902. return '';
  1903. }
  1904. public function getWechatJsConfig(Request $request)
  1905. {
  1906. //try {
  1907. // $chapter->is_show_share_button = 1;
  1908. $bid = $request->input('bid', '');
  1909. $cid = $request->input('cid', '');
  1910. $url = $request->input('url', '');
  1911. $url = urldecode($url);
  1912. \Log::info('url:' . ($this->uid) . $url);
  1913. if (empty($bid) || empty($cid) || empty($url)) {
  1914. return response()->error('PARAM_EMPTY');
  1915. }
  1916. $share_url = 'https://'._domain().'/detail?fromtype=readershare&id='.$bid.'&fromflag='.($this->uid).'&fromcid='.$cid;
  1917. //$js_config = ChapterShareWechatConfigService::getConfig($url);
  1918. $app_hash = array(
  1919. 4025=>['appid'=>'wx80b618c9dcc940f7','appsecret'=>'255a2de8db51e4084b5e9087d26d4ecb'],
  1920. 4147=>['appid'=>'wx2a99699cd9572812','appsecret'=>'0e0d57f94eeba50abb3af6883df05a5c'],
  1921. 691=>['appid'=>'wx5cefcd251dc40693','appsecret'=>'755f64c85173dad21f20870e38f59d8a'],
  1922. 123=>['appid'=>'wx983808610aa9dcc5','appsecret'=>'91002999590b79f3c7be35fd73c04049'],
  1923. 211=>['appid'=>'wx39338e374cc2055b','appsecret'=>'1a4c2039be271b3811182be5bb53eb34'],
  1924. );
  1925. $appId = $app_hash[$this->distribution_channel_id]['appid'];
  1926. $appSecret = $app_hash[$this->distribution_channel_id]['appsecret'];
  1927. $js_config = (new ChapterShareWechatConfigService($appId,$appSecret))->getSignPackage($url);
  1928. /*$appid = DB::table('official_accounts')->where('distribution_channel_id',$this->distribution_channel_id)->first();//(['distribution_channel_id'=>$this->distribution_channel_id]);
  1929. $appid = $appid->appid;
  1930. //\Log::info('get_appid:'.($appid));
  1931. $js_config = (new ChapterShareWechatConfigService($appid))->getSignPackage($url);
  1932. //$chapter->js_config = $js_config;
  1933. //$chapter->share_url = $share_url;
  1934. $book = BookService::getBookById(Hashids::decode($bid)[0]);
  1935. $first_cid = $book->first_cid;
  1936. $share_url = 'https://site' . encodeDistributionChannelId($this->distribution_channel_id) . '.' . env('SHARE_DOMAIN') . '/reader?fromtype=readershare&bid=' . $bid . '&cid=' . ($first_cid) . '&fromflag=' . ($this->uid) . '&fromcid=' . $cid;
  1937. /*if (in_array($this->uid, explode(',', env('TEST_SHARE_UIDS')))) {
  1938. $share_url = 'https://site5017zqeyzwgyx9n8.zhuishuyun.com/reader?fromtype=readershare&bid=' . $bid . '&fromflag=' . ($this->uid) . '&fromcid=' . $cid;
  1939. }*/
  1940. $book = BookService::getBookById(Hashids::decode($bid)[0]);
  1941. $first_cid = $book->first_cid;
  1942. $share_url = 'https://site' . encodeDistributionChannelId($this->distribution_channel_id) . '.' . env('SHARE_DOMAIN') . '/reader?fromtype=readershare&bid=' . $bid . '&cid=' . ($first_cid) . '&fromflag=' . ($this->uid) . '&fromcid=' . $cid;
  1943. if (in_array($this->distribution_channel_id, [2, 14])) {
  1944. $js_config = ChapterShareWechatConfigService::getConfig($url);
  1945. $share_url = 'https://site' . ($this->distribution_channel_id) . '.' . env('SHARE_DOMAIN') . '/reader?fromtype=readershare&bid=' . $bid . '&cid=' . ($first_cid) . '&fromflag=' . ($this->uid) . '&fromcid=' . $cid;
  1946. }
  1947. $js_config['share_url'] = $share_url;
  1948. /*} catch (\Exception $e) {
  1949. \Log::error($e->getMessage());
  1950. }*/
  1951. //\Log::info($js_config);
  1952. return response()->success($js_config);
  1953. }
  1954. }