BalanceAudit.php 5.7 KB

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