BalanceAudit.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace common\models;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\user\Info;
  5. use Yii;
  6. use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  7. /**
  8. * This is the model class for table "{{%BALANCE_AUDIT}}".
  9. *
  10. * @property string $ID
  11. * @property string $USER_ID 会员ID
  12. * @property string $LAST_DEC_LV 申请时会员级别
  13. * @property string $LAST_EMP_LV 申请时会员聘级
  14. * @property string $LAST_DEC_ROLE_ID 申请时报单中心级别
  15. * @property string $TYPE 余额类型
  16. * @property string $DEAL_TYPE 交易类型
  17. * @property string $AMOUNT 金额
  18. * @property int $AUDIT_STATUS 状态
  19. * @property string $UPDATE_ADMIN_ID 变更管理员
  20. * @property string $AUDIT_ADMIN_ID 审核管理员
  21. * @property string $CREATE_REMARK 创建备注
  22. * @property string $AUDIT_REMARK 审核备注
  23. * @property int $REMARK_IS_SHOW 前台是否展示
  24. * @property int $CREATED_AT 创建时间
  25. * @property int $AUDITED_AT 审核时间
  26. */
  27. class BalanceAudit extends \common\components\ActiveRecord
  28. {
  29. const TYPE = [
  30. 'bonus' => [
  31. 'name' => 'bonus',
  32. 'label' => '会员账户奖金',
  33. ],
  34. 'reconsume_points' => [
  35. 'name' => 'reconsume_points',
  36. 'label' => '复消积分',
  37. ],
  38. 'exchange_points' => [
  39. 'name' => 'exchange_points',
  40. 'label' => '兑换积分',
  41. ],
  42. 'cash' => [
  43. 'name' => 'cash',
  44. 'label' => '会员账户余额',
  45. ],
  46. // 'cf' => [
  47. // 'name' => 'cf',
  48. // 'label' => '车房养老奖余额',
  49. // ],
  50. // 'lx' => [
  51. // 'name' => 'lx',
  52. // 'label' => '领袖分红奖余额',
  53. // ],
  54. ];
  55. /**
  56. * @inheritdoc
  57. */
  58. public static function tableName()
  59. {
  60. return '{{%BALANCE_AUDIT}}';
  61. }
  62. /**
  63. * {@inheritdoc}
  64. */
  65. public function rules()
  66. {
  67. return [
  68. [['USER_ID', 'TYPE', 'DEAL_TYPE', 'CREATED_AT'], 'required'],
  69. [['AMOUNT'], 'number'],
  70. [['AUDIT_STATUS', 'REMARK_IS_SHOW', 'CREATED_AT', 'AUDITED_AT'], 'integer'],
  71. [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_DEC_ROLE_ID', 'DEAL_TYPE', 'UPDATE_ADMIN_ID', 'AUDIT_ADMIN_ID'], 'string', 'max' => 32],
  72. [['TYPE'], 'string', 'max' => 48],
  73. [['CREATE_REMARK', 'AUDIT_REMARK'], 'string', 'max' => 4000],
  74. [['ID'], 'unique'],
  75. ];
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function attributeLabels()
  81. {
  82. return [
  83. 'ID' => 'ID',
  84. 'USER_ID' => '会员ID',
  85. 'LAST_DEC_LV' => '申请时会员级别',
  86. 'LAST_EMP_LV' => '申请时会员聘级',
  87. 'LAST_DEC_ROLE_ID' => '申请时报单中心级别',
  88. 'TYPE' => '余额类型',
  89. 'DEAL_TYPE' => '交易类型',
  90. 'AMOUNT' => '金额',
  91. 'AUDIT_STATUS' => '状态',
  92. 'UPDATE_ADMIN_ID' => '变更管理员',
  93. 'AUDIT_ADMIN_ID' => '审核管理员',
  94. 'CREATE_REMARK' => '创建备注',
  95. 'AUDIT_REMARK' => '审核备注',
  96. 'REMARK_IS_SHOW' => '前台是否展示',
  97. 'CREATED_AT' => '创建时间',
  98. 'AUDITED_AT' => ' 审核时间',
  99. ];
  100. }
  101. /**
  102. * 操作日志记录条件
  103. * @return array
  104. */
  105. public function attrLabelsWithLogType(){
  106. return [
  107. 'USER_ID' => '会员ID',
  108. 'TYPE' => [
  109. 'label' => '余额类型',
  110. 'type' => function($data){
  111. $value = $data['value'];
  112. return \Yii::$app->params['bonusWalletType'][$value]['label'];
  113. },
  114. ],
  115. 'DEAL_TYPE' => [
  116. 'label' => '交易类型',
  117. 'type' => function($data){
  118. $value = $data['value'];
  119. $dealType = DealType::findOneAsArray('ID=:ID', [':ID'=>$value], 'TYPE_NAME');
  120. return $dealType['TYPE_NAME'];
  121. },
  122. ],
  123. 'AMOUNT' => '金额',
  124. 'AUDIT_STATUS' => [
  125. 'label' => '审核状态',
  126. 'type' => ValueTypeConfig::AUDIT_STATUS_TYPE,
  127. ],
  128. 'UPDATE_ADMIN_ID' => [
  129. 'label' => '变更管理员',
  130. 'type' => function($data){
  131. $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
  132. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  133. return !empty($result) ? $result['ADMIN_NAME'] : '';
  134. },
  135. ],
  136. 'AUDIT_ADMIN_ID' => [
  137. 'label' => '审核管理员',
  138. 'type' => function($data){
  139. $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
  140. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  141. return !empty($result) ? $result['ADMIN_NAME'] : '';
  142. },
  143. ],
  144. 'CREATE_REMARK' => '备注',
  145. 'REMARK_IS_SHOW' => [
  146. 'label' => '前台是否显示备注',
  147. 'type' => ValueTypeConfig::YES_NO_TYPE,
  148. ],
  149. 'CREATED_AT' => [
  150. 'label' => '创建时间',
  151. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  152. ],
  153. 'AUDITED_AT' => [
  154. 'label' => '审核时间',
  155. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  156. ],
  157. ];
  158. }
  159. }