PeriodBonusList.php 8.7 KB

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