PeriodBonusList.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. 'LAST_DEC_LV_NAME' => [
  100. 'header' => \Yii::t('ctx', 'PCMemberLevel'), // 结算时会员级别
  101. 'headerOther' => [
  102. 'width' => '140',
  103. ],
  104. ],
  105. 'LAST_EMP_LV_NAME' => [
  106. 'header' => \Yii::t('ctx', 'latestDirector'), // 结算时会员最新管理星级
  107. 'headerOther' => [
  108. 'width' => '140',
  109. ],
  110. ],
  111. 'LAST_ELITE_LV_NAME' => [
  112. 'header' => \Yii::t('ctx', 'latestElite'), // 结算时会员最新ELite
  113. 'headerOther' => [
  114. 'width' => '140',
  115. ],
  116. ],
  117. 'LAST_REC_USER_NAME' => [
  118. 'header' => Yii::t('ctx', 'sponsorNo'), // 开拓者编号
  119. 'headerOther' => [
  120. 'width' => '150',
  121. ],
  122. ],
  123. 'BONUS_PB' => [
  124. 'header' => Yii::t('ctx', 'performanceBonus'), // 绩效奖
  125. 'headerOther' => [
  126. 'width' => '150',
  127. ],
  128. ],
  129. 'BONUS_TOTAL' => [
  130. 'header' => Yii::t('ctx', 'totalBonus'), // 总奖金
  131. 'headerOther' => [
  132. 'width' => '120',
  133. ],
  134. ],
  135. 'BONUS_E' => [
  136. 'header' => Yii::t('ctx', 'eliteBonus'), // Elite奖金
  137. 'headerOther' => [
  138. 'width' => '120',
  139. ],
  140. ],
  141. 'BONUS_PE' => [
  142. 'header' => Yii::t('ctx', 'proEliteBonus'), // Pro_Elite奖金
  143. 'headerOther' => [
  144. 'width' => '120',
  145. ],
  146. ],
  147. 'BONUS_SE' => [
  148. 'header' => Yii::t('ctx', 'superEliteBonus'), // Super_Elite奖金
  149. 'headerOther' => [
  150. 'width' => '150',
  151. ],
  152. ],
  153. 'BONUS_LB' => [
  154. 'header' => Yii::t('ctx', 'leaderShipBonus'), // LeaderShip奖金
  155. 'headerOther' => [
  156. 'width' => '150',
  157. ],
  158. ],
  159. 'BONUS_ST' => [
  160. 'header' => Yii::t('ctx', 'stockistBonus'), // 店铺奖
  161. 'headerOther' => [
  162. 'width' => '120',
  163. ],
  164. ],
  165. 'BONUS_WB' => [
  166. 'header' => Yii::t('ctx', 'welcomeBonus'), // 迎新奖
  167. 'headerOther' => [
  168. 'width' => '130',
  169. ],
  170. ],
  171. 'BONUS_CAR' => [
  172. 'header' => Yii::t('ctx', 'carBonus'), // 车奖
  173. 'headerOther' => [
  174. 'width' => '120',
  175. ],
  176. ],
  177. ];
  178. }
  179. return $this->columns;
  180. }
  181. /**
  182. * 前台用于筛选的类型集合
  183. * @return mixed
  184. */
  185. public function getFilterTypes()
  186. {
  187. if(!$this->filterTypes){
  188. $this->filterTypes = [
  189. 'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberCode')], // 会员编号
  190. 'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberName')], // 会员姓名
  191. 'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'PCMemberLevel'), 'other'=> 'decLevel'], // 结算时会员级别
  192. 'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestDirector'), 'other'=> 'empLevel'], // 结算时会员管理星级
  193. 'LAST_ELITE_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestElite'), 'other'=> 'elite'], // 结算时会员Elite
  194. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'bonusMonth')], // 结算月
  195. ];
  196. }
  197. return $this->filterTypes;
  198. }
  199. }