ChapterController.php 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109
  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. //强制走leyuee.com
  406. if(in_array($bid,[5254,3354,3362,3624,3364,3366,3363,3347,3355,3367,3348,3358]))
  407. {
  408. $this->book_info->promotion_domain = 'leyuee.com';
  409. if(stripos($this->book_info->promotion_domain, $domain) === false){
  410. return response()->error('WAP_DOMAIN_NOT_MATCH', [
  411. 'url' => $this->getCorrespondBookUrl()
  412. ]);
  413. }
  414. }
  415. $temp_flag = false;
  416. //强制走iycdm.com
  417. if(in_array($bid,[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]))
  418. {
  419. $temp_flag = true;
  420. $this->book_info->promotion_domain = 'iycdm.com';
  421. }
  422. //图书域名,book_configs表的promotion_domain 要跟当前的主机名匹配 在强关章节后3章
  423. if ((($chapter->sequence > $subscribe_seq + 3) || $temp_flag) && $this->isVisitDomainEqualBookDomain($domain) ) {
  424. if($special_user_log && $special_user_log == $this->uid){
  425. $my_log = myLog('special');
  426. $my_log->info('book domain not match------------------------');
  427. }
  428. return response()->error('WAP_DOMAIN_NOT_MATCH', [
  429. 'url' => $this->getCorrespondBookUrl()
  430. ]);
  431. }
  432. if($special_user_log && $special_user_log == $this->uid){
  433. $my_log = myLog('special');
  434. $my_log->info('book domain jump--------------------------');
  435. }
  436. $user_info = $this->_user_info;
  437. $this->user = $user_info;
  438. //用户是否强关
  439. $this->is_had_subscribe = $is_had_subscribe = $inter_not_need_sub ? true : $this->getSubscribe();
  440. //判断当前是否有强制显示服务号信息的cookie、已经关注 跳转到服务号信息引导页
  441. if($has_force_show_qrcode_cookie && $is_had_subscribe)
  442. {
  443. if($special_user_log && $special_user_log == $this->uid){
  444. $my_log = myLog('special');
  445. $my_log->info('do not have force show qrcode cookie-------------------------');
  446. }
  447. $force_read_url = '/subscribe/getFromUser';//服务号信息引导页
  448. $force_read_data = ['src' => $force_read_url];
  449. return response()->error('WAP_NOT_SUBSCRIBE', $force_read_data);
  450. }
  451. if($special_user_log && $special_user_log == $this->uid){
  452. $my_log = myLog('special');
  453. $my_log->info('has force show qrcode cookie-ok-------------------------');
  454. }
  455. if ($force_subscribe || $chapter->is_vip == 0) {
  456. //vip前一张和枪管前一张的访问统计
  457. $this->beforeForceSubAndBeforeVipUvAndPv($book_info, $subscribe_seq, $chapter);
  458. }
  459. //不用关注且不是vip章节
  460. if ($force_subscribe && $chapter->is_vip == 0) {
  461. //获取公共号
  462. $officialAccount = $this->getOfficialAccount();
  463. $this->chapter->is_show_subscribe_link = 0;
  464. //非强关,但是设置了弱关,阅读页底部显示强关链接
  465. if ($officialAccount && isset($officialAccount->appid) && !empty($officialAccount->appid)) {
  466. $sub_type = $this->getSubscribeType($officialAccount->appid, $bid);
  467. if (in_array(2, $sub_type['type']) && !$is_had_subscribe) {
  468. $this->chapter->is_show_subscribe_link = 1;
  469. }
  470. }
  471. if($special_user_log && $special_user_log == $this->uid){
  472. $my_log = myLog('special');
  473. $my_log->info('do not force subscribe-and is not vip-------------------------');
  474. }
  475. $this->getChapter();
  476. return response()->item(new ChapterTransformer, $this->chapter);
  477. }
  478. if($special_user_log && $special_user_log == $this->uid){
  479. $my_log = myLog('special');
  480. $my_log->info('11111111111111111111111111111111111111111');
  481. }
  482. //需要强制关注 不是vip章节 已经关注了
  483. if (!$force_subscribe && $chapter->is_vip == 0 && $is_had_subscribe) {
  484. $this->getChapter();
  485. return response()->item(new ChapterTransformer, $this->chapter);
  486. }
  487. if($special_user_log && $special_user_log == $this->uid){
  488. $my_log = myLog('special');
  489. $my_log->info('222222222222222222222222222222222222222');
  490. }
  491. //需要强制关注 没关注
  492. if ((!$force_subscribe) && !$is_had_subscribe) {
  493. $force_data = $this->forceSubscribe();
  494. if ($force_data) {
  495. $this->subscribeStats();
  496. if($special_user_log && $special_user_log == $this->uid){
  497. $my_log = myLog('special');
  498. $my_log->info('need subscribe-------------------------');
  499. }
  500. //阅读记录
  501. ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  502. 'cid' => $cid, 'chapter_name' => $chapter->name]);
  503. return response()->error($force_data['error_type'], $force_data['data']);
  504. }
  505. //取不到公众号则不用强关
  506. if ($chapter->is_vip == 0) {
  507. $this->getChapter();
  508. if($special_user_log && $special_user_log == $this->uid){
  509. $my_log = myLog('special');
  510. $my_log->info('official fail--------------------------');
  511. }
  512. return response()->item(new ChapterTransformer, $this->chapter);
  513. }
  514. }
  515. if($special_user_log && $special_user_log == $this->uid){
  516. $my_log = myLog('special');
  517. $my_log->info('33333333333333333333333333333333333333333');
  518. }
  519. //已经付费
  520. if ($this->getOrderRecord($bid, $cid)) {
  521. $this->getChapter();
  522. if($special_user_log && $special_user_log == $this->uid){
  523. $my_log = myLog('special');
  524. $my_log->info('had order order record--------------------------');
  525. }
  526. return response()->item(new ChapterTransformer, $this->chapter);
  527. }
  528. if($special_user_log && $special_user_log == $this->uid){
  529. $my_log = myLog('special');
  530. $my_log->info('4444444444444444444444444444444444444444444');
  531. }
  532. //获取价格
  533. $fee = $this->getPrice($book_info, $chapter);
  534. //广告
  535. if($this->isUserInAdSample() && $ad_status && $ad_status == 1 && $user_info->balance < $fee){
  536. if($special_user_log && $special_user_log == $this->uid){
  537. $my_log = myLog('special');
  538. $my_log->info('ad-----in--------------------');
  539. }
  540. //广告解锁2张
  541. /*if($this->chapter->next_cid){
  542. $next_chapter = ChapterService::getChapterNameById($this->chapter->next_cid, $bid);
  543. if($next_chapter){
  544. $next_chapter_name = $next_chapter->name;
  545. $this->bookOrderOrChapterOrder($book_info, $this->chapter->next_cid, 0, $next_chapter_name, 1);
  546. AdVisitStatService::create($this->uid,$this->book_info->bid,$this->chapter->next_cid,'UNLOCK_2');
  547. }
  548. }*/
  549. //$this->chapter->is_show_ad = 0;
  550. $result = AdVisitStatService::getInfoV2($this->uid, $cid, ['UNLOCK', 'UNLOCK_2']);
  551. if ($result){
  552. $this->getChapter();
  553. $this->bookOrderOrChapterOrder($book_info, $cid, 0, $chapter->name, 1);
  554. return response()->item(new ChapterTransformer, $this->chapter);
  555. }
  556. }
  557. if($special_user_log && $special_user_log == $this->uid){
  558. $my_log = myLog('special');
  559. $my_log->info('5555555555555555555555555555555555');
  560. }
  561. //以上都是不用付费的情况******************************************************
  562. //未付费
  563. //返回的价格信息
  564. $data = [
  565. 'book_id' => $this->en_bid,
  566. 'book_name' => $book_info->book_name,
  567. 'chapter_name' => $chapter->name,
  568. 'chapter_id' => $cid,
  569. 'pay_type' => $book_info->charge_type,
  570. 'fee' => $fee,
  571. 'user_balance' => $user_info->balance,
  572. 'product_id' => $book_info->product_id,
  573. 'uid' => $this->uid,
  574. 'distribution_channel_id' => $this->distribution_channel_id,
  575. 'is_discount' => 0,
  576. 'discount_fee' => '',
  577. 'discount' => '',
  578. 'is_first_book_order'=>$this->is_first_book_order
  579. ];
  580. if($special_user_log && $special_user_log == $this->uid){
  581. $my_log = myLog('special');
  582. $my_log->info('data is:');
  583. $my_log->info($data);
  584. }
  585. //余额不足 弹窗提醒
  586. if ($user_info['balance'] < $fee) {
  587. if($special_user_log && $special_user_log == $this->uid){
  588. $my_log = myLog('special');
  589. $my_log->info('balance is lack');
  590. $my_log->info('user balance is: '.$user_info['balance']);
  591. $my_log->info('fee is: '.$fee);
  592. }
  593. //$this->smartPushTestBookPayPageUv($bid);
  594. //$this->sendOrderPayPageUv($bid);
  595. //除了单本订购 其他的都不提醒,直接跳转到充值页面
  596. if ($book_info->charge_type == 'CHAPTER') {
  597. if($special_user_log && $special_user_log == $this->uid){
  598. $my_log = myLog('special');
  599. $my_log->info('chapter order balance lack');
  600. }
  601. return response()->error('WAP_CHAPTER_SECOND_BALANCE_PAY', $data);
  602. }
  603. //需要提箱
  604. if ($this->isOrderRemind($bid)) {
  605. if($special_user_log && $special_user_log == $this->uid){
  606. $my_log = myLog('special');
  607. $my_log->info('balance lack remind');
  608. }
  609. return response()->error('WAP_BOOK_BALANCE_PAY', $data);
  610. //return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
  611. } else {
  612. if($special_user_log && $special_user_log == $this->uid){
  613. $my_log = myLog('special');
  614. $my_log->info('balance lack not remind');
  615. }
  616. return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
  617. }
  618. }
  619. if($special_user_log && $special_user_log == $this->uid){
  620. $my_log = myLog('special');
  621. $my_log->info('6666666666666666666666666666666666666');
  622. }
  623. //余额充足 单本弹窗提醒,章节直接扣费
  624. if ($this->isOrderRemind($bid) && $book_info->charge_type == 'BOOK') {
  625. if($special_user_log && $special_user_log == $this->uid){
  626. $my_log = myLog('special');
  627. $my_log->info('balance enough remind');
  628. }
  629. return response()->error('WAP_BOOK_BUY', $data);
  630. }
  631. if($special_user_log && $special_user_log == $this->uid){
  632. $my_log = myLog('special');
  633. $my_log->info('77777777777777777777777777777');
  634. }
  635. //付费 不提醒
  636. if ($this->balancePay($book_info, $chapter, 0)) {
  637. if($special_user_log && $special_user_log == $this->uid){
  638. $my_log = myLog('special');
  639. $my_log->info('balance pay ok-----');
  640. }
  641. $this->getChapter();
  642. return response()->item(new ChapterTransformer, $this->chapter);
  643. } else {
  644. if($special_user_log && $special_user_log == $this->uid){
  645. $my_log = myLog('special');
  646. $my_log->info('balance pay fails!!!!!!!!!!!!!!!!');
  647. }
  648. //付费 异常
  649. return response()->error('WAP_SYS_ERROR');
  650. }
  651. }
  652. /**
  653. * @apiVersion 1.0.0
  654. * @apiDescription 余额支付
  655. * @api {get} books/{bid}/balance/chapterOrders/{cid} 余额支付
  656. * @apiGroup Chapter
  657. * @apiName pay
  658. * @apiParam (Int) remind 提醒
  659. * @apiSuccess {int} code 状态码
  660. * @apiSuccess {String} msg 信息
  661. * @apiSuccess {object} data 结果集
  662. * @apiSuccess {Int} data.chapter_id 章节id
  663. * @apiSuccess {String} data.chapter_name 章节名称
  664. * @apiSuccess {Int} data.chapter_sequence 序号
  665. * @apiSuccess {Int} data.chapter_is_vip 是否vip
  666. * @apiSuccess {Int} data.chapter_size 章节大小
  667. * @apiSuccess {Int} data.prev_cid 上一章节id
  668. * @apiSuccess {Int} data.next_cid 下一章节
  669. * @apiSuccess {String} data.recent_update_at 更新时间
  670. * @apiSuccess {String} data.chapter_content 章节内容
  671. * @apiSuccess {Int} data.is_need_subscirbe 是否强制关注(删除)
  672. * @apiSuccessExample {json} Success-Response:
  673. * HTTP/1.1 200 OK
  674. * {
  675. * code: 0,
  676. * msg: "",
  677. * data: {
  678. * chapter_id: 5,
  679. * chapter_name: "第1240章 不是我",
  680. * chapter_sequence: 1239,
  681. * chapter_is_vip: 1,
  682. * chapter_size: 2422,
  683. * prev_cid: 0,
  684. * next_cid: 0,
  685. * recent_update_at: 2017-11-20 15:01:56,
  686. * chapter_content: "叶妩被司行霈的阴阳怪气一吓,思路偏得太远了。 她张口结舌,忘记了自己要说什么。",
  687. * }
  688. * }
  689. */
  690. public function pay(Request $request, $t, $domain, $bid, $cid)
  691. {
  692. if (!$this->checkUid()) {
  693. return response()->error('NOT_LOGIN');
  694. }
  695. $remind = (int)$request->input('remind');
  696. $this->en_bid = $bid;
  697. $oldbid = $bid;
  698. $bid = Hashids::decode($bid)[0];
  699. $book_info = BookConfigService::getBookById($bid);;
  700. if (empty($book_info)) response()->error('WAP_SYS_ERROR');
  701. //获取章节
  702. $chapter = ChapterService::getChapterNameById($cid, $bid);
  703. if (!$chapter) {
  704. return response()->error('WAP_SYS_ERROR');
  705. }
  706. $this->chapter = $chapter;
  707. $this->book_info = $book_info;
  708. $this->cid = $cid;
  709. if ($this->balancePay($book_info, $chapter, $remind)) {
  710. ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $bid, 'book_name' => $book_info->book_name,
  711. 'cid' => $cid, 'chapter_name' => $chapter->name]);
  712. $this->getChapter();
  713. return response()->item(new ChapterTransformer, $this->chapter);
  714. } else {
  715. $fee = $this->getPrice($book_info, $chapter);
  716. $data = [
  717. 'book_id' => $oldbid,
  718. 'book_name' => $book_info->book_name,
  719. 'chapter_name' => $chapter->name,
  720. 'chapter_id' => $cid,
  721. 'pay_type' => $book_info->charge_type,
  722. 'fee' => $fee,
  723. 'user_balance' => $this->_user_info['balance'],
  724. 'product_id' => $book_info->product_id,
  725. 'uid' => $this->uid,
  726. 'distribution_channel_id' => $this->distribution_channel_id,
  727. 'is_discount' => 0,
  728. 'discount_fee' => '',
  729. 'discount' => '',
  730. 'is_first_book_order'=>$this->is_first_book_order
  731. ];
  732. //不需要提醒
  733. if ($book_info->charge_type == 'BOOK') {
  734. return response()->error('WAP_BOOK_SECOND_BALANCE_PAY', $data);
  735. } elseif ($book_info->charge_type == 'CHAPTER') {
  736. return response()->error('WAP_CHAPTER_SECOND_BALANCE_PAY', $data);
  737. } else {
  738. return response()->error('WAP_SYS_ERROR');
  739. }
  740. }
  741. }
  742. /**
  743. * 余额支付
  744. * @param $book_info
  745. * @param $chapter_id
  746. * @param $chapter_size
  747. * @return bool
  748. */
  749. protected function balancePay($book_info, $chapter, $is_remind)
  750. {
  751. $fee = $this->getPrice($book_info, $chapter);
  752. if ((int)$this->_user_info['balance'] >= $fee) {
  753. if ($this->bookOrderOrChapterOrder($book_info, $chapter->id, $fee, $chapter->name, $is_remind)) {
  754. $this->chapterOrderStats($fee);
  755. if($this->user){
  756. $this->user->balance -= $fee;
  757. }
  758. $this->customChapterOrderStats($fee);
  759. $this->crmChapterStats($fee);
  760. return true;
  761. }
  762. }
  763. return false;
  764. }
  765. /**
  766. * 获取章节内容
  767. * @param $bid
  768. * @param $cid
  769. * @return bool|mixed
  770. */
  771. private function getChapter()
  772. {
  773. //初始化 默认字段
  774. $this->initChapterDefaultField();
  775. //章节内容
  776. $chapter_content = ChapterService::getChapter($this->book_info->bid, $this->cid);
  777. //$this->chapter->content = str_replace($chapter_content->name, '', $chapter_content->content);
  778. $this->chapter->content = $chapter_content->content;
  779. //阅读记录
  780. if($this->chapter->sequence >= 2){
  781. ReadRecordService::addReadRecord(['uid' => $this->uid, 'bid' => $this->book_info->bid, 'book_name' => $this->book_info->book_name,
  782. 'cid' => $this->cid, 'chapter_name' => $this->chapter->name]);
  783. }
  784. //统计
  785. $this->chapterStats();
  786. //123特殊强关
  787. $this->specialSubscribeFlag();
  788. //签到奖励
  789. //$this->sign();
  790. //#短篇推送长篇需求#
  791. //$this->shortPushLong();
  792. //#短推长、短推短对比
  793. //$this->shortPushshort();
  794. //阅读器分享
  795. $this->share();
  796. //广告
  797. $this->isShowAd();
  798. //完整阅读纪录 阅读纪录
  799. $this->readRecordOther();
  800. }
  801. /**
  802. * 章节阅读接口需要配置返回的字段
  803. */
  804. private function initChapterDefaultField()
  805. {
  806. if (!$this->chapter) {
  807. return;
  808. }
  809. //内容
  810. $this->chapter->content = '';
  811. //签到默认字段
  812. $this->chapter->sign_days = 1;
  813. $this->chapter->sign_status = 0;
  814. $this->chapter->sign_reard = 0;
  815. $this->chapter->sign_version = 'v1';
  816. $this->chapter->sign_items = [];//只有v2签到才会用到的字段
  817. //#短篇推送长篇需求#
  818. $this->chapter->next_jump = 0;
  819. $this->chapter->next_jump_url = '';
  820. $this->chapter->show_push_title = 0;
  821. $this->chapter->push_title_url = '';
  822. $this->chapter->push_title = [];
  823. //分享
  824. $this->chapter->is_show_share_button = 0;
  825. //阅读底部强关图片 只有123有
  826. $this->chapter->is_had_subscribe = 0;
  827. //广告
  828. $this->chapter->is_show_ad = 0;//可不可点击
  829. $this->chapter->is_visiable_ad = 0;//可不可显示
  830. }
  831. private function sign()
  832. {
  833. //渠道123 未关注的签到放到强关前一章
  834. if ($this->distribution_channel_id == 123 && !$this->is_had_subscribe) {
  835. if ($this->book_info->force_subscribe_chapter_seq - 1 == $this->chapter->sequence) {
  836. $sign_status = $this->userSign($this->uid);
  837. //$sign_status = 0;
  838. $this->chapter->sign_status = $sign_status ? 1 : 0;
  839. $this->chapter->sign_reard = $sign_status;
  840. $this->chapter->sign_days = ReadRecordService::getSignCount($this->uid);
  841. if($this->chapter->sign_days && $this->chapter->sign_days>=8){
  842. $this->chapter->sign_items = $fee_pool = [50,50,120,50,50,50,150];
  843. }else{
  844. $this->chapter->sign_items = $fee_pool = [30,50,120,50,50,50,150];
  845. }
  846. }
  847. } else {
  848. $sign_status = $this->userSign($this->uid);
  849. //$sign_status =0;
  850. $this->chapter->sign_status = $sign_status ? 1 : 0;
  851. $this->chapter->sign_reard = $sign_status;
  852. $this->chapter->sign_days = ReadRecordService::getSignCount($this->uid);
  853. if($this->chapter->sign_days && $this->chapter->sign_days>=8){
  854. $this->chapter->sign_items = $fee_pool = [50,50,120,50,50,50,150];
  855. }else{
  856. $this->chapter->sign_items = $fee_pool = [30,50,120,50,50,50,150];
  857. }
  858. }
  859. }
  860. private function forceSubscribe()
  861. {
  862. if($this->need_subscribe_appid){
  863. $src = $this->getRcodeInfo(['appid' => $this->need_subscribe_appid], $this->book_info->bid);
  864. if (empty($src)) return false;
  865. $url = '/subscribe/qrcode?img=' . urlencode($src) . '&title=' . $this->need_subscribe_name . '&uid=' . $this->uid;
  866. return ['error_type' => 'WAP_NOT_SUBSCRIBE', 'data' => ['src' => $url, 'head_img' => '']];
  867. }
  868. //获取公众号信息
  869. $officialAccount = $this->getOfficialAccount();
  870. if (!$officialAccount || empty($officialAccount->appid)) {
  871. return false;
  872. }
  873. //如果是链接强关,则跳转
  874. $sub_type = $this->getSubscribeType($officialAccount->appid, $this->book_info->bid);
  875. if (in_array(3, $sub_type['type']) && $sub_type['url']) {
  876. return ['error_type' => 'WAP_LINK_SUBSCRIBE', 'data' => ['url' => $sub_type['url']]];
  877. }
  878. //普通强关
  879. if (in_array(1, $sub_type['type'])) {
  880. $src = $this->getRcodeInfo(['appid' => $officialAccount->appid], $this->book_info->bid);
  881. if (empty($src)) return false;
  882. if ($officialAccount->head_img) {
  883. $url = '/subscribe/qrcode?img=' . urlencode($src) . '&title=' . $officialAccount->nickname . '&head_img=' . urlencode($officialAccount->head_img) . '&uid=' . $this->uid;
  884. } else {
  885. $url = '/subscribe/qrcode?img=' . urlencode($src) . '&title=' . $officialAccount->nickname . '&uid=' . $this->uid;
  886. }
  887. return ['error_type' => 'WAP_NOT_SUBSCRIBE', 'data' => ['src' => $url, 'head_img' => $officialAccount->head_img]];
  888. }
  889. return false;
  890. }
  891. //强关页面的统计
  892. private function subscribeStats()
  893. {
  894. if ($this->send_order_id) {
  895. //$this->sendOrderSubscribePageUv($this->book_info->bid);
  896. //强关页面的uv
  897. /*try {
  898. Redis::sadd('subscribe_page_uv' . $this->send_order_id, $this->uid);
  899. Redis::sadd('subscribe_page_uv_send_order_ids', $this->send_order_id);
  900. } catch (\Exception $e) {
  901. }*/
  902. }
  903. }
  904. /**
  905. * 短推长
  906. */
  907. private function shortPushLong()
  908. {
  909. if ($this->book_info->charge_type = 'CHAPTER') return;
  910. $is_has_book_order = BookOrderService::isHasBookOrder($this->uid);
  911. if ($this->chapter->is_vip && $is_has_book_order) {
  912. $this->chapter->show_push_title = 1;
  913. $this->chapter->push_title = DataAnalysisBookConfig::getUserReaderPagePushBook($this->uid, $this->distribution_channel_id);
  914. }
  915. if (!$this->chapter->next_cid && $is_has_book_order) {
  916. $link = DataAnalysisBookConfig::getUserReaderPagePushBook($this->uid, $this->distribution_channel_id, 1);
  917. if ($link && isset($link['link']) && !empty($link['link'])) {
  918. $this->chapter->next_jump = 1;
  919. $this->chapter->next_jump_url = $link['link'];
  920. }
  921. }
  922. }
  923. /**
  924. * 短推长、短推短对比需求
  925. * 目标用户:全站短篇进入新注册且订阅短篇的付费用户
  926. * 方式:根据uid奇偶取用,奇:测试用户1 偶:测试用户2
  927. * 测试用户1:底部链接+完本推荐 均使用短篇小说
  928. * 测试用户2:底部链接+完本推荐 均使用长篇小说
  929. * 目标用户:全站短篇进入新注册且订阅短篇的付费用户
  930. */
  931. private function shortPushshort()
  932. {
  933. //新用户 注册时间大于某个值
  934. if(!$this->user){
  935. return ;
  936. }
  937. if(!env('SHORT_PUSH_SHORT_START_TIME') || strtotime($this->user->created_at) < env('SHORT_PUSH_SHORT_START_TIME')){
  938. return ;
  939. }
  940. //没有派单
  941. if(!$this->user->send_order_id) return ;
  942. //只在vip章节底部显示
  943. if(!$this->chapter->is_vip){
  944. return ;
  945. }
  946. //强关
  947. if(!$this->is_had_subscribe){
  948. return ;
  949. }
  950. //短篇进入
  951. $send_order_info = SendOrderService::getById($this->user->send_order_id);
  952. if(!$send_order_info || $send_order_info->charge_type != 'BOOK'){
  953. return ;
  954. }
  955. //订阅短篇的付费用户
  956. $is_has_book_order = BookOrderService::isHasBookOrder($this->uid);
  957. if(!$is_has_book_order) return ;
  958. //是否付费用户
  959. if(!OrderService::isPaidUser($this->uid)) return ;
  960. $type = $this->uid %2 == 1? 'BOOK':'CHAPTER';
  961. $result = DataAnalysisSelectUserService::create($this->uid, $this->distribution_channel_id, $type, 500, $attach = 'short2s2l');
  962. if(!$result) return ;
  963. //底部链接
  964. $this->chapter->show_push_title = 1;
  965. $this->chapter->push_title = DataAnalysisBookConfig::getUserReaderPagePushBookV2($this->uid, $this->distribution_channel_id,$type);
  966. //完本推荐
  967. if (!$this->chapter->next_cid ) {
  968. $link = DataAnalysisBookConfig::getUserReaderPagePushBookV2($this->uid, $this->distribution_channel_id,$type, 1);
  969. if($link && $link['link']){
  970. $this->chapter->next_jump = 1;
  971. $this->chapter->next_jump_url = $link['link'];
  972. }
  973. }
  974. }
  975. private function share()
  976. {
  977. if ($this->is_had_subscribe && in_array($this->distribution_channel_id, [2, 14, 211,4025,4147,691,123]) && $this->user) {//,4147,691,123,4025
  978. $this->chapter->is_show_share_button = 1;
  979. }
  980. }
  981. /**
  982. * 123 渠道阅读底部强关图片
  983. */
  984. private function specialSubscribeFlag()
  985. {
  986. if ($this->distribution_channel_id == 123 && !$this->is_had_subscribe) {
  987. $this->chapter->is_had_subscribe = 1;
  988. }
  989. }
  990. //订阅统计
  991. private function chapterOrderStats($fee)
  992. {
  993. $day = date('Y--m-d');
  994. try {
  995. Redis::hincrby('wap:chapterandbookorder:bid:' . $this->book_info->bid, $day, $fee);
  996. } catch (\Exception $e) {
  997. }
  998. $this->smartPushTestBook($this->book_info->bid, $fee);
  999. $specialChannelIdStats = env('SPECIAL_CHANNEL_STATS', 211);
  1000. if (in_array($this->distribution_channel_id, explode(',', $specialChannelIdStats))) {
  1001. WapVisitStatService::specialChannelIdStatsSave($this->uid, $this->book_info->bid, $fee);
  1002. }
  1003. }
  1004. /**
  1005. * 签到
  1006. * @param $uid
  1007. * @return int
  1008. */
  1009. protected function userSign($uid)
  1010. {
  1011. if (UserSignService::isSign($uid)) {
  1012. //签过到了
  1013. return 0;
  1014. }
  1015. /*if(in_array($this->distribution_channel_id,explode(',',redisEnv('NEW_SIGN_CHANNELS','')))){
  1016. $version = UserSignService::getUserSignVersion($this->uid);
  1017. }else{
  1018. $version = 'v1';
  1019. }*/
  1020. $version = UserSignService::getUserSignVersion($this->uid);
  1021. $this->chapter->sign_version = $version;
  1022. if ($res = UserSignService::signToday($uid,$this->chapter->sign_version)) {
  1023. //$sign_key = 'leyuee:wap:usersigni';
  1024. //Redis::hset($sign_key, $uid, $res);
  1025. return $res;
  1026. }
  1027. return 0;
  1028. }
  1029. /**
  1030. * 添加订购记录
  1031. * @param $book_info
  1032. * @param $chapter_id
  1033. * @param $fee
  1034. * @return bool
  1035. */
  1036. protected function bookOrderOrChapterOrder($book_info, $chapter_id, $fee, $chapter_name, $is_remind)
  1037. {
  1038. if ($book_info['charge_type'] == 'BOOK') {
  1039. $data = [
  1040. 'uid' => $this->uid,
  1041. 'fee' => $fee,
  1042. 'u' => Cookie::get('send_order_id'),
  1043. 'distribution_channel_id' => $this->distribution_channel_id,
  1044. 'bid' => $book_info->bid,
  1045. 'book_name' => $book_info->book_name,
  1046. 'send_order_id' => Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0,
  1047. ];
  1048. return BookOrderService::addOrderRecodeAndDecrUserBalance($data, $this->uid);
  1049. } else {
  1050. $data = [
  1051. 'uid' => $this->uid,
  1052. 'fee' => $fee,
  1053. 'cid' => $chapter_id,
  1054. 'bid' => $book_info->bid,
  1055. 'distribution_channel_id' => $this->distribution_channel_id,
  1056. 'book_name' => $book_info->book_name,
  1057. 'chapter_name' => $chapter_name,
  1058. 'send_order_id' => Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0,
  1059. 'is_remind' => $is_remind
  1060. ];
  1061. //print_r($data);
  1062. if ($is_remind) {
  1063. $this->addOrderRemind($book_info->bid);
  1064. }
  1065. return ChapterOrderService::addOrderAndDecrUserBalance($data, $this->uid);
  1066. }
  1067. }
  1068. protected function addOrderRemind($bid)
  1069. {
  1070. if (ChapterReminderService::checkIsNoReminder($this->uid, $bid)) {
  1071. return true;
  1072. } else {
  1073. ChapterReminderService::add($this->uid, $bid);
  1074. return true;
  1075. }
  1076. }
  1077. /**
  1078. * 是否订购提醒
  1079. * @param $chapter_id
  1080. * @return bool
  1081. */
  1082. protected function isOrderRemind($bid)
  1083. {
  1084. $is_no_reminder = ChapterReminderService::checkIsNoReminder($this->uid, $bid) ? 1 : 0;
  1085. return $is_no_reminder == 0;
  1086. }
  1087. /**
  1088. * 用户是否关注
  1089. * @param $uid
  1090. * @return bool
  1091. */
  1092. protected function getSubscribe()
  1093. {
  1094. $send_order_info = null;
  1095. if(!$this->send_order_id && Redis::hget('channel:setting:'.$this->distribution_channel_id,'no_send_order_subscribe')){
  1096. return true;
  1097. }
  1098. if($this->send_order_id){
  1099. $send_order_info = SendOrderService::getById($this->send_order_id);
  1100. }
  1101. $send_order_subscribe_status = Redis::hget('channel:setting:'.$this->distribution_channel_id,'send_order_subscribe');
  1102. /*if(is_null($send_order_subsribe_status)){
  1103. $send_order_subsribe_status = 0;
  1104. }*/
  1105. //$send_order_subscribe_status = 0;
  1106. if($send_order_subscribe_status &&
  1107. $send_order_info &&
  1108. $send_order_info->promotion_type == 'EXTERNAL' &&
  1109. $send_order_info->send_time &&
  1110. strtotime($send_order_info->send_time) >= 1557712800
  1111. ){
  1112. $subscribe_info = ForceSubscribeUserIService::subscribes($this->uid,$this->distribution_channel_id,$this->send_order_id);
  1113. $this->need_subscribe_appid = $subscribe_info['appid'];
  1114. $this->need_subscribe_name = $subscribe_info['name'];
  1115. return $subscribe_info['is_subscribed'];
  1116. }
  1117. if($send_order_info &&
  1118. $send_order_info->promotion_type == 'INTERNAL' &&
  1119. strtotime($send_order_info->created_at) > 1555488000){
  1120. return true;
  1121. }
  1122. $res = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
  1123. if ($res) {
  1124. $this->force_subscribe_time = isset($res->created_at)?$res->created_at:null;
  1125. return true;
  1126. }
  1127. return false;
  1128. }
  1129. /**
  1130. * 获取公众号信息
  1131. * @param $distribution_channel_id
  1132. */
  1133. protected function getOfficialAccount()
  1134. {
  1135. $distribution_channel_id = $this->distribution_channel_id;
  1136. $res = OfficialAccountService::canUseOfficialAccountByChannelId(compact('distribution_channel_id'));
  1137. if (isset($res->nickname) && !empty($res->nickname)) {
  1138. Cookie::queue('force_subscribe_name', $res->nickname, env('U_COOKIE_EXPIRE'));
  1139. }
  1140. return $res;
  1141. }
  1142. /**
  1143. * 获取二维码
  1144. * @param $param
  1145. * @return bool
  1146. */
  1147. private function getRcodeInfo($param, $bid)
  1148. {
  1149. //return "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGI8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyZEZ0T0ZoSHljM2kxOTUwQU5zY08AAgRF8-xbAwQAjScA";
  1150. $param_need = [
  1151. 'gzh_app_id' => $param['appid'],
  1152. 'scene_id' => $this->uid,
  1153. 'timestamp' => time(),
  1154. ];
  1155. $param_need['sign'] = $this->getSign($param_need);
  1156. $client = new Client(['timeout' => 3.0,]);
  1157. try {
  1158. Log::info('get qrcode url is:' . 'https://zsyauth.aizhuishu.com/api/get_qrcode_url?' . http_build_query($param_need));
  1159. $qrcode_url_res = $client->request('get', 'https://zsyauth.aizhuishu.com/api/get_qrcode_url?' . http_build_query($param_need))->getBody()->getContents();
  1160. if ($qrcode_url_res) {
  1161. $qrcode_url = json_decode($qrcode_url_res, true);
  1162. if ($qrcode_url['code'] == 1) {
  1163. //保存强关时的bid
  1164. if (isset($qrcode_url['data']) && !empty($qrcode_url['data'])) {
  1165. Redis::hset('force_subscribe_from_bid', $param['appid'] . '_' . $this->uid, $bid);
  1166. $send_order_id = Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0;
  1167. Redis::hset('force_subscribe_from_send_order_id', $param['appid'] . '_' . $this->uid, $send_order_id);
  1168. Log::info('uid is' . $this->uid . '--qrcode is:' . $qrcode_url['data']);
  1169. return $qrcode_url['data'];
  1170. }
  1171. }
  1172. }
  1173. } catch (\Exception $e) {
  1174. //\Log::info($e);
  1175. //Redis::sadd('force_subscribe_qrcode:error', $param['appid'] . '_' . time());
  1176. }
  1177. return false;
  1178. }
  1179. /**
  1180. * 获取订购记录
  1181. * @param $book_info
  1182. * @param $chapter_id
  1183. * @return bool
  1184. */
  1185. private function getOrderRecord($bid, $chapter_id)
  1186. {
  1187. //包年记录
  1188. $uid = $this->uid;
  1189. $res = YearOrderService::getRecord($uid);
  1190. if ($res) return true;
  1191. $res = null;
  1192. //单本订购记录
  1193. $res = BookOrderService::getRecordByuidBid($uid, $bid);
  1194. if ($res) return true;
  1195. $res = null;
  1196. //章节订购记录
  1197. $chapterOrder = new ChapterOrderService();
  1198. if ($chapterOrder->checkIsOrdered($uid, $bid, $chapter_id)) return true;
  1199. return false;
  1200. }
  1201. /**
  1202. * 计算价格
  1203. * @param $book_info
  1204. * @param $chapter_size
  1205. * @return float
  1206. */
  1207. private function getPrice($book_info, $chapter)
  1208. {
  1209. if ($book_info->charge_type == 'BOOK') {
  1210. if(BookOrderService::isHasBookOrder($this->uid)){
  1211. $this->is_first_book_order = 0;
  1212. return 1399;
  1213. }else{
  1214. $this->is_first_book_order = 1;
  1215. return 899;
  1216. }
  1217. } else {
  1218. //$fee = ceil($chapter->size/100);
  1219. //$channel_fee = BookService::getChapterPrice()
  1220. $channel_fee = BookService::getChapterPrice($this->distribution_channel_id);
  1221. if ($channel_fee) {
  1222. $price_rate = $channel_fee / 100;
  1223. } else {
  1224. //$price_rate = 0.012;
  1225. $price_rate = env('DEFAULT_CHAPTER_PRICE', 0.015);
  1226. }
  1227. //Log::info($price_rate);
  1228. $fee = ceil($chapter->size * $price_rate);
  1229. /*if($this->isRaisePrice()){
  1230. $fee = round($chapter->size * 0.018);
  1231. }*/
  1232. }
  1233. /*//首个计费章节书币价格以35书币为基准,低于35提升至35,原价高于35书币,维持原价
  1234. if (isset($chapter->sequence) && isset($book_info->vip_seq)) {
  1235. if ($chapter->sequence == $book_info->vip_seq) {
  1236. if ($fee < 35) {
  1237. $fee = 35;
  1238. }
  1239. }
  1240. }
  1241. //$template_10_site = redisEnv('TEMPLATE_10_SITE','');
  1242. list($template_10_site,$template_10_no_abtest_site) = redisEnvMulti('TEMPLATE_10_SITE','TEMPLATE_10_NO_AB_TEST_SITE');
  1243. $start_time = env('TEMPLATE_COMPARE_START_TIME', 0);
  1244. if($start_time && $template_10_site && in_array($this->distribution_channel_id,explode(',',$template_10_site))){
  1245. if($this->uid %2 == 0 && strtotime($this->user->created_at) > $start_time){
  1246. if($fee <37) $fee = 37;
  1247. if($fee >45) $fee = 45;
  1248. }
  1249. }
  1250. if($template_10_no_abtest_site &&
  1251. in_array($this->distribution_channel_id,explode(',',$template_10_no_abtest_site)) &&
  1252. ($info = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'TEMPLATE_COMPAREV10_2')) &&
  1253. $info->attach
  1254. ){
  1255. if($fee <37) $fee = 37;
  1256. if($fee >45) $fee = 45;
  1257. }*/
  1258. if($fee <37) $fee = 37;
  1259. if($fee >60) $fee = 60;
  1260. return $fee;
  1261. }
  1262. //降低付费用户书币价值
  1263. private function isRaisePrice(){
  1264. if(!$this->uid)
  1265. return false;
  1266. if(!$this->user)
  1267. return false;
  1268. if($this->user->balance < 100){
  1269. return false;
  1270. }
  1271. if(!in_array($this->distribution_channel_id,[211,123])){
  1272. return false;
  1273. }
  1274. if(DataAnalysisSelectUserService::getByUidAndType($this->uid,'RAISE')){
  1275. return true;
  1276. }
  1277. return false;
  1278. }
  1279. /**
  1280. * 获取强关章节数
  1281. * @param $book
  1282. * @return int
  1283. */
  1284. private function getSubscribeChapterNum($book)
  1285. {
  1286. $hour = date('G');
  1287. $send_order_info = null;
  1288. if(in_array($this->distribution_channel_id,[123,211]) && $this->send_order_id){
  1289. //开启落地页强关的需求有变,需要在链接实际推广1小时后就开启功能
  1290. $send_order_info = SendOrderService::getById($this->send_order_id);
  1291. if($send_order_info && $send_order_info->send_time && time()-strtotime($send_order_info->send_time) > 3600){
  1292. return 1;
  1293. }
  1294. }
  1295. if($this->send_order_id && $hour <=5 && in_array($this->send_order_id,[392216,392218,415200,415212,415163])){
  1296. return 1;
  1297. }
  1298. 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])){
  1299. return 1;
  1300. }
  1301. //派单强关
  1302. if ($this->send_order_id) {
  1303. $send_order_info || $send_order_info = SendOrderService::getById($this->send_order_id);
  1304. if ($send_order_info && $send_order_info->book_id == $book->bid && $send_order_info->subscribe_chapter_seq) {
  1305. return $send_order_info->subscribe_chapter_seq;
  1306. }
  1307. }
  1308. $subscribe = BookSubscribleChapterService::getSubcribleChapter($book->bid, $this->distribution_channel_id);
  1309. if ($subscribe) {
  1310. return (isset($subscribe->subscribe_chapter_id) && $subscribe->subscribe_chapter_id > 0) ? $subscribe->subscribe_chapter_id : $book->force_subscribe_chapter_seq;
  1311. }
  1312. return $book->force_subscribe_chapter_seq;
  1313. }
  1314. /**
  1315. * 判断访问的域名和数据库指定的域名是否一致,一致返回false ,不一致 true
  1316. * @param $domain 当前访问的doain
  1317. * @return bool
  1318. */
  1319. private function isVisitDomainEqualBookDomain($domain)
  1320. {
  1321. $book_domain = $this->book_info->promotion_domain;
  1322. if ($domain == 'zhuishuyun' && stripos($book_domain, 'leyuee') !== false) {
  1323. return false;
  1324. }
  1325. return stripos($book_domain, $domain) === false;
  1326. }
  1327. //获取对当前图书对应域名的链接
  1328. private function getCorrespondBookUrl()
  1329. {
  1330. $url = sprintf(
  1331. 'https://site%s.%s/reader?bid=%s&cid=%s&send_order_id=%s&fromtype=%s&stats=2&crm=%s',
  1332. $this->en_distribution_channel_id,
  1333. $this->book_info->promotion_domain,
  1334. $this->en_bid,
  1335. $this->cid,
  1336. $this->send_order_id,
  1337. $this->from_type,
  1338. $this->crm
  1339. );
  1340. return $url;
  1341. }
  1342. /**
  1343. * 用户添加标签
  1344. * @param $book_info
  1345. */
  1346. private function addTag($book_info)
  1347. {
  1348. if (!UserDeepReadTagService::isAddTag($this->uid, $book_info->bid)) {
  1349. try {
  1350. UserDeepReadTagService::addTag([
  1351. 'uid' => $this->uid,
  1352. 'bid' => $book_info->bid,
  1353. 'book_name' => $book_info->book_name,
  1354. 'category_id' => $book_info->category_id,
  1355. 'category_name' => $book_info->category_name,
  1356. 'sex_preference' => $book_info->channel_name ? $book_info->channel_name : '',
  1357. 'distribution_channel_id' => $this->distribution_channel_id ? $this->distribution_channel_id : '0',
  1358. 'send_order_id' => Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0,
  1359. ]);
  1360. } catch (\Exception $e) {
  1361. }
  1362. }
  1363. }
  1364. private function newUserRewardRead()
  1365. {
  1366. $count = ChapterOrderService::getUserRecordCount($this->uid);
  1367. return $count > 2;
  1368. }
  1369. private function isBookOrdered($bid)
  1370. {
  1371. $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $bid);
  1372. if ($chapter_order) return true;
  1373. $res = BookOrderService::getRecordByuidBid($this->uid, $bid);
  1374. if ($res) return true;
  1375. return false;
  1376. }
  1377. private function beforeForceSubAndBeforeVipUvAndPv($book, $book_force_seq, $chapter)
  1378. {
  1379. $send_order_id = Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 14;
  1380. $prev_sub_seq = 0;
  1381. if ($book_force_seq) {
  1382. $prev_sub_seq = $book_force_seq - 1;
  1383. }
  1384. $prev_vip_seq = 0;
  1385. $date = date('Y-m-d');
  1386. if (isset($book->vip_seq) && !empty($book->vip_seq)) {
  1387. $prev_vip_seq = $book->vip_seq - 1;
  1388. }
  1389. if ($chapter->sequence == $prev_vip_seq) {
  1390. $uv_key = 'book:' . $book->bid . ':beforevip:uv:date:' . $date . ':send_order_id:' . $send_order_id;
  1391. $pv_key = 'book:' . $book->bid . ':beforevip:pv:send_order_id:' . $send_order_id;
  1392. Redis::hincrby($pv_key, $date, 1);
  1393. Redis::hincrby($pv_key, 'total', 1);
  1394. Redis::sadd($uv_key, $this->uid);
  1395. Redis::sadd('beforevip' . $date, $book->bid . '-' . $send_order_id);
  1396. }
  1397. if ($chapter->sequence == $prev_sub_seq) {
  1398. $uv_key = 'book:' . $book->bid . ':beforeforcesub:uv:date:' . $date . ':send_order_id:' . $send_order_id;
  1399. $pv_key = 'book:' . $book->bid . ':beforeforcesub::pvsend_order_id:' . $send_order_id;
  1400. Redis::hincrby($pv_key, $date, 1);
  1401. Redis::hincrby($pv_key, 'total', 1);
  1402. Redis::sadd($uv_key, $this->uid);
  1403. Redis::sadd('beforeforcesub' . $date, $book->bid . '-' . $send_order_id);
  1404. }
  1405. }
  1406. private function readRecordOther()
  1407. {
  1408. $bid = $this->book_info->bid;
  1409. $cid = $this->cid;
  1410. $distribution_channel_id = $this->distribution_channel_id;
  1411. $send_order_id = $this->send_order_id;
  1412. $from = $this->from_type;
  1413. $sequence = $this->chapter->sequence;
  1414. ReadRecordStatsService::record($this->uid,$bid,$cid,$distribution_channel_id,$send_order_id,$from,$sequence);
  1415. /*$chapter = $this->chapter;
  1416. try {
  1417. $data = [];
  1418. $data['uid'] = $this->uid;
  1419. $data['bid'] = $chapter->bid;
  1420. $data['cid'] = $chapter->id;
  1421. $data['is_vip'] = $chapter->is_vip;
  1422. $data['seq'] = $chapter->sequence;
  1423. $data['created_at'] = date('Y-m-d H:i:s');
  1424. $data['updated_at'] = date('Y-m-d H:i:s');
  1425. DB::table('read_records')->insert($data);
  1426. } catch (\Exception $e) {
  1427. }*/
  1428. }
  1429. /**
  1430. * 下架图书 true:下架不能阅读了, false:可以正常阅读
  1431. * @return bool
  1432. */
  1433. private function isOffShelf()
  1434. {
  1435. $book_info = $this->book_info;
  1436. //针对米玩站点部分图书放开
  1437. $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];
  1438. if(in_array($this->distribution_channel_id,$miwan_sites) && in_array($book_info->bid,[1154,1232,1276,1295,1535,1542,1629,2430,4437,4730]))
  1439. {
  1440. return false;
  1441. }
  1442. if ($book_info->is_on_shelf == 0 || $book_info->is_on_shelf == 3) {
  1443. return true;
  1444. }
  1445. //屏蔽一本书1042 2626
  1446. if (in_array($book_info->bid, [1042, 2626]) && $this->distribution_channel_id == 123) {
  1447. return true;
  1448. }
  1449. if ($book_info->is_on_shelf == 4) {
  1450. //版权到期,有阅读记录还可以继续阅读,订购
  1451. /*if (!ReadRecordService::getRecordByUidBid($this->uid, $book_info->bid)) {
  1452. return true;
  1453. }*/
  1454. //版权到期,有包年可以继续阅读
  1455. $year_order = YearOrderService::getRecord($this->uid);
  1456. if($year_order){
  1457. return false;
  1458. }
  1459. //1155
  1460. //版权到期,有订购记录还可以继续阅读,订购
  1461. $chapter_order = ChapterOrderService::checkBookIsOrdered($this->uid, $book_info->bid);
  1462. if (!$chapter_order) return true;
  1463. if($book_info->bid == 1155){
  1464. $charge_info = Order::where('uid',$this->uid)
  1465. ->where('price','>=',redisEnv('OFF_SHELF_BOOK_LIMIT_CHARGE',0))
  1466. ->where('from_bid',$book_info->bid)
  1467. ->where('status','PAID')
  1468. ->first();
  1469. if(!$charge_info){
  1470. return true;
  1471. }
  1472. }
  1473. }
  1474. if($book_info->is_on_shelf == 10){
  1475. //Log::info('ddddddddddddddddddddddddddd');
  1476. $yq_book_user = BookUserService::selectUser($this->uid);
  1477. //Log::info($yq_book_user);
  1478. if($yq_book_user && $yq_book_user->type == 'ENABLE'){
  1479. return false;
  1480. }
  1481. return true;
  1482. }
  1483. //crm上架
  1484. if($book_info->is_on_shelf == 5){
  1485. if(!CrmUserService::isCrmUser($this->uid,$this->is_paid)){
  1486. return true;
  1487. }
  1488. }
  1489. return false;
  1490. }
  1491. //章节被删除的情况
  1492. private function chapterNotExists()
  1493. {
  1494. $chapter = $this->chapter;
  1495. $cid = $this->cid;
  1496. if ($chapter) return false;
  1497. //章节不存在的情况
  1498. $no_check = ChapterService::getChapterNameByIdNoCheck($cid);
  1499. $h5_scheme = 'https';
  1500. if (!$no_check) {
  1501. //章节真正不存在的情况
  1502. $url = $h5_scheme . '://' . _domain() . '/catalog?id=' . $this->en_bid;
  1503. return $url;
  1504. }
  1505. //章节被删除的情况
  1506. // if ($no_check->next_cid) {
  1507. // $url = $h5_scheme . '://' . _domain() . '/reader?bid=' . $this->en_bid . '&cid=' . $no_check->next_cid;
  1508. // return $url;
  1509. // }
  1510. //章节被删除的是最后一章的情况
  1511. $url = $h5_scheme . '://' . _domain() . '/catalog?id=' . $this->en_bid;// . '&sequence=' . $no_check->sequence;
  1512. return $url;
  1513. }
  1514. /**
  1515. * 深度阅读
  1516. * @param $chapter
  1517. */
  1518. private function deepReadRecord()
  1519. {
  1520. if (!env('ON_BOOK_UV_PV', false)) {
  1521. return;
  1522. }
  1523. $chapter = $this->chapter;
  1524. $key = 'book:' . $chapter->bid . ':deepread:uv';
  1525. $chapter_key = 'book:' . $chapter->bid . ':chapterseq:' . $chapter->sequence;
  1526. if (Redis::scard($key) > 50000) {
  1527. if (Redis::Sismember($key, $this->uid)) {
  1528. Redis::sadd($chapter_key, $this->uid);
  1529. }
  1530. } else {
  1531. Redis::sadd($key, $this->uid);
  1532. Redis::sadd($chapter_key, $this->uid);
  1533. }
  1534. }
  1535. /**
  1536. * 强关类型
  1537. * @param $appid
  1538. * @return array
  1539. */
  1540. private function getSubscribeType($appid, $bid)
  1541. {
  1542. $send_order_id = Cookie::get('send_order_id') ? Cookie::get('send_order_id') : 0;
  1543. $sub_setting = ChannelSubscribeSettingService::getSubscribeTypeByAppId($appid);
  1544. if (!$sub_setting) return ['type' => [1], 'url' => ''];
  1545. $types = explode(',', $sub_setting->force_subscribe_type);
  1546. $url = '';
  1547. if (in_array(3, $types) && !empty($sub_setting->resource_url)) {
  1548. $h5_scheme = env('H5_SCHEME', 'https');
  1549. $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;
  1550. }
  1551. return ['type' => $types, 'url' => $url];
  1552. }
  1553. private function showChapterPrice($bid, $charge_type)
  1554. {
  1555. if ($charge_type == 'BOOK') {
  1556. return false;
  1557. }
  1558. $show_chapter_price_bid = env('SHOW_CHAPTER_PRICE_BID', 'all');
  1559. if ($show_chapter_price_bid != 'all') {
  1560. $show_chapter_price_bid_array = explode(',', $show_chapter_price_bid);
  1561. if (!in_array($bid, $show_chapter_price_bid_array)) {
  1562. return false;
  1563. }
  1564. }
  1565. $show_chapter_price_channel = env('SHOW_CHAPTER_PRICE_CHANNEL', '');
  1566. if (!$show_chapter_price_channel) {
  1567. return false;
  1568. }
  1569. if ($show_chapter_price_channel == 'all') {
  1570. return true;
  1571. }
  1572. $show_chapter_price_channel_array = explode(',', $show_chapter_price_channel);
  1573. if (in_array($this->distribution_channel_id, $show_chapter_price_channel_array)) {
  1574. return true;
  1575. }
  1576. return false;
  1577. }
  1578. /**
  1579. * 阅读统计
  1580. */
  1581. private function chapterStats()
  1582. {
  1583. $chapter = $this->chapter;
  1584. $bid = $this->book_info->bid;
  1585. //派单精确统计
  1586. if ($chapter->sequence <= 30) {
  1587. //$this->sendOrderChapterUv($bid, $chapter->sequence);
  1588. }
  1589. //智能推送 测书统计章节uv
  1590. if ($chapter->sequence <= 60) {
  1591. //测书数据 由30改到60 2018-11-26 18:00
  1592. if($this->book_info->test_status == 1){
  1593. $this->smartPushTestBookChapterUv($bid, $chapter->sequence); //2019-07-09 10:30 cancel
  1594. }
  1595. }
  1596. //智能推送 测书统计第二章 uv
  1597. if ($chapter->sequence == 2) {
  1598. $this->smartPushTestBookSecondChapterUv($bid);
  1599. }
  1600. // 统计前5张uv 会放在book_five_chapter_uv表中,脚本在 \App\Console\Commands\BookTest::data1里面
  1601. // 作用早忘记了
  1602. $field = date('Y-m-d');
  1603. /*
  1604. if ($chapter->sequence <= 5 && $this->send_order_id) {
  1605. try {
  1606. Redis::sadd(sprintf('book_before_five_uv_%s_%s_%s', $field, $bid, $chapter->sequence), $this->uid);
  1607. Redis::sadd('book_before_five_uvs', sprintf('%s_%s_%s', $field, $bid, $chapter->sequence));
  1608. } catch (\Exception $e) {
  1609. }
  1610. }*/
  1611. //统计点击率
  1612. $key = 'book_click_num_bid_' . $bid;
  1613. try {
  1614. Redis::HINCRBY($key, $field, 1);
  1615. } catch (\Exception $e) {
  1616. }
  1617. //阅读页面pvuv
  1618. $this->recordReaderUvAndPv();
  1619. }
  1620. private function smartPushTestBook($bid, $balance)
  1621. {
  1622. $smart_bid = ReadRecordService::getSmartPush($this->uid);
  1623. if ($smart_bid && in_array($bid, $smart_bid)) {
  1624. $field = sprintf('%s_amount', $bid);
  1625. try {
  1626. Redis::HINCRBY('smart_push_test_book', $field, $balance);
  1627. Redis::sadd('smart_push_test_book_user_count' . $bid, $this->uid);
  1628. } catch (\Exception $e) {
  1629. }
  1630. }
  1631. }
  1632. private function smartPushTestBookSecondChapterUv($bid)
  1633. {
  1634. $smart_bid = ReadRecordService::getSmartPush($this->uid);
  1635. if ($smart_bid && in_array($bid, $smart_bid)) {
  1636. try {
  1637. Redis::sadd('smart_push_test_book_second_uv' . $bid, $this->uid);
  1638. } catch (\Exception $e) {
  1639. }
  1640. }
  1641. }
  1642. private function smartPushTestBookChapterUv($bid, $sequence)
  1643. {
  1644. $smart_bid = ReadRecordService::getSmartPush($this->uid);
  1645. if ($smart_bid && in_array($bid, $smart_bid)) {
  1646. try {
  1647. $key = 'smartPushTestBookChapterUv:bid:%s:seq:%s';
  1648. Redis::sadd(sprintf($key, $bid, $sequence), $this->uid);
  1649. } catch (\Exception $e) {
  1650. }
  1651. }
  1652. }
  1653. /**
  1654. * 测书 智能推送统计
  1655. * @param $bid
  1656. */
  1657. private function smartPushTestBookPayPageUv($bid)
  1658. {
  1659. $smart_bid = ReadRecordService::getSmartPush($this->uid);
  1660. if ($smart_bid && in_array($bid, $smart_bid)) {
  1661. try {
  1662. $key = 'smartPushTestBookPayPageUv:bid:%s';
  1663. Redis::sadd(sprintf($key, $bid), $this->uid);
  1664. } catch (\Exception $e) {
  1665. }
  1666. }
  1667. }
  1668. /**
  1669. * 派单精确统计--章节
  1670. * @param $bid
  1671. * @param $sequence
  1672. */
  1673. private function sendOrderChapterUv($bid, $sequence)
  1674. {
  1675. if ($this->send_order_id) {
  1676. $send_order_bid = Redis::hget('sendOrderIdToBid', $this->send_order_id);
  1677. if (!$send_order_bid) {
  1678. $send_order_info = SendOrderService::getById($this->send_order_id);
  1679. if ($send_order_info) {
  1680. $send_order_bid = $send_order_info->book_id;
  1681. Redis::hset('sendOrderIdToBid', $this->send_order_id, $send_order_bid . '-' . time());
  1682. }
  1683. } else {
  1684. $send_order_bid_arr = explode('-', $send_order_bid);
  1685. $send_order_bid = $send_order_bid_arr[0];
  1686. }
  1687. if ($send_order_bid && $send_order_bid == $bid) {
  1688. try {
  1689. $key = 'accurateSendOrderChapterUv:bid:%s:seq:%s:sendorderid:' . $this->send_order_id;
  1690. Redis::sadd(sprintf($key, $bid, $sequence), $this->uid);
  1691. } catch (\Exception $e) {
  1692. }
  1693. }
  1694. }
  1695. }
  1696. /**
  1697. * 派单精确统计--强关页面uv
  1698. * @param $bid
  1699. */
  1700. private function sendOrderSubscribePageUv($bid)
  1701. {
  1702. if ($this->send_order_id) {
  1703. $send_order_bid = Redis::hget('sendOrderIdToBid', $this->send_order_id);
  1704. if (!$send_order_bid) {
  1705. $send_order_info = SendOrderService::getById($this->send_order_id);
  1706. if ($send_order_info) {
  1707. $send_order_bid = $send_order_info->book_id;
  1708. Redis::hset('sendOrderIdToBid', $this->send_order_id, $send_order_bid . '-' . time());
  1709. }
  1710. } else {
  1711. $send_order_bid_arr = explode('-', $send_order_bid);
  1712. $send_order_bid = $send_order_bid_arr[0];
  1713. }
  1714. if ($send_order_bid && $send_order_bid == $bid) {
  1715. try {
  1716. $key = 'accurateSendOrderSubscribePageUv:bid:%s:sendorderid:' . $this->send_order_id;
  1717. Redis::sadd(sprintf($key, $bid), $this->uid);
  1718. } catch (\Exception $e) {
  1719. }
  1720. }
  1721. }
  1722. }
  1723. /**
  1724. * 派单精确统计--支付页面uv
  1725. * @param $bid
  1726. */
  1727. private function sendOrderPayPageUv($bid)
  1728. {
  1729. if ($this->send_order_id) {
  1730. $send_order_bid = Redis::hget('sendOrderIdToBid', $this->send_order_id);
  1731. if (!$send_order_bid) {
  1732. $send_order_info = SendOrderService::getById($this->send_order_id);
  1733. if ($send_order_info) {
  1734. $send_order_bid = $send_order_info->book_id;
  1735. Redis::hset('sendOrderIdToBid', $this->send_order_id, $send_order_bid . '-' . time());
  1736. }
  1737. } else {
  1738. $send_order_bid_arr = explode('-', $send_order_bid);
  1739. $send_order_bid = $send_order_bid_arr[0];
  1740. }
  1741. if ($send_order_bid && $send_order_bid == $bid) {
  1742. try {
  1743. $key = 'accurateSendOrderPayPageUv:bid:%s:send_order_id:' . $this->send_order_id;
  1744. Redis::sadd(sprintf($key, $bid), $this->uid);
  1745. } catch (\Exception $e) {
  1746. }
  1747. }
  1748. }
  1749. }
  1750. private function recordReaderUvAndPv()
  1751. {
  1752. WapVisitStatService::recordReaderUvAndPv($this->uid, $this->distribution_channel_id);
  1753. }
  1754. //用户是否在广告样本中
  1755. private function isUserInAdSample(){
  1756. /*$res = DataAnalysisSelectUserService::getByUidAndType($this->uid,'AD_V2');
  1757. if($res){
  1758. return true;
  1759. }else{
  1760. return false;
  1761. }*/
  1762. $is_ad_user = Cookie::get('cpc_ad_status');
  1763. if($is_ad_user && $is_ad_user == 'show') return true;
  1764. return false;
  1765. }
  1766. //阅读页面底部是否显示广告
  1767. private function isShowAd(){
  1768. if (in_array($this->uid, explode(',', env('TEST_CPC_UID')))) {
  1769. $this->chapter->is_visiable_ad = 1;
  1770. if($this->chapter->is_vip){
  1771. $this->chapter->is_show_ad = 1;
  1772. }
  1773. return ;
  1774. }
  1775. $ad_status = env('AD_STATUS',1);
  1776. if(!$ad_status){
  1777. return ;
  1778. }
  1779. if(!$this->is_had_subscribe){
  1780. return ;
  1781. }
  1782. //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])){
  1783. $cpc_status = Redis::hget('channel:setting:'.$this->distribution_channel_id,'cpc_status');
  1784. if($cpc_status === '0'){
  1785. return ;
  1786. }
  1787. //按章付费才显示
  1788. if($this->book_info->charge_type != 'CHAPTER'){
  1789. return ;
  1790. }
  1791. //用户是否在广告样本中
  1792. //if(!$this->isUserInAdSample()) return ;
  1793. $is_ad_user = Cookie::get('cpc_ad_status');
  1794. if(!$is_ad_user || $is_ad_user != 'show') return ;
  1795. $cid = 0;
  1796. if($this->chapter && $this->chapter->next_cid){
  1797. $cid = $this->chapter->next_cid;
  1798. }
  1799. if(!$cid){
  1800. return ;
  1801. }
  1802. //付费用户没有广告
  1803. if(OrderService::isPaidUser($this->uid)) return ;
  1804. //如果下一张已经付费,广告不显示
  1805. /*$exists = AdVisitStatService::getByUid($this->uid);
  1806. if(!$exists){
  1807. if($this->uid %2 == 0){
  1808. DataAnalysisSelectUserService::create($this->uid,$this->distribution_channel_id,'AD_TEST_3',-1,'unshow');
  1809. return ;
  1810. }else{
  1811. DataAnalysisSelectUserService::create($this->uid,$this->distribution_channel_id,'AD_TEST_3',-1,'show');
  1812. }
  1813. }*/
  1814. //广告都显示
  1815. $this->chapter->is_visiable_ad = 1;
  1816. AdVisitStatService::create($this->uid,$this->book_info->bid,$this->cid,'EXPOSURE');
  1817. if($this->getOrderRecord($this->book_info->bid, $cid)){
  1818. return ;
  1819. }
  1820. $next_chapter = ChapterService::getChapterNameById($cid, $this->book_info->bid);
  1821. //下一章事vip的话 才显示广告
  1822. if(!$next_chapter || !$next_chapter->is_vip){
  1823. return ;
  1824. }
  1825. $price = $this->getPrice($this->book_info,$next_chapter);
  1826. $flag = $price > $this->user->balance;
  1827. if( $flag ){
  1828. $this->chapter->is_show_ad = 1;
  1829. AdVisitStatService::create($this->uid,$this->book_info->bid,$this->cid,'CAN_CLICK');
  1830. }
  1831. }
  1832. private function crmChapterStats($fee){
  1833. $crm = Cookie::get('crm');
  1834. if(!$crm)return ;
  1835. try{
  1836. CrmChapterOrderDetailService::create($this->uid,$fee,$this->book_info->bid,$crm);
  1837. }catch (\Exception $e){}
  1838. }
  1839. private function customChapterOrderStats($fee)
  1840. {
  1841. //custom_290824
  1842. Log::info('customChapterOrderStats start');
  1843. Log::info($this->from_type);
  1844. if(strpos($this->from_type,'custom') === false){
  1845. return ;
  1846. }
  1847. $customer_id= str_ireplace('custom_','',$this->from_type);
  1848. Log::info($customer_id);
  1849. if(!$customer_id || !is_numeric($customer_id)) return ;
  1850. $info = Redis::hget('latestcustomerinfo',$customer_id);
  1851. if(!$info) return ;
  1852. Log::info($info);
  1853. $info_array = json_decode($info,1);
  1854. Log::info($info_array);
  1855. $customer_bid = isset($info_array['bid'])?$info_array['bid']:0;
  1856. $customer_send_time = isset($info_array['send_time'])?$info_array['send_time']:0;
  1857. if(!$customer_bid || !$customer_send_time) return ;
  1858. CustomChapterOrderService::create([
  1859. 'distribution_channel_id'=>$this->distribution_channel_id,
  1860. 'bid'=>$this->book_info->bid,
  1861. 'cid'=>$this->cid,
  1862. 'book_name'=>$this->book_info->book_name,
  1863. 'chapter_name'=>$this->chapter->name,
  1864. 'uid'=>$this->uid,
  1865. 'send_order_id'=>$this->send_order_id,
  1866. 'fee'=>$fee,
  1867. 'charge_balance'=>0,
  1868. 'reward_balance'=>0,
  1869. 'custom_id'=>$customer_id,
  1870. 'flag'=>$customer_bid == $this->book_info->bid?1:0,
  1871. 'send_time'=>$customer_send_time
  1872. ]);
  1873. }
  1874. private function forceGuidePerson(){
  1875. //强制导粉
  1876. //$force_guide_sites = redisEnv('FORCE_GUIDE_SITES');
  1877. //$img = redisEnv('GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  1878. $flag = 1;
  1879. if(Redis::SISMEMBER('crm:out_channel_sites',$this->distribution_channel_id)){
  1880. $img = redisEnv('OUT_FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  1881. $force_guide_sites = $this->distribution_channel_id;
  1882. $group = 'OUT_FORCE';
  1883. $flag = Cookie::get('is_force_out_guide');
  1884. $flag = $flag?$flag:0;
  1885. }else{
  1886. list($force_guide_sites,$img) = redisEnvMulti('GUIDE_PERSONAL_ACCOUNT_SITES','FORCE_GUIDE_PERSONAL_ACCOUNT_OURS_QRCODE');
  1887. $group = 'FORCE';
  1888. }
  1889. if($flag && $force_guide_sites &&
  1890. $img &&
  1891. in_array($this->distribution_channel_id,explode(',',$force_guide_sites)) &&
  1892. $this->is_paid &&
  1893. ($this->chapter->sequence == 2 || $this->chapter->sequence == 8)&&
  1894. !UserBindHkWelfareService::isHasGet($this->uid) &&
  1895. ForceGuidePersonAccountService::isShow($this->uid,$this->book_info->bid,$this->cid)
  1896. ){
  1897. 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);
  1898. }
  1899. return '';
  1900. }
  1901. public function getWechatJsConfig(Request $request)
  1902. {
  1903. //try {
  1904. // $chapter->is_show_share_button = 1;
  1905. $bid = $request->input('bid', '');
  1906. $cid = $request->input('cid', '');
  1907. $url = $request->input('url', '');
  1908. $url = urldecode($url);
  1909. \Log::info('url:' . ($this->uid) . $url);
  1910. if (empty($bid) || empty($cid) || empty($url)) {
  1911. return response()->error('PARAM_EMPTY');
  1912. }
  1913. $share_url = 'https://'._domain().'/detail?fromtype=readershare&id='.$bid.'&fromflag='.($this->uid).'&fromcid='.$cid;
  1914. //$js_config = ChapterShareWechatConfigService::getConfig($url);
  1915. $app_hash = array(
  1916. 4025=>['appid'=>'wx80b618c9dcc940f7','appsecret'=>'255a2de8db51e4084b5e9087d26d4ecb'],
  1917. 4147=>['appid'=>'wx2a99699cd9572812','appsecret'=>'0e0d57f94eeba50abb3af6883df05a5c'],
  1918. 691=>['appid'=>'wx5cefcd251dc40693','appsecret'=>'755f64c85173dad21f20870e38f59d8a'],
  1919. 123=>['appid'=>'wx983808610aa9dcc5','appsecret'=>'91002999590b79f3c7be35fd73c04049'],
  1920. 211=>['appid'=>'wx39338e374cc2055b','appsecret'=>'1a4c2039be271b3811182be5bb53eb34'],
  1921. );
  1922. $appId = $app_hash[$this->distribution_channel_id]['appid'];
  1923. $appSecret = $app_hash[$this->distribution_channel_id]['appsecret'];
  1924. $js_config = (new ChapterShareWechatConfigService($appId,$appSecret))->getSignPackage($url);
  1925. /*$appid = DB::table('official_accounts')->where('distribution_channel_id',$this->distribution_channel_id)->first();//(['distribution_channel_id'=>$this->distribution_channel_id]);
  1926. $appid = $appid->appid;
  1927. //\Log::info('get_appid:'.($appid));
  1928. $js_config = (new ChapterShareWechatConfigService($appid))->getSignPackage($url);
  1929. //$chapter->js_config = $js_config;
  1930. //$chapter->share_url = $share_url;
  1931. $book = BookService::getBookById(Hashids::decode($bid)[0]);
  1932. $first_cid = $book->first_cid;
  1933. $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;
  1934. /*if (in_array($this->uid, explode(',', env('TEST_SHARE_UIDS')))) {
  1935. $share_url = 'https://site5017zqeyzwgyx9n8.zhuishuyun.com/reader?fromtype=readershare&bid=' . $bid . '&fromflag=' . ($this->uid) . '&fromcid=' . $cid;
  1936. }*/
  1937. $book = BookService::getBookById(Hashids::decode($bid)[0]);
  1938. $first_cid = $book->first_cid;
  1939. $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;
  1940. if (in_array($this->distribution_channel_id, [2, 14])) {
  1941. $js_config = ChapterShareWechatConfigService::getConfig($url);
  1942. $share_url = 'https://site' . ($this->distribution_channel_id) . '.' . env('SHARE_DOMAIN') . '/reader?fromtype=readershare&bid=' . $bid . '&cid=' . ($first_cid) . '&fromflag=' . ($this->uid) . '&fromcid=' . $cid;
  1943. }
  1944. $js_config['share_url'] = $share_url;
  1945. /*} catch (\Exception $e) {
  1946. \Log::error($e->getMessage());
  1947. }*/
  1948. //\Log::info($js_config);
  1949. return response()->success($js_config);
  1950. }
  1951. }