PerfStandardList.php 5.2 KB

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