Package com.lgx8.management.action

Source Code of com.lgx8.management.action.RechargeController

package com.lgx8.management.action;

import java.io.IOException;
import java.util.Date;
import java.util.List;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.lgx8.common.PageArgument;
import com.lgx8.common.PageList;
import com.lgx8.common.servlet.BaseController;
import com.lgx8.management.dao.IMerchantDao;
import com.lgx8.management.dao.IRechargehistoryDao;
import com.lgx8.management.entities.Merchant;
import com.lgx8.management.entities.RechargeHistoryCount;
import com.lgx8.management.entities.Rechargehistory;
import com.lgx8.management.service.IRechargeRebateService;
import com.lgx8.management.service.RechargeHistoryCountService;
import com.lgx8.right.entities.RunTimeUser;
import com.lgx8.right.entities.User;

@Controller
public class RechargeController extends BaseController {

  @Autowired
  IRechargehistoryDao rechargehistoryDao;
  @Autowired
  IMerchantDao merchantDao;
  @Autowired
  IRechargeRebateService rechargeRebateService;
  @Autowired
  RechargeHistoryCountService rechargeHistoryCountService;
 
  @RequestMapping("/recharge/initrecharge.do")
  public String initRechargePage(HttpServletRequest request,HttpServletResponse response){
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(rtUser!=null&&rtUser.getUsertype()==User.USER_TYPE_MERCHANT){
      long _mid = rtUser.getOrganizationid();
      Merchant _m = merchantDao.getMerchantById(_mid);
      request.setAttribute("merchant", _m);
    }
    return "/management/recharge/create_rechargehistory";
  }
 
  @RequestMapping("/recharge/initrechargeapply.do")
  public String initRechargePageApply(HttpServletRequest request,HttpServletResponse response){
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(rtUser!=null&&rtUser.getUsertype()==User.USER_TYPE_MERCHANT){
      long _mid = rtUser.getOrganizationid();
      Merchant _m = merchantDao.getMerchantById(_mid);
      request.setAttribute("merchant", _m);
    }
    return "/management/recharge/create_rechargeapply";
  }
 
  @RequestMapping("/recharge/listrechargehistory.do")
  public ModelAndView listRechargePage(HttpServletRequest request,HttpServletResponse response){
    String cz_st = request.getParameter("cz_st");
    String cz_ed = request.getParameter("cz_ed");
    String qr_st = request.getParameter("qr_st");
    String qr_ed = request.getParameter("qr_ed");
    StringBuffer sb = new StringBuffer();
    PageArgument pr = getPageInfo(request);
    if(cz_st!=null&&cz_st.length()!=0){
      sb.append(" and t1.CZSJ >= str_to_date('"+cz_st+"','%Y-%m-%d %H:%i:%s')");
    }
    if(cz_ed!=null&&cz_ed.length()!=0){
      sb.append(" and t1.CZSJ <= str_to_date('"+cz_ed+"','%Y-%m-%d %H:%i:%s')");
    }
    if(qr_st!=null&&qr_st.length()!=0){
      sb.append(" and t1.czqdrq >= str_to_date('"+qr_st+"','%Y-%m-%d %H:%i:%s')");
    }
    if(qr_ed!=null&&qr_ed.length()!=0){
      sb.append(" and t1.czqdrq <= str_to_date('"+qr_ed+"','%Y-%m-%d %H:%i:%s')");
    }
   
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(rtUser!=null&&rtUser.getUsertype()!=User.USER_TYPE_NORMAL){
      String hql = "";
      if(rtUser.getUsertype()==User.USER_TYPE_MERCHANT){
        sb.append(" and t1.merchant.id="+rtUser.getOrganizationid());
      }
      if(rtUser.getUsertype()==User.USER_TYPE_TGCENTER||rtUser.getUsertype()==User.USER_TYPE_YYCENTER){
        sb.append(" and t1.merchant.organization.id="+rtUser.getOrganizationid());
      }
     
      if(sb.toString()!=null&&!sb.toString().equals("")){
        hql = " from Rechargehistory t1 where "+sb.toString().substring(4)+" order by t1.CZSJ desc";
      }else{
        hql = " from Rechargehistory t1 order by t1.CZSJ desc";
      }
      PageList list = rechargehistoryDao.listRechargehistoryByConditions(hql, new Object[]{}, pr);
      printJSON(response, list.toJSON());
    }
    return null;
  }
 

  @RequestMapping("/recharge/listconfirmrechargehistory.do")
  public ModelAndView listConfirmRechargePage(HttpServletRequest request,HttpServletResponse response){
    String cz_st = request.getParameter("cz_st");
    String cz_ed = request.getParameter("cz_ed");
    String qr_st = request.getParameter("qr_st");
    String qr_ed = request.getParameter("qr_ed");
    String czzt = request.getParameter("czzt");
    StringBuffer sb = new StringBuffer();
    PageArgument pr = getPageInfo(request);
    if(cz_st!=null&&cz_st.length()!=0){
      sb.append(" and czsj >= str_to_date('"+cz_st+"','%Y-%m-%d %H:%i:%s')");
    }
    if(cz_ed!=null&&cz_ed.length()!=0){
      sb.append(" and czsj <= str_to_date('"+cz_ed+"','%Y-%m-%d %H:%i:%s')");
    }
    if(qr_st!=null&&qr_st.length()!=0){
      sb.append(" and czqdrq >= str_to_date('"+qr_st+"','%Y-%m-%d %H:%i:%s')");
    }
    if(qr_ed!=null&&qr_ed.length()!=0){
      sb.append(" and czqdrq <= str_to_date('"+qr_ed+"','%Y-%m-%d %H:%i:%s')");
    }
   
    if(czzt!=null&&czzt.length()!=0){
      sb.append(" and czzt="+czzt);
    }
   
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(rtUser!=null&&rtUser.getUsertype()==User.USER_TYPE_GSYG){
      String hql = "";
        hql = "from Rechargehistory where ifnull(deleteflag,'0')='0' "+sb.toString()+" order by czsj desc";
      PageList list = rechargehistoryDao.listRechargehistoryByConditions(hql, new Object[]{}, pr);
      printJSON(response, list.toJSON());
    }
    return null;
  }
 
  @RequestMapping("/recharge/saverechargehistory.do")
  public String saveRechargeHistory(HttpServletRequest request,HttpServletResponse response){
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    String czje = request.getParameter("czje");
    String czjf = "";
    String[] is_nore = request.getParameterValues("is_nore");
    if(rtUser!=null&&rtUser.getUsertype()==User.USER_TYPE_MERCHANT){
      long _mid = rtUser.getOrganizationid();
      Merchant _m = merchantDao.getMerchantById(_mid);
      Rechargehistory rechargeh = new Rechargehistory();
      rechargeh.setCZYHBH(rtUser);
      rechargeh.setCZSJ(new Date());
      rechargeh.setRESERVATION01(Rechargehistory.RECHARGEHISTORY_CZLX_SDCZ);
      rechargeh.setCzzt(Rechargehistory.RECHARGEHISTORY_INIT);
      rechargeh.setCZJE(Double.parseDouble(czje==null?"0":czje));
      if(is_nore!=null&&is_nore.length > 0){
        czjf = request.getParameter("czjf");
        rechargeh.setRESERVATION02("02");//设定为不返利
      }else{
        czjf = Double.parseDouble(czje==null?"0":czje)*10+"";
        rechargeh.setRESERVATION02("01");//设定为返利
      }
      rechargeh.setCZDHJFS(Double.parseDouble(czjf==null?"0":czjf));
      rechargeh.setCZYHLX("02");
      if(_m!=null){
        rechargeh.setMerchant(_m);
      }
      rechargehistoryDao.createRechargeHistory(rechargeh);
      request.setAttribute("rechargehistory", rechargeh);
    }
    return "/management/recharge/result_rechargehistory";
  }
 
  @RequestMapping("/recharge/confirmrechargehistory.do")
  public String confirmRechargeHistory(HttpServletRequest request,HttpServletResponse response){
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    String idString = request.getParameter("id");
    String confirmlx = request.getParameter("confirmType");
    long id = idString==null?0l:Long.parseLong(idString);
    if(rtUser!=null&&rtUser.getUsertype()==User.USER_TYPE_GSYG&&id!=0){
      Rechargehistory rh = rechargehistoryDao.findRechargehistoryById(id);
      rechargeRebateService.confirmRechargehistory(rtUser, rh, confirmlx);
      request.setAttribute("rechargehistory", rh);
      request.setAttribute("confirm", "true");
    }
    return "/management/recharge/result_rechargehistory";
  }
 
  @RequestMapping("/recharge/saverechargehistoryapply.do")
  public ModelAndView saveRechargeHistoryApply(HttpServletRequest request,HttpServletResponse response){
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    String czje = request.getParameter("czje");
    String czjf = "";
    String[] is_nore = request.getParameterValues("is_nore");
    if(rtUser!=null&&rtUser.getUsertype()==User.USER_TYPE_MERCHANT){
      Merchant _m = merchantDao.getMerchantById(rtUser.getOrganizationid());
      Rechargehistory rechargeh = new Rechargehistory();
      rechargeh.setCZYHBH(rtUser);
      rechargeh.setCZSJ(new Date());
      rechargeh.setCzzt(Rechargehistory.RECHARGEHISTORY_INIT);
      rechargeh.setCZJE(Double.parseDouble(czje==null?"0":czje));
      if(is_nore!=null&&is_nore.length > 0){
        czjf = request.getParameter("czjf");
        rechargeh.setRESERVATION02("02");
      }else{
        czjf = Double.parseDouble(czje==null?"0":czje)*10+"";
        rechargeh.setRESERVATION02("01");
      }
      rechargeh.setCZDHJFS(Double.parseDouble(czjf==null?"0":czjf));
      rechargeh.setRESERVATION01(Rechargehistory.RECHARGEHISTORY_CZLX_ZFBZ);
      rechargeh.setCZYHLX("02");
      if(_m!=null){
        rechargeh.setMerchant(_m);
      }
     
      rechargehistoryDao.createRechargeHistory(rechargeh);
      request.setAttribute("rechargehistory", rechargeh);
     
      try {
        request.getRequestDispatcher("/paymentmerchant.do").forward(request, response);
      } catch (ServletException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return null;
  }
 
  @RequestMapping("/rechargehistory/listcountrechargehistory.do")
  public String listCountRechargeHistory(HttpServletRequest request,HttpServletResponse response){
    String name = request.getParameter("name");
    String st_time = request.getParameter("st_time");
    String ed_time = request.getParameter("ed_time");
    String str_curPage = request.getParameter("curPage");
    int curPage = Integer.parseInt(str_curPage==null?"1":str_curPage);
    User user = RunTimeUser.getRunTimeUser(request);
    if(user.getUsertype()==User.USER_TYPE_MERCHANT){
      long m_id = user.getOrganizationid();
      if(m_id!=0){
        Merchant m = merchantDao.getMerchantById(m_id);
        name = m.getSJMC();
      }
    }
    List<RechargeHistoryCount> list = rechargeHistoryCountService.getRechargeHistoryCount(name, st_time, ed_time, curPage-1);
    int count = rechargeHistoryCountService.getRechargeHistoryCountPageCount(name, st_time, ed_time);
    request.setAttribute("list", list);
    request.setAttribute("curPage", str_curPage);
    request.setAttribute("name", name);
    request.setAttribute("st_time", st_time);
    request.setAttribute("ed_time", ed_time);
    request.setAttribute("count", count+"");
    return "/management/recharge/listcountrechargehistory";
  }
}
TOP

Related Classes of com.lgx8.management.action.RechargeController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.