PeriodBonusList.php 8.0 KB

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