Pc.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\pc\model;
  13. use app\model\BaseModel;
  14. use app\model\goods\Goods as GoodsModel;
  15. use app\model\goods\GoodsCategory as GoodsCategoryModel;
  16. use app\model\system\Api;
  17. use app\model\system\Config as ConfigModel;
  18. use app\model\web\Config as WebConfig;
  19. use think\facade\Cache;
  20. /**
  21. * PC端
  22. * @author Administrator
  23. *
  24. */
  25. class Pc extends BaseModel
  26. {
  27. private $link = [
  28. [
  29. 'title' => '首页',
  30. 'url' => '/'
  31. ],
  32. [
  33. 'title' => '登录',
  34. 'url' => '/auth/login'
  35. ],
  36. [
  37. 'title' => '注册',
  38. 'url' => '/auth/register'
  39. ],
  40. [
  41. 'title' => '找回密码',
  42. 'url' => '/auth/find'
  43. ],
  44. [
  45. 'title' => '公告列表',
  46. 'url' => '/cms/notice/list'
  47. ],
  48. [
  49. 'title' => '文章列表',
  50. 'url' => '/cms/article/list'
  51. ],
  52. [
  53. 'title' => '帮助中心',
  54. 'url' => '/cms/help/list'
  55. ],
  56. [
  57. 'title' => '购物车',
  58. 'url' => '/goods/cart'
  59. ],
  60. [
  61. 'title' => '领券中心',
  62. 'url' => '/goods/coupon'
  63. ],
  64. [
  65. 'title' => '商品分类',
  66. 'url' => '/goods/category'
  67. ],
  68. [
  69. 'title' => '商品列表',
  70. 'url' => '/goods/list'
  71. ],
  72. [
  73. 'title' => '品牌专区',
  74. 'url' => '/goods/brand'
  75. ],
  76. [
  77. 'title' => '团购专区',
  78. 'url' => '/promotion/groupbuy'
  79. ],
  80. [
  81. 'title' => '秒杀专区',
  82. 'url' => '/promotion/seckill'
  83. ],
  84. [
  85. 'title' => '会员中心',
  86. 'url' => '/member'
  87. ]
  88. ];
  89. private $web_demain = __ROOT__ . '/web';
  90. private $not_found_file_error = "未找到源码包,请检查目录文件";
  91. /*************************************************网站部署******************************************/
  92. /**
  93. * 默认部署:无需下载,一键刷新,API接口请求地址为当前域名,编译代码存放到web文件夹中
  94. * @return array
  95. */
  96. public function downloadCsDefault()
  97. {
  98. try {
  99. $path = 'addon/pc/source/cs_default';
  100. $web_path = 'web'; // web端生成目录
  101. if (!is_dir($path) || count(scandir($path)) <= 3) {
  102. return $this->error('', $this->not_found_file_error);
  103. }
  104. if (is_dir($web_path)) {
  105. // 先将之前的文件删除
  106. if (count(scandir($web_path)) > 1) deleteDir($web_path);
  107. } else {
  108. // 创建web目录
  109. mkdir($web_path, intval('0777', 8), true);
  110. }
  111. // 将原代码包拷贝到web目录下
  112. recurseCopy($path, $web_path);
  113. $this->dealWithParamReplace($web_path);
  114. file_put_contents($web_path . '/refresh.log', time());
  115. return $this->success();
  116. } catch (\Exception $e) {
  117. return $this->error('', $e->getMessage() . $e->getLine());
  118. }
  119. }
  120. /**
  121. * 独立部署:下载编译代码包,参考开发文档进行配置
  122. * @param $domain
  123. * @return array
  124. */
  125. public function downloadCsSeparate($domain)
  126. {
  127. $this->web_demain = $domain;
  128. try {
  129. $path = 'addon/pc/source/cs_separate';
  130. $source_file_path = 'upload/web/cs_separate'; // web端生成目录
  131. if (!is_dir($path) || count(scandir($path)) <= 3) {
  132. return $this->error('', $this->not_found_file_error);
  133. }
  134. if (is_dir($source_file_path)) {
  135. // 先将之前的文件删除
  136. if (count(scandir($source_file_path)) > 2) deleteDir($source_file_path);
  137. } else {
  138. // 创建web目录
  139. mkdir($source_file_path, intval('0777', 8), true);
  140. }
  141. // 将原代码包拷贝到web目录下
  142. recurseCopy($path, $source_file_path);
  143. $this->dealWithParamReplace($source_file_path);
  144. // 生成压缩包
  145. $file_arr = getFileMap($source_file_path);
  146. if (!empty($file_arr)) {
  147. $zipname = 'web_cs_separate_' . date('YmdHi') . '.zip';
  148. $zip = new \ZipArchive();
  149. $res = $zip->open($zipname, \ZipArchive::CREATE);
  150. if ($res === TRUE) {
  151. foreach ($file_arr as $file_path => $file_name) {
  152. if (is_dir($file_path)) {
  153. $file_path = str_replace($source_file_path . '/', '', $file_path);
  154. $zip->addEmptyDir($file_path);
  155. } else {
  156. $zip_path = str_replace($source_file_path . '/', '', $file_path);
  157. $zip->addFile($file_path, $zip_path);
  158. }
  159. }
  160. $zip->close();
  161. header("Content-Type: application/zip");
  162. header("Content-Transfer-Encoding: Binary");
  163. header("Content-Length: " . filesize($zipname));
  164. header("Content-Disposition: attachment; filename=\"" . basename($zipname) . "\"");
  165. readfile($zipname);
  166. @unlink($zipname);
  167. }
  168. }
  169. return $this->success();
  170. } catch (\Exception $e) {
  171. return $this->error('', $e->getMessage() . $e->getLine());
  172. }
  173. }
  174. /**
  175. * 源码下载:下载开源代码包,参考开发文档进行配置,结合业务需求进行二次开发
  176. * @return array
  177. */
  178. public function downloadOs()
  179. {
  180. try {
  181. $source_file_path = 'addon/pc/source/os';
  182. if (!is_dir($source_file_path) || count(scandir($source_file_path)) <= 3) {
  183. return $this->error('', $this->not_found_file_error);
  184. }
  185. $file_arr = getFileMap($source_file_path);
  186. if (!empty($file_arr)) {
  187. $zipname = 'web_os_' . date('YmdHi') . '.zip';
  188. $zip = new \ZipArchive();
  189. $res = $zip->open($zipname, \ZipArchive::CREATE);
  190. if ($res === TRUE) {
  191. foreach ($file_arr as $file_path => $file_name) {
  192. if (is_dir($file_path)) {
  193. $file_path = str_replace($source_file_path . '/', '', $file_path);
  194. $zip->addEmptyDir($file_path);
  195. } else {
  196. $zip_path = str_replace($source_file_path . '/', '', $file_path);
  197. $zip->addFile($file_path, $zip_path);
  198. }
  199. }
  200. $zip->close();
  201. header("Content-Type: application/zip");
  202. header("Content-Transfer-Encoding: Binary");
  203. header("Content-Length: " . filesize($zipname));
  204. header("Content-Disposition: attachment; filename=\"" . basename($zipname) . "\"");
  205. readfile($zipname);
  206. @unlink($zipname);
  207. }
  208. }
  209. return $this->success();
  210. } catch (\Exception $e) {
  211. return $this->error('', $e->getMessage() . $e->getLine());
  212. }
  213. }
  214. /**
  215. * 替换配置信息,API请求域名地址、图片、密钥等
  216. * @param $source_path
  217. * @param string $domain
  218. */
  219. private function dealWithParamReplace($source_path)
  220. {
  221. //处理js文件中的变量替换
  222. $js_path = $source_path . '/_nuxt';
  223. $files = scandir($js_path);
  224. foreach ($files as $path) {
  225. if ($path != '.' && $path != '..') {
  226. $temp_path = $js_path . '/' . $path;
  227. if (file_exists($temp_path)) {
  228. if (preg_match("/(\w{7})(.js)$/", $temp_path)) {
  229. $content = file_get_contents($temp_path);
  230. $content = $this->paramReplace($content);
  231. file_put_contents($temp_path, $content);
  232. }
  233. }
  234. }
  235. }
  236. }
  237. /**
  238. * 参数替换
  239. * @param $string
  240. * @param string $domain
  241. * @return string|string[]|null
  242. */
  243. private function paramReplace($string)
  244. {
  245. $api_model = new Api();
  246. $api_config = $api_model->getApiConfig()[ 'data' ];
  247. $web_config_model = new WebConfig();
  248. $web_config = $web_config_model->getMapConfig();
  249. $web_config = $web_config[ 'data' ][ 'value' ];
  250. $web_socket = ( strstr(__ROOT__, 'https://') === false ? str_replace('http', 'ws', __ROOT__) : str_replace('https', 'wss', __ROOT__) ) . '/wss';
  251. $patterns = [
  252. '/\{\{\$baseUrl\}\}/',
  253. '/\{\{\$imgDomain\}\}/',
  254. '/\{\{\$webDomain\}\}/',
  255. '/\{\{\$mpKey\}\}/',
  256. '/\{\{\$apiSecurity\}\}/',
  257. '/\{\{\$publicKey\}\}/',
  258. '/\{\{\$webSocket\}\}/'
  259. ];
  260. $replacements = [
  261. __ROOT__,
  262. __ROOT__,
  263. $this->web_demain,
  264. $web_config[ 'tencent_map_key' ] ?? '',
  265. $api_config[ 'is_use' ] ?? 0,
  266. $api_config[ 'value' ][ 'public_key' ] ?? '',
  267. $web_socket
  268. ];
  269. $string = preg_replace($patterns, $replacements, $string);
  270. return $string;
  271. }
  272. /**
  273. * 获取PC端固定跳转链接
  274. * @return array
  275. */
  276. public function getLink()
  277. {
  278. foreach ($this->link as $k => $v) {
  279. if ($v[ 'url' ] == '/auth/register' && addon_is_exit('memberregister') == 0) {
  280. unset($this->link[ $k ]);
  281. } elseif ($v[ 'url' ] == '/goods/coupon' && addon_is_exit('coupon') == 0) {
  282. unset($this->link[ $k ]);
  283. } elseif ($v[ 'url' ] == '/promotion/seckill' && addon_is_exit('seckill') == 0) {
  284. unset($this->link[ $k ]);
  285. } elseif ($v[ 'url' ] == '/promotion/groupbuy' && addon_is_exit('groupbuy') == 0) {
  286. unset($this->link[ $k ]);
  287. }
  288. }
  289. $this->link = array_values($this->link);
  290. return $this->link;
  291. }
  292. /**
  293. * 设置首页浮层
  294. * @param $data
  295. * @return array
  296. */
  297. public function setFloatLayer($data, $site_id, $app_module = 'shop')
  298. {
  299. $config = new ConfigModel();
  300. $res = $config->setConfig($data, 'PC端首页浮层', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'PC_INDEX_FLOAT_LAYER_CONFIG' ] ]);
  301. return $res;
  302. }
  303. /**
  304. * 获取首页浮层
  305. * @param $data
  306. * @return array
  307. */
  308. public function getFloatLayer($site_id, $app_module = 'shop')
  309. {
  310. $config = new ConfigModel();
  311. $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'PC_INDEX_FLOAT_LAYER_CONFIG' ] ]);
  312. if (empty($res[ 'data' ][ 'value' ])) {
  313. $res[ 'data' ][ 'value' ] = [
  314. 'title' => '首页浮层',
  315. 'url' => '{"title":"\u81ea\u5b9a\u4e49","url":"https:\/\/www.niushop.com"}',
  316. 'is_show' => 1,
  317. 'number' => '3',
  318. 'img_url' => 'public/static/img/pc/index_float_layer.png'
  319. ];
  320. } else {
  321. if (is_null(json_decode($res[ 'data' ][ 'value' ][ 'url' ]))) {
  322. $res[ 'data' ][ 'value' ][ 'url' ] = '{"title":"\u81ea\u5b9a\u4e49","url":"https:\/\/www.niushop.com"}';
  323. }
  324. }
  325. return $res;
  326. }
  327. /*****************************************导航*****************************************/
  328. /**
  329. * 添加导航
  330. * @param array $data
  331. */
  332. public function addNav($data)
  333. {
  334. $id = model('pc_nav')->add($data);
  335. Cache::tag("pc_nav")->clear();
  336. return $this->success($id);
  337. }
  338. /**
  339. * 修改导航
  340. * @param array $data
  341. */
  342. public function editNav($data, $condition)
  343. {
  344. $res = model('pc_nav')->update($data, $condition);
  345. Cache::tag("pc_nav")->clear();
  346. return $this->success($res);
  347. }
  348. /**
  349. * 删除导航
  350. * @param unknown $coupon_type_id
  351. */
  352. public function deleteNav($condition)
  353. {
  354. $res = model('pc_nav')->delete($condition);
  355. Cache::tag("pc_nav")->clear();
  356. return $this->success($res);
  357. }
  358. /**
  359. * 获取导航详情
  360. * @param int $id
  361. * @return multitype:string mixed
  362. */
  363. public function getNavInfo($id)
  364. {
  365. $cache = Cache::get("pc_nav_getNavInfo_" . $id);
  366. if (!empty($cache)) {
  367. return $this->success($cache);
  368. }
  369. $res = model('pc_nav')->getInfo([ [ 'id', '=', $id ] ], 'id, nav_title, nav_url, sort, is_blank, create_time, modify_time, nav_icon, is_show');
  370. Cache::tag("pc_nav")->set("pc_nav_getNavInfo_" . $id, $res);
  371. return $this->success($res);
  372. }
  373. /**
  374. * 获取导航详情
  375. * @param int $id
  376. * @return multitype:string mixed
  377. */
  378. public function getNavInfoByCondition($condition, $field = 'id, nav_title, nav_url, sort, is_blank, create_time, modify_time, nav_icon, is_show')
  379. {
  380. $res = model('pc_nav')->getInfo($condition, $field);
  381. return $this->success($res);
  382. }
  383. /**
  384. * 获取导航分页列表
  385. * @param array $condition
  386. * @param number $page
  387. * @param string $page_size
  388. * @param string $order
  389. * @param string $field
  390. */
  391. public function getNavPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = 'id, nav_title, nav_url, sort, is_blank, create_time, modify_time, nav_icon, is_show')
  392. {
  393. $data = json_encode([ $condition, $field, $order, $page, $page_size ]);
  394. $cache = Cache::get("pc_nav_getNavPageList_" . $data);
  395. if (!empty($cache)) {
  396. return $this->success($cache);
  397. }
  398. $list = model('pc_nav')->pageList($condition, $field, $order, $page, $page_size);
  399. Cache::tag("pc_nav")->set("pc_nav_getNavPageList_" . $data, $list);
  400. return $this->success($list);
  401. }
  402. /**
  403. * 获取导航列表
  404. * @param array $condition
  405. * @param string $field
  406. * @param string $order
  407. * @return array
  408. */
  409. public function getNavList($condition = [], $field = 'id,nav_title,nav_url,sort,is_blank,create_time,modify_time,nav_icon,is_show', $order = 'create_time desc')
  410. {
  411. $data = json_encode([ $condition, $field, $order ]);
  412. $cache = Cache::get("pc_nav_getNavList_" . $data);
  413. if (!empty($cache)) {
  414. return $this->success($cache);
  415. }
  416. $list = model('pc_nav')->getList($condition, $field, $order);
  417. Cache::tag("pc_nav")->set("pc_nav_getNavList_" . $data, $list);
  418. return $this->success($list);
  419. }
  420. /**
  421. * 修改排序
  422. * @param int $sort
  423. * @param int $id
  424. */
  425. public function modifyNavSort($sort, $id)
  426. {
  427. $res = model('pc_nav')->update([ 'sort' => $sort ], [ [ 'id', '=', $id ] ]);
  428. Cache::tag('pc_nav')->clear();
  429. return $this->success($res);
  430. }
  431. /*****************************************友情链接*****************************************/
  432. /**
  433. * 添加友情链接
  434. * @param array $data
  435. */
  436. public function addLink($data)
  437. {
  438. $id = model('pc_friendly_link')->add($data);
  439. Cache::tag("pc_friendly_link")->clear();
  440. return $this->success($id);
  441. }
  442. /**
  443. * 修改友情链接
  444. * @param array $data
  445. */
  446. public function editLink($data, $condition)
  447. {
  448. $res = model('pc_friendly_link')->update($data, $condition);
  449. Cache::tag("pc_friendly_link")->clear();
  450. return $this->success($res);
  451. }
  452. /**
  453. * 删除友情链接
  454. * @param unknown $coupon_type_id
  455. */
  456. public function deleteLink($condition)
  457. {
  458. $res = model('pc_friendly_link')->delete($condition);
  459. Cache::tag("pc_friendly_link")->clear();
  460. return $this->success($res);
  461. }
  462. /**
  463. * 获取友情链接详情
  464. * @param int $id
  465. * @return multitype:string mixed
  466. */
  467. public function getLinkInfo($id)
  468. {
  469. $cache = Cache::get("pc_friendly_link_info" . $id);
  470. if (!empty($cache)) {
  471. return $this->success($cache);
  472. }
  473. $res = model('pc_friendly_link')->getInfo([ [ 'id', '=', $id ] ], 'id, link_title, link_url, link_pic, link_sort, is_blank, is_show');
  474. Cache::tag("pc_friendly_link")->set("pc_friendly_link_info" . $id, $res);
  475. return $this->success($res);
  476. }
  477. /**
  478. * 获取导航分页列表
  479. * @param array $condition
  480. * @param number $page
  481. * @param string $page_size
  482. * @param string $order
  483. * @param string $field
  484. */
  485. public function getLinkPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'link_sort desc', $field = 'id, link_title, link_url, link_pic, link_sort, is_blank, is_show')
  486. {
  487. $data = json_encode([ $condition, $field, $order, $page, $page_size ]);
  488. $cache = Cache::get("pc_friendly_linkPageList_" . $data);
  489. if (!empty($cache)) {
  490. return $this->success($cache);
  491. }
  492. $list = model('pc_friendly_link')->pageList($condition, $field, $order, $page, $page_size);
  493. Cache::tag("pc_friendly_link")->set("pc_friendly_linkPageList_" . $data, $list);
  494. return $this->success($list);
  495. }
  496. /**
  497. * 获取导航列表
  498. * @param array $condition
  499. * @param number $page
  500. * @param string $page_size
  501. * @param string $order
  502. * @param string $field
  503. */
  504. public function getLinkList($condition = [], $field = true, $order = '')
  505. {
  506. $data = json_encode([ $condition, $field, $order ]);
  507. $cache = Cache::get("pc_friendly_linkList_" . $data);
  508. if (!empty($cache)) {
  509. return $this->success($cache);
  510. }
  511. $list = model('pc_friendly_link')->getList($condition, $field, $order);
  512. Cache::tag("pc_friendly_link")->set("pc_friendly_linkList_" . $data, $list);
  513. return $this->success($list);
  514. }
  515. /**
  516. * 修改排序
  517. * @param $sort
  518. * @param $id
  519. * @return array
  520. */
  521. public function modifyLinkSort($sort, $id)
  522. {
  523. $res = model('pc_friendly_link')->update([ 'link_sort' => $sort ], [ [ 'id', '=', $id ] ]);
  524. Cache::tag('pc_friendly_link')->clear();
  525. return $this->success($res);
  526. }
  527. /*****************************************首页楼层*****************************************/
  528. /**
  529. * 添加楼层模板
  530. * @param $data
  531. * @return array
  532. */
  533. public function addFloorBlockList($data)
  534. {
  535. $res = model("pc_floor_block")->addList($data);
  536. return $this->success($res);
  537. }
  538. /**
  539. * 获取PC端首页楼层模板
  540. * @return array
  541. */
  542. public function getFloorBlockList()
  543. {
  544. $list = model('pc_floor_block')->getList([], 'id,name,title,value,sort');
  545. return $this->success($list);
  546. }
  547. /**
  548. * 添加楼层
  549. * @param $data
  550. * @return array
  551. */
  552. public function addFloor($data)
  553. {
  554. $data[ 'create_time' ] = time();
  555. $res = model("pc_floor")->add($data);
  556. return $this->success($res);
  557. }
  558. /**
  559. * 编辑楼层
  560. * @param $data
  561. * @param $condition
  562. * @return array
  563. */
  564. public function editFloor($data, $condition)
  565. {
  566. $res = model("pc_floor")->update($data, $condition);
  567. return $this->success($res);
  568. }
  569. /**
  570. * 修改首页楼层排序
  571. * @param $sort
  572. * @param $condition
  573. * @return array
  574. */
  575. public function modifyFloorSort($sort, $condition)
  576. {
  577. $res = model('pc_floor')->update([ 'sort' => $sort ], $condition);
  578. return $this->success($res);
  579. }
  580. /**
  581. * 删除首页楼层
  582. * @param $condition
  583. * @return array
  584. */
  585. public function deleteFloor($condition)
  586. {
  587. $res = model('pc_floor')->delete($condition);
  588. return $this->success($res);
  589. }
  590. /**
  591. * 获取首页楼层信息
  592. * @param $condition
  593. * @param $field
  594. * @return array
  595. */
  596. public function getFloorInfo($condition, $field = 'id,block_id,title,value,state,create_time,sort')
  597. {
  598. $res = model("pc_floor")->getInfo($condition, $field);
  599. return $this->success($res);
  600. }
  601. /**
  602. * 获取首页楼层详情
  603. * @param $id
  604. * @return array
  605. */
  606. public function getFloorDetail($id, $site_id)
  607. {
  608. $goods_model = new GoodsModel();
  609. $goods_category_model = new GoodsCategoryModel();
  610. $floor_info = model("pc_floor")->getInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'id,block_id,title,value,state,sort');
  611. if (!empty($floor_info)) {
  612. $value = $floor_info[ 'value' ];
  613. if (!empty($value)) {
  614. $value = json_decode($value, true);
  615. foreach ($value as $k => $v) {
  616. if (!empty($v[ 'type' ])) {
  617. if ($v[ 'type' ] == 'goods') {
  618. // 商品
  619. $field = 'goods_id,goods_name,goods_image,price,create_time,sku_id,introduction,market_price';
  620. // $order = 'sort desc,create_time desc';
  621. $order = '';
  622. $list = $goods_model->getGoodsList([ [ 'goods_id', 'in', $v[ 'value' ][ 'goods_ids' ] ] ], $field, $order)[ 'data' ];
  623. $value[ $k ][ 'value' ][ 'list' ] = $list;
  624. } elseif ($v[ 'type' ] == 'category') {
  625. // 商品分类
  626. $condition = [
  627. [ 'category_id', 'in', $v[ 'value' ][ 'category_ids' ] ],
  628. [ 'site_id', '=', $site_id ]
  629. ];
  630. $list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,short_name,image,image_adv')[ 'data' ];
  631. $value[ $k ][ 'value' ][ 'list' ] = $list;
  632. }
  633. }
  634. }
  635. $floor_info[ 'value' ] = json_encode($value);
  636. }
  637. }
  638. return $this->success($floor_info);
  639. }
  640. /**
  641. * 获取PC端首页楼层列表
  642. * @param array $condition
  643. * @param string $field
  644. * @param string $order
  645. * @return array
  646. */
  647. public function getFloorList($condition = [], $field = 'pf.id,pf.block_id,pf.title,pf.value,pf.state,pf.create_time,pf.sort,fb.name as block_name,fb.title as block_title', $order = 'pf.sort desc,pf.create_time desc')
  648. {
  649. $alias = 'pf';
  650. $join = [
  651. [ 'pc_floor_block fb', 'pf.block_id = fb.id', 'inner' ]
  652. ];
  653. $list = model('pc_floor')->getList($condition, $field, $order, $alias, $join);
  654. return $this->success($list);
  655. }
  656. /**
  657. * 获取PC端首页楼层分页列表
  658. * @param array $condition
  659. * @param int $page
  660. * @param int $page_size
  661. * @param string $order
  662. * @param string $field
  663. * @return array
  664. */
  665. public function getFloorPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'pf.create_time desc', $field = 'pf.id,pf.block_id,pf.title,pf.value,pf.state,pf.create_time,pf.sort,fb.name as block_name,fb.title as block_title')
  666. {
  667. $alias = 'pf';
  668. $join = [
  669. [ 'pc_floor_block fb', 'pf.block_id = fb.id', 'inner' ]
  670. ];
  671. $list = model('pc_floor')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
  672. return $this->success($list);
  673. }
  674. }