Diy.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\diy;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\activity\bargain\StoreBargainServices;
  14. use app\services\activity\combination\StoreCombinationServices;
  15. use app\services\activity\seckill\StoreSeckillServices;
  16. use app\services\article\ArticleServices;
  17. use app\services\diy\DiyServices;
  18. use app\services\other\CacheServices;
  19. use app\services\product\product\StoreCategoryServices;
  20. use app\services\product\product\StoreProductServices;
  21. use crmeb\exceptions\AdminException;
  22. use think\facade\App;
  23. /**
  24. *
  25. * Class Diy
  26. * @package app\controller\admin\v1\diy
  27. */
  28. class Diy extends AuthController
  29. {
  30. /**
  31. * @param App $app
  32. * @param DiyServices $services
  33. */
  34. public function __construct(App $app, DiyServices $services)
  35. {
  36. parent::__construct($app);
  37. $this->services = $services;
  38. }
  39. /**
  40. * DIY列表
  41. * @return mixed
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. */
  46. public function getList()
  47. {
  48. $where = $this->request->getMore([
  49. ['status', ''],
  50. ['type', 0],
  51. ['name', ''],
  52. ['version', ''],
  53. ]);
  54. $where['type'] = -1;
  55. $data = $this->services->getDiyList($where);
  56. return app('json')->success($data);
  57. }
  58. /**
  59. * 保存可视化编辑资源
  60. * @param int $id
  61. * @return mixed
  62. */
  63. public function saveData(int $id = 0)
  64. {
  65. $data = $this->request->postMore([
  66. ['value', ''],
  67. ]);
  68. $value_config = ['seckill', 'bargain', 'combination', 'goodList'];
  69. $value = is_string($data['value']) ? json_decode($data['value'], true) : $data['value'];
  70. foreach ($value as $key => &$val) {
  71. if (in_array($key, $value_config) && is_array($val)) {
  72. foreach ($val as $k => &$v) {
  73. if (isset($v['selectConfig']['list']) && $v['selectConfig']['list']) {
  74. $v['selectConfig']['list'] = [];
  75. }
  76. if (isset($v['goodsList']['list']) && $v['goodsList']['list'] && $v['tabConfig']['tabVal'] == 1) {
  77. $limitMax = config('database.page.limitMax', 50);
  78. if (count($v['goodsList']['list']) > $limitMax) {
  79. return app('json')->fail(400350);
  80. }
  81. $v['ids'] = array_column($v['goodsList']['list'], 'id');
  82. $v['goodsList']['list'] = [];
  83. }
  84. }
  85. }
  86. }
  87. $data['value'] = json_encode($value);
  88. $data['version'] = uniqid();
  89. $this->services->saveData($id, $data);
  90. return app('json')->success(100000);
  91. }
  92. /**
  93. * 保存Diy资源
  94. * @param int $id
  95. * @return mixed
  96. */
  97. public function saveDiyData(int $id = 0)
  98. {
  99. $data = $this->request->postMore([
  100. ['name', ''],
  101. ['title', ''],
  102. ['value', ''],
  103. ['type', ''],
  104. ['cover_image', ''],
  105. ['is_show', 0],
  106. ['is_bg_color', 0],
  107. ['is_bg_pic', 0],
  108. ['bg_tab_val', 0],
  109. ['color_picker', ''],
  110. ['bg_pic', ''],
  111. ]);
  112. $value = is_string($data['value']) ? json_decode($data['value'], true) : $data['value'];
  113. $infoDiy = $id ? $this->services->get($id, ['is_diy']) : [];
  114. if ($infoDiy && $infoDiy['is_diy']) {
  115. foreach ($value as $key => &$item) {
  116. if ($item['name'] === 'goodList') {
  117. if (isset($item['selectConfig']['list'])) {
  118. unset($item['selectConfig']['list']);
  119. }
  120. if (isset($item['goodsList']['list']) && is_array($item['goodsList']['list'])) {
  121. $limitMax = config('database.page.limitMax', 50);
  122. if (isset($item['numConfig']['val']) && isset($item['tabConfig']['tabVal']) && $item['tabConfig']['tabVal'] == 0 && $item['numConfig']['val'] > $limitMax) {
  123. return app('json')->fail(400350);
  124. }
  125. $item['goodsList']['ids'] = array_column($item['goodsList']['list'], 'id');
  126. unset($item['goodsList']['list']);
  127. }
  128. } elseif ($item['name'] === 'articleList') {
  129. if (isset($item['selectList']['list']) && is_array($item['selectList']['list'])) {
  130. unset($item['selectList']['list']);
  131. }
  132. } elseif ($item['name'] === 'promotionList') {
  133. unset($item['productList']['list']);
  134. }
  135. }
  136. $data['value'] = json_encode($value);
  137. } else {
  138. if (isset($value['d_goodList']['selectConfig']['list'])) {
  139. unset($value['d_goodList']['selectConfig']['list']);
  140. } elseif (isset($value['d_goodList']['goodsList']['list'])) {
  141. $limitMax = config('database.page.limitMax', 50);
  142. if (isset($value['d_goodList']['numConfig']['val']) && isset($value['d_goodList']['tabConfig']['tabVal']) && $value['d_goodList']['tabConfig']['tabVal'] == 0 && $value['d_goodList']['numConfig']['val'] > $limitMax) {
  143. return app('json')->fail(400350);
  144. }
  145. $value['d_goodList']['goodsList']['ids'] = array_column($value['d_goodList']['goodsList']['list'], 'id');
  146. unset($value['d_goodList']['goodsList']['list']);
  147. } elseif (isset($value['k_newProduct']['goodsList']['list'])) {
  148. $list = [];
  149. foreach ($value['k_newProduct']['goodsList']['list'] as $item) {
  150. $list[] = [
  151. 'image' => $item['image'],
  152. 'store_info' => $item['store_info'],
  153. 'store_name' => $item['store_name'],
  154. 'id' => $item['id'],
  155. 'price' => $item['price'],
  156. 'ot_price' => $item['ot_price'],
  157. ];
  158. }
  159. $value['k_newProduct']['goodsList']['list'] = $list;
  160. } elseif (isset($value['selectList']['list']) && is_array($value['selectList']['list'])) {
  161. unset($value['goodsList']['list']);
  162. }
  163. $data['value'] = json_encode($value);
  164. }
  165. $data['version'] = '1.0';
  166. $data['type'] = 2;
  167. $data['is_diy'] = 1;
  168. $data['version'] = uniqid();
  169. return app('json')->success($id ? 100001 : 100000, ['id' => $this->services->saveData($id, $data)]);
  170. }
  171. /**
  172. * 删除模板
  173. * @param $id
  174. * @return mixed
  175. */
  176. public function del($id)
  177. {
  178. $this->services->del($id);
  179. return app('json')->success(100002);
  180. }
  181. /**
  182. * 使用模板
  183. * @param $id
  184. * @return mixed
  185. */
  186. public function setStatus($id)
  187. {
  188. $this->services->setStatus($id);
  189. return app('json')->success(100014);
  190. }
  191. /**
  192. * 获取一条数据
  193. * @param int $id
  194. * @param StoreProductServices $services
  195. * @param StoreSeckillServices $seckillServices
  196. * @param StoreCombinationServices $combinationServices
  197. * @param StoreBargainServices $bargainServices
  198. * @return mixed
  199. * @throws \think\db\exception\DataNotFoundException
  200. * @throws \think\db\exception\DbException
  201. * @throws \think\db\exception\ModelNotFoundException
  202. */
  203. public function getInfo(int $id, StoreProductServices $services, StoreSeckillServices $seckillServices, StoreCombinationServices $combinationServices, StoreBargainServices $bargainServices)
  204. {
  205. if (!$id) throw new AdminException(100100);
  206. $info = $this->services->get($id);
  207. if ($info) {
  208. $info = $info->toArray();
  209. } else {
  210. throw new AdminException(400351);
  211. }
  212. if (!$info['value']) return app('json')->success(compact('info'));
  213. $info['value'] = json_decode($info['value'], true);
  214. $value_config = ['seckill', 'bargain', 'combination', 'goodList'];
  215. foreach ($info['value'] as $key => &$val) {
  216. if (in_array($key, $value_config) && is_array($val)) {
  217. if ($key == 'goodList') {
  218. foreach ($val as $k => &$v) {
  219. if (isset($v['ids']) && $v['ids'] && $v['tabConfig']['tabVal'] == 1) {
  220. $v['goodsList']['list'] = $services->getSearchList(['ids' => $v['ids']]);
  221. }
  222. }
  223. }
  224. if ($key == "seckill") {
  225. foreach ($val as $k => &$v) {
  226. if (isset($v['ids']) && $v['ids'] && $v['tabConfig']['tabVal'] == 1) {
  227. $v['goodsList']['list'] = $seckillServices->getDiySeckillList(['ids' => $v['ids']])['list'];
  228. }
  229. }
  230. }
  231. if ($key == "bargain") {
  232. foreach ($val as $k => &$v) {
  233. if (isset($v['ids']) && $v['ids'] && $v['tabConfig']['tabVal'] == 1) {
  234. $v['goodsList']['list'] = $bargainServices->getHomeList(['ids' => $v['ids']])['list'];
  235. }
  236. }
  237. }
  238. if ($key == "combination") {
  239. foreach ($val as $k => &$v) {
  240. if (isset($v['ids']) && $v['ids'] && $v['tabConfig']['tabVal'] == 1) {
  241. $v['goodsList']['list'] = $combinationServices->getHomeList(['ids' => $v['ids']])['list'];
  242. }
  243. }
  244. }
  245. }
  246. }
  247. return app('json')->success(compact('info'));
  248. }
  249. /**
  250. * 获取diy数据
  251. * @param $id
  252. * @param StoreProductServices $services
  253. * @return mixed
  254. * @throws \think\db\exception\DataNotFoundException
  255. * @throws \think\db\exception\DbException
  256. * @throws \think\db\exception\ModelNotFoundException
  257. */
  258. public function getDiyInfo($id, StoreProductServices $services)
  259. {
  260. if (!$id) throw new AdminException(100100);
  261. $info = $this->services->get($id);
  262. if ($info) {
  263. $info = $info->toArray();
  264. } else {
  265. throw new AdminException(400351);
  266. }
  267. $info['value'] = json_decode($info['value'], true);
  268. if ($info['value']) {
  269. /** @var ArticleServices $articleServices */
  270. $articleServices = app()->make(ArticleServices::class);
  271. if ($info['is_diy']) {
  272. foreach ($info['value'] as &$item) {
  273. if ($item['name'] === 'goodList') {
  274. if (isset($item['goodsList']['ids']) && count($item['goodsList']['ids'])) {
  275. $item['goodsList']['list'] = $services->getSearchList(['ids' => $item['goodsList']['ids']]);
  276. } else {
  277. $item['goodsList']['list'] = [];
  278. }
  279. } elseif ($item['name'] === 'articleList') {//文章
  280. $data = [];
  281. if ($item['selectConfig']['activeValue'] ?? 0) {
  282. $data = $articleServices->getList(['cid' => $item['selectConfig']['activeValue'] ?? 0], 0, $item['numConfig']['val'] ?? 0);
  283. }
  284. $item['selectList']['list'] = $data['list'] ?? [];
  285. } elseif ($item['name'] === 'promotionList') {//活动模仿
  286. $data = [];
  287. if (isset($item['tabConfig']['tabCur']) && $typeArr = $item['tabConfig']['list'][$item['tabConfig']['tabCur']] ?? []) {
  288. $val = $typeArr['link']['activeVal'] ?? 0;
  289. if ($val) {
  290. $data = $this->get_groom_list($val, (int)($item['numConfig']['val'] ?? 0));
  291. }
  292. }
  293. $item['productList']['list'] = $data;
  294. }
  295. }
  296. } else {
  297. if (isset($info['value']['d_goodList']['goodsList'])) {
  298. $info['value']['d_goodList']['goodsList']['list'] = [];
  299. }
  300. if (isset($info['value']['d_goodList']['goodsList']['ids']) && count($info['value']['d_goodList']['goodsList']['ids'])) {
  301. $info['value']['d_goodList']['goodsList']['list'] = $services->getSearchList(['ids' => $info['value']['d_goodList']['goodsList']['ids']]);
  302. }
  303. }
  304. }
  305. return app('json')->success(compact('info'));
  306. }
  307. /**
  308. * 获取推荐商品
  309. * @param $type
  310. * @param int $num
  311. * @return array|array[]
  312. * @throws \think\db\exception\DataNotFoundException
  313. * @throws \think\db\exception\DbException
  314. * @throws \think\db\exception\ModelNotFoundException
  315. */
  316. protected function get_groom_list($type, int $num = 0)
  317. {
  318. /** @var StoreProductServices $services */
  319. $services = app()->make(StoreProductServices::class);
  320. $info = [];
  321. if ($type == 1) {// 精品推荐
  322. $info = $services->getRecommendProduct(0, 'is_best', $num);// 精品推荐个数
  323. } else if ($type == 2) {// 热门榜单
  324. $info = $services->getRecommendProduct(0, 'is_hot', $num);// 热门榜单 猜你喜欢
  325. } else if ($type == 3) {// 首发新品
  326. $info = $services->getRecommendProduct(0, 'is_new', $num);// 首发新品
  327. } else if ($type == 4) {// 促销单品
  328. $info = $services->getRecommendProduct(0, 'is_benefit', $num);// 促销单品
  329. } else if ($type == 5) {// 会员商品
  330. $whereVip = [
  331. ['vip_price', '>', 0],
  332. ['is_vip', '=', 1],
  333. ];
  334. $info = $services->getRecommendProduct(0, $whereVip, $num);// 会员商品
  335. }
  336. return $info;
  337. }
  338. /**
  339. * 推荐商品展示
  340. * @param $type
  341. * @return \think\Response
  342. * @throws \think\db\exception\DataNotFoundException
  343. * @throws \think\db\exception\DbException
  344. * @throws \think\db\exception\ModelNotFoundException
  345. * @author wuhaotian
  346. * @email 442384644@qq.com
  347. * @date 2024/3/11
  348. */
  349. public function getGroomList($type)
  350. {
  351. [$page, $limit] = $this->request->getMore([
  352. ['page', 1],
  353. ['limit', 6],
  354. ], true);
  355. $list = $this->get_groom_list($type, $limit);
  356. return app('json')->success($list);
  357. }
  358. /**
  359. * 获取uni-app路径
  360. * @return mixed
  361. */
  362. public function getUrl()
  363. {
  364. $url = sys_data('uni_app_link');
  365. if ($url) {
  366. $model_checkbox = sys_config('model_checkbox', ['seckill', 'bargain', 'combination']);
  367. foreach ($url as $key => &$link) {
  368. $link['url'] = $link['link'];
  369. $link['parameter'] = trim($link['param']);
  370. if (!in_array('seckill', $model_checkbox) && strpos($link['name'], '秒杀') !== false) unset($url[$key]);
  371. if (!in_array('bargain', $model_checkbox) && strpos($link['name'], '砍价') !== false) unset($url[$key]);
  372. if (!in_array('combination', $model_checkbox) && strpos($link['name'], '拼团') !== false) unset($url[$key]);
  373. }
  374. } else {
  375. /** @var CacheServices $cache */
  376. $cache = app()->make(CacheServices::class);
  377. $url = $cache->getDbCache('uni_app_url', null);
  378. }
  379. return app('json')->success(compact('url'));
  380. }
  381. /**
  382. * 获取商品分类
  383. * @return mixed
  384. * @throws \think\db\exception\DataNotFoundException
  385. * @throws \think\db\exception\DbException
  386. * @throws \think\db\exception\ModelNotFoundException
  387. */
  388. public function getCategory()
  389. {
  390. /** @var StoreCategoryServices $categoryService */
  391. $categoryService = app()->make(StoreCategoryServices::class);
  392. $list = $categoryService->cascaderList(1, 1);
  393. return app('json')->success($list);
  394. }
  395. /**
  396. * 获取商品
  397. * @return mixed
  398. */
  399. public function getProduct()
  400. {
  401. $where = $this->request->getMore([
  402. ['id', 0],
  403. ['salesOrder', ''],
  404. ['priceOrder', ''],
  405. ]);
  406. $id = $where['id'];
  407. unset($where['id']);
  408. $where['is_show'] = 1;
  409. /** @var StoreCategoryServices $storeCategoryServices */
  410. $storeCategoryServices = app()->make(StoreCategoryServices::class);
  411. if ($storeCategoryServices->value(['id' => $id], 'pid')) {
  412. $where['sid'] = $id;
  413. } else {
  414. $where['cid'] = $id;
  415. }
  416. [$page, $limit] = $this->services->getPageValue();
  417. /** @var StoreProductServices $productService */
  418. $productService = app()->make(StoreProductServices::class);
  419. $list = $productService->getSearchList($where, $page, $limit);
  420. return app('json')->success($list);
  421. }
  422. /**
  423. * 获取提货点自提开启状态
  424. * @return mixed
  425. */
  426. public function getStoreStatus()
  427. {
  428. $data['store_status'] = sys_config('store_self_mention', 0);
  429. return app('json')->success($data);
  430. }
  431. /**
  432. * 还原模板数据
  433. * @param $id
  434. * @return mixed
  435. */
  436. public function Recovery($id)
  437. {
  438. if (!$id) throw new AdminException(100100);
  439. $info = $this->services->get($id);
  440. if ($info) {
  441. $info->value = $info->default_value;
  442. $info->update_time = time();
  443. $info->save();
  444. return app('json')->success(100014);
  445. } else {
  446. throw new AdminException(400351);
  447. }
  448. }
  449. /**
  450. * 获取二级分类
  451. * @return mixed
  452. */
  453. public function getByCategory()
  454. {
  455. $where = $this->request->getMore([
  456. ['pid', -1],
  457. ['name', '']
  458. ]);
  459. /** @var StoreCategoryServices $categoryServices */
  460. $categoryServices = app()->make(StoreCategoryServices::class);
  461. return app('json')->success($categoryServices->getALlByIndex($where));
  462. }
  463. /**
  464. * 添加页面
  465. * @return mixed
  466. * @throws \FormBuilder\Exception\FormBuilderException
  467. */
  468. public function create()
  469. {
  470. return app('json')->success($this->services->createForm());
  471. }
  472. /**
  473. * 保存页面
  474. * @return mixed
  475. */
  476. public function save()
  477. {
  478. $data = $this->request->postMore([
  479. ['name', ''],
  480. ]);
  481. if (!$data['name']) app('json')->fail(400352);
  482. $data['version'] = '1.0';
  483. $data['add_time'] = time();
  484. $data['type'] = 0;
  485. $data['is_diy'] = 1;
  486. $this->services->save($data);
  487. return app('json')->success(100000);
  488. }
  489. /**
  490. * 设置默认数据
  491. * @param $id
  492. * @return mixed
  493. */
  494. public function setRecovery($id)
  495. {
  496. if (!$id) throw new AdminException(100100);
  497. $info = $this->services->get($id);
  498. if ($info) {
  499. $info->default_value = $info->value;
  500. $info->update_time = time();
  501. $info->save();
  502. return app('json')->success(100014);
  503. } else {
  504. throw new AdminException(100026);
  505. }
  506. }
  507. /**
  508. * 获取商品列表
  509. * @return mixed
  510. * @throws \think\db\exception\DataNotFoundException
  511. * @throws \think\db\exception\DbException
  512. * @throws \think\db\exception\ModelNotFoundException
  513. */
  514. public function getProductList()
  515. {
  516. $where = $this->request->getMore([
  517. ['cate_id', ''],
  518. ['store_name', ''],
  519. ['type', 0],
  520. ]);
  521. $where['is_show'] = 1;
  522. $where['is_del'] = 0;
  523. /** @var StoreCategoryServices $storeCategoryServices */
  524. $storeCategoryServices = app()->make(StoreCategoryServices::class);
  525. if ($where['cate_id'] !== '') {
  526. if ($storeCategoryServices->value(['id' => $where['cate_id']], 'pid')) {
  527. $where['sid'] = $where['cate_id'];
  528. } else {
  529. $where['cid'] = $where['cate_id'];
  530. }
  531. }
  532. unset($where['cate_id']);
  533. $list = $this->services->ProductList($where);
  534. return app('json')->success($list);
  535. }
  536. /**
  537. * 分类、个人中心、一键换色
  538. * @param $type
  539. * @return mixed
  540. */
  541. public function getColorChange($type)
  542. {
  543. $status = (int)$this->services->getColorChange((string)$type);
  544. return app('json')->success(compact('status'));
  545. }
  546. /**
  547. * 保存分类、个人中心、一键换色
  548. * @param $status
  549. * @param $type
  550. * @return mixed
  551. */
  552. public function colorChange($status, $type)
  553. {
  554. if (!$status) throw new AdminException(100100);
  555. $info = $this->services->get(['template_name' => $type, 'type' => 1]);
  556. if ($info) {
  557. $info->value = $status;
  558. $info->update_time = time();
  559. $info->save();
  560. return app('json')->success(100014);
  561. } else {
  562. throw new AdminException(100026);
  563. }
  564. }
  565. /**
  566. * 获取个人中心数据
  567. * @return mixed
  568. */
  569. public function getMember()
  570. {
  571. $data = $this->services->getMemberData();
  572. return app('json')->success($data);
  573. }
  574. /**
  575. * 保存个人中心数据
  576. * @return mixed
  577. * @throws \think\db\exception\DataNotFoundException
  578. * @throws \think\db\exception\DbException
  579. * @throws \think\db\exception\ModelNotFoundException
  580. */
  581. public function memberSaveData()
  582. {
  583. $data = $this->request->postMore([
  584. ['status', 0],
  585. ['order_status', 0],
  586. ['my_banner_status', 0],
  587. ['routine_my_banner', []],
  588. ['routine_my_menus', []]
  589. ]);
  590. $this->services->memberSaveData($data);
  591. return app('json')->success(100000);
  592. }
  593. /**
  594. * 获取开屏广告
  595. * @return mixed
  596. */
  597. public function getOpenAdv()
  598. {
  599. /** @var CacheServices $cacheServices */
  600. $cacheServices = app()->make(CacheServices::class);
  601. $data = $cacheServices->getDbCache('open_adv', '');
  602. if ($data == '') {
  603. $data = [
  604. 'status' => 0,
  605. 'time' => '',
  606. 'type' => 'pic',
  607. 'value' => [],
  608. 'video_link' => '',
  609. ];
  610. }
  611. return app('json')->success($data);
  612. }
  613. /**
  614. * 保存开屏广告
  615. * @return mixed
  616. */
  617. public function openAdvAdd()
  618. {
  619. $data = $this->request->postMore([
  620. ['status', 0],
  621. ['time', 0],
  622. ['type', ''],
  623. ['value', []],
  624. ['video_link', '']
  625. ]);
  626. if ($data['type'] == '') $data['type'] = 'pic';
  627. /** @var CacheServices $cacheServices */
  628. $cacheServices = app()->make(CacheServices::class);
  629. $cacheServices->setDbCache('open_adv', $data);
  630. return app('json')->success(100000);
  631. }
  632. /**
  633. * 获取单个diy小程序预览二维码
  634. * @param $id
  635. * @return mixed
  636. */
  637. public function getRoutineCode($id)
  638. {
  639. $image = $this->services->getRoutineCode((int)$id);
  640. return app('json')->success(compact('image'));
  641. }
  642. }