BalanceAudit.php 6.0 KB

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