NetworkList.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\atlas;
  3. use common\helpers\Cache;
  4. use common\helpers\user\Info;
  5. use common\libs\dataList\DataListInterface;
  6. use common\models\EmployLevel;
  7. use common\models\Period;
  8. use common\models\UserNetwork;
  9. use Yii;
  10. class NetworkList extends \common\libs\dataList\DataList implements DataListInterface {
  11. /**
  12. * 列表名称
  13. * @return string
  14. */
  15. public function getListName() {
  16. return '安置网络列表';
  17. }
  18. /**
  19. * 列表筛选到的数据
  20. * @throws \yii\base\Exception
  21. */
  22. public function dataHandle() {
  23. $userId = $this->others['userId'];
  24. $deep = $this->others['deep'];
  25. $periodNum = $this->others['periodNum'];
  26. $period = Period::instance();
  27. $mainUserInfo = Info::baseInfo($userId, $periodNum);
  28. $decLevelConfig = Cache::getDecLevelConfig();
  29. $empLevelConfig = Cache::getEmpLevelConfig();
  30. $param = [];
  31. if ( $this->pageSize ) $param['pageSize'] = $this->pageSize;
  32. if ( $this->page !== null ) $param['page'] = $this->page;
  33. $this->listData = UserNetwork::getChildrenInDeepFromPeriodWithPage($userId, $deep, $periodNum, $param);
  34. foreach($this->listData['list'] as $key=>$value){
  35. $userBaseInfo = Info::baseInfo($value['USER_ID'], $periodNum);
  36. $this->listData['list'][$key]['LIST_PERIOD_NUM'] = $periodNum?$periodNum:$period->getNowPeriodNum();
  37. $this->listData['list'][$key]['COUNT_DEEP'] = (int)($userBaseInfo['NETWORK_DEEP']);
  38. $this->listData['list'][$key]['USER_NAME'] = $userBaseInfo['USER_NAME'];
  39. $this->listData['list'][$key]['SEE_USER_NAME'] = $userBaseInfo['USER_NAME'];
  40. $this->listData['list'][$key]['REAL_NAME'] = $userBaseInfo['REAL_NAME'];
  41. $this->listData['list'][$key]['PERIOD_AT'] = $userBaseInfo['PERIOD_AT'];
  42. $this->listData['list'][$key]['DEC_LV_NAME'] = $decLevelConfig[$userBaseInfo['DEC_LV']]['LEVEL_NAME'];
  43. $this->listData['list'][$key]['EMP_LV_NAME'] = isset($empLevelConfig[$userBaseInfo['EMP_LV']])?$empLevelConfig[$userBaseInfo['EMP_LV']]['LEVEL_NAME']:$empLevelConfig[EmployLevel::getDefaultLevelId()]['LEVEL_NAME'];
  44. }
  45. $this->listData['periodNum'] = $periodNum;
  46. $this->listData['listTopDeep'] = $mainUserInfo['NETWORK_DEEP'];
  47. }
  48. /**
  49. * 要展示和导出的所有字段
  50. * @return array
  51. */
  52. public function getColumn() {
  53. if (!$this->columns) {
  54. $this->columns = [
  55. 'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  56. 'SEE_USER_NAME' => null,
  57. 'COUNT_DEEP' => [
  58. 'header' => Yii::t('ctx', 'numberOfLayers'), // 层数
  59. 'headerOther' => ['width' => '140'],
  60. ],
  61. 'USER_NAME' => [
  62. 'header' => Yii::t('ctx', 'placementMemberNumber'), // 安置会员编号
  63. 'headerOther' => ['width' => '150'],
  64. ],
  65. 'REAL_NAME' => [
  66. 'header' => Yii::t('ctx', 'placementMemberName'), // 安置会员姓名
  67. ],
  68. 'DEC_LV_NAME' => [
  69. 'header' => Yii::t('ctx', 'recommendedMemberLevel'), // 推荐会员级别
  70. 'headerOther' => [
  71. 'width' => '210',
  72. ],
  73. ],
  74. 'EMP_LV_NAME' => [
  75. 'header' => Yii::t('ctx', 'highestDirector'), // 最高管理星级
  76. 'headerOther' => [
  77. 'width' => '210',
  78. ],
  79. ],
  80. 'CROWN_LV_NAME' => [
  81. 'header' => Yii::t('ctx', 'highestCrown'), // 最高皇冠星级
  82. 'headerOther' => [
  83. 'width' => '210',
  84. ],
  85. ],
  86. 'PERIOD_AT' => [
  87. 'header' => Yii::t('ctx', 'joiningPeriod'), // 加入期数
  88. 'headerOther' => ['width' => '110'],
  89. ],
  90. ];
  91. }
  92. return $this->columns;
  93. }
  94. /**
  95. * 前台用于筛选的类型集合
  96. * @return mixed
  97. */
  98. public function getFilterTypes() {
  99. if (!$this->filterTypes) {
  100. $this->filterTypes = [
  101. 'userName' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'modelListAtlasUserName')], // 会员编号
  102. 'deep' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'modelListAtlasDepth')], // 深度
  103. 'periodNum' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'numberOfPeriods')], // 期数
  104. ];
  105. }
  106. return $this->filterTypes;
  107. }
  108. }