Package com.lgx8.management.action

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

package com.lgx8.management.action;

import java.util.Date;

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.IChargeIndexDao;
import com.lgx8.management.dao.IMerchantDao;
import com.lgx8.management.dao.IOrganizationDao;
import com.lgx8.management.entities.ChargeIndex;
import com.lgx8.management.entities.Merchant;
import com.lgx8.management.entities.Organization;
import com.lgx8.management.entities.Rebaterule;
import com.lgx8.management.service.IRechargeRebateService;
import com.lgx8.right.entities.RunTimeUser;
import com.lgx8.right.entities.User;

@Controller
public class RebateController extends BaseController {
 
  @Autowired
  IRechargeRebateService rechargeRebateService;
  @Autowired
  IMerchantDao merchantDao;
  @Autowired
  IOrganizationDao organizationDao;
  @Autowired
  IChargeIndexDao chargeIndexDao;
 
  @RequestMapping("/rebate/list_rebaterule.do")
  public ModelAndView listRebateRule(HttpServletRequest request,HttpServletResponse response){
    String tj_st = request.getParameter("tj_st");
    String tj_ed = request.getParameter("tj_ed");
    String fllx = request.getParameter("fllx");
    StringBuffer sb = new StringBuffer();
    PageArgument pr = getPageInfo(request);
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(tj_st!=null&&!tj_st.equals("")){
      sb.append(" and createdtime>=str_to_date('"+tj_st+"','%Y-%m-%d %H:%i:%s')");
    }
    if(tj_ed!=null&&!tj_ed.equals("")){
      sb.append(" and createdtime<=str_to_date('"+tj_ed+"','%Y-%m-%d %H:%i:%s')");
    }
    if(fllx!=null&&!fllx.equals("")){
      sb.append(" and fllx='"+fllx+"'");
    }
    if(rtUser!=null){
      String hql = " from Rebaterule where ifnull(deleteflag,'0')='0' "+sb.toString()+" order by createdtime desc";
      Object[] o = new Object[]{};
      PageList list = rechargeRebateService.getPageListRebateruleByConditions(hql, o, pr);
      printJSON(response, list.toJSON());
    }
    return null;
  }
 
  @RequestMapping("/rebate/modifyrebateruleinit.do")
  public ModelAndView modifyRebateruleInit(HttpServletRequest request,HttpServletResponse response){
    String re_id = request.getParameter("rrid");
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(re_id!=null&&re_id.length()>0){
      if(rtUser.getUsertype()==User.USER_TYPE_GSYG){
        Rebaterule rr = rechargeRebateService.getRebateRule(Long.parseLong(re_id));
        request.setAttribute("rebaterule", rr);
        return  new ModelAndView("/management/rebate/create_rebaterule");
      }else{
        return new ModelAndView("/management/rebate/list_rebaterule");
      }
    }
    return null;
  }
 
  @RequestMapping("/rebate/deleterebaterule.do")
  public ModelAndView deleteRebateruleInit(HttpServletRequest request,HttpServletResponse response){
    String re_id = request.getParameter("rrid");
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(re_id!=null&&re_id.length()>0){
      if(rtUser.getUsertype()==User.USER_TYPE_GSYG){
        Rebaterule rr = rechargeRebateService.getRebateRule(Long.parseLong(re_id));
        rechargeRebateService.deleteRebateRule(rr);
      }
    }
    return new ModelAndView("/management/rebate/list_rebaterule");
  }
 
  @RequestMapping("/rebate/saverebate.do")
  public String saveRebateRule(HttpServletRequest request,HttpServletResponse response){
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    String fllv = request.getParameter("fllv");
    String fllx = request.getParameter("fllx");
    String flzt = request.getParameter("flzt");
    String flid = request.getParameter("rrid");
    Rebaterule rr = null;
    if(rtUser.getUsertype()==User.USER_TYPE_GSYG){
      if(flid!=null&&flid.length()>0&&!flid.equals("0")){
        long id = Long.parseLong(flid);
        rr = rechargeRebateService.getRebateRule(id);
        rr.setDELETEFLAG(flzt);
        rr.setFLLX(fllx);
        rr.setCREATOR(rtUser);
        rr.setFLLV(Double.parseDouble(fllv==null?"0.0":fllv));
        rechargeRebateService.updateRebateRule(rr);
      }else{
        rr = new Rebaterule();
        rr.setCREATEDTIME(new Date());
        rr.setDELETEFLAG(flzt);
        rr.setFLLX(fllx);
        rr.setCREATOR(rtUser);
        rr.setFLLV(Double.parseDouble(fllv==null?"0.0":fllv));
        rechargeRebateService.createRebateRule(rr);
      }
    }
    request.setAttribute("rebaterule", rr);
    return "/management/rebate/result_rebaterule";
  }
 
  @RequestMapping("/rebate/list_rebate.do")
  public ModelAndView listRebate(HttpServletRequest request,HttpServletResponse response){
    String tj_st = request.getParameter("fl_st");
    String tj_ed = request.getParameter("fl_ed");
    StringBuffer sb = new StringBuffer();
    PageArgument pr = getPageInfo(request);
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(tj_st!=null&&!tj_st.equals("")){
      sb.append(" and flsj>=str_to_date('"+tj_st+"','%Y-%m-%d %H:%i:%s')");
    }
    if(tj_ed!=null&&!tj_ed.equals("")){
      sb.append(" and flsj<=str_to_date('"+tj_ed+"','%Y-%m-%d %H:%i:%s')");
    }
   
    if(rtUser!=null&&rtUser.getUsertype()!=0&&rtUser.getUsertype()!=User.USER_TYPE_NORMAL){
      if(rtUser.getUsertype()!=User.USER_TYPE_GSYG){
        sb.append(" and flsyfbh="+rtUser.getOrganizationid());
      }
      String hql = "";
      if(sb.toString()!=null&&!sb.toString().equals("")){
         hql = " from Rebate where "+sb.toString().substring(4)+" order by flsj desc";
      }else{
        hql = " from Rebate order by flsj desc";
      }
      Object[] o = new Object[]{};
      PageList list = rechargeRebateService.getPageListRebateByConditions(hql, o, pr);
      printJSON(response, list.toJSON());
    }
    return null;
  }
 
  @RequestMapping("/rebate/list_chargeconfirmindex.do")
  public ModelAndView listConfirmChargeIndex(HttpServletRequest request,HttpServletResponse response){
    String tj_st = request.getParameter("qbtj_st");
    String tj_ed = request.getParameter("qbtj_ed");
    String hd_lx = request.getParameter("qblx");
    StringBuffer sb = new StringBuffer();
    PageArgument pr = getPageInfo(request);
    if(tj_st!=null&&tj_st.length()!=0){
      sb.append(" and dhtjrq>=str_to_date('"+tj_st+"','%Y-%m-%d %H:%i:%s')");
    }
    if(tj_ed!=null&&tj_ed.length()!=0){
      sb.append(" and dhtjrq<=str_to_date('"+tj_ed+"','%Y-%m-%d %H:%i:%s')");
    }
   
    if(hd_lx!=null&&hd_lx.length()!=0&&!hd_lx.equals("")){
      sb.append(" and dhlx='"+hd_lx+"'");
    }
   
    sb.append(" and dhzt='0'");
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
   
    if(rtUser!=null&&rtUser.getUsertype()==User.USER_TYPE_GSYG){
      String hql = "from ChargeIndex where ifnull(deleteflag,'0')='0' "+sb.toString()+" order by dhtjrq desc";
      PageList list = rechargeRebateService.getPageListRebateByConditions(hql, new Object[]{}, pr);
      printJSON(response, list.toJSON());
    }
    return null;
  }
 
  @RequestMapping("/rebate/list_chargeindex.do")
  public ModelAndView listChargeIndex(HttpServletRequest request,HttpServletResponse response){
    String tj_st = request.getParameter("qbtj_st");
    String tj_ed = request.getParameter("qbtj_ed");
    String qr_st = request.getParameter("qbqr_st");
    String qr_ed = request.getParameter("qbqr_ed");
    String hd_lx = request.getParameter("qblx");
    String hd_zt = request.getParameter("qbzt");
    StringBuffer sb = new StringBuffer();
    PageArgument pr = getPageInfo(request);
    if(tj_st!=null&&tj_st.length()!=0){
      sb.append(" and dhtjrq>=str_to_date('"+tj_st+"','%Y-%m-%d %H:%i:%s')");
    }
    if(tj_ed!=null&&tj_ed.length()!=0){
      sb.append(" and dhtjrq<=str_to_date('"+tj_ed+"','%Y-%m-%d %H:%i:%s')");
    }
   
    if(qr_st!=null&&qr_st.length()!=0){
      sb.append(" and dhqrq>=str_to_date('"+qr_st+"','%Y-%m-%d %H:%i:%s')");
    }
   
    if(qr_ed!=null&&qr_ed.length()!=0){
      sb.append(" and dhqrq<=str_to_date('"+qr_ed+"','%Y-%m-%d %H:%i:%s')");
    }
   
    if(hd_lx!=null&&hd_lx.length()!=0&&!hd_lx.equals("")){
      sb.append(" and dhlx='"+hd_lx+"'");
    }
   
    if(hd_zt!=null&&hd_zt.length()!=0&&!hd_zt.equals("")){
      sb.append(" and dhzt='"+hd_zt+"'");
    }
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
   
    if(rtUser!=null&&rtUser.getUsertype()!=User.USER_TYPE_NORMAL){
      String hql = "";
      if(rtUser.getUsertype()==User.USER_TYPE_MERCHANT){
        long _mid = rtUser.getOrganizationid();
        hql = "from ChargeIndex where ifnull(deleteflag,'0')='0' and merchantid="+_mid+sb.toString()+" order by dhtjrq desc";
      }else if(rtUser.getUsertype()!=User.USER_TYPE_GSYG&&rtUser.getUsertype()!=User.USER_TYPE_MERCHANT){
        long _orid = rtUser.getOrganizationid();
        hql = "from ChargeIndex where ifnull(deleteflag,'0')='0' and dhorid="+_orid+sb.toString()+" order by dhtjrq desc";
      }else{
        hql = "from ChargeIndex where ifnull(deleteflag,'0')='0' "+sb.toString()+" order by dhtjrq desc";
      }
      PageList list = rechargeRebateService.getPageListRebateByConditions(hql, new Object[]{}, pr);
      printJSON(response, list.toJSON());
    }
    return null;
  }
 
  @RequestMapping("/rebate/hdtjinit.do")
  public String hdtjInitPage(HttpServletRequest request,HttpServletResponse response){
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    if(rtUser!=null&&rtUser.getUsertype()!=User.USER_TYPE_GSYG&&rtUser.getUsertype()!=User.USER_TYPE_NORMAL){
      if(rtUser.getUsertype()==User.USER_TYPE_MERCHANT){
        Merchant _m = merchantDao.getMerchantById(rtUser.getOrganizationid());
        request.setAttribute("merchant", _m);
      }else{
        Organization _or = organizationDao.getOrganizationById(rtUser.getOrganizationid());
        request.setAttribute("organization", _or);
      }
    }
    return "/management/rebate/create_hdqb";
  }
 
  @RequestMapping("/rebate/hdtjsave.do")
  public String hdtjSavePage(HttpServletRequest request,HttpServletResponse response){
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    String dhjf = request.getParameter("dhqb");
    String dhfs = request.getParameter("dhfs");
    ChargeIndex ci = null;
    if(rtUser!=null&&rtUser.getUsertype()!=User.USER_TYPE_GSYG&&rtUser.getUsertype()!=User.USER_TYPE_NORMAL){
      ci = new ChargeIndex();
      ci.setDhfs(dhfs);
      ci.setDhtjr(rtUser);
      ci.setDhtjrq(new Date());
      ci.setDhjfs(Double.parseDouble(dhjf));
      ci.setDhzt(ChargeIndex.CHARGEINDEX_DHZT_INIT);
      if(rtUser.getUsertype()==User.USER_TYPE_MERCHANT){
        Merchant _m = merchantDao.getMerchantById(rtUser.getOrganizationid());
        ci.setDhlx(ChargeIndex.CHARGEINDEX_DHLX_MERCHANT);
        ci.setMerchantId(_m);
        double qbsl = _m.getFlqb();
        _m.setFlqb(qbsl-Double.parseDouble(dhjf));
        merchantDao.updateMerchant(_m);
      }else{
        Organization _or = organizationDao.getOrganizationById(rtUser.getOrganizationid());
        if(_or.getJGLX().equals("3")){
          ci.setDhlx(ChargeIndex.CHARGEINDEX_DHLX_TGZ);
        }
        if(_or.getJGLX().equals("4")){
          ci.setDhlx(ChargeIndex.CHARGEINDEX_DHLX_TGCENTER);
        }
        if(_or.getJGLX().equals("5")){
          ci.setDhlx(ChargeIndex.CHARGEINDEX_DHLX_YYCENTER);
        }
        ci.setDhorid(_or);
        double qbsl = _or.getFlqb();
        _or.setFlqb(qbsl-Double.parseDouble(dhjf));
        organizationDao.updateOrganization(_or);
      }
      chargeIndexDao.createChargeIndex(ci);
    }
    request.setAttribute("chargeindex", ci);
    return "/management/rebate/result_hdqb";
  }
 
  @RequestMapping("/rebate/confirmchargeindex.do")
  public String confirmChargeIndex(HttpServletRequest request,HttpServletResponse response){
    String sysid = request.getParameter("id");
    String confirm = request.getParameter("confirm");
    long id = sysid==null?0l:Long.parseLong(sysid);
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
    ChargeIndex ci = null;
    if(rtUser!=null&&rtUser.getUsertype()==User.USER_TYPE_GSYG&&id!=0){
      ci = chargeIndexDao.getChargeIndex(id);
      if(ci!=null){
        String lx = ci.getDhlx();
        if(lx.equals(ChargeIndex.CHARGEINDEX_DHLX_MERCHANT)){
          Merchant _m = ci.getMerchantId();
          if(confirm.equals("0")){
            double flqb = _m.getFlqb();
            _m.setFlqb(flqb+ci.getDhjfs());
            ci.setDeleteflag("1");
          }else{
            if(ci.getDhfs().equals(ChargeIndex.CHARGEINDEX_DHFS_HANDLERJF)){
              double syjf = _m.getSYJFSL();
              _m.setSYJFSL(syjf+ci.getDhjfs());
              //ci.setHdjes(ci.getDhjfs());
            }
            ci.setDhjes(ci.getDhjfs());
          }
          merchantDao.updateMerchant(_m);
        }else{
          Organization _or = ci.getDhorid();
          if(confirm.equals("0")){
            double flqb = _or.getFlqb();
            _or.setFlqb(flqb+ci.getDhjfs());
            ci.setDeleteflag("1");
          }else{
            ci.setDhjes(ci.getDhjfs());
          }
          organizationDao.updateOrganization(_or);
        }
        ci.setDhqrr(rtUser);
        ci.setDhqrq(new Date());
        ci.setDhzt(ChargeIndex.CHARGEINDEX_DHZT_OVER);
        chargeIndexDao.updateChargeIndex(ci);
      }
     
    }
    request.setAttribute("chargeindex", ci);
    return "/management/rebate/result_confirmchargeindex";
  }
}
TOP

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

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.