asp三級分銷佣金/提成代碼;

'--------------------------------
'參數uid爲用戶id,total爲消費金額;
'--------------------------------
sub commission(uid,total)
	dim sql,rs,pid1,pid2,pid3
	sql="select PID from idea_User where id="&uid
	set rs = Server.CreateObject("ADODB.RecordSet")
	rs.Open sql,conn,1,1
	if not rs.EOF Then
		pid1=rs("PID")
	else
		pid1=0
	end if
	rs.close
	
	if pid1>0 then
		conn.Execute("update idea_user set balance=balance+("&total&"*0.5) where id="&pid1)
		sql="select pid from idea_user where id="&pid1
		rs.open sql,conn,1,1
		if not rs.EOF then
			pid2=rs("PID")
		else
			pid2=0
		end if
		rs.Close
	end if
	
	If pid2>0 then
		conn.Execute("update idea_user set balance=balance+("&total&"*0.3) where id="&pid2)
		sql="select pid from idea_user where id="&pid2
		rs.open sql,conn,1,1
		if not rs.EOF then
			pid3=rs("PID")
		else
			pid3=0
		end if
		rs.Close
	end if
	
	If pid3>0 then
		conn.Execute("update idea_user set balance=balance+("&total&"*0.2) where id="&pid3)
	end if
	
	set rs=nothing
	Response.Write("success")
end sub

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章