package com.ssm.manage.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Maps;
import com.ssm.core.service.impl.BaseServiceImpl;
import com.ssm.core.utils.BigDecimalUtils;
import com.ssm.core.utils.SnowflakeUtil;
import com.ssm.core.utils.StoreParaUtils;
import com.ssm.manage.dao.SsmCashDao;
import com.ssm.manage.entity.*;
import com.ssm.manage.extendEntity.AchiCommEntity;
import com.ssm.manage.extendEntity.StaffProgress;
import com.ssm.manage.extendEntity.StoreDaily;
import com.ssm.manage.mapper.CashListMapper;
import com.ssm.manage.query.*;
import com.ssm.manage.response.*;
import com.ssm.manage.service.*;
import com.ssm.manage.utils.CommonUtils;
import com.ssm.manage.utils.Constant;
import com.ssm.manage.utils.DateUtils;
import com.ssm.manage.utils.LogExecutionTime;
import com.ssm.util.RedisClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.text.StrBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.SessionAttribute;
import tk.mybatis.mapper.entity.Example;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@Service
@Slf4j
public class SsmCashServiceImpl extends BaseServiceImpl<CashList> implements SsmCashService {
    @Autowired
    private SsmBaseStoreService ssmBaseStoreService;
    @Autowired
    private SsmCollectionTypeService ssmCollectionTypeService;
    

    @Autowired
    private SsmBaseStaffService ssmBaseStaffService;


    @Autowired
    private SsmStoreParaService ssmStoreParaService;
    @Autowired
    private SsmTransactionRecordService ssmTransactionRecordService;

    @Autowired
    private SsmProjectService ssmProjectService;

    @Autowired
    private SsmRechargeAccountService ssmRechargeAccountService;

    @Autowired
    private SsmCourseAccountService ssmCourseAccountService;

    @Autowired
    private SsmPayService ssmPayService;

    @Autowired
    private SsmAccountTradeRecordService ssmAccountTradeRecordService;

    @Autowired
    private SsmStoreMemberService ssmStoreMemberService;

    @Autowired
    private SsmRefundCashService ssmRefundCashService;

    @Autowired
    private SsmCashAccountSrevice ssmCashAccountSrevice;

    @Autowired
    private RedisClient<StaffResponse> redisClient;

    @Autowired
    private SsmMemberCsService ssmMemberCsService;

    @Autowired
    private SsmSalesmanService ssmSalesmanService;

    @Autowired
    private SsmCashSignatureService ssmCashSignatureService;

    @Autowired
    private SsmCashDownloadRecordService ssmCashDownloadRecordService;

    @Autowired
    private SsmCashDao dao;

    @Autowired
    private CashListMapper mapper;

    @Override
    public SsmCashDao getDao() {
        return dao;
    }

    private static String staffKey = "staffKey";

    @Override
    public void createTable() {
        String date = DateUtils.YMFormat(DateUtils.diffMonth(new Date(),1));
        dao.createTable(date);
    }


    @Override
    public PageInfo<CashListResponse> selectPage(CashListRequest cashListRequest) throws SmsException, ParseException {
        Date date = DateUtils.YMParse(cashListRequest.getSelectDate());
        cashListRequest.setCashDate(date);
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        //校验门店注册时间 时间之前的数据不允许查看
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())),date) < 0){
            throw new SmsException(ResponseCode.NO_DATA);
        }
        PageInfo<CashList> pageInfo = dao.selectPage(cashListRequest);
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);
//            //隐藏手机号码
//            String memberPhone = CommonUtils.mobileHide(cashList.getMobilePhone());
//            cashListResponse.setMobilePhone(memberPhone);
            //查询现付列表
            PayList payList = new PayList();
            payList.setDocId(String.valueOf(cashList.getId()));
            payList.setStoreId(cashList.getStoreId());
            List<PayList> list = ssmPayService.select(payList);
            //查询充值卡付列表(通过账户交易记录)
            List<RechargeAccountResponse> rechargeConsumeList = this.setRechargeAccountList(cashList);
            //设置业务人员列表
            cashListResponse = this.getStaffList(cashList,cashListResponse);
            cashListResponse.setPayLists(list);
            cashListResponse.setRechargeConsumeList(rechargeConsumeList);
            listResponses.add(cashListResponse);
        }
        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        p.setTotal(pageInfo.getTotal());
        return p;
    }

    @Override
    public PageInfo<CashListResponse> selectCashList(CashListRequest cashListRequest) throws SmsException, ParseException {
        Date date = DateUtils.YMParse(cashListRequest.getSelectDate());
        cashListRequest.setCashDate(date);
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())),date) < 0){
            throw new SmsException(ResponseCode.NO_DATA);
        }
        //按单据号分组之后的数据
        //PageInfo<CashList> pageInfo = dao.selectCashList(cashListRequest);
        PageInfo<CashList> pageInfo = dao.selectCashListGroup(cashListRequest);
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList,cashListResponse);
//            //隐藏手机号码
//            String memberPhone = CommonUtils.mobileHide(cashList.getMobilePhone());
//            cashListResponse.setMobilePhone(memberPhone);
            cashListRequest.setCashNum(cashList.getCashNum());
            cashListRequest.setId(null);
            List<CashList> cashLists = dao.selectByNum(cashListRequest);
            List<ProjectRequest> projectRequestsList = new ArrayList<>();
            for (CashList list : cashLists) {
                //项目列表
                List<ProjectRequest> projectRequests = new ArrayList<>();
                //设置项目列表
                projectRequests = this.setProject(projectRequests,list);
                for (ProjectRequest projectRequest : projectRequests) {
                    projectRequest.setCollectionAmount(list.getCollectionAmount());
                    projectRequest.setRemark(list.getRemark());
                    projectRequest.setSex(list.getSex());
                    BaseProject baseProject = new BaseProject();
                    baseProject.setId(projectRequest.getId());
                    BaseProject baseProject1 = ssmProjectService.selectOne(baseProject);
                    if(null != baseProject1){
                        projectRequest.setProjectNum(baseProject1.getProjectNum());
                    }
                }
                for (ProjectRequest projectRequest : projectRequests) {
                    projectRequestsList.add(projectRequest);
                }
            }
            //cashListResponse.setProjectList(projectRequests);
            cashListResponse.setProjectList(projectRequestsList);
            cashListResponse.setEntities(this.getAchiCommList(cashList, cashListResponse));

            listResponses.add(cashListResponse);
        }
        for (CashListResponse projectRequest : listResponses) {
            //查询现付列表
            PayList payList = new PayList();
            payList.setDocId(projectRequest.getCashNum());
            payList.setStoreId(projectRequest.getStoreId());
            List<PayList> payLists = ssmPayService.select(payList);
            projectRequest.setPayLists(payLists);
            List<ProjectRequest> projectList = projectRequest.getProjectList();
            for (ProjectRequest request : projectList) {
                Salesman salesman = new Salesman();
                salesman.setOrderId(String.valueOf(projectRequest.getId()));
                salesman.setOrderType(0);
                salesman.setOrderNum(projectRequest.getCashNum());
                salesman.setProjectId(request.getId());
                List<Salesman> salesmen = ssmSalesmanService.selectList(salesman);
                request.setSalesmens(salesmen);
            }
        }
        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        p.setTotal(pageInfo.getTotal());
        return p;
    }

    @Override
    @LogExecutionTime
    public PageInfo<CashListResponse> selectCashListNew(CashListRequest cashListRequest) throws SmsException, ParseException {

        Date date = DateUtils.YMParse(cashListRequest.getSelectDate());
        cashListRequest.setCashDate(date);
//        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
//        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())),date) < 0){
//            throw new SmsException(ResponseCode.NO_DATA);
//        }
        List<Long> lists = new ArrayList<>();
        if(cashListRequest.getSelectType()==0){
            lists=cashListRequest.getStoreList();
        }else{
            BaseStore baseStore1 = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
            if(null == baseStore1.getParentId()&&(cashListRequest.getStoreList().size()<0||cashListRequest.getStoreList()==null)){
                StoreRequest storeRequest = new StoreRequest();
                storeRequest.setId(cashListRequest.getStoreId());
                List<BaseStores> pagesorganizations = ssmBaseStoreService.pagesorganizations(storeRequest);
                List<Long> collect = pagesorganizations.stream().map(BaseStores::getId).collect(Collectors.toList());
                lists=collect;
            }else{
                lists.add(cashListRequest.getStoreId());
            }

        }


        cashListRequest.setStoreList(lists);
        //按单据号分组之后的数据
        //PageInfo<CashList> pageInfo = dao.selectCashList(cashListRequest);
        PageInfo<CashList> pageInfo = dao.selectCashListGroupNew(cashListRequest);


        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
//                CashListRequest cashListnew  = new CashListRequest();
//                String docNum = cashList.getCashNum();
//                cashListnew.setCashNum(docNum);
//                String substring = docNum.substring(docNum.length()-11, docNum.length() - 3);
////                System.out.println(substring);
//                StrBuilder strBuilder = new StrBuilder(substring);
//                StrBuilder insert = strBuilder.insert(6, "-").insert(4, "-");
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//                Date parse = simpleDateFormat.parse(String.valueOf(insert));
//                cashList.setCashDate(parse);
////                System.out.println(insert);
//                List<CashList> cashListsnew  = this.selectList(cashListnew);

            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList,cashListResponse);
//            //隐藏手机号码
//            String memberPhone = CommonUtils.mobileHide(cashList.getMobilePhone());
//            cashListResponse.setMobilePhone(memberPhone);
            cashListRequest.setCashNum(cashList.getCashNum());
            cashListRequest.setId(null);
            cashListRequest.setStoreId(cashList.getStoreId());
            List<CashList> cashLists = dao.selectByNum(cashListRequest);
            List<ProjectRequest> projectRequestsList = new ArrayList<>();

            for (CashList list : cashLists) {
                //项目列表
                cashListResponse.setInputId(list.getInputId());
                List<ProjectRequest> projectRequests = new ArrayList<>();
                //设置项目列表
                projectRequests = this.setProject(projectRequests,list);
                for (ProjectRequest projectRequest : projectRequests) {
//                    for (CashList cashList1 : cashListsnew) {
//
//                    }
                    if(projectRequest.getCourseAccountId()!=null){
                            CourseAccount courseAccount = new CourseAccount();
                            courseAccount.setId(projectRequest.getCourseAccountId());
                            CourseAccount courseAccount1 = ssmCourseAccountService.selectOne(courseAccount);
                            projectRequest.setCourseRestCount(courseAccount1.getCourseRestCount());
                            cashListResponse.setIsCoursePay(1);
                    }
                    projectRequest.setCollectionAmount(list.getCollectionAmount());
                    projectRequest.setRemark(list.getRemark());
                    projectRequest.setSex(list.getSex());
                    BaseProject baseProject = new BaseProject();
                    baseProject.setId(projectRequest.getId());
                    BaseProject baseProject1 = ssmProjectService.selectOne(baseProject);
                    if(null != baseProject1){
                        projectRequest.setProjectNum(baseProject1.getProjectNum());
                    }

                }
                for (ProjectRequest projectRequest : projectRequests) {
                    projectRequest.setOnePrice(list.getPrice().divide(BigDecimal.valueOf(list.getNumberTimes()==0?1:list.getNumberTimes()),10,BigDecimal.ROUND_HALF_UP));
                    projectRequest.setNumber(list.getNumberTimes());
                    projectRequestsList.add(projectRequest);
                }
            }

            cashListResponse.setProjectList(projectRequestsList);

            double rechargeSum=0;
            double cashSum = 0;


            for(ProjectRequest projectRequest:projectRequestsList){
                cashSum+=(projectRequest.getCollectionCashAmount()==null?0:projectRequest.getCollectionCashAmount().doubleValue());
                rechargeSum+=(projectRequest.getCollectionRechargeAmount()==null?0:projectRequest.getCollectionRechargeAmount().doubleValue());
//                if(projectRequest.getCollectionCashAmount().doubleValue()==0&&projectRequest.getCollectionRechargeAmount().doubleValue()==0){
//                    rechargeSum+=(projectRequest.getCashAmount()==null?0:projectRequest.getCashAmount().doubleValue());
//                }
                if(projectRequest.getCourseAccountId()!=null){
                    rechargeSum += projectRequest.getTransactionPrice().multiply(BigDecimal.valueOf(projectRequest.getNumber())).doubleValue();
                }
               // .setScale(10, BigDecimal.ROUND_HALF_UP)
                //rechargeSum.add(projectRequest.getCollectionRechargeAmount()==null?new BigDecimal("0"):projectRequest.getCollectionRechargeAmount());
            }
            BigDecimal rechargeSum1=BigDecimalUtils.bigDecimalRound(BigDecimal.valueOf(rechargeSum),2);
            rechargeSum=rechargeSum1.doubleValue();
            cashListResponse.setCashSum(cashSum);
            cashListResponse.setRechargeSum(rechargeSum);


            cashListResponse.setEntities(this.getAchiCommList(cashList, cashListResponse));
            if(cashListResponse.getIsCoursePay()==null){
                cashListResponse.setIsCoursePay(0);
            }
            listResponses.add(cashListResponse);
        }
        for (CashListResponse projectRequest : listResponses) {

            //查询员工num
            if(projectRequest.getInputId()!=null){
                BaseStaff baseStaff = ssmBaseStaffService.selectByPrimaryKey(projectRequest.getInputId());
                projectRequest.setInputNum(baseStaff.getStaffNum());
            }

            //查询现付列表
            PayList payList = new PayList();
            payList.setDocId(projectRequest.getCashNum());
            payList.setStoreId(projectRequest.getStoreId());
            List<PayList> payLists = ssmPayService.select(payList);
            projectRequest.setPayLists(payLists);
            List<ProjectRequest> projectList = projectRequest.getProjectList();

            for (ProjectRequest request : projectList) {
                Salesman salesman = new Salesman();
                salesman.setOrderId(String.valueOf(projectRequest.getId()));
                salesman.setOrderType(0);
                salesman.setOrderNum(projectRequest.getCashNum());
                salesman.setProjectId(request.getId());
                List<Salesman> salesmen = ssmSalesmanService.selectList(salesman);
                request.setSalesmens(salesmen);

            }

        }
        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        p.setTotal(pageInfo.getTotal());
        return p;
    }

    @Override
    public PageInfo<CashListResponse> cashListDetail(CashListRequest cashListRequest) throws SmsException, ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = simpleDateFormat.parse(cashListRequest.getSelectDate());
        cashListRequest.setCashDate(parse);
        PageInfo<CashList> pageInfo = dao.selectCashListGroups(cashListRequest);
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList,cashListResponse);
            CashListRequest cashListRequest1 = new CashListRequest();
//            //隐藏手机号码
//            String memberPhone = CommonUtils.mobileHide(cashList.getMobilePhone());
//            cashListResponse.setMobilePhone(memberPhone);
            cashListRequest1.setCashNum(cashList.getCashNum());
            cashListRequest1.setStoreId(cashList.getStoreId());
            cashListRequest1.setId(cashList.getId());
            cashListRequest1.setCashDate(parse);
            List<CashList> cashLists = dao.selectByNum(cashListRequest1);
            List<ProjectRequest> projectRequestsList = new ArrayList<>();
            for (CashList list : cashLists) {
                //项目列表
                List<ProjectRequest> projectRequests = new ArrayList<>();
                //设置项目列表
                projectRequests = this.setProject(projectRequests,list);
                for (ProjectRequest projectRequest : projectRequests) {
                    projectRequest.setCollectionAmount(list.getCollectionAmount());
                    projectRequest.setRemark(list.getRemark());
                    projectRequest.setSex(list.getSex());
                    BaseProject baseProject = new BaseProject();
                    baseProject.setId(projectRequest.getId());
                    BaseProject baseProject1 = ssmProjectService.selectOne(baseProject);
                    if(null != baseProject1){
                        projectRequest.setProjectNum(baseProject1.getProjectNum());
                    }
                }
                for (ProjectRequest projectRequest : projectRequests) {
                    projectRequestsList.add(projectRequest);
                }
            }

            double rechargeSum=0;
            double cashSum = 0;


            for(ProjectRequest projectRequest:projectRequestsList){
                cashSum+=(projectRequest.getCollectionCashAmount()==null?0:projectRequest.getCollectionCashAmount().doubleValue());
                rechargeSum+=(projectRequest.getCollectionRechargeAmount()==null?0:projectRequest.getCollectionRechargeAmount().doubleValue());
                //rechargeSum.add(projectRequest.getCollectionRechargeAmount()==null?new BigDecimal("0"):projectRequest.getCollectionRechargeAmount());
            }

            cashListResponse.setCashSum(cashSum);
            cashListResponse.setRechargeSum(rechargeSum);


            //cashListResponse.setProjectList(projectRequests);
            cashListResponse.setProjectList(projectRequestsList);
            cashListResponse.setEntities(this.getAchiCommList(cashList, cashListResponse));

            listResponses.add(cashListResponse);
        }
        for (CashListResponse projectRequest : listResponses) {
            //查询现付列表
            PayList payList = new PayList();
            payList.setDocId(projectRequest.getCashNum());
            payList.setStoreId(projectRequest.getStoreId());
            List<PayList> payLists = ssmPayService.select(payList);
            projectRequest.setPayLists(payLists);
            List<ProjectRequest> projectList = projectRequest.getProjectList();
            for (ProjectRequest request : projectList) {
                Salesman salesman = new Salesman();
                salesman.setOrderId(String.valueOf(projectRequest.getId()));
                salesman.setOrderType(0);
                salesman.setOrderNum(projectRequest.getCashNum());
                salesman.setProjectId(request.getId());
                List<Salesman> salesmen = ssmSalesmanService.selectList(salesman);
                request.setSalesmens(salesmen);
            }
        }
        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        p.setTotal(pageInfo.getTotal());
        return p;
    }

    @Override
    public PageInfo<CashListResponse> selectCashLists(CashListRequest cashListRequest) throws SmsException, ParseException {
        Date date = DateUtils.YMParse(cashListRequest.getSelectDate());
        cashListRequest.setCashDate(date);
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())),date) < 0){
            throw new SmsException(ResponseCode.NO_DATA);
        }
        //按单据号分组之后的数据
        PageInfo<CashList> pageInfo = dao.selectCashList(cashListRequest);
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList,cashListResponse);
//            //隐藏手机号码
//            String memberPhone = CommonUtils.mobileHide(cashList.getMobilePhone());
//            cashListResponse.setMobilePhone(memberPhone);
            cashListRequest.setCashNum(cashList.getCashNum());
//            PayList payList = new PayList();
//            payList.setDocId();
//            ssmPayService.select(payList)
            //通过单据号查询所有对应项目数据
            List<CashList> cashLists = dao.selectByNum(cashListRequest);
            //项目列表
            List<ProjectRequest> projectRequests = new ArrayList<>();
            int arr=0;
            for (CashList list : cashLists) {
                //设置项目列表
                projectRequests = this.setProject(projectRequests,list);
                for (ProjectRequest projectRequest : projectRequests) {
                    projectRequest.setCollectionAmount(cashLists.get(arr).getCollectionAmount());
                    BaseProject baseProject = new BaseProject();
                    baseProject.setId(projectRequest.getId());
                    BaseProject baseProject1 = ssmProjectService.selectOne(baseProject);
                    if(null != baseProject1){
                        projectRequest.setProjectNum(baseProject1.getProjectNum());
                    }
                    arr++;

                    Salesman salesman = new Salesman();
                    salesman.setOrderId(list.getId().toString());
                    salesman.setOrderType(0);
                    List<Salesman> select = ssmSalesmanService.select(salesman);
                    projectRequest.setSalesmens(select);
                }
                cashListResponse.setProjectList(projectRequests);
                arr=0;
            }
            RefundCash refundCash = new RefundCash();
            refundCash.setCashId(cashListResponse.getId());
            List<RefundCash> refundCash1 = ssmRefundCashService.select(refundCash);
            if(null == refundCash1 || refundCash1.size()==0){
                listResponses.add(cashListResponse);
            }
        }

        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        p.setTotal(pageInfo.getTotal());
        return p;
    }

    /*
    * 项目列表设置
    * */
    public List<ProjectRequest> setProject(List<ProjectRequest> projectRequests,CashList cashList){
        ProjectRequest projectRequest = new ProjectRequest();
        projectRequest.setCashId(cashList.getId());
        projectRequest.setCourseAccountId(cashList.getCourseAccountId());
        projectRequest.setCashDate(cashList.getCashDate());
        projectRequest.setTransactionPrice(cashList.getTransactionPrice());
        projectRequest.setId(cashList.getProjectId());
        projectRequest.setProjectName(cashList.getProjectName());
        projectRequest.setMinumumTimes(cashList.getMinumumTimes());
        projectRequest.setPrice(cashList.getPrice());
        projectRequest.setMinumumPrice(cashList.getMinumumPrice());
        projectRequest.setPriceMember(cashList.getPriceMember());
        projectRequest.setMinumumPriceMember(cashList.getMinumumPriceMember());
        projectRequest.setAchievementLarge(cashList.getAchievementLarge());
        projectRequest.setAchievementZhonggong(cashList.getAchievementZhonggong());
        projectRequest.setAchievementTechnician(cashList.getAchievementTechnician());
        projectRequest.setAchievementSmall(cashList.getAchievementSmall());
        projectRequest.setCardAchievementLarge(cashList.getCardAchievementLarge());
        projectRequest.setCardAchievementZhonggong(cashList.getCardAchievementZhonggong());
        projectRequest.setCardAchievementTechnician(cashList.getCardAchievementTechnician());
        projectRequest.setCardAchievementSmall(cashList.getCardAchievementSmall());
        projectRequest.setCommissionLarge(cashList.getCommissionLarge());
        projectRequest.setCommissionZhonggong(cashList.getCommissionZhonggong());
        projectRequest.setCommissionTechnician(cashList.getCommissionTechnician());
        projectRequest.setCommissionSmall(cashList.getCommissionSmall());
        projectRequest.setCardCommissionLarge(cashList.getCardCommissionLarge());
        projectRequest.setCardCommissionZhonggong(cashList.getCardCommissionZhonggong());
        projectRequest.setCardCommissionTechnician(cashList.getCardCommissionTechnician());
        projectRequest.setCardCommissionSmall(cashList.getCardCommissionSmall());
//        projectRequest.setSalesAchievement(cashList.getCollectionCashAmount());
        projectRequest.setCollectionCashAmount(cashList.getCollectionCashAmount());
        projectRequest.setAmount(cashList.getAmount());
        projectRequest.setCollectionRechargeAmount(cashList.getCollectionRechargeAmount());
        projectRequest.setCollectionIntegralAmount(cashList.getCollectionIntegralAmount());
        projectRequest.setCashAmount(cashList.getCashAmount());

        //查询现付列表
        PayList payList = new PayList();
//        payList.setDocId(String.valueOf(cashList.getId()));
        payList.setDocId(cashList.getCashNum());
        payList.setStoreId(cashList.getStoreId());
        List<PayList> payLists = ssmPayService.select(payList);
        projectRequest.setPayLists(payLists);
        //查询充值卡付列表(通过账户交易记录)
        List<RechargeAccountResponse> rechargeConsumeList = this.setRechargeAccountList(cashList);
        projectRequest.setRechargeConsumeList(rechargeConsumeList);
        //设置业务人员列表
        projectRequest = this.getStaffList(cashList,projectRequest);
        projectRequests.add(projectRequest);
        return projectRequests;
    }

    /*
     * 充值卡付列表设置返回值
     * */
    public List<RechargeAccountResponse> setRechargeAccountList(CashList cashList){
        List<RechargeAccountResponse> list = new ArrayList<>();
        AccountTradeRecordRequest accountTradeRecordRequest = new AccountTradeRecordRequest();
        accountTradeRecordRequest.setDocType(Constant.doc_type_store_cash);
        accountTradeRecordRequest.setAccountType(Constant.account_type_recharge_consume);
        accountTradeRecordRequest.setDocId(cashList.getId());
        accountTradeRecordRequest.setInputDate(cashList.getCashDate());
        List<AccountTradeRecord> recordList = ssmAccountTradeRecordService.selectList(accountTradeRecordRequest);
        for (AccountTradeRecord accountTradeRecord : recordList) {
            RechargeAccountResponse rechargeAccountResponse = new RechargeAccountResponse();
            RechargeAccount rechargeAccount = ssmRechargeAccountService.selectByPrimaryKey(accountTradeRecord.getAccountId());
            BeanUtils.copyProperties(rechargeAccount,rechargeAccountResponse);
            rechargeAccountResponse.setSpendMoney(accountTradeRecord.getAccountSpendMoney());
            rechargeAccountResponse.setAccountGiftSpendMoney(accountTradeRecord.getAccountGiftSpendMoney());
            rechargeAccountResponse.setCardRestMoney(accountTradeRecord.getAccountRestMoney());
            rechargeAccountResponse.setCardGiftMoney(accountTradeRecord.getAccountGiftConsumeMoney());

            rechargeAccountResponse.setRechargeTypeName(rechargeAccount.getRechargeTypeName());
            rechargeAccountResponse.setRechargeTypeNum(rechargeAccount.getRechargeTypeNum());
            list.add(rechargeAccountResponse);
        }
        return list;
    }

    /*
     * 业务员列表设置返回值
     * */
    public CashListResponse getStaffList(CashList cashList, CashListResponse cashListResponse){
        List<StaffRequest> largeList = new ArrayList<>();
        if (null != cashList.getServiceLargeOneStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getLargeOneNumber());
            staffRequest.setId(cashList.getServiceLargeOneStaffId());
            staffRequest.setStaffName(cashList.getServiceLargeOneStaffName());
            staffRequest.setIdentityCard(cashList.getServiceLargeOneIdentityCard());
            staffRequest.setRatio(cashList.getServiceLargeOneRatio());
//            achiCommEntity.setSaleAchievementAmount(cashList.getServiceLargeOneAchievementAmount());
//            achiCommEntity.setSaleCommissionAmount(cashList.getServiceLargeOneCommissionAmount());
            largeList.add(staffRequest);
        }
        List<StaffRequest> zhonggongList = new ArrayList<>();
        if (null != cashList.getServiceZhonggongOneStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getZhonggongOneNumber());
            staffRequest.setId(cashList.getServiceZhonggongOneStaffId());
            staffRequest.setStaffName(cashList.getServiceZhonggongOneStaffName());
            staffRequest.setIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
            staffRequest.setRatio(cashList.getServiceZhonggongOneRatio());
//            achiCommEntity.setSaleAchievementAmount(cashList.getServiceZhonggongOneAchievementAmount());
//            achiCommEntity.setSaleCommissionAmount(cashList.getServiceZhonggongOneCommissionAmount());
            zhonggongList.add(staffRequest);
        }
        List<StaffRequest> technicianList = new ArrayList<>();
        if (null != cashList.getServiceTechnicianOneStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getTechnicianOneNumber());
            staffRequest.setId(cashList.getServiceTechnicianOneStaffId());
            staffRequest.setStaffName(cashList.getServiceTechnicianOneStaffName());
            staffRequest.setIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
            staffRequest.setRatio(cashList.getServiceTechnicianOneRatio());
//            achiCommEntity.setSaleAchievementAmount(cashList.getServiceTechnicianOneAchievementAmount());
//            achiCommEntity.setSaleCommissionAmount(cashList.getServiceTechnicianOneCommissionAmount());
            technicianList.add(staffRequest);
        }
        List<StaffRequest> smallList = new ArrayList<>();
        if (null != cashList.getServiceSmallOneStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getSmallOneNumber());
            staffRequest.setId(cashList.getServiceSmallOneStaffId());
            staffRequest.setStaffName(cashList.getServiceSmallOneStaffName());
            staffRequest.setIdentityCard(cashList.getServiceSmallOneIdentityCard());
            staffRequest.setRatio(cashList.getServiceSmallOneRatio());
//            achiCommEntity.setSaleAchievementAmount(cashList.getServiceSmallOneAchievementAmount());
//            achiCommEntity.setSaleCommissionAmount(cashList.getServiceSmallOneCommissionAmount());
            smallList.add(staffRequest);
        }
        cashListResponse.setLargeList(largeList);
        cashListResponse.setZhonggongList(zhonggongList);
        cashListResponse.setTechnicianList(technicianList);
        cashListResponse.setSmallList(smallList);
        return cashListResponse;
    }


    /*
     * 业务员列表设置返回值
     * */
    public ProjectRequest getStaffList(CashList cashList, ProjectRequest projectRequest){
        BigDecimal hundredBD = BigDecimalUtils.bigDecimal("100");
        List<StaffRequest> largeList = new ArrayList<>();
        if (null != cashList.getServiceLargeOneStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getLargeOneNumber());
            staffRequest.setId(cashList.getServiceLargeOneStaffId());
            staffRequest.setStaffName(cashList.getServiceLargeOneStaffName());
            staffRequest.setIdentityCard(cashList.getServiceLargeOneIdentityCard());
            staffRequest.setRatio(cashList.getServiceLargeOneRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
            largeList.add(staffRequest);
        }
        if (null != cashList.getServiceLargeTwoStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getLargeTwoNumber());
            staffRequest.setId(cashList.getServiceLargeTwoStaffId());
            staffRequest.setStaffName(cashList.getServiceLargeTwoStaffName());
            staffRequest.setIdentityCard(cashList.getServiceLargeTwoIdentityCard());
            staffRequest.setRatio(cashList.getServiceLargeTwoRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
            largeList.add(staffRequest);
        }
        if (null != cashList.getServiceLargeThreeStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getLargeThreeNumber());
            staffRequest.setId(cashList.getServiceLargeThreeStaffId());
            staffRequest.setStaffName(cashList.getServiceLargeThreeStaffName());
            staffRequest.setIdentityCard(cashList.getServiceLargeThreeIdentityCard());
            staffRequest.setRatio(cashList.getServiceLargeThreeRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
            largeList.add(staffRequest);
        }
        if (null != cashList.getServiceLargeFourStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getLargeFourNumber());
            staffRequest.setId(cashList.getServiceLargeFourStaffId());
            staffRequest.setStaffName(cashList.getServiceLargeFourStaffName());
            staffRequest.setIdentityCard(cashList.getServiceLargeFourIdentityCard());
            staffRequest.setRatio(cashList.getServiceLargeFourRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
            largeList.add(staffRequest);
        }
        if (null != cashList.getServiceLargeFiveStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getLargeFiveNumber());
            staffRequest.setId(cashList.getServiceLargeFiveStaffId());
            staffRequest.setStaffName(cashList.getServiceLargeFiveStaffName());
            staffRequest.setIdentityCard(cashList.getServiceLargeFiveIdentityCard());
            staffRequest.setRatio(cashList.getServiceLargeFiveRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
            largeList.add(staffRequest);
        }

        List<StaffRequest> zhonggongList = new ArrayList<>();
        if (null != cashList.getServiceZhonggongOneStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getZhonggongOneNumber());
            staffRequest.setId(cashList.getServiceZhonggongOneStaffId());
            staffRequest.setStaffName(cashList.getServiceZhonggongOneStaffName());
            staffRequest.setIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
            staffRequest.setRatio(cashList.getServiceZhonggongOneRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
            zhonggongList.add(staffRequest);
        }
        if (null != cashList.getServiceZhonggongTwoStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getZhonggongTwoNumber());
            staffRequest.setId(cashList.getServiceZhonggongTwoStaffId());
            staffRequest.setStaffName(cashList.getServiceZhonggongTwoStaffName());
            staffRequest.setIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
            staffRequest.setRatio(cashList.getServiceZhonggongTwoRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
            zhonggongList.add(staffRequest);
        }
        if (null != cashList.getServiceZhonggongThreeStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getZhonggongThreeNumber());
            staffRequest.setId(cashList.getServiceZhonggongThreeStaffId());
            staffRequest.setStaffName(cashList.getServiceZhonggongThreeStaffName());
            staffRequest.setIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
            staffRequest.setRatio(cashList.getServiceZhonggongThreeRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
            zhonggongList.add(staffRequest);
        }
        if (null != cashList.getServiceZhonggongFourStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getZhonggongFourNumber());
            staffRequest.setId(cashList.getServiceZhonggongFourStaffId());
            staffRequest.setStaffName(cashList.getServiceZhonggongFourStaffName());
            staffRequest.setIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
            staffRequest.setRatio(cashList.getServiceZhonggongFourRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
            zhonggongList.add(staffRequest);
        }
        if (null != cashList.getServiceZhonggongFiveStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getZhonggongFiveNumber());
            staffRequest.setId(cashList.getServiceZhonggongFiveStaffId());
            staffRequest.setStaffName(cashList.getServiceZhonggongFiveStaffName());
            staffRequest.setIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
            staffRequest.setRatio(cashList.getServiceZhonggongFiveRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
            zhonggongList.add(staffRequest);
        }
        List<StaffRequest> technicianList = new ArrayList<>();
        if (null != cashList.getServiceTechnicianOneStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getTechnicianOneNumber());
            staffRequest.setId(cashList.getServiceTechnicianOneStaffId());
            staffRequest.setStaffName(cashList.getServiceTechnicianOneStaffName());
            staffRequest.setIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
            staffRequest.setRatio(cashList.getServiceTechnicianOneRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
            technicianList.add(staffRequest);
        }
        if (null != cashList.getServiceTechnicianTwoStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getTechnicianTwoNumber());
            staffRequest.setId(cashList.getServiceTechnicianTwoStaffId());
            staffRequest.setStaffName(cashList.getServiceTechnicianTwoStaffName());
            staffRequest.setIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
            staffRequest.setRatio(cashList.getServiceTechnicianTwoRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
            technicianList.add(staffRequest);
        }
        if (null != cashList.getServiceTechnicianThreeStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getTechnicianThreeNumber());
            staffRequest.setId(cashList.getServiceTechnicianThreeStaffId());
            staffRequest.setStaffName(cashList.getServiceTechnicianThreeStaffName());
            staffRequest.setIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
            staffRequest.setRatio(cashList.getServiceTechnicianThreeRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
            technicianList.add(staffRequest);
        }
        List<StaffRequest> smallList = new ArrayList<>();
        if (null != cashList.getServiceSmallOneStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getSmallOneNumber());
            staffRequest.setId(cashList.getServiceSmallOneStaffId());
            staffRequest.setStaffName(cashList.getServiceSmallOneStaffName());
            staffRequest.setIdentityCard(cashList.getServiceSmallOneIdentityCard());
            staffRequest.setRatio(cashList.getServiceSmallOneRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
            smallList.add(staffRequest);
        }
        if (null != cashList.getServiceSmallTwoStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getSmallTwoNumber());
            staffRequest.setId(cashList.getServiceSmallTwoStaffId());
            staffRequest.setStaffName(cashList.getServiceSmallTwoStaffName());
            staffRequest.setIdentityCard(cashList.getServiceSmallTwoIdentityCard());
            staffRequest.setRatio(cashList.getServiceSmallTwoRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
            smallList.add(staffRequest);
        }
        if (null != cashList.getServiceSmallThreeStaffId()){
            StaffRequest staffRequest = new StaffRequest();
            staffRequest.setBrandNumber(cashList.getSmallThreeNumber());
            staffRequest.setId(cashList.getServiceSmallThreeStaffId());
            staffRequest.setStaffName(cashList.getServiceSmallThreeStaffName());
            staffRequest.setIdentityCard(cashList.getServiceSmallThreeIdentityCard());
            staffRequest.setRatio(cashList.getServiceSmallThreeRatio());
            staffRequest.setCashCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
            staffRequest.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
            staffRequest.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
            staffRequest.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
            smallList.add(staffRequest);
        }
        projectRequest.setLargeList(largeList);
        projectRequest.setZhonggongList(zhonggongList);
        projectRequest.setTechnicianList(technicianList);
        projectRequest.setSmallList(smallList);
        return projectRequest;
    }

    @Override
    public String getDocNum(CashListRequest cashListRequest,String storeNum) {
        String ymdDate = DateUtils.YMDFormat(cashListRequest.getCashDate());
        cashListRequest.setSelectDate(ymdDate);
        String cashNum = "SY";
        cashListRequest.setSelectDate(cashNum+storeNum+cashListRequest.getSelectDate());
        List<CashList> cashLists = dao.getDocNum(cashListRequest);
        String num;
        int mm = 0;
        if (cashLists != null && cashLists.size() > 0) {
            CashList cashList = cashLists.get(0);
            int a=storeNum.length();
            mm = Integer.parseInt(cashList.getCashNum().substring(10+a)) + 1;
            if (mm < 10){
                num = "00" + mm;
            }else if (mm < 100){
                num = "0" + mm;
            }else {
                num = String.valueOf(mm);
            }
            if(storeNum!=null){
                cashNum += storeNum+ ymdDate + num;
            }else{
                cashNum +=  ymdDate + num;
            }


        }else {
            num = "001" ;
            if(storeNum!=null){
                cashNum += storeNum+ ymdDate + num;
            }else{
                cashNum +=  ymdDate + num;
            }
        }
        return cashNum;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public List<AccountTradeRecord> doCash(List<CashListRequest> cashListRequestList, String phone, CashSignatureFile cashSignatureFile) throws SmsException, ParseException {
        int i = 0;
        int l = 0;
        String cashNum = "";
        //返回值修改为账户交易记录list 短信发送使用
        List<AccountTradeRecord> list = new ArrayList<>();
        for (CashListRequest cashListRequest : cashListRequestList) {
            l++;
            if(null == cashListRequest.getCashDate()){
                cashListRequest.setCashDate(new Date());
            }

            CashList cashList = dao.one(cashListRequest);
            if (null != cashList) {
                cashNum = cashList.getCashNum();
            }else {
                cashList = new CashList();
                BeanUtils.copyProperties(cashListRequest,cashList);
            }

            cashList.setAmount(cashListRequest.getAmount());
            cashList.setCollectionCashAmount(cashListRequest.getCollectionCashAmount());
            cashList.setCollectionRechargeAmount(cashListRequest.getCollectionRechargeAmount());
            cashList.setCollectionIntegralAmount(cashListRequest.getCollectionIntegralAmount());
            cashList.setCollectionGiftAmount(cashListRequest.getCollectionGiftAmount());
            cashList.setCashAmount(cashListRequest.getCashAmount());
            cashList.setCourseAccountId(cashListRequest.getCourseAccountId());
            if(l==1){
                cashList.setMan(cashListRequest.getMan());
                cashList.setWoman(cashListRequest.getWoman());
            }

            //充值卡付判断
            List<RechargeAccountRequest> rechargeAccountList = cashListRequest.getRechargeAccountList();
            BigDecimal discountMoneyTotal = BigDecimalUtils.bigDecimal("0");
            BigDecimal giftMoneyTotal = BigDecimalUtils.bigDecimal("0");
            if (null != rechargeAccountList && rechargeAccountList.size() > 0) {
                BigDecimal hundredBd = BigDecimalUtils.bigDecimal("100");
                for (RechargeAccountRequest rechargeAccountRequest : rechargeAccountList) {
                    RechargeAccount rechargeAccount = ssmRechargeAccountService.selectByPrimaryKey(rechargeAccountRequest.getId());
                    if(rechargeAccountRequest.getType()==2){//促销卡
                        //判断账户剩余可用金额是否小于卡付金额
                        if (BigDecimalUtils.compareTo(rechargeAccount.getCardConsumeMoney(), rechargeAccountRequest.getSpendMoney()) == -1) {
                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
                        }
                        if (BigDecimalUtils.compareTo(rechargeAccount.getGiftConsumeMoney(), rechargeAccountRequest.getFreePaymentAmount()) == -1) {
                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
                        }

                    }else{
                        //判断账户剩余可用金额是否小于卡付金额
                        if (BigDecimalUtils.compareTo(BigDecimalUtils.add(rechargeAccount.getCardConsumeMoney(), rechargeAccount.getGiftConsumeMoney()), rechargeAccountRequest.getSpendMoney()) == -1) {
                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
                        }
                        BigDecimal discountMoney = BigDecimalUtils.bigDecimal("0");
                        if (rechargeAccount.getType() == 1 && cashListRequest.getNoDiscount() == 0) {
                            //计算卡付金额抵扣金额
                            discountMoney = BigDecimalUtils.div(rechargeAccountRequest.getSpendMoney(), BigDecimalUtils.div(rechargeAccountRequest.getDiscount(), hundredBd));
                            discountMoneyTotal = BigDecimalUtils.add(discountMoneyTotal, discountMoney);
                        }else {
                            giftMoneyTotal = BigDecimalUtils.add(giftMoneyTotal, rechargeAccountRequest.getSpendMoney());
                        }
                    }
                }
            }

            //疗程卡付判断
            if (null != cashList.getCourseAccountId()) {
                CourseAccount courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
                if (courseAccount.getCourseConsumeCount() < cashList.getNumberTimes()) {
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "疗程账户可用次数小于消费次数");
                }
            }else if (BigDecimalUtils.compareTo(discountMoneyTotal, BigDecimalUtils.bigDecimal("0")) == 1 &&
                    BigDecimalUtils.compareTo(cashList.getCollectionCashAmount(), BigDecimalUtils.bigDecimal("0")) == 0) {
                //折扣卡收银 允许使用容差 并且没有现付
                //不存在现付 总支付金额 = 总卡付支付金额 + 积分付
                BigDecimal amount = BigDecimalUtils.add(discountMoneyTotal, cashList.getCollectionIntegralAmount(), 2);
                //容差值< (成交金额-总支付金额) 即支付金额和成交金额不相等
                StoreParament balance = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.balance);
                if (null != balance && BigDecimalUtils.compareTo(BigDecimalUtils.bigDecimal(balance.getParamentValue()), BigDecimalUtils.subtract(cashList.getTransactionPrice(), amount).abs()) < 0) {
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "总支付金额和成交金额不相等");
                }
            }else {
                //存在现付
                //总支付金额 = 折扣卡付抵扣金额 + 赠送卡使用金额 + 总现付 + 积分付
                BigDecimal amount = BigDecimalUtils.add(BigDecimalUtils.add(BigDecimalUtils.add(discountMoneyTotal, giftMoneyTotal), cashList.getCollectionCashAmount()), cashList.getCollectionIntegralAmount(), 2);
                if (BigDecimalUtils.compareTo(amount, cashList.getTransactionPrice()) != 0) {
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "总支付金额和成交金额不相等");
                }
            }

            cashList.setIsCancel(0);
            StoreMemberList storeMember = ssmStoreMemberService.selectByPrimaryKey(cashList.getMemberId());
            //查询会员是否有积分
            StoreParament storeParament = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.member_integral);
            if ("1".equals(storeParament.getParamentValue())){
                //查询消费金额兑换积分比例
                StoreParament integralPara = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.exp_money_by_integral);
                String value[] = integralPara.getParamentValue().split(":");
                //使用float类型 除法时能计算小数
                float money = Integer.parseInt(value[0]);
                float integral = Integer.parseInt(value[1]);
//            //使用积分支付 消费赠送积分需使用实际支付-积分金额计算  不使用积分支付 消费赠送积分使用
//            if (null != cashList.getIntegral()) {
//                if (cashListRequest.getIntegral() > 0) {
//                    cashList.setGiveIntegral(BigDecimalUtils.div(BigDecimalUtils.subtract(cashList.getCashAmount(), cashList.getCollectionIntegralAmount()), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
//                } else {
//                    cashList.setGiveIntegral(BigDecimalUtils.div(cashList.getAmount(), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
//                }
//            }
                //如果使用积分支付将门店会员积分进行扣减  收银消费对会员积分进行增加
                if (null != storeMember) {
                    if (cashListRequest.getIntegral() > 0) {
                        cashList.setGiveIntegral(BigDecimalUtils.div(BigDecimalUtils.subtract(cashList.getCashAmount(), cashList.getCollectionIntegralAmount()), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
                        storeMember.setIntegral(storeMember.getIntegral() - cashListRequest.getIntegral() + cashList.getGiveIntegral());
                    }else {
                        cashList.setGiveIntegral(BigDecimalUtils.div(cashList.getAmount(), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
                        storeMember.setIntegral(storeMember.getIntegral() + cashList.getGiveIntegral());
                    }

                }
            }
            if (null != storeMember) {
                //对会员进行最近消费日期更新
                storeMember.setConsumeDate(cashList.getCashDate());
                ssmStoreMemberService.updateByPrimaryKey(storeMember);
            }
            //设置业务员
            List<StaffRequest> largeList = cashListRequest.getLargeList();
            List<StaffRequest> zhonggongList = cashListRequest.getZhonggongList();
            List<StaffRequest> technicianList = cashListRequest.getTechnicianList();
            List<StaffRequest> smallList = cashListRequest.getSmallList();
            this.setStaffValue(largeList, zhonggongList, technicianList, smallList, cashList);

            //计算业绩提成
            List<PayList> payLists = cashListRequest.getPayLists();
            cashList = this.setAchiComm(cashList, rechargeAccountList, payLists, cashListRequest);

            //设置录单人信息
            if (redisClient.hasKey(getStaffKey(phone))){
                StaffResponse staffResponse = redisClient.get(getStaffKey(phone));
                cashList.setInputId(staffResponse.getId());
                cashList.setInputBy(staffResponse.getStaffName());
            }
            Set<String> keys = redisClient.keys(getStaffKey(phone) + "*");
            //从redis查询 设置录单人信息 app使用
            if (keys.size() > 0){
                String key =  new ArrayList<>(keys).get(0);
                StaffResponse staffResponse = redisClient.get(key);
                cashList.setInputId(staffResponse.getId());
                cashList.setInputBy(staffResponse.getStaffName());
            }
            //有主键ID 更新收银单据信息
            if (null != cashList.getId()) {
                try {
                    i = dao.doCash(cashList);
                } catch (Exception e) {
                    log.error("SsmRechargeServiceImpl.doCash:", e);
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
                }
            }else {
                //无主键ID 后续收银额外添加项目 添加收银单据信息
                cashList.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
                try {
                    i = dao.addCash(cashList);
                } catch (Exception e) {
                    log.error("SsmRechargeServiceImpl.doCash:", e);
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
                }
            }
            if(null != cashListRequest.getSalesmens()){
                List<Salesman> salesmens = cashListRequest.getSalesmens();
                for (Salesman salesmen : salesmens) {
                    Random r = new Random(3);
                    int i1 = r.nextInt();
                    salesmen.setId(salesmen.getId()+i1);
                    salesmen.setOrderId(String.valueOf(cashList.getId()));
                    salesmen.setOrderNum(cashList.getCashNum());
                    salesmen.setOrderType(0);
                    salesmen.setOrderDate(new Date());
                    salesmen.setState(0);
                    salesmen.setMoney(cashListRequest.getTransactionPrice());
                    salesmen.setProjectId(cashListRequest.getProjectId());
                }
                ssmSalesmanService.addBatch(salesmens);
            }
            //充值卡付 扣减充值账户金额
            if (null != rechargeAccountList && rechargeAccountList.size() > 0) {
                //计算扣减金额 并添加账户交易记录
                list = ssmRechargeAccountService.subMoney(rechargeAccountList, cashList, list);
//                ssmCashAccountSrevice.add(rechargeAccountList,cashList);
            }
            //疗程卡付 扣减疗程账户次数
            CourseAccount courseAccount = new CourseAccount();
            if (null != cashList.getCourseAccountId()) {
                courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
                ssmCourseAccountService.subCount(courseAccount, cashList.getNumberTimes(), 0);
                //添加账户交易记录
                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, courseAccount);
                ssmAccountTradeRecordService.addRecord(accountTradeRecord);
                list.add(accountTradeRecord);
            }
            //现付 添加现付记录
            if (null != payLists && payLists.size() > 0) {
                for (PayList payList : payLists) {
                    payList.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
                    payList.setDocId(String.valueOf(cashList.getId()));
                    payList.setType(Constant.doc_type_store_cash);
                    payList.setStoreId(cashList.getStoreId());
                }
                ssmPayService.addPayList(payLists);
                //添加账户交易记录
                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, null);
                ssmAccountTradeRecordService.addRecord(accountTradeRecord);
                list.add(accountTradeRecord);
            }

            //将服务单据信息添加到评价表
            MemberCsRequest memberCsRequest = new MemberCsRequest();
            BeanUtils.copyProperties(cashList, memberCsRequest);
            memberCsRequest.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
            memberCsRequest.setDocId(cashList.getId());
            memberCsRequest.setDocNum(cashList.getCashNum());
            memberCsRequest.setDocType(Constant.doc_type_store_cash);
            memberCsRequest.setDocDate(cashList.getCashDate());
            memberCsRequest.setTradeId(cashList.getProjectId());
            memberCsRequest.setTradeName(cashList.getProjectName());
            memberCsRequest.setTradeMoney(cashList.getTransactionPrice());
            memberCsRequest.setTradeCount(cashList.getNumberTimes());
            StringBuffer staffIds = new StringBuffer();
            StringBuffer staffNames = new StringBuffer();
            if (largeList.size() > 0 || zhonggongList.size() > 0 || technicianList.size() > 0 || smallList.size() > 0) {
                for (StaffRequest staffRequest : largeList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : zhonggongList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : technicianList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : smallList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
            }
            memberCsRequest.setStaffIds(staffIds.toString());
            memberCsRequest.setStaffNames(staffNames.toString());
            ssmMemberCsService.addMemberCs(memberCsRequest);
        }
        //将签名文件信息保存
        if (StringUtils.isNotBlank(cashSignatureFile.getFileName()) && StringUtils.isNotBlank(cashSignatureFile.getFilePath())) {
            cashSignatureFile.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
            cashSignatureFile.setCashNum(cashNum);
            ssmCashSignatureService.saveNotNull(cashSignatureFile);
        }
        return list;
    }


    @Override
    @Transactional(rollbackFor=Exception.class)
    public List<AccountTradeRecord> doCashSalem(List<CashListRequest> cashListRequestList, String phone, CashSignatureFile cashSignatureFile,Long storeId) throws SmsException, ParseException {
        int i = 0;
        String cashNum = "";
        //返回值修改为账户交易记录list 短信发送使用
        List<AccountTradeRecord> list = new ArrayList<>();
        for (CashListRequest cashListRequest : cashListRequestList) {
            if(null == cashListRequest.getCashDate()){
                cashListRequest.setCashDate(new Date());
            }

            CashList cashList = dao.one(cashListRequest);
            if (null != cashList) {
                cashNum = cashList.getCashNum();
            }else {
                cashList = new CashList();
                BeanUtils.copyProperties(cashListRequest,cashList);
            }

            cashList.setAmount(cashListRequest.getAmount());
            cashList.setCollectionCashAmount(cashListRequest.getCollectionCashAmount());
            cashList.setCollectionRechargeAmount(cashListRequest.getCollectionRechargeAmount());
            cashList.setCollectionIntegralAmount(cashListRequest.getCollectionIntegralAmount());
            cashList.setCollectionGiftAmount(cashListRequest.getCollectionGiftAmount());
            cashList.setCashAmount(cashListRequest.getCashAmount());
            cashList.setCourseAccountId(cashListRequest.getCourseAccountId());
            cashList.setProjectNum(cashListRequest.getProjectNum());
            //充值卡付判断
            List<RechargeAccountRequest> rechargeAccountList = cashListRequest.getRechargeAccountList();
            BigDecimal discountMoneyTotal = BigDecimalUtils.bigDecimal("0");
            BigDecimal giftMoneyTotal = BigDecimalUtils.bigDecimal("0");
            if (null != rechargeAccountList && rechargeAccountList.size() > 0) {
                BigDecimal hundredBd = BigDecimalUtils.bigDecimal("100");
                for (RechargeAccountRequest rechargeAccountRequest : rechargeAccountList) {
                    RechargeAccount rechargeAccount = ssmRechargeAccountService.selectByPrimaryKey(rechargeAccountRequest.getId());
                    //rechargeAccount.setFirstCharge(rechargeAccount.getFirstCharge()+1);
//                    if(rechargeAccountRequest.getType()==2){//促销卡
//
////                        //判断账户剩余可用金额是否小于卡付金额
////                        BigDecimal discoutMoney = rechargeAccountRequest.getDiscoutMoney();
//////                        if (BigDecimalUtils.compareTo(rechargeAccount.getCardConsumeMoney(), rechargeAccountRequest.getSpendMoney()) == -1) {
//////                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
//////                        }
//////                        if (BigDecimalUtils.compareTo(rechargeAccount.getGiftConsumeMoney(), rechargeAccountRequest.getFreePaymentAmount()) == -1) {
//////                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
//////                        }
////                        //判断账户剩余可用金额是否小于卡付金额
////                        if (BigDecimalUtils.compareTo(BigDecimalUtils.add(rechargeAccount.getCardConsumeMoney(), rechargeAccount.getGiftConsumeMoney()), rechargeAccountRequest.getSpendMoney()) == -1) {
////                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
////                        }
////                        BigDecimal discountMoney = BigDecimalUtils.bigDecimal("0");
////                        //计算卡付金额抵扣金额
////                        discountMoney = BigDecimalUtils.div(rechargeAccountRequest.getSpendMoney(), BigDecimalUtils.div(rechargeAccountRequest.getDiscount(), hundredBd));
////                        discountMoneyTotal = BigDecimalUtils.add(discountMoneyTotal, discountMoney);
//                    }else{
//
//                    }
                    //判断账户剩余可用金额是否小于卡付金额
                    if (BigDecimalUtils.compareTo(BigDecimalUtils.add(rechargeAccount.getCardConsumeMoney(), rechargeAccount.getGiftConsumeMoney()), rechargeAccountRequest.getSpendMoney()) == -1) {
                        throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
                    }
                    BigDecimal discountMoney = BigDecimalUtils.bigDecimal("0");
                    if (rechargeAccount.getType() == 1 && cashListRequest.getNoDiscount() == 0) {
                        //计算卡付金额抵扣金额
                        discountMoney = BigDecimalUtils.div(rechargeAccountRequest.getSpendMoney(), BigDecimalUtils.div(rechargeAccountRequest.getDiscount(), hundredBd));
                        discountMoneyTotal = BigDecimalUtils.add(discountMoneyTotal, discountMoney);
                    }else  if (rechargeAccount.getType() == 2) {
                        //计算卡付金额抵扣金额
                        discountMoney = BigDecimalUtils.div(rechargeAccountRequest.getSpendMoney(), BigDecimalUtils.div(rechargeAccountRequest.getDiscount(), hundredBd));
                        discountMoneyTotal = BigDecimalUtils.add(discountMoneyTotal, discountMoney);
                    } else{
                        giftMoneyTotal = BigDecimalUtils.add(giftMoneyTotal, rechargeAccountRequest.getSpendMoney());
                    }
                }
            }

            //疗程卡付判断
            if (null != cashList.getCourseAccountId()) {
                CourseAccount courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
                if (courseAccount.getCourseConsumeCount() < cashList.getNumberTimes()) {
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "疗程账户可用次数小于消费次数");
                }
            }else if (BigDecimalUtils.compareTo(discountMoneyTotal, BigDecimalUtils.bigDecimal("0")) == 1 &&
                    BigDecimalUtils.compareTo(cashList.getCollectionCashAmount(), BigDecimalUtils.bigDecimal("0")) == 0) {
                //折扣卡收银 允许使用容差 并且没有现付
                //不存在现付 总支付金额 = 总卡付支付金额 + 积分付
                BigDecimal amount = BigDecimalUtils.add(discountMoneyTotal, cashList.getCollectionIntegralAmount(), 2);
                //容差值< (成交金额-总支付金额) 即支付金额和成交金额不相等
                StoreParament balance = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.balance);
                if (null != balance && BigDecimalUtils.compareTo(BigDecimalUtils.bigDecimal(balance.getParamentValue()), BigDecimalUtils.subtract(cashList.getTransactionPrice(), amount).abs()) < 0) {
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "总支付金额和成交金额不相等");
                }
            }
            else {
                //存在现付
                //总支付金额 = 折扣卡付抵扣金额 + 赠送卡使用金额 + 总现付 + 积分付
                BigDecimal amount = BigDecimalUtils.add(BigDecimalUtils.add(BigDecimalUtils.add(discountMoneyTotal, giftMoneyTotal), cashList.getCollectionCashAmount()), cashList.getCollectionIntegralAmount(), 2);
                if (BigDecimalUtils.compareTo(amount, cashList.getTransactionPrice()) != 0) {
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "总支付金额和成交金额不相等");
                }
            }

            cashList.setIsCancel(0);
            StoreMemberList storeMember = ssmStoreMemberService.selectByPrimaryKey(cashList.getMemberId());
            //查询会员是否有积分
            StoreParament storeParament = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.member_integral);
            if ("1".equals(storeParament.getParamentValue())){
                //查询消费金额兑换积分比例
                StoreParament integralPara = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.exp_money_by_integral);
                String value[] = integralPara.getParamentValue().split(":");
                //使用float类型 除法时能计算小数
                float money = Integer.parseInt(value[0]);
                float integral = Integer.parseInt(value[1]);
//            //使用积分支付 消费赠送积分需使用实际支付-积分金额计算  不使用积分支付 消费赠送积分使用
//            if (null != cashList.getIntegral()) {
//                if (cashListRequest.getIntegral() > 0) {
//                    cashList.setGiveIntegral(BigDecimalUtils.div(BigDecimalUtils.subtract(cashList.getCashAmount(), cashList.getCollectionIntegralAmount()), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
//                } else {
//                    cashList.setGiveIntegral(BigDecimalUtils.div(cashList.getAmount(), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
//                }
//            }
                //如果使用积分支付将门店会员积分进行扣减  收银消费对会员积分进行增加
                if (null != storeMember) {
                    if (cashListRequest.getIntegral() > 0) {
                        cashList.setGiveIntegral(BigDecimalUtils.div(BigDecimalUtils.subtract(cashList.getCashAmount(), cashList.getCollectionIntegralAmount()), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
                        storeMember.setIntegral(storeMember.getIntegral() - cashListRequest.getIntegral() + cashList.getGiveIntegral());
                    }else {
                        cashList.setGiveIntegral(BigDecimalUtils.div(cashList.getAmount(), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
                        storeMember.setIntegral(storeMember.getIntegral() + cashList.getGiveIntegral());
                    }

                }
            }
            if (null != storeMember) {
                //对会员进行最近消费日期更新
                storeMember.setConsumeDate(cashList.getCashDate());
                ssmStoreMemberService.updateByPrimaryKey(storeMember);
            }
            //设置业务员
            List<StaffRequest> largeList = cashListRequest.getLargeList();
            List<StaffRequest> zhonggongList = cashListRequest.getZhonggongList();
            List<StaffRequest> technicianList = cashListRequest.getTechnicianList();
            List<StaffRequest> smallList = cashListRequest.getSmallList();
            this.setStaffValue(largeList, zhonggongList, technicianList, smallList, cashList);

            //计算业绩提成
            List<PayList> payLists = cashListRequest.getPayLists();
            cashList = this.setAchiComm(cashList, rechargeAccountList, payLists, cashListRequest);
            if(cashList!=null){
                if(cashList.getLargeAchievementAmount()==null){
                    cashList.setLargeAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getZhonggongAchievementAmount()==null){
                    cashList.setZhonggongAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getTechnicianAchievementAmount()==null){
                    cashList.setTechnicianAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getSmallAchievementAmount()==null){
                    cashList.setSmallAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getLargeCommissionAmount()==null){
                    cashList.setLargeCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getZhonggongCommissionAmount()==null){
                    cashList.setZhonggongCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getTechnicianCommissionAmount()==null){
                    cashList.setTechnicianCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getSmallCommissionAmount()==null){
                    cashList.setSmallCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardLargeAchievementAmount()==null){
                    cashList.setCardLargeAchievementAmount(new BigDecimal("0.00"));
                }

                if(cashList.getCardZhonggongAchievementAmount()==null){
                    cashList.setCardZhonggongAchievementAmount(new BigDecimal("0.00"));
                }

                if(cashList.getCardTechnicianAchievementAmount()==null){
                    cashList.setCardTechnicianAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardSmallAchievementAmount()==null){
                    cashList.setCardSmallAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardLargeCommissionAmount()==null){
                    cashList.setCardLargeCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardZhonggongCommissionAmount()==null){
                    cashList.setCardZhonggongCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardTechnicianCommissionAmount()==null){
                    cashList.setCardTechnicianCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardSmallCommissionAmount()==null){
                    cashList.setCardSmallCommissionAmount(new BigDecimal("0.00"));
                }
            }

            //设置录单人信息
            if (redisClient.hasKey(getStaffKey(phone))){
                StaffResponse staffResponse = redisClient.get(getStaffKey(phone));
                cashList.setInputId(staffResponse.getId());
                cashList.setInputBy(staffResponse.getStaffName());
            }
            Set<String> keys = redisClient.keys(getStaffKey(phone) + "*");
            //从redis查询 设置录单人信息 app使用
            if (keys.size() > 0){
                String key =  new ArrayList<>(keys).get(0);
                StaffResponse staffResponse = redisClient.get(key);
                cashList.setInputId(staffResponse.getId());
                cashList.setInputBy(staffResponse.getStaffName());
            }
            //有主键ID 更新收银单据信息
            if (null != cashList.getId()) {
                try {
                    i = dao.doCash(cashList);
                } catch (Exception e) {
                    log.error("SsmRechargeServiceImpl.doCash:", e);
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
                }
            }else {
                //无主键ID 后续收银额外添加项目 添加收银单据信息
                cashList.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
                try {
                    i = dao.addCash(cashList);
                } catch (Exception e) {
                    log.error("SsmRechargeServiceImpl.doCash:", e);
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
                }
            }
            if(null != cashListRequest.getSalesmens()){
                //添加高管的当前单据门店信息
                StoreRequest storeRequest = new StoreRequest();
                storeRequest.setId(storeId);
                BaseStore baseStore1 = ssmBaseStoreService.selectOne(storeRequest);

                List<Salesman> salesmens = cashListRequest.getSalesmens();
                for (Salesman salesmen : salesmens) {
                    Random r = new Random(3);
                    int i1 = r.nextInt();
                    salesmen.setId(salesmen.getId()+i1);
                    salesmen.setOrderId(String.valueOf(cashList.getId()));
                    salesmen.setOrderNum(cashList.getCashNum());
                    salesmen.setOrderType(0);
                    salesmen.setOrderDate(new Date());
                    salesmen.setState(0);
                    salesmen.setMoney(cashListRequest.getTransactionPrice());
                    salesmen.setProjectId(cashListRequest.getProjectId());
                    salesmen.setStoreNum(baseStore1.getStoreNum());
                    salesmen.setStoreName(baseStore1.getStoreName());
                    salesmen.setStoreIdOrder(baseStore1.getId());
                }
                ssmSalesmanService.addBatch(salesmens);
            }
            //充值卡付 扣减充值账户金额
            if (null != rechargeAccountList && rechargeAccountList.size() > 0) {
                //计算扣减金额 并添加账户交易记录
                list = ssmRechargeAccountService.subMoney(rechargeAccountList, cashList, list);
//                ssmCashAccountSrevice.add(rechargeAccountList,cashList);
            }
            //
            //疗程卡付 扣减疗程账户次数
            CourseAccount courseAccount = new CourseAccount();
            if (null != cashList.getCourseAccountId()) {
                courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
                ssmCourseAccountService.subCount(courseAccount, cashList.getNumberTimes(), 0);
                //添加账户交易记录
                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, courseAccount);
                ssmAccountTradeRecordService.addRecord(accountTradeRecord);
                list.add(accountTradeRecord);
            }
            //现付 添加现付记录
            if (null != payLists && payLists.size() > 0) {
                for (PayList payList : payLists) {
                    payList.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
                    payList.setDocId(String.valueOf(cashList.getId()));
                    payList.setType(Constant.doc_type_store_cash);
                    payList.setStoreId(cashList.getStoreId());
                }
                ssmPayService.addPayList(payLists);
                //添加账户交易记录
                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, null);
                ssmAccountTradeRecordService.addRecord(accountTradeRecord);
                list.add(accountTradeRecord);
            }

            //将服务单据信息添加到评价表
            MemberCsRequest memberCsRequest = new MemberCsRequest();
            BeanUtils.copyProperties(cashList, memberCsRequest);
            memberCsRequest.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
            memberCsRequest.setDocId(cashList.getId());
            memberCsRequest.setDocNum(cashList.getCashNum());
            memberCsRequest.setDocType(Constant.doc_type_store_cash);
            memberCsRequest.setDocDate(cashList.getCashDate());
            memberCsRequest.setTradeId(cashList.getProjectId());
            memberCsRequest.setTradeName(cashList.getProjectName());
            memberCsRequest.setTradeMoney(cashList.getTransactionPrice());
            memberCsRequest.setTradeCount(cashList.getNumberTimes());
            StringBuffer staffIds = new StringBuffer();
            StringBuffer staffNames = new StringBuffer();
            if (largeList.size() > 0 || zhonggongList.size() > 0 || technicianList.size() > 0 || smallList.size() > 0) {
                for (StaffRequest staffRequest : largeList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : zhonggongList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : technicianList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : smallList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
            }
            memberCsRequest.setStaffIds(staffIds.toString());
            memberCsRequest.setStaffNames(staffNames.toString());
            ssmMemberCsService.addMemberCs(memberCsRequest);
        }
        //将签名文件信息保存
        if (StringUtils.isNotBlank(cashSignatureFile.getFileName()) && StringUtils.isNotBlank(cashSignatureFile.getFilePath())) {
            cashSignatureFile.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
            cashSignatureFile.setCashNum(cashNum);
            ssmCashSignatureService.saveNotNull(cashSignatureFile);
        }
        return list;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public List<AccountTradeRecord> doCashsj(List<CashListRequest> cashListRequestList, String phone, CashSignatureFile cashSignatureFile,Long storeId) throws SmsException, ParseException {
        int i = 0;
        int s = 0;
        int count = 0;
        BigDecimal amountcash=BigDecimal.valueOf(0);
        BigDecimal projectMenoyCash=BigDecimal.valueOf(0);
        String cashNum = "";
        //返回值修改为账户交易记录list 短信发送使用
        List<AccountTradeRecord> list = new ArrayList<>();
        for (CashListRequest cashListRequest : cashListRequestList) {
            BigDecimal courseMoney=BigDecimal.valueOf(0);
            if(null != cashListRequest.getCourseMoney()){
                courseMoney=cashListRequest.getCourseMoney();
            }
            if(cashListRequest.getIsAddition()==1){
                cashListRequest.setCashDate(cashListRequest.getAdditionDate());
            }
            count=count+1;
            BaseProject baseProject = new BaseProject();
            baseProject.setId(cashListRequest.getProjectId());
            BaseProject baseProject1 = ssmProjectService.selectOne(baseProject);

            s++;
            if(null == cashListRequest.getCashDate()){
                cashListRequest.setCashDate(new Date());
            }
            CashList cashList = dao.one(cashListRequest);
            if (null != cashList) {
                cashNum = cashList.getCashNum();
            }else {
                cashList = new CashList();
                BeanUtils.copyProperties(cashListRequest,cashList);
            }
            //todo 加上购买日期判断
//            if(baseProject1.getSalesDeadline()!=null && cashList.getCourseAccountId()!=null){
//                String salesDeadline = baseProject1.getSalesDeadline();
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//                Date parse;
//                try {
//                    parse = simpleDateFormat.parse(salesDeadline);
//                } catch (ParseException e) {
//                    throw new RuntimeException(e);
//                }
//                if(parse.before(new Date())){
//                    throw new SmsException(ResponseCode.MSG,baseProject1.getProjectName()+"项目超过消费时间，不允许消费");
//                }
//            }

            cashList.setAmount(cashListRequest.getTransactionPrice().multiply(BigDecimal.valueOf(cashList.getNumberTimes())));
            cashList.setCollectionCashAmount(cashListRequest.getCollectionCashAmount());
            cashList.setCollectionRechargeAmount(cashListRequest.getCollectionRechargeAmount());
            cashList.setCollectionIntegralAmount(cashListRequest.getCollectionIntegralAmount());
            cashList.setCollectionGiftAmount(cashListRequest.getCollectionGiftAmount());
            cashList.setCashAmount(cashListRequest.getCashAmount());
            cashList.setCourseAccountId(cashListRequest.getCourseAccountId());
            cashList.setProjectNum(cashListRequest.getProjectNum());

            //项目成交价
            BigDecimal transactionPrice = cashListRequest.getTransactionPrice();
            BigDecimal subtract = transactionPrice.subtract(cashList.getCollectionCashAmount());


            //充值卡付判断
            List<RechargeAccountRequest> rechargeAccountList = cashListRequest.getRechargeAccountList();
            BigDecimal discountMoneyTotal = BigDecimalUtils.bigDecimal("0");
            BigDecimal giftMoneyTotal = BigDecimalUtils.bigDecimal("0");
            if (null != rechargeAccountList && rechargeAccountList.size() > 0) {
                BigDecimal hundredBd = BigDecimalUtils.bigDecimal("100");
                if(baseProject1.getNoDiscount()==0){
                    //打折
                    for (RechargeAccountRequest rechargeAccountRequest : rechargeAccountList) {
                        RechargeAccount rechargeAccount = ssmRechargeAccountService.selectByPrimaryKey(rechargeAccountRequest.getId());

                        //判断账户剩余可用金额是否小于卡付金额
                        if (BigDecimalUtils.compareTo(rechargeAccount.getCardConsumeMoney(), rechargeAccountRequest.getSpendMoney()) == -1) {
                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
                        }
                        if (BigDecimalUtils.compareTo(rechargeAccount.getGiftConsumeMoney(), rechargeAccountRequest.getGiftSpendMoney()) == -1) {
                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户赠送可消费金额小于卡付金额");
                        }
                        BigDecimal discountMoney = BigDecimalUtils.bigDecimal("0");
                        if (rechargeAccount.getType() == 1 && cashListRequest.getNoDiscount() == 0 ) {
                            //计算卡付金额抵扣金额
                            discountMoney = BigDecimalUtils.div(rechargeAccountRequest.getSpendMoney(), BigDecimalUtils.div(rechargeAccountRequest.getDiscount(), hundredBd));
                            BigDecimal giftDiscountMoney = BigDecimalUtils.div(rechargeAccountRequest.getGiftSpendMoney(),
                                    BigDecimalUtils.div(rechargeAccountRequest.getDiscountFreeAmount()==null?BigDecimal.valueOf(0):rechargeAccountRequest.getDiscountFreeAmount(), hundredBd)
                                            .setScale(10, BigDecimal.ROUND_HALF_UP));
                            discountMoneyTotal = BigDecimalUtils.add(discountMoneyTotal, discountMoney).add(giftDiscountMoney);
                        }else  if (rechargeAccount.getType() == 2) {//促销卡
                            //计算卡付金额抵扣金额
                            discountMoney = BigDecimalUtils.div(rechargeAccountRequest.getSpendMoney(), BigDecimalUtils.div(rechargeAccountRequest.getDiscount(), hundredBd).setScale(10, BigDecimal.ROUND_HALF_UP)).setScale(10, BigDecimal.ROUND_HALF_UP);
                            //五舍六入ROUND_HALF_DOWN,四舍五入ROUND_HALF_UP
                            BigDecimal giftDiscountMoney = BigDecimalUtils.div(rechargeAccountRequest.getGiftSpendMoney(),
                            BigDecimalUtils.div(rechargeAccountRequest.getDiscountFreeAmount()==null?BigDecimal.valueOf(0):rechargeAccountRequest.getDiscountFreeAmount(), hundredBd)
                                    .setScale(10, BigDecimal.ROUND_HALF_UP))
                                    .setScale(10, BigDecimal.ROUND_HALF_UP);
                            discountMoneyTotal = BigDecimalUtils.add(discountMoneyTotal, BigDecimalUtils.add(discountMoney,giftDiscountMoney));
                        } else{
                            //discountMoneyTotal=rechargeAccountRequest.getSpendMoney();
                            discountMoneyTotal = discountMoneyTotal.add(BigDecimalUtils.add(rechargeAccountRequest.getGiftSpendMoney(), rechargeAccountRequest.getSpendMoney()));
                        }
                    }

                }else{//不打折
                    BigDecimal account = BigDecimal.valueOf(0);
                    for (RechargeAccountRequest rechargeAccountRequest : rechargeAccountList) {
                        if(null == rechargeAccountRequest.getGiftSpendMoney()){
                            rechargeAccountRequest.setGiftSpendMoney(BigDecimalUtils.bigDecimal("0"));
                        }
                        RechargeAccount rechargeAccount = ssmRechargeAccountService.selectByPrimaryKey(rechargeAccountRequest.getId());

                        //判断账户剩余可用金额是否小于卡付金额
                        //判断账户剩余可用金额是否小于卡付金额
                        if (BigDecimalUtils.compareTo(rechargeAccount.getCardConsumeMoney(), rechargeAccountRequest.getSpendMoney()) == -1) {
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户可消费金额小于卡付金额");
                        }
                        if (BigDecimalUtils.compareTo(rechargeAccount.getGiftConsumeMoney(), rechargeAccountRequest.getGiftSpendMoney()) == -1) {
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                            throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "账户赠送可消费金额小于卡付金额");
                        }
                        account=account.add(rechargeAccountRequest.getSpendMoney().add(rechargeAccountRequest.getGiftSpendMoney()));
                    }
                    discountMoneyTotal = account;
                }
            }

//            //NEw
//            cashList.setCollectionCashAmount(cashList.getTransactionPrice().subtract(discountMoneyTotal));
//            amountcash=cashList.getCollectionCashAmount().add(amountcash);

            //疗程卡付判断
            if (null != cashList.getCourseAccountId()) {
                CourseAccount courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
                if (courseAccount.getCourseConsumeCount() < cashList.getNumberTimes()) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "疗程账户可用次数小于消费次数");
                }
            }else if (BigDecimalUtils.compareTo(discountMoneyTotal, BigDecimalUtils.bigDecimal("0")) == 1 &&
                    BigDecimalUtils.compareTo(cashList.getCollectionCashAmount(), BigDecimalUtils.bigDecimal("0")) == 0) {
                //折扣卡收银 允许使用容差 并且没有现付
                //不存在现付 总支付金额 = 总卡付支付金额 + 积分付
                BigDecimal amount = BigDecimalUtils.add(discountMoneyTotal, cashList.getCollectionIntegralAmount(), 4);
                //容差值< (成交金额-总支付金额) 即支付金额和成交金额不相等
                StoreParament balance = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.balance);
                if (null != balance && BigDecimalUtils.compareTo(BigDecimalUtils.bigDecimal(balance.getParamentValue()), BigDecimalUtils.subtract(cashList.getTransactionPrice(), amount).abs()) < 0) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "总支付金额和成交金额不相等");
                }
            }
            else {
                //存在现付
                //总支付金额 = 总卡付金额抵扣金额 + 总现付 + 积分付
                BigDecimal amount = BigDecimalUtils.add(BigDecimalUtils.add(discountMoneyTotal, cashList.getCollectionCashAmount()), cashList.getCollectionIntegralAmount()).setScale(10, RoundingMode.HALF_UP);
                StoreParament balance = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.balance);
                //容差值< (成交金额-总支付金额) 即支付金额和成交金额不相等
                if (null != balance && BigDecimalUtils.compareTo(BigDecimalUtils.bigDecimal(balance.getParamentValue()), BigDecimalUtils.subtract(cashList.getTransactionPrice(), amount).abs()) < 0) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "总支付金额和成交金额不相等");
                }
               /* if (BigDecimalUtils.compareTo(amount, cashList.getTransactionPrice()) != 0) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.STORE_CASH_NOT_PERMISSION, "总支付金额和成交金额不相等");
                }*/
            }
            cashList.setIsCancel(0);
            StoreMemberList storeMember = ssmStoreMemberService.selectByPrimaryKey(cashList.getMemberId());
            //查询会员是否有积分
            StoreParament storeParament = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.member_integral);
            if ("1".equals(storeParament.getParamentValue())){
                //查询消费金额兑换积分比例
                StoreParament integralPara = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.exp_money_by_integral);
                String value[] = integralPara.getParamentValue().split(":");
                //使用float类型 除法时能计算小数
                float money = Integer.parseInt(value[0]);
                float integral = Integer.parseInt(value[1]);
//            //使用积分支付 消费赠送积分需使用实际支付-积分金额计算  不使用积分支付 消费赠送积分使用
//            if (null != cashList.getIntegral()) {
//                if (cashListRequest.getIntegral() > 0) {
//                    cashList.setGiveIntegral(BigDecimalUtils.div(BigDecimalUtils.subtract(cashList.getCashAmount(), cashList.getCollectionIntegralAmount()), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
//                } else {
//                    cashList.setGiveIntegral(BigDecimalUtils.div(cashList.getAmount(), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
//                }
//            }
                //如果使用积分支付将门店会员积分进行扣减  收银消费对会员积分进行增加
                if (null != storeMember) {
                    if (cashListRequest.getIntegral() > 0) {
                        cashList.setGiveIntegral(BigDecimalUtils.div(BigDecimalUtils.subtract(cashList.getCashAmount(), cashList.getCollectionIntegralAmount()), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
                        storeMember.setIntegral(storeMember.getIntegral() - cashListRequest.getIntegral() + cashList.getGiveIntegral());
                    }else {
                        cashList.setGiveIntegral(BigDecimalUtils.div(cashList.getAmount(), BigDecimalUtils.bigDecimal(String.valueOf(money / integral))).intValue());
                        storeMember.setIntegral(storeMember.getIntegral() + cashList.getGiveIntegral());
                    }
                }
            }

            if (null != storeMember) {
                //对会员进行最近消费日期更新
                storeMember.setConsumeDate(cashList.getCashDate());
                ssmStoreMemberService.updateByPrimaryKey(storeMember);
            }
            //设置业务员
            List<StaffRequest> largeList = cashListRequest.getLargeList();
            List<StaffRequest> zhonggongList = cashListRequest.getZhonggongList();
            List<StaffRequest> technicianList = cashListRequest.getTechnicianList();
            List<StaffRequest> smallList = cashListRequest.getSmallList();
            this.setStaffValue(largeList, zhonggongList, technicianList, smallList, cashList);
            BigDecimal reduce = largeList.stream().map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
            if(null != reduce && reduce.compareTo(BigDecimal.valueOf(100))!=0 && reduce.compareTo(BigDecimal.valueOf(0))!=0){
                throw new SmsException(ResponseCode.MSG,"美容师业绩占比和不等于100");
            }
            BigDecimal reduce1 = zhonggongList.stream().map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
            if(null != reduce1 && reduce1.compareTo(BigDecimal.valueOf(100))!=0 && reduce1.compareTo(BigDecimal.valueOf(0))!=0){
                throw new SmsException(ResponseCode.MSG,"美发师业绩占比和不等于100");
            }
            BigDecimal reduce2 = technicianList.stream().map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
            if(null != reduce2 && reduce2.compareTo(BigDecimal.valueOf(100))!=0 && reduce2.compareTo(BigDecimal.valueOf(0))!=0){
                throw new SmsException(ResponseCode.MSG,"技师业绩占比和不等于100");
            }
            BigDecimal reduce3 = smallList.stream().map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
            if(null != reduce3 && reduce3.compareTo(BigDecimal.valueOf(100))!=0 && reduce3.compareTo(BigDecimal.valueOf(0))!=0){
                throw new SmsException(ResponseCode.MSG,"助理业绩占比和不等于100");
            }

            //计算业绩提成
            List<PayList> payLists = cashListRequest.getPayLists();
            cashList = this.setAchiCommCash(cashList, rechargeAccountList, cashList.getCollectionCashAmount(), cashListRequest);

            if(cashList!=null){
                if(cashList.getLargeAchievementAmount()==null){
                    cashList.setLargeAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getZhonggongAchievementAmount()==null){
                    cashList.setZhonggongAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getTechnicianAchievementAmount()==null){
                    cashList.setTechnicianAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getSmallAchievementAmount()==null){
                    cashList.setSmallAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getLargeCommissionAmount()==null){
                    cashList.setLargeCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getZhonggongCommissionAmount()==null){
                    cashList.setZhonggongCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getTechnicianCommissionAmount()==null){
                    cashList.setTechnicianCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getSmallCommissionAmount()==null){
                    cashList.setSmallCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardLargeAchievementAmount()==null){
                    cashList.setCardLargeAchievementAmount(new BigDecimal("0.00"));
                }

                if(cashList.getCardZhonggongAchievementAmount()==null){
                    cashList.setCardZhonggongAchievementAmount(new BigDecimal("0.00"));
                }

                if(cashList.getCardTechnicianAchievementAmount()==null){
                    cashList.setCardTechnicianAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardSmallAchievementAmount()==null){
                    cashList.setCardSmallAchievementAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardLargeCommissionAmount()==null){
                    cashList.setCardLargeCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardZhonggongCommissionAmount()==null){
                    cashList.setCardZhonggongCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardTechnicianCommissionAmount()==null){
                    cashList.setCardTechnicianCommissionAmount(new BigDecimal("0.00"));
                }
                if(cashList.getCardSmallCommissionAmount()==null){
                    cashList.setCardSmallCommissionAmount(new BigDecimal("0.00"));
                }
            }

            //设置录单人信息
            if (redisClient.hasKey(getStaffKey(phone))){
                StaffResponse staffResponse = redisClient.get(getStaffKey(phone));
                cashList.setInputId(staffResponse.getId());
                cashList.setInputBy(staffResponse.getStaffName());
            }
            Set<String> keys = redisClient.keys(getStaffKey(phone) + "*");
            //从redis查询 设置录单人信息 app使用
            if (keys.size() > 0){
                String key =  new ArrayList<>(keys).get(0);
                StaffResponse staffResponse = redisClient.get(key);
                cashList.setInputId(staffResponse.getId());
                cashList.setInputBy(staffResponse.getStaffName());
            }
            //校验业绩提成
            //判断业绩提成校验是否是收银校验
            StoreRequest storeRequest1 = new StoreRequest();
            storeRequest1.setId(storeId);
            BaseStores baseStores1 = ssmBaseStoreService.pagesorganizations(storeRequest1).stream().filter(baseStores -> null == baseStores.getParentId()).findAny().orElse(null);
            StoreParament parament = StoreParaUtils.getStorePara(baseStores1.getId(), Constant.pro_achi_comm_verify);
            if ("1".equals(parament.getParamentValue())) {
                StoreParament commissionCheck = StoreParaUtils.getStorePara(baseStores1.getId(), Constant.commission_check_cash);
                if(commissionCheck.getParamentValue().trim().equals("1")) {
                    CashListResponse cashListResponse = new CashListResponse();
                    BeanUtils.copyProperties(cashList, cashListResponse);
                    List<AchiCommEntity> entities = new ArrayList<>();
                    //设置业务人员列表
                    if (null == cashList.getCourseAccountId()) { //是非疗程卡包收银
                        entities = this.getAchiCommLists(cashList, cashListResponse);
                        for (AchiCommEntity entity : entities) {
                            entity.setOrderType("");
                        }
                    } else { //卡包收银
                        entities = this.getAchiCommListsCard(cashList, cashListResponse);
                    }
                    BigDecimal CardAchi = entities.stream().map(AchiCommEntity::getCardAchi).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal CashAchi = entities.stream().map(AchiCommEntity::getCashAchi).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal CardComm = entities.stream().map(AchiCommEntity::getCardComm).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal CashComm = entities.stream().map(AchiCommEntity::getCashComm).reduce(BigDecimal.ZERO, BigDecimal::add);
                    if (CardAchi.add(CashAchi).compareTo(cashList.getTransactionPrice()) == 1) {
                        throw new SmsException(ResponseCode.MSG, "第" + count + "条收银项目[ " + cashList.getProjectNum() + "/" + cashList.getProjectName() + " ]业绩（" + CardAchi.add(CashAchi).setScale(2) + "）大于成交金额（" + cashList.getTransactionPrice() + ")");
                    }
                    if (CardComm.add(CashComm).compareTo(cashList.getTransactionPrice()) != -1) {
                        throw new SmsException(ResponseCode.MSG, "第" + count + "条收银项目[ " + cashList.getProjectNum() + "/" + cashList.getProjectName() + " ]提成（" + CardComm.add(CashComm).setScale(2) + "）大于等于成交金额（" + cashList.getTransactionPrice() + ")");
                    }
                }
            }


            cashList.setCourseMoney(courseMoney);
            //有主键ID 更新收银单据信息
            if (null != cashList.getId()) {
                try {
                    cashList.setRemark(cashListRequest.getRemark());

                    i = dao.doCash(cashList);
                } catch (Exception e) {
                    log.error("SsmRechargeServiceImpl.doCash:", e);
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
                }
            }else {
                //无主键ID 后续收银额外添加项目 添加收银单据信息
                cashList.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
                cashList.setRemark(cashListRequest.getRemark());
                try {
                    i = dao.addCash(cashList);
                } catch (Exception e) {
                    log.error("SsmRechargeServiceImpl.doCash:", e);
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
                }
            }
            if(null != cashListRequest.getSalesmens()){
                //添加高管的当前单据门店信息
                StoreRequest storeRequest = new StoreRequest();
                storeRequest.setId(storeId);
                BaseStore baseStore1 = ssmBaseStoreService.selectOne(storeRequest);

                List<Salesman> salesmens = cashListRequest.getSalesmens();
                BigDecimal reduce5 = salesmens.stream().filter(salesman -> salesman.getStaffType()==0).map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal reduce6 = salesmens.stream().filter(salesman -> salesman.getStaffType()==1).map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
                if(null != reduce5 && reduce5.compareTo(BigDecimal.valueOf(100))!=0 && reduce5.compareTo(BigDecimal.valueOf(0))!=0){
                    throw new SmsException(ResponseCode.MSG,"高管业绩占比和不等于100");
                }
                if(null != reduce6 && reduce6.compareTo(BigDecimal.valueOf(100))!=0 && reduce6.compareTo(BigDecimal.valueOf(0))!=0){
                    throw new SmsException(ResponseCode.MSG,"管理员业绩占比和不等于100");
                }
                for (Salesman salesmen : salesmens) {
                    Random r = new Random(3);
                    int i1 = r.nextInt();
                    salesmen.setId(salesmen.getId()+i1);
                    salesmen.setOrderId(String.valueOf(cashList.getId()));
                    salesmen.setOrderNum(cashList.getCashNum());
                    salesmen.setOrderType(0);
                    salesmen.setOrderDate(new Date());
                    salesmen.setState(0);
                    salesmen.setMoney(cashListRequest.getCollectionCashAmount());
                    salesmen.setProjectId(cashListRequest.getProjectId());
                    salesmen.setStoreNum(baseStore1.getStoreNum());
                    salesmen.setStoreName(baseStore1.getStoreName());
                    salesmen.setStoreIdOrder(baseStore1.getId());
                    salesmen.setOperatorBy(cashList.getInputBy());
                    salesmen.setIsAddition(cashList.getIsAddition());
                }
                ssmSalesmanService.addBatch(salesmens);
            }
            //充值卡付 扣减充值账户金额
            if (null != rechargeAccountList && rechargeAccountList.size() > 0) {
                //计算扣减金额 并添加账户交易记录
                list = ssmRechargeAccountService.subMoney(rechargeAccountList, cashList, list);
//                ssmCashAccountSrevice.add(rechargeAccountList,cashList);
            }
            //疗程卡付 扣减疗程账户次数
            CourseAccount courseAccount = new CourseAccount();
            if (null != cashList.getCourseAccountId()) {
                courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
//                ssmCourseAccountService.subCount(courseAccount, cashList.getNumberTimes(), 0);
                ssmCourseAccountService.subCountNew(courseAccount, cashList.getNumberTimes(), 0);
                //添加账户交易记录
                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, courseAccount);
                ssmAccountTradeRecordService.addRecord(accountTradeRecord);
                list.add(accountTradeRecord);

//                TransactionRecord transactionRecord = this.setTransactionRecord(cashList, courseAccount);
//                ssmTransactionRecordService.add(transactionRecord);
            }
            if(null != cashList.getCollectionCashAmount()){
                if(cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0))==1){
                    if (null == cashList.getCourseAccountId() && rechargeAccountList.size() == 0){
                        //添加账户交易记录
                        AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, null);
                        ssmAccountTradeRecordService.addRecord(accountTradeRecord);
                        list.add(accountTradeRecord);
                    }

                }
            }


//            //现付 添加现付记录
//            if (null != payLists && payLists.size() > 0) {
//                for (PayList payList : payLists) {
//                    payList.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
//                    payList.setDocId(cashList.getId());
//                    payList.setType(Constant.doc_type_store_cash);
//                }
//                ssmPayService.addPayList(payLists);
//                //添加账户交易记录
//                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, null);
//                ssmAccountTradeRecordService.addRecord(accountTradeRecord);
//                list.add(accountTradeRecord);
//            }

            //将服务单据信息添加到评价表
            MemberCsRequest memberCsRequest = new MemberCsRequest();
            BeanUtils.copyProperties(cashList, memberCsRequest);
            memberCsRequest.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
            memberCsRequest.setDocId(cashList.getId());
            memberCsRequest.setDocNum(cashList.getCashNum());
            memberCsRequest.setDocType(Constant.doc_type_store_cash);
            memberCsRequest.setDocDate(cashList.getCashDate());
            memberCsRequest.setTradeId(cashList.getProjectId());
            memberCsRequest.setTradeName(cashList.getProjectName());
            memberCsRequest.setTradeMoney(cashList.getTransactionPrice());
            memberCsRequest.setTradeCount(cashList.getNumberTimes());
            StringBuffer staffIds = new StringBuffer();
            StringBuffer staffNames = new StringBuffer();
            if (largeList.size() > 0 || zhonggongList.size() > 0 || technicianList.size() > 0 || smallList.size() > 0) {
                for (StaffRequest staffRequest : largeList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : zhonggongList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : technicianList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
                for (StaffRequest staffRequest : smallList) {
                    staffIds = staffIds.append(staffRequest.getId()).append(",");
                    staffNames = staffNames.append(staffRequest.getStaffName()).append(",");
                }
            }
            memberCsRequest.setStaffIds(staffIds.toString());
            memberCsRequest.setStaffNames(staffNames.toString());
            ssmMemberCsService.addMemberCs(memberCsRequest);

            BaseProject baseProject2 = new BaseProject();
            baseProject2.setOvertime("cash");
            baseProject2.setId(cashListRequest.getProjectId());
            int update = ssmProjectService.updateNotNull(baseProject2);
            if(update==0){
                throw new SmsException(ResponseCode.MSG,"收银异常");
            }
        }
        //将签名文件信息保存
        if (StringUtils.isNotBlank(cashSignatureFile.getFileName()) && StringUtils.isNotBlank(cashSignatureFile.getFilePath())) {
            cashSignatureFile.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
            cashSignatureFile.setCashNum(cashNum);
            ssmCashSignatureService.saveNotNull(cashSignatureFile);
        }

        //现付 添加现付记录
            if (null != cashListRequestList.get(0).getPayLists() && cashListRequestList.get(0).getPayLists().size() > 0) {
                //todo 判断补单算哪个日期的业绩
//                StoreParament storeParament = StoreParaUtils.getStorePara(storeId, Constant.ISADDITION);

//                BigDecimal cashMoneyTotal=BigDecimal.valueOf(0);
                for (PayList payList : cashListRequestList.get(0).getPayLists()) {
                    payList.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
                    payList.setDocId(cashNum);
                    payList.setType(Constant.doc_type_store_cash);
                    payList.setStoreId(storeId);
                    if(1==1){
                        payList.setPayDate(list.get(0).getAdditionDate());
                    }else {
                        payList.setPayDate(new Date());
                    }
                    payList.setIsCancel(0);
//                    cashMoneyTotal=cashMoneyTotal.add(payList.getPayMoney());
                }
//                if(cashMoneyTotal.compareTo(amountcash)!=0){
//                    throw new SmsException(ResponseCode.MSG,"应收现付与实际现付金额不相等");
//                }
                ssmPayService.addPayList(cashListRequestList.get(0).getPayLists());
                //添加账户交易记录
//                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, null);
//                ssmAccountTradeRecordService.addRecord(accountTradeRecord);
//                list.add(accountTradeRecord);

            }

        return list;
    }

    @Transactional(rollbackFor=Exception.class)
    @Override
    public int addCashList(CashList cashList) throws SmsException {
        int i = 0;
        try {
            //现付加卡付
            if(cashList.getCollectionAmount().equals("0")&&(cashList.getCollectionRechargeAmount().doubleValue()>0||cashList.getCashAmount().doubleValue()>0)){
                cashList.setCollectionAmount(String.valueOf(cashList.getCollectionRechargeAmount().add(cashList.getCashAmount())));
            }
            //是疗程卡付，对金额进行重新赋值
            if(cashList.getCourseAccountId()!=null){
                cashList.setAmount(cashList.getTransactionPrice().multiply(BigDecimal.valueOf(cashList.getCashNumber())));
                cashList.setCashAmount(cashList.getAmount());
                cashList.setCollectionAmount(cashList.getAmount().toString());
            }
            if(cashList.getIsAddition()==1){
                cashList.setCashDate(cashList.getAdditionDate());
            }
            i = dao.addCash(cashList);
        }catch (Exception e){
            log.error("SsmCashServiceImpl.addCashList:",e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
        }
        return i;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public List<AccountTradeRecord> addCashList(List<CashListRequest> listRequests, Long storeId, String storeName, String phone, CashSignatureFile cashSignatureFile) throws SmsException, ParseException {
        int i = 0;
        List<AccountTradeRecord> list = new ArrayList<>();
        //单据号
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setCashDate(new Date());
        cashListRequest.setSelectDate(DateUtils.YMFormat(new Date()));
        cashListRequest.setStoreId(storeId);
        String docNum = this.getDocNum(cashListRequest,null);
        //查询最低价控制门店参数
        StoreParament storeParament = StoreParaUtils.getStorePara(storeId, Constant.minimum);
        for (CashListRequest listRequest : listRequests) {
            //有最低价控制  校验成交单价
            if ("1".equals(storeParament.getParamentValue())){
                //会员最低价校验
                if (null != listRequest.getMemberId() && BigDecimalUtils.compareTo(listRequest.getTransactionPrice(),listRequest.getMinumumPriceMember()) == -1){
                    throw new SmsException(ResponseCode.MINUMUM_PRICE_LOW,"成交价");
                }else if (null == listRequest.getMemberId() && BigDecimalUtils.compareTo(listRequest.getTransactionPrice(),listRequest.getMinumumPrice()) == -1){
                    //散客最低价校验
                    throw new SmsException(ResponseCode.MINUMUM_PRICE_LOW,"成交价");
                }
            }
            CashList cashList = new CashList();
            //设置开单时间
            listRequest.setCashDate(cashListRequest.getCashDate());
            //不走补单 正常开单 补单时间默认为开单时间
            if (0 == listRequest.getIsAddition()) {
                listRequest.setAdditionDate(new Date());
            }
            listRequest.setStoreId(storeId);
            listRequest.setStoreName(storeName);
            BeanUtils.copyProperties(listRequest,cashList);

            //主键ID
            Long cashId = new SnowflakeUtil(new Random().nextInt(1023)).nextId();
            cashList.setId(cashId);
            //单据号不存在 直接赋值 单据号存在 即当前单据增加项目 单据号不变
            if (null == listRequest.getCashNum()) {
                cashList.setCashNum(docNum);
            }
            i = this.addCashList(cashList);
            //重新给参数list添加ID 方便查询
            listRequest.setId(cashId);
        }
        if (i > 0){
            list = this.doCashSalem(listRequests,phone, cashSignatureFile,storeId);
        }
        return list;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public List<AccountTradeRecord> addCash(List<CashListRequest> listRequests, Long storeId, String storeName, String phone, CashSignatureFile cashSignatureFile) throws SmsException, ParseException {
        int i = 0;

        List<AccountTradeRecord> list = new ArrayList<>();
        //单据号
        CashListRequest cashListRequest = new CashListRequest();

        cashListRequest.setCashDate(new Date());
        cashListRequest.setSelectDate(DateUtils.YMFormat(new Date()));
        cashListRequest.setStoreId(storeId);

        String storeNUm=ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId()).getStoreNum();
        if(listRequests.get(0).getIsAddition()==1){
            cashListRequest.setCashDate(listRequests.get(0).getAdditionDate());
            cashListRequest.setSelectDate(DateUtils.YMFormat(listRequests.get(0).getAdditionDate()));
        }
        String docNum = this.getDocNum(cashListRequest,storeNUm);
        //查询最低价控制门店参数
        StoreParament storeParament = StoreParaUtils.getStorePara(storeId, Constant.minimum);
//        StoreParament storeParament1 = new StoreParament();
//        storeParament1.setStoreId(storeId);
//        storeParament1.setParamentName("balance");
//        storeParament1 = ssmStoreParaService.selectOne(storeParament1);
//        //容差，五毛钱
//        BigDecimal balance = new BigDecimal(storeParament1.getParamentValue());

        for (CashListRequest listRequest : listRequests) {
            BigDecimal collectionGiftAmount1=new BigDecimal("0");
            //赠送卡支付金额
            if(listRequest.getRechargeAccountList().size()>0&&listRequest.getRechargeAccountList()!=null){
               for(RechargeAccountRequest rechargeAccountRequest:listRequest.getRechargeAccountList()){
                   if(rechargeAccountRequest.getGiftSpendMoney()!=null);
                   collectionGiftAmount1=collectionGiftAmount1.add(rechargeAccountRequest.getGiftSpendMoney());
               }
            }
            listRequest.setCollectionGiftAmount(collectionGiftAmount1);

            if(null == listRequest.getCourseAccountId()){
                //有最低价控制  校验成交单价
                if ("1".equals(storeParament.getParamentValue())){
                    //会员最低价校验
                    if (null != listRequest.getMemberId() && BigDecimalUtils.compareTo(listRequest.getTransactionPrice(),listRequest.getMinumumPriceMember()) == -1){
                        throw new SmsException(ResponseCode.MINUMUM_PRICE_LOW,"成交价");
                    }else if (null == listRequest.getMemberId() && BigDecimalUtils.compareTo(listRequest.getTransactionPrice(),listRequest.getMinumumPrice()) == -1){
                        //散客最低价校验
                        throw new SmsException(ResponseCode.MINUMUM_PRICE_LOW,"成交价");
                    }
                }
            }

            CashList cashList = new CashList();

            //设置开单时间
            listRequest.setCashDate(cashListRequest.getCashDate());
            //不走补单 正常开单 补单时间默认为开单时间
            if (0 == listRequest.getIsAddition()) {
                listRequest.setAdditionDate(new Date());
            }
            listRequest.setStoreId(storeId);
            listRequest.setStoreName(storeName);
            BeanUtils.copyProperties(listRequest,cashList);

            //主键ID
            Long cashId = new SnowflakeUtil(new Random().nextInt(1023)).nextId();
            cashList.setId(cashId);
            //单据号不存在 直接赋值 单据号存在 即当前单据增加项目 单据号不变
            if (null == listRequest.getCashNum()) {
                cashList.setCashNum(docNum);
            }
            i = this.addCashList(cashList);
            //重新给参数list添加ID 方便查询
            listRequest.setId(cashId);
        }
        if (i > 0){
            list = this.doCashsj(listRequests,phone, cashSignatureFile,storeId);
        }
        return list;
    }

    /*
    * 设置业务员
    * */
    public CashList setStaffValue(List<StaffRequest> largeList, List<StaffRequest> zhonggongList, List<StaffRequest> technicianList, List<StaffRequest> smallList, CashList cashList){
        //大工
        if (null != largeList && largeList.size() > 0){
            for (int i = 0; i < largeList.size(); i++) {
                StaffRequest staffRequest = largeList.get(i);
                if (i == 0){
                    cashList.setServiceLargeOneStaffId(staffRequest.getId());
                    cashList.setServiceLargeOneStaffName(staffRequest.getStaffName());
                    cashList.setServiceLargeOneIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceLargeOneRatio(staffRequest.getRatio());
                    cashList.setLargeOneNumber(staffRequest.getBrandNumber());
                }else if (i == 1){
                    cashList.setServiceLargeTwoStaffId(staffRequest.getId());
                    cashList.setServiceLargeTwoStaffName(staffRequest.getStaffName());
                    cashList.setServiceLargeTwoIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceLargeTwoRatio(staffRequest.getRatio());
                    cashList.setLargeTwoNumber(staffRequest.getBrandNumber());
                }else if (i == 2){
                    cashList.setServiceLargeThreeStaffId(staffRequest.getId());
                    cashList.setServiceLargeThreeStaffName(staffRequest.getStaffName());
                    cashList.setServiceLargeThreeIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceLargeThreeRatio(staffRequest.getRatio());
                    cashList.setLargeThreeNumber(staffRequest.getBrandNumber());
                }else if (i == 3){
                    cashList.setServiceLargeFourStaffId(staffRequest.getId());
                    cashList.setServiceLargeFourStaffName(staffRequest.getStaffName());
                    cashList.setServiceLargeFourIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceLargeFourRatio(staffRequest.getRatio());
                    cashList.setLargeFourNumber(staffRequest.getBrandNumber());
                }else if (i == 4){
                    cashList.setServiceLargeFiveStaffId(staffRequest.getId());
                    cashList.setServiceLargeFiveStaffName(staffRequest.getStaffName());
                    cashList.setServiceLargeFiveIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceLargeFiveRatio(staffRequest.getRatio());
                    cashList.setLargeFiveNumber(staffRequest.getBrandNumber());
                }
            }
        }
        //中工
        if (null != zhonggongList&& zhonggongList.size() > 0){
            for (int i = 0; i < zhonggongList.size(); i++) {
                StaffRequest staffRequest = zhonggongList.get(i);
                if (i == 0){
                    cashList.setServiceZhonggongOneStaffId(staffRequest.getId());
                    cashList.setServiceZhonggongOneStaffName(staffRequest.getStaffName());
                    cashList.setServiceZhonggongOneIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceZhonggongOneRatio(staffRequest.getRatio());
                    cashList.setZhonggongOneNumber(staffRequest.getBrandNumber());
                }else if (i == 1){
                    cashList.setServiceZhonggongTwoStaffId(staffRequest.getId());
                    cashList.setServiceZhonggongTwoStaffName(staffRequest.getStaffName());
                    cashList.setServiceZhonggongTwoIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceZhonggongTwoRatio(staffRequest.getRatio());
                    cashList.setZhonggongTwoNumber(staffRequest.getBrandNumber());
                }else if (i == 2){
                    cashList.setServiceZhonggongThreeStaffId(staffRequest.getId());
                    cashList.setServiceZhonggongThreeStaffName(staffRequest.getStaffName());
                    cashList.setServiceZhonggongThreeIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceZhonggongThreeRatio(staffRequest.getRatio());
                    cashList.setZhonggongThreeNumber(staffRequest.getBrandNumber());
                }else if (i == 3){
                    cashList.setServiceZhonggongFourStaffId(staffRequest.getId());
                    cashList.setServiceZhonggongFourStaffName(staffRequest.getStaffName());
                    cashList.setServiceZhonggongFourIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceZhonggongFourRatio(staffRequest.getRatio());
                    cashList.setZhonggongFourNumber(staffRequest.getBrandNumber());
                }else if (i == 4){
                    cashList.setServiceZhonggongFiveStaffId(staffRequest.getId());
                    cashList.setServiceZhonggongFiveStaffName(staffRequest.getStaffName());
                    cashList.setServiceZhonggongFiveIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceZhonggongFiveRatio(staffRequest.getRatio());
                    cashList.setZhonggongFiveNumber(staffRequest.getBrandNumber());
                }
            }
        }
        //技师
        if (null != technicianList&& technicianList.size() > 0){
            for (int i = 0; i < technicianList.size(); i++) {
                StaffRequest staffRequest = technicianList.get(i);
                if (i == 0){
                    cashList.setServiceTechnicianOneStaffId(staffRequest.getId());
                    cashList.setServiceTechnicianOneStaffName(staffRequest.getStaffName());
                    cashList.setServiceTechnicianOneIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceTechnicianOneRatio(staffRequest.getRatio());
                    cashList.setTechnicianOneNumber(staffRequest.getBrandNumber());
                }else if (i == 1){
                    cashList.setServiceTechnicianTwoStaffId(staffRequest.getId());
                    cashList.setServiceTechnicianTwoStaffName(staffRequest.getStaffName());
                    cashList.setServiceTechnicianTwoIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceTechnicianTwoRatio(staffRequest.getRatio());
                    cashList.setTechnicianTwoNumber(staffRequest.getBrandNumber());
                }else if (i == 2){
                    cashList.setServiceTechnicianThreeStaffId(staffRequest.getId());
                    cashList.setServiceTechnicianThreeStaffName(staffRequest.getStaffName());
                    cashList.setServiceTechnicianThreeIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceTechnicianThreeRatio(staffRequest.getRatio());
                    cashList.setTechnicianThreeNumber(staffRequest.getBrandNumber());
                }
            }
        }

        //小工
        if (null != smallList&& smallList.size() > 0){
            for (int i = 0; i < smallList.size(); i++) {
                StaffRequest staffRequest = smallList.get(i);
                if (i == 0){
                    cashList.setServiceSmallOneStaffId(staffRequest.getId());
                    cashList.setServiceSmallOneStaffName(staffRequest.getStaffName());
                    cashList.setServiceSmallOneIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceSmallOneRatio(staffRequest.getRatio());
                    cashList.setSmallOneNumber(staffRequest.getBrandNumber());
                }else if (i == 1){
                    cashList.setServiceSmallTwoStaffId(staffRequest.getId());
                    cashList.setServiceSmallTwoStaffName(staffRequest.getStaffName());
                    cashList.setServiceSmallTwoIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceSmallTwoRatio(staffRequest.getRatio());
                    cashList.setSmallTwoNumber(staffRequest.getBrandNumber());
                }else if (i == 2){
                    cashList.setServiceSmallThreeStaffId(staffRequest.getId());
                    cashList.setServiceSmallThreeStaffName(staffRequest.getStaffName());
                    cashList.setServiceSmallThreeIdentityCard(staffRequest.getIdentityCard());
                    cashList.setServiceSmallThreeRatio(staffRequest.getRatio());
                    cashList.setSmallThreeNumber(staffRequest.getBrandNumber());
                }
            }
        }
        return cashList;
    }

    /*
    * 设置业绩提成
    * */
    public CashList setAchiComm(CashList cashList, List<RechargeAccountRequest> rechargeAccountRequestList, List<PayList> payLists, CashListRequest cashListRequest){
        StoreParament integralPara = StoreParaUtils.getStorePara(cashList.getStoreId(),Constant.member_integral);
        StoreParament storeParament = new StoreParament();
        if ("1".equals(integralPara.getParamentValue())){
            storeParament = StoreParaUtils.getStorePara(cashList.getStoreId(),"integral");
        }
        BaseProject project = ssmProjectService.selectByPrimaryKey(cashList.getProjectId());
        //合作项目抽佣比例
        BigDecimal cooperationRatio= BigDecimal.valueOf(0.00);
        if(null!=project){
            cooperationRatio= project.getBrokerage();
        }
        //现付 或者存在积分付
        if (null != payLists && payLists.size() > 0 || BigDecimalUtils.compareTo(cashList.getCollectionIntegralAmount(), BigDecimalUtils.bigDecimal("0")) == 1 && project.getIsCooperation() == 0) {
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付大工业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(), BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount())));
                    } else {
                        cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(), cashList.getCollectionCashAmount()));
                    }
                } else {
                    //固定金额
                    //积分付计入现付大工业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getCommissionLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付大工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(), cashList.getLargeAchievementAmount()));
//                    } else {
                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(), cashList.getLargeAchievementAmount()));
//                    }
                } else {
                    //固定金额
                    //积分付计入现付大工提成
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
            }
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                if (BigDecimalUtils.compareTo(cashList.getAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(), BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount())));
                    } else {
                        cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(), cashList.getCollectionCashAmount()));
                    }
                } else {
                    //积分付计入现付中工业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }

                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getCommissionZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付中工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(), cashList.getZhonggongAchievementAmount()));
//                    } else {
                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(), cashList.getZhonggongAchievementAmount()));
//                    }
                } else {
                    //固定金额
                    //积分付计入现付中工提成
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
            }

            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {
                if (BigDecimalUtils.compareTo(cashList.getAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(), BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount())));
                    } else {
                        cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(), cashList.getCollectionCashAmount()));
                    }
                } else {
                    //积分付计入现付技师业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getCommissionTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付技师提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(), cashList.getTechnicianAchievementAmount()));
//                    } else {
                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(), cashList.getTechnicianAchievementAmount()));
//                    }
                } else {
                    //固定金额
                    //积分付计入现付技师提成
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
            }
            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {
                if (BigDecimalUtils.compareTo(cashList.getAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(), BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount())));
                    } else {
                        cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(), cashList.getCollectionCashAmount()));
                    }
                } else {
                    //积分付计入现付小工业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getCommissionSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付小工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(), cashList.getSmallAchievementAmount()));
//                    } else {
                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(), cashList.getSmallAchievementAmount()));
//                    }
                } else {
                    //固定金额
                    //积分付计入现付小工提成
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
            }

        }

        //现付 或者存在积分付  合作项目
        if (null != payLists && payLists.size() > 0 || BigDecimalUtils.compareTo(cashList.getCollectionIntegralAmount(), BigDecimalUtils.bigDecimal("0")) == 1 && project.getIsCooperation() == 1) {
            if(project.getIsCooperation() == 1){
                //大工
                if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付大工业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(), BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio)));
                        } else {
                            cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(), BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio)));
                        }
                    } else {
                        //固定金额
                        //积分付计入现付大工业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getCommissionLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付大工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(), cashList.getLargeAchievementAmount()));
//                    } else {
                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(), cashList.getLargeAchievementAmount()));
//                    }
                    } else {
                        //固定金额
                        //积分付计入现付大工提成
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                }
                //中工
                if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                    if (BigDecimalUtils.compareTo(cashList.getAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(), BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio)));
                        } else {
                            cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(), BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio)));
                        }
                    } else {
                        //积分付计入现付中工业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }

                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getCommissionZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付中工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(), cashList.getZhonggongAchievementAmount()));
//                    } else {
                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(), cashList.getZhonggongAchievementAmount()));
//                    }
                    } else {
                        //固定金额
                        //积分付计入现付中工提成
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }

                    }
                }
                //技师
                if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {
                    if (BigDecimalUtils.compareTo(cashList.getAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(), BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio)));
                        } else {
                            cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(), BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio)));
                        }
                    } else {
                        //积分付计入现付技师业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getCommissionTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付技师提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(), cashList.getTechnicianAchievementAmount()));
//                    } else {
                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(), cashList.getTechnicianAchievementAmount()));
//                    }
                    } else {
                        //固定金额
                        //积分付计入现付技师提成
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                }
                //小工
                if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {
                    if (BigDecimalUtils.compareTo(cashList.getAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(), BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio)));
                        } else {
                            cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(), BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio)));
                        }
                    } else {
                        //积分付计入现付小工业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getCommissionSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付小工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(), cashList.getSmallAchievementAmount()));
//                    } else {
                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(), cashList.getSmallAchievementAmount()));
//                    }
                    } else {
                        //固定金额
                        //积分付计入现付小工提成
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                }

            }

        }

        //充值卡付
        if (null != rechargeAccountRequestList && rechargeAccountRequestList.size() > 0 && project.getIsCooperation() == 0){
           //大工
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //大工卡付业绩计算
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(), cashList.getCollectionRechargeAmount()));
                } else {
                    //固定金额
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionLarge(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //大工卡付提成计算
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),cashList.getCardLargeAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
            }
            //中工
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //中工卡付业绩计算
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), cashList.getCollectionRechargeAmount()));
                } else {
                    //固定金额
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionZhonggong(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //中工卡付提成计算
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),cashList.getCardZhonggongAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
            }
            //技师
            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //技师卡付业绩计算
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), cashList.getCollectionRechargeAmount()));
                } else {
                    //固定金额
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionTechnician(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //技师卡付提成计算
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),cashList.getCardTechnicianAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
            }

            //小工
            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //小工卡付业绩计算
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), cashList.getCollectionRechargeAmount()));
                } else {
                    //固定金额
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionSmall(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //小工卡付提成计算
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),cashList.getCardSmallAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
            }

        }

        //充值卡付  合作项目
        if (null != rechargeAccountRequestList && rechargeAccountRequestList.size() > 0 && project.getIsCooperation() == 1){
            //大工
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //大工卡付业绩计算
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(), BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionLarge(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //大工卡付提成计算
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),cashList.getCardLargeAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
            }
            //中工
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //中工卡付业绩计算
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionZhonggong(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //中工卡付提成计算
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),cashList.getCardZhonggongAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
            }
            //技师
            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //技师卡付业绩计算
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionTechnician(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //技师卡付提成计算
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),cashList.getCardTechnicianAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
            }

            //小工
            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //小工卡付业绩计算
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionSmall(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //小工卡付提成计算
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),cashList.getCardSmallAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
            }

        }

        //疗程卡付
        if (null != cashList.getCourseAccountId() && project.getIsCooperation() == 0){
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //大工卡付业绩计算
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(), cashList.getAmount()));
                } else {
                    //固定金额
                    cashList.setCardLargeAchievementAmount(cashList.getCardAchievementLarge());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionLarge(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //大工卡付提成计算
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),cashList.getCardLargeAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardLargeCommissionAmount(cashList.getCardCommissionLarge());
                }
            }
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //中工卡付业绩计算
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), cashList.getAmount()));
                } else {
                    //固定金额
                    cashList.setCardZhonggongAchievementAmount(cashList.getCardAchievementZhonggong());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionZhonggong(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //中工卡付提成计算
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),cashList.getCardZhonggongAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardZhonggongCommissionAmount(cashList.getCardCommissionZhonggong());
                }
            }

            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //技师卡付业绩计算
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), cashList.getAmount()));
                } else {
                    //固定金额
                    cashList.setCardTechnicianAchievementAmount(cashList.getCardAchievementTechnician());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionTechnician(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //技师卡付提成计算
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),cashList.getCardTechnicianAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardTechnicianCommissionAmount(cashList.getCardCommissionTechnician());
                }
            }

            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //小工卡付业绩计算
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), cashList.getAmount()));
                } else {
                    //固定金额
                    cashList.setCardSmallAchievementAmount(cashList.getCardAchievementSmall());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionSmall(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //小工卡付提成计算
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),cashList.getCardSmallAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardSmallCommissionAmount(cashList.getCardCommissionSmall());
                }
            }
        }

        //疗程卡付 合作项目
        if (null != cashList.getCourseAccountId() && project.getIsCooperation() == 1){
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //大工卡付业绩计算
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(), BigDecimalUtils.multiply(cashList.getAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardLargeAchievementAmount(cashList.getCardAchievementLarge());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionLarge(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //大工卡付提成计算
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),cashList.getCardLargeAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardLargeCommissionAmount(cashList.getCardCommissionLarge());
                }
            }
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //中工卡付业绩计算
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), BigDecimalUtils.multiply(cashList.getAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardZhonggongAchievementAmount(cashList.getCardAchievementZhonggong());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionZhonggong(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //中工卡付提成计算
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),cashList.getCardZhonggongAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardZhonggongCommissionAmount(cashList.getCardCommissionZhonggong());
                }
            }

            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //技师卡付业绩计算
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), BigDecimalUtils.multiply(cashList.getAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardTechnicianAchievementAmount(cashList.getCardAchievementTechnician());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionTechnician(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //技师卡付提成计算
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),cashList.getCardTechnicianAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardTechnicianCommissionAmount(cashList.getCardCommissionTechnician());
                }
            }

            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //小工卡付业绩计算
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), BigDecimalUtils.multiply(cashList.getAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardSmallAchievementAmount(cashList.getCardAchievementSmall());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionSmall(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //小工卡付提成计算
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),cashList.getCardSmallAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardSmallCommissionAmount(cashList.getCardCommissionSmall());
                }
            }
        }
        return cashList;
    }

    public CashList setAchiCommCash(CashList cashList, List<RechargeAccountRequest> rechargeAccountRequestList, BigDecimal collectionCashAmount, CashListRequest cashListRequest){
             //卡付金额+赠送支付金额
        if( cashList.getCollectionRechargeAmount()!=null){
//            cashList.setCollectionRechargeAmount( cashList.getCollectionRechargeAmount().add( cashList.getCollectionGiftAmount()));
            cashList.setCollectionRechargeAmount( cashList.getCollectionRechargeAmount());
        }

        StoreParament integralPara = StoreParaUtils.getStorePara(cashList.getStoreId(),Constant.member_integral);
        StoreParament storeParament = new StoreParament();
        if ("1".equals(integralPara.getParamentValue())){
            storeParament = StoreParaUtils.getStorePara(cashList.getStoreId(),"integral");
        }
        BaseProject project = ssmProjectService.selectByPrimaryKey(cashList.getProjectId());
        //合作项目抽佣比例
        BigDecimal cooperationRatio= BigDecimal.valueOf(0.00);

        //现付 或者存在积分付
        if (BigDecimalUtils.compareTo(collectionCashAmount, BigDecimalUtils.bigDecimal("0")) == 1||BigDecimalUtils.compareTo(cashList.getCollectionIntegralAmount(), BigDecimalUtils.bigDecimal("0")) == 1 && project.getIsCooperation() == 0) {
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付大工业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(), BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount())));
                    } else {
                        cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(), cashList.getCollectionCashAmount()));
                    }
                } else {
                    //固定金额
                    //积分付计入现付大工业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getCommissionLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付大工提成
                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(), cashList.getLargeAchievementAmount()));
                } else {
                    //固定金额
                    //积分付计入现付大工提成
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
            }
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                if (BigDecimalUtils.compareTo((cashList.getAchievementZhonggong()==null?new BigDecimal("0"):cashList.getAchievementZhonggong()), BigDecimalUtils.bigDecimal("1")) != 1) {
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply((cashList.getAchievementZhonggong()==null?new BigDecimal("0"):cashList.getAchievementZhonggong()), BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount())));
                    } else {
                        cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply((cashList.getAchievementZhonggong()==null?new BigDecimal("0"):cashList.getAchievementZhonggong()), cashList.getCollectionCashAmount()));
                    }
                } else {
                    //积分付计入现付中工业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }

                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getCommissionZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付中工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(), cashList.getZhonggongAchievementAmount()));
//                    } else {
                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(), cashList.getZhonggongAchievementAmount()));
//                    }
                } else {
                    //固定金额
                    //积分付计入现付中工提成
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
            }

            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {
                if (BigDecimalUtils.compareTo(cashList.getAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(), BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount())));
                    } else {
                        cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(), cashList.getCollectionCashAmount()));
                    }
                } else {
                    //积分付计入现付技师业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getCommissionTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付技师提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(), cashList.getTechnicianAchievementAmount()));
//                    } else {
                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(), cashList.getTechnicianAchievementAmount()));
//                    }
                } else {
                    //固定金额
                    //积分付计入现付技师提成
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
            }
            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {
                if (BigDecimalUtils.compareTo(cashList.getAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(), BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount())));
                    } else {
                        cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(), cashList.getCollectionCashAmount()));
                    }
                } else {
                    //积分付计入现付小工业绩
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
                //按比例计算
                if (BigDecimalUtils.compareTo(cashList.getCommissionSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //积分付计入现付小工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(), cashList.getSmallAchievementAmount()));
//                    } else {
                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(), cashList.getSmallAchievementAmount()));
//                    }
                } else {
                    //固定金额
                    //积分付计入现付小工提成
                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(),
                                BigDecimalUtils.div(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()), cashList.getAmount())));
                    }else {
                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(),
                                BigDecimalUtils.div(cashList.getCollectionCashAmount(), cashList.getAmount())));
                    }
                }
            }

        }

        //现付 或者存在积分付  合作项目
        if (BigDecimalUtils.compareTo(collectionCashAmount, BigDecimalUtils.bigDecimal("0")) == 1 ||BigDecimalUtils.compareTo(cashList.getCollectionIntegralAmount(), BigDecimalUtils.bigDecimal("0")) == 1 && project.getIsCooperation() == 1) {
            if(project.getIsCooperation() == 1){
                //大工
                if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付大工业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(), BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio)));
                        } else {
                            cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(), BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio)));
                        }
                    } else {
                        //固定金额
                        //积分付计入现付大工业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementLarge(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getCommissionLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付大工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(), cashList.getLargeAchievementAmount()));
//                    } else {
                        cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(), cashList.getLargeAchievementAmount()));
//                    }
                    } else {
                        //固定金额
                        //积分付计入现付大工提成
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionLarge(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                }
                //中工
                if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                    if (BigDecimalUtils.compareTo(cashList.getAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            if(project.getSmokeCommissionWay()==0){//合作固定
                                cashList.setZhonggongAchievementAmount(cooperationRatio);
                            }else{//比例
                                cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(), BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio)));
                            }
                        } else {
                            if(project.getSmokeCommissionWay()==0){//合作固定
                                cashList.setZhonggongAchievementAmount(cooperationRatio);
                            }else{//比例
                                cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(), BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio)));
                            }
                        }
                    } else {
                        //积分付计入现付中工业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            if(project.getSmokeCommissionWay()==0){//合作固定
                                cashList.setZhonggongAchievementAmount(cooperationRatio);
                            }else{//比例
                                cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(),
                                        BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                            }


                        }else {
                            if(project.getSmokeCommissionWay()==0){//合作固定
                                cashList.setZhonggongAchievementAmount(cooperationRatio);
                            }else{//比例
                                cashList.setZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementZhonggong(),
                                        BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                            }
                        }
                    }

                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getCommissionZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付中工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(), cashList.getZhonggongAchievementAmount()));
//                    } else {
                        cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(), cashList.getZhonggongAchievementAmount()));
//                    }
                    } else {
                        //固定金额
                        //积分付计入现付中工提成
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionZhonggong(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }

                    }
                }
                //技师
                if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {
                    if (BigDecimalUtils.compareTo(cashList.getAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(), BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio)));
                        } else {
                            cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(), BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio)));
                        }
                    } else {
                        //积分付计入现付技师业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementTechnician(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getCommissionTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付技师提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(), cashList.getTechnicianAchievementAmount()));
//                    } else {
                        cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(), cashList.getTechnicianAchievementAmount()));
//                    }
                    } else {
                        //固定金额
                        //积分付计入现付技师提成
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionTechnician(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                }
                //小工
                if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {
                    if (BigDecimalUtils.compareTo(cashList.getAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(), BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio)));
                        } else {
                            cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(), BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio)));
                        }
                    } else {
                        //积分付计入现付小工业绩
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getAchievementSmall(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                    //按比例计算
                    if (BigDecimalUtils.compareTo(cashList.getCommissionSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                        //积分付计入现付小工提成
//                    if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
//                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(), cashList.getSmallAchievementAmount()));
//                    } else {
                        cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(), cashList.getSmallAchievementAmount()));
//                    }
                    } else {
                        //固定金额
                        //积分付计入现付小工提成
                        if (null != storeParament.getParamentValue() && "0".equals(storeParament.getParamentValue())) {
                            cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(BigDecimalUtils.add(cashList.getCollectionCashAmount(), cashList.getCollectionIntegralAmount()),cooperationRatio), cashList.getAmount())));
                        }else {
                            cashList.setSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCommissionSmall(),
                                    BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionCashAmount(),cooperationRatio), cashList.getAmount())));
                        }
                    }
                }


            }

        }

        //充值卡付
        if (null != rechargeAccountRequestList && rechargeAccountRequestList.size() > 0 && project.getIsCooperation() == 0){
           //大工
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //大工卡付业绩计算
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(), cashList.getCollectionRechargeAmount()));
                } else {
                    //固定金额
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionLarge(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //大工卡付提成计算
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),cashList.getCardLargeAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
            }
            //中工
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //中工卡付业绩计算
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), cashList.getCollectionRechargeAmount()));
                } else {
                    //固定金额
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionZhonggong(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //中工卡付提成计算
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),cashList.getCardZhonggongAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
            }
            //技师
            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //技师卡付业绩计算
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), cashList.getCollectionRechargeAmount()));
                } else {
                    //固定金额
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionTechnician(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //技师卡付提成计算
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),cashList.getCardTechnicianAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
            }

            //小工
            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //小工卡付业绩计算
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), cashList.getCollectionRechargeAmount()));
                } else {
                    //固定金额
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionSmall(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //小工卡付提成计算
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),cashList.getCardSmallAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),
                            BigDecimalUtils.div(cashList.getCollectionRechargeAmount(), cashList.getAmount())));
                }
            }

        }

        //充值卡付  合作项目
        if (null != rechargeAccountRequestList && rechargeAccountRequestList.size() > 0 && project.getIsCooperation() == 1){
            //大工
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //大工卡付业绩计算
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(), BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionLarge(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //大工卡付提成计算
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),cashList.getCardLargeAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
            }
            //中工
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //中工卡付业绩计算
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionZhonggong(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //中工卡付提成计算
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),cashList.getCardZhonggongAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
            }
            //技师
            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //技师卡付业绩计算
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionTechnician(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //技师卡付提成计算
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),cashList.getCardTechnicianAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
            }

            //小工
            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //小工卡付业绩计算
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionSmall(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //小工卡付提成计算
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),cashList.getCardSmallAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),
                            BigDecimalUtils.div(BigDecimalUtils.multiply(cashList.getCollectionRechargeAmount(),cooperationRatio), cashList.getAmount())));
                }
            }

        }

        //疗程卡付
        if (null != cashList.getCourseAccountId() && project.getIsCooperation() == 0){
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //大工卡付业绩计算
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(), cashList.getAmount()));
                } else {
                    //固定金额
                    cashList.setCardLargeAchievementAmount(cashList.getCardAchievementLarge());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionLarge(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //大工卡付提成计算
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),cashList.getCardLargeAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardLargeCommissionAmount(cashList.getCardCommissionLarge());
                }
            }
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //中工卡付业绩计算
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), cashList.getAmount()));
                } else {
                    //固定金额
                    cashList.setCardZhonggongAchievementAmount(cashList.getCardAchievementZhonggong());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionZhonggong(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //中工卡付提成计算
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),cashList.getCardZhonggongAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardZhonggongCommissionAmount(cashList.getCardCommissionZhonggong());
                }
            }

            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //技师卡付业绩计算
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), cashList.getAmount()));
                } else {
                    //固定金额
                    cashList.setCardTechnicianAchievementAmount(cashList.getCardAchievementTechnician());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionTechnician(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //技师卡付提成计算
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),cashList.getCardTechnicianAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardTechnicianCommissionAmount(cashList.getCardCommissionTechnician());
                }
            }

            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //小工卡付业绩计算
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), cashList.getAmount()));
                } else {
                    //固定金额
                    cashList.setCardSmallAchievementAmount(cashList.getCardAchievementSmall());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionSmall(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //小工卡付提成计算
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),cashList.getCardSmallAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardSmallCommissionAmount(cashList.getCardCommissionSmall());
                }
            }
        }

        //疗程卡付 合作项目
        if (null != cashList.getCourseAccountId() && project.getIsCooperation() == 1){
            if (cashListRequest.getLargeList() != null && cashListRequest.getLargeList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementLarge(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //大工卡付业绩计算
                    cashList.setCardLargeAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementLarge(), BigDecimalUtils.multiply(cashList.getAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardLargeAchievementAmount(cashList.getCardAchievementLarge());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionLarge(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //大工卡付提成计算
                    cashList.setCardLargeCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionLarge(),cashList.getCardLargeAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardLargeCommissionAmount(cashList.getCardCommissionLarge());
                }
            }
            if (cashListRequest.getZhonggongList() != null && cashListRequest.getZhonggongList().size() > 0) {
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementZhonggong(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //中工卡付业绩计算
                    cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementZhonggong(), BigDecimalUtils.multiply(cashList.getAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardZhonggongAchievementAmount(cashList.getCardAchievementZhonggong());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionZhonggong(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //中工卡付提成计算
                    cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionZhonggong(),cashList.getCardZhonggongAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardZhonggongCommissionAmount(cashList.getCardCommissionZhonggong());
                }
            }

            if (cashListRequest.getTechnicianList() != null && cashListRequest.getTechnicianList().size() > 0) {

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementTechnician(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //技师卡付业绩计算
                    cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementTechnician(), BigDecimalUtils.multiply(cashList.getAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardTechnicianAchievementAmount(cashList.getCardAchievementTechnician());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionTechnician(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //技师卡付提成计算
                    cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionTechnician(),cashList.getCardTechnicianAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardTechnicianCommissionAmount(cashList.getCardCommissionTechnician());
                }
            }

            if (cashListRequest.getSmallList() != null && cashListRequest.getSmallList().size() > 0) {

                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardAchievementSmall(), BigDecimalUtils.bigDecimal("1")) != 1) {
                    //小工卡付业绩计算
                    cashList.setCardSmallAchievementAmount(BigDecimalUtils.multiply(cashList.getCardAchievementSmall(), BigDecimalUtils.multiply(cashList.getAmount(),cooperationRatio)));
                } else {
                    //固定金额
                    cashList.setCardSmallAchievementAmount(cashList.getCardAchievementSmall());
                }
                //按比例
                if (BigDecimalUtils.compareTo(cashList.getCardCommissionSmall(),BigDecimalUtils.bigDecimal("1")) != 1){
                    //小工卡付提成计算
                    cashList.setCardSmallCommissionAmount(BigDecimalUtils.multiply(cashList.getCardCommissionSmall(),cashList.getCardSmallAchievementAmount()));
                }else {
                    //固定金额
                    cashList.setCardSmallCommissionAmount(cashList.getCardCommissionSmall());
                }
            }
        }
        return cashList;
    }


    /*
    * 查询门店参数
    * */
    public StoreParament getStorePara(Long storeId,String key){
        StoreParament storeParament = new StoreParament();
        storeParament.setStoreId(storeId);
        storeParament.setParamentName(key);
        storeParament = ssmStoreParaService.selectOne(storeParament);
        return storeParament;
    }

    /*
     * 账户交易记录属性赋值 疗程付 现付
     * */
    public TransactionRecord setTransactionRecord(CashList cashList,CourseAccount courseAccount){
        TransactionRecord accountTradeRecord = new TransactionRecord();
        accountTradeRecord.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
        accountTradeRecord.setStoreId(cashList.getStoreId());
        accountTradeRecord.setStoreName(cashList.getStoreName());
        accountTradeRecord.setMemberId(cashList.getMemberId());
        accountTradeRecord.setMemberName(cashList.getMemberName());
        accountTradeRecord.setMemberIdentity(cashList.getMemberIdentityCard());
        accountTradeRecord.setMemberPhone(cashList.getMobilePhone());
        accountTradeRecord.setAccountId(courseAccount.getId());
        accountTradeRecord.setAccountName(courseAccount.getCourseProjectName());
        if (cashList.getIsCancel() == 0) {
            accountTradeRecord.setAccountType(Constant.account_type_project_consume);
            accountTradeRecord.setDocDate(cashList.getCashDate());
            accountTradeRecord.setAccountSpendCount(cashList.getNumberTimes());
            //花费金额为单次成交金额
            accountTradeRecord.setCardMoney(cashList.getTransactionPrice());
            accountTradeRecord.setOperationBy(cashList.getInputBy());
            accountTradeRecord.setType(0);
            accountTradeRecord.setDocState(0);
        }else {
            accountTradeRecord.setAccountType(Constant.account_type_project_consume_cancel);
            accountTradeRecord.setDocDate(cashList.getCancelDate());
            accountTradeRecord.setAccountInCount(cashList.getNumberTimes());
            accountTradeRecord.setAccountInMoney(cashList.getTransactionPrice());
            accountTradeRecord.setOperationBy(cashList.getCancelBy());
            accountTradeRecord.setType(1);
            accountTradeRecord.setDocState(1);
        }
        BaseProject baseProject = new BaseProject();
        baseProject.setId(courseAccount.getCourseProjectId());
        baseProject = ssmProjectService.selectOne(baseProject);
        accountTradeRecord.setAccountNum(baseProject.getProjectNum());
        accountTradeRecord.setTradeCount(cashList.getNumberTimes());
        accountTradeRecord.setCashMoney(cashList.getCollectionCashAmount());
        accountTradeRecord.setAccountRestCount(courseAccount.getCourseRestCount());
        accountTradeRecord.setAccountConsumeCount(courseAccount.getCourseConsumeCount());
        accountTradeRecord.setDocId(cashList.getId());
        accountTradeRecord.setDocNum(cashList.getCashNum());
        BaseProject baseProject1 = new BaseProject();
        baseProject1.setId(cashList.getProjectId());
        baseProject1 = ssmProjectService.selectOne(baseProject1);
        accountTradeRecord.setDocProjectId(cashList.getProjectId());
        accountTradeRecord.setDocProjectName(cashList.getProjectName());
        accountTradeRecord.setDocProjectNum(baseProject.getProjectNum());
        accountTradeRecord.setTradingMoney(cashList.getAmount());
        accountTradeRecord.setPrice(cashList.getTransactionPrice());
        accountTradeRecord.setQuantity(cashList.getNumberTimes());
        return accountTradeRecord;
    }

    /*
     * 账户交易记录属性赋值 疗程付 现付
     * */
    public TransactionRecord setTransactionRecord(CashList cashList){
        TransactionRecord accountTradeRecord = new TransactionRecord();
        accountTradeRecord.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
        accountTradeRecord.setStoreId(cashList.getStoreId());
        accountTradeRecord.setStoreName(cashList.getStoreName());
        accountTradeRecord.setMemberId(cashList.getMemberId());
        accountTradeRecord.setMemberName(cashList.getMemberName());
        accountTradeRecord.setMemberIdentity(cashList.getMemberIdentityCard());
        accountTradeRecord.setMemberPhone(cashList.getMobilePhone());
        if (cashList.getIsCancel() == 0) {
            accountTradeRecord.setAccountType(Constant.account_type_store_cash);
            accountTradeRecord.setCashMoney(cashList.getCollectionCashAmount());
            accountTradeRecord.setDocDate(cashList.getCashDate());
            accountTradeRecord.setDate(new Date());
            accountTradeRecord.setOperationBy(cashList.getInputBy());
            accountTradeRecord.setType(0);
            accountTradeRecord.setDocState(0);
        }else {
            accountTradeRecord.setAccountType(Constant.account_type_store_cash_cancel);
            accountTradeRecord.setCashMoney(cashList.getCollectionCashAmount());
            accountTradeRecord.setDocDate(cashList.getCancelDate());
            accountTradeRecord.setDate(new Date());
            accountTradeRecord.setOperationBy(cashList.getCancelBy());
            accountTradeRecord.setType(1);
            accountTradeRecord.setDocState(1);
        }
        accountTradeRecord.setDocId(cashList.getId());
        accountTradeRecord.setDocNum(cashList.getCashNum());
        BaseProject baseProject = new BaseProject();
        baseProject.setId(cashList.getProjectId());
        baseProject = ssmProjectService.selectOne(baseProject);
        accountTradeRecord.setDocProjectId(cashList.getProjectId());
        accountTradeRecord.setDocProjectName(cashList.getProjectName());
        accountTradeRecord.setDocProjectNum(baseProject.getProjectNum());
        accountTradeRecord.setTradingMoney(cashList.getAmount());
        accountTradeRecord.setPrice(cashList.getTransactionPrice());
        accountTradeRecord.setQuantity(cashList.getNumberTimes());
        return accountTradeRecord;
    }

    /*
     * 账户交易记录属性赋值 疗程付 现付
     * */
    public AccountTradeRecord setAccountTradeRecord(CashList cashList,CourseAccount courseAccount){
        AccountTradeRecord accountTradeRecord = new AccountTradeRecord();
        accountTradeRecord.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
        accountTradeRecord.setStoreId(cashList.getStoreId());
        accountTradeRecord.setStoreName(cashList.getStoreName());
        accountTradeRecord.setMemberId(cashList.getMemberId());
        accountTradeRecord.setMemberName(cashList.getMemberName());
        accountTradeRecord.setMemberIdentity(cashList.getMemberIdentityCard());
        accountTradeRecord.setMemberPhone(cashList.getMobilePhone());
        if(cashList.getIsAddition()==1){
            accountTradeRecord.setAdditionDate(cashList.getAdditionDate());
        }
        //疗程卡付
        if (null != courseAccount) {

            accountTradeRecord.setAccountRestMoney(courseAccount.getCourseRestPrice());
            accountTradeRecord.setAccountConsumeMoney(courseAccount.getCourseConsumePrice());
            accountTradeRecord.setAccountId(courseAccount.getId());
            accountTradeRecord.setAccountName(courseAccount.getCourseProjectName());
            if (cashList.getIsCancel() == 0) {
                accountTradeRecord.setAccountType(Constant.account_type_project_consume);
                accountTradeRecord.setInputDate(cashList.getCashDate());
                accountTradeRecord.setAccountSpendCount(cashList.getNumberTimes());
                //花费金额为单次成交金额
                accountTradeRecord.setAccountSpendMoney(cashList.getTransactionPrice());
                accountTradeRecord.setInputBy(cashList.getInputBy());
                accountTradeRecord.setOrderStatu(0);
            }else {
                accountTradeRecord.setAccountType(Constant.account_type_project_consume_cancel);
                accountTradeRecord.setInputDate(cashList.getCancelDate());
                accountTradeRecord.setAccountInCount(cashList.getNumberTimes());
                accountTradeRecord.setAccountInMoney(cashList.getTransactionPrice());
                accountTradeRecord.setInputBy(cashList.getCancelBy());
                accountTradeRecord.setOrderStatu(1);
            }
            accountTradeRecord.setAccountRestCount(courseAccount.getCourseRestCount());
            accountTradeRecord.setAccountConsumeCount(courseAccount.getCourseConsumeCount());
        }else {//现付
            if (cashList.getIsCancel() == 0) {
                accountTradeRecord.setAccountType(Constant.account_type_store_cash);
                accountTradeRecord.setAccountSpendMoney(cashList.getCollectionCashAmount());
                accountTradeRecord.setInputDate(cashList.getCashDate());
                accountTradeRecord.setInputBy(cashList.getInputBy());
            }else {
                accountTradeRecord.setAccountType(Constant.account_type_store_cash_cancel);
                accountTradeRecord.setAccountSpendMoney(cashList.getCollectionCashAmount());
                accountTradeRecord.setInputDate(cashList.getCancelDate());
                accountTradeRecord.setInputBy(cashList.getCancelBy());
            }
        }
        accountTradeRecord.setIsAddition(cashList.getIsAddition());
        accountTradeRecord.setIsAddition(cashList.getIsAddition());
        accountTradeRecord.setDocId(cashList.getId());
        accountTradeRecord.setPrice(cashList.getTransactionPrice());
        accountTradeRecord.setDocNum(cashList.getCashNum());
        accountTradeRecord.setDocType(Constant.doc_type_store_cash);
        accountTradeRecord.setTradeId(cashList.getProjectId());
        accountTradeRecord.setTradeName(cashList.getProjectName());
        accountTradeRecord.setTradeMoney(cashList.getTransactionPrice());
        accountTradeRecord.setTradeCount(cashList.getNumberTimes());
        accountTradeRecord.setCardMoney(cashList.getCollectionRechargeAmount());
        accountTradeRecord.setCashMoney(cashList.getCollectionCashAmount());
        return accountTradeRecord;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public int cancel(List<CashListRequest> cashListRequestList, String phone) throws SmsException {
        int i = 0;
//        CashListRequest cashListRequest1 = new CashListRequest();
//        cashListRequest1
        //dao.selectByNum();
        for (CashListRequest cashListRequest : cashListRequestList) {
//            CashList cashList = new CashList();
//            BeanUtils.copyProperties(cashListRequest, cashList);
            CashList cashList = dao.one(cashListRequest);
            //修改支付表的支付状态
            PayList payList = new PayList();
            payList.setDocId(cashList.getCashNum());
            List<PayList> payListList = ssmPayService.select(payList);
            if(payListList!=null&&payListList.size()>0) {
                for (PayList list : payListList) {
                    list.setIsCancel(1);
                    ssmPayService.updateByNum(list);
                }
            }
            //查询是否欠款并进行了还款

            //查询作废后剩余金额是否大于0
            StoreParament storeParament = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.service_ticke);
            int days = (int) DateUtils.getDayDiff(cashList.getCashDate(), new Date());
            if(!"0".equals(storeParament.getParamentValue())) {
                if (Integer.parseInt(storeParament.getParamentValue()) < days) {
                    throw new SmsException(ResponseCode.CANCEL_NOT_PERMISSION, "单据超过允许作废时间");
                }
            }
            //设置作废人信息
            if (redisClient.hasKey(getStaffKey(phone))){
                StaffResponse staffResponse = redisClient.get(getStaffKey(phone));
                cashList.setCancelId(staffResponse.getId());
                cashList.setCancelBy(staffResponse.getStaffName());
            }
            //修改疗程单据状态
            cashList.setIsCancel(1);
            cashList.setCancelDate(new Date());
            //如果使用积分支付 将积分返回
            StoreMemberList storeMember = ssmStoreMemberService.selectByPrimaryKey(cashList.getMemberId());
            //查询会员是否有积分
            StoreParament parament = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.member_integral);
            if ("1".equals(parament.getParamentValue())) {
                if (null != storeMember) {
                    if (null != cashList.getIntegral() && 0 != cashList.getIntegral()) {
                        storeMember.setIntegral(storeMember.getIntegral() + cashList.getIntegral() - cashList.getGiveIntegral());
                    }else {
                        storeMember.setIntegral(storeMember.getIntegral() - cashList.getGiveIntegral());
                    }
                    ssmStoreMemberService.updateByPrimaryKey(storeMember);
                }
            }
            //使用充值卡付 消费钱返还
            if (null != cashListRequest.getRechargeAccountList() && cashListRequest.getRechargeAccountList().size() > 0){
                List<RechargeAccountRequest> rechargeAccountRequestList = cashListRequest.getRechargeAccountList();
                ssmRechargeAccountService.addMoney(rechargeAccountRequestList, cashList);
            }
            //使用疗程卡付 消费次数返还
            if (null != cashList.getCourseAccountId()){
                CourseAccount courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
                courseAccount = ssmCourseAccountService.addCountNew(courseAccount, cashList);
                //添加账户交易记录
                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, courseAccount);
                accountTradeRecord.setOrderStatu(1);
                ssmAccountTradeRecordService.addRecord(accountTradeRecord);

//                TransactionRecord transactionRecord = this.setTransactionRecord(cashList, courseAccount);
//                ssmTransactionRecordService.add(transactionRecord);
            }

//            if(cashList.getCollectionCashAmount().compareTo(BigDecimalUtils.bigDecimal("0"))==1){
//                TransactionRecord transactionRecord = this.setTransactionRecord(cashList);
//                ssmTransactionRecordService.add(transactionRecord);
//            }

            //使用现付
            if(null != cashListRequest.getCollectionCashAmount()){
                if (cashListRequest.getCollectionCashAmount().compareTo(BigDecimalUtils.bigDecimal("0"))==1 && cashListRequest.getRechargeAccountList().size() == 0 && null == cashList.getCourseAccountId()) {
                    //添加账户交易记录
                    AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(cashList, null);
                    accountTradeRecord.setOrderStatu(1);
                    ssmAccountTradeRecordService.addRecord(accountTradeRecord);
                }
            }


            //只计算总现付卡付大工 中工 技师 小工业绩提成
            cashList.setLargeAchievementAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setZhonggongAchievementAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setTechnicianAchievementAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setSmallAchievementAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setLargeCommissionAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setZhonggongCommissionAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setTechnicianCommissionAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setSmallCommissionAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setCardLargeAchievementAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setCardZhonggongAchievementAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setCardTechnicianAchievementAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setCardSmallAchievementAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setCardLargeCommissionAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setCardZhonggongCommissionAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setCardTechnicianCommissionAmount(BigDecimalUtils.bigDecimal("0"));
            cashList.setCardSmallCommissionAmount(BigDecimalUtils.bigDecimal("0"));


            Set<String> keys = redisClient.keys(getStaffKey(phone) + "*");
            //从redis查询 设置作废人信息 app使用
            if (keys.size() > 0){
                String key =  new ArrayList<>(keys).get(0);
                StaffResponse staffResponse = redisClient.get(key);
                cashList.setCancelId(staffResponse.getId());
                cashList.setCancelBy(staffResponse.getStaffName());
            }
            try {
                i = dao.cancel(cashList);
                Salesman salesman = new Salesman();
                salesman.setOrderId(String.valueOf(cashList.getId()));
                List<Salesman> salesmen = ssmSalesmanService.selectList(salesman);
                for (Salesman salesman1 : salesmen) {
                    salesman1.setState(1);
                    ssmSalesmanService.updateNotNull(salesman1);
                }
            }catch (Exception e){
                log.error("SsmCashServiceImpl.cancel:", e);
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
            }
            if(i<1){
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                throw new SmsException(ResponseCode.MSG,"已作废，请勿重复作废！");
            }
            //将评价单进行删除操作
            MemberCs memberCs = new MemberCs();
            memberCs.setDocId(cashList.getId());
            ssmMemberCsService.delete(memberCs);
        }

        return i;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public int updateStaff(List<CashListRequest> cashListRequestList, Long storeId) throws SmsException {

        int i = 0;
        int count = 0;
        List<PayList> payListList = cashListRequestList.get(0).getPayLists();
        if(payListList!=null && payListList.size()>0){
            for (PayList payList : payListList) {
                BaseCollectionType baseCollectionType = ssmCollectionTypeService.selectByPrimaryKey(payList.getPayId());
                payList.setPayName(baseCollectionType.getCollectionTypeName());
                payList.setPayDate(cashListRequestList.get(0).getCashDate());
                ssmPayService.updateByPrimaryKey(payList);
            }
        }
        for (CashListRequest cashListRequest : cashListRequestList) {

            count=count+1;
            CashList cashList = new CashList();
            BeanUtils.copyProperties(cashListRequest, cashList);
            cashList.setStoreId(storeId);

            StoreParament storeParament = StoreParaUtils.getStorePara(storeId, Constant.editOrderNum);
            int days = (int) DateUtils.getDayDiff(cashListRequest.getCashDate(), new Date());
            if("999".equals(storeParament.getParamentValue())) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
                if(!dateFormat.format(new Date()).equals(dateFormat.format(cashList.getCashDate()))) {
                    throw new SmsException(ResponseCode.CANCEL_NOT_PERMISSIONS, "请联系管理员");
                }
            }
            if(!"0".equals(storeParament.getParamentValue())) {
                if (Integer.parseInt(storeParament.getParamentValue()) < days) {
                    throw new SmsException(ResponseCode.CANCEL_NOT_PERMISSIONS, "单据超过允许修改时间");
                }
            }

            //设置业务员
            List<StaffRequest> largeList = cashListRequest.getLargeList();
            List<StaffRequest> zhonggongList = cashListRequest.getZhonggongList();
            List<StaffRequest> technicianList = cashListRequest.getTechnicianList();
            List<StaffRequest> smallList = cashListRequest.getSmallList();
            this.setStaffValue(largeList, zhonggongList, technicianList, smallList, cashList);
            BigDecimal reduce = largeList.stream().map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
            if(null != reduce && reduce.compareTo(BigDecimal.valueOf(100))!=0 && reduce.compareTo(BigDecimal.valueOf(0))!=0){
                throw new SmsException(ResponseCode.MSG,"美容师业绩占比和不等于100");
            }
            BigDecimal reduce1 = zhonggongList.stream().map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
            if(null != reduce1 && reduce1.compareTo(BigDecimal.valueOf(100))!=0 && reduce1.compareTo(BigDecimal.valueOf(0))!=0){
                throw new SmsException(ResponseCode.MSG,"美发师业绩占比和不等于100");
            }
            BigDecimal reduce2 = technicianList.stream().map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
            if(null != reduce2 && reduce2.compareTo(BigDecimal.valueOf(100))!=0 && reduce2.compareTo(BigDecimal.valueOf(0))!=0){
                throw new SmsException(ResponseCode.MSG,"技师业绩占比和不等于100");
            }
            BigDecimal reduce3 = smallList.stream().map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
            if(null != reduce3 && reduce3.compareTo(BigDecimal.valueOf(100))!=0 && reduce3.compareTo(BigDecimal.valueOf(0))!=0){
                throw new SmsException(ResponseCode.MSG,"助理业绩占比和不等于100");
            }


            //计算业绩提成
            List<PayList> payLists = cashListRequest.getPayLists();
            List<RechargeAccountRequest> rechargeAccountList = cashListRequest.getRechargeAccountList();
            cashList = this.setAchiComm(cashList, rechargeAccountList, payLists, cashListRequest);
            //校验业绩提成
            //判断业绩提成校验是否是收银校验
            StoreRequest storeRequest1 = new StoreRequest();
            storeRequest1.setId(storeId);
            BaseStores baseStores1 = ssmBaseStoreService.pagesorganizations(storeRequest1).stream().filter(baseStores -> null == baseStores.getParentId()).findAny().orElse(null);
            StoreParament parament = StoreParaUtils.getStorePara(baseStores1.getId(), Constant.pro_achi_comm_verify);
            if ("1".equals(parament.getParamentValue())) {
                StoreParament commissionCheck = StoreParaUtils.getStorePara(baseStores1.getId(), Constant.commission_check_cash);
                if(commissionCheck.getParamentValue().trim().equals("1")) {
                    CashListResponse cashListResponse = new CashListResponse();
                    BeanUtils.copyProperties(cashList, cashListResponse);
                    List<AchiCommEntity> entities = new ArrayList<>();
                    //设置业务人员列表
                    if (null == cashList.getCourseAccountId()) { //是非疗程卡包收银
                        entities = this.getAchiCommLists(cashList, cashListResponse);
                        for (AchiCommEntity entity : entities) {
                            entity.setOrderType("");
                        }
                    } else { //卡包收银
                        entities = this.getAchiCommListsCard(cashList, cashListResponse);
                    }
                    BigDecimal CardAchi = entities.stream().map(AchiCommEntity::getCardAchi).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal CashAchi = entities.stream().map(AchiCommEntity::getCashAchi).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal CardComm = entities.stream().map(AchiCommEntity::getCardComm).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal CashComm = entities.stream().map(AchiCommEntity::getCashComm).reduce(BigDecimal.ZERO, BigDecimal::add);
                    if (CardAchi.add(CashAchi).compareTo(cashList.getTransactionPrice()) == 1) {
                        throw new SmsException(ResponseCode.MSG, "第" + count + "条收银项目[ " + cashList.getProjectNum() + "/" + cashList.getProjectName() + " ]业绩（" + CardAchi.add(CashAchi).setScale(2) + "）大于成交金额（" + cashList.getTransactionPrice() + ")");
                    }
                    if (CardComm.add(CashComm).compareTo(cashList.getTransactionPrice()) != -1) {
                        throw new SmsException(ResponseCode.MSG, "第" + count + "条收银项目[ " + cashList.getProjectNum() + "/" + cashList.getProjectName() + " ]提成（" + CardComm.add(CashComm).setScale(2) + "）大于等于成交金额（" + cashList.getTransactionPrice() + ")");
                    }
                }
            }
            try {

                i = dao.updateStaff(cashList);
                CashListRequest cashListRequest1 = new CashListRequest();
                cashListRequest1.setId(cashList.getId());
                cashListRequest1.setCashDate(cashList.getCashDate());
                CashList cashList1 = dao.one(cashListRequest1);
                Salesman salesman = new Salesman();
                salesman.setOrderId(String.valueOf(cashListRequest.getId()));
                List<Salesman> salesmen = ssmSalesmanService.selectList(salesman);
                //CashList cashList2 = dao.selectByPrimaryKey(cashListRequest.getId());
                for (Salesman salesman1 : salesmen) {
                    ssmSalesmanService.delete(salesman1);
                }
                BaseStore baseStore = new BaseStore();
                baseStore.setId(storeId);
                BaseStore baseStore1 = ssmBaseStoreService.selectOne(baseStore);
                if(null != cashListRequest.getSalesmens()){
                    List<Salesman> salesmens = cashListRequest.getSalesmens();
                    BigDecimal reduce5 = salesmens.stream().filter(salesman1 -> salesman1.getStaffType()==0).map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
                    BigDecimal reduce6 = salesmens.stream().filter(salesman1 -> salesman1.getStaffType()==1).map(aa -> aa.getRatio()).reduce(BigDecimal.ZERO, BigDecimal::add);
                    if(null != reduce5 && reduce5.compareTo(BigDecimal.valueOf(100))!=0 && reduce5.compareTo(BigDecimal.valueOf(0))!=0){
                        throw new SmsException(ResponseCode.MSG,"高管业绩占比和不等于100");
                    }
                    if(null != reduce6 && reduce6.compareTo(BigDecimal.valueOf(100))!=0 && reduce6.compareTo(BigDecimal.valueOf(0))!=0){
                        throw new SmsException(ResponseCode.MSG,"管理员业绩占比和不等于100");
                    }
                    for (Salesman salesmen2 : salesmens) {
                        long l = new SnowflakeUtil(new Random().nextInt(1023)).nextId();
//                        Random r = new Random(3);
//                        int i1 = r.nextInt();
                        salesmen2.setId(l);
                        salesmen2.setOrderId(String.valueOf(cashList.getId()));
                        salesmen2.setOrderNum(cashList.getCashNum());
                        salesmen2.setOrderType(0);
                        salesmen2.setOrderDate(cashListRequest.getCashDate());
                        salesmen2.setState(0);
                        salesmen2.setMoney(cashList1.getCollectionCashAmount());
                        salesmen2.setProjectId(cashList1.getProjectId());
                        salesmen2.setStoreNum(baseStore1.getStoreNum());
                        salesmen2.setStoreName(baseStore1.getStoreName());
                        salesmen2.setStoreIdOrder(baseStore1.getId());
                    }
                    ssmSalesmanService.addBatch(salesmens);
                }
            }catch (Exception e){
                log.error("SsmCashServiceImpl.updateStaff:", e);
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
            }
        }
        return i;
    }


    @Override
    @Transactional(rollbackFor=Exception.class)
    public int cancelRowOnly(RefundCash refundCash, RefundOrderList refundOrderList) throws SmsException {
        int i = 0;
        //查询对应收银单
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setId(refundCash.getCashId());
        cashListRequest.setCashDate(refundCash.getCashDate());
        CashList cashList = dao.one(cashListRequest);
//        //修改疗程单据状态
//        cashList.setIsCancel(1);
//        cashList.setCancelDate(new Date());
//
//        StoreMemberList storeMember = ssmStoreMemberService.selectByPrimaryKey(cashList.getMemberId());
//
//        //查询会员是否有积分
//        StoreParament storeParament = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.member_integral);
//        if ("1".equals(storeParament.getParamentValue())) {
//            if (null != storeMember) {
//                //如果使用积分支付 将积分返回
//                if (null != cashList.getIntegral() && 0 != cashList.getIntegral()) {
//                    storeMember.setIntegral(storeMember.getIntegral() + cashList.getIntegral() - cashList.getGiveIntegral());
//                }else {
//                    storeMember.setIntegral(storeMember.getIntegral() - cashList.getGiveIntegral());
//                }
//                ssmStoreMemberService.updateByPrimaryKey(storeMember);
//            }
//        }
//
//        //设置作废人信息
//        cashList.setCancelId(refundOrderList.getAuditId());
//        cashList.setCancelBy(refundOrderList.getAuditBy());
//
//        cashList.setIsCancel(1);
//        try {
//            i = dao.cancel(cashList);
//        }catch (Exception e){
//            log.error("SsmCashServiceImpl.cancel:", e);
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//            throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
//        }
        //账户添加
        if (null != cashList.getCourseAccountId()){//疗程卡付
            //添加疗程卡次数
            CourseAccount courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
            courseAccount = ssmCourseAccountService.addCount(courseAccount, cashList.getNumberTimes(),cashList.getAmount());
            //插入账户交易记录
            AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(courseAccount,cashList , refundOrderList);
            i = ssmAccountTradeRecordService.addRecord(accountTradeRecord);
        }
        if (null != cashList.getCollectionRechargeAmount() && BigDecimalUtils.compareTo(cashList.getCollectionRechargeAmount(), BigDecimalUtils.bigDecimal("0")) == 1){//充值卡付
            //添加充值卡金额
            CashAccountList cashAccount = new CashAccountList();
            cashAccount.setCashId(cashList.getId());
            List<CashAccountList> accountLists = ssmCashAccountSrevice.select(cashAccount);
            for (CashAccountList accountList : accountLists) {

                RechargeAccount rechargeAccount = ssmRechargeAccountService.addMoney(accountList,cashList.getStoreId());
                //插入账户交易记录
                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(rechargeAccount, accountList, refundOrderList,cashList);
                i = ssmAccountTradeRecordService.addRecord(accountTradeRecord);
            }
        }
        if (null != cashList.getCollectionCashAmount() && BigDecimalUtils.compareTo(cashList.getCollectionCashAmount(), BigDecimalUtils.bigDecimal("0")) == 1){//现付
            //添加账户交易记录
            AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(refundOrderList, cashList);
            i = ssmAccountTradeRecordService.addRecord(accountTradeRecord);
        }
        return i;
    }


    @Override
    @Transactional(rollbackFor=Exception.class)
    public int restoreRowOnly(RefundCash refundCash, RefundOrderList refundOrderList) throws SmsException {
        int i = 0;
        //查询对应收银单
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setId(refundCash.getCashId());
        cashListRequest.setCashDate(refundCash.getCashDate());
        CashList cashList = dao.one(cashListRequest);
//        //修改疗程单据状态
//        cashList.setIsCancel(0);
//
//        StoreMemberList storeMember = ssmStoreMemberService.selectByPrimaryKey(cashList.getMemberId());
//        //查询会员是否有积分
//        StoreParament storeParament = StoreParaUtils.getStorePara(cashList.getStoreId(), Constant.member_integral);
//        if ("1".equals(storeParament.getParamentValue())) {
//            if (null != storeMember) {
//                //如果使用积分支付 将积分反算
//                if (null != cashList.getIntegral() && 0 != cashList.getIntegral()) {
//                    storeMember.setIntegral(storeMember.getIntegral() - cashList.getIntegral() + cashList.getGiveIntegral());
//                }else {
//                    storeMember.setIntegral(storeMember.getIntegral() + cashList.getGiveIntegral());
//                }
//                ssmStoreMemberService.updateByPrimaryKey(storeMember);
//            }
//        }
//        try {
//            i = dao.cancel(cashList);
//        }catch (Exception e){
//            log.error("SsmCashServiceImpl.restoreRowOnly:", e);
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//            throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
//        }

        //账户添加
        if (null != cashList.getCourseAccountId()){//疗程卡付
            //添加疗程卡次数
            CourseAccount courseAccount = ssmCourseAccountService.selectByPrimaryKey(cashList.getCourseAccountId());
            courseAccount = ssmCourseAccountService.subCount(courseAccount, cashList.getNumberTimes(), cashList.getAmount());
            //插入账户交易记录
            AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(courseAccount,cashList , refundOrderList);
            accountTradeRecord.setOrderStatu(2);
            accountTradeRecord.setInputBy(refundOrderList.getAuditBy());
            i = ssmAccountTradeRecordService.addRecord(accountTradeRecord);
        }
        if (null != cashList.getCollectionRechargeAmount() && BigDecimalUtils.compareTo(cashList.getCollectionRechargeAmount(), BigDecimalUtils.bigDecimal("0")) == 1){//充值卡付
            //添加充值卡金额
            CashAccountList cashAccount = new CashAccountList();
            cashAccount.setCashId(cashList.getId());
            List<CashAccountList> accountLists = ssmCashAccountSrevice.select(cashAccount);
            for (CashAccountList accountList : accountLists) {
                RechargeAccount rechargeAccount = ssmRechargeAccountService.subMoney(accountList,cashList.getStoreId());
                //插入账户交易记录
                AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(rechargeAccount, accountList, refundOrderList,cashList);
                accountTradeRecord.setOrderStatu(2);
                accountTradeRecord.setInputDate(new Date());
                accountTradeRecord.setInputBy(refundOrderList.getAuditBy());
                i = ssmAccountTradeRecordService.addRecord(accountTradeRecord);
            }
        }
        if (null != cashList.getCollectionCashAmount() && BigDecimalUtils.compareTo(cashList.getCollectionCashAmount(), BigDecimalUtils.bigDecimal("0")) == 1){//现付
            //添加账户交易记录
            AccountTradeRecord accountTradeRecord = this.setAccountTradeRecord(refundOrderList, cashList);
            accountTradeRecord.setInputDate(new Date());
            accountTradeRecord.setOrderStatu(2);
            accountTradeRecord.setInputBy(refundOrderList.getAuditBy());
            i = ssmAccountTradeRecordService.addRecord(accountTradeRecord);
        }
        return i;
    }


    public AccountTradeRecord setAccountTradeRecord(CourseAccount courseAccount, CashList cashList, RefundOrderList refundOrderList){
        AccountTradeRecord accountTradeRecord = new AccountTradeRecord();
        accountTradeRecord.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
        accountTradeRecord.setStoreId(refundOrderList.getStoreId());
        accountTradeRecord.setStoreName(refundOrderList.getStoreName());
        accountTradeRecord.setMemberId(refundOrderList.getMemberId());
        accountTradeRecord.setMemberName(refundOrderList.getMemberName());
        accountTradeRecord.setMemberIdentity(refundOrderList.getMemberIdentityCard());
        accountTradeRecord.setMemberPhone(refundOrderList.getMobilePhone());
        accountTradeRecord.setAccountId(courseAccount.getId());
        accountTradeRecord.setAccountName(courseAccount.getCourseProjectName());
        if (refundOrderList.getState() == 3){//审核
            accountTradeRecord.setAccountInCount(cashList.getNumberTimes());
            accountTradeRecord.setAccountType(Constant.account_type_refund_cash_audit);
            accountTradeRecord.setInputDate(refundOrderList.getAuditDate());
            accountTradeRecord.setInputBy(refundOrderList.getAuditBy());
            accountTradeRecord.setAccountInMoney(cashList.getAmount());
//            accountTradeRecord.setOrderStatu(0);
        }else if (refundOrderList.getState() == 4){//反审核
            accountTradeRecord.setAccountSpendCount(cashList.getNumberTimes());
            accountTradeRecord.setAccountType(Constant.account_type_refund_cash_unaudit);
            accountTradeRecord.setInputDate(new Date());
            accountTradeRecord.setInputBy(refundOrderList.getAuditBy());
            accountTradeRecord.setAccountSpendMoney(cashList.getAmount());
            accountTradeRecord.setOrderStatu(0);
        }
        accountTradeRecord.setDocId(refundOrderList.getId());
        accountTradeRecord.setDocNum(refundOrderList.getRefundNum());
        accountTradeRecord.setDocType(Constant.doc_type_refund_cash);
        accountTradeRecord.setTradeId(courseAccount.getCourseProjectId());
        accountTradeRecord.setTradeName(courseAccount.getCourseProjectName());
        accountTradeRecord.setTradeMoney(cashList.getAmount());
        accountTradeRecord.setTradeCount(cashList.getNumberTimes());
        accountTradeRecord.setPrice(cashList.getTransactionPrice());
        if (!"2".equals(courseAccount.getCourseType())) {
            accountTradeRecord.setAccountRestCount(courseAccount.getCourseRestCount());
            accountTradeRecord.setAccountConsumeCount(courseAccount.getCourseConsumeCount());
        }else {
            accountTradeRecord.setAccountGiftRestCount(courseAccount.getCourseRestCount());
            accountTradeRecord.setAccountGiftConsumeCount(courseAccount.getCourseConsumeCount());
        }
        accountTradeRecord.setAccountRestMoney(courseAccount.getCourseRestPrice());
        accountTradeRecord.setAccountConsumeMoney(courseAccount.getCourseConsumePrice());

        accountTradeRecord.setCardMoney(cashList.getCollectionRechargeAmount());
        accountTradeRecord.setCashMoney(cashList.getCollectionCashAmount());
        return accountTradeRecord;
    }


    public AccountTradeRecord setAccountTradeRecord(RechargeAccount rechargeAccount, CashAccountList accountList, RefundOrderList refundOrderList,CashList cashList){
        AccountTradeRecord accountTradeRecord = new AccountTradeRecord();
        accountTradeRecord.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
        accountTradeRecord.setStoreId(refundOrderList.getStoreId());
        accountTradeRecord.setStoreName(refundOrderList.getStoreName());
        accountTradeRecord.setMemberId(refundOrderList.getMemberId());
        accountTradeRecord.setMemberName(refundOrderList.getMemberName());
        accountTradeRecord.setMemberIdentity(refundOrderList.getMemberIdentityCard());
        accountTradeRecord.setMemberPhone(refundOrderList.getMobilePhone());
        accountTradeRecord.setAccountId(rechargeAccount.getId());
        accountTradeRecord.setAccountName(rechargeAccount.getRechargeTypeName());
        if (refundOrderList.getState() == 3){//审核
            accountTradeRecord.setAccountInMoney(accountList.getCardPayMoney());
            //赠送卡花费金额置0
            accountTradeRecord.setAccountGiftSpendMoney(accountList.getGiftPayMoney());
            accountTradeRecord.setAccountType(Constant.account_type_refund_cash_audit);
            accountTradeRecord.setInputDate(new Date());
        }else if (refundOrderList.getState() == 4){//反审核
            accountTradeRecord.setAccountSpendMoney(accountList.getCardPayMoney());
            //赠送卡花费金额
            accountTradeRecord.setAccountGiftSpendMoney(accountList.getGiftPayMoney());
            accountTradeRecord.setAccountType(Constant.account_type_refund_cash_unaudit);
            accountTradeRecord.setInputDate(refundOrderList.getAuditDate());
        }
        accountTradeRecord.setDocId(refundOrderList.getId());
        accountTradeRecord.setDocNum(refundOrderList.getRefundNum());
        accountTradeRecord.setDocType(Constant.doc_type_refund_cash);
        accountTradeRecord.setTradeId(rechargeAccount.getRechargeTypeId());
        accountTradeRecord.setTradeName(rechargeAccount.getRechargeTypeName());
        accountTradeRecord.setTradeMoney(accountList.getCardPayMoney().add(accountList.getGiftPayMoney()));
        accountTradeRecord.setAccountRestMoney(rechargeAccount.getCardRestMoney());
        accountTradeRecord.setAccountConsumeMoney(rechargeAccount.getCardConsumeMoney());
        accountTradeRecord.setAccountGiftRestMoney(rechargeAccount.getCardGiftMoney());
        accountTradeRecord.setAccountGiftConsumeMoney(rechargeAccount.getGiftConsumeMoney());
        accountTradeRecord.setCardMoney(cashList.getCollectionRechargeAmount());
        accountTradeRecord.setCashMoney(cashList.getCollectionCashAmount());
        return accountTradeRecord;
    }

    public AccountTradeRecord setAccountTradeRecord(RefundOrderList refundOrderList, CashList cashList){
        AccountTradeRecord accountTradeRecord = new AccountTradeRecord();
        accountTradeRecord.setId(new SnowflakeUtil(new Random().nextInt(1023)).nextId());
        accountTradeRecord.setStoreId(refundOrderList.getStoreId());
        accountTradeRecord.setStoreName(refundOrderList.getStoreName());
        accountTradeRecord.setMemberId(refundOrderList.getMemberId());
        accountTradeRecord.setMemberName(refundOrderList.getMemberName());
        accountTradeRecord.setMemberIdentity(refundOrderList.getMemberIdentityCard());
        accountTradeRecord.setMemberPhone(refundOrderList.getMobilePhone());

        if (refundOrderList.getState() == 3){//审核
            accountTradeRecord.setAccountSpendMoney(cashList.getCollectionCashAmount());
            accountTradeRecord.setAccountType(Constant.account_type_refund_cash_audit);
            accountTradeRecord.setInputDate(new Date());
        }else if (refundOrderList.getState() == 4){//反审核
            accountTradeRecord.setAccountInMoney(cashList.getCollectionCashAmount());
            accountTradeRecord.setAccountType(Constant.account_type_refund_cash_unaudit);
            accountTradeRecord.setInputDate(refundOrderList.getAuditDate());
        }
        accountTradeRecord.setDocId(refundOrderList.getId());
        accountTradeRecord.setDocNum(refundOrderList.getRefundNum());
        accountTradeRecord.setDocType(Constant.doc_type_refund_cash);
        accountTradeRecord.setTradeId(cashList.getProjectId());
        accountTradeRecord.setTradeName(cashList.getProjectName());
        accountTradeRecord.setTradeMoney(cashList.getTransactionPrice());
        accountTradeRecord.setTradeCount(cashList.getNumberTimes());
        accountTradeRecord.setCardMoney(cashList.getCollectionRechargeAmount());
        accountTradeRecord.setCashMoney(cashList.getCollectionCashAmount());
        return accountTradeRecord;
    }

    @Override
    public List<CashListResponse> selectList(Long storeId, String dateStr, Date date) throws SmsException, ParseException {
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setStoreId(storeId);
        cashListRequest.setDateStr(dateStr);
        cashListRequest.setCashDate(date);
        cashListRequest.setIsCancel(0);
        //查出门店信息 by storeId
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        //校验门店注册时间 时间之前的数据不允许查看
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())), date) < 0){
            throw new SmsException(ResponseCode.NO_DATA);
        }
        //根据条件查询数据
        List<CashList> cashLists =  dao.selectPage2(cashListRequest);
        /*PageInfo<CashList> pageInfo = dao.selectPage(cashListRequest);*/
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : cashLists) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);
            List<AchiCommEntity> entities = new ArrayList<>();
            //设置业务人员列表
            if(null == cashList.getCourseAccountId()){ //是非疗程卡包收银
                entities = this.getAchiCommLists(cashList,cashListResponse);

                for (AchiCommEntity entity : entities) {
                    entity.setOrderType("");
                }
            }else{ //卡包收银
                entities = this.getAchiCommListsCard(cashList,cashListResponse);
            }


            for (AchiCommEntity entity : entities) {
                entity.setDocId(cashList.getId());
                if(cashList.getCashNum().equals(entity.getDocNum())){
                    entity.setProjectId(cashList.getProjectNum());
                    //entity.setMemberNum(cashList.getProjectNum());
                    if(null == entity.getMemberName()){
                        entity.setMemberName(cashList.getMemberName());
                    }
                    if(null == entity.getMoney()){
                        entity.setMoney(cashList.getPriceMember());
                    }


                }
            }

            cashListResponse.setEntities(entities);
            listResponses.add(cashListResponse);
        }
        return listResponses;
    }

    @Override
    public List<CashList> selectListByStartTimeAndEndTime(Long storeId, String dateStr, Date startTime,Date endTime) throws SmsException, ParseException {
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setStoreId(storeId);
//        cashListRequest.setDateStr(dateStr);
        cashListRequest.setCashDate(startTime);
        cashListRequest.setStartTime(startTime);
        cashListRequest.setEndTime(endTime);
        cashListRequest.setIsCancel(0);
        //查出门店信息 by storeId
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        //校验门店注册时间 时间之前的数据不允许查看
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())), startTime) < 0){
            throw new SmsException(ResponseCode.NO_DATA);
        }
        //根据条件查询数据
        List<CashList> cashLists =  dao.selectPage2(cashListRequest);
        return cashLists;
    }

    @Override
    public List<CashListResponse> selectListchia(Long storeId,Date startDate,Date endDate) throws SmsException, ParseException {
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setStoreId(storeId);

        cashListRequest.setCashDate(startDate);

        //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

        //String format1 = format.format(startDate);

        cashListRequest.setStartTime(startDate);
        cashListRequest.setEndTime(endDate);
        //根据条件查询数据
        List<CashList> cashLists =  dao.selectPage2(cashListRequest);
        /*PageInfo<CashList> pageInfo = dao.selectPage(cashListRequest);*/
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : cashLists) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);
            List<AchiCommEntity> entities = new ArrayList<>();
            //设置业务人员列表
            if(null == cashList.getCourseAccountId()){ //是散客收银
                entities = this.getAchiCommLists(cashList,cashListResponse);
                for (AchiCommEntity entity : entities) {
                    entity.setOrderType("");
                }
            }else{ //卡包收银
                entities = this.getAchiCommListsCard(cashList,cashListResponse);
            }
            for (AchiCommEntity entity : entities) {
                if(cashList.getCashNum().equals(entity.getDocNum())){
                    entity.setProjectId(cashList.getProjectNum());
                    //entity.setMemberNum(cashList.getProjectNum());
                    if(null == entity.getMemberName()){
                        entity.setMemberName(cashList.getMemberName());
                    }
                    if(null == entity.getMoney()){
                        entity.setMoney(cashList.getPriceMember());
                    }


                }
            }

            cashListResponse.setEntities(entities);
            listResponses.add(cashListResponse);
        }
        return listResponses;
    }

    @Override
    public List<CashListResponse> selectListAbnormal(Long storeId, String dateStr, Date date) throws SmsException, ParseException {
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setStoreId(storeId);
        cashListRequest.setDateStr(dateStr);
        cashListRequest.setCashDate(date);
        cashListRequest.setIsCancel(0);
        //查出门店信息 by storeId
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        //校验门店注册时间 时间之前的数据不允许查看
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())), date) < 0){
            throw new SmsException(ResponseCode.NO_DATA);
        }
        //根据条件查询数据
        List<CashList> cashLists =  dao.selectPage2(cashListRequest);
        /*PageInfo<CashList> pageInfo = dao.selectPage(cashListRequest);*/
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : cashLists) {
            //总业绩
            BigDecimal totalPerformance = BigDecimal.valueOf(0);
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);
            BaseProject baseProject = ssmProjectService.selectByPrimaryKey(cashList.getProjectId());

            cashListResponse.setProject(baseProject);
            List<AchiCommEntity> entities = new ArrayList<>();
            //设置业务人员列表
            if(null == cashList.getCourseAccountId()){ //收银
                entities = this.getAchiCommLists(cashList,cashListResponse);
                for (AchiCommEntity entity : entities) {
                    entity.setOrderType("");
                }
            }else{ //卡包收银
                entities = this.getAchiCommListsCardNew(cashList,cashListResponse);
            }
            for (AchiCommEntity entity : entities) {
                totalPerformance=totalPerformance.add(entity.getCashAchi().add(entity.getCardAchi()));
                if(cashList.getCashNum().equals(entity.getDocNum())){
                    entity.setProjectId(cashList.getProjectNum());
                    //entity.setMemberNum(cashList.getProjectNum());
                    if(null == entity.getMemberName()){
                        entity.setMemberName(cashList.getMemberName());
                    }
                    if(null == entity.getMoney()){
                        entity.setMoney(cashList.getPriceMember());
                    }
                }
            }
            if(null != cashList.getCourseAccountId()){
                if(totalPerformance.subtract(cashList.getTransactionPrice()).abs().compareTo(new BigDecimal("0.05")) == 1){
                    cashListResponse.setEntities(entities);
                    cashListResponse.setErrorMessage("请检查是否填写员工或者漏填员工，无误则检查项目是否有业绩提成");
                    listResponses.add(cashListResponse);
                }
            }else{
                if(totalPerformance.subtract(cashList.getCollectionCashAmount().add(cashList.getCollectionRechargeAmount())).abs().compareTo(new BigDecimal("0.05")) == 1){
                    cashListResponse.setEntities(entities);
                    cashListResponse.setErrorMessage("请检查是否填写员工或者漏填员工，无误则检查项目是否有业绩提成");
                    listResponses.add(cashListResponse);
                }
            }
            List<AchiCommEntity> collect = entities.stream().filter(item ->item.getSaleStaffId()!=null &&  item.getSaleRatio().compareTo(new BigDecimal("0")) == 0).collect(Collectors.toList());
            if(collect!=null && collect.size()>0){
                cashListResponse.setEntities(entities);
                cashListResponse.setErrorMessage("存在占比为零的员工存在");
                if(!listResponses.contains(cashListResponse)){
                    listResponses.add(cashListResponse);
                }
            }


        }
        return listResponses;
    }

    @Override
    public List<CashListResponse> selectListAbnormalNew(Long storeId, Date startTime,Date endTime) throws SmsException, ParseException {
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setStoreId(storeId);
//        cashListRequest.setStartTime(startTime);
//        cashListRequest.setEndTime(endTime);
        cashListRequest.setCashDate(startTime);
        cashListRequest.setIsCancel(0);
        //查出门店信息 by storeId
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        //校验门店注册时间 时间之前的数据不允许查看
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())), endTime) < 0) {
            throw new SmsException(ResponseCode.NO_DATA);
        }
        //根据条件查询数据
        List<CashList> cashLists = dao.selectPage2(cashListRequest);
        /*PageInfo<CashList> pageInfo = dao.selectPage(cashListRequest);*/
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : cashLists) {
            //总业绩
            BigDecimal totalPerformance = BigDecimal.valueOf(0);
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);
            BaseProject baseProject = ssmProjectService.selectByPrimaryKey(cashList.getProjectId());

            cashListResponse.setProject(baseProject);
            List<AchiCommEntity> entities = new ArrayList<>();
            //设置业务人员列表
            if (null == cashList.getCourseAccountId()) { //收银
                entities = this.getAchiCommLists(cashList, cashListResponse);
                for (AchiCommEntity entity : entities) {
                    entity.setOrderType("");
                }
            } else { //卡包收银
                entities = this.getAchiCommListsCardNew(cashList, cashListResponse);
            }
            for (AchiCommEntity entity : entities) {
                totalPerformance = totalPerformance.add(entity.getCashAchi().add(entity.getCardAchi()));
                if (cashList.getCashNum().equals(entity.getDocNum())) {
                    entity.setProjectId(cashList.getProjectNum());
                    //entity.setMemberNum(cashList.getProjectNum());
                    if (null == entity.getMemberName()) {
                        entity.setMemberName(cashList.getMemberName());
                    }
                    if (null == entity.getMoney()) {
                        entity.setMoney(cashList.getPriceMember());
                    }
                }
            }
            if (null != cashList.getCourseAccountId()) {
                if (totalPerformance.subtract(cashList.getTransactionPrice()).abs().compareTo(new BigDecimal("0.05")) == 1) {
                    cashListResponse.setEntities(entities);
                    cashListResponse.setErrorMessage("请检查是否填写员工或者漏填员工，无误则检查项目是否有业绩提成，项目业绩正确请进行业绩重算");
                    listResponses.add(cashListResponse);
                }
            } else {
                if (totalPerformance.subtract(cashList.getCollectionCashAmount().add(cashList.getCollectionRechargeAmount())).abs().compareTo(new BigDecimal("0.05")) == 1) {
                    cashListResponse.setEntities(entities);
                    cashListResponse.setErrorMessage("请检查是否填写员工或者漏填员工，无误则检查项目是否有业绩提成，项目业绩正确请进行业绩重算");
                    listResponses.add(cashListResponse);
                }
            }
            List<AchiCommEntity> collect = entities.stream().filter(item -> item.getSaleStaffId() != null && item.getSaleRatio().compareTo(new BigDecimal("0")) == 0).collect(Collectors.toList());
            if (collect != null && collect.size() > 0) {
                cashListResponse.setEntities(entities);
                cashListResponse.setErrorMessage("存在占比为零的员工存在");
                if (!listResponses.contains(cashListResponse)) {
                    listResponses.add(cashListResponse);
                }
            }
        }
        return listResponses;
    }

    @Override
    public List<CashListResponse> selectLists(Long storeId, String startDate, String endDate, Date date) throws SmsException, ParseException {
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setStoreId(storeId);

        cashListRequest.setStartTime(DateUtils.YMDParse(startDate));
        cashListRequest.setEndTime(DateUtils.YMDParse(endDate));
        cashListRequest.setCashDate(date);
        cashListRequest.setIsCancel(0);
        //查出门店信息 by storeId
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        //校验门店注册时间 时间之前的数据不允许查看
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())), date) < 0){
            throw new SmsException(ResponseCode.NO_DATA);
        }
        //根据条件查询数据
        List<CashList> cashLists =  dao.selectPage2(cashListRequest);
        /*PageInfo<CashList> pageInfo = dao.selectPage(cashListRequest);*/
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : cashLists) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);
            //设置业务人员列表
            List<AchiCommEntity> entities = this.getAchiCommList(cashList,cashListResponse);
            cashListResponse.setEntities(entities);
            listResponses.add(cashListResponse);
        }
        return listResponses;
    }

    public List<AchiCommEntity> getAchiCommList(CashList cashList, CashListResponse cashListResponse){
        List<AchiCommEntity> entities = new ArrayList<>();
        BigDecimal hundredBD = com.ssm.manage.utils.BigDecimalUtils.bigDecimal("100");
        if(cashList.getAchievementLarge()==null){
            cashList.setAchievementLarge(BigDecimal.ZERO);
        }
        if(cashList.getAchievementZhonggong()==null){
            cashList.setAchievementZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getAchievementTechnician()==null){
            cashList.setAchievementTechnician(BigDecimal.ZERO);
        }
        if(cashList.getAchievementSmall()==null){
            cashList.setAchievementSmall(BigDecimal.ZERO);
        }
        if(cashList.getCommissionLarge()==null){
            cashList.setCommissionLarge(BigDecimal.ZERO);
        }
        if(cashList.getCommissionZhonggong()==null){
            cashList.setCommissionZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCommissionTechnician()==null){
            cashList.setCommissionTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCommissionSmall()==null){
            cashList.setCommissionSmall(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementLarge()==null){
            cashList.setCardAchievementLarge(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementZhonggong()==null){
            cashList.setCardAchievementZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementTechnician()==null){
            cashList.setCardAchievementTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementSmall()==null){
            cashList.setCardAchievementSmall(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionLarge()==null){
            cashList.setCardCommissionLarge(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionZhonggong()==null){
            cashList.setCardCommissionZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionTechnician()==null){
            cashList.setCardCommissionTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionSmall()==null) {
            cashList.setCardCommissionSmall(BigDecimal.ZERO);
        }
            //大工1编码
        if (null != cashList.getServiceLargeOneStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
                    BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //大工2编码
        if (null != cashList.getServiceLargeTwoStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //大工3编码
        if (null != cashList.getServiceLargeThreeStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //中工1编码
        if (null != cashList.getServiceZhonggongOneStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(
                    BigDecimalUtils.add(
                            BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
                                    BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                            BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
                                    BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //中工2编码
        if (null != cashList.getServiceZhonggongTwoStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //中工3编码
        if (null != cashList.getServiceZhonggongThreeStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //技师1编码
        if (null != cashList.getServiceTechnicianOneStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getTechnicianOneNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianOneStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianOneStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceTechnicianOneRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

            entities.add(achiCommEntity);
        }
        //技师2编码
        if (null != cashList.getServiceTechnicianTwoStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getTechnicianTwoNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianTwoStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianTwoStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceTechnicianTwoRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //技师3编码
        if (null != cashList.getServiceTechnicianThreeStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getTechnicianThreeNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianThreeStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianThreeStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceTechnicianThreeRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //助理1编码
        if (null != cashList.getServiceSmallOneStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getSmallOneNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceSmallOneStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceSmallOneStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallOneIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceSmallOneRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //助理2编码
        if (null != cashList.getServiceSmallTwoStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getSmallTwoNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceSmallTwoStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceSmallTwoStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallTwoIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceSmallTwoRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        //助理3编码
        if (null != cashList.getServiceSmallThreeStaffId()){
            AchiCommEntity achiCommEntity = new AchiCommEntity();
            achiCommEntity.setDocNum(cashList.getCashNum());
            achiCommEntity.setDocType(Constant.doc_type_store_cash);
            achiCommEntity.setDocDate(cashList.getCashDate());
            achiCommEntity.setTradeName(cashList.getProjectName());
            achiCommEntity.setBrandNumber(cashList.getSmallThreeNumber());
            achiCommEntity.setSaleStaffId(cashList.getServiceSmallThreeStaffId());
            achiCommEntity.setSaleStaffName(cashList.getServiceSmallThreeStaffName());
            achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallThreeIdentityCard());
            achiCommEntity.setSaleRatio(cashList.getServiceSmallThreeRatio());
            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                    BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
            entities.add(achiCommEntity);
        }
        return entities;
    }


    private HashMap<String, BigDecimal> getFixedAmount(BigDecimal CardAmount,BigDecimal CashAmount,BigDecimal Cardyj,BigDecimal Cashyj ){

        HashMap<String, BigDecimal> map = new HashMap<>();
        //卡付业绩
        BigDecimal multiply = BigDecimalUtils.multiply(CardAmount.divide(CardAmount.add(CashAmount),4,BigDecimal.ROUND_HALF_UP), Cardyj);
        //现付业绩
        BigDecimal multiplys = BigDecimalUtils.multiply(CashAmount.divide(CardAmount.add(CashAmount),4,BigDecimal.ROUND_HALF_UP), Cashyj);

        //总的业绩
        BigDecimal add = multiply.add(multiplys);
        map.put("card",multiply);
        map.put("cash",multiplys);
        map.put("total",add);
        return map;

    };

    //升级后修改的新业绩提成算法
    public List<AchiCommEntity> getAchiCommLists(CashList cashList, CashListResponse cashListResponse){

            if(cashList.getAchievementLarge()==null){
                cashList.setAchievementLarge(BigDecimal.ZERO);
            }
            if(cashList.getAchievementZhonggong()==null){
                cashList.setAchievementZhonggong(BigDecimal.ZERO);
            }
            if(cashList.getAchievementTechnician()==null){
                cashList.setAchievementTechnician(BigDecimal.ZERO);
            }
            if(cashList.getAchievementSmall()==null){
                cashList.setAchievementSmall(BigDecimal.ZERO);
            }

            if(cashList.getCommissionLarge()==null){
                cashList.setCommissionLarge(BigDecimal.ZERO);
            }
            if(cashList.getCommissionZhonggong()==null){
                cashList.setCommissionZhonggong(BigDecimal.ZERO);
            }
            if(cashList.getCommissionTechnician()==null){
                cashList.setCommissionTechnician(BigDecimal.ZERO);
            }
            if(cashList.getCommissionSmall()==null){
                cashList.setCommissionSmall(BigDecimal.ZERO);
            }
            if(cashList.getCardAchievementLarge()==null){
                cashList.setCardAchievementLarge(BigDecimal.ZERO);
            }
            if(cashList.getCardAchievementZhonggong()==null){
                cashList.setCardAchievementZhonggong(BigDecimal.ZERO);
            }
            if(cashList.getCardAchievementTechnician()==null){
                cashList.setCardAchievementTechnician(BigDecimal.ZERO);
            }
            if(cashList.getCardAchievementSmall()==null){
                cashList.setCardAchievementSmall(BigDecimal.ZERO);
            }

            if(cashList.getCardCommissionLarge()==null){
                cashList.setCardCommissionLarge(BigDecimal.ZERO);
            }
            if(cashList.getCardCommissionZhonggong()==null){
                cashList.setCardCommissionZhonggong(BigDecimal.ZERO);
            }
            if(cashList.getCardCommissionTechnician()==null){
                cashList.setCardCommissionTechnician(BigDecimal.ZERO);
            }
            if(cashList.getCardCommissionSmall()==null) {
                cashList.setCardCommissionSmall(BigDecimal.ZERO);
            }

                List<AchiCommEntity> entities = new ArrayList<>();
        BigDecimal hundredBD = com.ssm.manage.utils.BigDecimalUtils.bigDecimal("100");
        //减掉固定金额业绩的单据总金额
//        BigDecimal totalMeony = cashList.getCashAmount();
        //赠送支付金额
        BigDecimal zsMoney=new BigDecimal("0");
        if(cashList.getCollectionGiftAmount()!=null&&cashList.getCollectionGiftAmount().doubleValue()>=0){
            zsMoney=cashList.getCollectionGiftAmount();
        }


        BigDecimal totalMeony = cashList.getCollectionCashAmount().add(cashList.getCollectionRechargeAmount().add(zsMoney));
        BigDecimal GDtotalMeony = cashList.getCollectionCashAmount().add(cashList.getCollectionRechargeAmount());


        //减掉固定金额业绩的单据现付金额
        BigDecimal achievementMeony = cashList.getCollectionCashAmount();
        //减掉固定金额业绩的单据卡付金额
        BigDecimal cardMeony = cashList.getCollectionRechargeAmount();

        BaseProject baseProject = ssmProjectService.selectByPrimaryKey(cashList.getProjectId());
        BigDecimal cooperationCashAchi=new BigDecimal("0");//合作现付业绩
        BigDecimal cooperationRechargeAchi=new BigDecimal("0");//合作卡付业绩
        BigDecimal cashRechargeAchiSum=new BigDecimal("0");//合作总业绩
        //isCooperation 比例brokerage 1是比例 0是固定smokeCommissionWay
        if(baseProject.getIsCooperation()==1){
            if(baseProject.getSmokeCommissionWay()==1){//合作按比例
                //合作项目现付业绩
                cooperationCashAchi=cooperationCashAchi.add(baseProject.getBrokerage().multiply(cashList.getCollectionCashAmount()));
                //合作项目卡付业绩
                cooperationRechargeAchi=cooperationRechargeAchi.add(baseProject.getBrokerage().multiply(cashList.getCollectionRechargeAmount()));
            }else{//合作按固定
                /*//方法1：现付和卡付对比，取最大值先扣，不够再补上
                if(BigDecimalUtils.compareTo(achievementMeony,cardMeony)==1){//现付金额对比卡付金额
                    //如果现付金额-项目固定提成>0,或者等于0就执行
                    if(BigDecimalUtils.compareTo(achievementMeony.subtract(baseProject.getBrokerage()),new BigDecimal("0"))==1||BigDecimalUtils.compareTo(achievementMeony.subtract(baseProject.getBrokerage()),new BigDecimal("0"))==0){//
                        achievementMeony=achievementMeony.subtract(baseProject.getBrokerage());
                    }else{//使用卡付金额-（项目固定提成-现付金额），现付金额=0
                        cardMeony=cardMeony.subtract(baseProject.getBrokerage().subtract(achievementMeony));
                        achievementMeony=new BigDecimal("0");
                    }
                }else{
                    //如果卡付金额-项目固定提成>0,或者等于0就执行
                    if(BigDecimalUtils.compareTo(cardMeony.subtract(baseProject.getBrokerage()),new BigDecimal("0"))==1||BigDecimalUtils.compareTo(cardMeony.subtract(baseProject.getBrokerage()),new BigDecimal("0"))==0){//
                        cardMeony=cardMeony.subtract(baseProject.getBrokerage());
                    }else{//使用现付金额-（项目固定提成-卡付金额），卡付金额=0
                        achievementMeony=achievementMeony.subtract(baseProject.getBrokerage().subtract(cardMeony));
                        achievementMeony=new BigDecimal("0");
                    }
                }*/

                //方法2：卡付和现付/总付金额，获取现付和卡付的支付比例*合作项目固定金额
                BigDecimal sum=cashList.getCollectionCashAmount().add(cashList.getCollectionRechargeAmount());
                //（卡付（或现付）/总付款金额=卡付（或现付）比例）
                BigDecimal Cash=cashList.getCollectionCashAmount().divide(sum,10,BigDecimal.ROUND_HALF_UP);
                BigDecimal Recharge=cashList.getCollectionRechargeAmount().divide(sum,10,BigDecimal.ROUND_HALF_UP);
                cooperationCashAchi=cooperationCashAchi.add(baseProject.getBrokerage().multiply(Cash).setScale(10,BigDecimal.ROUND_HALF_UP));
                cooperationRechargeAchi=cooperationRechargeAchi.add(baseProject.getBrokerage().multiply(Recharge).setScale(10,BigDecimal.ROUND_HALF_UP));
            }
        }
        cashRechargeAchiSum=cashRechargeAchiSum.add(cooperationCashAchi).add(cooperationRechargeAchi).divide(new BigDecimal("100"));
        achievementMeony=achievementMeony.subtract(cooperationCashAchi);//业绩-合作项目现付业绩
        cardMeony=cardMeony.subtract(cooperationRechargeAchi);//业绩-合作项目卡付业绩

        //存在卡付，也存在现付
        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1){
            //判断大工是否存在
            if(null != cashList.getServiceLargeOneStaffId() || null != cashList.getServiceLargeTwoStaffId() || null != cashList.getServiceLargeThreeStaffId()){
                //判断卡付和现付是否同时存在
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1 &&cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementLarge(), cashList.getAchievementLarge());
                    achievementMeony= BigDecimalUtils.subtract(achievementMeony,fixedAmount.get("cash"));
//                    cardMeony= BigDecimalUtils.subtract(cardMeony,fixedAmount.get("card"));
                    totalMeony= BigDecimalUtils.subtract(totalMeony,fixedAmount.get("total"));
                }else{
                    //判断现付业绩是否为固定金额
                    if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                        achievementMeony= BigDecimalUtils.subtract(achievementMeony,cashList.getAchievementLarge());


                        totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getAchievementLarge());
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
//                        cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementLarge());
                        totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getCardAchievementLarge());
                    }
                }

            }

            //判断中工是否存在
            if(null != cashList.getServiceZhonggongOneStaffId() || null != cashList.getServiceZhonggongTwoStaffId() || null != cashList.getServiceZhonggongThreeStaffId()){
                //判断卡付和现付是否同时存在
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1 &&cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                    HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementZhonggong(), cashList.getAchievementZhonggong());
                    achievementMeony = BigDecimalUtils.subtract(achievementMeony, fixedAmount.get("cash"));
//                    cardMeony = BigDecimalUtils.subtract(cardMeony, fixedAmount.get("card"));

                    totalMeony = BigDecimalUtils.subtract(totalMeony, fixedAmount.get("total"));
                }else{
                    if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                        achievementMeony= BigDecimalUtils.subtract(achievementMeony,cashList.getAchievementZhonggong());
                        totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getAchievementZhonggong());
                    }
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
//                        cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementZhonggong());
                        totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getCardAchievementZhonggong());
                    }
                }
            }

            //判断小工（技师）是否存在
            if(null != cashList.getServiceTechnicianOneStaffId() || null != cashList.getServiceTechnicianTwoStaffId() || null != cashList.getServiceTechnicianThreeStaffId()){
                if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1 && cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                    HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementTechnician(), cashList.getAchievementTechnician());
                    achievementMeony = BigDecimalUtils.subtract(achievementMeony, fixedAmount.get("cash"));
//                    cardMeony = BigDecimalUtils.subtract(cardMeony, fixedAmount.get("card"));

                    totalMeony = BigDecimalUtils.subtract(totalMeony, fixedAmount.get("total"));
                }else{
                    if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                        achievementMeony= BigDecimalUtils.subtract(achievementMeony,cashList.getAchievementTechnician());
                        totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getAchievementTechnician());
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
//                        cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementTechnician());
                        totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getCardAchievementTechnician());
                    }
                }
            }

            //判断助理是否存在
            if(null != cashList.getServiceSmallOneStaffId() || null != cashList.getServiceSmallTwoStaffId() || null != cashList.getServiceSmallThreeStaffId()){
                if( cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1 && cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                    HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementSmall(), cashList.getAchievementSmall());
                    achievementMeony = BigDecimalUtils.subtract(achievementMeony, fixedAmount.get("cash"));
//                    cardMeony = BigDecimalUtils.subtract(cardMeony, fixedAmount.get("card"));

                    totalMeony = BigDecimalUtils.subtract(totalMeony, fixedAmount.get("total"));
                }else{
                    if(cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                        achievementMeony= BigDecimalUtils.subtract(achievementMeony,cashList.getAchievementSmall());
                        totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getAchievementSmall());
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
//                        cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementSmall());
                        totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getCardAchievementSmall());
                    }
                }


            }

            //大工1编码
            if (null != cashList.getServiceLargeOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));

                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());

                achiCommEntity.setSaleAchievementAmount(cashList.getAchievementLarge());

                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
                        BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));

                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementLarge(), cashList.getAchievementLarge());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony,cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        }
                    }
                }

                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);
//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
//                    BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工2编码
            if (null != cashList.getServiceLargeTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementLarge(), cashList.getAchievementLarge());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工3编码
            if (null != cashList.getServiceLargeThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementLarge(), cashList.getAchievementLarge());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大厂4编码
            if (null != cashList.getServiceLargeFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFourRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementLarge(), cashList.getAchievementLarge());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大厂5编码
            if (null != cashList.getServiceLargeFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFiveRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementLarge(), cashList.getAchievementLarge());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionLarge(), cashList.getCommissionLarge());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工1编码
            if (null != cashList.getServiceZhonggongOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());

                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));

                achiCommEntity.setSaleCommissionAmount(
                        BigDecimalUtils.add(
                                BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                                BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementZhonggong(), cashList.getAchievementZhonggong());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }

                    }else{//百分百
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(
//                    BigDecimalUtils.add(
//                        BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                            BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工2编码
            if (null != cashList.getServiceZhonggongTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementZhonggong(), cashList.getAchievementZhonggong());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工3编码
            if (null != cashList.getServiceZhonggongThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementZhonggong(), cashList.getAchievementZhonggong());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工4编码
            if (null != cashList.getServiceZhonggongFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFourRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementZhonggong(), cashList.getAchievementZhonggong());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工5编码
            if (null != cashList.getServiceZhonggongFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFiveRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementZhonggong(), cashList.getAchievementZhonggong());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionZhonggong(), cashList.getCommissionZhonggong());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //技师1编码
            if (null != cashList.getServiceTechnicianOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementTechnician(), cashList.getAchievementTechnician());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
            //技师2编码
            if (null != cashList.getServiceTechnicianTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setMoney(GDtotalMeony);
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianTwoRatio()));
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementTechnician(), cashList.getAchievementTechnician());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //技师3编码
            if (null != cashList.getServiceTechnicianThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));


                //判断现付业绩是否为固定金额
                if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementTechnician(), cashList.getAchievementTechnician());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionTechnician(), cashList.getCommissionTechnician());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理1编码
            if (null != cashList.getServiceSmallOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementSmall(), cashList.getAchievementSmall());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理2编码
            if (null != cashList.getServiceSmallTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));

                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementSmall(), cashList.getAchievementSmall());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理3编码
            if (null != cashList.getServiceSmallThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));

                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));


                //判断现付业绩是否为固定金额
                if(cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardAchievementSmall(), cashList.getAchievementSmall());
                        achiCommEntity.setCashAchi(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }else{
                        achiCommEntity.setCashAchi(cashList.getAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }

                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                            }

                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }

                    }else{
                        //卡付业绩比例计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCashComm(fixedAmount.get("cash").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }
                    //判断卡付业绩是否为固定金额
                    if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //卡付业绩按固定金额计算
                        //计算卡付业绩
                        if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                            HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                            achiCommEntity.setCardAchi(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }else{
                            achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }
                    }else{
                        //卡付业绩百分比计算
                        achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        //计算卡付提成
                        //判断卡付提成是否为固定金额
                        if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                            //提成按固定金额算
                            if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1 && cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1 &&cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {
                                HashMap<String, BigDecimal> fixedAmount = this.getFixedAmount(cardMeony, cashList.getCollectionCashAmount(), cashList.getCardCommissionSmall(), cashList.getCommissionSmall());
                                achiCommEntity.setCardComm(fixedAmount.get("card").multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                            }else{
                                achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                            }
                        }else{
                            //提成按百分百
                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                            achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                        }
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
        }else if(cardMeony.compareTo(BigDecimal.valueOf(0)) == 1){//只有卡付
            //判断大工是否存在
            if(null != cashList.getServiceLargeOneStaffId() || null != cashList.getServiceLargeTwoStaffId() || null != cashList.getServiceLargeThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementLarge());
                    totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getCardAchievementLarge());
                }
            }

            //判断中工是否存在
            if(null != cashList.getServiceZhonggongOneStaffId() || null != cashList.getServiceZhonggongTwoStaffId() || null != cashList.getServiceZhonggongThreeStaffId()){
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementZhonggong());
                    totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getCardAchievementZhonggong());
                }
            }

            //判断小工（技师）是否存在
            if(null != cashList.getServiceTechnicianOneStaffId() || null != cashList.getServiceTechnicianTwoStaffId() || null != cashList.getServiceTechnicianThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementTechnician());
                    totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getCardAchievementTechnician());
                }
            }

            //判断助理是否存在
            if(null != cashList.getServiceSmallOneStaffId() || null != cashList.getServiceSmallTwoStaffId() || null != cashList.getServiceSmallThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementSmall());
                    totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getCardAchievementSmall());
                }
            }

            //大工1编码
            if (null != cashList.getServiceLargeOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
                achiCommEntity.setSaleAchievementAmount(cashList.getAchievementLarge());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
                        BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }
                }

                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);
//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
//                    BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工2编码
            if (null != cashList.getServiceLargeTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));

                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工3编码
            if (null != cashList.getServiceLargeThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工4编码
            if (null != cashList.getServiceLargeFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFourRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工5编码
            if (null != cashList.getServiceLargeFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFiveRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工1编码
            if (null != cashList.getServiceZhonggongOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils
                        .add(
                                BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));

                achiCommEntity.setSaleCommissionAmount(
                        BigDecimalUtils.add(
                                BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                                BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(
//                    BigDecimalUtils.add(
//                        BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                            BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工2编码
            if (null != cashList.getServiceZhonggongTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工3编码
            if (null != cashList.getServiceZhonggongThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工4编码
            if (null != cashList.getServiceZhonggongFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFourRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工5编码
            if (null != cashList.getServiceZhonggongFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFiveRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //技师1编码
            if (null != cashList.getServiceTechnicianOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
            //技师2编码
            if (null != cashList.getServiceTechnicianTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //技师3编码
            if (null != cashList.getServiceTechnicianThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理1编码
            if (null != cashList.getServiceSmallOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理2编码
            if (null != cashList.getServiceSmallTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理3编码
            if (null != cashList.getServiceSmallThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
        }else if(cashList.getCollectionCashAmount().compareTo(BigDecimal.valueOf(0)) == 1) {//只有现付
            //判断大工是否存在
            if(null != cashList.getServiceLargeOneStaffId() || null != cashList.getServiceLargeTwoStaffId() || null != cashList.getServiceLargeThreeStaffId()){
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    achievementMeony= BigDecimalUtils.subtract(achievementMeony,cashList.getAchievementLarge());
                    totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getAchievementLarge());
                }
            }

            //判断中工是否存在
            if(null != cashList.getServiceZhonggongOneStaffId() || null != cashList.getServiceZhonggongTwoStaffId() || null != cashList.getServiceZhonggongThreeStaffId()){
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    achievementMeony= BigDecimalUtils.subtract(achievementMeony,cashList.getAchievementZhonggong());
                    totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getAchievementZhonggong());
                }
            }

            //判断小工（技师）是否存在
            if(null != cashList.getServiceTechnicianOneStaffId() || null != cashList.getServiceTechnicianTwoStaffId() || null != cashList.getServiceTechnicianThreeStaffId()){
                if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    achievementMeony= BigDecimalUtils.subtract(achievementMeony,cashList.getAchievementTechnician());
                    totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getAchievementTechnician());
                }
            }

            //判断助理是否存在
            if(null != cashList.getServiceSmallOneStaffId() || null != cashList.getServiceSmallTwoStaffId() || null != cashList.getServiceSmallThreeStaffId()){
                if(cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    achievementMeony= BigDecimalUtils.subtract(achievementMeony,cashList.getAchievementSmall());
                    totalMeony= BigDecimalUtils.subtract(totalMeony,cashList.getAchievementSmall());
                }
            }

            //大工1编码
            if (null != cashList.getServiceLargeOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
                achiCommEntity.setSaleAchievementAmount(cashList.getAchievementLarge());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
                        BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    }else{//百分百
                        BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge());
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }
                }

                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);
//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
//                    BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工2编码
            if (null != cashList.getServiceLargeTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工3编码
            if (null != cashList.getServiceLargeThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工4编码
            if (null != cashList.getServiceLargeFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFourRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工5编码
            if (null != cashList.getServiceLargeFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFiveRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }
                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionLarge()),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工1编码
            if (null != cashList.getServiceZhonggongOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(
                        BigDecimalUtils.add(
                                BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                                BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }

                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(
//                    BigDecimalUtils.add(
//                        BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                            BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工2编码
            if (null != cashList.getServiceZhonggongTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }

                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工3编码
            if (null != cashList.getServiceZhonggongThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }

                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工4编码
            if (null != cashList.getServiceZhonggongFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFourRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }

                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工5编码
            if (null != cashList.getServiceZhonggongFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFiveRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionZhonggong()),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }

                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //技师1编码
            if (null != cashList.getServiceTechnicianOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }

                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
            //技师2编码
            if (null != cashList.getServiceTechnicianTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }

                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //技师3编码
            if (null != cashList.getServiceTechnicianThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));


                //判断现付业绩是否为固定金额
                if(cashList.getAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionTechnician()),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }

                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理1编码
            if (null != cashList.getServiceSmallOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallOneRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理2编码
            if (null != cashList.getServiceSmallTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallTwoRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                if(cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }

                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理3编码
            if (null != cashList.getServiceSmallThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallThreeRatio()));
                achiCommEntity.setMoney(GDtotalMeony);
//                achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));


                //判断现付业绩是否为固定金额
                if(cashList.getAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){ //=计算固定金额
                    //计算现付业绩
                    //判断是否存在卡付和现付并且卡付业绩也是固定金额
                    achiCommEntity.setCashAchi(cashList.getAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));


                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }


                }else{ //计算百分百
                    //计算现付业绩
                    achiCommEntity.setCashAchi(BigDecimalUtils.multiply(achievementMeony,cashList.getAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算现付提成
                    //判断现付提成是否为百分百还是固定金额
                    if(cashList.getCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1) {//a大于b//业绩提成比例> 1=固定金额
                        //判断是否存在卡付和现付并且卡付提出也是固定金额
                        achiCommEntity.setCashComm(cashList.getCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }else{//百分百
                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()));
//                        achiCommEntity.setCashComm(BigDecimalUtils.multiply(BigDecimalUtils.multiply(achiCommEntity.getCashAchi(),cashList.getCommissionSmall()),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }

                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
        }



        return entities;
    }

    //升级后修改的新疗程消费业绩提成算法
    public List<AchiCommEntity> getAchiCommListsCard(CashList cashList, CashListResponse cashListResponse){

        if(cashList.getLargeAchievementAmount()==null){
            cashList.setLargeAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getZhonggongAchievementAmount()==null){
            cashList.setZhonggongAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getTechnicianAchievementAmount()==null){
            cashList.setTechnicianAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getSmallAchievementAmount()==null){
            cashList.setSmallAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getLargeCommissionAmount()==null){
            cashList.setLargeCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getZhonggongCommissionAmount()==null){
            cashList.setZhonggongCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getTechnicianCommissionAmount()==null){
            cashList.setTechnicianCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getSmallCommissionAmount()==null){
            cashList.setSmallCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardLargeAchievementAmount()==null){
            cashList.setCardLargeAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardZhonggongAchievementAmount()==null){
            cashList.setCardZhonggongAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardTechnicianAchievementAmount()==null){
            cashList.setCardTechnicianAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardSmallAchievementAmount()==null){
            cashList.setCardSmallAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardLargeCommissionAmount()==null){
            cashList.setCardLargeCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardZhonggongCommissionAmount()==null){
            cashList.setCardZhonggongCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardTechnicianCommissionAmount()==null){
            cashList.setCardTechnicianCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardSmallCommissionAmount()==null){
            cashList.setCardSmallCommissionAmount(BigDecimal.ZERO);
        }

        if(cashList.getAchievementLarge()==null){
            cashList.setAchievementLarge(BigDecimal.ZERO);
        }
        if(cashList.getAchievementZhonggong()==null){
            cashList.setAchievementZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getAchievementTechnician()==null){
            cashList.setAchievementTechnician(BigDecimal.ZERO);
        }
        if(cashList.getAchievementSmall()==null){
            cashList.setAchievementSmall(BigDecimal.ZERO);
        }

        if(cashList.getCommissionLarge()==null){
            cashList.setCommissionLarge(BigDecimal.ZERO);
        }
        if(cashList.getCommissionZhonggong()==null){
            cashList.setCommissionZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCommissionTechnician()==null){
            cashList.setCommissionTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCommissionSmall()==null){
            cashList.setCommissionSmall(BigDecimal.ZERO);
        }


        if(cashList.getCardAchievementLarge()==null){
            cashList.setCardAchievementLarge(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementZhonggong()==null){
            cashList.setCardAchievementZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementTechnician()==null){
            cashList.setCardAchievementTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementSmall()==null){
            cashList.setCardAchievementSmall(BigDecimal.ZERO);
        }

        if(cashList.getCardCommissionLarge()==null){
            cashList.setCardCommissionLarge(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionZhonggong()==null){
            cashList.setCardCommissionZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionTechnician()==null){
            cashList.setCardCommissionTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionSmall()==null){
            cashList.setCardCommissionSmall(BigDecimal.ZERO);
        }









        List<AchiCommEntity> entities = new ArrayList<>();
        BigDecimal hundredBD = com.ssm.manage.utils.BigDecimalUtils.bigDecimal("100");
        //减掉固定金额业绩的单据总金额
        BigDecimal totalMeony = BigDecimal.ZERO;
        if(cashList.getCourseAccountId()!=null && cashList.getCourseMoney()!=null && cashList.getCourseMoney().compareTo(BigDecimal.ZERO)==1){
            totalMeony = cashList.getCourseMoney().multiply(BigDecimal.valueOf(cashList.getNumberTimes()));
        }else {
            totalMeony = cashList.getTransactionPrice().multiply(BigDecimal.valueOf(cashList.getNumberTimes()));
        }
        cashList.setAmount(totalMeony);
        //减掉固定金额业绩的单据卡付金额
        BigDecimal cardMeony =totalMeony;
        /**
        *  疗程卡付不需要再进行分业绩提成，直接使用疗程的成交单价进行计算提成喝业绩
        */
//        BaseProject baseProject = ssmProjectService.selectByPrimaryKey(cashList.getProjectId());
        BigDecimal cooperationRechargeAchi=new BigDecimal("0");//合作卡付业绩
        BigDecimal cashRechargeAchiSum=new BigDecimal("0");//合作总业绩
//        isCooperation 比例brokerage 1是比例 0是固定smokeCommissionWay
//        if(baseProject.getIsCooperation()==1){
//            if(baseProject.getSmokeCommissionWay()==1){//合作按比例
//                //合作项目卡付业绩
//                cooperationRechargeAchi=cooperationRechargeAchi.add(baseProject.getBrokerage().multiply(cardMeony).divide(hundredBD,10,BigDecimal.ROUND_HALF_UP));
//            }else{//合作按固定
//                cooperationRechargeAchi=baseProject.getBrokerage();
//            }
//        }
        cashRechargeAchiSum=cashRechargeAchiSum.add(cooperationRechargeAchi);
        cardMeony=cardMeony.subtract(cooperationRechargeAchi);//业绩-合作项目卡付业绩



        //存在卡付，也存在现付
        if((cashList.getCollectionCashAmount().add(cashList.getCollectionRechargeAmount())).compareTo(BigDecimal.valueOf(0)) == 1){//只有卡付
            //判断大工是否存在
            if(null != cashList.getServiceLargeOneStaffId() || null != cashList.getServiceLargeTwoStaffId() || null != cashList.getServiceLargeThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementLarge());
                }
            }

            //判断中工是否存在
            if(null != cashList.getServiceZhonggongOneStaffId() || null != cashList.getServiceZhonggongTwoStaffId() || null != cashList.getServiceZhonggongThreeStaffId()){
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementZhonggong());
                }
            }

            //判断小工（技师）是否存在
            if(null != cashList.getServiceTechnicianOneStaffId() || null != cashList.getServiceTechnicianTwoStaffId() || null != cashList.getServiceTechnicianThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementTechnician());
                }
            }

            //判断助理是否存在
            if(null != cashList.getServiceSmallOneStaffId() || null != cashList.getServiceSmallTwoStaffId() || null != cashList.getServiceSmallThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementSmall());
                }
            }

            //大工1编码
            if (null != cashList.getServiceLargeOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
                achiCommEntity.setSaleAchievementAmount(cashList.getAchievementLarge());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
                        BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }
                }

                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);
//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
//                    BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工2编码
            if (null != cashList.getServiceLargeTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工3编码
            if (null != cashList.getServiceLargeThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工4编码
            if (null != cashList.getServiceLargeFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFourRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工5编码
            if (null != cashList.getServiceLargeFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFiveRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工1编码
            if (null != cashList.getServiceZhonggongOneStaffId()){


                AchiCommEntity achiCommEntity = new AchiCommEntity();

                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(
                        BigDecimalUtils.add(
                                BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                                BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(
//                    BigDecimalUtils.add(
//                        BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                            BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工2编码
            if (null != cashList.getServiceZhonggongTwoStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工3编码
            if (null != cashList.getServiceZhonggongThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongThreeRatio()));
                  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工4编码
            if (null != cashList.getServiceZhonggongFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFourRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工5编码
            if (null != cashList.getServiceZhonggongFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFiveRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //技师5编码
            if (null != cashList.getServiceTechnicianOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianOneRatio()));
                  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
            //技师2编码
            if (null != cashList.getServiceTechnicianTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianTwoRatio()));
                  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //技师3编码
            if (null != cashList.getServiceTechnicianThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();

                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianThreeRatio()));
                  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理1编码
            if (null != cashList.getServiceSmallOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallOneRatio()));
                  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理2编码
            if (null != cashList.getServiceSmallTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallTwoRatio()));
                  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理3编码
            if (null != cashList.getServiceSmallThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallThreeRatio()));
                  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
        }
        else if(cashList.getCourseAccountId()!=null){//疗程消耗
            cashList.setCollectionCashAmount(cashList.getTransactionPrice());
            //判断大工是否存在
            if(null != cashList.getServiceLargeOneStaffId() || null != cashList.getServiceLargeTwoStaffId() || null != cashList.getServiceLargeThreeStaffId()){
                //判断卡付业绩是否为固定金额

                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementLarge());
                }
            }

            //判断中工是否存在
            if(null != cashList.getServiceZhonggongOneStaffId() || null != cashList.getServiceZhonggongTwoStaffId() || null != cashList.getServiceZhonggongThreeStaffId()){
                if(cashList.getCardAchievementZhonggong()!=null&&cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementZhonggong());
                }
            }

            //判断小工（技师）是否存在
            if(null != cashList.getServiceTechnicianOneStaffId() || null != cashList.getServiceTechnicianTwoStaffId() || null != cashList.getServiceTechnicianThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if((cashList.getCardAchievementTechnician()==null?BigDecimal.ZERO:cashList.getCardAchievementTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementTechnician());
                }
            }

            //判断助理是否存在
            if(null != cashList.getServiceSmallOneStaffId() || null != cashList.getServiceSmallTwoStaffId() || null != cashList.getServiceSmallThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementSmall());
                }
            }

            //大工1编码
            if (null != cashList.getServiceLargeOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
                achiCommEntity.setSaleAchievementAmount(cashList.getAchievementLarge());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
                        BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }
                }

                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);
//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
//                    BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工2编码
            if (null != cashList.getServiceLargeTwoStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工3编码
            if (null != cashList.getServiceLargeThreeStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工4编码
            if (null != cashList.getServiceLargeFourStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFourRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工5编码
            if (null != cashList.getServiceLargeFiveStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFiveRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工1编码
            if (null != cashList.getServiceZhonggongOneStaffId()){


                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(
                        BigDecimalUtils.add(
                                BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                                BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong()==null){
                    cashList.setCardAchievementZhonggong(BigDecimal.ZERO);
                }
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong()==null){
                        cashList.setCardCommissionZhonggong(BigDecimal.ZERO);
                    }
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(
//                    BigDecimalUtils.add(
//                        BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                            BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工2编码
            if (null != cashList.getServiceZhonggongTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工3编码
            if (null != cashList.getServiceZhonggongThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工4编码
            if (null != cashList.getServiceZhonggongFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFourRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工5编码
            if (null != cashList.getServiceZhonggongFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFiveRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //技师1编码
            if (null != cashList.getServiceTechnicianOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if((cashList.getCardAchievementTechnician()==null?BigDecimal.ZERO:cashList.getCardAchievementTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())==null?BigDecimal.ZERO:(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
            //技师2编码
            if (null != cashList.getServiceTechnicianTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //技师3编码
            if (null != cashList.getServiceTechnicianThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理1编码
            if (null != cashList.getServiceSmallOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理2编码
            if (null != cashList.getServiceSmallTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理3编码
            if (null != cashList.getServiceSmallThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
        }




        return entities;
    }

    //升级后修改的新疗程消费业绩提成算法
    public List<AchiCommEntity> getAchiCommListsCardNew(CashList cashList, CashListResponse cashListResponse){

        if(cashList.getLargeAchievementAmount()==null){
            cashList.setLargeAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getZhonggongAchievementAmount()==null){
            cashList.setZhonggongAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getTechnicianAchievementAmount()==null){
            cashList.setTechnicianAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getSmallAchievementAmount()==null){
            cashList.setSmallAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getLargeCommissionAmount()==null){
            cashList.setLargeCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getZhonggongCommissionAmount()==null){
            cashList.setZhonggongCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getTechnicianCommissionAmount()==null){
            cashList.setTechnicianCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getSmallCommissionAmount()==null){
            cashList.setSmallCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardLargeAchievementAmount()==null){
            cashList.setCardLargeAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardZhonggongAchievementAmount()==null){
            cashList.setCardZhonggongAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardTechnicianAchievementAmount()==null){
            cashList.setCardTechnicianAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardSmallAchievementAmount()==null){
            cashList.setCardSmallAchievementAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardLargeCommissionAmount()==null){
            cashList.setCardLargeCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardZhonggongCommissionAmount()==null){
            cashList.setCardZhonggongCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardTechnicianCommissionAmount()==null){
            cashList.setCardTechnicianCommissionAmount(BigDecimal.ZERO);
        }
        if(cashList.getCardSmallCommissionAmount()==null){
            cashList.setCardSmallCommissionAmount(BigDecimal.ZERO);
        }

        if(cashList.getAchievementLarge()==null){
            cashList.setAchievementLarge(BigDecimal.ZERO);
        }
        if(cashList.getAchievementZhonggong()==null){
            cashList.setAchievementZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getAchievementTechnician()==null){
            cashList.setAchievementTechnician(BigDecimal.ZERO);
        }
        if(cashList.getAchievementSmall()==null){
            cashList.setAchievementSmall(BigDecimal.ZERO);
        }

        if(cashList.getCommissionLarge()==null){
            cashList.setCommissionLarge(BigDecimal.ZERO);
        }
        if(cashList.getCommissionZhonggong()==null){
            cashList.setCommissionZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCommissionTechnician()==null){
            cashList.setCommissionTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCommissionSmall()==null){
            cashList.setCommissionSmall(BigDecimal.ZERO);
        }


        if(cashList.getCardAchievementLarge()==null){
            cashList.setCardAchievementLarge(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementZhonggong()==null){
            cashList.setCardAchievementZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementTechnician()==null){
            cashList.setCardAchievementTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCardAchievementSmall()==null){
            cashList.setCardAchievementSmall(BigDecimal.ZERO);
        }

        if(cashList.getCardCommissionLarge()==null){
            cashList.setCardCommissionLarge(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionZhonggong()==null){
            cashList.setCardCommissionZhonggong(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionTechnician()==null){
            cashList.setCardCommissionTechnician(BigDecimal.ZERO);
        }
        if(cashList.getCardCommissionSmall()==null){
            cashList.setCardCommissionSmall(BigDecimal.ZERO);
        }









        List<AchiCommEntity> entities = new ArrayList<>();
        BigDecimal hundredBD = com.ssm.manage.utils.BigDecimalUtils.bigDecimal("100");
        //减掉固定金额业绩的单据总金额
        BigDecimal totalMeony = cashList.getTransactionPrice().multiply(BigDecimal.valueOf(cashList.getCashNumber()));
        cashList.setAmount(totalMeony);
        //减掉固定金额业绩的单据卡付金额
        BigDecimal cardMeony =totalMeony;
        /**
         *  疗程卡付不需要再进行分业绩提成，直接使用疗程的成交单价进行计算提成喝业绩
         */
//        BaseProject baseProject = ssmProjectService.selectByPrimaryKey(cashList.getProjectId());
//        BeanUtils.copyProperties(baseProject,cashList);
        BigDecimal cooperationRechargeAchi=new BigDecimal("0");//合作卡付业绩
        BigDecimal cashRechargeAchiSum=new BigDecimal("0");//合作总业绩
//        isCooperation 比例brokerage 1是比例 0是固定smokeCommissionWay
//        if(baseProject.getIsCooperation()==1){
//            if(baseProject.getSmokeCommissionWay()==1){//合作按比例
//                //合作项目卡付业绩
//                cooperationRechargeAchi=cooperationRechargeAchi.add(baseProject.getBrokerage().multiply(cardMeony).divide(hundredBD,10,BigDecimal.ROUND_HALF_UP));
//            }else{//合作按固定
//                cooperationRechargeAchi=baseProject.getBrokerage();
//            }
//        }
//        cashRechargeAchiSum=cashRechargeAchiSum.add(cooperationRechargeAchi);
//        cardMeony=cardMeony.subtract(cooperationRechargeAchi);//业绩-合作项目卡付业绩



        //存在卡付，也存在现付
        if((cashList.getCollectionCashAmount().add(cashList.getCollectionRechargeAmount())).compareTo(BigDecimal.valueOf(0)) == 1){//只有卡付
            //判断大工是否存在
            if(null != cashList.getServiceLargeOneStaffId() || null != cashList.getServiceLargeTwoStaffId() || null != cashList.getServiceLargeThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementLarge());
                }
            }

            //判断中工是否存在
            if(null != cashList.getServiceZhonggongOneStaffId() || null != cashList.getServiceZhonggongTwoStaffId() || null != cashList.getServiceZhonggongThreeStaffId()){
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementZhonggong());
                }
            }

            //判断小工（技师）是否存在
            if(null != cashList.getServiceTechnicianOneStaffId() || null != cashList.getServiceTechnicianTwoStaffId() || null != cashList.getServiceTechnicianThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementTechnician());
                }
            }

            //判断助理是否存在
            if(null != cashList.getServiceSmallOneStaffId() || null != cashList.getServiceSmallTwoStaffId() || null != cashList.getServiceSmallThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementSmall());
                }
            }

            //大工1编码
            if (null != cashList.getServiceLargeOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
                achiCommEntity.setSaleAchievementAmount(cashList.getAchievementLarge());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
                        BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }
                }

                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);
//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
//                    BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工2编码
            if (null != cashList.getServiceLargeTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工3编码
            if (null != cashList.getServiceLargeThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工4编码
            if (null != cashList.getServiceLargeFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFourRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }

            //大工5编码
            if (null != cashList.getServiceLargeThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFiveRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工1编码
            if (null != cashList.getServiceZhonggongOneStaffId()){


                AchiCommEntity achiCommEntity = new AchiCommEntity();

                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(
                        BigDecimalUtils.add(
                                BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                                BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(
//                    BigDecimalUtils.add(
//                        BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                            BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工2编码
            if (null != cashList.getServiceZhonggongTwoStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工3编码
            if (null != cashList.getServiceZhonggongThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工4编码
            if (null != cashList.getServiceZhonggongFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFourRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工4编码
            if (null != cashList.getServiceZhonggongFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFiveRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //技师1编码
            if (null != cashList.getServiceTechnicianOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
            //技师2编码
            if (null != cashList.getServiceTechnicianTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //技师3编码
            if (null != cashList.getServiceTechnicianThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();

                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理1编码
            if (null != cashList.getServiceSmallOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理2编码
            if (null != cashList.getServiceSmallTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理3编码
            if (null != cashList.getServiceSmallThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
        }
        else if(cashList.getCourseAccountId()!=null){//疗程消耗
            cashList.setCollectionCashAmount(cashList.getTransactionPrice());
            //判断大工是否存在
            if(null != cashList.getServiceLargeOneStaffId() || null != cashList.getServiceLargeTwoStaffId() || null != cashList.getServiceLargeThreeStaffId()){
                //判断卡付业绩是否为固定金额

                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementLarge());
                }
            }

            //判断中工是否存在
            if(null != cashList.getServiceZhonggongOneStaffId() || null != cashList.getServiceZhonggongTwoStaffId() || null != cashList.getServiceZhonggongThreeStaffId()){
                if(cashList.getCardAchievementZhonggong()!=null&&cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementZhonggong());
                }
            }

            //判断小工（技师）是否存在
            if(null != cashList.getServiceTechnicianOneStaffId() || null != cashList.getServiceTechnicianTwoStaffId() || null != cashList.getServiceTechnicianThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if((cashList.getCardAchievementTechnician()==null?BigDecimal.ZERO:cashList.getCardAchievementTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementTechnician());
                }
            }

            //判断助理是否存在
            if(null != cashList.getServiceSmallOneStaffId() || null != cashList.getServiceSmallTwoStaffId() || null != cashList.getServiceSmallThreeStaffId()){
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){//a大于b//业绩提成比例> 1=固定金额
                    cardMeony= BigDecimalUtils.subtract(cardMeony,cashList.getCardAchievementSmall());
                }
            }

            //大工1编码
            if (null != cashList.getServiceLargeOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
                achiCommEntity.setSaleAchievementAmount(cashList.getAchievementLarge());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
                        BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }
                }

                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);
//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(
//                    BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工2编码
            if (null != cashList.getServiceLargeTwoStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工3编码
            if (null != cashList.getServiceLargeThreeStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工4编码
            if (null != cashList.getServiceLargeFourStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFourRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFourRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //大工5编码
            if (null != cashList.getServiceLargeFiveStaffId()){

                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceLargeFiveRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionLarge().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionLarge().multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionLarge()).multiply(BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);


//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getLargeFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceLargeFiveStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceLargeFiveStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceLargeFiveIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceLargeFiveRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeFiveRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardLargeAchievementAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardLargeCommissionAmount(),BigDecimalUtils.div(cashList.getServiceLargeThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工1编码
            if (null != cashList.getServiceZhonggongOneStaffId()){


                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(
                        BigDecimalUtils.add(
                                BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
                                BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
                                        BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong()==null){
                    cashList.setCardAchievementZhonggong(BigDecimal.ZERO);
                }
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong()==null){
                        cashList.setCardCommissionZhonggong(BigDecimal.ZERO);
                    }
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongOneNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongOneStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongOneStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongOneIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongOneRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(
//                    BigDecimalUtils.add(
//                        BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)),
//                            BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),
//                            BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongOneRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工2编码
            if (null != cashList.getServiceZhonggongTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工3编码
            if (null != cashList.getServiceZhonggongThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongThreeNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工2编码
            if (null != cashList.getServiceZhonggongFourStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFourRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //  achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFourNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFourStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFourStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFourIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFourRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                    }else{
                        //提成按百分百
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFourRatio(),hundredBD)));
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);

//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongTwoNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongTwoStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongTwoStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongTwoIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongTwoRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongTwoRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //中工3编码
            if (null != cashList.getServiceZhonggongFiveStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceZhonggongFiveRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongFiveStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongFiveStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongFiveIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceZhonggongFiveRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD))));

                //判断现付业绩是否为固定金额
                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionZhonggong().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionZhonggong().multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionZhonggong()).multiply(BigDecimalUtils.div(cashList.getServiceZhonggongFiveRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));
                entities.add(achiCommEntity);



//            AchiCommEntity achiCommEntity = new AchiCommEntity();
//            achiCommEntity.setDocNum(cashList.getCashNum());
//            achiCommEntity.setDocType(Constant.doc_type_store_cash);
//            achiCommEntity.setDocDate(cashList.getCashDate());
//            achiCommEntity.setTradeName(cashList.getProjectName());
//            achiCommEntity.setBrandNumber(cashList.getZhonggongFiveNumber());
//            achiCommEntity.setSaleStaffId(cashList.getServiceZhonggongThreeStaffId());
//            achiCommEntity.setSaleStaffName(cashList.getServiceZhonggongThreeStaffName());
//            achiCommEntity.setSaleIdentityCard(cashList.getServiceZhonggongThreeIdentityCard());
//            achiCommEntity.setSaleRatio(cashList.getServiceZhonggongThreeRatio());
//            achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)),
//                    BigDecimalUtils.multiply(cashList.getCardZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD))));
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getZhonggongAchievementAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getZhonggongCommissionAmount(),BigDecimalUtils.div(cashList.getServiceZhonggongThreeRatio(),hundredBD)));
//            entities.add(achiCommEntity);
            }
            //技师1编码
            if (null != cashList.getServiceTechnicianOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if((cashList.getCardAchievementTechnician()==null?BigDecimal.ZERO:cashList.getCardAchievementTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())==null?BigDecimal.ZERO:(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianOneRatio(),hundredBD)));
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
            //技师2编码
            if (null != cashList.getServiceTechnicianTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //技师3编码
            if (null != cashList.getServiceTechnicianThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceTechnicianThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getTechnicianThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceTechnicianThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceTechnicianThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceTechnicianThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceTechnicianThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementTechnician().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementTechnician().multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm((cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician()).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),(cashList.getCardCommissionTechnician()==null?BigDecimal.ZERO:cashList.getCardCommissionTechnician())).multiply(BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardTechnicianAchievementAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardTechnicianCommissionAmount(),BigDecimalUtils.div(cashList.getServiceTechnicianThreeRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理1编码
            if (null != cashList.getServiceSmallOneStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallOneRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallOneNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallOneStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallOneStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallOneIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallOneRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallOneRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理2编码
            if (null != cashList.getServiceSmallTwoStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallTwoRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallTwoNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallTwoStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallTwoStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallTwoIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallTwoRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD))));

                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

//            achiCommEntity.setCashAchi(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCashComm(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
//            achiCommEntity.setCardComm(BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallTwoRatio(),hundredBD)));
                entities.add(achiCommEntity);
            }
            //助理3编码
            if (null != cashList.getServiceSmallThreeStaffId()){
                AchiCommEntity achiCommEntity = new AchiCommEntity();
                achiCommEntity.setCooperationAchi(cashRechargeAchiSum.multiply(cashList.getServiceSmallThreeRatio()));
                achiCommEntity.setMoney(cashList.getAmount());
                //achiCommEntity.setMoney(cashList.getCashAmount());
                achiCommEntity.setMemberNum(String.valueOf(cashList.getMemberId()));
                achiCommEntity.setMemberName(cashList.getMemberName());
                achiCommEntity.setProjectId(String.valueOf(cashList.getProjectId()));
                achiCommEntity.setDocNum(cashList.getCashNum());
                achiCommEntity.setDocType(Constant.doc_type_store_cash);
                achiCommEntity.setOrderType("card");
                achiCommEntity.setDocDate(cashList.getCashDate());
                achiCommEntity.setTradeName(cashList.getProjectName());
                achiCommEntity.setBrandNumber(cashList.getSmallThreeNumber());
                achiCommEntity.setSaleStaffId(cashList.getServiceSmallThreeStaffId());
                achiCommEntity.setSaleStaffName(cashList.getServiceSmallThreeStaffName());
                achiCommEntity.setSaleIdentityCard(cashList.getServiceSmallThreeIdentityCard());
                achiCommEntity.setSaleRatio(cashList.getServiceSmallThreeRatio());
                achiCommEntity.setSaleAchievementAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallAchievementAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));
                achiCommEntity.setSaleCommissionAmount(BigDecimalUtils.add(BigDecimalUtils.multiply(cashList.getSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)),
                        BigDecimalUtils.multiply(cashList.getCardSmallCommissionAmount(),BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD))));


                //判断卡付业绩是否为固定金额
                if(cashList.getCardAchievementSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                    //卡付业绩按固定金额计算
                    //计算卡付业绩
                    achiCommEntity.setCardAchi(cashList.getCardAchievementSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }

                }else{
                    //卡付业绩比例计算
                    achiCommEntity.setCardAchi(BigDecimalUtils.multiply(cardMeony,cashList.getCardAchievementSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));

                    //计算卡付提成
                    //判断卡付提成是否为固定金额
                    if(cashList.getCardCommissionSmall().compareTo(BigDecimal.valueOf(1)) == 1){
                        //提成按固定金额算
                        achiCommEntity.setCardComm(cashList.getCardCommissionSmall().multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }else{
                        //提成按百分百
                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()));
//                        achiCommEntity.setCardComm(BigDecimalUtils.multiply(achiCommEntity.getCardAchi(),cashList.getCardCommissionSmall()).multiply(BigDecimalUtils.div(cashList.getServiceSmallThreeRatio(),hundredBD)));
                    }
                }
                if(null == achiCommEntity.getCashAchi()){
                    achiCommEntity.setCashAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardAchi() ){
                    achiCommEntity.setCardAchi(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCashComm()){
                    achiCommEntity.setCashComm(BigDecimal.valueOf(0));
                }
                if(null == achiCommEntity.getCardComm()){
                    achiCommEntity.setCardComm(BigDecimal.valueOf(0));
                }
                achiCommEntity.setTotalPerformance(BigDecimalUtils.add(achiCommEntity.getCashAchi(),achiCommEntity.getCardAchi()));
                achiCommEntity.setTotalCommission(BigDecimalUtils.add(achiCommEntity.getCashComm(),achiCommEntity.getCardComm()));

                entities.add(achiCommEntity);
            }
        }




        return entities;
    }

    @Override
    public PageInfo<CashListResponse> selectByMember(CashListRequest cashListRequest) throws SmsException {
        Date date = null;
        try {
            date = DateUtils.YMParse(cashListRequest.getSelectDate());
        } catch (ParseException e) {
            throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
        }
        cashListRequest.setCashDate(date);
        PageInfo<CashList> pageInfo = dao.selectPage(cashListRequest);
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);

            //设置业务人员列表
            List<AchiCommEntity> entities = this.getAchiCommList(cashList,cashListResponse);
            cashListResponse.setEntities(entities);
            listResponses.add(cashListResponse);
        }
        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        return p;
    }

    @Override
    public PageInfo<CashListResponse> selectProgress(CashListRequest cashListRequest) throws SmsException {
        Date date = null;
        try {
            date = DateUtils.YMParse(cashListRequest.getSelectDate());
        } catch (ParseException e) {
            throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
        }
        cashListRequest.setCashDate(date);
        PageInfo<CashList> pageInfo = dao.selectProgress(cashListRequest);
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);

            //设置业务人员列表
            List<AchiCommEntity> entities = this.getAchiCommList(cashList,cashListResponse);
            cashListResponse.setEntities(entities);
            listResponses.add(cashListResponse);
        }
        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        return p;
    }

    @Override
    public PageInfo<StaffProgress> selectStaffProgress(StaffProgress staffProgress) throws SmsException {
        Date date = null;
        try {
            date = DateUtils.YMParse(staffProgress.getSelectDate());
        } catch (ParseException e) {
            throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
        }
        staffProgress.setCashDate(date);
        return dao.selectStaffProgress(staffProgress);
    }

    @Override
    public List<StoreDaily> selectDayRecord(StoreDailyRequest storeDailyRequest) throws SmsException {
        return dao.selectDayRecord(storeDailyRequest);
    }
    @Override
    public List<StoreDaily> selectDayRecordManAndWoman(StoreDailyRequest storeDailyRequest) throws SmsException {
        return dao.selectDayRecordManAndWoman(storeDailyRequest);
    }
    @Override
    public List<StoreDaily> selectDayRecordRec(StoreDailyRequest storeDailyRequest) throws SmsException {
        return dao.selectDayRecordRec(storeDailyRequest);
    }
    @Override
    public List<StoreDaily> selectDayRecordRecByDate(StoreDailyRequest storeDailyRequest) throws SmsException {
        return mapper.selectDayRecordRecByDate(storeDailyRequest);
    }
    @Override
    public List<StoreDaily> selectDayRecordCou(StoreDailyRequest storeDailyRequest) throws SmsException {
        return dao.selectDayRecordCou(storeDailyRequest);
    }

    @Override
    public List<StoreDaily> selectDayRecordCouByDate(StoreDailyRequest storeDailyRequest) throws SmsException {
        return mapper.selectDayRecordCouByDate(storeDailyRequest);
    }

    @Override
    public PageInfo<CashListResponse> selectByRecharge(AccountTradeRecordRequest accountTradeRecordRequest) {

        PageInfo<CashList> pageInfo = dao.selectByRecharge(accountTradeRecordRequest);
        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList, cashListResponse);

            //设置业务人员列表
            List<AchiCommEntity> entities = this.getAchiCommList(cashList,cashListResponse);
            cashListResponse.setEntities(entities);
            listResponses.add(cashListResponse);
        }
        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        return p;
    }

    @Override
    public List<StoreDaily> selectRecordByMonth(StoreDailyRequest storeDailyRequest) throws SmsException, ParseException {
        CashListRequest cashListRequest = new CashListRequest();
        cashListRequest.setStoreId(storeDailyRequest.getStoreId());
        cashListRequest.setDateStr(storeDailyRequest.getDateStr());
        cashListRequest.setCashDate(storeDailyRequest.getDate());
        cashListRequest.setIsCancel(0);
        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
        //校验门店注册时间 时间之前的数据不允许查看     门店注册日期  单据日期
        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())), cashListRequest.getCashDate()) < 0){
            throw new SmsException(ResponseCode.NO_DATA);
        }
        //使用了pagehelper 自动添加了一个limit 字段，所以导致数据只有10条，需修改dao层，service层
        List<CashList> lists = dao.selectPage2(cashListRequest);
        //PageInfo<CashList> pageInfo = dao.selectPage(cashListRequest);
        //List<CashList> lists = pageInfo.getList();

        Map<String, List<CashList>> map = new HashMap<>();
        if (!lists.isEmpty()) {
            //对list进行分组生成map    by 单据日期
            map = lists.stream().collect(Collectors.groupingBy(item -> DateUtils.ymdFormat(item.getCashDate())));
        }
        //然后对map按时间进行升序排序
//        map = map.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEachOrdered(e -> result.put(e.getKey(), e.getValue()));
        Map<String, List<CashList>> sortMap = new TreeMap<>(map);
        List<StoreDaily> storeDailyList = new ArrayList<>();
        for (Map.Entry<String, List<CashList>> entry : sortMap.entrySet()) {
            List<CashList> cashLists = entry.getValue();
            StoreDaily storeDaily = new StoreDaily();
            //计算业绩   过滤0正常的显示   map 将项目成交单价过滤出来 然后 使用 reduce 合计
            BigDecimal cashMoney = cashLists.stream().filter(cashList -> 0 == cashList.getIsCancel()).map(CashList::getTransactionPrice).reduce(BigDecimal.ZERO,BigDecimal::add);
            storeDaily.setDocDate(DateUtils.ymdString2Date(entry.getKey()));
            storeDaily.setCashMoney(null == cashMoney ? com.ssm.manage.utils.BigDecimalUtils.bigDecimal("0"):cashMoney);
            storeDaily.setCashPeopleNum(entry.getValue().size());
            storeDaily.setStoreId(baseStore.getId());
            storeDaily.setStoreName(baseStore.getStoreName());
            storeDailyList.add(storeDaily);
        }
//        Collections.reverse(storeDailyList);
        return storeDailyList;
    }

    @Transactional(rollbackFor=Exception.class)
    @Override
    public List<CashList> selectDownloadRecord(CashListRequest cashListRequest) throws SmsException, ParseException {
        List<CashList> lists = new ArrayList<>();
        //首先将下载记录添加到记录表
        CashDownloadRecord cashDownloadRecord = new CashDownloadRecord();
        BeanUtils.copyProperties(cashListRequest, cashDownloadRecord);
        Set<String> keys = redisClient.keys(getStaffKey(cashListRequest.getStaffPhone()) + "*");
        //从redis查询 设置操作人信息 app使用
        if (keys.size() > 0){
            String key =  new ArrayList<>(keys).get(0);
            StaffResponse staffResponse = redisClient.get(key);
            cashDownloadRecord.setStaffId(staffResponse.getId());
            cashDownloadRecord.setStaffName(staffResponse.getStaffName());
        }
        //插入记录
        int i = 0;
        try {
            i = ssmCashDownloadRecordService.addRecord(cashDownloadRecord);
        }catch (Exception e){
            log.error("SsmCashServiceImpl.selectDownloadRecord:",e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            throw new SmsException(ResponseCode.UNKNOWN_SYSTEM_EXCEPTION);
        }
        if (i > 0) {
            cashListRequest.setCashDate(DateUtils.ymParse(cashListRequest.getDateStr()));
            BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
            //校验门店注册时间 时间之前的数据不允许查看
            if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())), cashListRequest.getCashDate()) < 0) {
                throw new SmsException(ResponseCode.NO_DATA);
            }
            lists = dao.selectDownloadRecord(cashListRequest);
        }
        return lists;
    }

    public String getStaffKey(String phone){
        return staffKey + phone;
    }

    @Override
    public List<CashList> selectList(CashListRequest cashListRequest) throws SmsException, ParseException {
        return dao.selectPage3(cashListRequest);
    }

    @Override
    public List<CashList> selectListSalem(CashList cashList){
        return dao.selectListSalem(cashList);
    }

    @Override
    public int updatechia(CashList cashList){
        return dao.updatechia(cashList);
    }

    @Override
    public AccountTradeRecord retransmission(AccountTradeRecord accountTradeRecord) throws SmsException, ParseException {
        return ssmAccountTradeRecordService.retransmission(accountTradeRecord);
    }

    @Override
    public List<CashList> getAllCashList(CashListRequest cashListRequest) {

        return dao.getAllCashList(cashListRequest);
    }

    @Override
    public List<CashDayVo> selectByDay(StoreDailyRequest storeDailyRequest) {
        return dao.selectByDay(storeDailyRequest);
    }

    @Override
    public List<StoreDaily> selectByDayGroupByDateAndStoreId(StoreDailyRequest storeDailyRequest) {
        return dao.selectByDayGroupByDateAndStoreId(storeDailyRequest);
    }

    @Override
    public List<CashList> selectListByMonthly(CashListRequest cashListRequest) {
        return mapper.selectListByMonthly(cashListRequest);
    }

    @Override
    public BigDecimal selectFKJByRefundCashGifMoney(StoreDailyRequest storeDailyRequest) {
        return mapper.selectFKJByRefundCashGifMoney(storeDailyRequest);
    }

    @Override
    public PageInfo<CashListResponse> cashListByDocNum(CashListRequest cashListRequest) {
        Date date = null;
        try {
            date = DateUtils.YMParse(cashListRequest.getSelectDate());
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        cashListRequest.setCashDate(date);
//        BaseStore baseStore = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
//        if (DateUtils.compare(DateUtils.YMParse(DateUtils.YMFormat(baseStore.getFunderDate())),date) < 0){
//            throw new SmsException(ResponseCode.NO_DATA);
//        }
        List<Long> lists = new ArrayList<>();
        if(cashListRequest.getSelectType()==0){
            lists=cashListRequest.getStoreList();
        }else{
            BaseStore baseStore1 = ssmBaseStoreService.selectByPrimaryKey(cashListRequest.getStoreId());
            if(null == baseStore1.getParentId()&&(cashListRequest.getStoreList().size()<0||cashListRequest.getStoreList()==null)){
                StoreRequest storeRequest = new StoreRequest();
                storeRequest.setId(cashListRequest.getStoreId());
                List<BaseStores> pagesorganizations = ssmBaseStoreService.pagesorganizations(storeRequest);
                List<Long> collect = pagesorganizations.stream().map(BaseStores::getId).collect(Collectors.toList());
                lists=collect;
            }else{
                lists.add(cashListRequest.getStoreId());
            }

        }


        cashListRequest.setStoreList(lists);
        //按单据号分组之后的数据
        //PageInfo<CashList> pageInfo = dao.selectCashList(cashListRequest);
        PageInfo<CashList> pageInfo = dao.selectCashListGroupNew(cashListRequest);


        List<CashListResponse> listResponses = new ArrayList<>();
        for (CashList cashList : pageInfo.getList()) {
//                CashListRequest cashListnew  = new CashListRequest();
//                String docNum = cashList.getCashNum();
//                cashListnew.setCashNum(docNum);
//                String substring = docNum.substring(docNum.length()-11, docNum.length() - 3);
////                System.out.println(substring);
//                StrBuilder strBuilder = new StrBuilder(substring);
//                StrBuilder insert = strBuilder.insert(6, "-").insert(10, "-");
//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//                Date parse = simpleDateFormat.parse(String.valueOf(insert));
//                cashList.setCashDate(parse);
////                System.out.println(insert);
//                List<CashList> cashListsnew  = this.selectList(cashListnew);

            CashListResponse cashListResponse = new CashListResponse();
            BeanUtils.copyProperties(cashList,cashListResponse);
//            //隐藏手机号码
//            String memberPhone = CommonUtils.mobileHide(cashList.getMobilePhone());
//            cashListResponse.setMobilePhone(memberPhone);
            cashListRequest.setCashNum(cashList.getCashNum());
            cashListRequest.setId(null);
            cashListRequest.setStoreId(cashList.getStoreId());
            List<CashList> cashLists = dao.selectByNum(cashListRequest);
            List<ProjectRequest> projectRequestsList = new ArrayList<>();

            for (CashList list : cashLists) {
                //项目列表
                cashListResponse.setInputId(list.getInputId());
                List<ProjectRequest> projectRequests = new ArrayList<>();
                //设置项目列表
                projectRequests = this.setProject(projectRequests,list);
                for (ProjectRequest projectRequest : projectRequests) {
//                    for (CashList cashList1 : cashListsnew) {
//
//                    }
                    if(projectRequest.getCourseAccountId()!=null){
                        CourseAccount courseAccount = new CourseAccount();
                        courseAccount.setId(projectRequest.getCourseAccountId());
                        CourseAccount courseAccount1 = ssmCourseAccountService.selectOne(courseAccount);
                        projectRequest.setCourseRestCount(courseAccount1.getCourseRestCount());
                        cashListResponse.setIsCoursePay(1);
                    }
                    projectRequest.setCollectionAmount(list.getCollectionAmount());
                    projectRequest.setRemark(list.getRemark());
                    projectRequest.setSex(list.getSex());
                    BaseProject baseProject = new BaseProject();
                    baseProject.setId(projectRequest.getId());
                    BaseProject baseProject1 = ssmProjectService.selectOne(baseProject);
                    if(null != baseProject1){
                        projectRequest.setProjectNum(baseProject1.getProjectNum());
                    }

                }
                for (ProjectRequest projectRequest : projectRequests) {
                    projectRequest.setOnePrice(list.getPrice().divide(BigDecimal.valueOf(list.getNumberTimes()==0?1:list.getNumberTimes()),10,BigDecimal.ROUND_HALF_UP));
                    projectRequest.setNumber(list.getNumberTimes());
                    projectRequestsList.add(projectRequest);
                }
            }

            cashListResponse.setProjectList(projectRequestsList);

            double rechargeSum=0;
            double cashSum = 0;


            for(ProjectRequest projectRequest:projectRequestsList){
                cashSum+=(projectRequest.getCollectionCashAmount()==null?0:projectRequest.getCollectionCashAmount().doubleValue());
                rechargeSum+=(projectRequest.getCollectionRechargeAmount()==null?0:projectRequest.getCollectionRechargeAmount().doubleValue());
//                if(projectRequest.getCollectionCashAmount().doubleValue()==0&&projectRequest.getCollectionRechargeAmount().doubleValue()==0){
//                    rechargeSum+=(projectRequest.getCashAmount()==null?0:projectRequest.getCashAmount().doubleValue());
//                }
                if(projectRequest.getCourseAccountId()!=null){
                    rechargeSum += projectRequest.getTransactionPrice().multiply(BigDecimal.valueOf(projectRequest.getNumber())).doubleValue();
                }
                // .setScale(10, BigDecimal.ROUND_HALF_UP)
                //rechargeSum.add(projectRequest.getCollectionRechargeAmount()==null?new BigDecimal("0"):projectRequest.getCollectionRechargeAmount());
            }
            BigDecimal rechargeSum1=BigDecimalUtils.bigDecimalRound(BigDecimal.valueOf(rechargeSum),2);
            rechargeSum=rechargeSum1.doubleValue();
            cashListResponse.setCashSum(cashSum);
            cashListResponse.setRechargeSum(rechargeSum);


            cashListResponse.setEntities(this.getAchiCommList(cashList, cashListResponse));
            if(cashListResponse.getIsCoursePay()==null){
                cashListResponse.setIsCoursePay(0);
            }
            listResponses.add(cashListResponse);
        }
        for (CashListResponse projectRequest : listResponses) {

            //查询员工num
            if(projectRequest.getInputId()!=null){
                BaseStaff baseStaff = ssmBaseStaffService.selectByPrimaryKey(projectRequest.getInputId());
                projectRequest.setInputNum(baseStaff.getStaffNum());
            }

            //查询现付列表
            PayList payList = new PayList();
            payList.setDocId(projectRequest.getCashNum());
            payList.setStoreId(projectRequest.getStoreId());
            List<PayList> payLists = ssmPayService.select(payList);
            projectRequest.setPayLists(payLists);
            List<ProjectRequest> projectList = projectRequest.getProjectList();

            for (ProjectRequest request : projectList) {
                Salesman salesman = new Salesman();
                salesman.setOrderId(String.valueOf(projectRequest.getId()));
                salesman.setOrderType(0);
                salesman.setOrderNum(projectRequest.getCashNum());
                salesman.setProjectId(request.getId());
                List<Salesman> salesmen = ssmSalesmanService.selectList(salesman);
                request.setSalesmens(salesmen);

            }

        }
        PageInfo<CashListResponse> p =  new PageInfo<>(listResponses);
        p.setTotal(pageInfo.getTotal());
        return p;
    }

}
