Cache.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class Cache extends BaseModel
  12. {
  13. /**
  14. * @access public
  15. * @author csdeshang
  16. * @param string $method
  17. * @return boolean
  18. */
  19. public function call($method)
  20. {
  21. $method = '_' . strtolower($method);
  22. if (method_exists($this, $method)) {
  23. return $this->$method();
  24. } else {
  25. return false;
  26. }
  27. }
  28. /**
  29. * 基本设置
  30. * @access private
  31. * @author csdeshang
  32. * @return array
  33. */
  34. private function _config()
  35. {
  36. $result = Db::name('config')->select()->toArray();
  37. if (is_array($result)) {
  38. $list_config = array();
  39. foreach ($result as $k => $v) {
  40. $list_config[$v['code']] = $v['value'];
  41. }
  42. }
  43. unset($result);
  44. return $list_config;
  45. }
  46. /**
  47. * 商品分类SEO
  48. * @access private
  49. * @author csdeshang
  50. * @return array
  51. */
  52. private function _goodsclassseo()
  53. {
  54. $list = Db::name('goodsclass')->field('gc_id,gc_title,gc_keywords,gc_description')->where('gc_keywords', '<>', '')->select()->toArray();
  55. if (!is_array($list))
  56. return null;
  57. $array = array();
  58. foreach ($list as $k => $v) {
  59. if ($v['gc_title'] != '' || $v['gc_keywords'] != '' || $v['gc_description'] != '') {
  60. if ($v['gc_name'] != '') {
  61. $array[$v['gc_id']]['name'] = $v['gc_name'];
  62. }
  63. if ($v['gc_title'] != '') {
  64. $array[$v['gc_id']]['title'] = $v['gc_title'];
  65. }
  66. if ($v['gc_keywords'] != '') {
  67. $array[$v['gc_id']]['key'] = $v['gc_keywords'];
  68. }
  69. if ($v['gc_description'] != '') {
  70. $array[$v['gc_id']]['desc'] = $v['gc_description'];
  71. }
  72. }
  73. }
  74. return $array;
  75. }
  76. /**
  77. * 商城主要频道SEO
  78. * @access private
  79. * @author csdeshang
  80. * @return array
  81. */
  82. private function _seo()
  83. {
  84. $list = Db::name('seo')->select()->toArray();
  85. if (!is_array($list))
  86. return null;
  87. $array = array();
  88. foreach ($list as $key => $value) {
  89. $array[$value['seo_type']] = $value;
  90. }
  91. return $array;
  92. }
  93. /**
  94. * 快递公司
  95. * @access private
  96. * @author csdeshang
  97. * @return array
  98. */
  99. private function _express()
  100. {
  101. $fields = 'express_id,express_name,express_state,express_code,express_letter,express_order,express_url';
  102. $list = Db::name('express')->field($fields)->order('express_order,express_letter')->where(array('express_state' => 1))->select()->toArray();
  103. if (!is_array($list))
  104. return null;
  105. $array = array();
  106. foreach ($list as $k => $v) {
  107. $array[$v['express_id']] = $v;
  108. }
  109. return $array;
  110. }
  111. /**
  112. * 自定义导航
  113. * @access private
  114. * @author csdeshang
  115. * @return array
  116. */
  117. private function _nav()
  118. {
  119. $list = Db::name('navigation')->order('nav_sort')->select()->toArray();
  120. if (!is_array($list))
  121. return null;
  122. return $list;
  123. }
  124. /**
  125. * 抢购价格区间
  126. * @access private
  127. * @author csdeshang
  128. * @return array
  129. */
  130. private function _groupbuyprice()
  131. {
  132. $price = Db::name('groupbuypricerange')->order('gprange_start')->select()->toArray();
  133. if (!is_array($price)) {
  134. $price = array();
  135. } else {
  136. $price = ds_change_arraykey($price, 'gprange_id');
  137. }
  138. return $price;
  139. }
  140. /**
  141. * 商品TAG
  142. * @access private
  143. * @author csdeshang
  144. * @return array
  145. */
  146. private function _classtag()
  147. {
  148. $field = 'gctag_id,gctag_name,gctag_value,gc_id,type_id';
  149. $list = Db::name('goodsclasstag')->field($field)->select()->toArray();
  150. if (!is_array($list))
  151. return null;
  152. return $list;
  153. }
  154. /**
  155. * 店铺分类
  156. * @access private
  157. * @author csdeshang
  158. * @return array
  159. */
  160. private function _storeclass()
  161. {
  162. $store_class_tmp = Db::name('storeclass')->order('storeclass_sort asc,storeclass_id asc')->select()->toArray();
  163. $store_class = array();
  164. if (is_array($store_class_tmp) && !empty($store_class_tmp)) {
  165. foreach ($store_class_tmp as $k => $v) {
  166. $store_class[$v['storeclass_id']] = $v;
  167. }
  168. }
  169. return $store_class;
  170. }
  171. /**
  172. * 店铺等级
  173. * @access private
  174. * @author csdeshang
  175. * @return array
  176. */
  177. private function _storegrade()
  178. {
  179. $list = Db::name('storegrade')->select()->toArray();
  180. $array = array();
  181. foreach ((array) $list as $v) {
  182. $array[$v['storegrade_id']] = $v;
  183. }
  184. unset($list);
  185. return $array;
  186. }
  187. /**
  188. * 店铺消息模板
  189. * @access private
  190. * @author csdeshang
  191. * @return array
  192. */
  193. private function _storemsgtpl()
  194. {
  195. $list = model('storemsgtpl')->getStoremsgtplList(array());
  196. $array = array();
  197. foreach ((array) $list as $v) {
  198. $array[$v['storemt_code']] = $v;
  199. }
  200. unset($list);
  201. return $array;
  202. }
  203. /**
  204. * 用户消息模板
  205. * @access private
  206. * @author csdeshang
  207. * @return array
  208. */
  209. private function _membermsgtpl()
  210. {
  211. $list = model('membermsgtpl')->getMembermsgtplList(array());
  212. $array = array();
  213. foreach ((array) $list as $v) {
  214. $array[$v['membermt_code']] = $v;
  215. }
  216. unset($list);
  217. return $array;
  218. }
  219. /**
  220. * 咨询类型
  221. * @access private
  222. * @author csdeshang
  223. * @return array
  224. */
  225. private function _consulttype()
  226. {
  227. $list = model('consulttype')->getConsulttypeList(array());
  228. $array = array();
  229. foreach ((array) $list as $val) {
  230. $val['consulttype_introduce'] = html_entity_decode($val['consulttype_introduce']);
  231. $array[$val['consulttype_id']] = $val;
  232. }
  233. unset($list);
  234. return $array;
  235. }
  236. }