<!--#include file="conn.asp"-->
<%
action=Request("action")
%>

<%
if action="userJfNumber" then
JfNumber=Request("JfNumber")
selectedPromoPirce=JfNumber/cart_jfdk
%>
{"result":"success","data":{"selectedPromoPirce":<%=Formatnumber(selectedPromoPirce,2,-1,-1,0)%>}}
<%end if%>


<%if action="userCouponCodeNumber" then
couponCodeNumber=Request("couponCodeNumber")
	set rsp=server.CreateObject("adodb.recordset")
	rsp.open "select * from com_coupon where CodeNumber='"&couponCodeNumber&"'",conn,1,1
	if not rsp.bof or not rsp.eof then
	amount=rsp("amount")
	used=rsp("used")
	bgdate=rsp("date")
	enddate=rsp("enddate")
	if bgdate>date() then
	%>
	{"result":"error","message":"该优惠券还没生效，请重新输入"}
	<%
	elseif enddate<date() then
	%>
	{"result":"error","message":"该优惠券已经过期，请重新输入"}
	<%
	else
			if used=1 then
			%>
			{"result":"error","message":"该优惠券已经被使用过了，请重新输入"}
			<%
			else
			%>
			{"result":"success","data":{"selectedPromoPirce":<%=amount%>}}	
			<%
			end if
	end if
	else
	%>
	{"result":"error","message":"该优惠券不存在，请重新输入"}
	<%
	end if
	rsp.close
	set rsp=nothing
%>
<%end if%>

<%if action="calculatePromoPrice" then
promoRuleId=Request("promoRuleId")
if promoRuleId<>"coupon_code" then
setId=replace(promoRuleId,"act_","")
	set rsp=server.CreateObject("adodb.recordset")
	rsp.open "select * from com_act where id="&setId&"",conn,1,1
	if not rsp.bof or not rsp.eof then
	amount=rsp("amount")
%>
{"result":"success","data":{"totalProductQuantity":0,"totalProductPrice":0,"selectedPromoRuleId":"<%=promoRuleId%>","shoppingProductListHtml":"","selectedPromoPirce":<%=amount%>}}
<%
end if
	rsp.close
	set rsp=nothing
else
%>
{"result":"success","data":{"totalProductQuantity":0,"totalProductPrice":0,"selectedPromoRuleId":"<%=promoRuleId%>","shoppingProductListHtml":"","selectedPromoPirce":0}}
<%
end if
end if%>