Cache.php 6.8 KB

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