123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Elton
- * Date: 2020/8/8
- * Time: 14:00
- * JOB 调用 是否清水小说
- */
- namespace app\api\controller\v1;
- use app\common\library\Redis;
- use app\main\constants\CacheConstants;
- use app\main\service\LogService;
- use think\Config;
- use think\Request;
- class Waterbookapi extends Init
- {
- public function waterRules()
- {
- LogService::info('API:Waterbookapi->waterRules:params:'.json_encode(Request::instance()->param()));
- $channel_id = (integer)Request::instance()->param('channel_id') ?? 0;
- $aim_city = [];
- if($channel_id){
- // 读取Hash中的规则
- $waterRule = array_filter(Redis::instance()->hMGet(CacheConstants::LIGHT_RULE, ['*', $channel_id]));
- $push_type = 0;
- if($waterRule){
- foreach ($waterRule as $k=>$item)
- {
- $waterRule[$k] = json_decode($item, true);
- }
- //
- if (isset($waterRule['*']['t']) && $waterRule['*']['t'] == 1) {
- $push_type = 1;
- }else{
- if(isset($waterRule[$channel_id]['t'])){
- $push_type = $waterRule[$channel_id]['t'];
- }
- }
- $aim_city = array_column($waterRule, 'c');
- }
- $data = [
- 'push_type' => $push_type,
- 'city_ids' => implode(',', $aim_city),
- 'water_uids' => Config::get('site.water_uids')
- ];
- $this->setMsg('success')->setData($data)->getReturn();
- }else{
- $this->setCode(1)->setMsg('fail')->getReturn();
- }
- }
- }
|