BalanceList.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\user\Info;
  5. use common\libs\dataList\column\Price;
  6. use common\libs\dataList\column\YesNo;
  7. use common\libs\dataList\DataListInterface;
  8. use common\models\User;
  9. use common\models\UserBind;
  10. use common\models\UserBonus;
  11. use common\models\UserInfo;
  12. use common\libs\dataList\column\DateTime;
  13. use common\models\UserPerformance;
  14. use common\models\UserWallet;
  15. use common\models\Withdraw;
  16. use Yii;
  17. class BalanceList extends \common\libs\dataList\DataList implements DataListInterface
  18. {
  19. /**
  20. * 列表名称
  21. * @return string
  22. */
  23. public function getListName(){
  24. return '会员奖金余额列表';
  25. }
  26. /**
  27. * 列表筛选到的数据
  28. * @throws \yii\base\Exception
  29. */
  30. public function dataHandle()
  31. {
  32. $this->condition .= ' AND UI.STATUS=1 AND I.LAST_LOGIN_AT>=1620748800';
  33. $this->listData = UserBonus::lists($this->condition, $this->params, [
  34. 'select' => 'UB.*,UI.*,UW.CASH, UP.AMOUNTS AS PRP',
  35. 'from' => UserBonus::tableName() . ' AS UB',
  36. 'join' => [
  37. ['LEFT JOIN', User::tableName() . ' AS UI', 'UI.ID=UB.USER_ID'],
  38. ['LEFT JOIN', UserWallet::tableName() . ' AS UW', 'UW.USER_ID=UB.USER_ID'],
  39. ['LEFT JOIN', UserInfo::tableName() . ' AS I', 'I.USER_ID=UB.USER_ID'],
  40. ['LEFT JOIN', "(SELECT USER_ID,SUM(AMOUNTS) AS AMOUNTS FROM AR_USER_PERFORMANCE WHERE STATUS_ID<30 GROUP BY USER_ID) UP", 'UW.USER_ID=UP.USER_ID']
  41. ],
  42. 'orderBy' => 'UB.CREATED_AT ASC, UB.ID ASC',
  43. 'page' => $this->page,
  44. 'pageSize' => $this->pageSize,
  45. ]);
  46. }
  47. /**
  48. * 要展示和导出的所有字段
  49. * @return array
  50. */
  51. public function getColumn(){
  52. if(!$this->columns){
  53. $this->columns = [
  54. 'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  55. 'USER_NAME' => [
  56. 'header' => \Yii::t('ctx', 'memberCode'), // 会员编号
  57. 'headerOther' => [
  58. 'width' => '150',
  59. ],
  60. 'valueOther' => [
  61. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  62. ],
  63. ],
  64. 'REAL_NAME' => [
  65. 'header' => \Yii::t('ctx', 'memberName'), // 会员姓名
  66. 'headerOther' => [
  67. 'width' => '250',
  68. ],
  69. 'valueOther' => [
  70. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  71. ],
  72. ],
  73. 'IS_DEC' => [
  74. 'header' => \Yii::t('ctx', 'whetherStockist'), // 是否报单中心
  75. 'value' => function($row) {
  76. return (new YesNo([
  77. 'value' => $row['IS_DEC'],
  78. ]))->result();
  79. },
  80. 'headerOther' => function($row) {
  81. return [
  82. 'width' => '200',
  83. ];
  84. },
  85. 'valueOther' => function($row) {
  86. return [
  87. 'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
  88. ];
  89. },
  90. ],
  91. 'BONUS' => [
  92. 'header' => \Yii::t('ctx', 'memberBonus'), // 会员奖金余额
  93. 'value' => function($row) {
  94. return (new Price([
  95. 'value' => $row['BONUS'],
  96. ]))->result();
  97. },
  98. 'headerOther' => [
  99. 'width' => '150',
  100. 'prop'=>'BONUS',
  101. ],
  102. 'valueOther' => [
  103. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  104. ],
  105. ],
  106. 'CASH' => [
  107. 'header' => \Yii::t('ctx', 'memberEcoin'), // 会员余额
  108. 'value' => function($row) {
  109. return (new Price([
  110. 'value' => $row['CASH'],
  111. ]))->result();
  112. },
  113. 'headerOther' => [
  114. 'width' => '150',
  115. 'prop'=>'BONUS',
  116. ],
  117. 'valueOther' => [
  118. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  119. ],
  120. ],
  121. 'USER_PERFORMANCE_BONUS' => [
  122. 'header' => \Yii::t('ctx', 'userPerformance'), // 绩效奖金
  123. 'value' => function($row) {
  124. return (new Price([
  125. 'value' => $row['PRP'],
  126. ]))->result();
  127. },
  128. 'headerOther' => [
  129. 'width' => '150',
  130. 'prop'=>'USER_PERFORMANCE_BONUS',
  131. ],
  132. 'valueOther' => [
  133. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  134. ],
  135. ],
  136. ];
  137. }
  138. return $this->columns;
  139. }
  140. /**
  141. * 前台用于筛选的类型集合
  142. * @return mixed
  143. */
  144. public function getFilterTypes()
  145. {
  146. if(!$this->filterTypes){
  147. $this->filterTypes = [
  148. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'memberCode')], // 会员编号
  149. 'REAL_NAME'=> ['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'memberName')], // 会员姓名
  150. 'IS_DEC'=> ['isUserTable'=> false, 'name'=> \Yii::t('ctx', 'whetherStockist'), 'other'=> 'yesOrNo'], // 是否报单中心
  151. ];
  152. }
  153. return $this->filterTypes;
  154. }
  155. }