ReconsumeAudit.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. namespace common\models;
  3. use backendApi\modules\v1\models\Admin;
  4. use Yii;
  5. use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  6. /**
  7. * This is the model class for table "{{%RECONSUME_AUDIT}}".
  8. *
  9. * @property string $ID
  10. * @property string $USER_ID 会员ID
  11. * @property int $TYPE 类型
  12. * @property string $CHANGE_PV 变动PV
  13. * @property int $CHANGE_MONTH 变动月数
  14. * @property int $CALC_MONTH 扣月复销时的结算月
  15. * @property int $AUDIT_STATUS 审核状态
  16. * @property string $CREATE_ADMIN 创建管理员
  17. * @property string $AUDIT_ADMIN 审核管理员
  18. * @property string $CREATE_REMARK 申请备注
  19. * @property string $AUDIT_REMARK 审核备注
  20. * @property int $REMARK_IS_SHOW 申请备注是否显示
  21. * @property int $CREATED_AT 创建时间
  22. * @property int $AUDITED_AT 审核时间
  23. */
  24. class ReconsumeAudit extends \common\components\ActiveRecord
  25. {
  26. const TYPE_CHANGE = 0; // 一般性质的变动余额和月数,不影响复销得奖资格
  27. const TYPE_RECONSUME = 1; // 扣除复销余额和月数,并使下个月得奖复销有效
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public static function tableName()
  32. {
  33. return '{{%RECONSUME_AUDIT}}';
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function rules()
  39. {
  40. return [
  41. [['USER_ID', 'CREATE_ADMIN', 'CREATED_AT'], 'required'],
  42. [['TYPE', 'CHANGE_MONTH', 'CALC_MONTH', 'AUDIT_STATUS', 'REMARK_IS_SHOW', 'CREATED_AT', 'AUDITED_AT'], 'integer'],
  43. [['CHANGE_PV'], 'number'],
  44. [['ID', 'USER_ID', 'CREATE_ADMIN', 'AUDIT_ADMIN'], 'string', 'max' => 32],
  45. [['CREATE_REMARK', 'AUDIT_REMARK'], 'string', 'max' => 4000],
  46. [['ID'], 'unique'],
  47. ];
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function attributeLabels()
  53. {
  54. return [
  55. 'ID' => 'ID',
  56. 'USER_ID' => '会员ID',
  57. 'TYPE' => '类型',
  58. 'CHANGE_PV' => '变动PV',
  59. 'CHANGE_MONTH' => '变动月数',
  60. 'CALC_MONTH' => '扣月复销时的结算月',
  61. 'AUDIT_STATUS' => '审核状态',
  62. 'CREATE_ADMIN' => '创建管理员',
  63. 'AUDIT_ADMIN' => '审核管理员',
  64. 'CREATE_REMARK' => '申请备注',
  65. 'AUDIT_REMARK' => '审核备注',
  66. 'REMARK_IS_SHOW' => '申请备注是否显示',
  67. 'CREATED_AT' => '创建时间',
  68. 'AUDITED_AT' => '审核时间',
  69. ];
  70. }
  71. /**
  72. * 操作日志记录条件
  73. * @return array
  74. */
  75. public function attrLabelsWithLogType(){
  76. return [
  77. 'USER_ID' => '会员ID',
  78. 'TYPE' => [
  79. 'label' => '类型',
  80. 'type' => function($data){
  81. $value = $data['value'];
  82. return $value==self::TYPE_CHANGE?'调整积分余额':'调整剩余月份';
  83. },
  84. ],
  85. 'CHANGE_PV' => '变动PV',
  86. 'CHANGE_MONTH' => '变动月数',
  87. 'AUDIT_STATUS' => [
  88. 'label' => '审核状态',
  89. 'type' => ValueTypeConfig::AUDIT_STATUS_TYPE,
  90. ],
  91. 'CREATE_ADMIN' => [
  92. 'label' => '申请人',
  93. 'type' => function($data){
  94. $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
  95. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  96. return !empty($result) ? $result['ADMIN_NAME'] : '';
  97. },
  98. ],
  99. 'AUDIT_ADMIN' => [
  100. 'label' => '审核人',
  101. 'type' => function($data){
  102. $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
  103. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  104. return !empty($result) ? $result['ADMIN_NAME'] : '';
  105. },
  106. ],
  107. 'CREATE_REMARK' => '备注',
  108. 'REMARK_IS_SHOW' => [
  109. 'label' => '申请备注是否显示',
  110. 'type' => ValueTypeConfig::YES_NO_TYPE,
  111. ],
  112. 'CREATED_AT' => [
  113. 'label' => '申请时间',
  114. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  115. ],
  116. 'AUDITED_AT' => [
  117. 'label' => '审核时间',
  118. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  119. ],
  120. ];
  121. }
  122. }