<%@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 "/"
|
|
'部门信息
|
sql="select id,vID,vtext,vType,vOrder,vtitle from dictionary where vtitle='OA_Department' and vID="&departmentID
|
rs.open sql,objConn,1,1
|
If not rs.eof then
|
DepartmentName=rs("vtext")
|
If InStr(DepartmentName,"-")>1 Then DepartmentKey = Mid(DepartmentName,1,InStr(DepartmentName,"-")-1)
|
Else
|
Response.Redirect "/"
|
end if
|
rs.close()
|
If DepartmentKey<>"" Then
|
sql="select vOrder2 from dictionary where vtitle='OrderClass' and vtext like '"&DepartmentKey&"%' and vOrder2<>'' and vType>0"
|
rs.open sql,objConn,1,1
|
do while not rs.Eof
|
OA_OrderClass=OA_OrderClass&","&rs("vOrder2")
|
rs.movenext
|
loop
|
rs.close()
|
If OA_OrderClass<>"" Then OA_OrderClass=Mid(OA_OrderClass,2)
|
End If
|
If OA_OrderClass="" Then OA_OrderClass="BF,AB,SA"
|
|
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)
|
|
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
|
|
%>
|
<script language="JScript" runat="Server">
|
function toObject(json) {
|
eval("var o=" + json);
|
return o;
|
}
|
function toArray(s){
|
var dic = Server.CreateObject("Scripting.Dictionary")
|
eval("var a=" + json);
|
for(var i=0;i<a.length;i++){
|
var obj = Server.CreateObject("Scripting.Dictionary")
|
for(x in a[i]) obj.Add(x,a[i][x])
|
dic.Add(i, obj);
|
}
|
return dic
|
}
|
</script>
|
<script language="jscript" runat="server">
|
Array.prototype.get = function(i)
|
{
|
return this[i];
|
};
|
function getjson(str){
|
try{
|
eval("var jsonStr = (" + str + ")");
|
}catch(ex){
|
var jsonStr = null;
|
}
|
return jsonStr;
|
}
|
</script>
|
<%
|
str=HTMLCODE
|
str=right(str,len(str)-instr(str,"[")+1)
|
str=left(str,InstrRev(str,"]"))
|
dim obj
|
set obj = getjson(str)
|
for i=0 to obj.length-1
|
OA_weixinUserID = obj.get(i).userid '成员UserID。对应管理端的帐号
|
OA_Name = obj.get(i).name '成员名称
|
departmentIDs = obj.get(i).department '部门信息
|
If departmentIDs<>"" Then
|
departmentIDsSP = SPLIT(departmentIDs,",")
|
If departmentIDsSP(0)="185" And UBOUND(departmentIDsSP)>0 Then
|
departmentID = departmentIDsSP(1)
|
Else
|
departmentID = departmentIDsSP(0)
|
End If
|
Else
|
departmentID = 0
|
End If
|
OA_Position = obj.get(i).position '职位信息
|
OA_mobile = obj.get(i).mobile '手机号码
|
OA_gender = obj.get(i).gender '性别。0表示未定义,1表示男性,2表示女性
|
OA_email = obj.get(i).email '邮箱
|
'OA_weixinID = obj.get(i).weixinid '微信号
|
OA_weixinAvatar = Replace(obj.get(i).avatar,"\/","\") '头像url。注:如果要获取小图将url最后的
|
OA_weixinStatus = obj.get(i).status '关注状态: 1=已关注,2=已冻结,4=未关注
|
OA_IdentityCard = ""
|
for v=0 to obj.get(i).extattr.attrs.length-1
|
If obj.get(i).extattr.attrs.get(v).name="身份证" Then
|
OA_IdentityCard=obj.get(i).extattr.attrs.get(v).value
|
End If
|
Next
|
|
'Response.Write HTMLCODE&"<br><br>"
|
'Response.End
|
|
'更新库存数据
|
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_IdentityCard='"&OA_IdentityCard&"',OA_weixinStatus="&OA_weixinStatus&",OA_DepartmentID="&departmentID&",OA_DepartmentIDs='"&departmentIDs&"'"&execLevelSql&" where OA_User_ID="&OA_User_ID
|
'Response.Write sql
|
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_IdentityCard,OA_weixinStatus,OA_execLevel,OA_DepartmentID,OA_DepartmentIDs,OA_OrderClass) values ('"&OA_weixinUserID&"',pwdencrypt('000000'),'"&OA_weixinUserID&"','"&OA_Name&"','"&OA_Position&"','"&OA_mobile&"',"&OA_gender&",'"&OA_email&"','"&OA_weixinID&"','"&OA_weixinAvatar&"','"&OA_IdentityCard&"',"&OA_weixinStatus&","&OA_execLevel&","&departmentID&",'"&OA_DepartmentIDs&"','"&OA_OrderClass&"')"
|
objConn.Execute sql
|
'设置职能
|
If InStr(OA_Position,"客服")>0 Then OA_Competency=OA_Competency&",1"
|
If InStr(OA_Position,"司机")>0 Then OA_Competency=OA_Competency&",2"
|
If InStr(OA_Position,"医生")>0 Then OA_Competency=OA_Competency&",3"
|
If InStr(OA_Position,"护士")>0 Then OA_Competency=OA_Competency&",4"
|
If OA_Competency<>"" Then
|
OA_CompetencySP=SPLIT(OA_Competency,",")
|
for z = 1 to UBOUND(OA_CompetencySP)
|
OA_CompetencyID=OA_CompetencySP(z)
|
sql="insert into OA_Competency (OA_CompetencyID,OA_CompetencyUserID) select "&OA_CompetencyID&",OA_User_ID from OA_User where OA_User='"&OA_weixinUserID&"'"
|
objConn.Execute sql
|
next
|
End If
|
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
|
End If
|
Response.Redirect "/AdminUser_List.gds?departmentID="&departmentID&"&h_menu1_1="&session("h_menu1_1")&"&SystemMessageType=3&SMT=1"
|
%>
|