Member.class.php
31.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
<?php
/**
* Member.class.php
* 用户接口操作类
*
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2014 - ? VcySDK (http://www.vchangyi.com/)
* @author zhuxun37
* @version 1.0.0
*/
namespace VcySDK;
use Common\Model\AttrModel;
class Member
{
/**
* 接口调用类
*
* @var object
*/
private $serv = null;
/**
* SERVICE 类
*
* @var null
*/
private $service = null;
/**
* 获取用户列表的接口地址
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const LIST_URL = '%s/member/list';
/**
* 获取用户列表的接口地址(包含删除的用户)
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const ALL_LIST_URL = '%s/member/ignore-permissions/list';
/**
* 已删除用户基本信息分页列表接口地址(不过滤可见范围)
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const DELETED_BASIC_LIST_URL = '%s/member/ignore-permissions/deleted-basic-list';
/**
* 同步用户信息
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const SYNC_URL = '%s/member/sync';
/**
* 获取指定用户信息
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const GET_URL = '%s/member/get';
/**
* 更新指定用户信息
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const UPDATE_URL = '%s/member/update';
/**
* 更新所有用户的扩展字段
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const UPDATE_EXT_URL = '%s/member/update-ext';
/**
* 获取用户和部门对照信息列表
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_DEPARTMENT_LIST_URL = '%s/member/get-member-conn-depart';
/**
* 获取用户和部门对照信息列表 (跳过鉴权)
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_IGNORE_PERMISSIONS_MEMBER_DEPARTMENT_LIST_URL = '%s/member/ignore-permissions/get-member-conn-depart';
/**
* 获取用户和职位对照信息列表
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_JOB_LIST_URL = '%s/member/get-member-conn-job';
/**
* 新增用户信息
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const ADD_URL = '%s/member/add';
/**
* 删除用户
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const DELETE_URL = '%s/member/delete';
/**
* 获取用户列表
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const SEARCH_URL = '%s/search/list';
/**
* 获取用户列表
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const APP_ALLOW_URL = '%s/get-app-allow';
/**
* 批量删除
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const BAT_DEL_URL = '%s/member/bat-delete';
/**
* 批量启用、禁用
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MODIFY_STATUS_URL = '%s/member/modify-member-status';
/**
* 批量用户移动部门
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MOVE_DEPT_URL = '%s/member/move-department';
/**
* 添加扩展属性
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_EXT_ADD_URL = '%s/member-ext/add';
/**
* 批量添加扩展属性
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_EXT_BATADD_URL = '%s/member-ext/bat-add';
/**
* 查询用户扩展属性
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_EXT_GET_URL = '%s/member-ext/get';
/**
* 查询用户所有扩展属性
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_EXT_LIST_URL = '%s/member-ext/list';
/**
* 读取用户基本信息列表
*
* @var string
*/
const MEMBER_IGNORE_PERMISSIONS_BASIC_LIST = '%s/member/ignore-permissions/basic-list';
/**
* 修改用户扩展属性
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_EXT_MODIFY_URL = '%s/member-ext/modify';
/**
* 删除用户扩展属性
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_EXT_DEL_URL = '%s/member-ext/del';
/**
* 批量修改扩展属性
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_EXT_BATMODIFY_URL = '%s/member-ext/bat-modify';
/**
* 删除所有用户指定扩展属性
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_EXT_ALLDEL_URL = '%s/member-ext/all-del';
/**
* 人员、已关注、未关注、禁用人员总数
*/
const MEMBER_RELEVANT_TOTAL = '%s/statistics/user';
/**
* 在职情况统计
*/
const MEMBER_ACTIVE_TOTAL = '%s/statistics/job';
/**
* 判断指定用户信息是否已存在
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const CHECK_INFO_EXIST_URL = '%s/member/check-info-exist';
/**
* 用户配置数据保存
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_SETTING_SAVE = '%s/member/settings/save';
/**
* 用户配置数据查找
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_SETTING_GET = '%s/member/settings/get';
/**
* 用户配置数据列表
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_SETTING_ALL = '%s/member/settings/all';
/**
* 用户配置数据删除
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_SETTING_DELETE = '%s/member/settings/delete';
/**
* 根据 OpenId 或者 UserId 查询用户详情
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_GET_BY_USERID = '%s/member/get-by-userid';
/**
* OpenId 转换为 UserId
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_OPENID_TO_USERID = '%s/member/openid-to-userid';
/**
* 企业用户列表接口(忽略权限过滤)
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_IGNORE_PERMISSIONS_LIST = '%s/member/ignore-permissions/list';
/**
* 企业用户关注状态统计接口(忽略权限过滤)
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_IGNORE_PERMISSIONS_STATUS_COUNT = '%s/member/ignore-permissions/status-count';
/**
* 获取没有部门的人员 (跳过鉴权)
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MEMBER_IGNORE_PERMISSIONS_GET_NO_DEPARTMENT_MEMBER = '%s/member/ignore-permissions/get-no-department-member';
/**
* loginCheckAuth
* %s = {apiUrl}/s/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const LOGIN_CHECK_AUTH = '%s/login/check-auth';
/**
* 获取某时间段内人员数量
*/
const MEMBER_COUNT_BY_DAY = '%s/subscribe/count-by-day';
/**
* 根据手机或邮箱或姓名获取用户信息列表
*
* @var string
*/
const MEMBER_USER_IMPORT_BASIC_LIST = '%s/import/list';
/**
* 根据userid获取用户所有标签
*
* @var string
*/
const MEMBER_TAGS_GET_BY_USERID = '%s/member/search-tag';
/**
* 初始化
*
* @param Service $serv 接口调用类
*/
public function __construct($serv)
{
$this->serv = $serv;
$this->service = new Service();
}
/**
* 获取用户列表
*
* @param array $condition 查询条件数据
* + int memAll 是否包含已删除人员(1=是;2=否,UC默认)
* + int eqMemStatus 查询指定状态的用户列表(1=新增;2=修改;3=删除)
* @param mixed $orders 排序字段
* @param int $page 当前页码
* @param int $perpage 每页记录数
* @param bool $ignorePermissions 是否跳过鉴权
*
* @return array|bool
*/
public function listAll($condition = [], $page = 1, $perpage = 30, $orders = [], $ignorePermissions = true)
{
// 查询参数
$keyList = [];
foreach (['userids', 'memUids'] as $_key) {
$this->service->setAndIsArr($condition, $_key, $keyList);
}
$this->service->getValue($condition, $keyList);
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
$uc_url = $ignorePermissions ? self::MEMBER_IGNORE_PERMISSIONS_LIST : self::LIST_URL;
$result = $this->serv->postSDK($uc_url, $condition, 'generateApiUrlA');
if ($result['list'] && $result['memberExtList']) {
$list = array_combine_by_key($result['list'], 'memUid');
// 把扩展属性合并到list
foreach ($result['memberExtList'] as $v) {
$memUid = $v['memUid'];
$extKey = $v['extKey'];
$extValue = $v['extValue'];
$list[$memUid][$extKey] = $extValue;
}
unset($result['memberExtList']);
$result['list'] = array_values($list);
}
return $result;
}
/**
* 获取用户基本信息列表
*
* @param array $condition 查询条件数据
* @param mixed $orders 排序字段
* @param int $page 当前页码
* @param int $perpage 每页记录数
*
* @return boolean|multitype:
*/
public function listAllBasic($condition = array(), $page = 1, $perpage = 30, $orders = array())
{
// 查询参数
$keyList = [];
foreach (['userids', 'memUids'] as $_key) {
$this->service->setAndIsArr($condition, $_key, $keyList);
}
$this->service->getValue($condition, $keyList);
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
$result = $this->serv->postSDK(self::MEMBER_IGNORE_PERMISSIONS_BASIC_LIST, $condition, 'generateApiUrlA');
return $result;
}
/**
* 获取用户列表(包含已删除用户)
*
* @param array $condition 查询条件数据
* @param mixed $orders 排序字段
* @param int $page 当前页码
* @param int $perpage 每页记录数
*
* @return array|bool
*/
public function listUsersAll($condition = [], $page = 1, $perpage = 30, $orders = [])
{
// 查询参数
$keyList = [];
foreach (['userids', 'memUids'] as $_key) {
$this->service->setAndIsArr($condition, $_key, $keyList);
}
$this->service->getValue($condition, $keyList);
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
$result = $this->serv->postSDK(
self::ALL_LIST_URL,
$condition,
'generateApiUrlA');
if ($result['list']) {
$list = array_combine_by_key($result['list'], 'memUid');
if ($result['memberExtList']) {
// 把扩展属性合并到list
foreach ($result['memberExtList'] as $v) {
$memUid = $v['memUid'];
$extKey = $v['extKey'];
$extValue = $v['extValue'];
$list[$memUid][$extKey] = $extValue;
}
}
unset($result['memberExtList']);
$result['list'] = $list;
}
return $result;
}
/**
* 同步用户信息
*
* @return boolean|multitype:
*/
public function sync()
{
return $this->serv->postSDK(self::SYNC_URL, [], 'generateApiUrlB');
}
/**
* 获取指定用户信息
*
* @param array $condition 请求参数
* + memUid string 用户UID
*
* @return boolean|multitype:
*/
public function fetch($condition)
{
$result = $this->serv->postSDK(self::GET_URL, $condition, 'generateApiUrlA');
if ($result['memberExtList']) {
// 把扩展属性合并到用户数据
foreach ($result['memberExtList'] as $v) {
$result[$v['extKey']] = $v['extValue'];
}
unset($result['memberExtList']);
}
$attr_keys = array_keys(cfg('USER_ATTRS'));
$user_keys = array_keys($result);
$diffs = array_diff($attr_keys, $user_keys);
// 补全属性
foreach ($diffs as $k) {
$result[$k] = '';
}
return $result;
}
/**
* 更新用户信息
*
* @param array $data 人员数据
* + string(32) memUid 人员ID
* + string(64) memWeixin 微信号 手机/微信号/邮箱,不可同时为空
* + string(11) memMobile 手机号码 手机/微信号/邮箱,不可同时为空
* + string(80) memEmail 邮箱地址 手机/微信号/邮箱,不可同时为空
* + int(10) memActive 是否在职(0: 已离职; 1: 在职)
* + string(54) memUsername 用户名称
* + int(10) memNum 用户编号
* + int(10) memAdmincp 是否管理员(0: 非管理员; 1: 管理员)
* + int(11) memGroupid 分组ID
* + int(2) memGender 性别(0: 未知; 1: 男; 2: 女)
* + string(255) memAddress 用户所在地址
* + string(18) memIdcard 身份证号
* + string(64) memTelephone 电话号码, 一般是固话
* + string(12) memQq QQ
* + string(10) memBirthday 生日(年月日)
* + string(255) memRemark 备注
* + string(255) memExt1 预留字段
* + string(255) memExt2 预留字段
* + string(255) memExt3 预留字段
* + string(255) memExt4 预留字段
* + string(255) memExt5 预留字段
* + string(255) memExt6 预留字段
* + string(255) memExt7 预留字段
* + string(255) memExt8 预留字段
*
* @throws \VcySDK\Exception
* @return boolean|mixed
*/
public function update($data)
{
$this->service->getValue($data, ['dpIdList']);
$memberAttr = new MemberAttr();
list($defData, $extAttrs, $extAttrsField) = $memberAttr->splitAttr($data);
// 这里遍历下扩展属性 UC 需要扩展属性名称
foreach ($extAttrs as $field => $value) {
$defData['extattr'][] = [
'name' => $extAttrsField[$field]['attr_name'],
// 如果是单选类型的
'value' => in_array($extAttrsField[$field]['type'], [
AttrModel::ATTR_TYPE_RADIO,
AttrModel::ATTR_TYPE_CHECKBOX,
]) ? $extAttrsField[$field]['option'][$value]['name'] : $value
];
}
$result = $this->serv->postSDK(self::UPDATE_URL, $defData, 'generateApiUrlA');
if ($result['memUid'] && $extAttrs) {
$extData = $memberAttr->formatExtData($result['memUid'], $extAttrs);
$this->batModifyExt(['data' => $extData]);
}
return $result;
}
/**
* 更新所有用户的扩展字段
*
* @param array $member 人员数据
* + string(255) memExt1 预留字段
* + string(255) memExt2 预留字段
* + string(255) memExt3 预留字段
* + string(255) memExt4 预留字段
* + string(255) memExt5 预留字段
* + string(255) memExt6 预留字段
* + string(255) memExt7 预留字段
* + string(255) memExt8 预留字段
*
* @throws \VcySDK\Exception
* @return boolean|mixed
*/
public function updateExt($member)
{
return $this->serv->postSDK(self::UPDATE_EXT_URL, $member, 'generateApiUrlA');
}
/**
* 查询用户对应的部门列表
*
* @param array $condition 查询条件
* @param bool $ignorePermissions 是否跳过鉴权
*
* @return boolean|multitype
*/
public function listDepartment($condition, $ignorePermissions = true)
{
return $this->serv->postSDK($ignorePermissions ?
self::MEMBER_IGNORE_PERMISSIONS_MEMBER_DEPARTMENT_LIST_URL : self::MEMBER_DEPARTMENT_LIST_URL,
$condition,
'generateApiUrlA');
}
/**
* 查询用户对应职位的列表
*
* @param array $condition 查询条件
*
* @return bool|mixed
* @throws \VcySDK\Exception
*/
public function listJob($condition)
{
return $this->serv->postSDK(self::MEMBER_JOB_LIST_URL, $condition, 'generateApiUrlA');
}
/**
* 添加人员
*
* @param array $data 人员数据
* + array dpIdList 部门ID
* + string(54) memUsername 用户名称
* + string(64) memWeixin 微信号 手机/微信号/邮箱,不可同时为空
* + string(11) memMobile 手机号码 手机/微信号/邮箱,不可同时为空
* + string(80) memEmail 邮箱地址 手机/微信号/邮箱,不可同时为空
* + int(10) memActive 是否在职(0: 已离职; 1: 在职)
* + int(10) memNum 用户编号
* + int(10) memAdmincp 是否管理员(0: 非管理员; 1: 管理员)
* + int(11) memGroupid 分组ID
* + int(2) memGender 性别(0: 未知; 1: 男; 2: 女)
* + string(255) memAddress 用户所在地址
* + string(18) memIdcard 身份证号
* + string(64) memTelephone 电话号码, 一般是固话
* + string(12) memQq QQ
* + string(10) memBirthday 生日(年月日)
* + string(255) memRemark 备注
* + string(255) memExt1 预留字段
* + string(255) memExt2 预留字段
* + string(255) memExt3 预留字段
* + string(255) memExt4 预留字段
* + string(255) memExt5 预留字段
* + string(255) memExt6 预留字段
* + string(255) memExt7 预留字段
* + string(255) memExt8 预留字段
*
* @return bool|mixed
* @throws \VcySDK\Exception
*/
public function add($data)
{
$this->service->getValue($data, ['dpIdList']);
$memberAttr = new MemberAttr();
list($defData, $extAttrs, $extAttrsField) = $memberAttr->splitAttr($data);
// 这里遍历下扩展属性 UC 需要扩展属性名称
foreach ($extAttrs as $field => $value) {
$defData['extattr'][] = [
'name' => $extAttrsField[$field]['attr_name'],
// 如果是单选类型的
'value' => in_array($extAttrsField[$field]['type'], [
AttrModel::ATTR_TYPE_RADIO,
AttrModel::ATTR_TYPE_CHECKBOX,
]) ? $extAttrsField[$field]['option'][$value]['name'] : $value
];
}
$result = $this->serv->postSDK(self::ADD_URL, $defData, 'generateApiUrlA');
if ($result['memUid'] && $extAttrs) {
$extData = $memberAttr->formatExtData($result['memUid'], $extAttrs);
$this->batModifyExt(['data' => $extData]);
}
return $result;
}
/**
* 用户删除
*
* @param array $condition 条件数组
* + string(32) memUid 人员ID
*
* @return bool|mixed
* @throws \VcySDK\Exception
*/
public function delete($condition)
{
return $this->serv->postSDK(self::DELETE_URL, $condition, 'generateApiUrlA');
}
/**
* 用户列表
*
* @param $condition
* + array memUids memUid数组
* + int pageNum 页码
* + int pageSize 每页记录数
* + string|array name 搜索条件
*
* @return array|bool
*/
public function searchList($condition)
{
$this->service->getValue($condition, ['memUids']);
return $this->serv->postSDK(self::SEARCH_URL, $condition, 'generateApiUrlA');
}
/**
* 读取应用权限列表
*
* @return array|bool
*/
public function appAllow()
{
return $this->serv->postSDK(self::APP_ALLOW_URL, [], 'generateApiUrlA');
}
/**
* 批量删除
*
* @param $param
* + string memUids 用户ID列表
*
* @return array|bool
*/
public function batDelete($param)
{
return $this->serv->postSDK(self::BAT_DEL_URL, $param, 'generateApiUrlA');
}
/**
* 批量启用、禁用
*
* @param $param
* + array memUids 用户ID列表
* + int enable 操作类型 : 1=启用, 0=禁用
*
* @return array|bool
*/
public function batchModifyStatus($param)
{
return $this->serv->postSDK(self::MODIFY_STATUS_URL, $param, 'generateApiUrlA');
}
/**
* 批量用户移动部门
*
* @param $param
* + array memUids 用户UID列表
* + array dpIdList 部门ID列表
*
* @return array|bool
*/
public function moveDept($param)
{
return $this->serv->postSDK(self::MOVE_DEPT_URL, $param, 'generateApiUrlA');
}
/**
* 添加扩展属性
*
* @param $param
* + string memUid 用户UID
* + string extKey 扩展属性Key
* + mixed extValue 扩展属性Value
*
* @return array|bool
*/
public function addExt($param)
{
return $this->serv->postSDK(self::MEMBER_EXT_ADD_URL, $param, 'generateApiUrlA');
}
/**
* 批量添加扩展属性
*
* @param $param
* + array data 属性数据
*
* @return array|bool
*
* $data = [
* [
* 'memUid' => '',
* 'extKey' => '',
* 'extValue' => '',
* ],
* ];
*
*/
public function batAddExt($param)
{
return $this->serv->postSDK(self::MEMBER_EXT_BATADD_URL, $param, 'generateApiUrlA');
}
/**
* 查询用户扩展属性
*
* @param $param
* + string extId 扩展属性ID
*
* @return array|bool
*/
public function getExt($param)
{
return $this->serv->postSDK(self::MEMBER_EXT_GET_URL, $param, 'generateApiUrlA');
}
/**
* 查询用户所有扩展属性
*
* @param $param
* + string memUid 用户UID
*
* @return array|bool
*/
public function listExt($param)
{
return $this->serv->postSDK(self::MEMBER_EXT_LIST_URL, $param, 'generateApiUrlA');
}
/**
* 修改用户扩展属性
*
* @param $param
* + string extId 扩展属性ID
* + string memUid 用户UID
* + string extKey 扩展属性Key
* + mixed extValue 扩展属性Value
*
* @return array|bool
*/
public function modifyExt($param)
{
return $this->serv->postSDK(self::MEMBER_EXT_MODIFY_URL, $param, 'generateApiUrlA');
}
/**
* 删除用户扩展属性
*
* @param $param
* + string extId 扩展属性ID
*
* @return array|bool
*/
public function delExt($param)
{
return $this->serv->postSDK(self::MEMBER_EXT_DEL_URL, $param, 'generateApiUrlA');
}
/**
* 批量编辑扩展属性
*
* @param $param
* + array data 属性数据
*
* @return array|bool
*
* $data = [
* [
* 'memUid' => '',
* 'extKey' => '',
* 'extValue' => '',
* ],
* ];
*
*/
public function batModifyExt($param)
{
return $this->serv->postSDK(self::MEMBER_EXT_BATMODIFY_URL, $param, 'generateApiUrlA');
}
/**
* 删除所有用户指定扩展属性
*
* @param $param
* + string extKey 扩展属性Key
*
* @return array|bool
*/
public function delAllExt($param)
{
return $this->serv->postSDK(self::MEMBER_EXT_ALLDEL_URL, $param, 'generateApiUrlA');
}
/**
* 人员、已关注、未关注、禁用人员总数
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberRelevantTotal()
{
return $this->serv->postSDK(self::MEMBER_RELEVANT_TOTAL, [], 'generateApiUrlE');
}
/**
* 在职情况统计
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberActiveTotal()
{
return $this->serv->postSDK(self::MEMBER_ACTIVE_TOTAL, [], 'generateApiUrlE');
}
/**
* 判断指定用户信息是否已存在 (手机号, 邮箱, 微信号)
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function checkMemInfoSingle($condition)
{
return $this->serv->postSDK(self::CHECK_INFO_EXIST_URL, $condition, 'generateApiUrlA');
}
/**
* 用户配置数据保存
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberSettingSave($condition)
{
return $this->serv->postSDK(self::MEMBER_SETTING_SAVE, $condition, 'generateApiUrlA');
}
/**
* 用户配置数据查找
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberSettingGet($condition)
{
return $this->serv->postSDK(self::MEMBER_SETTING_GET, $condition, 'generateApiUrlA');
}
/**
* 用户配置数据列表
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberSettingAll($condition)
{
return $this->serv->postSDK(self::MEMBER_SETTING_ALL, $condition, 'generateApiUrlA');
}
/**
* 用户配置数据删除
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberSettingDelete($condition)
{
return $this->serv->postSDK(self::MEMBER_SETTING_DELETE, $condition, 'generateApiUrlA');
}
/**
* 根据 UserId 查询用户详情
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberGetByUserId($condition)
{
return $this->serv->postSDK(self::MEMBER_GET_BY_USERID, $condition, 'generateApiUrlA');
}
/**
* 根据 UserId 查询用户详情
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberOpenIdToUserId($condition)
{
return $this->serv->postSDK(self::MEMBER_OPENID_TO_USERID, $condition, 'generateApiUrlA');
}
/**
* 企业用户关注状态统计接口(忽略权限过滤)
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberStatusCount($condition)
{
return $this->serv->postSDK(self::MEMBER_IGNORE_PERMISSIONS_STATUS_COUNT, $condition, 'generateApiUrlA');
}
/**
* 获取没有部门的人员 (跳过鉴权)
* @param array $condition 查询条件数据
* @param mixed $orders 排序字段
* @param int $page 当前页码
* @param int $perpage 每页记录数
* @return array|bool
* @throws \VcySDK\Exception
*/
public function getNoPepartmentMember($condition = [], $page = 1, $perpage = 30, $orders = [])
{
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
return $this->serv->postSDK(
self::MEMBER_IGNORE_PERMISSIONS_GET_NO_DEPARTMENT_MEMBER,
$condition,
'generateApiUrlA');
}
/**
* 判断当前登陆人员是否微信管理员
*
* @param $params
* + userid string 用户ID
* + plIdentifier string 应用标识
*
* @return array|bool
*/
public function loginCheckAuth($params)
{
return $this->serv->postSDK(
self::LOGIN_CHECK_AUTH,
$params,
'generateApiUrlSP'
);
}
/**
* 获取某时间段内人员数量
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function memberCountByDay($condition)
{
return $this->serv->postSDK(self::MEMBER_COUNT_BY_DAY, $condition,
'generateApiUrlA');
}
/**
* 根据手机或邮箱或姓名获取用户信息列表
*
* @param array $condition 查询条件数据
* array(
* array(
* 'names'=>array(),
* 'mobiles'=>array(),
* 'emails'=>array(),
* )
* @param int $page 当前页码
* @param int $perpage 每页记录数
* @param int $orders 排序
* @return boolean|multitype:
*/
public function list_import_user($condition = array(), $page = 1, $perpage = 1000, $orders = array())
{
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
// 查询参数
$keyList = [];
foreach (['names', 'emails', 'mobiles'] as $_key) {
$this->service->setAndIsArr($condition, $_key, $keyList);
}
$this->service->getValue($condition, $keyList);
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
return $this->serv->postSDK(self::MEMBER_USER_IMPORT_BASIC_LIST, $condition, 'generateApiUrlA');
}
/**
* 根据 UserId 查询用户所有标签
*
* @param $condition
*
* @return array|bool
* @throws \VcySDK\Exception
*/
public function getTagsByUserId($condition)
{
return $this->serv->postSDK(self::MEMBER_TAGS_GET_BY_USERID, $condition, 'generateApiUrlA');
}
}