Package com.lgx8.management.serviceImpl

Source Code of com.lgx8.management.serviceImpl.RechargeRabateServiceImpl

package com.lgx8.management.serviceImpl;

import java.util.Date;

import com.lgx8.common.PageArgument;
import com.lgx8.common.PageList;
import com.lgx8.management.dao.IMerchantDao;
import com.lgx8.management.dao.IOrganizationDao;
import com.lgx8.management.dao.IRebateDao;
import com.lgx8.management.dao.IRebateRuleDao;
import com.lgx8.management.dao.IRechargehistoryDao;
import com.lgx8.management.entities.Merchant;
import com.lgx8.management.entities.Organization;
import com.lgx8.management.entities.Rebate;
import com.lgx8.management.entities.Rebaterule;
import com.lgx8.management.entities.Rechargehistory;
import com.lgx8.management.service.IRechargeRebateService;
import com.lgx8.right.entities.User;

public class RechargeRabateServiceImpl implements IRechargeRebateService {
  private IRechargehistoryDao rechargehistoryDao;
  private IRebateDao rebateDao;
  private IRebateRuleDao rebateRuleDao;
  private IOrganizationDao organizationDao;
  private IMerchantDao merchantDao;
 
  public IRebateDao getRebateDao() {
    return rebateDao;
  }

  public void setRebateDao(IRebateDao rebateDao) {
    this.rebateDao = rebateDao;
  }

  public IRebateRuleDao getRebateRuleDao() {
    return rebateRuleDao;
  }

  public void setRebateRuleDao(IRebateRuleDao rebateRuleDao) {
    this.rebateRuleDao = rebateRuleDao;
  }

  public IRechargehistoryDao getRechargehistoryDao() {
    return rechargehistoryDao;
  }

  public void setRechargehistoryDao(IRechargehistoryDao rechargehistoryDao) {
    this.rechargehistoryDao = rechargehistoryDao;
  }
 
  public IOrganizationDao getOrganizationDao() {
    return organizationDao;
  }

  public void setOrganizationDao(IOrganizationDao organizationDao) {
    this.organizationDao = organizationDao;
  }
 
  public IMerchantDao getMerchantDao() {
    return merchantDao;
  }

  public void setMerchantDao(IMerchantDao merchantDao) {
    this.merchantDao = merchantDao;
  }

  public Rechargehistory createCustmerXF(Merchant m, User user, double czje, double czjfs) {
    if(m!=null){
      Rebaterule re_rule = null;
      Organization _or = m.getOrganization();
      Rechargehistory recharge = new Rechargehistory();
      if(_or!=null){
        double flje = 0.0;
        if(_or.getJGLX().equals("2")){
          re_rule = rebateRuleDao.findRebateRuleByLx("01");
          double flqb = _or.getFlqb();
          if(re_rule!=null){
            flje = czjfs*re_rule.getFLLV();
            Rebate re = new Rebate();
            re.setFLED(flje);
            re.setFLSJ(new Date());
            re.setFLSYFBH(_or.getID());
            re.setFLLX("01");
            re.setRESERVATION01(m.getSJMC());
            re.setRESERVATION02(m.getID()+"");
            re.setRESERVATION03(_or.getJGMC());
            _or.setFlqb(flqb+flje);
            organizationDao.updateOrganization(_or);
            rebateDao.createRebate(re);
          }
        }
        if(_or.getJGLX().equals("3")){
          re_rule = rebateRuleDao.findRebateRuleByLx("02");
          double flqb = _or.getFlqb();
          if(re_rule!=null){
            flje = czjfs*re_rule.getFLLV();
            Rebate re = new Rebate();
            re.setFLED(flje);
            re.setFLSJ(new Date());
            re.setFLSYFBH(_or.getID());
            re.setFLLX("02");
            re.setRESERVATION01(m.getSJMC());
            re.setRESERVATION02(m.getID()+"");
            re.setRESERVATION03(_or.getJGMC());
            _or.setFlqb(flqb+flje);
            organizationDao.updateOrganization(_or);
            rebateDao.createRebate(re);
          }
        }
        if(_or.getJGLX().equals("4")){
          re_rule = rebateRuleDao.findRebateRuleByLx("03");
          double flqb = _or.getFlqb();
          if(re_rule!=null){
            flje = czjfs*re_rule.getFLLV();
            Rebate re = new Rebate();
            re.setFLED(flje);
            re.setFLSJ(new Date());
            re.setFLSYFBH(_or.getID());
            re.setFLLX("03");
            re.setRESERVATION01(m.getSJMC());
            re.setRESERVATION02(m.getID()+"");
            re.setRESERVATION03(_or.getJGMC());
            _or.setFlqb(flqb+flje);
            organizationDao.updateOrganization(_or);
            rebateDao.createRebate(re);
          }
        }
       
        Organization _por = _or.getSsjg();
        if(_por != null &&  _por.getJGLX().equals("5")){
          re_rule = rebateRuleDao.findRebateRuleByLx("04");
          double flqb = _por.getFlqb();
          if(re_rule!=null){
            flje = czjfs*re_rule.getFLLV();
            Rebate re = new Rebate();
            re.setFLED(flje);
            re.setFLSJ(new Date());
            re.setFLSYFBH(_por.getID());
            re.setFLLX("04");
            re.setRESERVATION01(m.getSJMC());
            re.setRESERVATION02(m.getID()+"");
            re.setRESERVATION03(_por.getJGMC());
            _por.setFlqb(flqb+flje);
            organizationDao.updateOrganization(_por);
            rebateDao.createRebate(re);
          }
        }
        recharge.setCZDHJFS(czjfs);
        recharge.setCZJE(czje);
        recharge.setCZQDR(null);
        recharge.setCZSJ(new Date());
        recharge.setMerchant(m);
        recharge.setCZYHBH(user);
        recharge.setCZYHLX("01");
        rechargehistoryDao.createRechargeHistory(recharge);
        double syjfs = m.getSYJFSL();
        m.setSYJFSL(syjfs+czjfs);
        merchantDao.updateMerchant(m);
      }
    }
    return null;
  }
 
  public void confirmRechargehistory(User u,Rechargehistory rh,String confirmLx){
    if(rh!=null&&rh.getCzzt()!=Rechargehistory.RECHARGEHISTORY_OVER){
      Merchant _m = rh.getMerchant();
      Organization _or = _m.getOrganization();
      if(confirmLx.equals("1")){
        rh.setCZQDR(u);
        rh.setCzqdrq(new Date());
        rh.setCzzt(Rechargehistory.RECHARGEHISTORY_OVER);
        double flje = 0.0;
        double czjfs=rh.getCZDHJFS();
        Rebaterule re_rule = null;
        if(_or != null&&!rh.getRESERVATION02().equals("02"))
        {
          if( _or.getJGLX().equals("2")){
            re_rule = rebateRuleDao.findRebateRuleByLx("01");
            double flqb = _or.getFlqb();
            if(re_rule!=null){
              flje = czjfs*re_rule.getFLLV();
              Rebate re = new Rebate();
              re.setFLED(flje);
              re.setFLSJ(new Date());
              re.setFLSYFBH(_or.getID());
              re.setFLLX("01");
              re.setRESERVATION01(_m.getSJMC());
              re.setRESERVATION02(_m.getID()+"");
              re.setRESERVATION03(_or.getJGMC());
              _or.setFlqb(flqb+flje);
              organizationDao.updateOrganization(_or);
              rebateDao.createRebate(re);
            }
          }
          if( _or.getJGLX().equals("3")){
            re_rule = rebateRuleDao.findRebateRuleByLx("02");
            double flqb = _or.getFlqb();
            if(re_rule!=null){
              flje = czjfs*re_rule.getFLLV();
              Rebate re = new Rebate();
              re.setFLED(flje);
              re.setFLSJ(new Date());
              re.setFLSYFBH(_or.getID());
              re.setFLLX("02");
              re.setRESERVATION01(_m.getSJMC());
              re.setRESERVATION02(_m.getID()+"");
              re.setRESERVATION03(_or.getJGMC());
              _or.setFlqb(flqb+flje);
              organizationDao.updateOrganization(_or);
              rebateDao.createRebate(re);
            }
          }
          if(_or.getJGLX().equals("4")){
            re_rule = rebateRuleDao.findRebateRuleByLx("03");
            double flqb = _or.getFlqb();
            if(re_rule!=null){
              flje = czjfs*re_rule.getFLLV();
              Rebate re = new Rebate();
              re.setFLED(flje);
              re.setFLSJ(new Date());
              re.setFLSYFBH(_or.getID());
              re.setFLLX("03");
              re.setRESERVATION01(_m.getSJMC());
              re.setRESERVATION02(_m.getID()+"");
              re.setRESERVATION03(_or.getJGMC());
              _or.setFlqb(flqb+flje);
              organizationDao.updateOrganization(_or);
              rebateDao.createRebate(re);
            }
          }
         
          Organization _por = _or.getSsjg();
          if(_por != null && _por.getJGLX().equals("5")){
            re_rule = rebateRuleDao.findRebateRuleByLx("04");
            double flqb = _por.getFlqb();
            if(re_rule!=null){
              flje = czjfs*re_rule.getFLLV();
              Rebate re = new Rebate();
              re.setFLED(flje);
              re.setFLSJ(new Date());
              re.setFLSYFBH(_por.getID());
              re.setFLLX("04");
              re.setRESERVATION01(_m.getSJMC());
              re.setRESERVATION02(_m.getID()+"");
              re.setRESERVATION03(_por.getJGMC());
              _por.setFlqb(flqb+flje);
              organizationDao.updateOrganization(_por);
              rebateDao.createRebate(re);
            }
          }
        }
        rechargehistoryDao.updateRechargeHistory(rh);
        double syjf = _m.getSYJFSL();
        _m.setSYJFSL(syjf+rh.getCZDHJFS());
        merchantDao.updateMerchant(_m);
      }else{
        rh.setDELETEFLAG("1");
        rechargehistoryDao.updateRechargeHistory(rh);
      }
    }
  }

  public void createRebateRule(Rebaterule rerule) {
    rebateRuleDao.createRebateRule(rerule);
  }

  public void createRebate(Rebate re) {
    rebateDao.createRebate(re);
  }

  public PageList getPageListRebateByConditions(String hql, Object[] objs, PageArgument pr) {
    return rebateDao.listRebateByConditions(hql, objs, pr);
  }

  public PageList getPageListRebateruleByConditions(String hql, Object[] objs, PageArgument pr) {
    return rebateRuleDao.listRebateRuleByConditions(hql, objs, pr);
  }

  public Rebate getRebate(long id) {
    return rebateDao.getRebateById(id);
  }

  public Rebaterule getRebateRule(long id) {
    return rebateRuleDao.findRebateRuleById(id);
  }

  public void updateRebate(Rebate re) {
    rebateDao.updateRebate(re);
  }

  public void updateRebateRule(Rebaterule rerule) {
    rebateRuleDao.updateRebateRule(rerule);
  }

  public void deleteRebate(Rebate re) {
    rebateDao.deleteRebate(re);
  }

  public void deleteRebateRule(Rebaterule rr) {
    rebateRuleDao.deleteRebateRule(rr);
  }

}
TOP

Related Classes of com.lgx8.management.serviceImpl.RechargeRabateServiceImpl

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.