Info.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. <?php
  2. # 核心类,数据获取类
  3. namespace Goods\Lib;
  4. use Dever;
  5. class Info
  6. {
  7. private $table_info = 'goods/info';
  8. private $table_attr = 'goods/info_attr';
  9. private $table_sku = 'goods/info_sku';
  10. /**
  11. * instance
  12. *
  13. * @var string
  14. */
  15. protected static $instance;
  16. /**
  17. * init
  18. *
  19. * @return mixed
  20. */
  21. public static function init($top_category = false)
  22. {
  23. if (empty(self::$instance[$top_category])) {
  24. self::$instance[$top_category] = new self($top_category);
  25. }
  26. return self::$instance[$top_category];
  27. }
  28. public function __construct($top_category = false)
  29. {
  30. $this->top_category = $top_category;
  31. # 必有有分类才能进入到需求中
  32. if (!$this->top_category) {
  33. $this->top_category = -1;
  34. //Dever::alert('错误的分类信息');
  35. }
  36. }
  37. # 根据商品条形码获取商品
  38. public function getGoodsByCode($type_id = false, $type = 1, $check = true)
  39. {
  40. $code = Dever::input('code');
  41. if (!$code) {
  42. Dever::alert('错误的条形码');
  43. }
  44. $where['code'] = $code;
  45. $sku = Dever::db('goods/info_sku')->find($where);
  46. if (!$sku) {
  47. Dever::alert('商品不存在');
  48. }
  49. $goods = Dever::db('goods/info')->find($sku['info_id']);
  50. if (!$goods) {
  51. Dever::alert('商品不存在');
  52. }
  53. if ($goods['status'] != 1) {
  54. Dever::alert('商品已下架');
  55. }
  56. if ($type_id > 0) {
  57. if ($type == 1) {
  58. $table = 'shop/goods_sku';
  59. $col = 'shop_id';
  60. $name = '门店';
  61. } elseif ($type == 2) {
  62. $table = 'store/goods_sku';
  63. $col = 'store_id';
  64. $name = '仓库';
  65. } elseif ($type == 3) {
  66. $table = 'factory/goods_sku';
  67. $col = 'factory_id';
  68. $name = '工厂';
  69. }
  70. $where = array();
  71. $where[$col] = $type_id;
  72. $where['goods_id'] = $goods['id'];
  73. $where['sku_id'] = $sku['id'];
  74. $data = Dever::db($table)->getOne($where);
  75. if (!$data) {
  76. if ($sku['key'] == -1) {
  77. $where['sku_id'] = -1;
  78. $data = Dever::db($table)->getOne($where);
  79. if (!$data) {
  80. Dever::alert($name . '商品不存在');
  81. }
  82. } else {
  83. Dever::alert($name . '商品不存在');
  84. }
  85. }
  86. if ($check && $data['total'] <= 0) {
  87. # 验证库存
  88. Dever::alert($name . '商品库存不足');
  89. }
  90. }
  91. if ($sku['key'] == -1) {
  92. $sku['id'] = -1;
  93. }
  94. $goods['sku'] = $sku;
  95. return $goods;
  96. }
  97. private function setAttr($cate, $order = 'list_reorder')
  98. {
  99. if ($order != 'list_reorder') {
  100. Dever::config('base')->attrOrder = $order;
  101. }
  102. Dever::setInput('update_category', $cate);
  103. $attr = Dever::db($this->table_attr, array(), $cate);
  104. return $attr;
  105. }
  106. public function getAttr($cate)
  107. {
  108. return Dever::load('attr/api')->getAttrByCate($cate, 'list');
  109. }
  110. # 根据分类获取需求列表数据
  111. public function getData($cate = false, $limit = '0,10', $page = false, $attr = true)
  112. {
  113. if (!$limit) {
  114. $limit = '0,10';
  115. }
  116. $where = $data = array();
  117. if (!$cate) {
  118. if ($this->top_category > 0) {
  119. $where['top_category_id'] = $this->top_category;
  120. }
  121. } elseif (strstr($cate, ',')) {
  122. $where['category'] = $this->top_category . ',' . $cate;
  123. } else {
  124. $where['second_category_id'] = $cate;
  125. }
  126. if ($page) {
  127. $method = 'getPageAll';
  128. } else {
  129. $where['limit'] = $limit;
  130. $method = 'getAll';
  131. }
  132. $name = Dever::input('name');
  133. if ($name) {
  134. $where['name'] = $name;
  135. }
  136. $data = Dever::db($this->table_info)->$method($where);
  137. if ($data && $attr) {
  138. foreach ($data as $k => $v) {
  139. $data[$k] = $this->info($v, 'list_reorder');
  140. }
  141. }
  142. return $data;
  143. }
  144. # 根据属性获取需求列表数据 这里带有检索属性的功能 此处还需优化
  145. public function getDataByAttr($cate = false, $where = array())
  146. {
  147. if (!$cate) {
  148. Dever::alert('错误的分类信息');
  149. }
  150. $where_sql = array();
  151. $name = Dever::input('name');
  152. if ($name) {
  153. //$where['name'] = $name;
  154. $where_sql[] = ' t_2.name = "'.$name.'"';
  155. }
  156. $attr = $this->setAttr($this->top_category . ',' . $cate);
  157. //print_r($attr->config['attr']);
  158. $where_sql = Dever::load('attr/api')->getSql($attr->config['attr'], $where, $where_sql);
  159. if (!$where_sql) {
  160. return array();
  161. }
  162. # 这里用pdo的数据绑定,字符串字段的区间查询就是有问题。。。只能用sql了
  163. //$data = $attr->getPageAll($where);
  164. $page['template'] = 'list';
  165. $page['num'] = 10;
  166. $where_sql = implode(' and ', $where_sql);
  167. $sql = 'SELECT t_2.* FROM `{project}_goods_'.$attr->config['name'].'` as t_1 Left Join `{project}_goods_info` AS t_2 ON t_1.`info_id`=t_2.`id` WHERE '.$where_sql.' order by t_2.`reorder` desc,t_2.`id` desc';
  168. $data = $attr->fetchAll($sql, array(), $page);
  169. if ($data) {
  170. foreach ($data as $k => $v) {
  171. $data[$k] = $this->info($v, 'list_reorder');
  172. }
  173. }
  174. return $data;
  175. }
  176. # 获取列表页的搜索条件
  177. public function getSearch($cate = false)
  178. {
  179. # 获取搜索条件
  180. if (!$cate) {
  181. $search_cate = $cate = $this->top_category;
  182. } else {
  183. $search_cate = $cate;
  184. }
  185. # 1是当前用户所在的城市,暂时写死
  186. # 获取搜索条件
  187. $search = Dever::load('attr/api')->getSearch($search_cate, true, 1, false, 2);
  188. # 下级分类
  189. $search['cate'] = Dever::load('category/api')->getList($cate);
  190. # 上级分类
  191. $search['parent_cate'] = Dever::load('category/api')->getList($this->top_category);
  192. return $search;
  193. }
  194. # 获取支付信息
  195. public function getPayState($uid, $id, $category)
  196. {
  197. $pay_where['category'] = $category;
  198. $pay = Dever::db('goods/pay')->one($pay_where);
  199. $pay_state = 0;
  200. if ($pay && $pay['num'] > 0) {
  201. $pay_state = $pay['num'];
  202. } elseif (strstr($category, ',')) {
  203. $category = explode(',', $category);
  204. $category = array_pop($category);
  205. $pay_state = $this->getPayState($uid, $id, $category);
  206. }
  207. //$update['where_id'] = $id;
  208. //$update['poster_pay_type'] = $pay_state;
  209. //Dever::db($this->table_info)->update($update);
  210. return $pay_state;
  211. }
  212. # 更新需求
  213. public function update($top, $cate, $data, $id, $uid)
  214. {
  215. if ($cate) {
  216. $category = $top . ',' . $cate;
  217. } else {
  218. $category = $top;
  219. }
  220. $attr = $this->setAttr($category);
  221. $attr_update = Dever::preInput('attr_');
  222. if ($attr_update) {
  223. foreach ($attr_update as $k => $v) {
  224. if (strstr($k, '_s')) {
  225. $k = str_replace('_s', '', $k);
  226. $attr_update[$k] = $v;
  227. }
  228. if (strstr($k, '_e')) {
  229. $k = str_replace('_e', '', $k);
  230. $attr_update[$k] .= ',' . $v;
  231. }
  232. }
  233. }
  234. $update = array();
  235. $update['name'] = $data['name'];
  236. $update['category'] = $category;
  237. $update['pic'] = $data['pic'];
  238. //$update['pic_cover'] = $data['pic'];
  239. $update['poster_uid'] = $uid;
  240. if (isset($data['view_price']) && $data['view_price']) {
  241. $update['view_price'] = $data['view_price'];
  242. }
  243. if ($uid && $id) {
  244. # 此处要判断是用户自己的
  245. $info = Dever::db($this->table_info)->one($id);
  246. /*
  247. if ($uid == $info['poster_uid']) {
  248. Dever::alert('错误的用户参数');
  249. }
  250. */
  251. $update['where_id'] = $attr_update['where_id'] = $id;
  252. Dever::db($this->table_info)->update($update);
  253. Dever::db($this->table_attr)->update($attr_update);
  254. $pay = 0;
  255. } else {
  256. $id = Dever::db($this->table_info)->insert($update);
  257. $attr_update['category'] = $update['category'];
  258. $attr_update['info_id'] = $id;
  259. $attr_update['id'] = $id;
  260. Dever::db($this->table_attr)->insert($attr_update);
  261. # 验证是否需要支付,根据category判断
  262. $pay = false;
  263. //$pay = $this->getPayState($uid, $id, $category);
  264. $info = Dever::db($this->table_info)->one($id);
  265. $info = $this->getInfoLink($info);
  266. }
  267. return array('id' => $id, 'pay' => $pay, 'cate' => $category, 'top' => $top, 'info' => $info);
  268. }
  269. # 获取支付所需要的信息
  270. public function getPayInfo($id, $sku = 0, $type = 1, $value = '')
  271. {
  272. $info = is_array($id) ? $id : Dever::db($this->table_info)->find($id);
  273. if ($info) {
  274. if ($type == 2) {
  275. $info['price'] = $info['f_price'];
  276. unset($info['s_price']);
  277. } else {
  278. unset($info['f_price']);
  279. }
  280. $sku = $sku > 0 ? $sku : $info['sku_id'];
  281. if ($sku > 0) {
  282. $where['info_id'] = $info['id'];
  283. $where['id'] = $sku;
  284. $sku = Dever::db('goods/info_sku')->find($where);
  285. if ($sku) {
  286. if ($sku['type'] == 3) {
  287. $price = $sku['price'];
  288. $s_price = $sku['s_price'];
  289. $f_price = $sku['f_price'];
  290. $sku['price'] = 0;
  291. $sku['s_price'] = 0;
  292. $sku['f_price'] = 0;
  293. # 计算价格
  294. $key = explode('_', $sku['key']);
  295. $attr = Dever::db('attr/info')->find($key[0]);
  296. if ($attr) {
  297. if ($value >= $attr['sell_value']) {
  298. $sku['price'] = $price;
  299. $sku['s_price'] = $s_price;
  300. $sku['f_price'] = $f_price;
  301. }
  302. }
  303. }
  304. $info['sku_id'] = $sku['id'];
  305. if ($type == 2) {
  306. $info['price'] = $sku['f_price'];
  307. } else {
  308. $info['price'] = $sku['price'];
  309. $info['s_price'] = $sku['s_price'];
  310. }
  311. $info['min'] = $sku['min'];
  312. //$info['attr_json'] = $sku['attr'];
  313. $info['attr'] = Dever::json_decode($sku['attr']);
  314. if ($info['attr']) {
  315. $info['attr'] = Dever::load('attr/api')->getInfoByJson($info['attr']);
  316. $info['sku_name'] = $info['attr']['string'];
  317. }
  318. }
  319. }
  320. /*
  321. $info['freight_id'] = 0;
  322. $info['freight_price'] = 0;
  323. $freight = $this->freight($info, $info['price'], $user, $num);
  324. if ($freight) {
  325. $info['freight_id'] = $freight['id'];
  326. $info['freight_price'] = $freight['price'];
  327. }
  328. */
  329. # 佣金计算
  330. //$info['reward'] = $this->reward($info, $info['price']*$num);
  331. }
  332. return $info;
  333. }
  334. # 获取自提信息
  335. public function storeInfo($goods_id, $area_id = '')
  336. {
  337. $info = Dever::db($this->table_info)->find($goods_id);
  338. if (!$info) {
  339. return array();
  340. }
  341. $array = explode(',', $info['category']);
  342. $cate = $store = array();
  343. $total = count($array);
  344. $total -= 1;
  345. # 用户所在地理位置
  346. if ($area_id) {
  347. $where['area'] = $area_id;
  348. }
  349. foreach ($array as $k => $v) {
  350. $cate[$k] = $v;
  351. if ($k < $total) {
  352. $cate[] = '-1';
  353. }
  354. $where['category'] = $cate;
  355. $data = Dever::db('goods/store')->state($where);
  356. if ($data) {
  357. $store += $data;
  358. }
  359. }
  360. return $store;
  361. }
  362. # 获取运费信息
  363. public function getFreight($id, $goods_price, $user, $num)
  364. {
  365. $info = Dever::db($this->table_info)->find($id);
  366. return $this->freight($info, $goods_price, $user, $num);
  367. }
  368. # 根据已经选择的sku获取商品信息
  369. public function getInfoBySku($id, $sku_id)
  370. {
  371. $info = Dever::db($this->table_info)->find($id);
  372. if ($info && $sku_id > 0) {
  373. $sku = Dever::db($this->table_sku)->find($sku_id);
  374. if ($sku && $sku['attr']) {
  375. $sku['attr'] = Dever::json_decode($sku['attr']);
  376. $info['sku'] = Dever::load('attr/api')->getInfoByJson($sku['attr']);
  377. }
  378. }
  379. return $info;
  380. }
  381. # 获取基本信息
  382. public function getInfo($info, $attr = true, $other = false, $order = 'view_reorder', $user = array(), $reward = false)
  383. {
  384. if (!is_array($info)) {
  385. $info = Dever::db($this->table_info)->find($info);
  386. }
  387. if (!$info) {
  388. Dever::alert('商品不存在');
  389. }
  390. if ($info && $attr) {
  391. $info = $this->info($info, $order, $other, $user, $reward);
  392. } else {
  393. $this->getGroup($info);
  394. }
  395. if (!isset($info['goods_id'])) {
  396. $info['goods_id'] = $info['id'];
  397. }
  398. if ($info['pic']) {
  399. $info['pic'] = explode(',', $info['pic']);
  400. }
  401. if ($info['tag_id']) {
  402. $info['tag'] = Dever::db('goods/tag')->getAllByIds($info['tag_id']);
  403. }
  404. return $info;
  405. }
  406. # 获取组合商品
  407. public function getGroup(&$info)
  408. {
  409. if ($info && $info['price_type'] > 2 && $info['goods'] && is_string($info['goods'])) {
  410. # 获取套餐或者组合的商品
  411. $goods = Dever::array_decode($info['goods']);
  412. $goods_info = array();
  413. foreach ($goods as $k => $v) {
  414. $ginfo = Dever::db('goods/info')->one($v['goods_id']);
  415. if ($ginfo) {
  416. $goods_info[] = array
  417. (
  418. 'id' => $ginfo['id'],
  419. 'name' => $ginfo['name'],
  420. 'price' => $ginfo['price'],
  421. 'cover' => $ginfo['cover'],
  422. 'num' => $v['num'],
  423. );
  424. }
  425. }
  426. $info['goods'] = $goods_info;
  427. }
  428. }
  429. # 获取基本信息
  430. public function info($info, $key = 'view_reorder', $other = false, $user = array(), $reward = false)
  431. {
  432. $info['category_array'] = Dever::load('category/api')->string($info['category']);
  433. if ($info['price_type'] == 2) {
  434. $attr = $this->setAttr($info['category'], $key);
  435. $attr_data = $attr->one($info['id']);
  436. $info['attr'] = $info['group_attr'] = $info['single_attr'] = $info['input_attr'] = array();
  437. if ($attr->config['attr']) {
  438. $i = 0;
  439. foreach ($attr->config['attr'] as $k => $v) {
  440. if (isset($v[$key]) && $v[$key] > 0 && $v['state'] == 1) {
  441. if (isset($attr_data['attr_' . $v['id']])) {
  442. $v['value'] = $attr_data['attr_' . $v['id']];
  443. } else {
  444. continue;
  445. $v['value'] = '';
  446. }
  447. $v['value_string'] = Dever::load('attr/api')->getValue($v);
  448. if ($v['ename'] == 'price') {
  449. $info['price'] = $v['value_string'];
  450. } else {
  451. if ($v['icon']) {
  452. $v['bg'] = 'background-image: url('.$v['icon'].')';
  453. $v['pic'] = '<img src="'.$v['icon'].'" width="18" />';
  454. }
  455. $info['attr'][$i] = $this->attr($i, $v, $info);
  456. $i++;
  457. }
  458. }
  459. }
  460. # 获取sku的价格
  461. $this->getPrice($info, $other);
  462. }
  463. if (!$info['attr']) {
  464. $info['price_type'] = 1;
  465. }
  466. }
  467. if (isset($info['cdate']) && $info['cdate']) {
  468. $info['cdate_string'] = Dever::mdate($info['cdate'], 2);
  469. }
  470. $info = $this->getInfoLink($info);
  471. $this->getGroup($info);
  472. if (Dever::config('base')->buy && Dever::config('base')->buy == 1) {
  473. $info['price'] = $info['f_price'];
  474. }
  475. //$info['freight'] = 0;
  476. //unset($info['goods']);
  477. unset($info['f_price']);
  478. unset($info['cdate']);
  479. unset($info['udate']);
  480. unset($info['category']);
  481. unset($info['top_category_id']);
  482. unset($info['second_category_id']);
  483. unset($info['category_id']);
  484. unset($info['area']);
  485. unset($info['mode']);
  486. unset($info['top']);
  487. unset($info['youhui']);
  488. unset($info['status']);
  489. unset($info['reorder']);
  490. unset($info['state']);
  491. return $info;
  492. }
  493. # 佣金计算
  494. private function reward($info, $price)
  495. {
  496. if ($info['reward_value'] && $info['reward_value'] > 0) {
  497. if ($info['reward_type'] == 2) {
  498. $info['reward_value'] = round(($info['reward_value']/100) * $price, 2);
  499. }
  500. return $info['reward_value'];
  501. }
  502. $array = explode(',', $info['category']);
  503. $cate = $reward = array();
  504. $total = count($array);
  505. $total -= 1;
  506. foreach ($array as $k => $v) {
  507. $cate[$k] = $v;
  508. if ($k < $total) {
  509. $cate[] = '-1';
  510. }
  511. $where['category'] = $cate;
  512. $data = Dever::db('goods/reward')->one($where);
  513. if ($data) {
  514. $reward = $data;
  515. }
  516. }
  517. if ($reward) {
  518. if ($reward['value'] && $reward['value'] > 0) {
  519. if ($reward['type'] == 2) {
  520. $reward['value'] = round(($reward['value']/100) * $price, 2);
  521. }
  522. return $reward['value'];
  523. }
  524. }
  525. return 0;
  526. }
  527. # 运费计算,暂时用省份代表地区
  528. private function freight($info, $goods_price, $user = array(), $num = 1)
  529. {
  530. $array = explode(',', $info['category']);
  531. $cate = $freight = array();
  532. $total = count($array);
  533. $total -= 1;
  534. if ($info && $info['goods_area']) {
  535. $where['goods_area'] = $info['goods_area'];
  536. }
  537. # 用户所在地理位置
  538. if ($user && isset($user['area_id']) && $user['area_id']) {
  539. $area = explode(',', $user['area_id']);
  540. $where['area'] = $area[0];
  541. }
  542. foreach ($array as $k => $v) {
  543. $cate[$k] = $v;
  544. if ($k < $total) {
  545. $cate[] = '-1';
  546. }
  547. $where['category'] = $cate;
  548. $data = Dever::db('goods/freight')->one($where);
  549. if ($data) {
  550. $freight = $data;
  551. }
  552. }
  553. if ($freight) {
  554. $price = $freight['first_price'];
  555. if ($num > $freight['first_num']) {
  556. $num = $num - $freight['first_num'];
  557. $price = $freight['first_price'] + ($freight['next_price']*$num);
  558. }
  559. if ($freight['type'] == 2) {
  560. $freight['price'] = round($goods_price*$num*($price/100), 2);
  561. } else {
  562. $freight['price'] = $price;
  563. }
  564. }
  565. return $freight;
  566. }
  567. private function attr($key, $data, &$info)
  568. {
  569. # 获取销售属性
  570. if ($data['option']) {
  571. $value = explode(',', $data['value']);
  572. $option = $data['option'];
  573. $data['option'] = array();
  574. foreach ($value as $k => $v) {
  575. if (isset($option[$v])) {
  576. $option[$v]['parent_name'] = $data['name'];
  577. $data['option'][] = $info['option'][$option[$v]['price_key']] = $option[$v];
  578. }
  579. }
  580. } else {
  581. unset($data['option']);
  582. }
  583. if ($data['is_sell'] == 2) {
  584. if ($data['sell_type'] == 1) {
  585. $info['group_attr'][] = $key;
  586. } elseif ($data['sell_type'] == 2) {
  587. $info['single_attr'][] = $key;
  588. } elseif ($data['sell_type'] == 3) {
  589. $info['input_attr'][] = $key;
  590. }
  591. }
  592. return $data;
  593. }
  594. private function getPrice(&$info, $other = false)
  595. {
  596. # 获取价格
  597. $where['info_id'] = $info['id'];
  598. $info['price_array'] = array();
  599. $list = Dever::db('goods/info_sku')->getData($where);
  600. $min = $max = array();
  601. if ($list) {
  602. foreach ($list as $k => $v) {
  603. if ($v['key']) {
  604. if (Dever::config('base')->buy && Dever::config('base')->buy == 1) {
  605. $v['price'] = $v['f_price'];
  606. }
  607. $v['name'] = array();
  608. $temp = explode('_', $v['key']);
  609. foreach ($temp as $k1 => $v1) {
  610. if (isset($info['option'][$v1])) {
  611. $v['name'][] = $info['option'][$v1]['name'];
  612. }
  613. }
  614. $v['name'] = implode(',', $v['name']);
  615. if ($other) {
  616. foreach ($other[1] as $k1 => $v1) {
  617. $v[$v1] = isset($other[0][$v['id']][$v1]) ? $other[0][$v['id']][$v1] : 0;
  618. }
  619. }
  620. if ($v['type'] == 1) {
  621. if (!$min) {
  622. $min = $v;
  623. }
  624. if (!$max) {
  625. $max = $v;
  626. }
  627. if ($min['price'] > $v['price']) {
  628. $min = $v;
  629. }
  630. if ($max['price'] < $v['price']) {
  631. $max = $v;
  632. }
  633. }
  634. $info['price_array'][$v['key']] = $v;
  635. }
  636. }
  637. }
  638. $info['price_min'] = $min;
  639. $info['price_max'] = $max;
  640. if ($min) {
  641. $info['price'] = $min['price'];
  642. $info['s_price'] = $min['s_price'];
  643. $info['sku_id'] = $min['id'];
  644. }
  645. unset($info['option']);
  646. }
  647. public function getInfoLink($info)
  648. {
  649. if (isset($this->view_path)) {
  650. $info['view_path'] = $this->view_path . '?top=' . $info['top_category_id'] . '&id=' . $info['id'];
  651. $info['view_link'] = Dever::url($info['view_path']);
  652. }
  653. return $info;
  654. }
  655. public function setViewPath($path)
  656. {
  657. $this->view_path = $path;
  658. }
  659. # 根据分类获取商品
  660. public function getGoods_api()
  661. {
  662. $where['category_id'] = Dever::input('cate_id');
  663. $factory_id = Dever::input('id');
  664. $data = Dever::db('goods/info_category')->getData($where);
  665. return $data;
  666. }
  667. }