package thyyxxk.webserver.entity.zygl;

import cn.hutool.core.convert.Convert;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 住院日结报表
 */
@Data
public class ZyDailySettlementVo {
    //最后一次结算时间
    private String lastDailyDate;
    //本次结算时间
    private String currentDate;
    //结算人
    private String opName;
    //工号
    private String opCodeRs;
    //结算总金额
    private BigDecimal totalCharge;
    //发票金额
    private BigDecimal receiptAmount;
    //记账总额 社保记账
    private BigDecimal jzAmount;
    //发票张数
    private Integer fpCount;
    //现金缴纳的预收金金额
    private BigDecimal depositCashAmount;
    //现金缴纳的预收金次数
    private Integer depositCashNum;
    //微信缴纳的预收金金额
    private BigDecimal depositWxAmount;
    //微信缴纳的预收金次数
    private Integer depositWxNum;
    //支付宝缴纳的预收金金额
    private BigDecimal depositZfbAmount;
    //支付宝缴纳的预收金次数
    private Integer depositZfbNum;
    //医保缴纳的预收金金额
    private BigDecimal depositYbAmount;
    //医保宝缴纳的预收金次数
    private Integer depositYbNum;
    //银联卡缴纳的预收金金额
    private BigDecimal depositYlkAmount;
    //银联卡宝缴纳的预收金次数
    private Integer depositYlkNum;
    //其他缴纳的预收金金额
    private BigDecimal depositQtAmount;
    //其他缴纳的预收金次数
    private Integer depositQtNum;
    //聚合支付缴纳的预收金金额
    private BigDecimal depositJhzfAmount;
    //聚合支付缴纳的预收金次数
    private Integer depositJhzfNum;
    //合计缴纳的预收金金额
    private BigDecimal depositTotalAmount;
    //合计缴纳的预收金次数
    private Integer depositTotalNum;
    //本院记账缴纳的预收金金额 记账金额
    private BigDecimal depositByjzAmount;
    //现金退费的预收金金额
    private BigDecimal returnCashAmount;
    //现金退费的预收金次数
    private Integer returnCashNum;
    //微信退费的预收金金额
    private BigDecimal returnWxAmount;
    //微信退费的预收金次数
    private Integer returnWxNum;
    //支付宝退费的预收金金额
    private BigDecimal returnZfbAmount;
    //支付宝退费的预收金次数
    private Integer returnZfbNum;
    //医保退费的预收金金额
    private BigDecimal returnYbAmount;
    //医保宝退费的预收金次数
    private Integer returnYbNum;
    //银联卡退费的预收金金额
    private BigDecimal returnYlkAmount;
    //银联卡宝退费的预收金次数
    private Integer returnYlkNum;
    //其他退费的预收金金额
    private BigDecimal returnQtAmount;
    //其他退费的预收金次数
    private Integer returnQtNum;
    //聚合支付退费的预收金金额
    private BigDecimal returnJhzfAmount;
    //聚合支付退费的预收金次数
    private Integer returnJhzfNum;
    //合计退费的预收金金额
    private BigDecimal returnTotalAmount;
    //合计退费的预收金次数
    private Integer returnTotalNum;
    //现金结算补款金额
    private BigDecimal jsbkCashAmount;
    //微信结算补款金额
    private BigDecimal jsbkWxAmount;
    //支付宝结算补款金额
    private BigDecimal jsbkZfbAmount;
    //医保卡结算补款金额
    private BigDecimal jsbkYbAmount;
    //银联卡结算补款金额
    private BigDecimal jsbkYlkAmount;
    //其他结算补款金额
    private BigDecimal jsbkQtAmount;
    //聚合支付结算补款金额
    private BigDecimal jsbkJhzfAmount;
    //合计结算补款金额
    private BigDecimal jsbkTotalAmount;
    //现金结算退款金额
    private BigDecimal jstkCashAmount;
    //微信结算退款金额
    private BigDecimal jstkWxAmount;
    //支付宝结算退款金额
    private BigDecimal jstkZfbAmount;
    //医保卡结算退款金额
    private BigDecimal jstkYbAmount;
    //银联卡结算退款金额
    private BigDecimal jstkYlkAmount;
    //其他结算退款金额
    private BigDecimal jstkQtAmount;
    //聚合支付结算退款金额
    private BigDecimal jstkJhzfAmount;
    //合计结算退款金额
    private BigDecimal jstkTotalAmount;
    //民政优抚金额
    private BigDecimal jsjzMzyfAmount;
    //产妇补助
    private BigDecimal jsCfbzAmount;
    //医保支付金额
    private BigDecimal ybjzAmount;
    //核算金额 回收预交金金额
    private BigDecimal hsJe;
    //核算次数 回收预交金笔数
    private Integer hsCount;

    //预交金上缴合计 现金 部分金额
    private BigDecimal yjjsjhjCashAmount;
    //预交金上缴合计 微信 部分金额
    private BigDecimal yjjsjhjWxAmount;
    //预交金上缴合计 支付宝 部分金额
    private BigDecimal yjjsjhjZfbAmount;
    //预交金上缴合计 医保卡 部分金额
    private BigDecimal yjjsjhjYbkAmount;
    //预交金上缴合计 银联卡 部分金额
    private BigDecimal yjjsjhjYlkAmount;
    //预交金上缴合计 其他 部分金额
    private BigDecimal yjjsjhjQtAmount;
    //预交金上缴合计 聚合支付 部分金额
    private BigDecimal yjjsjhjJhzfAmount;
    //预交金上缴合计 合计 部分金额
    private BigDecimal yjjsjhjHjAmount;
    //预交金上缴合计大写
    private String yjjsjhjHjAmountStr;

    //结算补退合计 现金 部分金额
    private BigDecimal jsbtCashAmount;
    //结算补退合计 微信 部分金额
    private BigDecimal jsbtWxAmount;
    //结算补退合计 支付宝 部分金额
    private BigDecimal jsbtZfbAmount;
    //结算补退合计 医保卡 部分金额
    private BigDecimal jsbtYbkAmount;
    //结算补退合计 银联卡 部分金额
    private BigDecimal jsbtYlkAmount;
    //结算补退合计 其他 部分金额
    private BigDecimal jsbtQtAmount;
    //结算补退合计 聚合支付 部分金额
    private BigDecimal jsbtJhzfAmount;
    //结算补退合计 合计 部分金额
    private BigDecimal jsbtHjAmount;
    //结算补退合计大写
    private String jsbtHjAmountStr;
    //包干返回 本院医保垫付
    private BigDecimal totalByybdf;
    //上缴合计 现金 部分金额
    private BigDecimal sjhjCashAmount;
    //上缴合计 微信 部分金额
    private BigDecimal sjhjWxAmount;
    //上缴合计 支付宝 部分金额
    private BigDecimal sjhjZfbAmount;
    //上缴合计 医保卡 部分金额
    private BigDecimal sjhjYbkAmount;
    //上缴合计 银联卡 部分金额
    private BigDecimal sjhjYlkAmount;
    //上缴合计 聚合支付 部分金额
    private BigDecimal sjhjJhzfAmount;
    //转账部分金额
    private BigDecimal zzAmount;
    //发票现金部分金额
    private BigDecimal fpxjAmount;

    /**
     * 预交金收费列表
     */
    private List<Map<String, Object>> chargeZyDepositFileList;

    /**
     * 预交金退费列表
     */
    private List<Map<String, Object>> refunfZyDepositFileList;
    /**
     * 预交金收据号开始单据号
     */
    private String receiptNoBegin;
    /**
     * 预交金收据号结束单据号
     */
    private String receiptNoEnd;
    /**
     * 结算收据号开始单据号
     */
    private String jsReceiptNoBegin;
    /**
     * 结算收据号结束单据号
     */
    private String jsReceiptNoEnd;

    /**
     * 结算病人明细
     */
    private List<Map<String, Object>> zyChargeDetailList;
    /**
     * 结算预交金明细
     */
    private List<Map<String, Object>> jsYjjDetailList;

    /**
     * 结算费用登记报表
     */
    private List<Map<String, Object>> jsfydjbb;

    /**
     * 设置预交金合计
     */
    public void sumtDepositTotal() {
        //收预交金
        if (depositCashAmount == null) {
            depositCashAmount = BigDecimal.ZERO;
        }
        if (depositWxAmount == null) {
            depositWxAmount = BigDecimal.ZERO;
        }
        if (depositZfbAmount == null) {
            depositZfbAmount = BigDecimal.ZERO;
        }
        if (depositYbAmount == null) {
            depositYbAmount = BigDecimal.ZERO;
        }
        if (depositYlkAmount == null) {
            depositYlkAmount = BigDecimal.ZERO;
        }
        if (depositQtAmount == null) {
            depositQtAmount = BigDecimal.ZERO;
        }
        if (depositJhzfAmount == null) {
            depositJhzfAmount = BigDecimal.ZERO;
        }
        depositTotalAmount = depositCashAmount.add(depositWxAmount).add(depositZfbAmount).add(depositYbAmount).add(depositYlkAmount).add(depositQtAmount).add(depositJhzfAmount);
        if (depositCashNum == null) {
            depositCashNum = 0;
        }
        if (depositWxNum == null) {
            depositWxNum = 0;
        }
        if (depositZfbNum == null) {
            depositZfbNum = 0;
        }
        if (depositYbNum == null) {
            depositYbNum = 0;
        }
        if (depositYlkNum == null) {
            depositYlkNum = 0;
        }
        if (depositQtNum == null) {
            depositQtNum = 0;
        }
        if (depositJhzfNum == null) {
            depositJhzfNum = 0;
        }
        depositTotalNum = depositCashNum + depositWxNum + depositZfbNum + depositYbNum + depositYlkNum + depositQtNum+depositJhzfNum;

        //退预交金
        if (returnCashAmount == null) {
            returnCashAmount = BigDecimal.ZERO;
        } else if (returnCashAmount.compareTo(BigDecimal.ZERO) == -1) {
            returnCashAmount = BigDecimal.ZERO.subtract(returnCashAmount);
        }
        if (returnWxAmount == null) {
            returnWxAmount = BigDecimal.ZERO;
        } else if (returnWxAmount.compareTo(BigDecimal.ZERO) == -1) {
            returnWxAmount = BigDecimal.ZERO.subtract(returnWxAmount);
        }
        if (returnZfbAmount == null) {
            returnZfbAmount = BigDecimal.ZERO;
        } else if (returnZfbAmount.compareTo(BigDecimal.ZERO) == -1) {
            returnZfbAmount = BigDecimal.ZERO.subtract(returnZfbAmount);
        }
        if (returnYbAmount == null) {
            returnYbAmount = BigDecimal.ZERO;
        } else if (returnYbAmount.compareTo(BigDecimal.ZERO) == -1) {
            returnYbAmount = BigDecimal.ZERO.subtract(returnYbAmount);
        }
        if (returnYlkAmount == null) {
            returnYlkAmount = BigDecimal.ZERO;
        } else if (returnYlkAmount.compareTo(BigDecimal.ZERO) == -1) {
            returnYlkAmount = BigDecimal.ZERO.subtract(returnYlkAmount);
        }
        if (returnQtAmount == null) {
            returnQtAmount = BigDecimal.ZERO;
        } else if (returnQtAmount.compareTo(BigDecimal.ZERO) == -1) {
            returnQtAmount = BigDecimal.ZERO.subtract(returnQtAmount);
        }
        if (returnJhzfAmount == null) {
            returnJhzfAmount = BigDecimal.ZERO;
        } else if (returnJhzfAmount.compareTo(BigDecimal.ZERO) == -1) {
            returnJhzfAmount = BigDecimal.ZERO.subtract(returnJhzfAmount);
        }
        returnTotalAmount = returnCashAmount.add(returnWxAmount).add(returnZfbAmount).add(returnYbAmount).add(returnYlkAmount).add(returnQtAmount).add(returnJhzfAmount);
        if (returnCashNum == null) {
            returnCashNum = 0;
        }
        if (returnWxNum == null) {
            returnWxNum = 0;
        }
        if (returnZfbNum == null) {
            returnZfbNum = 0;
        }
        if (returnYbNum == null) {
            returnYbNum = 0;
        }
        if (returnYlkNum == null) {
            returnYlkNum = 0;
        }
        if (returnQtNum == null) {
            returnQtNum = 0;
        }
        if (returnJhzfNum == null) {
            returnJhzfNum = 0;
        }
        returnTotalNum = returnCashNum + returnWxNum + returnZfbNum + returnYbNum + returnYlkNum + returnQtNum+returnJhzfNum;

        //结算补款
        if (jsbkCashAmount == null) {
            jsbkCashAmount = BigDecimal.ZERO;
        }
        if (jsbkWxAmount == null) {
            jsbkWxAmount = BigDecimal.ZERO;
        }
        if (jsbkZfbAmount == null) {
            jsbkZfbAmount = BigDecimal.ZERO;
        }
        if (jsbkYbAmount == null) {
            jsbkYbAmount = BigDecimal.ZERO;
        }
        if (jsbkYlkAmount == null) {
            jsbkYlkAmount = BigDecimal.ZERO;
        }
        if (jsbkQtAmount == null) {
            jsbkQtAmount = BigDecimal.ZERO;
        }
        if (jsbkJhzfAmount == null) {
            jsbkJhzfAmount = BigDecimal.ZERO;
        }
        jsbkTotalAmount = jsbkCashAmount.add(jsbkWxAmount).add(jsbkZfbAmount).add(jsbkYbAmount).add(jsbkYlkAmount).add(jsbkQtAmount).add(jsbkJhzfAmount);
        //结算退款
        if (jstkCashAmount == null) {
            jstkCashAmount = BigDecimal.ZERO;
        }
        if (jstkWxAmount == null) {
            jstkWxAmount = BigDecimal.ZERO;
        }
        if (jstkZfbAmount == null) {
            jstkZfbAmount = BigDecimal.ZERO;
        }
        if (jstkYbAmount == null) {
            jstkYbAmount = BigDecimal.ZERO;
        }
        if (jstkYlkAmount == null) {
            jstkYlkAmount = BigDecimal.ZERO;
        }
        if (jstkQtAmount == null) {
            jstkQtAmount = BigDecimal.ZERO;
        }
        if (jstkJhzfAmount == null) {
            jstkJhzfAmount = BigDecimal.ZERO;
        }
        jstkTotalAmount = jstkCashAmount.add(jstkWxAmount).add(jstkZfbAmount).add(jstkYbAmount).add(jstkYlkAmount).add(jstkQtAmount).add(jstkJhzfAmount);
        //医保支付金额
        if (jzAmount == null) {
            jzAmount = BigDecimal.ZERO;
        }
        if (jsjzMzyfAmount == null) {
            jsjzMzyfAmount = BigDecimal.ZERO;
        }
        if (jsCfbzAmount == null) {
            jsCfbzAmount = BigDecimal.ZERO;
        }
        ybjzAmount = jzAmount.subtract(jsjzMzyfAmount);

        yjjsjhjCashAmount = depositCashAmount.subtract(returnCashAmount);
        yjjsjhjWxAmount = depositWxAmount.subtract(returnWxAmount);
        yjjsjhjZfbAmount = depositZfbAmount.subtract(returnZfbAmount);
        yjjsjhjYbkAmount = depositYbAmount.subtract(returnYbAmount);
        yjjsjhjYlkAmount = depositYlkAmount.subtract(returnYlkAmount);
        yjjsjhjQtAmount = depositQtAmount.subtract(returnQtAmount);
        yjjsjhjJhzfAmount = depositJhzfAmount.subtract(returnJhzfAmount);
        yjjsjhjHjAmount = depositTotalAmount.subtract(returnTotalAmount);
        yjjsjhjHjAmountStr = Convert.digitToChinese(yjjsjhjHjAmount);

        jsbtCashAmount = jsbkCashAmount.subtract(jstkCashAmount);
        jsbtWxAmount = jsbkWxAmount.subtract(jstkWxAmount);
        jsbtZfbAmount = jsbkZfbAmount.subtract(jstkZfbAmount);
        jsbtYbkAmount = jsbkYbAmount.subtract(jstkYbAmount);
        jsbtYlkAmount = jsbkYlkAmount.subtract(jstkYlkAmount);
        jsbtQtAmount = jsbkQtAmount.subtract(jstkQtAmount);
        jsbtJhzfAmount = jsbkJhzfAmount.subtract(jstkJhzfAmount);
        jsbtHjAmount = jsbkTotalAmount.subtract(jstkTotalAmount);
        jsbtHjAmountStr = Convert.digitToChinese(jsbtHjAmount);


        sjhjCashAmount = yjjsjhjCashAmount.add(jsbtCashAmount);
        sjhjWxAmount = yjjsjhjWxAmount.add(jsbtWxAmount);
        sjhjZfbAmount = yjjsjhjZfbAmount.add(jsbtZfbAmount);
        sjhjYbkAmount = yjjsjhjYbkAmount.add(jsbtYbkAmount);
        sjhjYlkAmount = yjjsjhjYlkAmount.add(jsbtYlkAmount);
        sjhjJhzfAmount = yjjsjhjJhzfAmount.add(jsbtJhzfAmount);
        //转账=deposit_qt  + return_qt + js_bk_qt  -  js_tk_qt
        zzAmount = depositQtAmount.subtract(returnQtAmount).add(jsbkQtAmount).subtract(jstkQtAmount);
        //total_charge- (js_cfbz+js_jz_yb+js_jz_mzyf)-(js_bk_ylk  -  js_tk_ylk )-( js_bk_cheque  -  js_tk_cheque )
        if (totalCharge == null) {
            totalCharge = BigDecimal.ZERO;
        }
        fpxjAmount = totalCharge.subtract(jsCfbzAmount.add(ybjzAmount).add(jsjzMzyfAmount)).subtract(jsbkYlkAmount.subtract(jstkYlkAmount)).subtract(jsbkYbAmount.subtract(jstkYbAmount));
        if (totalByybdf == null) {
            totalByybdf = BigDecimal.ZERO;
        }
        if (depositByjzAmount == null) {
            depositByjzAmount = BigDecimal.ZERO;
        }
        if (receiptAmount == null) {
            receiptAmount = BigDecimal.ZERO;
        }
        if (hsJe == null) {
            hsJe = BigDecimal.ZERO;
        }
    }


}
