123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- namespace common\models;
- use Yii;
- /**
- * This is the model class for table "{{%user_company}}".
- *
- * @property string $id
- * @property integer $uid
- * @property string $logo
- * @property string $company
- * @property integer $age
- * @property integer $level
- * @property string $licence
- * @property integer $created_at
- * @property string $tel
- * @property string $city
- * @property string $district
- * @property string $adress
- * @property integer $updated_at
- * @property string $introduction
- * @property integer $vip_start
- * @property integer $vip_end
- */
- class UserCompany extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- const ISMEMBER = 10;//会员
- const NOMEMBER = 0;//非会员
- public static function tableName()
- {
- return '{{%user_company}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['uid','company','created_at'], 'required'],
- [['uid','member', 'age', 'level', 'created_at', 'updated_at','vip_start','vip_end'], 'integer'],
- [['introduction', 'address'], 'string'],
- [['logo', 'licence','openid'], 'string', 'max' => 255],
- [['company'], 'string', 'max' => 120],
- [['tel', 'city', 'district','province'], 'string', 'max' => 32],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'uid' => '用户ID',
- 'logo' => 'logo地址',
- 'company' => '公司名称',
- 'age' => '年限',
- 'level' => '等级',
- 'licence' => 'Licence',
- 'created_at' => '创建时间',
- 'tel' => '联系电话',
- 'city' => '城市',
- 'district' => '地区',
- 'address' => '地址',
- 'updated_at' => 'Updated At',
- 'introduction' => '公司简介',
- 'openid' =>'openid',
- 'member' =>'是否会员',
- 'vip_start' =>'会员开始时间',
- 'vip_end' =>'会员结束时间',
- ];
- }
- static public function _getToken($uid)
- {
- $auth_str = $uid;
- $expiry = 0;
- $key = 'building';
- $timeExpiry = sprintf('%010d', $expiry ? $expiry + time() : 0);
- $topAuth = substr(md5($auth_str . $timeExpiry . $key), 0, 6);
- $enString = base64_encode($timeExpiry . $auth_str);
- return $topAuth . $enString;
- }
- static public function _checkToken($token)
- {
- $string = $token;
- $key = 'building';
- $topAuth = substr($string, 0, 6);
- $enString = substr($string, 6);
- $str = base64_decode($enString);
- $timeExpiry = substr($str, 0, 10);
- $deString = substr($str, 10);
- if ($topAuth != substr(md5($deString . $timeExpiry . $key), 0, 6)) {
- return false;
- }
- $timeExpiry *= 1;
- if ($timeExpiry != 0 && $timeExpiry < time()) {
- return false;
- }
- return $deString;
- }
- }
|