Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

183 righe
5.3 KiB

  1. <?php
  2. namespace backend\modules\api\models;
  3. use yii\db\ActiveRecord;
  4. use yii\db\Expression;
  5. /**
  6. * This is the model class for table "base_user".
  7. *
  8. * @property integer $ID
  9. * @property integer $MAIN_CORP_ID
  10. * @property string $USER_NAME
  11. * @property string $USER_PASSWORD
  12. * @property integer $ORG_ID
  13. * @property integer $TOP_ORG_ID
  14. * @property string $OPERA_ORG_ID
  15. * @property string $USER_SIGN
  16. * @property integer $USER_TYPE
  17. * @property integer $USER_ROLE
  18. * @property string $TRUE_NAME
  19. * @property integer $STATUS
  20. * @property integer $CANCEL_FLAG
  21. * @property integer $CREATE_USER_ID
  22. * @property string $CREATE_TIME
  23. * @property integer $UPDATE_USER_ID
  24. * @property string $UPDATE_TIME
  25. * @property string $PHONE_no
  26. */
  27. class BaseUser extends ActiveRecord
  28. {
  29. /**
  30. * @inheritdoc
  31. */
  32. public static function tableName()
  33. {
  34. return 'base_user';
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function rules()
  40. {
  41. return [
  42. [['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'],
  43. [['STATUS'], 'required'],
  44. [['USER_NAME', 'OPERA_ORG_ID', 'USER_SIGN', 'TRUE_NAME'], 'string', 'max' => 100],
  45. [['USER_PASSWORD'], 'string', 'max' => 200],
  46. [['CREATE_TIME', 'UPDATE_TIME'], 'string', 'max' => 20],
  47. [['PHONE_no'], 'string', 'max' => 11],
  48. ];
  49. }
  50. /**
  51. * @inheritdoc
  52. */
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'ID' => 'ID',
  57. 'MAIN_CORP_ID' => 'CS运营主体ID',
  58. 'MAIN_CORP_ID2' => '车辆运营主体ID',
  59. 'USER_NAME' => '用户名',
  60. 'USER_PASSWORD' => '用户密码',
  61. 'ORG_ID' => '直属组织机构ID,BASE_ORGANIZATION.ORG_ID,非0',
  62. 'TOP_ORG_ID' => '产品所属顶级机构ID,BASE_ORGANIZATION.ORG_ID 是否需要支付 需要支付置0',
  63. 'OPERA_ORG_ID' => 'Opera Org ID',
  64. 'USER_SIGN' => '用户识别代码',
  65. 'USER_TYPE' => '0:全权限 1:仅直通巴士 2.穿梭巴士 3.组合线路 4:直通+穿梭 5.直通+组合 6.穿梭+组合',
  66. 'USER_ROLE' => 'User Role',
  67. 'TRUE_NAME' => '真实名称',
  68. 'STATUS' => 'Status',
  69. 'CANCEL_FLAG' => '记录有效性标记,CANCEL_FLAG=0记录有效;CANCEL_FLAG=1,记录已删除',
  70. 'CREATE_USER_ID' => '记录创建用户ID',
  71. 'CREATE_TIME' => '记录创建时间',
  72. 'UPDATE_USER_ID' => '记录最后更新用户ID',
  73. 'UPDATE_TIME' => '记录最后更新时间',
  74. 'PHONE_no' => 'Phone No',
  75. ];
  76. }
  77. public function getbase_main_corporation()
  78. {
  79. return $this->hasOne(BaseMainCorporation::className(), ['id' => 'MAIN_CORP_ID']);
  80. }
  81. /**
  82. * Function Description:根据user_id 获取对应的org_id
  83. * Function Name: getTouristMainCorporationToOrgId
  84. * @param $user_id
  85. *
  86. * @return int
  87. *
  88. * @author LUOCJ
  89. */
  90. public static function getTouristMainCorporationToOrgId($user_id)
  91. {
  92. $model = BaseUser::findOne(['ID' => $user_id, 'CANCEL_FLAG' => 0]);
  93. $org_id = 0;
  94. if ($model)
  95. $org_id = $model->base_main_corporation->purchase_org_id;
  96. return $org_id;
  97. }
  98. /**
  99. * Function Description:获取运营主体main_corp_id
  100. * Function Name: getMainCorpId
  101. * @param int $user_id 用户id
  102. * @return int
  103. *
  104. * @author 温依莅
  105. */
  106. public static function getMainCorpId($user_id)
  107. {
  108. $res = self::find()->select('id,main_corp_id,user_name')->where(['id' => $user_id, 'cancel_flag' => 0])->asArray()->one();
  109. return $res['main_corp_id'] == 0 ? 1 : $res['main_corp_id'];
  110. }
  111. /**
  112. * Function Description:获取opera_org_id
  113. * Function Name: getOperaOrgId
  114. * @param $user_id
  115. *
  116. * @return array|ActiveRecord[]
  117. *
  118. * @author 李健
  119. */
  120. public function getOperaOrgId($user_id)
  121. {
  122. $res = self::find()
  123. ->select('opera_org_id')
  124. ->from(self::tableName())
  125. ->where('id='.$user_id)
  126. ->asArray()
  127. ->one();
  128. return $res;
  129. }
  130. /**
  131. * Function Description:获取运营主体id
  132. * Function Name: getMainCorpIdById
  133. * @param $user_id
  134. *
  135. * @return array|ActiveRecord[]
  136. *
  137. * @author 李健
  138. */
  139. public function getMainCorpIdById($user_id)
  140. {
  141. $res = self::find()
  142. ->select('main_corp_id')
  143. ->from(self::tableName())
  144. ->where('id='.$user_id)
  145. ->asArray()
  146. ->one();
  147. return $res;
  148. }
  149. /**
  150. * Function Description:获取运营主体id
  151. * Function Name: getMainCorpIdByUserId
  152. * @param $user_id
  153. *
  154. * @return array|null|ActiveRecord
  155. *
  156. * @author 李健
  157. */
  158. public function getMainCorpIdByUserId($user_id)
  159. {
  160. $select = [
  161. 'main_corp_id'=>new Expression('if(main_corp_id=0,1,main_corp_id)')
  162. ];
  163. $res = self::find()
  164. ->select($select)
  165. ->from(self::tableName())
  166. ->where('id='.$user_id)
  167. ->asArray()
  168. ->one();
  169. return $res;
  170. }
  171. }