package com.ywt.outpatient.domain.models;

import java.io.Serializable;

public class OpenHisPushPayCodeConfigVo implements Serializable {

    /**
     * {"prescription_icbc_is_open":1,"proportion":"0:1","icbc_pay_code":"1008","wx_pay_code":"1006"}
     */

    /**
     * 处方支付是否开启，0-关闭，1-开启
     */
    private Integer prescription_icbc_is_open;

    /**
     * 支付比例：wechat : icbc，eg：1:1
     * 注： 处方支付开启之后，比例才生效
     */
    private String proportion;

    /**
     * 工行pay_code，对应ywt_center库的icbc_vendor表的pay_code字段
     */
    private String icbc_pay_code;

    /**
     * 微信pay_code，对应ywt_center库的payment_config表的pay_code字段
     */
    private String wx_pay_code;

    public boolean getPrescriptionIcbcIsOpen() {
        if (prescription_icbc_is_open > 0)
            return true;
        return false;
    }

    public void setPrescriptionIcbcIsOpen(Integer prescriptionIcbcIsOpen) {
        this.prescription_icbc_is_open = prescriptionIcbcIsOpen;
    }

    public String getProportion() {
        return proportion;
    }

    public void setProportion(String proportion) {
        this.proportion = proportion;
    }

    /**
     * 得到比例中微信支付的初始次数(前提，必须先打开icbc配置)
     *
     * @return 次数
     */
    public int getWechatPayInitCount() {
        try {
            String[] arr = proportion.split(":");
            if (getPrescriptionIcbcIsOpen() && arr != null && arr.length == 2) {
                return Math.abs(Integer.parseInt(arr[0]));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 1;
    }

    /**
     * 得到比例中工行支付的初始次数(前提，必须先打开icbc配置)
     *
     * @return 次数
     */
    public int getIcbcPayInitCount() {
        try {
            String[] arr = proportion.split(":");
            if (getPrescriptionIcbcIsOpen() && arr != null && arr.length == 2) {
                return Math.abs(Integer.parseInt(arr[1]));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }

    public String getIcbc_pay_code() {
        return icbc_pay_code;
    }

    public void setIcbc_pay_code(String icbc_pay_code) {
        this.icbc_pay_code = icbc_pay_code;
    }

    public String getWx_pay_code() {
        return wx_pay_code;
    }

    public void setWx_pay_code(String wx_pay_code) {
        this.wx_pay_code = wx_pay_code;
    }

    /**
     * 获取paycode（不用比例）
     * @return paycode
     */
    public String getPayCodeWithOutProportion(){
        return getPrescriptionIcbcIsOpen() ? icbc_pay_code : wx_pay_code;
    }
}
