最近接的一个小项目,客户要求用asp写,微信公众号支付完成后回调入库,晚上加了会班,帮他写了一段asp微信公众号支付回调参数入库demo详细示例
sub AddData() ‘当本接口网络出现问题或无法返回success字符时,微信将会在30分钟内重复8次后台通知,入库时需要判断是否已经入库,避免重复数据入库‘看看记录存在了吗dim Rs,SQL,rsf‘必须声明,微信支付环境要求很高set rsf=conn.execute ("select * from Order_Info where transaction_id=‘"&transaction_id&"‘") if not rsf.eof then‘这里查询的transaction_id是指微信支付流水单,存在了什么也不做 else‘说明不存在下面开始修改这条信息,把微信返回的支付信息入库 SQL = "select * from Order_Info where ddh_=‘"&out_trade_no&"‘"‘out_trade_no是支付的订单号,在jsapi.asp中已经入库保存到ddh_里面了 Set Rs = Server.CreateObject("Adodb.RecordSet") Rs.Open SQL,Conn,1,3 Rs("openid") = openid Rs("is_subscribe") = is_subscribe Rs("trade_type") = trade_type Rs("bank_type") = bank_type Rs("total_fee") = total_fee Rs("transaction_id") = transaction_id Rs("out_trade_no") = out_trade_no Rs("time_end") = time_end Rs("AddTime") = Now() Rs("attach") = attach Rs("zfok") = "支付成功" Rs("Info") = request.QueryString Rs.Update Response.Write returnXml ‘返回SUCCESS给微信 Rs.Close Set Rs = Nothing ‘下面打开这个流水单,取得这条流水里的会员id ‘===============================下面在往会员表中写入支付成功的信息,其实这一步可以省掉的======================= dim SQLyy,Rsyy,hyidid,ipay,dateend,upper,ceo,yj,ej ipay = 1 dateend = date()+366 yj = Cint(Conn.execute("select yj from [about] where id =1")(0))‘取到一级拥级多少钱 ej = Cint(Conn.execute("select ej from [about] where id =1")(0))‘取到二级拥级多少钱 ‘newddh = int(attach)‘取到这个会员支付的流水id号 hyidid = Conn.execute("select hyid_ from [Order_Info] where ddh_=‘"&out_trade_no&"‘")(0)‘从流水明细中取得支付者的会员id号 Conn.ExeCute("update [member] set imoney=imoney+"&total_fee&",ipay="&ipay&",wx_text=‘"&attach&"‘,dateend=‘"&dateend&"‘ where Id="&hyidid&"")‘修改会员金额,是否支付,产品名字,到期时间 ‘下面开始查询他的上级,如果有则写入佣金 upper = Cint(Conn.execute("select upper from [member] where id ="&hyidid&"")(0))‘取到他的上级ID If Cint(upper) <> 0 Then Conn.ExeCute("update [member] set yongjin=yongjin+"&yj&" where Id="&upper&"")‘说明他是有上级的,给他的上级加点钱 Conn.Execute("Insert Into [upper_ls](hyid,qian,[upper]) values("&upper&",‘"&yj&"‘,"&hyidid&")")‘佣金流水明细 end if ‘下面开始查询他的上上级,如果有则写入佣金 ceo = Cint(Conn.execute("select [ceo] from [member] where id ="&hyidid&"")(0))‘取到他的上上级ID If Cint(ceo) <> 0 Then Conn.ExeCute("update [member] set yongjin=yongjin+"&ej&" where Id="&ceo&"")‘说明他是有上上级的,给他的上上级加点钱 Conn.Execute("Insert Into [upper_ls](hyid,jb,qian,[upper]) values("&ceo&",1,‘"&ej&"‘,"&hyidid&")")‘佣金流水明细 end if ‘写入结束============================================================= end ifrsf.closeset rsf=nothing‘检查是不是存在endend Sub