BalanceAudit.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. // 'tourism_points' => [
  55. // 'name' => 'tourism_points',
  56. // 'label' => '旅游积分',
  57. // ],
  58. 'garage_points' => [
  59. 'name' => 'garage_points',
  60. 'label' => '车房积分',
  61. ],
  62. ];
  63. /**
  64. * @inheritdoc
  65. */
  66. public static function tableName()
  67. {
  68. return '{{%BALANCE_AUDIT}}';
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function rules()
  74. {
  75. return [
  76. [['USER_ID', 'TYPE', 'DEAL_TYPE', 'CREATED_AT'], 'required'],
  77. [['AMOUNT'], 'number'],
  78. [['AUDIT_STATUS', 'REMARK_IS_SHOW', 'CREATED_AT', 'AUDITED_AT'], 'integer'],
  79. [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_DEC_ROLE_ID', 'DEAL_TYPE', 'UPDATE_ADMIN_ID', 'AUDIT_ADMIN_ID'], 'string', 'max' => 32],
  80. [['TYPE'], 'string', 'max' => 48],
  81. [['CREATE_REMARK', 'AUDIT_REMARK'], 'string', 'max' => 4000],
  82. [['ID'], 'unique'],
  83. ];
  84. }
  85. /**
  86. * {@inheritdoc}
  87. */
  88. public function attributeLabels()
  89. {
  90. return [
  91. 'ID' => 'ID',
  92. 'USER_ID' => '会员ID',
  93. 'LAST_DEC_LV' => '申请时会员级别',
  94. 'LAST_EMP_LV' => '申请时会员聘级',
  95. 'LAST_DEC_ROLE_ID' => '申请时报单中心级别',
  96. 'TYPE' => '余额类型',
  97. 'DEAL_TYPE' => '交易类型',
  98. 'AMOUNT' => '金额',
  99. 'AUDIT_STATUS' => '状态',
  100. 'UPDATE_ADMIN_ID' => '变更管理员',
  101. 'AUDIT_ADMIN_ID' => '审核管理员',
  102. 'CREATE_REMARK' => '创建备注',
  103. 'AUDIT_REMARK' => '审核备注',
  104. 'REMARK_IS_SHOW' => '前台是否展示',
  105. 'CREATED_AT' => '创建时间',
  106. 'AUDITED_AT' => ' 审核时间',
  107. ];
  108. }
  109. /**
  110. * 操作日志记录条件
  111. * @return array
  112. */
  113. public function attrLabelsWithLogType(){
  114. return [
  115. 'USER_ID' => '会员ID',
  116. 'TYPE' => [
  117. 'label' => '余额类型',
  118. 'type' => function($data){
  119. $value = $data['value'];
  120. return \Yii::$app->params['bonusWalletType'][$value]['label'];
  121. },
  122. ],
  123. 'DEAL_TYPE' => [
  124. 'label' => '交易类型',
  125. 'type' => function($data){
  126. $value = $data['value'];
  127. $dealType = DealType::findOneAsArray('ID=:ID', [':ID'=>$value], 'TYPE_NAME');
  128. return $dealType['TYPE_NAME'];
  129. },
  130. ],
  131. 'AMOUNT' => '金额',
  132. 'AUDIT_STATUS' => [
  133. 'label' => '审核状态',
  134. 'type' => ValueTypeConfig::AUDIT_STATUS_TYPE,
  135. ],
  136. 'UPDATE_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. 'AUDIT_ADMIN_ID' => [
  145. 'label' => '审核管理员',
  146. 'type' => function($data){
  147. $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
  148. $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
  149. return !empty($result) ? $result['ADMIN_NAME'] : '';
  150. },
  151. ],
  152. 'CREATE_REMARK' => '备注',
  153. 'REMARK_IS_SHOW' => [
  154. 'label' => '前台是否显示备注',
  155. 'type' => ValueTypeConfig::YES_NO_TYPE,
  156. ],
  157. 'CREATED_AT' => [
  158. 'label' => '创建时间',
  159. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  160. ],
  161. 'AUDITED_AT' => [
  162. 'label' => '审核时间',
  163. 'type' => ValueTypeConfig::DATE_TIME_TYPE,
  164. ],
  165. ];
  166. }
  167. }