cache.model.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <?php
  2. /**
  3. * 缓存操作
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class cacheModel extends Model
  11. {
  12. public function __construct(){
  13. parent::__construct();
  14. }
  15. public function call($method){
  16. $method = '_'.strtolower($method);
  17. if (method_exists($this,$method)){
  18. return $this->$method();
  19. }else{
  20. return false;
  21. }
  22. }
  23. /**
  24. * 基本设置
  25. *
  26. * @return array
  27. */
  28. private function _setting(){
  29. $list =$this->table('setting')->limit(false)->select();
  30. $array = array();
  31. foreach ((array)$list as $v) {
  32. $array[$v['name']] = $v['value'];
  33. }
  34. unset($list);
  35. return $array;
  36. }
  37. /**
  38. * 商品分类SEO
  39. *
  40. * @return array
  41. */
  42. private function _goods_class_seo(){
  43. $list = $this->table('goods_class')->field('gc_id,gc_title,gc_keywords,gc_description')->where(array('gc_keywords'=>array('neq','')))->limit(false)->select();
  44. if (!is_array($list)) return null;
  45. $array = array();
  46. foreach ($list as $k=>$v) {
  47. if ($v['gc_title'] != '' || $v['gc_keywords'] != '' || $v['gc_description'] != ''){
  48. if ($v['gc_name'] != ''){
  49. $array[$v['gc_id']]['name'] = $v['gc_name'];
  50. }
  51. if ($v['gc_title'] != ''){
  52. $array[$v['gc_id']]['title'] = $v['gc_title'];
  53. }
  54. if ($v['gc_keywords'] != ''){
  55. $array[$v['gc_id']]['key'] = $v['gc_keywords'];
  56. }
  57. if ($v['gc_description'] != ''){
  58. $array[$v['gc_id']]['desc'] = $v['gc_description'];
  59. }
  60. }
  61. }
  62. return $array;
  63. }
  64. /**
  65. * 商城主要频道SEO
  66. *
  67. * @return array
  68. */
  69. private function _seo(){
  70. $list =$this->table('seo')->limit(false)->select();
  71. if (!is_array($list)) return null;
  72. $array = array();
  73. foreach ($list as $key=>$value){
  74. $array[$value['type']] = $value;
  75. }
  76. return $array;
  77. }
  78. /**
  79. * 快递公司
  80. *
  81. * @return array
  82. */
  83. private function _express() {
  84. $fields = 'id,e_name,e_code,e_kdn_code,e_oms_code,e_letter,e_order,e_url,e_zt_state';
  85. $list = $this->table('express')->field($fields)->order('e_order,e_letter')->where(array('e_state'=>1))->limit(false)->select();
  86. if (!is_array($list)) return null;
  87. $array = array();
  88. foreach ($list as $k=>$v) {
  89. $array[$v['id']] = $v;
  90. }
  91. return $array;
  92. }
  93. /**
  94. * 自定义导航
  95. *
  96. * @return array
  97. */
  98. private function _nav(){
  99. $list = $this->table('navigation')->order('nav_sort')->limit(false)->select();
  100. if (!is_array($list)) return null;
  101. return $list;
  102. }
  103. /**
  104. * 抢购价格区间
  105. *
  106. * @return array
  107. */
  108. private function _groupbuy_price(){
  109. $price = $this->table('groupbuy_price_range')->order('range_start')->key('range_id')->select();
  110. if (!is_array($price)) $price = array();
  111. return $price;
  112. }
  113. /**
  114. * 商品TAG
  115. *
  116. * @return array
  117. */
  118. private function _class_tag(){
  119. $field = 'gc_tag_id,gc_tag_name,gc_tag_value,gc_id,type_id';
  120. $list = $this->table('goods_class_tag')->field($field)->limit(false)->select();
  121. if (!is_array($list)) return null;
  122. return $list;
  123. }
  124. /**
  125. * 店铺分类
  126. *
  127. * @return array
  128. */
  129. private function _store_class(){
  130. $store_class_tmp = $this->table('store_class')->limit(false)->order('sc_sort asc,sc_id asc')->select();
  131. $store_class = array();
  132. if (is_array($store_class_tmp) && !empty($store_class_tmp)){
  133. foreach ($store_class_tmp as $k=>$v){
  134. $store_class[$v['sc_id']] = $v;
  135. }
  136. }
  137. return $store_class;
  138. }
  139. /**
  140. * 店铺等级
  141. *
  142. * @return array
  143. */
  144. private function _store_grade(){
  145. $list =$this->table('store_grade')->limit(false)->select();
  146. $array = array();
  147. foreach ((array)$list as $v) {
  148. $array[$v['sg_id']] = $v;
  149. }
  150. unset($list);
  151. return $array;
  152. }
  153. /**
  154. * 店铺等级
  155. *
  156. * @return array
  157. */
  158. private function _store_msg_tpl(){
  159. $list = Model('store_msg_tpl')->getStoreMsgTplList(array());
  160. $array = array();
  161. foreach ((array)$list as $v) {
  162. $array[$v['smt_code']] = $v;
  163. }
  164. unset($list);
  165. return $array;
  166. }
  167. /**
  168. * 店铺等级
  169. *
  170. * @return array
  171. */
  172. private function _member_msg_tpl(){
  173. $list = Model('member_msg_tpl')->getMemberMsgTplList(array());
  174. $array = array();
  175. foreach ((array)$list as $v) {
  176. $array[$v['mmt_code']] = $v;
  177. }
  178. unset($list);
  179. return $array;
  180. }
  181. /**
  182. * 咨询类型
  183. *
  184. * @return array
  185. */
  186. private function _consult_type(){
  187. $list = Model('consult_type')->getConsultTypeList(array());
  188. $array = array();
  189. foreach ((array)$list as $val) {
  190. $val['ct_introduce'] = html_entity_decode($val['ct_introduce']);
  191. $array[$val['ct_id']] = $val;
  192. }
  193. unset($list);
  194. return $array;
  195. }
  196. /**
  197. * Circle Member Level
  198. *
  199. * @return array
  200. */
  201. private function _circle_level(){
  202. $list = $this->table('circle_mldefault')->limit(false)->select();
  203. if (!is_array($list)) return null;
  204. $array = array();
  205. foreach ($list as $val){
  206. $array[$val['mld_id']] = $val;
  207. }
  208. return $array;
  209. }
  210. private function _home_goods()
  211. {
  212. $name = BASE_DATA_PATH . '/sales/home_goods.txt';
  213. if(!$content = file_get_contents($name)) {
  214. Log::record("cannot read file={$name}",Log::ERR);
  215. return null;
  216. }
  217. else
  218. {
  219. $common_ids = array();
  220. $ids = explode(',',$content);
  221. foreach($ids as $val)
  222. {
  223. $id = intval($val);
  224. if($id > 0) {
  225. array_push($common_ids,$id);
  226. }
  227. }
  228. return $this->fill_goods($common_ids);
  229. }
  230. }
  231. private function fill_goods($common_ids)
  232. {
  233. $tops = array();
  234. $ids = Model('goods')->field('goods_commonid,goods_id')->where(array('goods_state' => 1,'goods_verify' => 1))->group('goods_commonid')->order('goods_salenum')->limit(false)->select();
  235. $all = array();
  236. foreach($ids as $val) {
  237. $all[intval($val['goods_commonid'])] = intval($val['goods_id']);
  238. }
  239. foreach($common_ids as $commid)
  240. {
  241. $goods_id = $all[$commid];
  242. if(!empty($goods_id) && $goods_id > 0) {
  243. $tops[$commid] = $goods_id;
  244. unset($all[$commid]);
  245. }
  246. }
  247. $ret = array();
  248. foreach($tops as $key => $val) {
  249. array_push($ret,$val);
  250. }
  251. foreach($all as $key => $val) {
  252. array_push($ret,$val);
  253. }
  254. return $ret;
  255. }
  256. private function _android_version()
  257. {
  258. $model = Model();
  259. $items = $model->table('app_update')->where(array('cur_version' => '1', 'enable' => '1', 'platform' => 'android'))->order('ver_code desc')->select();
  260. if (empty($items)) {
  261. return array();
  262. } else {
  263. $lastest = $items[0];
  264. $app_path = BASE_ROOT_PATH . $lastest['app_path'];
  265. $lastest['md5_file'] = md5_file($app_path);
  266. return $lastest;
  267. }
  268. }
  269. }