<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
|
<%Session.CodePage=65001%>
|
<!--#include file="JsonPost_user.gds"-->
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<%
|
Set rs = Server.CreateObject("ADODB.Recordset")
|
departmentID = trim(Request("departmentID"))
|
If departmentID="" Then Response.Redirect "/"
|
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/user/list"
|
|
method="user_list"
|
Origin="access_token="&access_token&"&department_id="&departmentID&"&fetch_child=0&status=0"
|
|
'Response.Write Origin &"<BR>"
|
|
HTMLCODE= GetBody(appUrl,Origin)
|
'Response.Write HTMLCODE&"<br><br>"
|
'Response.End
|
|
|
JsonID=""
|
If Mid(HTMLCODE,12,1)<>"0" Then
|
Response.Write HTMLCODE
|
Else
|
'结果写入数据库
|
reserve=departmentID
|
JsonID = API_JsonSql(method,HTMLCODE,reserve)
|
End If
|
|
If JsonID<>"" Then
|
sql="update OA_User set OA_weixinStatus=0 where OA_DepartmentID="&departmentID
|
objConn.Execute sql
|
|
json = HTMLCODE
|
Sum_I = 0
|
|
str=json
|
str=right(str,len(str)-instr(str,"[{")-1)
|
str=left(str,InstrRev(str,"}]")-1)
|
'Response.Write Str&"<br><br>"
|
jsonPS=SPLIT(Str,"},{")
|
for i = 0 to UBOUND(jsonPS)
|
'Response.Write jsonPS(i) &"<br>"
|
json_dataPS=SPLIT(jsonPS(i),",")
|
OA_weixinUserID=""
|
OA_Name=""
|
OA_Position=""
|
OA_mobile=""
|
OA_gender=""
|
OA_email=""
|
OA_weixinID=""
|
OA_weixinAvatar=""
|
OA_weixinStatus=""
|
for j = 0 to UBOUND(json_dataPS)
|
json_dataName = Replace(left(json_dataPS(j),Instr(json_dataPS(j),":")-1),"""","")
|
json_dataStr = mid(json_dataPS(j),Instr(json_dataPS(j),":")+1)
|
If Left(json_dataStr,1)="""" Then json_dataStr=Mid(json_dataStr,2)
|
If right(json_dataStr,1)="""" Then json_dataStr=Mid(json_dataStr,1,Len(json_dataStr)-1)
|
select case json_dataName
|
case "userid"
|
OA_weixinUserID = json_dataStr '成员UserID。对应管理端的帐号
|
case "name"
|
OA_Name = json_dataStr '成员名称
|
case "position"
|
OA_Position = json_dataStr '职位信息
|
case "mobile"
|
OA_mobile = json_dataStr '手机号码
|
case "gender"
|
OA_gender = json_dataStr '性别。0表示未定义,1表示男性,2表示女性
|
case "email"
|
OA_email = json_dataStr '邮箱
|
case "weixinid"
|
OA_weixinID = json_dataStr '微信号
|
case "avatar"
|
json_dataStr = Replace(json_dataStr,"\/","\")
|
OA_weixinAvatar = json_dataStr '头像url。注:如果要获取小图将url最后的
|
case "status"
|
OA_weixinStatus = json_dataStr '关注状态: 1=已关注,2=已冻结,4=未关注
|
end select
|
Next
|
'更新库存数据
|
If OA_weixinUserID<>"" And OA_Name<>"" Then
|
sql="select OA_User_ID from OA_User where OA_weixinUserID='"&OA_weixinUserID&"'"
|
rs.open sql,objConn,1,1
|
If OA_weixinStatus=2 Then
|
OA_execLevel=-1
|
Else
|
OA_execLevel=1
|
End if
|
if not rs.Eof then
|
OA_User_ID = rs("OA_User_ID")
|
If OA_execLevel=-1 Then
|
execLevelSql=",OA_execLevel=-1 "
|
Else
|
execLevelSql=""
|
End if
|
sql="update OA_User set OA_Name='"&OA_Name&"',OA_Position='"&OA_Position&"',OA_mobile='"&OA_mobile&"',OA_gender="&OA_gender&",OA_email='"&OA_email&"',OA_weixinID='"&OA_weixinID&"',OA_weixinAvatar='"&OA_weixinAvatar&"',OA_weixinStatus="&OA_weixinStatus&",OA_DepartmentID="&departmentID&""&execLevelSql&" where OA_User_ID="&OA_User_ID
|
objConn.Execute sql
|
Else
|
sql="Insert into OA_User (OA_User,OA_Pass,OA_weixinUserID,OA_Name,OA_Position,OA_mobile,OA_gender,OA_email,OA_weixinID,OA_weixinAvatar,OA_weixinStatus,OA_execLevel,OA_DepartmentID) values ('"&OA_weixinUserID&"',pwdencrypt('000000'),'"&OA_weixinUserID&"','"&OA_Name&"','"&OA_Position&"','"&OA_mobile&"',"&OA_gender&",'"&OA_email&"','"&OA_weixinID&"','"&OA_weixinAvatar&"',"&OA_weixinStatus&","&OA_execLevel&","&departmentID&")"
|
objConn.Execute sql
|
end If
|
rs.close()
|
Sum_I=Sum_I+1
|
End if
|
next
|
|
sql="update OA_User set OA_weixinStatus=2,OA_execLevel=-1 where OA_weixinStatus=0 and OA_DepartmentID="&departmentID
|
objConn.Execute sql
|
sql="update API_Json set is_Json=is_Json+1,is_Json_time=getdate() where id="&JsonID
|
objConn.Execute sql
|
|
Response.Redirect "/AdminUser_List.gds?departmentID="&departmentID&"&h_menu1_1="&session("h_menu1_1")&"&SystemMessageType=3&SMT=1"
|
End if
|
%>
|