PeriodPerfList.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use common\helpers\Cache;
  4. use common\models\PerfMonth;
  5. use common\models\PerfPeriod;
  6. use common\models\User as modelUser;
  7. use common\libs\dataList\column\Price;
  8. use common\libs\dataList\DataListInterface;
  9. use common\libs\dataList\column\DateTime;
  10. use Yii;
  11. class PeriodPerfList extends \common\libs\dataList\DataList implements DataListInterface
  12. {
  13. /**
  14. * 列表名称
  15. * @return string
  16. */
  17. public function getListName(){
  18. return '期业绩列表';
  19. }
  20. /**
  21. * 列表筛选到的数据
  22. * @throws \yii\base\Exception
  23. */
  24. public function dataHandle()
  25. {
  26. $data = PerfPeriod::lists($this->condition, $this->params, [
  27. 'select'=>'PM.*, U.USER_NAME, U.REAL_NAME',
  28. 'from' => PerfPeriod::tableName().' AS PM',
  29. 'join' => [
  30. ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PM.USER_ID=U.ID'],
  31. ],
  32. 'orderBy' => 'PM.CREATED_AT DESC, PM.ID DESC',
  33. 'page' => $this->page,
  34. 'pageSize' => $this->pageSize,
  35. ]);
  36. if ($data['list']) {
  37. foreach ($data['list'] as $key => $value) {
  38. $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
  39. $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
  40. }
  41. }
  42. $this->listData = $data;
  43. }
  44. /**
  45. * 要展示和导出的所有字段
  46. * @return array
  47. */
  48. public function getColumn(){
  49. if(!$this->columns){
  50. $this->columns = [
  51. 'PERIOD_NUM' => [
  52. 'header' => '期数',
  53. 'headerOther' => [
  54. 'width' => '100',
  55. ],
  56. ],
  57. 'USER_NAME' => [
  58. 'header' => '会员编号',
  59. 'headerOther' => [
  60. 'width' => '110',
  61. ],
  62. ],
  63. 'REAL_NAME' => [
  64. 'header' => '会员姓名',
  65. 'headerOther' => [
  66. 'width' => '150',
  67. ],
  68. ],
  69. 'LAST_DEC_LV_NAME' => [
  70. 'header' => '结算时会员级别',
  71. 'headerOther' => [
  72. 'width' => '150',
  73. ],
  74. ],
  75. 'LAST_EMP_LV_NAME' => [
  76. 'header' => '结算时会员聘级',
  77. 'headerOther' => [
  78. 'width' => '150',
  79. ],
  80. ],
  81. 'PV_PCS' => [
  82. 'header' => '个人业绩',
  83. 'headerOther' => [
  84. 'width' => '150',
  85. ],
  86. 'value' => function($row) {
  87. return (new Price([
  88. 'value' => $row['PV_PCS'],
  89. ]))->result();
  90. },
  91. ],
  92. 'PV_PSS' => [
  93. 'header' => '新增团队业绩',
  94. 'headerOther' => [
  95. 'width' => '150',
  96. ],
  97. 'value' => function($row) {
  98. return (new Price([
  99. 'value' => $row['PV_PSS'],
  100. ]))->result();
  101. },
  102. ],
  103. 'CREATED_AT' => [
  104. 'header' => '创建时间',
  105. 'value' => function($row) {
  106. return (new DateTime([
  107. 'value' => $row['CREATED_AT'],
  108. ]))->result();
  109. },
  110. 'headerOther' => ['width' => '170'],
  111. ],
  112. ];
  113. }
  114. return $this->columns;
  115. }
  116. /**
  117. * 前台用于筛选的类型集合
  118. * @return mixed
  119. */
  120. public function getFilterTypes()
  121. {
  122. if(!$this->filterTypes){
  123. $this->filterTypes = [
  124. 'PERIOD_NUM'=> ['isUserTable'=> false, 'name'=> '期数'],
  125. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
  126. 'CREATED_AT'=> ['isUserTable'=> false, 'name'=> '创建时间', 'other'=> 'date'],
  127. ];
  128. }
  129. return $this->filterTypes;
  130. }
  131. }