📄 create_coupon.jsp
字号:
<%@ include file="common_imports.jsp" %>
<%
if(jspPath == null)
jspPath = "/shop/my_account.jsp";
//if (!isSignin) {
// request.getRequestDispatcher("/shop/login.jsp?jsp_path=/shop/create_coupon.jsp").forward(request,response);
//} else
if (! "admin".equals(userID)) {
request.getRequestDispatcher(jspPath).forward(request,response);
}
String error = "";
String formTitle = "Create New Coupon";
String buttonLabel = "Create Coupon";
String savedMsg = "";
String insertCouponSQL = "INSERT INTO OPERA_COUPON_INFO (couponid, contentid, shopid, value, description) VALUES (?,?,?,?,?)";
String verifySQL = "SELECT contentid,shopid,value,description FROM OPERA_COUPON_INFO WHERE couponid=?";
String action = request.getParameter("action");
String description = request.getParameter("description");
String contentID = request.getParameter("content_id");
String couponID = request.getParameter("couponid");
String shopID = request.getParameter("shopid");
String couponValue = request.getParameter("couponvalue");
if ("create".equals(action)) {
if (couponID == null || "".equals(couponID.trim()))
error += " Coupon ID is required.<br/>";
else {
String[] existingCoupon = DBUtil.getRecord(verifySQL,
new int[] {java.sql.Types.VARCHAR,java.sql.Types.VARCHAR,java.sql.Types.FLOAT,java.sql.Types.VARCHAR},
null, new String[] {couponID});
if (existingCoupon != null) {
error += " Coupon code has already existed.<br/>";
}
}
if (contentID == null || "".equals(contentID.trim()))
error += " Content ID is required.<br/>";
if (shopID == null || "".equals(shopID.trim()))
error += " Shop ID is required.<br/>";
if (couponValue == null || "".equals(couponValue.trim()))
error += " Coupon Value is required.<br/>";
else {
try {
Float.parseFloat(couponValue);
}catch (Exception ex) {
error += " Invalid Coupon value.<br/>";
}
}
if ("".equals(error)) {
DBUtil.execute(insertCouponSQL, new Object[] {couponID, contentID,shopID, Float.valueOf(couponValue),description});
savedMsg = " " + couponID + " coupon has been created.<br/>";
}
}
if (couponID == null) couponID ="";
if (contentID == null) contentID = "";
if (couponValue == null) couponValue = "";
if (description == null) description = "";
%>
<%@ include file="top_body.jsp" %>
<td width="500" valign="top">
<table width="480" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<a href="coupon.jsp" style="text-decoration:none;font-size:11px">Go back to coupon list</a></td>
</tr>
<tr>
<td class="song_title">
<%=formTitle%></td>
</tr>
<tr>
<td class="subsong_detail" style="font-size:9px"> <span class="star">*</span> Indicates required field</td>
</tr>
<tr>
<td> </td>
</tr>
<%
if (!"".equals(error)) {
%>
<tr>
<td class="star" style="font-weight:normal;"><%=error%></td>
</tr>
<tr>
<td> </td>
</tr>
<%
} else if (! "".equals(savedMsg)) {
%>
<tr>
<td class="subsong_detail"><%=savedMsg%></td>
</tr>
<tr>
<td> </td>
</tr>
<%
}
%>
<tr>
<td>
<form method="post">
<input type="hidden" name="action" value="create">
<table cellspacing="0" cellpadding="4">
<tr>
<td class="subsong_detail"> <b>Coupon Code:</b><span class="star">*</span> </td>
<td class="subsong_detail"> <input type="text" class="body_text" name="couponid" size="25" value="<%=couponID%>"/></td>
</tr>
<tr>
<td class="subsong_detail" valign="top"> <b>Content ID:</b><span class="star">*</span> </td>
<td class="subsong_detail"> <input type="text" class="body_text" name="content_id" size="25" value="<%=contentID%>"/><br/>
<span class="body_text" style="font-size:9px"> Type: <b>total</b> if the coupon is for total purchase, NOT for specific content.
</td>
</tr>
<tr>
<td class="subsong_detail"> <b>Shop ID:</b> </td>
<td class="subsong_detail"> <%=operaShopID%></td>
<input type="hidden" name="shopid" value="<%=operaShopID%>">
</tr>
<tr>
<td class="subsong_detail"> <b>Value:</b><span class="star">*</span> </td>
<td class="subsong_detail">$ <input type="text" class="body_text" name="couponvalue" size="25" value="<%=couponValue%>"/></td>
</tr>
<tr>
<td class="subsong_detail"> <b>Description:</b> </td>
<td class="subsong_detail"> <input type="text" class="body_text" name="description" size="25" value="<%=description%>"/></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" class="body_text" value="<%=buttonLabel%>"/></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td>
<%@ include file = "footer.jsp" %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -