You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
2.6 KiB

  1. <?php
  2. namespace backend\modules\hotel\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "base_user".
  6. *
  7. * @property integer $ID
  8. * @property string $USER_NAME
  9. * @property string $USER_PASSWORD
  10. * @property integer $ORG_ID
  11. * @property integer $TOP_ORG_ID
  12. * @property string $OPERA_ORG_ID
  13. * @property string $USER_SIGN
  14. * @property integer $USER_TYPE
  15. * @property integer $USER_ROLE
  16. * @property string $TRUE_NAME
  17. * @property integer $STATUS
  18. * @property integer $CANCEL_FLAG
  19. * @property integer $CREATE_USER_ID
  20. * @property string $CREATE_TIME
  21. * @property integer $UPDATE_USER_ID
  22. * @property string $UPDATE_TIME
  23. * @property string $PHONE_no
  24. */
  25. class User extends \yii\db\ActiveRecord
  26. {
  27. /**
  28. * @inheritdoc
  29. */
  30. public static function tableName()
  31. {
  32. return 'base_user';
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function rules()
  38. {
  39. return [
  40. [['ORG_ID', 'TOP_ORG_ID', 'USER_TYPE', 'USER_ROLE', 'STATUS', 'CANCEL_FLAG', 'CREATE_USER_ID', 'UPDATE_USER_ID'], 'integer'],
  41. [['STATUS'], 'required'],
  42. [['USER_NAME', 'OPERA_ORG_ID', 'USER_SIGN', 'TRUE_NAME'], 'string', 'max' => 100],
  43. [['USER_PASSWORD'], 'string', 'max' => 200],
  44. [['CREATE_TIME', 'UPDATE_TIME'], 'string', 'max' => 20],
  45. [['PHONE_no'], 'string', 'max' => 11],
  46. ];
  47. }
  48. /**
  49. * @inheritdoc
  50. */
  51. public function attributeLabels()
  52. {
  53. return [
  54. 'ID' => 'ID',
  55. 'USER_NAME' => 'User Name',
  56. 'USER_PASSWORD' => 'User Password',
  57. 'ORG_ID' => 'Org ID',
  58. 'TOP_ORG_ID' => 'Top Org ID',
  59. 'OPERA_ORG_ID' => 'Opera Org ID',
  60. 'USER_SIGN' => 'User Sign',
  61. 'USER_TYPE' => 'User Type',
  62. 'USER_ROLE' => 'User Role',
  63. 'TRUE_NAME' => 'True Name',
  64. 'STATUS' => 'Status',
  65. 'CANCEL_FLAG' => 'Cancel Flag',
  66. 'CREATE_USER_ID' => 'Create User ID',
  67. 'CREATE_TIME' => 'Create Time',
  68. 'UPDATE_USER_ID' => 'Update User ID',
  69. 'UPDATE_TIME' => 'Update Time',
  70. 'PHONE_no' => 'Phone No',
  71. ];
  72. }
  73. public function getOrders()
  74. {
  75. return $this->hasMany(OrderMain::className(), ['CREATE_USER_ID' => 'ID']);
  76. }
  77. public static function getPrincipal($principal)
  78. {
  79. $sql = "select true_name from base_user where id in ($principal)";
  80. $data = Yii::$app->db->createCommand($sql)->queryAll();
  81. $tmp = [];
  82. foreach ($data as $k => $v) {
  83. $tmp[] = $v['true_name'];
  84. }
  85. $data = implode(',', $tmp);
  86. return $data;
  87. }
  88. }