BalanceList.php 6.5 KB

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