BalanceAudit.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. 'cash' => [
  39. 'name' => 'cash',
  40. 'label' => '会员账户余额',
  41. ],
  42. // 'cf' => [
  43. // 'name' => 'cf',
  44. // 'label' => '车房养老奖余额',
  45. // ],
  46. // 'lx' => [
  47. // 'name' => 'lx',
  48. // 'label' => '领袖分红奖余额',
  49. // ],
  50. ];
  51. /**
  52. * @inheritdoc
  53. */
  54. public static function tableName()
  55. {
  56. return '{{%BALANCE_AUDIT}}';
  57. }
  58. /**
  59. * {@inheritdoc}
  60. */
  61. public function rules()
  62. {
  63. return [
  64. [['USER_ID', 'TYPE', 'DEAL_TYPE', 'CREATED_AT'], 'required'],
  65. [['AMOUNT'], 'number'],
  66. [['AUDIT_STATUS', 'REMARK_IS_SHOW', 'CREATED_AT', 'AUDITED_AT'], 'integer'],
  67. [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_DEC_ROLE_ID', 'DEAL_TYPE', 'UPDATE_ADMIN_ID', 'AUDIT_ADMIN_ID'], 'string', 'max' => 32],
  68. [['TYPE'], 'string', 'max' => 48],
  69. [['CREATE_REMARK', 'AUDIT_REMARK'], 'string', 'max' => 4000],
  70. [['ID'], 'unique'],
  71. ];
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. public function attributeLabels()
  77. {
  78. return [
  79. 'ID' => 'ID',
  80. 'USER_ID' => '会员ID',
  81. 'LAST_DEC_LV' => '申请时会员级别',
  82. 'LAST_EMP_LV' => '申请时会员聘级',
  83. 'LAST_DEC_ROLE_ID' => '申请时报单中心级别',
  84. 'TYPE' => '余额类型',
  85. 'DEAL_TYPE' => '交易类型',
  86. 'AMOUNT' => '金额',
  87. 'AUDIT_STATUS' => '状态',
  88. 'UPDATE_ADMIN_ID' => '变更管理员',
  89. 'AUDIT_ADMIN_ID' => '审核管理员',
  90. 'CREATE_REMARK' => '创建备注',
  91. 'AUDIT_REMARK' => '审核备注',
  92. 'REMARK_IS_SHOW' => '前台是否展示',
  93. 'CREATED_AT' => '创建时间',
  94. 'AUDITED_AT' => ' 审核时间',
  95. ];
  96. }
  97. /**
  98. * 操作日志记录条件
  99. * @return array
  100. */
  101. public function attrLabelsWithLogType(){
  102. return [
  103. 'USER_ID' => '会员ID',
  104. 'TYPE' => [
  105. 'label' => '余额类型',
  106. 'type' => function($data){
  107. $value = $data['value'];
  108. return \Yii::$app->params['bonusWalletType'][$value]['label'];
  109. },
  110. ],
  111. 'DEAL_TYPE' => [
  112. 'label' => '交易类型',
  113. 'type' => function($data){
  114. $value = $data['value'];
  115. $dealType = DealType::findOneAsArray('ID=:ID', [':ID'=>$value], 'TYPE_NAME');
  116. return $dealType['TYPE_NAME'];
  117. },
  118. ],
  119. 'AMOUNT' => '金额',
  120. 'AUDIT_STATUS' => [
  121. 'label' => '审核状态',
  122. 'type' => ValueTypeConfig::AUDIT_STATUS_TYPE,
  123. ],
  124. 'UPDATE_ADMIN_ID' => [
  125. 'label' => '变更管理员',
  126. 'type' => function($data){
  127. $value = $data['value'];
  128. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  129. return $result['ADMIN_NAME'];
  130. },
  131. ],
  132. 'AUDIT_ADMIN_ID' => [
  133. 'label' => '审核管理员',
  134. 'type' => function($data){
  135. $value = $data['value'];
  136. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  137. return $result['ADMIN_NAME'];
  138. },
  139. ],
  140. 'CREATE_REMARK' => '备注',
  141. 'REMARK_IS_SHOW' => [
  142. 'label' => '前台是否显示备注',
  143. 'type' => ValueTypeConfig::YES_NO_TYPE,
  144. ],
  145. 'CREATED_AT' => [
  146. 'label' => '创建时间',
  147. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  148. ],
  149. 'AUDITED_AT' => [
  150. 'label' => '审核时间',
  151. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  152. ],
  153. ];
  154. }
  155. }