PeriodBonusList.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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\UserInfo;
  10. use common\libs\dataList\column\DateTime;
  11. use Yii;
  12. class PeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
  13. {
  14. /**
  15. * 列表名称
  16. * @return string
  17. */
  18. public function getListName(){
  19. return '奖金列表';
  20. }
  21. /**
  22. * 列表筛选到的数据
  23. * @throws \yii\base\Exception
  24. */
  25. public function dataHandle()
  26. {
  27. $yearMonth = $this->others['yearMonth'];
  28. $this->listData = CalcBonus::lists($this->condition, $this->params, [
  29. 'select'=>'CB.*,UI.CON_UID,UI.REC_UID',
  30. 'from' => CalcBonus::tableName().' AS CB',
  31. 'join' => [
  32. ['INNER JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
  33. ],
  34. 'yearMonth' => $yearMonth,
  35. 'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
  36. 'page' => $this->page,
  37. 'pageSize' => $this->pageSize,
  38. ]);
  39. unset($yearMonth);
  40. if ($this->listData['list']) {
  41. foreach ($this->listData['list'] as $key => $value) {
  42. $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
  43. $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
  44. $this->listData['list'][$key]['LAST_ELITE_LV_NAME'] = Cache::getEliteLevelConfig()[$value['LAST_ELITE_LV']]['LEVEL_NAME'];
  45. $this->listData['list'][$key]['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$value['LAST_STATUS']]['label'];
  46. $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
  47. $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
  48. $this->listData['list'][$key]['LAST_CON_USER_NAME'] = Info::getUserNameByUserId($value['CON_UID']);
  49. $this->listData['list'][$key]['LAST_CON_REAL_NAME'] = Info::getUserRealNameByUserId($value['CON_UID']);
  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' => '150',
  65. ],
  66. 'valueOther' => [
  67. 'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
  68. ],
  69. ],
  70. 'CALCULATED_AT' => [
  71. 'header' => \Yii::t('ctx', 'bonusDate'), // 结算时间
  72. 'value' => function($row) {
  73. return (new DateTime([
  74. 'value' => $row['CALCULATED_AT'],
  75. ]))->result();
  76. },
  77. 'headerOther' => ['width' => '170'],
  78. ],
  79. 'LAST_USER_NAME' => [
  80. 'header' => \Yii::t('ctx', 'memberCode'), // 会员编号
  81. 'headerOther' => [
  82. 'width' => '150',
  83. ],
  84. 'valueOther' => [
  85. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  86. ],
  87. ],
  88. 'LAST_REAL_NAME' => [
  89. 'header' => \Yii::t('ctx', 'memberName'), // 会员姓名
  90. 'headerOther' => [
  91. 'width' => '120',
  92. ],
  93. 'valueOther' => [
  94. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  95. ],
  96. ],
  97. 'LAST_DEC_LV_NAME' => [
  98. 'header' => \Yii::t('ctx', 'PCMemberLevel'), // 结算时会员级别
  99. 'headerOther' => [
  100. 'width' => '140',
  101. ],
  102. ],
  103. 'LAST_EMP_LV_NAME' => [
  104. 'header' => \Yii::t('ctx', 'latestDirector'), // 结算时会员最新管理星级
  105. 'headerOther' => [
  106. 'width' => '140',
  107. ],
  108. ],
  109. 'LAST_ELITE_LV_NAME' => [
  110. 'header' => \Yii::t('ctx', 'latestElite'), // 结算时会员最新ELite
  111. 'headerOther' => [
  112. 'width' => '140',
  113. ],
  114. ],
  115. 'LAST_MOBILE' => [
  116. 'header' => \Yii::t('ctx', 'phoneNumber'),//手机号码
  117. 'headerOther' => [
  118. 'width' => '120',
  119. ],
  120. ],
  121. 'LAST_PERIOD_AT' => [
  122. 'header' => Yii::t('ctx', 'joiningPeriod'), // 加入期数
  123. 'headerOther' => [
  124. 'width' => '110',
  125. ],
  126. ],
  127. 'LAST_CREATED_AT' => [
  128. 'header' => Yii::t('ctx', 'joiningDate'), // 加入时间
  129. 'value' => function($row) {
  130. return (new DateTime([
  131. 'value' => $row['LAST_CREATED_AT'],
  132. ]))->result();
  133. },
  134. 'headerOther' => ['width' => '170'],
  135. ],
  136. 'LAST_REC_USER_NAME' => [
  137. 'header' => Yii::t('ctx', 'sponsorNo'), // 开拓者编号
  138. 'headerOther' => [
  139. 'width' => '150',
  140. ],
  141. ],
  142. 'LAST_REC_REAL_NAME' => [
  143. 'header' => Yii::t('ctx', 'sponsorName'), // 开拓者姓名
  144. 'headerOther' => [
  145. 'width' => '120',
  146. ],
  147. ],
  148. 'CALC_MONTH' => [
  149. 'header' => Yii::t('ctx', 'bonusMonth'), // 结算月
  150. 'headerOther' => [
  151. 'width' => '110',
  152. ],
  153. ],
  154. ];
  155. }
  156. return $this->columns;
  157. }
  158. /**
  159. * 前台用于筛选的类型集合
  160. * @return mixed
  161. */
  162. public function getFilterTypes()
  163. {
  164. if(!$this->filterTypes){
  165. $this->filterTypes = [
  166. 'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberCode')], // 会员编号
  167. 'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'memberName')], // 会员姓名
  168. 'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'PCMemberLevel'), 'other'=> 'decLevel'], // 结算时会员级别
  169. 'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestDirector'), 'other'=> 'empLevel'], // 结算时会员管理星级
  170. 'LAST_ELITE_LV_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'latestElite'), 'other'=> 'elite'], // 结算时会员Elite
  171. 'LAST_MOBILE'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'phoneNumber')], // 手机号
  172. 'LAST_PERIOD_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'joiningPeriod')], // 加入期数
  173. 'LAST_CREATED_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'joiningDate'), 'other'=> 'date'], // 加入时间
  174. 'CALCULATED_AT'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'date'), 'other'=> 'date'], // 备份时间
  175. 'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'sponsorNo')], // 开拓者编号
  176. 'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'sponsorName')], // 开拓者姓名
  177. 'LAST_CON_USER_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'superiorNumber')], // 上级编号
  178. 'LAST_CON_REAL_NAME'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'superiorName')], // 上级姓名
  179. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> Yii::t('ctx', 'bonusMonth')], // 结算月
  180. ];
  181. }
  182. return $this->filterTypes;
  183. }
  184. }