getgeneraldiscount.jsp
来自「实现一个网络购物」· JSP 代码 · 共 33 行
JSP
33 行
<%--
Discounts are given in two includes:
- getdiscount.jsp for the product specific discounts
- getgeneraldiscount.jsp for the general discounts
<option id="5">(order) above the limit a discount of the amount mentioned</option>
<option id="6">(order) above the limit no shipping costs</option>
<option id="7">(order) a discount of the percentage mentioned</option>
<option id="8">(order) no shipping costs</option>
*************** 5,6,7,8: general discounts **********************
--%><%
int generaldiscount = 0;
%><mm:list nodes="$page" path="pages,posrel,discounts"
><mm:field name="discounts.startdate" jspvar="startdate" vartype="String" write="false"
><mm:field name="discounts.enddate" jspvar="enddate" vartype="String" write="false"><%
if(Long.parseLong(startdate)<=now && now<=Long.parseLong(enddate)) {
%><mm:field name="discounts.type" jspvar="type" vartype="String" write="false"
><mm:field name="discounts.amount" jspvar="discounts_amount" vartype="String" write="false"
><mm:field name="discounts.threshold" jspvar="discounts_threshold" vartype="String" write="false"><%
int amount = Integer.parseInt(discounts_amount);
int threshold = Integer.parseInt(discounts_threshold);
if(type.equals("5")&&(totalSum>threshold)) { generaldiscount = amount; }
if(type.equals("6")&&(totalSum>threshold)) { shippingCosts = 0; }
if(type.equals("7")) { generaldiscount = (amount*totalSum)/100; }
if(type.equals("8")) { shippingCosts = 0; }
%></mm:field
></mm:field
></mm:field><%
} %></mm:field
></mm:field
></mm:list>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?