RelationList.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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\UserRelation;
  9. use Yii;
  10. class RelationList 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 = UserRelation::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['RELATION_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['RELATION_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', 'recommendedMemberNo'), // 推荐会员编号
  63. 'headerOther' => ['width' => '150'],
  64. ],
  65. 'REAL_NAME' => [
  66. 'header' => Yii::t('ctx', 'nameRecommendedMember'), // 推荐会员姓名
  67. // 'headerOther' => [
  68. // 'width' => '120',
  69. // ],
  70. ],
  71. 'DEC_LV_NAME' => [
  72. 'header' => Yii::t('ctx', 'recommendedMemberLevel'), // 推荐会员级别
  73. 'headerOther' => [
  74. 'width' => '210',
  75. ],
  76. ],
  77. 'EMP_LV_NAME' => [
  78. 'header' => Yii::t('ctx', 'highestDirector'), // 推荐会员聘级
  79. 'headerOther' => [
  80. 'width' => '210',
  81. ],
  82. ],
  83. 'PERIOD_AT' => [
  84. 'header' => Yii::t('ctx', 'joiningPeriod'), // 加入期数
  85. 'headerOther' => ['width' => '110'],
  86. ],
  87. ];
  88. }
  89. return $this->columns;
  90. }
  91. /**
  92. * 前台用于筛选的类型集合
  93. * @return mixed
  94. */
  95. public function getFilterTypes() {
  96. if (!$this->filterTypes) {
  97. $this->filterTypes = [
  98. 'userName' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'modelListAtlasUserName')], // 会员编号
  99. 'deep' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'modelListAtlasDepth')], // 深度
  100. 'periodNum' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'numberOfPeriods')], // 期数
  101. ];
  102. }
  103. return $this->filterTypes;
  104. }
  105. }