|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
-
- namespace backend\modules\api\models;
-
- use yii\db\ActiveRecord;
- use yii\db\Expression;
-
- /**
- * This is the model class for table "base_user".
- *
- * @property integer $ID
- * @property integer $MAIN_CORP_ID
- * @property string $USER_NAME
- * @property string $USER_PASSWORD
- * @property integer $ORG_ID
- * @property integer $TOP_ORG_ID
- * @property string $OPERA_ORG_ID
- * @property string $USER_SIGN
- * @property integer $USER_TYPE
- * @property integer $USER_ROLE
- * @property string $TRUE_NAME
- * @property integer $STATUS
- * @property integer $CANCEL_FLAG
- * @property integer $CREATE_USER_ID
- * @property string $CREATE_TIME
- * @property integer $UPDATE_USER_ID
- * @property string $UPDATE_TIME
- * @property string $PHONE_no
- */
- class BaseUser extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'base_user';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['MAIN_CORP_ID', 'MAIN_CORP_ID2', 'ORG_ID', 'TOP_ORG_ID', 'USER_TYPE', 'USER_ROLE', 'STATUS', 'CANCEL_FLAG', 'CREATE_USER_ID', 'UPDATE_USER_ID'], 'integer'],
- [['STATUS'], 'required'],
- [['USER_NAME', 'OPERA_ORG_ID', 'USER_SIGN', 'TRUE_NAME'], 'string', 'max' => 100],
- [['USER_PASSWORD'], 'string', 'max' => 200],
- [['CREATE_TIME', 'UPDATE_TIME'], 'string', 'max' => 20],
- [['PHONE_no'], 'string', 'max' => 11],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'ID' => 'ID',
- 'MAIN_CORP_ID' => 'CS运营主体ID',
- 'MAIN_CORP_ID2' => '车辆运营主体ID',
- 'USER_NAME' => '用户名',
- 'USER_PASSWORD' => '用户密码',
- 'ORG_ID' => '直属组织机构ID,BASE_ORGANIZATION.ORG_ID,非0',
- 'TOP_ORG_ID' => '产品所属顶级机构ID,BASE_ORGANIZATION.ORG_ID 是否需要支付 需要支付置0',
- 'OPERA_ORG_ID' => 'Opera Org ID',
- 'USER_SIGN' => '用户识别代码',
- 'USER_TYPE' => '0:全权限 1:仅直通巴士 2.穿梭巴士 3.组合线路 4:直通+穿梭 5.直通+组合 6.穿梭+组合',
- 'USER_ROLE' => 'User Role',
- 'TRUE_NAME' => '真实名称',
- 'STATUS' => 'Status',
- 'CANCEL_FLAG' => '记录有效性标记,CANCEL_FLAG=0记录有效;CANCEL_FLAG=1,记录已删除',
- 'CREATE_USER_ID' => '记录创建用户ID',
- 'CREATE_TIME' => '记录创建时间',
- 'UPDATE_USER_ID' => '记录最后更新用户ID',
- 'UPDATE_TIME' => '记录最后更新时间',
- 'PHONE_no' => 'Phone No',
- ];
- }
-
- public function getbase_main_corporation()
- {
- return $this->hasOne(BaseMainCorporation::className(), ['id' => 'MAIN_CORP_ID']);
- }
-
- /**
- * Function Description:根据user_id 获取对应的org_id
- * Function Name: getTouristMainCorporationToOrgId
- * @param $user_id
- *
- * @return int
- *
- * @author LUOCJ
- */
- public static function getTouristMainCorporationToOrgId($user_id)
- {
- $model = BaseUser::findOne(['ID' => $user_id, 'CANCEL_FLAG' => 0]);
- $org_id = 0;
- if ($model)
- $org_id = $model->base_main_corporation->purchase_org_id;
- return $org_id;
- }
-
- /**
- * Function Description:获取运营主体main_corp_id
- * Function Name: getMainCorpId
- * @param int $user_id 用户id
- * @return int
- *
- * @author 温依莅
- */
- public static function getMainCorpId($user_id)
- {
- $res = self::find()->select('id,main_corp_id,user_name')->where(['id' => $user_id, 'cancel_flag' => 0])->asArray()->one();
- return $res['main_corp_id'] == 0 ? 1 : $res['main_corp_id'];
- }
-
- /**
- * Function Description:获取opera_org_id
- * Function Name: getOperaOrgId
- * @param $user_id
- *
- * @return array|ActiveRecord[]
- *
- * @author 李健
- */
- public function getOperaOrgId($user_id)
- {
- $res = self::find()
- ->select('opera_org_id')
- ->from(self::tableName())
- ->where('id='.$user_id)
- ->asArray()
- ->one();
- return $res;
- }
-
- /**
- * Function Description:获取运营主体id
- * Function Name: getMainCorpIdById
- * @param $user_id
- *
- * @return array|ActiveRecord[]
- *
- * @author 李健
- */
- public function getMainCorpIdById($user_id)
- {
- $res = self::find()
- ->select('main_corp_id')
- ->from(self::tableName())
- ->where('id='.$user_id)
- ->asArray()
- ->one();
- return $res;
- }
-
- /**
- * Function Description:获取运营主体id
- * Function Name: getMainCorpIdByUserId
- * @param $user_id
- *
- * @return array|null|ActiveRecord
- *
- * @author 李健
- */
- public function getMainCorpIdByUserId($user_id)
- {
- $select = [
- 'main_corp_id'=>new Expression('if(main_corp_id=0,1,main_corp_id)')
- ];
- $res = self::find()
- ->select($select)
- ->from(self::tableName())
- ->where('id='.$user_id)
- ->asArray()
- ->one();
- return $res;
- }
- }
|