⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cstlostaction.java

📁 本系统基本完善了CRM管理系统的各个模块
💻 JAVA
字号:
package com.accp.struts.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

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

import net.sf.json.JSONSerializer;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.LazyDynaBean;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.accp.entity.jb_crm_team0.CstCustomer;
import com.accp.entity.jb_crm_team0.CstLost;
import com.accp.service.CstLostService;
import com.accp.service.CustomerService;
import com.accp.util.PageResult;

/**
 * MyEclipse Struts Creation date: 08-30-2008
 * 
 * XDoclet definition:
 * 
 * @struts.action path="/cstLost" name="cstLostForm" parameter="actionType"
 *                scope="request" validate="true"
 */
public class CstLostAction extends DispatchAction {
	SimpleDateFormat sf = new SimpleDateFormat("yyyy年MM月dd日");
	private CstLostService cstLostService = null;
	private CustomerService custService = null;

	public CustomerService getCustService() {
		return custService;
	}

	public void setCustService(CustomerService custService) {
		this.custService = custService;
	}

	public CstLostService getCstLostService() {
		return cstLostService;
	}

	public void setCstLostService(CstLostService cstLostService) {
		this.cstLostService = cstLostService;
	}

	// 如果没有传递actionType,默认执行这个方法
	protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		System.out.println("默认方法...");
		// 默认去入口
		PrintWriter out = response.getWriter();
		out.print("允许访问");
		return null;
	}

	public ActionForward doList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		System.out.println("查询客户流失信息");
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		LazyDynaBean ldb = new LazyDynaBean();
		BeanUtils.populate(ldb, request.getParameterMap());
		Map paramMap = ldb.getMap();
		PageResult pgr = cstLostService.findAll(paramMap);
		System.out.println("总共有" + pgr.getRowCount() + "个客户流失");
		String pgrStr = JSONSerializer.toJSON(pgr).toString();
		System.out.println(pgrStr);
		out.print(pgrStr);
		return null;
	}

	public ActionForward doDefLostorConfirmLost(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		String lstId = request.getParameter("lstId");
		try {
			CstLost cstLost = cstLostService.findByLstId(Long.parseLong(lstId));
			if ("defLost".equals(request.getParameter("type"))) {
				cstLost.setLstStatus("暂缓流失");
				cstLost.setLstDelay(cstLost.getLstDelay()
						+ request.getParameter("lstAddDelay"));
			} else {
				// 在流失表中把客户的状态改为“已经流失”,并加上流失原因和流失时间
				cstLost.setLstStatus("已经流失");
				cstLost.setLstLostDate(new Date());
				cstLost.setLstReason(request.getParameter("lstReason"));
				// 在客户信息表中把客户的状态改为“2”即已流失
				CstCustomer customer = custService.findByCustNo(cstLost
						.getCstCustomer().getCustNo());
				customer.setCustStatus("2");
				custService.update(customer);
			}
			cstLostService.update(cstLost);
			out.print("{success:true,msg:'操作成功'}");
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{success:false,msg:'系统异常,操作失败'}");
		}

		return null;
	}

}

⌨️ 快捷键说明

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