BaUserList.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\user;
  3. use common\helpers\Cache;
  4. use common\helpers\http\BackendToFrontendApi;
  5. use common\libs\dataList\DataListInterface;
  6. use common\models\BaUser;
  7. use common\models\BaUserInfo;
  8. use common\models\User;
  9. use common\libs\dataList\column\DateTime;
  10. use common\models\UserNetwork;
  11. use Yii;
  12. class BaUserList extends \common\libs\dataList\DataList implements DataListInterface
  13. {
  14. /**
  15. * 列表名称
  16. * @return string
  17. */
  18. public function getListName(){
  19. return 'Brand_Ambassador_List';
  20. }
  21. /**
  22. * 列表筛选到的数据
  23. */
  24. public function dataHandle()
  25. {
  26. // $this->condition .= ' AND UN.USER_ID=UI.USER_ID AND UN.PARENT_UID=UI.CON_UID';
  27. $this->listData = BaUser::lists($this->condition, $this->params, [
  28. 'select' => 'U.*,
  29. UI.USER_ID, UI.ZC_PV, UI.CON_UID, UI.REC_UID, UI.CON_NUM, UI.REC_NUM, UI.NETWORK_DEEP,
  30. UI.RELATION_DEEP, UI.SYSTEM_ID, UI.IS_GROUP_LEADER, UI.IS_SYSTEM_LEADER, UI.IS_TEAM, UI.IS_BIND,
  31. UI.IS_TEAM_MAIN, UI.IS_BIND_MAIN, UI.IS_AUTO_WITHDRAW, UI.CLOSE_LOGIN, UI.REG_TYPE, UI.SHOULD_REG_TYPE,
  32. UI.REG_NAME, UI.CREDIT_CODE, UI.PREMISES, UI.LEGAL_PERSON, UI.REG_EXPIRES, UI.STORE_TYPE, UI.INVOICE_BALANCE,
  33. UI.HIGHEST_EMP_LV, UI.CLOSE_LOGIN_AT, UI.PULLED_AT,
  34. UI.GROUP_LEADER_AT, UI.ALLOW_TRANSFER, UI.ALLOW_RECONSUME_SMS, UI.ALLOW_RECONSUME_SMS_TO,
  35. UI.HIGHEST_EMP_LV_PERIOD, UI.TRANSFER_PROP, UI.LOGIN_NUMS, UI.FAIL_NUMS, UI.LAST_LOGIN_IP,
  36. UI.LAST_LOGIN_AT,
  37. RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,
  38. DU.USER_NAME DEC_USER_NAME',
  39. 'orderBy' => 'UI.CREATED_AT DESC, UI.ID DESC',
  40. 'from' => BaUser::tableName() . ' AS U',
  41. 'join' => [
  42. ['LEFT JOIN', BaUserInfo::tableName() . ' AS UI', 'UI.USER_ID=U.ID'],
  43. ['LEFT JOIN', User::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
  44. ['LEFT JOIN', BaUser::tableName() . ' AS DU', 'U.DEC_ID=DU.ID'],
  45. ],
  46. 'page' => $this->page,
  47. 'pageSize' => $this->pageSize,
  48. ]);
  49. }
  50. /**
  51. * 要展示和导出的所有字段
  52. * @return array
  53. */
  54. public function getColumn()
  55. {
  56. $regionConfig = Cache::getRegionConfig();
  57. if(!$this->columns){
  58. $this->columns = [
  59. 'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  60. 'BTF_URL' => null,
  61. 'USER_NAME' => [
  62. 'header' => 'Member Code', // 会员编号
  63. 'headerOther' => ['width' => '150'],
  64. ],
  65. 'REAL_NAME' => [
  66. 'header' => 'Member Name', // 会员姓名
  67. 'headerOther' => [
  68. 'width' => '120',
  69. ],
  70. 'valueOther' => [
  71. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  72. ],
  73. ],
  74. 'LOGIN_STATUS_NAME' => [
  75. 'header' => 'Login Status', // 登录状态
  76. 'value' => function($row) {
  77. return $row['ALLOW_LOGIN'] == 1 ? 'Allow Login': 'Prohibit Login'; // '允许登录' : '禁止登录'
  78. },
  79. 'headerOther' => ['width' => '110'],
  80. ],
  81. 'STATUS' => [
  82. 'header' => 'Status', // 状态
  83. 'value' => function($row) {
  84. return $row['STATUS'] == 1 ? 'Activate': 'Lock'; // '激活' : '锁定'
  85. },
  86. 'headerOther' => ['width' => '110'],
  87. ],
  88. 'ALLOW_LOGIN' => ['header' => 'Filter Allow Login','hidden'=>true], // 筛选允许登录
  89. 'CREATED_AT' => [
  90. 'header' => 'Joining Date', // 加入日期
  91. 'value' => function($row) {
  92. return (new DateTime([
  93. 'value' => $row['CREATED_AT'],
  94. ]))->result();
  95. },
  96. 'headerOther' => ['width' => '170'],
  97. ],
  98. 'PERIOD_AT' => [
  99. 'header' => 'Joining Period', // 加入期数
  100. 'headerOther' => ['width' => '180'],
  101. ],
  102. 'REC_USER_NAME' => [
  103. 'header' => 'Recommendation No', // 推荐编号
  104. 'headerOther' => ['width' => '160'],
  105. ],
  106. 'REC_REAL_NAME' => [
  107. 'header' => 'Recommended Name', // 推荐姓名
  108. 'headerOther' => ['width' => '160'],
  109. ],
  110. 'MOBILE' => [
  111. 'header' => 'Phone Number', // 手机号码
  112. 'value' => function($row) {
  113. return "\t".$row['MOBILE'];
  114. },
  115. 'headerOther' => ['width' => '120'],
  116. ],
  117. 'TEL' => [
  118. 'header' => 'Alternate Phone Number', // 备用手机号码
  119. 'value' => function($row) {
  120. return "\t".$row['TEL'];
  121. },
  122. 'headerOther' => ['width' => '180'],
  123. ],
  124. 'AREA' => [
  125. 'header' => 'Common Address', // 常用地址
  126. 'value' => function($row) use($regionConfig) {
  127. $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
  128. $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
  129. $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
  130. return $province.$city.$county;
  131. },
  132. 'showValue' => function($row) {
  133. $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
  134. $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
  135. $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
  136. return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
  137. },
  138. 'headerOther' => [
  139. 'width' => '200'
  140. ],
  141. ],
  142. ];
  143. }
  144. return $this->columns;
  145. }
  146. /**
  147. * 前台用于筛选的类型集合
  148. * @return mixed
  149. */
  150. public function getFilterTypes()
  151. {
  152. if(!$this->filterTypes){
  153. $this->filterTypes = [
  154. 'USER_NAME'=> ['name'=> 'Member code'], // 会员编号
  155. 'REAL_NAME'=> ['name'=> 'Member name'], // 会员姓名
  156. 'CREATED_AT'=> ['name'=> 'Joining Date', 'other'=> 'date'], // 加入日期
  157. 'PERIOD_AT'=> ['name'=> 'Joining Period'], // 加入期数
  158. 'REC_USER_NAME'=> ['name'=> 'Recommendation No'],//推荐编号
  159. 'MOBILE'=> ['name'=> 'Phone Number'],//手机号码
  160. 'AREA'=> ['name'=> 'Common address', 'other'=> 'area'],//常用地址
  161. 'STATUS'=> ['name'=> 'Active status', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> 'locking'],['id'=> 1, 'name'=> 'activation']]],
  162. ];
  163. }
  164. return $this->filterTypes;
  165. }
  166. }