BaUserList.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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, UI.SHOW_EMP_LV,UN.RELATIVE_LOCATION
  37. ',
  38. // CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,
  39. // RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,
  40. // DU.USER_NAME DEC_USER_NAME
  41. 'orderBy' => 'UI.CREATED_AT DESC, UI.ID DESC',
  42. 'from' => BaUser::tableName() . ' AS U',
  43. 'join' => [
  44. ['LEFT JOIN', BaUserInfo::tableName() . ' AS UI', 'UI.USER_ID=U.ID'],
  45. ['LEFT JOIN', UserNetwork::tableName() . ' AS UN', 'UI.USER_ID=UN.USER_ID'],
  46. ['LEFT JOIN', User::tableName() . ' AS CU', 'UI.CON_UID=CU.ID'],
  47. ['LEFT JOIN', User::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
  48. ['LEFT JOIN', User::tableName() . ' AS DU', 'U.DEC_ID=DU.ID'],
  49. ],
  50. 'page' => $this->page,
  51. 'pageSize' => $this->pageSize,
  52. ]);
  53. // foreach ($this->listData['list'] as $key => $value) {
  54. // // 后台访问前台的请求参数
  55. // if (!$this->isExport && Yii::$app->user->validateAdminAction('user', 'login-to-frontend')) {
  56. // $urlParams = BackendToFrontendApi::paramsFormat(['id' => $value['USER_ID']]);
  57. // $urlParamStr = '';
  58. // foreach ($urlParams as $pKey => $pValue) {
  59. // $urlParamStr .= $pKey . '=' . $pValue . '&';
  60. // }
  61. // $urlParamStr = substr($urlParamStr, 0, -1);
  62. // $this->listData['list'][$key]['BTF_URL'] = $urlParamStr;
  63. // } else {
  64. // $this->listData['list'][$key]['BTF_URL'] = null;
  65. // }
  66. // }
  67. }
  68. /**
  69. * 要展示和导出的所有字段
  70. * @return array
  71. */
  72. public function getColumn()
  73. {
  74. $regionConfig = Cache::getRegionConfig();
  75. if(!$this->columns){
  76. $this->columns = [
  77. 'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  78. 'BTF_URL' => null,
  79. 'USER_NAME' => [
  80. 'header' => 'Member Code', // 会员编号
  81. 'headerOther' => ['width' => '150'],
  82. ],
  83. 'REAL_NAME' => [
  84. 'header' => 'Member Name', // 会员姓名
  85. 'headerOther' => [
  86. 'width' => '120',
  87. ],
  88. 'valueOther' => [
  89. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  90. ],
  91. ],
  92. 'LOGIN_STATUS_NAME' => [
  93. 'header' => 'Login Status', // 登录状态
  94. 'value' => function($row) {
  95. return $row['ALLOW_LOGIN'] == 1 ? 'Allow Login': 'Prohibit Login'; // '允许登录' : '禁止登录'
  96. },
  97. 'headerOther' => ['width' => '110'],
  98. ],
  99. 'STATUS' => [
  100. 'header' => 'Status', // 状态
  101. 'value' => function($row) {
  102. return $row['STATUS'] == 1 ? 'Activate': 'Lock'; // '激活' : '锁定'
  103. },
  104. 'headerOther' => ['width' => '110'],
  105. ],
  106. 'ALLOW_LOGIN' => ['header' => 'Filter Allow Login','hidden'=>true], // 筛选允许登录
  107. 'CREATED_AT' => [
  108. 'header' => 'Joining Date', // 加入日期
  109. 'value' => function($row) {
  110. return (new DateTime([
  111. 'value' => $row['CREATED_AT'],
  112. ]))->result();
  113. },
  114. 'headerOther' => ['width' => '170'],
  115. ],
  116. 'PERIOD_AT' => [
  117. 'header' => 'Joining Period', // 加入期数
  118. 'headerOther' => ['width' => '180'],
  119. ],
  120. 'REC_USER_NAME' => [
  121. 'header' => 'Recommendation No', // 推荐编号
  122. 'headerOther' => ['width' => '160'],
  123. ],
  124. 'REC_REAL_NAME' => [
  125. 'header' => 'Recommended Name', // 推荐姓名
  126. 'headerOther' => ['width' => '160'],
  127. ],
  128. 'MOBILE' => [
  129. 'header' => 'Phone Number', // 手机号码
  130. 'value' => function($row) {
  131. return "\t".$row['MOBILE'];
  132. },
  133. 'headerOther' => ['width' => '120'],
  134. ],
  135. 'TEL' => [
  136. 'header' => 'Alternate Phone Number', // 备用手机号码
  137. 'value' => function($row) {
  138. return "\t".$row['TEL'];
  139. },
  140. 'headerOther' => ['width' => '180'],
  141. ],
  142. 'AREA' => [
  143. 'header' => 'Common Address', // 常用地址
  144. 'value' => function($row) use($regionConfig) {
  145. $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
  146. $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
  147. $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
  148. return $province.$city.$county;
  149. },
  150. 'showValue' => function($row) {
  151. $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
  152. $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
  153. $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
  154. return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
  155. },
  156. 'headerOther' => [
  157. 'width' => '200'
  158. ],
  159. ],
  160. ];
  161. }
  162. return $this->columns;
  163. }
  164. /**
  165. * 前台用于筛选的类型集合
  166. * @return mixed
  167. */
  168. public function getFilterTypes()
  169. {
  170. if(!$this->filterTypes){
  171. $this->filterTypes = [
  172. 'USER_NAME'=> ['name'=> 'Member code'], // 会员编号
  173. 'REAL_NAME'=> ['name'=> 'Member name'], // 会员姓名
  174. 'CREATED_AT'=> ['name'=> 'Joining Date', 'other'=> 'date'], // 加入日期
  175. 'PERIOD_AT'=> ['name'=> 'Joining Period'], // 加入期数
  176. 'REC_USER_NAME'=> ['name'=> 'Recommendation No'],//推荐编号
  177. 'MOBILE'=> ['name'=> 'Phone Number'],//手机号码
  178. 'AREA'=> ['name'=> 'Common address', 'other'=> 'area'],//常用地址
  179. 'STATUS'=> ['name'=> 'Active status', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> 'locking'],['id'=> 1, 'name'=> 'activation']]],
  180. ];
  181. }
  182. return $this->filterTypes;
  183. }
  184. }