PeriodBonusList.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use common\helpers\Cache;
  4. use common\helpers\Tool;
  5. use common\helpers\user\Info;
  6. use common\libs\dataList\column\Price;
  7. use common\libs\dataList\DataListInterface;
  8. use common\models\CalcBonus;
  9. use common\models\Period;
  10. use common\models\UserInfo;
  11. use common\libs\dataList\column\DateTime;
  12. use Yii;
  13. class PeriodBonusList 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. $yearMonth = $this->others['yearMonth'];
  29. $this->listData = CalcBonus::lists($this->condition, $this->params, [
  30. 'select'=>'CB.*,UI.CON_UID,UI.REC_UID,PO.CALC_YEAR,PO.CALC_MONTH',
  31. 'from' => CalcBonus::tableName().' AS CB',
  32. 'join' => [
  33. ['INNER JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
  34. ['INNER JOIN', Period::tableName() . ' AS PO', 'PO.PERIOD_NUM=CB.PERIOD_NUM'],
  35. ],
  36. 'yearMonth' => $yearMonth,
  37. 'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
  38. 'page' => $this->page,
  39. 'pageSize' => $this->pageSize,
  40. ]);
  41. if ($this->listData['list']) {
  42. foreach ($this->listData['list'] as $key => $value) {
  43. $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
  44. $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
  45. $this->listData['list'][$key]['LAST_ELITE_LV_NAME'] = Cache::getEliteLevelConfig()[$value['LAST_ELITE_LV']]['LEVEL_NAME'];
  46. $this->listData['list'][$key]['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$value['LAST_STATUS']]['label'];
  47. $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
  48. $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
  49. $this->listData['list'][$key]['BONUS_YEAR_MONTH'] = $value['CALC_YEAR'] . '-' . ($value['CALC_MONTH'] >= 10 ? $value['CALC_MONTH'] : '0' . $value['CALC_MONTH']);
  50. }
  51. }
  52. }
  53. /**
  54. * 要展示和导出的所有字段
  55. * @return array
  56. */
  57. public function getColumn(){
  58. if(!$this->columns){
  59. $this->columns = [
  60. 'ID' => null,
  61. 'PERIOD_NUM' => [
  62. 'header' => \Yii::t('ctx', 'payCycle'), // 结算期数
  63. 'headerOther' => [
  64. 'width' => '100',
  65. ],
  66. 'valueOther' => [
  67. 'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
  68. ],
  69. ],
  70. 'BONUS_YEAR_MONTH' => [
  71. 'header' => Yii::t('ctx', 'bonusMonth'), // 结算月
  72. 'headerOther' => [
  73. 'width' => '110',
  74. ],
  75. ],
  76. 'LAST_USER_NAME' => [
  77. 'header' => \Yii::t('ctx', 'memberCode'), // 会员编号
  78. 'headerOther' => [
  79. 'width' => '150',
  80. ],
  81. 'valueOther' => [
  82. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  83. ],
  84. ],
  85. 'LAST_REAL_NAME' => [
  86. 'header' => \Yii::t('ctx', 'memberName'), // 会员姓名
  87. 'headerOther' => [
  88. 'width' => '120',
  89. ],
  90. 'valueOther' => [
  91. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  92. ],
  93. ],
  94. 'LAST_DEC_LV_NAME' => [
  95. 'header' => \Yii::t('ctx', 'PCMemberLevel'), // 结算时会员级别
  96. 'headerOther' => [
  97. 'width' => '140',
  98. ],
  99. ],
  100. 'LAST_EMP_LV_NAME' => [
  101. 'header' => \Yii::t('ctx', 'latestDirector'), // 结算时会员最新管理星级
  102. 'headerOther' => [
  103. 'width' => '140',
  104. ],
  105. ],
  106. 'LAST_ELITE_LV_NAME' => [
  107. 'header' => \Yii::t('ctx', 'latestElite'), // 结算时会员最新ELite
  108. 'headerOther' => [
  109. 'width' => '140',
  110. ],
  111. ],
  112. 'LAST_REC_USER_NAME' => [
  113. 'header' => Yii::t('ctx', 'sponsorNo'), // 开拓者编号
  114. 'headerOther' => [
  115. 'width' => '150',
  116. ],
  117. ],
  118. 'LAST_REC_REAL_NAME' => [
  119. 'header' => Yii::t('ctx', 'sponsorName'), // 开拓者姓名
  120. 'headerOther' => [
  121. 'width' => '120',
  122. ],
  123. ],
  124. ];
  125. }
  126. return $this->columns;
  127. }
  128. /**
  129. * 前台用于筛选的类型集合
  130. * @return mixed
  131. */
  132. public function getFilterTypes()
  133. {
  134. if(!$this->filterTypes){
  135. $this->filterTypes = [
  136. 'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberCode')], // 会员编号
  137. 'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberName')], // 会员姓名
  138. 'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'PCMemberLevel'), 'other'=> 'decLevel'], // 结算时会员级别
  139. 'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestDirector'), 'other'=> 'empLevel'], // 结算时会员管理星级
  140. 'LAST_ELITE_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestElite'), 'other'=> 'elite'], // 结算时会员Elite
  141. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'bonusMonth')], // 结算月
  142. ];
  143. }
  144. return $this->filterTypes;
  145. }
  146. }