PeriodBonusList.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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\DataListInterface;
  7. use common\models\CalcBonus;
  8. use common\models\DeclarationLevel;
  9. use common\models\EliteLevel;
  10. use common\models\EmployLevel;
  11. use common\models\Period;
  12. use common\models\UserInfo;
  13. use Yii;
  14. class PeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
  15. {
  16. /**
  17. * 列表名称
  18. * @return string
  19. */
  20. public function getListName(){
  21. return '奖金列表';
  22. }
  23. /**
  24. * 列表筛选到的数据
  25. * @throws \yii\base\Exception
  26. */
  27. public function dataHandle()
  28. {
  29. $yearMonth = $this->others['yearMonth'];
  30. $this->listData = CalcBonus::lists($this->condition, $this->params, [
  31. 'select'=>'CB.*,UI.CON_UID,UI.REC_UID,PO.CALC_YEAR,PO.CALC_MONTH',
  32. 'from' => CalcBonus::tableName().' AS CB',
  33. 'join' => [
  34. ['INNER JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
  35. ['INNER JOIN', Period::tableName() . ' AS PO', 'PO.PERIOD_NUM=CB.PERIOD_NUM'],
  36. ],
  37. 'yearMonth' => $yearMonth,
  38. 'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
  39. 'page' => $this->page,
  40. 'pageSize' => $this->pageSize,
  41. ]);
  42. if ($this->listData['list']) {
  43. foreach ($this->listData['list'] as $key => $value) {
  44. $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? Cache::getDecLevelConfig()[DeclarationLevel::getDefaultLevelId()]['LEVEL_NAME'];
  45. $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? Cache::getEmpLevelConfig()[EmployLevel::getDefaultLevelId()]['LEVEL_NAME'];
  46. $this->listData['list'][$key]['LAST_ELITE_LV_NAME'] = Cache::getEliteLevelConfig()[$value['LAST_ELITE_LV']]['LEVEL_NAME'] ?? Cache::getEliteLevelConfig()[EliteLevel::getDefaultLevelId()]['LEVEL_NAME'];
  47. $this->listData['list'][$key]['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$value['LAST_STATUS']]['label'];
  48. $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
  49. $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
  50. $this->listData['list'][$key]['BONUS_YEAR_MONTH'] = $value['CALC_YEAR'] . '-' . ($value['CALC_MONTH'] >= 10 ? $value['CALC_MONTH'] : '0' . $value['CALC_MONTH']);
  51. }
  52. }
  53. }
  54. /**
  55. * 要展示和导出的所有字段
  56. * @return array
  57. */
  58. public function getColumn(){
  59. if(!$this->columns){
  60. $this->columns = [
  61. 'ID' => null,
  62. 'PERIOD_NUM' => [
  63. 'header' => \Yii::t('ctx', 'payCycle'), // 结算期数
  64. 'headerOther' => [
  65. 'width' => '130',
  66. ],
  67. 'valueOther' => [
  68. 'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
  69. ],
  70. ],
  71. 'BONUS_YEAR_MONTH' => [
  72. 'header' => Yii::t('ctx', 'bonusMonth'), // 结算月
  73. 'headerOther' => [
  74. 'width' => '110',
  75. ],
  76. ],
  77. 'LAST_USER_NAME' => [
  78. 'header' => \Yii::t('ctx', 'memberCode'), // 会员编号
  79. 'headerOther' => [
  80. 'width' => '150',
  81. ],
  82. 'valueOther' => [
  83. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  84. ],
  85. ],
  86. 'LAST_REAL_NAME' => [
  87. 'header' => \Yii::t('ctx', 'memberName'), // 会员姓名
  88. 'headerOther' => [
  89. 'width' => '120',
  90. ],
  91. 'valueOther' => [
  92. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  93. ],
  94. ],
  95. 'LAST_DEC_LV_NAME' => [
  96. 'header' => \Yii::t('ctx', 'PCMemberLevel'), // 结算时会员级别
  97. 'headerOther' => [
  98. 'width' => '140',
  99. ],
  100. ],
  101. 'LAST_EMP_LV_NAME' => [
  102. 'header' => \Yii::t('ctx', 'latestDirector'), // 结算时会员最新管理星级
  103. 'headerOther' => [
  104. 'width' => '140',
  105. ],
  106. ],
  107. 'LAST_ELITE_LV_NAME' => [
  108. 'header' => \Yii::t('ctx', 'latestElite'), // 结算时会员最新ELite
  109. 'headerOther' => [
  110. 'width' => '140',
  111. ],
  112. ],
  113. 'LAST_REC_USER_NAME' => [
  114. 'header' => Yii::t('ctx', 'sponsorNo'), // 开拓者编号
  115. 'headerOther' => [
  116. 'width' => '150',
  117. ],
  118. ],
  119. 'BONUS_PB' => [
  120. 'header' => Yii::t('ctx', 'performanceBonus'), // 绩效奖
  121. 'headerOther' => [
  122. 'width' => '150',
  123. ],
  124. ],
  125. 'BONUS_TOTAL' => [
  126. 'header' => Yii::t('ctx', 'totalBonus'), // 总奖金
  127. 'headerOther' => [
  128. 'width' => '120',
  129. ],
  130. ],
  131. 'BONUS_E' => [
  132. 'header' => Yii::t('ctx', 'eliteBonus'), // Elite奖金
  133. 'headerOther' => [
  134. 'width' => '120',
  135. ],
  136. ],
  137. 'BONUS_PE' => [
  138. 'header' => Yii::t('ctx', 'proEliteBonus'), // Pro_Elite奖金
  139. 'headerOther' => [
  140. 'width' => '120',
  141. ],
  142. ],
  143. 'BONUS_SE' => [
  144. 'header' => Yii::t('ctx', 'superEliteBonus'), // Super_Elite奖金
  145. 'headerOther' => [
  146. 'width' => '150',
  147. ],
  148. ],
  149. 'BONUS_LB' => [
  150. 'header' => Yii::t('ctx', 'leaderShipBonus'), // LeaderShip奖金
  151. 'headerOther' => [
  152. 'width' => '150',
  153. ],
  154. ],
  155. 'BONUS_ST' => [
  156. 'header' => Yii::t('ctx', 'stockistBonus'), // 店铺奖
  157. 'headerOther' => [
  158. 'width' => '120',
  159. ],
  160. ],
  161. 'BONUS_WB' => [
  162. 'header' => Yii::t('ctx', 'welcomeBonus'), // 迎新奖
  163. 'headerOther' => [
  164. 'width' => '130',
  165. ],
  166. ],
  167. 'BONUS_CAR' => [
  168. 'header' => Yii::t('ctx', 'carBonus'), // 车奖
  169. 'headerOther' => [
  170. 'width' => '120',
  171. ],
  172. ],
  173. ];
  174. }
  175. return $this->columns;
  176. }
  177. /**
  178. * 前台用于筛选的类型集合
  179. * @return mixed
  180. */
  181. public function getFilterTypes()
  182. {
  183. if(!$this->filterTypes){
  184. $this->filterTypes = [
  185. 'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberCode')], // 会员编号
  186. 'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberName')], // 会员姓名
  187. 'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'PCMemberLevel'), 'other'=> 'decLevel'], // 结算时会员级别
  188. 'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestDirector'), 'other'=> 'empLevel'], // 结算时会员管理星级
  189. 'LAST_ELITE_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestElite'), 'other'=> 'elite'], // 结算时会员Elite
  190. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'bonusMonth')], // 结算月
  191. ];
  192. }
  193. return $this->filterTypes;
  194. }
  195. }