merchantvoucherprovideaction.java

来自「基于struts的网上商店源码」· Java 代码 · 共 90 行

JAVA
90
字号
/*
 * 作者:刘云云
 * 时间:2007年12月12日
 * 功能:会员信息管理->发放优惠券。
 */
package com.mole.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.mole.struts.bean.MerchantVoucherBean;
import com.mole.struts.dao.MerchantVoucherProvideDAO;
import com.mole.struts.form.MerchantVoucherProvideForm;

/**
 * MyEclipse Struts Creation date: 12-12-2007
 * 
 * XDoclet definition:
 * 
 * @struts.action validate="true"
 * @struts.action-forward name="goMerchantVoucherConsignProvide"
 *                        path="/merchantVoucherConsignProvide.jsp"
 */
public class MerchantVoucherProvideAction extends Action {
	/*
	 * Generated Methods
	 */

	/**
	 * Method execute
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String storeId = (String) request.getSession().getAttribute("store");
		MerchantVoucherProvideDAO dao = new MerchantVoucherProvideDAO();
		String action = request.getParameter("action");

		if (action == null || action.equals("owner")) {// 获取发放本店优惠券页面
			String opp = request.getParameter("opp");
			if (opp != null && opp.equals("ok")) {
				MerchantVoucherProvideForm mpForm = (MerchantVoucherProvideForm) form;
				try {
					dao.executeProvideVoucherProcedure(storeId
							+ mpForm.getCardId(), mpForm.getVoucherId(), mpForm
							.getAmount());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			String sql = "SELECT ID,name,amount,discount FROM merchantVoucher WHERE storeID="
					+ storeId + " AND type=0";
			MerchantVoucherBean[] result = dao.getVoucherInfo(sql);
			request.setAttribute("result", result);
			request.setAttribute("pageAction", "owner");
			return mapping.findForward("goMerchantVoucherProvide");

		} else if (action.equals("consign")) {// 获取发放代发优惠券页面
			String opp = request.getParameter("opp");
			if (opp != null && opp.equals("ok")) {
				MerchantVoucherProvideForm mpForm = (MerchantVoucherProvideForm) form;
				try {
					dao.executeProvideVoucherProcedure(storeId
							+ mpForm.getCardId(), mpForm.getVoucherId(), mpForm
							.getAmount());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			String sql = "SELECT ID,name,amount,discount FROM merchantVoucher WHERE id IN"
					+ "( SELECT voucherID FROM bizGroupVoucher WHERE storeID="
					+ storeId + ")";
			MerchantVoucherBean[] result = dao.getVoucherInfo(sql);
			request.setAttribute("result", result);
			request.setAttribute("pageAction", "consign");
			return mapping.findForward("goMerchantVoucherProvide");
		}
		return null;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?