UserMove.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. namespace common\models;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\NetPoint;
  5. use common\helpers\user\Info;
  6. use Yii;
  7. use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  8. /**
  9. * This is the model class for table "{{%USER_MOVE}}".
  10. *
  11. * @property string $ID
  12. * @property string $USER_ID 移动的会员ID
  13. * @property string $FROM_UID 移动前接点UID
  14. * @property string $TO_UID 移动后接点UID
  15. * @property int $LOCATION 移动到位置
  16. * @property string $TYPE 移网类型
  17. * @property int $IS_MOVING 是否正在移动
  18. * @property int $MOVE_PERCENT 移动百分比
  19. * @property int $AUDIT_STATUS 审核状态
  20. * @property int $PERIOD_NUM 移动时的期数
  21. * @property int $UPDATE_PERIOD_NUM 修改期数
  22. * @property int $AUDIT_PERIOD_NUM 修改期数
  23. * @property string $MOVE_ADMIN_ID 移网管理员
  24. * @property string $AUDIT_ADMIN_ID 审核管理员
  25. * @property string $NET_TABLE_NAME 移点备份表名
  26. * @property string $CREATE_REMARK 创建备注
  27. * @property string $AUDIT_REMARK 审核备注
  28. * @property int $CREATED_AT 创建时间
  29. * @property int $STARTED_AT 移网开始时间
  30. * @property int $ENDED_AT 移网结束时间
  31. * @property int $AUDITED_AT 审核时间
  32. */
  33. class UserMove extends \common\components\ActiveRecord
  34. {
  35. const TYPE_NETWORK = NetPoint::NET_TYPE_NETWORK;
  36. const TYPE_RELATION = NetPoint::NET_TYPE_RELATION;
  37. const TYPE_NAME = [
  38. self::TYPE_NETWORK => ['id' => self::TYPE_NETWORK, 'name' => 'Placement network',], // 安置网络
  39. self::TYPE_RELATION => ['id' => self::TYPE_RELATION, 'name' => 'Sponsor network',], // 开拓网络
  40. ];
  41. const STATUS_APPLIED = 0; // 已申请
  42. const STATUS_AUDITED = 1; // 已审核
  43. const STATUS_FAILED = 2; // 审核失败
  44. const STATUS_REFUSED = 3; // 已拒绝
  45. const STATUS_NAME = [
  46. self::STATUS_APPLIED => 'To be reviewed', // 待审核
  47. self::STATUS_AUDITED => 'Approved', // 审核通过
  48. self::STATUS_FAILED => 'Failed', // 审核失败
  49. self::STATUS_REFUSED => 'Audit reject', // 拒绝
  50. ];
  51. /**
  52. * @inheritdoc
  53. */
  54. public static function tableName()
  55. {
  56. return '{{%USER_MOVE}}';
  57. }
  58. /**
  59. * @inheritdoc
  60. */
  61. public function rules()
  62. {
  63. return [
  64. [['USER_ID', 'FROM_UID', 'TO_UID', 'TYPE', 'PERIOD_NUM', 'MOVE_ADMIN_ID', 'CREATED_AT'], 'required'],
  65. [['LOCATION', 'IS_MOVING', 'MOVE_PERCENT', 'AUDIT_STATUS', 'PERIOD_NUM', 'UPDATE_PERIOD_NUM', 'AUDIT_PERIOD_NUM', 'CREATED_AT', 'STARTED_AT', 'ENDED_AT', 'AUDITED_AT'], 'integer'],
  66. [['ID', 'USER_ID', 'FROM_UID', 'TO_UID', 'MOVE_ADMIN_ID', 'AUDIT_ADMIN_ID', 'NET_TABLE_NAME'], 'string', 'max' => 32],
  67. [['TYPE'], 'string', 'max' => 48],
  68. [['CREATE_REMARK', 'AUDIT_REMARK'], 'string', 'max' => 4000],
  69. [['ID'], 'unique'],
  70. ];
  71. }
  72. /**
  73. * @inheritdoc
  74. */
  75. public function attributeLabels()
  76. {
  77. return [
  78. 'ID' => 'ID',
  79. 'USER_ID' => '移动的会员ID',
  80. 'FROM_UID' => '移动前接点UID',
  81. 'TO_UID' => '移动后接点UID',
  82. 'LOCATION' => '移动到位置',
  83. 'TYPE' => '移网类型',
  84. 'IS_MOVING' => '是否正在移动',
  85. 'MOVE_PERCENT' => '移动百分比',
  86. 'AUDIT_STATUS' => '审核状态',
  87. 'PERIOD_NUM' => '移动时的期数',
  88. 'UPDATE_PERIOD_NUM' => '修改期数',
  89. 'AUDIT_PERIOD_NUM' => '修改期数',
  90. 'MOVE_ADMIN_ID' => '移网管理员',
  91. 'AUDIT_ADMIN_ID' => '审核管理员',
  92. 'NET_TABLE_NAME' => '移点备份表名',
  93. 'CREATE_REMARK' => '创建备注',
  94. 'AUDIT_REMARK' => '审核备注',
  95. 'CREATED_AT' => '创建时间',
  96. 'STARTED_AT' => '移网开始时间',
  97. 'ENDED_AT' => '移网结束时间',
  98. 'AUDITED_AT' => '审核时间',
  99. ];
  100. }
  101. /**
  102. * 操作日志记录条件
  103. * @return array
  104. */
  105. public function attrLabelsWithLogType(){
  106. return [
  107. 'USER_ID' => '移动的会员ID',
  108. 'FROM_UID' => [
  109. 'label' => '移动前上级',
  110. 'type' => function($data){
  111. $value = $data['value'];
  112. return Info::getUserNameByUserId($value);
  113. },
  114. ],
  115. 'TO_UID' => [
  116. 'label' => '移动后上级',
  117. 'type' => function($data){
  118. $value = $data['value'];
  119. return Info::getUserNameByUserId($value);
  120. },
  121. ],
  122. 'LOCATION' => '移动到位置',
  123. 'TYPE' => [
  124. 'label' => '移网类型',
  125. 'type' => function($data){
  126. $value = $data['value'];
  127. return $value==self::TYPE_NETWORK?'安置网络':'开拓网络';
  128. },
  129. ],
  130. 'AUDIT_STATUS' => [
  131. 'label' => '审核状态',
  132. 'type' => ValueTypeConfig::AUDIT_STATUS_TYPE,
  133. ],
  134. 'MOVE_ADMIN_ID' => [
  135. 'label' => '创建人',
  136. 'type' => function($data){
  137. $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
  138. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  139. return !empty($result) ? $result['ADMIN_NAME'] : '';
  140. },
  141. ],
  142. 'AUDIT_ADMIN_ID' => [
  143. 'label' => '审核人',
  144. 'type' => function($data){
  145. $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
  146. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  147. return !empty($result) ? $result['ADMIN_NAME'] : '';
  148. },
  149. ],
  150. 'CREATE_REMARK' => '备注',
  151. 'CREATED_AT' => [
  152. 'label' => '创建时间',
  153. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  154. ],
  155. 'AUDITED_AT' => [
  156. 'label' => '审核时间',
  157. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  158. ],
  159. ];
  160. }
  161. }