| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2018/10/31
- * Time: 16:56
- */
- namespace app\common\model;
- use think\Cache;
- use think\Model;
- use think\Config;
- class Kefu extends Model
- {
- protected $pk = 'id';
- protected $table = 'cy_kefu';
- const CACHE_KEY = "kefu:getKefuList";
- protected static function init()
- {
- Kefu::afterInsert(function () {
- Cache::rm(self::CACHE_KEY);
- });
- Kefu::afterUpdate(function () {
- Cache::rm(self::CACHE_KEY);
- });
- Kefu::afterWrite(function () {
- Cache::rm(self::CACHE_KEY);
- });
- }
- /*
- *获取列表内容
- */
- public function getList()
- {
- return $this->field('id,qq,nickname,game_id')->where(['channel_id' => 0, 'type' => 1])->paginate();
- }
- public function getKefuList()
- {
- // ->cache(self::CACHE_KEY, Config::get('QUERY_RESULT_CACHE_TIME'))
- return $this->where(['channel_id' => 0, 'type' => 1])->field('id,qq,nickname,"周一至周五 09-18点" as time')->select();
- }
- // 根据游戏ID查询带有缓存的数据
- public function getKefuByGameId($where = [])
- {
- // $cacheName = self::CACHE_KEY;
- // if(!empty($where['game_id'])){
- // $cacheName .= ":".$where['game_id'];
- // }
- // ->cache($cacheName, Config::get('QUERY_RESULT_CACHE_TIME'))
- return $this->where(['channel_id' => 0, 'type' => 1])->where($where)->field('id,qq,nickname,"周一至周五 09-18点" as time')->select();
- }
- }
|