<?php

/* 
 * 客资工具模型
 */
namespace app\common\model;
use think\Model;
class Customer  extends Model{
    // protected $auto = ['ip'];
    // protected $autoWriteTimestamp = 'datetime';
    // protected function setIpAttr(){
    //     return get_client_ip();
    // }
    /**
     * 检查是否重复
     *
     */
    public function checkRepeat(){

    }
    public function getValidDay($brandclass){
    	$key = 'new_brand_valid_date_'.md5($brandclass);
        $valid_date = cache($key);
        if(!$valid_date){
            $info = sx_call('5a3bbb5d0988d',['brandclass'=>$brandclass]);
            if($info['code'] == 200){
                $valid_date = $info['data'][0]['valid_date'];
                cache($key,['data'=>$valid_date],86400);
            }else{
                $valid_date = 60;
            }
        }else{
        	$valid_date = $valid_date['data'];
        }
        if ($valid_date === null || $valid_date === '') {
            return array('code'=>200,'msg'=>'mc客资有效期配置为空不限制','data'=>[]);
        }
    }
    
}
