vip_rule_list.auto_cache.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. class vip_rule_list_auto_cache extends auto_cache{
  3. private $key = "vip:rule:list";
  4. public function load($param)
  5. {
  6. $list = $GLOBALS['cache']->get($this->key);
  7. if($list === false)
  8. {
  9. //unserialize(
  10. $sql = "select id,name,money,day_num,iap_money from ".DB_PREFIX."vip_rule where is_effect = 1 order by sort";
  11. $list = $GLOBALS['db']->getAll($sql,true,true);
  12. foreach($list as $k=>$v){
  13. $list[$k]['day_num'] = $v['day_num'].'天';
  14. $list[$k]['money_name'] = $this->get_money_name($v['money']);
  15. }
  16. $GLOBALS['cache']->set($this->key,$list);
  17. }
  18. return $list;
  19. }
  20. public function rm($param)
  21. {
  22. $GLOBALS['cache']->rm($this->key);
  23. }
  24. public function clear_all()
  25. {
  26. $GLOBALS['cache']->rm($this->key);
  27. }
  28. //获取字符串类型的钱数值,如果有小数位≠0则省略小数位,否则保留
  29. public function get_money_name($money){
  30. if(ceil($money)>intval($money)){
  31. $money_name = (string)$money;
  32. }else{
  33. $money_name = (string)intval($money);
  34. }
  35. return $money_name;
  36. }
  37. }
  38. ?>