123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?php
- namespace common\models;
- use Yii;
- /**
- * This is the model class for table "{{%user_mater}}".
- *
- * @property integer $id
- * @property integer $uid
- * @property string $backpic
- * @property string $company
- * @property string $type_id
- * @property string $name
- * @property integer $age
- * @property string $position
- * @property string $tel
- * @property string $qq
- * @property string $wechat
- * @property string $latitude
- * @property string $longitude
- * @property string $hashcode
- * @property string $province
- * @property string $city
- * @property string $area
- * @property string $address
- * @property string $intro
- * @property integer $c_time
- * @property integer $u_time
- * @property integer $member
- * @property integer $vip_start
- * @property integer $vip_end
- */
- class UserMater extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- const STATUS_YES = 10;
- const STATUS_NO = 0;
- const MEMBER_YES = 1;
- const MEMBER_NO = 0;
- public static function tableName()
- {
- return '{{%user_mater}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['c_time','u_time'], 'default','value'=>time()],
- //[['status'], 'default','value'=>self::STATUS_YES],
- //[['uid','company','type_id','name','tel'], 'required'],
- [['uid'], 'required'],
- [['company','name','backpic','position','tel','qq','wechat','latitude','longitude','hashcode','province','city','area','address','intro'], 'string'],
- [['c_time','type_id','uid','u_time','member','vip_start','vip_end'], 'integer'],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'uid' => '用户id',
- 'backpic' => '背景图片',
- 'company' => '企业名称',
- 'type_id' => '类型id',
- 'name' => '姓名',
- 'age' => '经营年限',
- 'position' => '职位',
- 'tel' => '手机号',
- 'qq' => 'qq',
- 'wechat' => '微信',
- 'latitude' => '纬度',
- 'longitude' => '经度',
- 'hashcode' => '经纬code',
- 'province' => '省编号',
- 'city' => '市编号',
- 'area' => '区编号',
- 'address' => '地址',
- 'intro' => '介绍',
- 'c_time' => '添加时间',
- 'u_time' => '更新时间',
- 'member' => '是否会员',
- 'vip_start' =>'会员开始时间',
- 'vip_end' =>'会员结束时间',
- ];
- }
- public function getType(){
- return $this->hasOne(MaterType::className(),['id'=>'type_id']);
- }
- public function getUser(){
- return $this->hasOne(User::className(),['id'=>'uid']);
- }
- /**
- * 商品展示图片
- * @return $this
- */
- public function getImages(){
- return $this->hasMany(ImageSource::className(),['topid'=>'uid'])->where(['type'=>ImageSource::TYPE_MATER_GOOD,'status'=>ImageSource::STATUS_YES]);
- }
- public function getAreaname()
- {
- $areaname ="";
- $provinceList = Yii::$app->cache->get('provinceList');
- if(!empty($provinceList))
- {
- if(!empty($this->province))
- $areaname .=empty($provinceList[$this->province]) ? "":$provinceList[$this->province] ;
- }else{
- $list = Area::find()->where(['type'=>1])->all();
- if(!empty($list))
- {
- foreach ($list as $value)
- {
- $provinceList[$value->area_id] = $value->area;
- if($this->province == $value->area_id)
- $areaname .= $value->area;
- }
- Yii::$app->cache->set('provinceList',$provinceList);
- }
- }
- $cityList = Yii::$app->cache->get('cityList');
- if(!empty($cityList))
- {
- if(!empty($this->city))
- $areaname .=empty($cityList[$this->city]) ? "":$cityList[$this->city];
- }else{
- $list = Area::find()->where(['type'=>2])->all();
- if(!empty($list))
- {
- foreach ($list as $value)
- {
- $cityList[$value->area_id] = $value->area;
- if($this->city == $value->area_id)
- $areaname .= $value->area;
- }
- Yii::$app->cache->set('cityList',$cityList);
- }
- }
- $areaList = Yii::$app->cache->get('areaList');
- if(!empty($areaList))
- {
- if(!empty($this->area))
- $areaname .=empty($areaList[$this->area])? "":$areaList[$this->area];
- }else{
- $list = Area::find()->where(['type'=>3])->all();
- if(!empty($list))
- {
- foreach ($list as $value)
- {
- $areaList[$value->area_id] = $value->area;
- if($this->area == $value->area_id)
- $areaname .= $value->area;
- }
- Yii::$app->cache->set('areaList',$areaList);
- }
- }
- return $areaname;
- }
- }
|