Poster.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\jielong\model;
  11. use app\model\BaseModel;
  12. use app\model\system\Config as ConfigModel;
  13. use app\model\system\Site;
  14. use app\model\upload\Upload;
  15. use extend\Poster as PosterExtend;
  16. /**
  17. * 海报生成类
  18. */
  19. class Poster extends BaseModel
  20. {
  21. /**
  22. * 接龙海报 用户端
  23. */
  24. public function goods($app_type, $page, $qrcode_param, $promotion_type, $site_id)
  25. {
  26. //根据不同的app_type 生成不同的分享地址 二维码
  27. try {
  28. $goods_info = $this->getGoodsInfo($qrcode_param[ 'jielong_id' ], $site_id);
  29. if (empty($goods_info)) return $this->error('未获取到商品信息');
  30. $weapp_status = 0;
  31. //判断是否绑定小程序
  32. if ($app_type == 'weapp') {
  33. $config = new ConfigModel();
  34. $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
  35. if (!empty($res[ 'data' ])) {
  36. if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
  37. return $this->success([ "status" => 2 ]);
  38. } else {
  39. $weapp_status = 1;
  40. }
  41. } else {
  42. return $this->success([ "status" => 2 ]);
  43. }
  44. }
  45. $qrcode_info = $this->getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id);
  46. if ($qrcode_info[ 'code' ] < 0) return $qrcode_info;
  47. if (!empty($qrcode_param[ 'source_member' ])) {
  48. $member_info = $this->getMemberInfo($qrcode_param[ 'source_member' ]);
  49. }
  50. //平台配置信息
  51. $site_model = new Site();
  52. $site_info = $site_model->getSiteInfo([ [ "site_id", "=", $site_id ] ]);
  53. $site_name = $site_info[ 'data' ][ 'site_name' ];
  54. $jielong_info = $goods_info[ 'jielong_info' ];
  55. $goods_info = $goods_info[ 'list' ];
  56. $poster = new PosterExtend(600, 960);
  57. $option = [
  58. [
  59. 'action' => 'imageCopy', // 背景图
  60. 'data' => [
  61. 'upload/poster/bg/jielong.png',
  62. 0,
  63. 0,
  64. 600,
  65. 960,
  66. 'square',
  67. true,
  68. 1
  69. ]
  70. ],
  71. [
  72. 'action' => 'imageCopy', // 二维码/太阳码
  73. 'data' => [
  74. $qrcode_info[ 'data' ][ 'path' ],
  75. $weapp_status ? 383 : 413, //x
  76. $weapp_status ? 740 : 770, //y
  77. $weapp_status ? 165 : 135,
  78. $weapp_status ? 165 : 135,
  79. 'square',
  80. 0,
  81. 1
  82. ]
  83. ],
  84. [
  85. 'action' => 'imageText', // 接龙时间
  86. 'data' => [
  87. $jielong_info[ 'jielong_time' ],
  88. 18,
  89. [ 255, 95, 75 ],
  90. 60,
  91. 845,
  92. 500,
  93. 1,
  94. true
  95. ]
  96. ],
  97. [
  98. 'action' => 'imageText', // 接龙状态
  99. 'data' => [
  100. $jielong_info[ 'jielong_status_name' ],
  101. 18,
  102. [ 18, 18, 18 ],
  103. 270,
  104. 845,
  105. 500,
  106. 1,
  107. true
  108. ]
  109. ],
  110. [
  111. 'action' => 'imageCircularCopy', // 写入店铺头像
  112. 'data' => [
  113. !empty($site_info[ 'data' ][ 'logo_square' ]) ? $site_info[ 'data' ][ 'logo_square' ] : 'public/uniapp/shop_img.png',
  114. 30,
  115. 40,
  116. 80,
  117. 80
  118. ]
  119. ],
  120. [
  121. 'action' => 'imageText', // 写入店铺名称
  122. 'data' => [
  123. !empty($site_name) ? $site_name : '单商户v5',
  124. 22,
  125. [ 255, 255, 255 ],
  126. 130,
  127. 80,
  128. 440,
  129. 1
  130. ]
  131. ],
  132. [
  133. 'action' => 'imageText', // 写入接龙语
  134. 'data' => [
  135. '"这个接龙不错,快和我一起参与吧!"',
  136. 18,
  137. [ 255, 255, 255 ],
  138. 130,
  139. 115,
  140. 440,
  141. 1
  142. ]
  143. ]
  144. ];
  145. $goods_option = [];
  146. $y = 0;
  147. foreach ($goods_info as &$v) {
  148. array_push($goods_option,
  149. [
  150. 'action' => 'imageCopy', // 商品图
  151. 'data' => [
  152. $v[ 'goods_image' ],
  153. 60,
  154. 190 + $y,//y
  155. 140,
  156. 140,
  157. 'square',
  158. 30,
  159. 1
  160. ]
  161. ],
  162. [
  163. 'action' => 'imageText', // 写入商品名称
  164. 'data' => [
  165. $v[ 'goods_name' ],
  166. 16,
  167. [ 89, 89, 89 ],
  168. 218,
  169. 225 + $y,//y
  170. 330,
  171. 2,
  172. true
  173. ]
  174. ],
  175. [
  176. 'action' => 'imageText', // 写入商品促销语
  177. 'data' => [
  178. $v[ 'introduction' ],
  179. 12,
  180. [ 205, 205, 205 ],
  181. 218,
  182. 287 + $y,//y
  183. 330,
  184. 1,
  185. true
  186. ]
  187. ],
  188. [
  189. 'action' => 'imageText', // 写入商品售价
  190. 'data' => [
  191. '¥ ' . $v[ 'discount_price' ],
  192. 20,
  193. [ 255, 95, 75 ],
  194. 218,
  195. 326 + $y,//y
  196. 500,
  197. 1,
  198. true
  199. ]
  200. ],
  201. [
  202. 'action' => 'imageText', // 写入商品原价
  203. 'data' => [
  204. '¥ ' . $v[ 'market_price' ],
  205. 16,
  206. [ 205, 205, 205 ],
  207. 340,
  208. 326 + $y,//y
  209. 500,
  210. 1,
  211. true,
  212. !empty($v[ 'is_market_price' ]) ? 1 : 0,
  213. ]
  214. ],
  215. [
  216. 'action' => 'imageCopy', // 删除线
  217. 'data' => [
  218. 'upload/poster/bg/del_line.png',
  219. 337,
  220. 283 + $y,//y
  221. 85,
  222. 64,
  223. 'square',
  224. true,
  225. !empty($v[ 'is_market_price' ]) ? 1 : 0,
  226. ]
  227. ]
  228. );
  229. $y += 180;
  230. }
  231. $option = array_merge($option, $goods_option);
  232. $option_res = $poster->create($option);
  233. if (is_array($option_res)) return $option_res;
  234. $res = $option_res->jpeg('upload/poster/jielong', 'goods_' . $promotion_type . '_' . $qrcode_param[ 'jielong_id' ] . '_' . time() . '_' . $app_type);
  235. if ($res[ 'code' ] == 0) {
  236. $upload = new Upload($site_id);
  237. $cloud_res = $upload->fileCloud($res[ 'data' ][ 'path' ]);
  238. if ($cloud_res[ 'code' ] >= 0) {
  239. if ($app_type == 'weapp') {
  240. return $this->success([ "poster_path" => $cloud_res[ 'data' ] . '?code=' . uniqid(), "qrcode_path" => $qrcode_info[ 'data' ][ 'path' ], "status" => $weapp_status ]);
  241. } else {
  242. return $this->success([ "poster_path" => $cloud_res[ 'data' ] . '?code=' . uniqid(), "qrcode_path" => $qrcode_info[ 'data' ][ 'path' ], "qrcode_url" => $qrcode_info[ 'data' ][ 'url' ] ]);
  243. }
  244. } else {
  245. return $this->error();
  246. }
  247. }
  248. return $res;
  249. } catch (\Exception $e) {
  250. return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
  251. }
  252. }
  253. /**
  254. * 接龙海报 管理端
  255. */
  256. public function goodsShop($app_type, $page, $qrcode_param, $promotion_type, $site_id)
  257. {
  258. //根据不同的app_type 生成不同的分享地址 二维码
  259. try {
  260. $goods_info = $this->getGoodsInfo($qrcode_param[ 'jielong_id' ], $site_id);
  261. if (empty($goods_info)) return $this->error('未获取到商品信息');
  262. //判断是否绑定小程序
  263. $config = new ConfigModel();
  264. $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
  265. $status = 0;
  266. if (!empty($res[ 'data' ])) {
  267. if (!empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
  268. $status = 1;
  269. }
  270. }
  271. //平台配置信息
  272. $site_model = new Site();
  273. $site_info = $site_model->getSiteInfo([ [ "site_id", "=", $site_id ] ]);
  274. $site_name = $site_info[ 'data' ][ 'site_name' ];
  275. $h5_qrcode_info = $this->getGoodsQrcode('h5', $page, $qrcode_param, $promotion_type, $site_id);
  276. if ($h5_qrcode_info[ 'code' ] < 0) return $h5_qrcode_info;
  277. $jielong_info = $goods_info[ 'jielong_info' ];
  278. $goods_info = $goods_info[ 'list' ];
  279. $poster = new PosterExtend(600, 960);
  280. $poster_2 = new PosterExtend(600, 960);
  281. $option = [
  282. [
  283. 'action' => 'imageCopy', // 背景图
  284. 'data' => [
  285. 'upload/poster/bg/jielong.png',
  286. 0,
  287. 0,
  288. 600,
  289. 960,
  290. 'square',
  291. true,
  292. 1
  293. ]
  294. ],
  295. [
  296. 'action' => 'imageCopy', // 二维码
  297. 'data' => [
  298. $h5_qrcode_info[ 'data' ][ 'path' ],
  299. 413, //x
  300. 770, //y
  301. 135,
  302. 135,
  303. 'square',
  304. 0,
  305. 1
  306. ]
  307. ],
  308. [
  309. 'action' => 'imageText', // 接龙时间
  310. 'data' => [
  311. $jielong_info[ 'jielong_time' ],
  312. 18,
  313. [ 255, 95, 75 ],
  314. 60,
  315. 845,
  316. 500,
  317. 1,
  318. true
  319. ]
  320. ],
  321. [
  322. 'action' => 'imageText', // 接龙状态
  323. 'data' => [
  324. $jielong_info[ 'jielong_status_name' ],
  325. 18,
  326. [ 18, 18, 18 ],
  327. 270,
  328. 845,
  329. 500,
  330. 1,
  331. true
  332. ]
  333. ],
  334. [
  335. 'action' => 'imageCircularCopy', // 写入店铺头像
  336. 'data' => [
  337. !empty($site_info[ 'data' ][ 'logo_square' ]) ? $site_info[ 'data' ][ 'logo_square' ] : 'public/uniapp/shop_img.png',
  338. 30,
  339. 40,
  340. 80,
  341. 80
  342. ]
  343. ],
  344. [
  345. 'action' => 'imageText', // 写入店铺名称
  346. 'data' => [
  347. !empty($site_name) ? $site_name : '单商户v5',
  348. 22,
  349. [ 255, 255, 255 ],
  350. 130,
  351. 80,
  352. 440,
  353. 1
  354. ]
  355. ],
  356. [
  357. 'action' => 'imageText', // 写入接龙语
  358. 'data' => [
  359. '"这个接龙不错,快和我一起参与吧!"',
  360. 18,
  361. [ 255, 255, 255 ],
  362. 130,
  363. 115,
  364. 440,
  365. 1
  366. ]
  367. ]
  368. ];
  369. $goods_option = [];
  370. $y = 0;
  371. foreach ($goods_info as &$v) {
  372. array_push($goods_option,
  373. [
  374. 'action' => 'imageCopy', // 商品图
  375. 'data' => [
  376. $v[ 'goods_image' ],
  377. 60,
  378. 190 + $y,//y
  379. 140,
  380. 140,
  381. 'square',
  382. 30,
  383. 1
  384. ]
  385. ],
  386. [
  387. 'action' => 'imageText', // 写入商品名称
  388. 'data' => [
  389. $v[ 'goods_name' ],
  390. 16,
  391. [ 89, 89, 89 ],
  392. 218,
  393. 225 + $y,//y
  394. 330,
  395. 2,
  396. true
  397. ]
  398. ],
  399. [
  400. 'action' => 'imageText', // 写入商品促销语
  401. 'data' => [
  402. $v[ 'introduction' ],
  403. 12,
  404. [ 205, 205, 205 ],
  405. 218,
  406. 287 + $y,//y
  407. 330,
  408. 1,
  409. true
  410. ]
  411. ],
  412. [
  413. 'action' => 'imageText', // 写入商品售价
  414. 'data' => [
  415. '¥ ' . $v[ 'discount_price' ],
  416. 20,
  417. [ 255, 95, 75 ],
  418. 218,
  419. 326 + $y,//y
  420. 500,
  421. 1,
  422. true
  423. ]
  424. ],
  425. [
  426. 'action' => 'imageText', // 写入商品原价
  427. 'data' => [
  428. '¥ ' . $v[ 'market_price' ],
  429. 16,
  430. [ 205, 205, 205 ],
  431. 340,
  432. 326 + $y,//y
  433. 500,
  434. 1,
  435. true,
  436. !empty($v[ 'is_market_price' ]) ? 1 : 0,
  437. ]
  438. ],
  439. [
  440. 'action' => 'imageCopy', // 删除线
  441. 'data' => [
  442. 'upload/poster/bg/del_line.png',
  443. 337,
  444. 283 + $y,//y
  445. 85,
  446. 64,
  447. 'square',
  448. true,
  449. !empty($v[ 'is_market_price' ]) ? 1 : 0,
  450. ]
  451. ]
  452. );
  453. $y += 180;
  454. }
  455. $option = array_merge($option, $goods_option);
  456. $option_res = $poster->create($option);
  457. if (is_array($option_res)) return $option_res;
  458. $res = $option_res->jpeg('upload/poster/jielong', 'goods_' . $promotion_type . '_' . $qrcode_param[ 'jielong_id' ] . rand(0, 99999) . '_' . 'h5');
  459. if ($status) {
  460. $weapp_qrcode_info = $this->getGoodsQrcode('weapp', $page, $qrcode_param, $promotion_type, $site_id);
  461. if ($weapp_qrcode_info[ 'code' ] < 0) return $weapp_qrcode_info;
  462. $option_2 = [
  463. [
  464. 'action' => 'imageCopy', // 背景图
  465. 'data' => [
  466. 'upload/poster/bg/jielong.png',
  467. 0,
  468. 0,
  469. 600,
  470. 960,
  471. 'square',
  472. true,
  473. 1
  474. ]
  475. ],
  476. [
  477. 'action' => 'imageCopy', //太阳码
  478. 'data' => [
  479. $weapp_qrcode_info[ 'data' ][ 'path' ],
  480. 383, //x
  481. 740, //y
  482. 165,
  483. 165,
  484. 'square',
  485. 0,
  486. 1
  487. ]
  488. ],
  489. [
  490. 'action' => 'imageText', // 接龙时间
  491. 'data' => [
  492. $jielong_info[ 'jielong_time' ],
  493. 18,
  494. [ 255, 95, 75 ],
  495. 60,
  496. 845,
  497. 500,
  498. 1,
  499. true
  500. ]
  501. ],
  502. [
  503. 'action' => 'imageText', // 接龙状态
  504. 'data' => [
  505. $jielong_info[ 'jielong_status_name' ],
  506. 18,
  507. [ 18, 18, 18 ],
  508. 270,
  509. 845,
  510. 500,
  511. 1,
  512. true
  513. ]
  514. ],
  515. [
  516. 'action' => 'imageCircularCopy', // 写入店铺头像
  517. 'data' => [
  518. 'public/uniapp/shop_img.png',
  519. 30,
  520. 40,
  521. 80,
  522. 80
  523. ]
  524. ],
  525. [
  526. 'action' => 'imageText', // 写入店铺名称
  527. 'data' => [
  528. !empty($site_name) ? $site_name : '单商户v5',
  529. 22,
  530. [ 255, 255, 255 ],
  531. 130,
  532. 80,
  533. 440,
  534. 1
  535. ]
  536. ],
  537. [
  538. 'action' => 'imageText', // 写入接龙语
  539. 'data' => [
  540. '"这个接龙不错,快和我一起参与吧!"',
  541. 18,
  542. [ 255, 255, 255 ],
  543. 130,
  544. 115,
  545. 440,
  546. 1
  547. ]
  548. ]
  549. ];
  550. $goods_option_2 = [];
  551. $y_2 = 0;
  552. foreach ($goods_info as &$v) {
  553. array_push($goods_option_2,
  554. [
  555. 'action' => 'imageCopy', // 商品图
  556. 'data' => [
  557. $v[ 'goods_image' ],
  558. 60,
  559. 190 + $y_2,//y
  560. 140,
  561. 140,
  562. 'square',
  563. 30,
  564. 1
  565. ]
  566. ],
  567. [
  568. 'action' => 'imageText', // 写入商品名称
  569. 'data' => [
  570. $v[ 'goods_name' ],
  571. 16,
  572. [ 89, 89, 89 ],
  573. 218,
  574. 225 + $y_2,//y
  575. 330,
  576. 2,
  577. true
  578. ]
  579. ],
  580. [
  581. 'action' => 'imageText', // 写入商品促销语
  582. 'data' => [
  583. $v[ 'introduction' ],
  584. 12,
  585. [ 205, 205, 205 ],
  586. 218,
  587. 287 + $y_2,//y
  588. 330,
  589. 1,
  590. true
  591. ]
  592. ],
  593. [
  594. 'action' => 'imageText', // 写入商品售价
  595. 'data' => [
  596. '¥ ' . $v[ 'discount_price' ],
  597. 20,
  598. [ 255, 95, 75 ],
  599. 218,
  600. 326 + $y_2,//y
  601. 500,
  602. 1,
  603. true
  604. ]
  605. ],
  606. [
  607. 'action' => 'imageText', // 写入商品原价
  608. 'data' => [
  609. '¥ ' . $v[ 'market_price' ],
  610. 16,
  611. [ 205, 205, 205 ],
  612. 340,
  613. 326 + $y_2,//y
  614. 500,
  615. 1,
  616. true,
  617. !empty($v[ 'is_market_price' ]) ? 1 : 0,
  618. ]
  619. ],
  620. [
  621. 'action' => 'imageCopy', // 删除线
  622. 'data' => [
  623. 'upload/poster/bg/del_line.png',
  624. 337,
  625. 283 + $y_2,//y
  626. 85,
  627. 64,
  628. 'square',
  629. true,
  630. !empty($v[ 'is_market_price' ]) ? 1 : 0,
  631. ]
  632. ]
  633. );
  634. $y_2 += 180;
  635. }
  636. $option_2 = array_merge($option_2, $goods_option_2);
  637. $option_res_2 = $poster_2->create($option_2);
  638. if (is_array($option_res_2)) return $option_res_2;
  639. $res_2 = $option_res_2->jpeg('upload/poster/jielong', 'goods_' . $promotion_type . '_' . $qrcode_param[ 'jielong_id' ] . rand(0, 999999) . '_' . 'weapp');
  640. }
  641. //if中的三元运算用法 true or 1==1 均可
  642. if ($res[ 'code' ] == 0 && ( $status ? $res_2[ 'code' ] == 0 : true )) {
  643. $upload = new Upload($site_id);
  644. $cloud_res = $upload->fileCloud($res[ 'data' ][ 'path' ]);
  645. if ($status) {
  646. $cloud_res_2 = $upload->fileCloud($res_2[ 'data' ][ 'path' ]);
  647. }
  648. if ($cloud_res[ 'code' ] >= 0 && ( $status ? $cloud_res_2[ 'code' ] >= 0 : 1 == 1 )) {
  649. $data = [
  650. 'h5_poster_path' => $cloud_res[ 'data' ],
  651. 'h5_qrcode_path' => $h5_qrcode_info[ 'data' ][ 'path' ],
  652. 'h5_qrcode_url' => $h5_qrcode_info[ 'data' ][ 'url' ],
  653. 'weapp_poster_path' => $status ? $cloud_res_2[ 'data' ] : '',
  654. 'weapp_qrcode_path' => $status ? $weapp_qrcode_info[ 'data' ][ 'path' ] : '',
  655. 'status' => $status,
  656. 'code' => uniqid()
  657. ];
  658. return $this->success($data);
  659. } else {
  660. return $this->error();
  661. }
  662. }
  663. return $res;
  664. } catch (\Exception $e) {
  665. return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
  666. }
  667. }
  668. /**
  669. * 获取用户信息
  670. * @param unknown $member_id
  671. */
  672. private function getMemberInfo($member_id)
  673. {
  674. $info = model('member')->getInfo([ 'member_id' => $member_id ], 'nickname,headimg');
  675. return $info;
  676. }
  677. /**
  678. * 获取商品信息
  679. * @param unknown $jielong_id
  680. */
  681. private function getGoodsInfo($jielong_id, $site_id)
  682. {
  683. $condition = [
  684. [ 'pjg.jielong_id', '=', $jielong_id ],
  685. [ 'g.goods_state', '=', 1 ],
  686. [ 'g.is_delete', '=', 0 ],
  687. [ 'g.site_id', '=', $site_id ]
  688. ];
  689. $alias = 'pjg';
  690. $join = [
  691. [ 'goods g', 'pjg.goods_id = g.goods_id', 'inner' ],
  692. [ 'goods_sku gs', 'g.sku_id = gs.sku_id', 'inner' ]
  693. ];
  694. $field = 'g.goods_image,g.goods_name,g.goods_stock,gs.price,gs.market_price,gs.discount_price,g.introduction';
  695. //接龙活动中商品信息
  696. $list = model('promotion_jielong_goods')->pageList($condition, $field, 'id asc', 1, 3, $alias, $join);
  697. $info = model('promotion_jielong')->getInfo([ 'jielong_id' => $jielong_id ], 'status,start_time,end_time');
  698. if ($info[ 'status' ] == 0) {
  699. $list[ 'jielong_info' ][ 'jielong_status_name' ] = '开始';
  700. $list[ 'jielong_info' ][ 'jielong_time' ] = date("m月-d日 H:i:s", $info[ 'start_time' ]);
  701. } else {
  702. $list[ 'jielong_info' ][ 'jielong_status_name' ] = '结束';
  703. $list[ 'jielong_info' ][ 'jielong_time' ] = date("m月d日 H:i:s", $info[ 'end_time' ]);
  704. }
  705. //获取第一张图片
  706. foreach ($list[ 'list' ] as &$v) {
  707. $v[ 'goods_image' ] = explode(',', $v[ 'goods_image' ])[ 0 ];
  708. $v[ 'introduction' ] = $v[ 'introduction' ] ? $v[ 'introduction' ] : '精选好物,等你来抢';
  709. $v[ 'is_market_price' ] = 1;
  710. if ($v[ 'market_price' ] == 0) {
  711. $v[ 'is_market_price' ] = 0;
  712. }
  713. //判断是否是全路径
  714. // if (!preg_match('/(http:\/\/)|(https:\/\/)/i', $v['goods_image'])) {
  715. // $v['goods_image'] = __ROOT__.'/'.$v['goods_image'];
  716. // }
  717. }
  718. return $list;
  719. }
  720. /**
  721. * 获取商品二维码
  722. * @param unknown $app_type 请求类型
  723. * @param unknown $page uniapp页面路径
  724. * @param unknown $qrcode_param 二维码携带参数
  725. * @param string $promotion_type 活动类型 null为无活动
  726. */
  727. private function getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id)
  728. {
  729. $res = event('Qrcode', [
  730. 'site_id' => $site_id,
  731. 'app_type' => $app_type,
  732. 'type' => 'create',
  733. 'data' => [ 'jielong_id' => $qrcode_param[ 'jielong_id' ] ],
  734. 'page' => $page,
  735. 'qrcode_path' => 'upload/qrcode/jielong',
  736. // 'qrcode_name' => 'goods_' . $promotion_type . '_' . $qrcode_param['jielong_id'] . '_' . $qrcode_param['source_member'] . '_' . $site_id,
  737. 'qrcode_name' => 'goods_' . $promotion_type . '_' . $qrcode_param[ 'jielong_id' ] . '_' . $site_id,
  738. ], true);
  739. return $res;
  740. }
  741. /**
  742. * 获取接龙推广
  743. * @param $page
  744. * @param $qrcode_param
  745. * @param $promotion_type
  746. * @param $site_id
  747. * @return array
  748. */
  749. public function getSolitaireQrcode($page, $qrcode_param, $promotion_type, $site_id)
  750. {
  751. $params = [
  752. 'site_id' => $site_id,
  753. 'data' => [ 'jielong_id' => $qrcode_param[ 'jielong_id' ] ],
  754. 'page' => $page,
  755. 'promotion_type' => $promotion_type,
  756. 'h5_path' => $page . '?jielong_id=' . $qrcode_param[ 'jielong_id' ],
  757. 'qrcode_path' => 'upload/qrcode/jielong',
  758. 'qrcode_name' => 'goods_' . $promotion_type . '_' . $qrcode_param[ 'jielong_id' ] . '_' . $site_id,
  759. ];
  760. $solitaire = event('ExtensionInformation', $params, true);
  761. return $this->success($solitaire);
  762. }
  763. }