UserList.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\ba;
  3. use common\helpers\Cache;
  4. use common\helpers\http\BackendToFrontendApi;
  5. use common\helpers\user\Info;
  6. use common\libs\dataList\DataListInterface;
  7. use common\models\DecRole;
  8. use common\models\OpenBank;
  9. use common\models\Region;
  10. use common\models\BaUser;
  11. use common\models\BaUserInfo;
  12. use common\libs\dataList\column\DateTime;
  13. use common\libs\dataList\column\YesNo;
  14. use common\models\UserNetwork;
  15. use common\models\UserSystem;
  16. use Yii;
  17. class UserList extends \common\libs\dataList\DataList implements DataListInterface
  18. {
  19. /**
  20. * 列表名称
  21. * @return string
  22. */
  23. public function getListName(){
  24. return 'BA会员列表';
  25. }
  26. /**
  27. * 列表筛选到的数据
  28. */
  29. public function dataHandle()
  30. {
  31. // $this->condition .= ' AND UN.USER_ID=UI.USER_ID AND UN.PARENT_UID=UI.CON_UID';
  32. $this->listData = BaUser::lists($this->condition, $this->params, [
  33. 'select' => 'U.*,
  34. UI.USER_ID, UI.ZC_PV, UI.CON_UID, UI.REC_UID, UI.CON_NUM, UI.REC_NUM, UI.NETWORK_DEEP,
  35. UI.RELATION_DEEP, UI.SYSTEM_ID, UI.IS_GROUP_LEADER, UI.IS_SYSTEM_LEADER, UI.IS_TEAM, UI.IS_BIND,
  36. UI.IS_TEAM_MAIN, UI.IS_BIND_MAIN, UI.IS_AUTO_WITHDRAW, UI.CLOSE_LOGIN, UI.REG_TYPE, UI.SHOULD_REG_TYPE,
  37. UI.REG_NAME, UI.CREDIT_CODE, UI.PREMISES, UI.LEGAL_PERSON, UI.REG_EXPIRES, UI.STORE_TYPE, UI.INVOICE_BALANCE,
  38. UI.HIGHEST_EMP_LV, UI.CLOSE_LOGIN_AT, UI.PULLED_AT,
  39. UI.GROUP_LEADER_AT, UI.ALLOW_TRANSFER, UI.ALLOW_RECONSUME_SMS, UI.ALLOW_RECONSUME_SMS_TO,
  40. UI.HIGHEST_EMP_LV_PERIOD, UI.TRANSFER_PROP, UI.LOGIN_NUMS, UI.FAIL_NUMS, UI.LAST_LOGIN_IP,
  41. CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,
  42. RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,
  43. DU.USER_NAME DEC_USER_NAME
  44. ',
  45. 'orderBy' => 'UI.CREATED_AT DESC, UI.ID DESC',
  46. 'from' => BaUser::tableName() . ' AS U',
  47. 'join' => [
  48. ['LEFT JOIN', BaUserInfo::tableName() . ' AS UI', 'UI.USER_ID=U.ID'],
  49. // ['LEFT JOIN', UserNetwork::tableName() . ' AS UN', 'UI.USER_ID=UN.USER_ID'],
  50. ['LEFT JOIN', BaUser::tableName() . ' AS CU', 'UI.CON_UID=CU.ID'],
  51. ['LEFT JOIN', BaUser::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
  52. ['LEFT JOIN', BaUser::tableName() . ' AS DU', 'U.DEC_ID=DU.ID'],
  53. ],
  54. 'page' => $this->page,
  55. 'pageSize' => $this->pageSize,
  56. ]);
  57. foreach ($this->listData['list'] as $key => $value) {
  58. // 后台访问前台的请求参数
  59. if (!$this->isExport && Yii::$app->user->validateAdminAction('user', 'login-to-frontend')) {
  60. $urlParams = BackendToFrontendApi::paramsFormat(['id' => $value['USER_ID']]);
  61. $urlParamStr = '';
  62. foreach ($urlParams as $pKey => $pValue) {
  63. $urlParamStr .= $pKey . '=' . $pValue . '&';
  64. }
  65. $urlParamStr = substr($urlParamStr, 0, -1);
  66. $this->listData['list'][$key]['BTF_URL'] = $urlParamStr;
  67. } else {
  68. $this->listData['list'][$key]['BTF_URL'] = null;
  69. }
  70. }
  71. }
  72. /**
  73. * 要展示和导出的所有字段
  74. * @return array
  75. */
  76. public function getColumn(){
  77. // $decLevelConfig = Cache::getDecLevelConfig();
  78. // $empLevelConfig = Cache::getEmpLevelConfig();
  79. // $crownLevelConfig = Cache::getStarCrownLevelConfig();
  80. // $decRoleConfig = DecRole::getAllData();
  81. // $systemConfig = UserSystem::getAllSystems();
  82. $openBankConfig = OpenBank::getAllOpenBank();
  83. $regionConfig = Cache::getRegionConfig();
  84. if(!$this->columns){
  85. $this->columns = [
  86. 'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  87. 'BTF_URL' => null,
  88. 'USER_NAME' => [
  89. 'header' => 'Member code',//会员编号
  90. 'headerOther' => ['width' => '150'],
  91. ],
  92. 'REAL_NAME' => [
  93. 'header' => 'Member name',//会员姓名
  94. 'headerOther' => [
  95. 'width' => '120',
  96. ],
  97. 'valueOther' => [
  98. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  99. ],
  100. ],
  101. 'LOGIN_STATUS_NAME' => [
  102. 'header' => 'Login status',//登录状态
  103. 'value' => function($row) {
  104. return $row['ALLOW_LOGIN'] == 1 ? 'allow Login': 'prohibit Login';//'允许登录' : '禁止登录'
  105. },
  106. 'headerOther' => ['width' => '110'],
  107. ],
  108. 'STATUS' => [
  109. 'header' => 'Status',//状态
  110. 'value' => function($row) {
  111. return $row['STATUS'] == 1 ? 'activate': 'lock';//'激活' : '锁定'
  112. },
  113. 'headerOther' => ['width' => '110'],
  114. ],
  115. 'ALLOW_LOGIN' => ['header' => 'Filter allow login','hidden'=>true],//筛选允许登录
  116. 'CREATED_AT' => [
  117. 'header' => 'Joining Date', // 加入日期
  118. 'value' => function($row) {
  119. return (new DateTime([
  120. 'value' => $row['CREATED_AT'],
  121. ]))->result();
  122. },
  123. 'headerOther' => ['width' => '170'],
  124. ],
  125. // 'PERIOD_AT' => [
  126. // 'header' => 'Joining Period',//加入期数
  127. // 'headerOther' => ['width' => '180'],
  128. // ],
  129. // 'DEC_LV_NAME' => [
  130. // 'header' => 'Real time membership level',//实时会员级别
  131. // 'headerOther' => [
  132. // 'width' => '120',
  133. // ],
  134. // 'value' => function($row) use($decLevelConfig) {
  135. // return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
  136. // },
  137. // 'valueOther' => [
  138. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  139. // ],
  140. // ],
  141. // 'DEC_LV_UPDATED_AT' => [
  142. // 'header' => 'Real time adjustment date',//实时调整日期
  143. // 'value' => function($row) {
  144. // return (new DateTime([
  145. // 'value' => $row['DEC_LV_UPDATED_AT'],
  146. // ]))->result();
  147. // },
  148. // 'headerOther' => ['width' => '160'],
  149. // ],
  150. // 'LAST_DEC_LV_NAME' => [
  151. // 'header' => 'Member level at settlement',//结算时会员级别
  152. // 'headerOther' => [
  153. // 'width' => '120',
  154. // ],
  155. // 'value' => function($row) use($decLevelConfig) {
  156. // if (!$row['LAST_DEC_LV']) {
  157. // return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
  158. // } else {
  159. // return $decLevelConfig[$row['LAST_DEC_LV']]['LEVEL_NAME'];
  160. // }
  161. // },
  162. // 'valueOther' => [
  163. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  164. // ],
  165. // ],
  166. // 'EMP_LV_NAME' => [
  167. // 'header' => 'Real time employment',//实时聘级
  168. // 'headerOther' => [
  169. // 'width' => '130',
  170. // ],
  171. // 'value' => function($row) use($empLevelConfig) {
  172. // return isset($empLevelConfig[$row['EMP_LV']])?$empLevelConfig[$row['EMP_LV']]['LEVEL_NAME']:'';
  173. // },
  174. // 'valueOther' => [
  175. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  176. // ],
  177. // ],
  178. // 'CROWN_LV_NAME' => [
  179. // 'header' => 'Real time crown', // 实时星级
  180. // 'headerOther' => [
  181. // 'width' => '130',
  182. // ],
  183. // 'value' => function($row) use($crownLevelConfig) {
  184. // return isset($crownLevelConfig[$row['CROWN_LV']])?$crownLevelConfig[$row['CROWN_LV']]['LEVEL_NAME']:'';
  185. // },
  186. // 'valueOther' => [
  187. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  188. // ],
  189. // ],
  190. 'REC_USER_NAME' => [
  191. 'header' => 'Recommendation No',//推荐编号
  192. 'headerOther' => ['width' => '150'],
  193. ],
  194. 'REC_REAL_NAME' => [
  195. 'header' => 'Recommended name',//推荐姓名
  196. 'headerOther' => ['width' => '100'],
  197. ],
  198. // 'CON_USER_NAME' => [
  199. // 'header' => 'Placement No',//安置编号
  200. // 'headerOther' => ['width' => '150'],
  201. // ],
  202. // 'CON_REAL_NAME' => [
  203. // 'header' => 'Placement Name',//安置姓名
  204. // 'headerOther' => ['width' => '100'],
  205. // ],
  206. 'MOBILE' => [
  207. 'header' => 'Phone Number',//手机号码
  208. 'value' => function($row) {
  209. return "\t".$row['MOBILE'];
  210. },
  211. 'headerOther' => ['width' => '120'],
  212. ],
  213. 'TEL' => [
  214. 'header' => 'Alternate Phone Number', // 备用手机号码
  215. 'value' => function($row) {
  216. return "\t".$row['TEL'];
  217. },
  218. 'headerOther' => ['width' => '120'],
  219. ],
  220. 'DEC_USER_NAME' => [
  221. 'header' => 'Stockist Code', // 所属报单中心编号
  222. 'headerOther' => ['width' => '150'],
  223. ],
  224. // 'IS_DEC' => [
  225. // 'header' => 'Declaration center or not',//是否报单中心
  226. // 'value' => function($row) {
  227. // return (new YesNo([
  228. // 'value' => $row['IS_DEC'],
  229. // ]))->result();
  230. // },
  231. // 'headerOther' => function($row) {
  232. // return [
  233. // 'width' => '120',
  234. // ];
  235. // },
  236. // 'valueOther' => function($row) {
  237. // return [
  238. // 'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
  239. // ];
  240. // },
  241. // ],
  242. // 'IS_ATLAS' => [
  243. // 'header' => 'Whether the atlas is displayed',//是否显示图谱
  244. // 'value' => function($row) {
  245. // return (new YesNo([
  246. // 'value' => $row['IS_ATLAS'],
  247. // ]))->result();
  248. // },
  249. // 'headerOther' => function($row) {
  250. // return [
  251. // 'width' => '120',
  252. // ];
  253. // },
  254. // 'valueOther' => function($row) {
  255. // return [
  256. // 'tag'=>['type'=>(isset($row['IS_ATLAS']) && $row['IS_ATLAS'] )? 'success' : 'info', 'size' => 'small']
  257. // ];
  258. // },
  259. // ],
  260. // 'IS_RECHARGE' => [
  261. // 'header' => 'Whether to display recharge',//是否显示充值
  262. // 'value' => function($row) {
  263. // return (new YesNo([
  264. // 'value' => $row['IS_RECHARGE'],
  265. // ]))->result();
  266. // },
  267. // 'headerOther' => function($row) {
  268. // return [
  269. // 'width' => '120',
  270. // ];
  271. // },
  272. // 'valueOther' => function($row) {
  273. // return [
  274. // 'tag'=>['type'=>(isset($row['IS_RECHARGE']) && $row['IS_RECHARGE'] )? 'success' : 'info', 'size' => 'small']
  275. // ];
  276. // },
  277. // ],
  278. // 'DEC_ROLE_NAME' => [
  279. // 'header' => 'Stockist Level',//报单中心级别
  280. // 'headerOther' => ['width' => '110'],
  281. // 'value' => function($row) use($decRoleConfig) {
  282. // return $decRoleConfig[$row['DEC_ROLE_ID']]['ROLE_NAME'] ?? '';
  283. // },
  284. // ],
  285. 'OPEN_BANK_NAME' => [
  286. 'header' => 'Bank Name',//开户银行
  287. 'headerOther' => ['width' => '110'],
  288. 'value' => function($row) use($openBankConfig) {
  289. return $openBankConfig[$row['OPEN_BANK']]['BANK_NAME'] ?? '';
  290. },
  291. ],
  292. 'BANK_NO' => [
  293. 'header' => 'Bank account number',//银行帐号
  294. 'headerOther' => ['width' => '220'],
  295. 'value' => function($row) {
  296. return "\t".$row['BANK_NO'];
  297. },
  298. ],
  299. 'AREA' => [
  300. 'header' => 'Common address',//常用地址
  301. 'value' => function($row) use($regionConfig) {
  302. $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
  303. $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
  304. $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
  305. return $province.$city.$county;
  306. },
  307. 'showValue' => function($row) {
  308. $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
  309. $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
  310. $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
  311. return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
  312. },
  313. 'headerOther' => [
  314. 'width' => '200'
  315. ],
  316. ],
  317. // 'ALLOW_TRANSFER' => [
  318. // 'header' => 'Enable "Transfer"', // 转账功能开启
  319. // 'value' => function($row) {
  320. // return $row['ALLOW_TRANSFER'] == 1 ? 'on': 'off';//'开启' : '关闭'
  321. // },
  322. // 'headerOther' => function($row) {
  323. // return [
  324. // 'width' => '120',
  325. // ];
  326. // },
  327. // 'valueOther' => function($row) {
  328. // return [
  329. // 'tag'=>['type'=>(isset($row['ALLOW_TRANSFER']) && $row['ALLOW_TRANSFER']) ? 'success' : 'info', 'size' => 'small']
  330. // ];
  331. // },
  332. // ],
  333. ];
  334. }
  335. return $this->columns;
  336. }
  337. /**
  338. * 前台用于筛选的类型集合
  339. * @return mixed
  340. */
  341. public function getFilterTypes()
  342. {
  343. if(!$this->filterTypes){
  344. $this->filterTypes = [
  345. 'USER_NAME'=> ['name'=> 'Member code'], // 会员编号
  346. 'REAL_NAME'=> ['name'=> 'Member name'], // 会员姓名
  347. 'CREATED_AT'=> ['name'=> 'Joining Date', 'other'=> 'date'], // 加入日期
  348. 'PERIOD_AT'=> ['name'=> 'Joining Period'], // 加入期数
  349. 'DEC_LV_NAME'=> ['name'=> 'Real time membership level', 'other'=> 'decLevel'], // 实时会员级别
  350. 'EMP_LV_NAME'=> ['name'=> 'Real time employment', 'other'=> 'empLevel'], // 实时聘级
  351. 'CROWN_LV_NAME'=> ['name'=> 'Real time Crown', 'other'=> 'crownLevel'], // 实时聘级
  352. 'REC_USER_NAME'=> ['name'=> 'Recommendation No'],//推荐编号
  353. 'CON_USER_NAME'=> ['name'=> 'Placement No'],//安置编号
  354. 'ID_CARD'=> ['name'=> 'Identification Number'],//证件号码
  355. 'MOBILE'=> ['name'=> 'Phone Number'],//手机号码
  356. 'DEC_USER_NAME'=> ['name'=> 'Stockist Code'], // 所属报单中心编号
  357. 'IS_DEC'=> ['name'=> 'Declaration center or not', 'other'=> 'yesOrNo'],//是否报单中心
  358. 'IS_STUDIO'=> ['name'=> 'Studio or not', 'other'=> 'yesOrNo'],//是否工作室
  359. 'DEC_ROLE_NAME'=> ['name'=> 'Stockist Level', 'other'=> 'decRole'],//报单中心级别
  360. 'AREA'=> ['name'=> 'Common address', 'other'=> 'area'],//常用地址
  361. 'STATUS'=> ['name'=> 'Active status', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> 'locking'],['id'=> 1, 'name'=> 'activation']]],
  362. ];
  363. }
  364. return $this->filterTypes;
  365. }
  366. }