package com.dhcc.finance.main.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dhcc.common.Shift;
import com.dhcc.common.constant.FinanceStatusCode;
import com.dhcc.common.constant.SysConstants;
import com.dhcc.common.constant.SysStatusCode;
import com.dhcc.common.model.CurrencyMeta;
import com.dhcc.common.model.SysUserInfo;
import com.dhcc.common.model.response.RestfulResponse;
import com.dhcc.common.util.CacheDataUtil;
import com.dhcc.common.util.SnowflakeIdWorker;
import com.dhcc.finance.constant.FinanceDictConsts;
import com.dhcc.finance.main.dao.CwBdGlorgbookMapper;
import com.dhcc.finance.main.dao.CwBdRecordBatchMapper;
import com.dhcc.finance.main.dao.CwBdRecordSerialMapper;
import com.dhcc.finance.main.dao.CwBdSubjschemeMapper;
import com.dhcc.finance.main.dao.CwGlTransferMapper;
import com.dhcc.finance.main.dao.CwGlVouchermaxnoMapper;
import com.dhcc.finance.main.dao.PmProjectChildMapper;
import com.dhcc.finance.main.domain.CwBdGlorgbook;
import com.dhcc.finance.main.domain.CwBdRecordBatch;
import com.dhcc.finance.main.domain.CwBdRecordGlorgbook;
import com.dhcc.finance.main.domain.CwBdRecordSerial;
import com.dhcc.finance.main.domain.CwBdSubjscheme;
import com.dhcc.finance.main.domain.CwGlTransfer;
import com.dhcc.finance.main.domain.CwGlVouchermaxno;
import com.dhcc.finance.main.model.FundsFlowInfo;
import com.dhcc.finance.main.model.ThirdPmProjectChild;
import com.dhcc.finance.main.model.VoucherRequestInfo;
import com.dhcc.finance.main.service.FinanceForThirdSupplyService;
import com.dhcc.finance.util.FinanceDateUtil;
import com.dhcc.finance.util.FinancePublicUtil;
import com.dhcc.finance.util.MetaDataUtil;

import brave.Tracer;
/**
 * 功能描述：财务对外接口（完善一些逻辑）
 * @author dml
 * @date 2019年7月18日 下午3:35:27
 * @修改日志：
 */
@Service
public class FinanceForThirdSupplyServiceImpl implements FinanceForThirdSupplyService{
	
	@Autowired
	private Tracer tracer;

	@Autowired
	private StringRedisTemplate stringRedisTemplate;
	
	@Autowired
	private CwBdGlorgbookMapper cwBdGlorgbookMapper; // 帐套管理表
	
	@Autowired
	CwBdSubjschemeMapper cwBdSubjschemeMapper;// 会计科目版本
	
	@Autowired
	CwGlTransferMapper cwGlTransferMapper;// 结转方案表
	
	@Autowired
	CwGlVouchermaxnoMapper cwGlVouchermaxnoMapper;// 最大凭证号
	
	@Autowired
	CwBdRecordSerialMapper cwBdRecordSerialMapper;// 自动记录批次流水信息表
	
	@Autowired
	CwBdRecordBatchMapper  cwBdRecordBatchMapper;// 自动记录批次信息表
	
	@Autowired
	PmProjectChildMapper  pmProjectChildMapper;// 子项目视图
	
	/*
	 * (非 Javadoc)  
	 * Title: createGlorgbookInfo 
	 * Description:生成账套信息
	 * @param thirdPmProjectChild
	 * @return  
	 * @see com.dhcc.finance.main.service.FinanceForThirdSupplyService#createGlorgbookInfo(com.dhcc.finance.main.model.ThirdPmProjectChild)    
	 * @author dml
	 * @date 2019年7月18日 下午3:40:18
	 * @修改日志：
	 */
	@Transactional(rollbackFor = Exception.class,propagation = Propagation.NESTED)
	@Override
	public RestfulResponse<Object, CurrencyMeta> createGlorgbookInfo(ThirdPmProjectChild thirdPmProjectChild) {
		SysUserInfo sysUserInfo = CacheDataUtil.<SysUserInfo>getCacheBean(stringRedisTemplate,
				SysConstants.REDIS_KEY_PREFIX.SYS_USER_INFO, SysUserInfo.class);
		
		// 业务数据非空校验
		String chackData = thirdPmProjectChild.chackData();
		if (chackData !=null) {
			return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.FAIL,
					chackData+SysStatusCode.SERVER_CHECK_ERROR.message(),
					MetaDataUtil.getMeta(tracer, SysStatusCode.SERVER_CHECK_ERROR));
		}
		// 判断该子项目是否已经建账
		long countByXtzxmbh = cwBdGlorgbookMapper.countByXtzxmbh(thirdPmProjectChild.getXtzxmbh());
		if (countByXtzxmbh>0) {   // 在此处判断是否已经建账套
			return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.FAIL,
					FinanceStatusCode.GLORGBOOK_EXISTING.message(),
					MetaDataUtil.getMeta(tracer, FinanceStatusCode.GLORGBOOK_EXISTING));
		}
		// 查询正启用的科目版本
		CwBdSubjscheme cwBdSubjscheme = cwBdSubjschemeMapper.selectByEnablestate();
		if (cwBdSubjscheme == null) {
			return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.FAIL,
					FinanceStatusCode.SUBJSCHEME_NOT_FOUND.message(),
					MetaDataUtil.getMeta(tracer, FinanceStatusCode.SUBJSCHEME_NOT_FOUND));
		}
		// 查询结转方案
		CwGlTransfer cwGlTransfer = cwGlTransferMapper.selectBypkSubjscheme(cwBdSubjscheme.getPkSubjscheme());
		if (cwGlTransfer == null) {
			return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.FAIL,
					FinanceStatusCode.TRANSFER_NOT_FOUND.message(),
					MetaDataUtil.getMeta(tracer, FinanceStatusCode.TRANSFER_NOT_FOUND));
		}
		// 获取当前时间的会计期间
		// 查询项目成立日期
		Date xmclr = null;
		xmclr = pmProjectChildMapper.selectXmclr(thirdPmProjectChild.getXtxmbh(), thirdPmProjectChild.getXtzxmbh());
		if (xmclr == null) {
			xmclr = new Date();
		}
		String period = FinanceDateUtil.getPeriod(xmclr);
		// 生成帐套信息
		
		CwBdGlorgbook cwBdGlorgbook = new CwBdGlorgbook();
		String pkGlorgbook = thirdPmProjectChild.getXtzxmbh();
		if (sysUserInfo != null) {
			cwBdGlorgbook.setCreateUser(sysUserInfo.getUserId());
		}
		cwBdGlorgbook.setPkGlorgbook(pkGlorgbook);
		cwBdGlorgbook.setXtxmbh(thirdPmProjectChild.getXtxmbh());
		cwBdGlorgbook.setXtzxmbh(thirdPmProjectChild.getXtzxmbh());
		//cwBdGlorgbook.setFqmjbh(thirdPrdFqmjInfo.getFqmjbh()); 该字段作废
		cwBdGlorgbook.setCode(thirdPmProjectChild.getXtzxmbh());
		cwBdGlorgbook.setName(thirdPmProjectChild.getXtzxmqc());
		cwBdGlorgbook.setPkAccperiod(period);
		cwBdGlorgbook.setPkCurrperiod(period);
		cwBdGlorgbook.setPkSubjscheme(cwBdSubjscheme.getPkSubjscheme());
		cwBdGlorgbook.setPkTransfer(cwGlTransfer.getPkTransfer());
		cwBdGlorgbook.setEnablestatte(FinanceDictConsts.Cwqyzt.YQY);
		cwBdGlorgbook.setUseState(FinanceDictConsts.Syzt.EFFECTIVE);
		cwBdGlorgbook.setCreateTime(new Date());
		cwBdGlorgbookMapper.insert(cwBdGlorgbook);
		// 初始化最大凭证号表
		// 所有的凭证类型
		List<CwGlVouchermaxno> cwGlVouchermaxnoList = new ArrayList<CwGlVouchermaxno>();
		// 组成新增数据
		CwGlVouchermaxno cwGlVouchermaxno = new CwGlVouchermaxno();
		if (sysUserInfo != null) {
			cwGlVouchermaxno.setCreateUser(sysUserInfo.getUserId());
		}
		cwGlVouchermaxno.setCreateTime(new Date());
		cwGlVouchermaxno.setUseState(FinanceDictConsts.Syzt.EFFECTIVE);
		cwGlVouchermaxno.setPkVouchermaxno(SnowflakeIdWorker.getInstance().nextIdString());
		cwGlVouchermaxno.setPkGlorgbook(pkGlorgbook);
		cwGlVouchermaxno.setPeriod(period);
		cwGlVouchermaxnoList.add(cwGlVouchermaxno);
		// 新增最大凭证信息（存在的不会在重复增加）
		cwGlVouchermaxnoMapper.insertCwGlVouchermaxnoBatch(cwGlVouchermaxnoList);
		
		return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.SUCCESS,
				SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS,
				MetaDataUtil.getMeta(tracer, SysStatusCode.OPERATION_SUCCESS));
	}
	/*
	 * (非 Javadoc)  
	 * <p>Title: insertRecordAccountForStart</p>  
	 * <p>Description: 新增记录流水记录表</p>
	 * @param fundsFlowInfoList
	 * @param voucherRequestInfo
	 * @param flowType
	 * @return  
	 * @see com.dhcc.finance.main.service.FinanceForThirdSupplyService#insertRecordAccountForStart(java.util.List, com.dhcc.finance.main.model.VoucherRequestInfo, java.lang.String)    
	 * @author huangpeng
	 * @date 2019年7月30日 下午4:00:12
	 * @修改日志：
	 */
	@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
	@Override
	public RestfulResponse<List<String>, CurrencyMeta> insertRecordAccountForStart(List<FundsFlowInfo> fundsFlowInfoList,
			VoucherRequestInfo voucherRequestInfo, String flowType, Map<String, String> cacheMap) {
		CwBdRecordBatch cwBdRecordBatch = new CwBdRecordBatch();//批次号记录实体
		cwBdRecordBatch.setBatchNo(voucherRequestInfo.getBatchNo());
		cwBdRecordBatch.setTradecode(voucherRequestInfo.getTradeCode());
		cwBdRecordBatch.setProjectCode((String)FinancePublicUtil.getMethodValueNoexc(fundsFlowInfoList.get(0), cacheMap.get(flowType+"xtzxmbh")));
		String hskjbh=(String)FinancePublicUtil.getMethodValueNoexc(fundsFlowInfoList.get(0), cacheMap.get(flowType+"lrry"));
		cwBdRecordBatch.setInitiateUse(hskjbh);
		cwBdRecordBatch.setUpdateTime(new Date());
		cwBdRecordBatchMapper.updateRecordBybatchNo(cwBdRecordBatch);//更新批次号记录信息
		
		
		List<String> pklist =new ArrayList<String>();//流水list
		for (FundsFlowInfo fundsFlowInfo : fundsFlowInfoList) {
			String serialNo=(String)FinancePublicUtil.getMethodValueNoexc(fundsFlowInfo, cacheMap.get(flowType+"flowNo"));
			pklist.add(serialNo);
		}
		List<CwBdRecordSerial> searchIsSignBySerial = cwBdRecordSerialMapper.searchIsSignBySerial(pklist);//查询流水号是否记账
		if(searchIsSignBySerial.size()>0) {
			for (CwBdRecordSerial cwBdRecordSerial : searchIsSignBySerial) {
				if(FinanceDictConsts.SF.yes.equals(cwBdRecordSerial.getSignType())) {
					return new RestfulResponse<List<String>, CurrencyMeta>(SysConstants.CODE.FAIL,FinanceStatusCode.SERIAL_ISNOT_REPEAT.message(),null,
							MetaDataUtil.getMeta(tracer, FinanceStatusCode.SERIAL_ISNOT_REPEAT));
				}
			}
		}
		List<String> pkSerialNo=cwBdRecordSerialMapper.selectPKSerialNo(voucherRequestInfo.getBatchNo(),voucherRequestInfo.getTradeCode());
		if(pkSerialNo.size()==0) {//新流水记录
			List<CwBdRecordSerial> arrayList = new ArrayList<CwBdRecordSerial>();//流水号记录表集合
			for (String serialNo : pklist) {
				CwBdRecordSerial cwBdRecordSerial = new CwBdRecordSerial();//流水号记录实体
				cwBdRecordSerial.setBatchNo(voucherRequestInfo.getBatchNo());
				cwBdRecordSerial.setTradecode(voucherRequestInfo.getTradeCode());
				cwBdRecordSerial.setCreateTime(new Date());
				cwBdRecordSerial.setCreateUser(hskjbh);
				cwBdRecordSerial.setId(SnowflakeIdWorker.getInstance().nextIdString());
				cwBdRecordSerial.setIsaudit(FinanceDictConsts.SF.no);
				cwBdRecordSerial.setIssign(FinanceDictConsts.SF.no);
				//String serialNo=(String)FinancePublicUtil.getMethodValueNoexc(fundsFlowInfo, cacheMap.get(flowType+"flowNo"));
				cwBdRecordSerial.setSerialNo(serialNo);//募集流水编号
				cwBdRecordSerial.setSignType(FinanceDictConsts.STATE.generate);
				cwBdRecordSerial.setUseState(FinanceDictConsts.Syzt.EFFECTIVE);
				arrayList.add(cwBdRecordSerial);
				//pklist.add(serialNo);
			}
			cwBdRecordSerialMapper.insertForBatch(arrayList);//自动生成凭证流水号记录表
		}else {//不是新记录
			pklist=pkSerialNo;
		}
		
		return new RestfulResponse<List<String>, CurrencyMeta>(SysConstants.CODE.SUCCESS,SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS,pklist,
				MetaDataUtil.getMeta(tracer,SysStatusCode.OPERATION_SUCCESS));
	}

	/*
	 * (非 Javadoc)  
	 * <p>Title: insertRecordForBatch</p>  
	 * <p>Description: 批次号插入</p>
	 * @param voucherRequestInfo
	 * @return  
	 * @see com.dhcc.finance.main.service.FinanceForThirdSupplyService#insertRecordForBatch(com.dhcc.finance.main.model.VoucherRequestInfo)    
	 * @author huangpeng
	 * @date 2019年8月20日 下午12:00:08
	 * @修改日志：
	 */
	@Override
	public RestfulResponse<Object, CurrencyMeta> insertRecordForBatch(VoucherRequestInfo voucherRequestInfo) {		
		List<CwBdRecordBatch> list=
				cwBdRecordBatchMapper.searchBatchIsExistOfCount(voucherRequestInfo.getBatchNo(),voucherRequestInfo.getTradeCode());
		if(list.size()==0) {
			//插入
			CwBdRecordBatch cwBdRecordBatch = new CwBdRecordBatch();//批次号记录实体
			String batchNo= SnowflakeIdWorker.getInstance().nextIdString();//第二种、第三种情况情况
			cwBdRecordBatch.setId(SnowflakeIdWorker.getInstance().nextIdString());
			if("1".equals(voucherRequestInfo.getParamType())) {
				cwBdRecordBatch.setBatchNo(voucherRequestInfo.getBatchNo());
			}else {
				cwBdRecordBatch.setBatchNo(batchNo);
				voucherRequestInfo.setBatchNo(batchNo);
			}	
			if (voucherRequestInfo.getPreparedate() !=null) {
				cwBdRecordBatch.setPreparedate(voucherRequestInfo.getPreparedate());
			}
			cwBdRecordBatch.setTradecode(voucherRequestInfo.getTradeCode());//交易码
			cwBdRecordBatch.setSignType(FinanceDictConsts.STATE.generate);//生成中
			cwBdRecordBatch.setInitiateTime(new Date());
			cwBdRecordBatch.setUseState(FinanceDictConsts.Syzt.EFFECTIVE);
			cwBdRecordBatch.setCreateTime(new Date());
			cwBdRecordBatchMapper.insert(cwBdRecordBatch);//自动生成凭证批次号记录表
		}else {
			for (CwBdRecordBatch cwBdRecordBatch : list) {
				if(FinanceDictConsts.SF.yes.equals(cwBdRecordBatch.getSignType())) {
					return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.FAIL,FinanceStatusCode.BATCHNO_HASBEEN_ACCOUNT.message(),
							MetaDataUtil.getMeta(tracer, FinanceStatusCode.BATCHNO_HASBEEN_ACCOUNT));
				}
			}
		}
		return new RestfulResponse<Object, CurrencyMeta>(SysConstants.CODE.SUCCESS,SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS,
				MetaDataUtil.getMeta(tracer,SysStatusCode.OPERATION_SUCCESS));	
	}
	/*
	 * (非 Javadoc)  
	 * Title: createGlorgbookInfoBatch 
	 * Description:批量建账
	 * @param thirdPmProjectChildList
	 * @return  
	 * @see com.dhcc.finance.main.service.FinanceForThirdSupplyService#createGlorgbookInfoBatch(java.util.List)    
	 * @author dml
	 * @date 2020年3月9日 下午4:06:52
	 * @修改日志：
	 */
	@Transactional(rollbackFor = Exception.class,propagation = Propagation.NESTED)
	@Override
	public RestfulResponse<List<CwBdRecordGlorgbook>, CurrencyMeta> createGlorgbookInfoBatch(List<CwBdRecordGlorgbook> cwBdRecordGlorgbookList) {
		SysUserInfo sysUserInfo = CacheDataUtil.<SysUserInfo>getCacheBean(stringRedisTemplate,
				SysConstants.REDIS_KEY_PREFIX.SYS_USER_INFO, SysUserInfo.class);
		// 查询正启用的科目版本
		CwBdSubjscheme cwBdSubjscheme = cwBdSubjschemeMapper.selectByEnablestate();
		if (cwBdSubjscheme == null) {
			for (CwBdRecordGlorgbook cwBdRecordGlorgbook : cwBdRecordGlorgbookList) {
				cwBdRecordGlorgbook.setFailReason(FinanceStatusCode.SUBJSCHEME_NOT_FOUND.message());
			}
			return new RestfulResponse<List<CwBdRecordGlorgbook>, CurrencyMeta>(SysConstants.CODE.SUCCESS,
					FinanceStatusCode.SUBJSCHEME_NOT_FOUND.message(),cwBdRecordGlorgbookList,
					MetaDataUtil.getMeta(tracer, FinanceStatusCode.SUBJSCHEME_NOT_FOUND));
		}
		// 查询结转方案
		CwGlTransfer cwGlTransfer = cwGlTransferMapper.selectBypkSubjscheme(cwBdSubjscheme.getPkSubjscheme());
		if (cwGlTransfer == null) {
			for (CwBdRecordGlorgbook cwBdRecordGlorgbook : cwBdRecordGlorgbookList) {
				cwBdRecordGlorgbook.setFailReason(FinanceStatusCode.TRANSFER_NOT_FOUND.message());
			}
			return new RestfulResponse<List<CwBdRecordGlorgbook>, CurrencyMeta>(SysConstants.CODE.SUCCESS,
					FinanceStatusCode.TRANSFER_NOT_FOUND.message(),cwBdRecordGlorgbookList,
					MetaDataUtil.getMeta(tracer, FinanceStatusCode.TRANSFER_NOT_FOUND));
		}

		List<CwBdRecordGlorgbook> pass = new ArrayList<CwBdRecordGlorgbook>();// 校验通过
		List<CwBdRecordGlorgbook> noPass = new ArrayList<CwBdRecordGlorgbook>();// 校验不通过
		// 查询是否已经记账
		List<CwBdGlorgbook> selectByXtzxmbhBatch = cwBdGlorgbookMapper.selectByXtzxmbhBatch(cwBdRecordGlorgbookList);
		// 业务数据非空校验
		for (CwBdRecordGlorgbook cwBdRecordGlorgbook : cwBdRecordGlorgbookList) {
			String chackData = cwBdRecordGlorgbook.chackData();
			if (chackData !=null) {
				cwBdRecordGlorgbook.setFailReason(chackData);
				noPass.add(cwBdRecordGlorgbook);
			} else {
				boolean flag = true;
				if (selectByXtzxmbhBatch.size()>0) {
					for (CwBdGlorgbook cwBdGlorgbook : selectByXtzxmbhBatch) {
						if (cwBdGlorgbook.getXtzxmbh().equals(cwBdRecordGlorgbook.getProjectCode())) {
							cwBdRecordGlorgbook.setFailReason(FinanceStatusCode.GLORGBOOK_EXISTING.message());
							noPass.add(cwBdRecordGlorgbook);
							flag = false;
							break;
						}
					}
				}
				if (flag) {
					pass.add(cwBdRecordGlorgbook);
				}
			}
		}
		
		if (pass.size()>0) {
			// 默认当前日期为项目成立日
			Date xmclr = new Date();
			String period = FinanceDateUtil.getPeriod(xmclr);
			List<CwBdGlorgbook> cwBdGlorgbookList = new ArrayList<CwBdGlorgbook>();// 账套信息
			List<CwGlVouchermaxno> cwGlVouchermaxnoList = new ArrayList<CwGlVouchermaxno>();// 最大凭证号信息
			for (CwBdRecordGlorgbook cwBdRecordGlorgbook : pass) {
				// 生成帐套信息
				CwBdGlorgbook cwBdGlorgbook = new CwBdGlorgbook();
				if (sysUserInfo != null) {
					cwBdGlorgbook.setCreateUser(sysUserInfo.getUserId());
				}
				cwBdGlorgbook.setPkGlorgbook(cwBdRecordGlorgbook.getProjectCode());
				cwBdGlorgbook.setXtxmbh(cwBdRecordGlorgbook.getXtxmbh());
				cwBdGlorgbook.setXtzxmbh(cwBdRecordGlorgbook.getProjectCode());
				cwBdGlorgbook.setCode(cwBdRecordGlorgbook.getProjectCode());
				cwBdGlorgbook.setName(cwBdRecordGlorgbook.getProjectName());
				cwBdGlorgbook.setPkAccperiod(period);
				cwBdGlorgbook.setPkCurrperiod(period);
				cwBdGlorgbook.setPkSubjscheme(cwBdSubjscheme.getPkSubjscheme());
				cwBdGlorgbook.setPkTransfer(cwGlTransfer.getPkTransfer());
				cwBdGlorgbook.setEnablestatte(FinanceDictConsts.Cwqyzt.YQY);
				cwBdGlorgbook.setUseState(FinanceDictConsts.Syzt.EFFECTIVE);
				cwBdGlorgbook.setCreateTime(new Date());
				cwBdGlorgbookList.add(cwBdGlorgbook);
				// 组成最大凭证号数据
				CwGlVouchermaxno cwGlVouchermaxno = new CwGlVouchermaxno();
				if (sysUserInfo != null) {
					cwGlVouchermaxno.setCreateUser(sysUserInfo.getUserId());
				}
				cwGlVouchermaxno.setCreateTime(new Date());
				cwGlVouchermaxno.setUseState(FinanceDictConsts.Syzt.EFFECTIVE);
				cwGlVouchermaxno.setPkVouchermaxno(SnowflakeIdWorker.getInstance().nextIdString());
				cwGlVouchermaxno.setPkGlorgbook(cwBdRecordGlorgbook.getProjectCode());
				cwGlVouchermaxno.setPeriod(period);
				cwGlVouchermaxnoList.add(cwGlVouchermaxno);
			}
			int res1 = cwBdGlorgbookMapper.insertCwBdGlorgbookBatch(cwBdGlorgbookList);
			// 新增最大凭证信息（存在的不会在重复增加）
			int res2 = cwGlVouchermaxnoMapper.insertCwGlVouchermaxnoBatch(cwGlVouchermaxnoList);
			if (res1*res2>0) {
				return new RestfulResponse<List<CwBdRecordGlorgbook>, CurrencyMeta>(SysConstants.CODE.SUCCESS,
						SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS,cwBdRecordGlorgbookList,
						MetaDataUtil.getMeta(tracer, SysStatusCode.OPERATION_SUCCESS));
			} else {
				Shift.fatalThrow(SysStatusCode.OPERATION_FAIL);
			}
		} else {
			return new RestfulResponse<List<CwBdRecordGlorgbook>, CurrencyMeta>(SysConstants.CODE.SUCCESS,
					SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS,cwBdRecordGlorgbookList,
					MetaDataUtil.getMeta(tracer, SysStatusCode.OPERATION_SUCCESS));
		}
		return new RestfulResponse<List<CwBdRecordGlorgbook>, CurrencyMeta>(SysConstants.CODE.SUCCESS,
				SysConstants.DEFAULT_MESSAGE.OPERATION_SUCCESS,cwBdRecordGlorgbookList,
				MetaDataUtil.getMeta(tracer, SysStatusCode.OPERATION_SUCCESS));
	}

}
