367 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			367 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			Java
		
	
	
	
package tqq9.lc123.cloud.app.plugin.form.pm;
 | 
						||
 | 
						||
import com.google.gson.Gson;
 | 
						||
import kd.bos.bill.AbstractBillPlugIn;
 | 
						||
import kd.bos.dataentity.entity.DynamicObject;
 | 
						||
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
						||
import kd.bos.dataentity.utils.StringUtils;
 | 
						||
import kd.bos.entity.datamodel.IDataModel;
 | 
						||
import kd.bos.entity.datamodel.RowDataEntity;
 | 
						||
import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
 | 
						||
import kd.bos.entity.datamodel.events.ChangeData;
 | 
						||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
 | 
						||
import kd.bos.logging.Log;
 | 
						||
import kd.bos.logging.LogFactory;
 | 
						||
import kd.bos.orm.query.QCP;
 | 
						||
import kd.bos.orm.query.QFilter;
 | 
						||
import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
						||
import tqq9.lc123.cloud.app.plugin.utils.HttpRequestUtils;
 | 
						||
 | 
						||
import java.io.IOException;
 | 
						||
import java.math.BigDecimal;
 | 
						||
import java.math.RoundingMode;
 | 
						||
import java.util.ArrayList;
 | 
						||
import java.util.HashMap;
 | 
						||
import java.util.List;
 | 
						||
import java.util.Map;
 | 
						||
 | 
						||
/**
 | 
						||
 * 采购订单
 | 
						||
 * 值改变事件:现返、货返金额分摊;付款比例不超过100%
 | 
						||
 */
 | 
						||
public class PuroderBillShareRefundPlugin extends AbstractBillPlugIn {
 | 
						||
 | 
						||
    private final static Log logger = LogFactory.getLog(PuroderBillShareRefundPlugin.class);
 | 
						||
    private final static String ENTRYENTITY = "billentry";
 | 
						||
 | 
						||
    private final static HashMap<String, String> tokenMap = new HashMap<String, String>() {{
 | 
						||
        put("Authorization", "Bearer b96dad1eb4f84c41bae651162aeacdd3");
 | 
						||
    }};
 | 
						||
 | 
						||
    private static String URL;
 | 
						||
    static {
 | 
						||
        DynamicObject url = BusinessDataServiceHelper.loadSingle("tqq9_thirdconfig", "name",
 | 
						||
                new QFilter[]{new QFilter("number", QCP.equals, "FLXT_Balance_Url")});
 | 
						||
        URL = url != null ? url.getString("name") : null;
 | 
						||
    }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    @Override
 | 
						||
    public void afterAddRow(AfterAddRowEventArgs e) {
 | 
						||
        super.afterAddRow(e);
 | 
						||
        if (StringUtils.equals(e.getEntryProp().getName(), ENTRYENTITY)) {
 | 
						||
            BigDecimal tqq9_discountamount = (BigDecimal) this.getModel().getValue("tqq9_discountamount");
 | 
						||
            if (tqq9_discountamount.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                RowDataEntity[] rowDataEntities = e.getRowDataEntities();
 | 
						||
                for (RowDataEntity rowDataEntity : rowDataEntities) {
 | 
						||
                    int rowIndex = rowDataEntity.getRowIndex();
 | 
						||
                    this.getModel().setValue("discounttype", "C", rowIndex);
 | 
						||
                }
 | 
						||
            }
 | 
						||
 | 
						||
        }
 | 
						||
    }
 | 
						||
 | 
						||
    @Override
 | 
						||
    public void propertyChanged(PropertyChangedArgs e) {
 | 
						||
        super.propertyChanged(e);
 | 
						||
        String name = e.getProperty().getName();
 | 
						||
        DynamicObject dataEntity = this.getModel().getDataEntity(true);
 | 
						||
        if ("tqq9_hsxfsyje".equals(name)) {
 | 
						||
            //含税现返使用金额
 | 
						||
            BigDecimal tqq9_hsxfsyje = dataEntity.getBigDecimal(name);//单头含税现返使用金额
 | 
						||
            if (tqq9_hsxfsyje.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry");
 | 
						||
                if (billentries != null && billentries.size() > 0) {
 | 
						||
                    BigDecimal remainRefundAmt = tqq9_hsxfsyje;//拆分后剩余的金额
 | 
						||
                    List<Integer> seqs = new ArrayList<>();
 | 
						||
                    BigDecimal tqq9_totalamount = BigDecimal.ZERO;
 | 
						||
                    for (int i = 0; i <= billentries.size() - 1; i++) {
 | 
						||
                        DynamicObject billentry = billentries.get(i);
 | 
						||
                        BigDecimal tqq9_amount = billentry.getBigDecimal("tqq9_amount");//明细折扣前价税合计
 | 
						||
                        tqq9_totalamount = tqq9_totalamount.add(tqq9_amount);
 | 
						||
                        if (tqq9_amount.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                            seqs.add(i);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    for (int i = 0; i < seqs.size(); i++) {
 | 
						||
                        int seq = seqs.get(i);
 | 
						||
                        if (i == seqs.size() - 1) {
 | 
						||
                            //如果是最后一行
 | 
						||
                            this.getModel().setValue("tqq9_xfamount", remainRefundAmt, seq);//明细现返使用金额
 | 
						||
                        } else {
 | 
						||
                            //如果不是最后一行
 | 
						||
                            BigDecimal tqq9_amount = (BigDecimal) this.getModel().getValue("tqq9_amount", seq);//明细折扣前价税合计
 | 
						||
                            if (tqq9_amount.compareTo(BigDecimal.ZERO) == 0) {
 | 
						||
                                this.getModel().setValue("tqq9_xfamount", BigDecimal.ZERO, seq);//明细现返使用金额
 | 
						||
                            } else {
 | 
						||
                                BigDecimal tqq9_xfamount = tqq9_hsxfsyje.multiply(tqq9_amount).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例
 | 
						||
                                this.getModel().setValue("tqq9_xfamount", tqq9_xfamount, seq);//明细现返使用金额
 | 
						||
                                remainRefundAmt = remainRefundAmt.subtract(tqq9_xfamount);
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
            this.getView().updateView("billentry");
 | 
						||
        }
 | 
						||
        if ("tqq9_hshfsyje".equals(name)) {
 | 
						||
            //含税货返使用金额
 | 
						||
            BigDecimal tqq9_hshfsyje = dataEntity.getBigDecimal(name);//单头含税货返使用金额
 | 
						||
            if (tqq9_hshfsyje.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry");
 | 
						||
                if (billentries != null && billentries.size() > 0) {
 | 
						||
                    BigDecimal remainRefundAmt = tqq9_hshfsyje;//拆分后剩余的金额
 | 
						||
                    List<Integer> seqs = new ArrayList<>();
 | 
						||
                    BigDecimal tqq9_totalamount = BigDecimal.ZERO;
 | 
						||
                    for (int i = 0; i <= billentries.size() - 1; i++) {
 | 
						||
                        DynamicObject billentry = billentries.get(i);
 | 
						||
                        BigDecimal tqq9_amount = billentry.getBigDecimal("tqq9_amount");//明细折扣前价税合计
 | 
						||
                        tqq9_totalamount = tqq9_totalamount.add(tqq9_amount);
 | 
						||
                        if (tqq9_amount.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                            seqs.add(i);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    for (int i = 0; i <= seqs.size() - 1; i++) {
 | 
						||
                        int seq = seqs.get(i);
 | 
						||
                        if (i == seqs.size() - 1) {
 | 
						||
                            //如果是最后一行
 | 
						||
                            this.getModel().setValue("tqq9_hfamount", remainRefundAmt, seq);//明细货返使用金额
 | 
						||
                        } else {
 | 
						||
                            //如果不是最后一行
 | 
						||
                            BigDecimal tqq9_amount = (BigDecimal) this.getModel().getValue("tqq9_amount", seq);//明细折扣前价税合计
 | 
						||
 | 
						||
                            if (tqq9_amount.compareTo(BigDecimal.ZERO) == 0) {
 | 
						||
                                this.getModel().setValue("tqq9_hfamount", BigDecimal.ZERO, seq);//明细货返使用金额
 | 
						||
                            } else {
 | 
						||
                                BigDecimal tqq9_hfamount = tqq9_hshfsyje.multiply(tqq9_amount).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例
 | 
						||
                                this.getModel().setValue("tqq9_hfamount", tqq9_hfamount, seq);//明细货返使用金额
 | 
						||
                                remainRefundAmt = remainRefundAmt.subtract(tqq9_hfamount);
 | 
						||
                            }
 | 
						||
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
            this.getView().updateView("billentry");
 | 
						||
        }
 | 
						||
        if ("tqq9_discountamount".equals(name)) {
 | 
						||
            //优惠金额
 | 
						||
            BigDecimal tqq9_discountamount = dataEntity.getBigDecimal(name);//单头优惠金额
 | 
						||
            if (tqq9_discountamount.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry");
 | 
						||
                if (billentries != null && billentries.size() > 0) {
 | 
						||
                    BigDecimal remainRefundAmt = tqq9_discountamount;//拆分后剩余的金额
 | 
						||
                    List<Integer> seqs = new ArrayList<>();
 | 
						||
                    BigDecimal tqq9_totalamount = BigDecimal.ZERO;
 | 
						||
                    for (int i = 0; i <= billentries.size() - 1; i++) {
 | 
						||
                        DynamicObject billentry = billentries.get(i);
 | 
						||
                        BigDecimal tqq9_amount = billentry.getBigDecimal("tqq9_amount");//明细折扣前价税合计
 | 
						||
                        tqq9_totalamount = tqq9_totalamount.add(tqq9_amount);
 | 
						||
                        if (tqq9_amount.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                            seqs.add(i);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    for (int i = 0; i <= seqs.size() - 1; i++) {
 | 
						||
                        int seq = seqs.get(i);
 | 
						||
                        if (i == seqs.size() - 1) {
 | 
						||
                            //如果是最后一行
 | 
						||
                            this.getModel().setValue("tqq9_disamount", remainRefundAmt, seq);//明细优惠金额
 | 
						||
                        } else {
 | 
						||
                            //如果不是最后一行
 | 
						||
                            BigDecimal tqq9_amount = (BigDecimal) this.getModel().getValue("tqq9_amount", seq);//明细折扣前价税合计
 | 
						||
                            if (tqq9_amount.compareTo(BigDecimal.ZERO) == 0) {
 | 
						||
                                this.getModel().setValue("tqq9_disamount", BigDecimal.ZERO, seq);//明细优惠金额
 | 
						||
                            } else {
 | 
						||
                                BigDecimal tqq9_disamount = tqq9_discountamount.multiply(tqq9_amount).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例
 | 
						||
                                this.getModel().setValue("tqq9_disamount", tqq9_disamount, seq);//明细优惠金额
 | 
						||
                                remainRefundAmt = remainRefundAmt.subtract(tqq9_disamount);
 | 
						||
                            }
 | 
						||
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
            this.getView().updateView("billentry");
 | 
						||
        }
 | 
						||
        if (StringUtils.equals("payrate", name)) {
 | 
						||
            //校验付款比例不能大于100%
 | 
						||
            IDataModel model = this.getModel();
 | 
						||
            DynamicObject pm_purorderbill = model.getDataEntity(true);//采购订单
 | 
						||
            DynamicObjectCollection entries = pm_purorderbill.getDynamicObjectCollection("purbillentry_pay");//付款计划分录
 | 
						||
            BigDecimal zero = BigDecimal.ZERO;
 | 
						||
            for (DynamicObject entry : entries) {
 | 
						||
                BigDecimal payrate = entry.getBigDecimal("payrate");
 | 
						||
                zero = zero.add(payrate);
 | 
						||
            }
 | 
						||
            if (zero.compareTo(new BigDecimal(100)) > 0) {
 | 
						||
                this.getView().showErrorNotification("付款计划付款比例总计大于100%,请修改");
 | 
						||
            }
 | 
						||
        }
 | 
						||
        if (StringUtils.equals("tqq9_amount", name)) {
 | 
						||
            //单头金额下推
 | 
						||
            DynamicObjectCollection billentries = dataEntity.getDynamicObjectCollection("billentry");
 | 
						||
            if (billentries != null && billentries.size() > 0) {
 | 
						||
                BigDecimal tqq9_hsxfsyje = dataEntity.getBigDecimal("tqq9_hsxfsyje");//单头含税现返使用金额
 | 
						||
                BigDecimal tqq9_hshfsyje = dataEntity.getBigDecimal("tqq9_hshfsyje");//单头含税货返使用金额
 | 
						||
                BigDecimal tqq9_discountamount = dataEntity.getBigDecimal("tqq9_discountamount");//单头优惠金额
 | 
						||
                BigDecimal remainRefundAmt_xf = tqq9_hsxfsyje;//拆分后剩余的金额-现返
 | 
						||
                BigDecimal remainRefundAmt_hf = tqq9_hshfsyje;//拆分后剩余的金额-货返
 | 
						||
                BigDecimal remainRefundAmt_yh = tqq9_discountamount;//拆分后剩余的金额-优惠
 | 
						||
                List<Integer> seqs = new ArrayList<>();
 | 
						||
                BigDecimal tqq9_totalamount = BigDecimal.ZERO;
 | 
						||
                for (int i = 0; i <= billentries.size() - 1; i++) {
 | 
						||
                    DynamicObject billentry = billentries.get(i);
 | 
						||
                    BigDecimal tqq9_amount = billentry.getBigDecimal("tqq9_amount");//明细折扣前价税合计
 | 
						||
                    tqq9_totalamount = tqq9_totalamount.add(tqq9_amount);
 | 
						||
                    if (tqq9_amount.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                        seqs.add(i);
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                for (int i = 0; i <= seqs.size() - 1; i++) {
 | 
						||
                    Integer seq = seqs.get(i);
 | 
						||
                    //现返
 | 
						||
                    if (tqq9_hsxfsyje.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                        if (i == seqs.size() - 1) {
 | 
						||
                            //如果是最后一行
 | 
						||
                            this.getModel().setValue("tqq9_xfamount", remainRefundAmt_xf, seq);//明细现返使用金额
 | 
						||
                        } else {
 | 
						||
                            //如果不是最后一行
 | 
						||
                            BigDecimal tqq9_amount = (BigDecimal) this.getModel().getValue("tqq9_amount", seq);//明细折扣前价税合计
 | 
						||
                            if (tqq9_amount.compareTo(BigDecimal.ZERO) == 0) {
 | 
						||
                                this.getModel().setValue("tqq9_xfamount", BigDecimal.ZERO, seq);//明细现返使用金额
 | 
						||
                            } else {
 | 
						||
                                BigDecimal tqq9_xfamount = tqq9_hsxfsyje.multiply(tqq9_amount).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例
 | 
						||
                                this.getModel().setValue("tqq9_xfamount", tqq9_xfamount, seq);//明细现返使用金额
 | 
						||
                                remainRefundAmt_xf = remainRefundAmt_xf.subtract(tqq9_xfamount);
 | 
						||
                            }
 | 
						||
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    //货返
 | 
						||
                    if (tqq9_hshfsyje.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                        if (i == seqs.size() - 1) {
 | 
						||
                            //如果是最后一行
 | 
						||
                            this.getModel().setValue("tqq9_hfamount", remainRefundAmt_hf, seq);//明细货返使用金额
 | 
						||
                        } else {
 | 
						||
                            //如果不是最后一行
 | 
						||
                            BigDecimal tqq9_amount = (BigDecimal) this.getModel().getValue("tqq9_amount", seq);//明细折扣前价税合计
 | 
						||
                            if (tqq9_amount.compareTo(BigDecimal.ZERO) == 0) {
 | 
						||
                                this.getModel().setValue("tqq9_hfamount", BigDecimal.ZERO, seq);//明细货返使用金额
 | 
						||
                            } else {
 | 
						||
                                BigDecimal tqq9_hfamount = tqq9_hshfsyje.multiply(tqq9_amount).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例
 | 
						||
                                this.getModel().setValue("tqq9_hfamount", tqq9_hfamount, seq);//明细货返使用金额
 | 
						||
                                remainRefundAmt_hf = remainRefundAmt_hf.subtract(tqq9_hfamount);
 | 
						||
                            }
 | 
						||
 | 
						||
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    //优惠
 | 
						||
                    if (tqq9_discountamount.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                        if (i == seqs.size() - 1) {
 | 
						||
                            //如果是最后一行
 | 
						||
                            this.getModel().setValue("tqq9_disamount", remainRefundAmt_yh, seq);//明细优惠金额
 | 
						||
                            this.getModel().setValue("discountamount", remainRefundAmt_yh, seq);//明细折扣额
 | 
						||
                        } else {
 | 
						||
                            //如果不是最后一行
 | 
						||
                            BigDecimal tqq9_amount = (BigDecimal) this.getModel().getValue("tqq9_amount", seq);//明细折扣前价税合计
 | 
						||
                            if (tqq9_amount.compareTo(BigDecimal.ZERO) == 0) {
 | 
						||
                                this.getModel().setValue("tqq9_disamount", BigDecimal.ZERO, seq);//明细优惠金额
 | 
						||
                                this.getModel().setValue("discountamount", BigDecimal.ZERO, seq);//
 | 
						||
                            } else {
 | 
						||
                                BigDecimal tqq9_disamount = tqq9_discountamount.multiply(tqq9_amount).divide(tqq9_totalamount, 10, RoundingMode.HALF_UP);//分录行含税金额比例
 | 
						||
                                this.getModel().setValue("tqq9_disamount", tqq9_disamount, seq);//明细优惠金额
 | 
						||
                                this.getModel().setValue("discountamount", tqq9_disamount, seq);//
 | 
						||
                                remainRefundAmt_yh = remainRefundAmt_yh.subtract(tqq9_disamount);
 | 
						||
                            }
 | 
						||
 | 
						||
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
            this.getView().updateView("billentry");
 | 
						||
        }
 | 
						||
        if (StringUtils.equals("material", name)) {
 | 
						||
            ChangeData changeData = e.getChangeSet()[0];
 | 
						||
            int rowIndex = changeData.getRowIndex();
 | 
						||
            DynamicObjectCollection dynamicObjectCollection = dataEntity.getDynamicObjectCollection(ENTRYENTITY);
 | 
						||
            DynamicObject dynamicObject = dynamicObjectCollection.get(rowIndex);
 | 
						||
            DynamicObject material = dynamicObject.getDynamicObject("material");
 | 
						||
            DynamicObject masterid = material.getDynamicObject("masterid");
 | 
						||
            DynamicObject bd_material = BusinessDataServiceHelper.loadSingle(masterid.getLong("id"), "bd_material");
 | 
						||
            DynamicObject org = dataEntity.getDynamicObject("org");
 | 
						||
            //上海
 | 
						||
            if (StringUtils.equals("SHLC", org.getString("number"))) {
 | 
						||
                BigDecimal tqq9_maxprice_sh = bd_material.getBigDecimal("tqq9_maxprice_sh");
 | 
						||
                if (tqq9_maxprice_sh.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                    getModel().setValue("priceandtax", tqq9_maxprice_sh, rowIndex);
 | 
						||
                    getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_sh, rowIndex);
 | 
						||
                }
 | 
						||
                //北京
 | 
						||
            } else if (StringUtils.equals("BJLC", org.getString("number"))) {
 | 
						||
                BigDecimal tqq9_maxprice_bj = bd_material.getBigDecimal("tqq9_maxprice_bj");
 | 
						||
                if (tqq9_maxprice_bj.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                    getModel().setValue("priceandtax", tqq9_maxprice_bj, rowIndex);
 | 
						||
                    getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_bj, rowIndex);
 | 
						||
                }
 | 
						||
                //广州
 | 
						||
            } else if (StringUtils.equals("GZLC", org.getString("number"))) {
 | 
						||
                BigDecimal tqq9_maxprice_gz = bd_material.getBigDecimal("tqq9_maxprice_gz");
 | 
						||
                if (tqq9_maxprice_gz.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                    getModel().setValue("priceandtax", tqq9_maxprice_gz, rowIndex);
 | 
						||
                    getModel().setValue("tqq9_zgcgxj", tqq9_maxprice_gz, rowIndex);
 | 
						||
                }
 | 
						||
            }
 | 
						||
        }
 | 
						||
        if (StringUtils.equals("priceandtax", name)) {
 | 
						||
            ChangeData changeData = e.getChangeSet()[0];
 | 
						||
            int rowIndex = changeData.getRowIndex();
 | 
						||
            int seq = rowIndex;
 | 
						||
            BigDecimal newValue = (BigDecimal) changeData.getNewValue();
 | 
						||
            BigDecimal tqq9_zgcgxj = (BigDecimal) getModel().getValue("tqq9_zgcgxj",seq);
 | 
						||
            if (newValue.compareTo(tqq9_zgcgxj) > 0 && tqq9_zgcgxj.compareTo(BigDecimal.ZERO) > 0) {
 | 
						||
                getModel().setValue("priceandtax", 0,seq);
 | 
						||
                this.getView().showErrorNotification("物料明细分录行" + seq + "含税单价超过最高采购限价,请修改");
 | 
						||
            }
 | 
						||
        }
 | 
						||
        if (StringUtils.equals("supplier", name)) {
 | 
						||
            IDataModel model = this.getModel();
 | 
						||
            ChangeData changeData = e.getChangeSet()[0];
 | 
						||
            DynamicObject newValue = (DynamicObject) changeData.getNewValue();//供应商
 | 
						||
            DynamicObject org = (DynamicObject)model.getValue("org");//组织
 | 
						||
            HashMap<String,Object> queryMap =new HashMap<>();
 | 
						||
            queryMap.put("supplierId",newValue.getString("number"));
 | 
						||
            queryMap.put("companyId",org.getString("number"));
 | 
						||
            Gson gson = new Gson();
 | 
						||
            try {
 | 
						||
                String bodyString = HttpRequestUtils.doGet(URL, queryMap, tokenMap);
 | 
						||
                HashMap map = gson.fromJson(bodyString, HashMap.class);
 | 
						||
                ArrayList<Map<String, Object>> data = (ArrayList) map.get("data");
 | 
						||
                if(data!=null){
 | 
						||
                    for (Map datum : data) {
 | 
						||
                        Map<String, Object> dataMap =  datum;
 | 
						||
                        String type = dataMap.get("type").toString();//类型
 | 
						||
                        BigDecimal totalMoney = new BigDecimal((Double)dataMap.get("totalMoney"));//剩余总金额
 | 
						||
                        BigDecimal totalMoneyAvailable = new BigDecimal((Double)dataMap.get("totalMoneyAvailable")) ;//可使用金额
 | 
						||
                        if(StringUtils.equals(type,"1.0")){
 | 
						||
                            //货返
 | 
						||
                            model.setValue("tqq9_hshfzje",totalMoney);//含税货返总金额
 | 
						||
                            model.setValue("tqq9_hshfkyje",totalMoneyAvailable);//含税货返可用金额
 | 
						||
                        }else if(StringUtils.equals(type,"0.0")){
 | 
						||
                            //现返
 | 
						||
                            model.setValue("tqq9_hsxfzje",totalMoney);//含税现返总金额
 | 
						||
                            model.setValue("tqq9_hsxfzje",totalMoneyAvailable);//含税现返可用金额
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            } catch (IOException ex) {
 | 
						||
                throw new RuntimeException(ex);
 | 
						||
            }
 | 
						||
            getView().updateView();
 | 
						||
        }
 | 
						||
    }
 | 
						||
}
 |