<!--#include virtual="/inc/conn.asp"--> 
<!--#include virtual="/inc/sitecon.asp"--> 
<!--#include virtual="/inc/md52.asp"-->
<%

Server.ScriptTimeOut = 999999
On error resume next 

downurl="http://"&trim(Request.ServerVariables("SERVER_NAME"))&"/" 

isnext="no"

Function SendEMail(email,title,body)
ismailok="yes"
if instr(1,trim(email),"@")=0 then ismailok="no"
	if ismailok="yes" then
		Dim JMail
		Set JMail = Server.CreateObject("JMail.Message")  
		JMail.Charset = "gb2312" 							

		JMail.FromName = mailformname	
		JMail.From = mailform							
		JMail.MailServerUserName = mailservername 	
		JMail.MailServerPassword = mailserverpass			
		msmtp=mailserver
				
		JMail.AddRecipient(trim(email))
		JMail.Subject = trim(title)
		JMail.Priority = 3
		JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR") 
		JMail.HTMLBody = "<html><head><META content=zh-cn http-equiv=Content-Language><meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"&body&"</body></html>" 
		JMail.Send(msmtp)
		JMail.Close() 
		Set JMail = Nothing 
		end if
		
		if err.number<>0 then 
		SendEMail="bad"
		else 
		SendEMail="ok"
		end if 
end Function

function gettel(url,cset) 
dim Http 
set Http=server.createobject("MSXML2.XMLHTTP") 
Http.open "GET",url,false 
Http.send() 
if Http.readystate<>4 then exit function 
gettel=BytesToBstr(Http.responseBody,cset) 
set http=nothing 
if err.number<>0 then err.Clear  
end function 


						rs.open "select top 1 * from mailto where mzt=0 order by mlei desc,mid desc",conn,1,3
						if not(rs.bof and rs.eof) then 
						
								if cint(rs("mfs"))=0 then '邮箱
									durl=downurl&"sms/alimail/mailto.php?mto="&trim(rs("mto"))&"&mti="&trim(rs("mti"))&"&mcon="&trim(rs("mcon"))&""
									ustr=gettel(durl,"gb2312")
									ustr=ReplaceTrim(ustr)
									isnext="yes"
									rs("mzt")=1
										if ustr="bad" then 
										rs("mzt2")=1
										elseif ustr="ok" then 
										rs("mzt2")=0
										else
										rs("mzt2")=0
										end if
									rs.update
								end if
								
								if cint(rs("mfs"))=1 then '手机
									ayapipartner=aysmsuser
									aysmspass=aysmspass
									userstr=""
									userstr="ayapipartner="&ayapipartner
									userstr=userstr&"&mobile="&trim(rs("mto"))
									userstr=userstr&"&aysmspass="&aysmspass
									userstrsign=md5(userstr)
									str = gettel(""&apijk&"sms.asp?ayapipartner="&ayapipartner&"&usersign="&userstrsign&"&mmbmid="&trim(rs("mbid"))&"&mobile="&trim(rs("mto"))&"&code1="&trim(rs("code1"))&"&code2="&trim(rs("code2"))&"&code3="&trim(rs("code3"))&"","gb2312")
									if str<>"000" then rs("mzt2")=1
									isnext="yes"
									rs("mzt")=1
									rs.update
								end if
								
								if cint(rs("mfs"))=2 then '微信
									isnext="yes"
									rs("mzt")=1
										if cint(rs("wxlei"))=0 then  '卖出通知
										weixinstr=gettel(""&downurl&"weixin/sms_maichu.php?touser="&trim(rs("mto"))&"&aywxchengjiao="&trim(rs("wx1"))&"&aywxshangpin="&trim(rs("wx2"))&"&aywxshuliang="&trim(rs("wx3"))&"&aywxjin="&trim(rs("wx4"))&"&aywxshijian="&trim(rs("wx5"))&"&aywxbiaoti="&trim(rs("wxtop"))&"&aywxend="&trim(rs("wxend"))&"&access_token="&getaccesstoken&"","gb2312")
										elseif cint(rs("wxlei"))=1 then  '库存不足通知 
										weixinstr=gettel(""&downurl&"weixin/sms_kucun.php?touser="&trim(rs("mto"))&"&aywxdianpu="&trim(rs("wx1"))&"&aywxshangpin="&trim(rs("wx2"))&"&aywxkucun="&trim(rs("wx3"))&"&aywxbiaoti="&trim(rs("wxtop"))&"&aywxend="&trim(rs("wxend"))&"&access_token="&getaccesstoken&"","gb2312")
										elseif cint(rs("wxlei"))=2 then  '买家购买成功通知 
										weixinstr=gettel(""&downurl&"weixin/sms_maijia.php?touser="&trim(rs("mto"))&"&aywxshangpin="&trim(rs("wx1"))&"&aywxend="&trim(rs("wxtext"))&"&access_token="&getaccesstoken&"","gb2312")
										elseif cint(rs("wxlei"))=3 then  '投诉通知 
										weixinstr=gettel(""&downurl&"weixin/sms_tousu.php?touser="&trim(rs("mto"))&"&wxtop="&trim(rs("wxtop"))&"&wxend="&trim(rs("wxtext"))&"&wx1="&trim(rs("wx1"))&"&wx2="&trim(rs("wx2"))&"&access_token="&getaccesstoken&"","gb2312")
										end if
										Set json = toObject(weixinstr)
										if trim(json.errmsg)="ok" then 
										rs("mzt2")=0
										else
										rs("mzt2")=1
										rs("fanhui")=json.errmsg
										end if
								rs.update	
								end if
						else
						isnext="yes"
						end if
						rs.close


conn.close


response.Write "OK<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>"
%>

