RelationList.php 4.8 KB

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