Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

徐昊 9 mesi fa
parent
commit
b866f2f918

+ 2642 - 0
src/main/java/fi/cas/formplugin/ArBillEditPlugin.java

@@ -0,0 +1,2642 @@
+package fi.cas.formplugin;
+
+import com.alibaba.fastjson.JSON;
+import kd.bos.bill.BillShowParameter;
+import kd.bos.bill.OperationStatus;
+import kd.bos.context.RequestContext;
+import kd.bos.dataentity.OperateOption;
+import kd.bos.dataentity.entity.DataEntityBase;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.entity.LocaleString;
+import kd.bos.dataentity.metadata.IDataEntityProperty;
+import kd.bos.dataentity.metadata.clr.DataEntityPropertyCollection;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.dataentity.serialization.SerializationUtils;
+import kd.bos.entity.AppMetadataCache;
+import kd.bos.entity.EntityMetadataCache;
+import kd.bos.entity.Tips;
+import kd.bos.entity.datamodel.*;
+import kd.bos.entity.datamodel.events.*;
+import kd.bos.entity.format.FormatFactory;
+import kd.bos.entity.format.FormatObject;
+import kd.bos.entity.format.FormatTypes;
+import kd.bos.entity.operate.result.OperationResult;
+import kd.bos.entity.param.AppParam;
+import kd.bos.entity.property.EntryProp;
+import kd.bos.exception.KDBizException;
+import kd.bos.form.*;
+import kd.bos.form.control.*;
+import kd.bos.form.control.events.BeforeItemClickEvent;
+import kd.bos.form.control.events.ClickListener;
+import kd.bos.form.control.events.ItemClickEvent;
+import kd.bos.form.control.events.RowClickEventListener;
+import kd.bos.form.events.*;
+import kd.bos.form.field.BasedataEdit;
+import kd.bos.form.field.ComboEdit;
+import kd.bos.form.field.ComboItem;
+import kd.bos.form.operate.AbstractOperate;
+import kd.bos.form.operate.FormOperate;
+import kd.bos.form.operate.SignOperateCallback;
+import kd.bos.list.ListFilterParameter;
+import kd.bos.list.ListShowParameter;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.orm.query.QFilter;
+import kd.bos.orm.util.CollectionUtils;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.bos.servicehelper.DispatchServiceHelper;
+import kd.bos.servicehelper.QueryServiceHelper;
+import kd.bos.servicehelper.inte.InteServiceHelper;
+import kd.bos.servicehelper.operation.OperationServiceHelper;
+import kd.bos.servicehelper.parameter.SystemParamServiceHelper;
+import kd.bos.servicehelper.workflow.WorkflowServiceHelper;
+import kd.bos.workflow.component.approvalrecord.IApprovalRecordGroup;
+import kd.fi.cas.business.errorcode.CasErrorCode;
+import kd.fi.cas.business.errorcode.PaymentErrorCode;
+import kd.fi.cas.business.helper.AcctBalanceHelper;
+import kd.fi.cas.business.helper.PayBillHepler;
+import kd.fi.cas.business.helper.PaymentFillPropHelper;
+import kd.fi.cas.business.helper.VisibleVirtualAcctHelper;
+import kd.fi.cas.business.opservice.impl.PaymentPayImpl;
+import kd.fi.cas.business.service.ViewReceiptService;
+import kd.fi.cas.consts.BillTypeConstants;
+import kd.fi.cas.enums.*;
+import kd.fi.cas.formplugin.PaymentBillEdit;
+import kd.fi.cas.formplugin.common.CasBillEdit;
+import kd.fi.cas.formplugin.helper.InitCheckPluginHelper;
+import kd.fi.cas.helper.*;
+import kd.fi.cas.pojo.BizBalanceModelBean;
+import kd.fi.cas.util.DateUtils;
+import kd.fi.cas.util.EmptyUtil;
+import kd.fi.cas.util.FormUtils;
+import kd.fi.cas.util.StringUtils;
+
+import java.math.BigDecimal;
+import java.text.Format;
+import java.util.*;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class ArBillEditPlugin extends CasBillEdit implements ClickListener, RowClickEventListener, SignCallbackLisenter {
+    private String labCurrencySign;
+    private int currencyAmtprecision;
+    private Format currencyFormat;
+    private static final String KEY_DIFFPAY_CALLBACK = "KEY_DIFFPAY_CALLBACK";
+    private static final String CONFIRM_DEL_CALLBACK = "CONFIRM_DEL_CALLBACK";
+    private static final String KEY_CALLBACK_CHARGEBACK = "CALLBACK_CHARGEBACK";
+    private static final String KEY_CLOSECALLBACK_CHARGEBACK = "CALLBACK_SELECTDRAFT";
+    private static Log logger = LogFactory.getLog(PaymentBillEdit.class);
+    private Long orgId;
+    private boolean isBeConfirmOK = false;
+    private List<String> settleTypes;
+
+    public ArBillEditPlugin() {
+        this.settleTypes = Arrays.asList(SettleMentTypeEnum.PROMISSORY.getValue(), SettleMentTypeEnum.CHECK.getValue(), SettleMentTypeEnum.DRAFT.getValue(), SettleMentTypeEnum.BUSINESS.getValue(), SettleMentTypeEnum.BANK.getValue());
+    }
+
+    private void initFormat() {
+        FormatObject fobj = InteServiceHelper.getUserFormat(RequestContext.get().getCurrUserId());
+        fobj.getCurrencyFormat().setCurrencySymbols(this.labCurrencySign);
+        fobj.getCurrencyFormat().setMinimumFractionDigits(this.currencyAmtprecision);
+        this.currencyFormat = FormatFactory.get(FormatTypes.Currency).getFormat(fobj);
+    }
+
+    public void preOpenForm(PreOpenFormEventArgs e) {
+        BillShowParameter showParameter = (BillShowParameter)e.getSource();
+        Object pkId = showParameter.getPkId();
+        if (pkId != null && !pkId.equals(0L)) {
+            DynamicObject info = BusinessDataServiceHelper.loadSingle(pkId, "nckd_cas_arbill", "id, billtype");
+            DynamicObject billtype = info.getDynamicObject("billtype");
+            if (billtype != null && BillTypeConstants.PAYBILL_SYN.equals(billtype.getPkValue())) {
+                e.getFormShowParameter().setFormId("cas_paybill_synonym");
+                e.getFormShowParameter().setCaption(ResManager.loadKDString("同名转账", "PaymentBillEdit_24", "fi-cas-formplugin", new Object[0]));
+            } else if (billtype != null && BillTypeConstants.PAYBILL_CASH.equals(billtype.getPkValue())) {
+                e.getFormShowParameter().setFormId("cas_paybill_cash");
+                e.getFormShowParameter().setCaption(ResManager.loadKDString("现金存取", "PaymentBillEdit_25", "fi-cas-formplugin", new Object[0]));
+            } else if (billtype != null && BillTypeConstants.PAYBILL_SPAN.equals(billtype.getPkValue())) {
+                e.getFormShowParameter().setCaption(ResManager.loadKDString("跨主体调拨", "PaymentBillEdit_28", "fi-cas-formplugin", new Object[0]));
+            }
+        } else {
+            String formId = showParameter.getFormId();
+            if ("cas_paybill_synonym".equals(formId)) {
+                e.getFormShowParameter().setFormId("cas_paybill_synonym");
+                e.getFormShowParameter().setCaption(ResManager.loadKDString("同名转账", "PaymentBillEdit_24", "fi-cas-formplugin", new Object[0]));
+            } else if ("cas_paybill_cash".equals(formId)) {
+                e.getFormShowParameter().setFormId("cas_paybill_cash");
+                e.getFormShowParameter().setCaption(ResManager.loadKDString("现金存取", "PaymentBillEdit_25", "fi-cas-formplugin", new Object[0]));
+            } else if ("cas_paybill_spanmainpart".equals(formId)) {
+                e.getFormShowParameter().setFormId("cas_paybill_spanmainpart");
+                e.getFormShowParameter().setCaption(ResManager.loadKDString("跨主体调拨", "PaymentBillEdit_28", "fi-cas-formplugin", new Object[0]));
+            }
+        }
+
+    }
+
+    public void registerListener(EventObject e) {
+        super.registerListener(e);
+        this.addClickListeners(new String[]{"changepayer", "changepayee", "addpayeelb1", "addpayeelb2", "settletnumber", "applyname"});
+        this.initF7();
+    }
+
+    private void initF7() {
+        this.fillPaymentType();
+        this.fillCurrency();
+        this.fillEntrustorg();
+        this.setSettlementTypeFilter();
+        this.fillNetBankAcct();
+        this.expenseItem();
+        this.fillFundFlow();
+    }
+
+    private void fillFundFlow() {
+        BasedataEdit fundFlow = (BasedataEdit)this.getControl("e_fundflowitem");
+        fundFlow.addBeforeF7SelectListener((select) -> {
+            ListShowParameter showParam = (ListShowParameter)select.getFormShowParameter();
+            Object org = this.getModel().getValue("org");
+            showParam.setCustomParam("org", String.valueOf(((DynamicObject)org).getPkValue()));
+        });
+    }
+
+    protected void expenseItem() {
+        BasedataEdit orgCtrl = (BasedataEdit)this.getControl("e_expenseitem");
+        orgCtrl.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
+            ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
+            DynamicObject[] objects = BusinessDataServiceHelper.load("er_expenseitembill", "id,expenseitem", new QFilter[]{new QFilter("billtype.bill_number.number", "=", "nckd_cas_arbill")});
+            if (!EmptyUtil.isEmpty(objects)) {
+                List<Object> ids = (List)Arrays.stream(objects).map((o) -> {
+                    return o.get("expenseitem.id");
+                }).collect(Collectors.toList());
+                QFilter qFilter = new QFilter("id", "in", ids);
+                showParameter.getListFilterParameter().getQFilters().add(qFilter);
+            }
+        });
+    }
+
+    protected String getControlBankAcctForSettleType() {
+        return "payeracctbank";
+    }
+
+    private boolean isAcctBankExistOnlineBankAcct() {
+        DynamicObject payeracctbank = (DynamicObject)this.getValue("payeracctbank");
+        if (null != payeracctbank) {
+            DynamicObjectCollection onlineBankAccts = payeracctbank.getDynamicObjectCollection("netbank");
+            return null != onlineBankAccts && onlineBankAccts.size() != 0;
+        } else {
+            return false;
+        }
+    }
+
+    private void fillNetBankAcct() {
+        BasedataEdit onlinebankacct = (BasedataEdit)this.getControl("netbankacct");
+        onlinebankacct.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
+            ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
+            DynamicObject payeracctbank = (DynamicObject)this.getValue("payeracctbank");
+            List<Long> ids = new ArrayList();
+            if (null != payeracctbank) {
+                DynamicObjectCollection onlineBankAccts = payeracctbank.getDynamicObjectCollection("netbank");
+                if (null != onlineBankAccts && onlineBankAccts.size() > 0) {
+                    Iterator var6 = onlineBankAccts.iterator();
+
+                    while(var6.hasNext()) {
+                        DynamicObject bankAcct = (DynamicObject)var6.next();
+                        ids.add((Long)bankAcct.getDynamicObject("fbasedataid").getPkValue());
+                    }
+                }
+            }
+
+            if (ids.size() == 0) {
+                ids.add(0L);
+            }
+
+            QFilter qFilter = new QFilter("id", "in", ids);
+            showParameter.getListFilterParameter().getQFilters().add(qFilter);
+        });
+    }
+
+    private void fillEntrustorg() {
+        BasedataEdit currencyF7 = (BasedataEdit)this.getControl("entrustorg");
+        currencyF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
+            ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
+            showParameter.setCustomParam("orgFuncId", "08");
+        });
+    }
+
+    private void fillPaymentType() {
+        BasedataEdit paymenttypeF7 = (BasedataEdit)this.getControl("paymenttype");
+        paymenttypeF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
+            String sourceBillType = (String)this.getModel().getValue("sourcebilltype");
+            ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
+            QFilter qFilter = new QFilter("enable", "=", "1");
+            Object entrance = this.getModel().getValue("entrance");
+            if (!CasHelper.isEmpty(this.getModel().getDataEntity().getPkValue())) {
+                DynamicObject payemntType = (DynamicObject)this.getModel().getValue("paymenttype");
+                if (payemntType != null) {
+                    qFilter = qFilter.and(new QFilter("ispartpayment", "=", payemntType.getBoolean("ispartpayment") ? "1" : "0"));
+                } else if (!PaymentTypeEnum.AP.name().equals(entrance)) {
+                    qFilter = qFilter.and(new QFilter("ispartpayment", "=", "0"));
+                }
+            }
+
+            if (entrance != null && !"".equals(entrance)) {
+                if (PaymentTypeEnum.AP.name().equals(entrance)) {
+                    qFilter = qFilter.and(new QFilter("ispartpayment", "=", "1"));
+                } else {
+                    qFilter = qFilter.and(new QFilter("ispartpayment", "=", "0"));
+                }
+            }
+
+            if ("pm_purorderbill".equals(sourceBillType) || "conm_purcontract".equals(sourceBillType)) {
+                qFilter = qFilter.and(new QFilter("biztype", "=", "202")).and(new QFilter("ispartpayment", "=", "1"));
+                qFilter = qFilter.and(new QFilter("ispartpayment", "=", "1"));
+            }
+
+            showParameter.getListFilterParameter().setFilter(qFilter);
+        });
+    }
+
+    private void fillCurrency() {
+        BasedataEdit currencyF7 = (BasedataEdit)this.getControl("currency");
+        currencyF7.addBeforeF7SelectListener((beforeF7SelectEvent) -> {
+            ListShowParameter showParameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter();
+            QFilter qFilter = new QFilter("enable", "=", "1");
+            Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
+            if (!isDiffCur) {
+                DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype");
+                boolean isCash = BaseDataHelper.isSettleTypeCash(settleType);
+                DynamicObject accountCash;
+                if (isCash) {
+                    accountCash = (DynamicObject)this.getModel().getValue("payeracctcash");
+                    if (accountCash != null) {
+                        List<Long> currencys = AccountCashHelper.getCurrencys(Collections.singletonList((Long)accountCash.getPkValue()));
+                        qFilter = qFilter.and(new QFilter("id", "in", currencys));
+                    }
+                } else {
+                    accountCash = (DynamicObject)this.getModel().getValue("payeracctbank");
+                    if (accountCash != null) {
+                        Set<Long> currencysx = AccountBankHelper.getCurrencyPks((Long)accountCash.getPkValue());
+                        qFilter = qFilter.and(new QFilter("id", "in", currencysx));
+                    }
+                }
+            }
+
+            showParameter.getListFilterParameter().setFilter(qFilter);
+        });
+    }
+
+    public void afterCreateNewData(EventObject e) {
+        super.afterCreateNewData(e);
+        this.setDefaultPaymentChannelValue();
+        if (!"true".equals(this.getPageCache().get("isFromWebApi"))) {
+            this.createNewModel();
+        }
+
+        this.getView().setVisible(false, new String[]{"netbankacct"});
+        this.getEntryCache();
+        this.calculateAmt();
+        DynamicObject settleType = this.getDynamicObject("settletype");
+        if (BaseDataHelper.isSettleTypeCash(settleType)) {
+            this.setValue("payeracctcash", AccountCashHelper.getDefaultAccountcash(this.getPk("org"), "payer"));
+        }
+
+    }
+
+    private void getEntryCache() {
+        String str_json = this.getPageCache().get("entry");
+        if (str_json != null) {
+            this.getModel().deleteEntryRow("entry", 0);
+            TableValueSetter vs = new TableValueSetter(new String[0]);
+            vs.addField("e_expenseitem", new Object[0]).addField("e_payableamt", new Object[0]).addField("project", new Object[0]).addField("e_fundflowitem", new Object[0]).addField("e_remark", new Object[0]);
+            Map<String, ArrayList<Map<String, String>>> maps = (Map) SerializationUtils.fromJsonString(str_json, Map.class);
+            ArrayList<Map<String, String>> list = (ArrayList)maps.get("entry");
+            Iterator var5 = list.iterator();
+
+            while(var5.hasNext()) {
+                Map<String, String> map = (Map)var5.next();
+                vs.addRow(new Object[]{map.get("e_expenseitem"), map.get("e_payableamt"), map.get("project"), map.get("e_fundflowitem"), map.get("e_remark")});
+            }
+
+            AbstractFormDataModel model = (AbstractFormDataModel)this.getModel();
+            model.batchCreateNewEntryRow("entry", vs);
+            this.getView().updateView("entry");
+        }
+
+    }
+
+    private void setDefaultPaymentChannelValue() {
+        List<ComboItem> comboItems = new ArrayList();
+        ComboEdit paymentChannel = (ComboEdit)this.getControl("paymentchannel");
+        ComboItem comboItem = new ComboItem();
+        comboItem.setValue(PaymentChannelEnum.COUNTER.getValue());
+        comboItem.setCaption(new LocaleString(ResManager.loadKDString(PaymentChannelEnum.COUNTER.getName(), "PaymentBillEdit_16", "fi-cas-formplugin", new Object[0])));
+        comboItems.add(comboItem);
+        paymentChannel.setComboItems(comboItems);
+        this.getModel().setValue("paymentchannel", comboItem.getValue());
+    }
+
+    public void beforeBindData(EventObject e) {
+        super.beforeBindData(e);
+        DynamicObject paymenttype = (DynamicObject)this.getModel().getValue("paymenttype");
+        if (null != paymenttype && !paymenttype.getBoolean("ispartpayment")) {
+            this.getView().setVisible(false, new String[]{"settleorg"});
+        }
+
+        this.settleOrg(false);
+        if (this.isBotpNew()) {
+            this.supplePayeeInfo();
+        }
+
+        this.getModel().setDataChanged(false);
+    }
+
+    private void supplePayeeInfo() {
+        Object sourcebilltype = this.getModel().getValue("sourcebilltype");
+        if (!CasHelper.isEmpty(sourcebilltype)) {
+            Object payee = this.getModel().getValue("payee");
+            Object payeebanknumMo = this.getModel().getValue("payeebanknum");
+            Object payeebankMo = this.getModel().getValue("payeebank");
+            Object payeeType = this.getValue("payeetype");
+            if (CasHelper.isEmpty(payeebanknumMo) && CasHelper.isEmpty(payeebankMo)) {
+                String billName = this.getModel().getDataEntityType().getName();
+                Map<String, Object> resultMap = CasPayeeOrPayerHelper.getPayeeOrPayerInfo(payee, payeeType, billName);
+                if (resultMap.size() > 0) {
+                    Object bankaccount = resultMap.get("payeebanknum");
+                    Object accountname = resultMap.get("accountname");
+                    DynamicObject payeebank = (DynamicObject)resultMap.get("payeebank");
+                    this.getModel().setValue("payeebanknum", bankaccount);
+                    this.getModel().setValue("recaccbankname", accountname);
+                    if (!CasHelper.isEmpty(payeebank)) {
+                        this.fillProvinceAndCity(payeebank);
+                    }
+                }
+            } else if (!CasHelper.isEmpty(payeebankMo)) {
+                this.fillProvinceAndCity((DynamicObject)payeebankMo);
+            }
+        }
+
+    }
+
+    private void fillProvinceAndCity(DynamicObject payeeBank) {
+        logger.info("打开单据 填充 国家、省、城市字段");
+        payeeBank = BusinessDataServiceHelper.loadSingle(payeeBank.getPkValue(), payeeBank.getDataEntityType().getName(), "id,name,number,country,provincetxt,citytxt,union_number");
+        this.getModel().setValue("payeebank", payeeBank);
+        this.getModel().setValue("payeebankname", payeeBank.getString("name"));
+        this.getModel().setValue("recbanknumber", payeeBank.getString("union_number"));
+        this.getModel().setValue("reccountry", payeeBank.getDynamicObject("country"));
+        this.getModel().setValue("recprovince", payeeBank.getString("provincetxt"));
+        this.getModel().setValue("reccity", payeeBank.getString("citytxt"));
+    }
+
+    private void createNewModel() {
+        this.getView().setVisible(false, new String[]{"usage"});
+        FormShowParameter parameter = this.getView().getFormShowParameter();
+        Map<String, Object> customParams = parameter.getCustomParams();
+        if (this.getModel().getValue("org") != null) {
+            this.orgId = this.getPk("org");
+        } else {
+            String appId = this.getView().getFormShowParameter().getAppId();
+            if (EmptyUtil.isNotEmpty(appId)) {
+                appId = AppMetadataCache.getAppInfo(appId).getId();
+            } else {
+                appId = AppMetadataCache.getAppInfo("cas").getId();
+            }
+
+            List<Long> authorizedBankOrgId = OrgHelper.getAuthorizedBankOrgId(RequestContext.get().getCurrUserId(), appId, "nckd_cas_arbill", "47156aff000000ac");
+            if (!CollectionUtils.isEmpty(authorizedBankOrgId)) {
+                this.orgId = (Long)authorizedBankOrgId.get(0);
+                this.setValue("org", this.orgId);
+            } else {
+                this.orgId = null;
+            }
+        }
+
+        this.setValueIfAbsent("bizdate", DateUtils.getCurrentDate());
+        if (customParams != null && customParams.containsKey("paymentType")) {
+            String entrance = (String)customParams.get("paymentType");
+            this.setValue("entrance", entrance);
+            long billTypeID = 0L;
+            QFilter[] qFilters;
+            if (PaymentTypeEnum.AP.name().equals(entrance)) {
+                qFilters = new QFilter[]{new QFilter("ispartpayment", "=", "1"), new QFilter("biztype", "=", "201")};
+                this.setPaymentType(qFilters);
+                billTypeID = BillTypeConstants.PAYBILL_PUR;
+            } else if (PaymentTypeEnum.SYN.name().equals(entrance)) {
+                qFilters = new QFilter[]{new QFilter("biztype", "=", "214")};
+                this.setPaymentType(qFilters);
+                billTypeID = BillTypeConstants.PAYBILL_SYN;
+            } else if (PaymentTypeEnum.SPAN.name().equals(entrance)) {
+                qFilters = new QFilter[]{new QFilter("biztype", "=", "217")};
+                this.setPaymentType(qFilters);
+                billTypeID = BillTypeConstants.PAYBILL_SPAN;
+            } else if (PaymentTypeEnum.CASH.name().equals(entrance)) {
+                qFilters = new QFilter[]{new QFilter("biztype", "=", "215")};
+                this.setPaymentType(qFilters);
+                billTypeID = BillTypeConstants.PAYBILL_CASH;
+            } else {
+                if (PaymentTypeEnum.ER.name().equals(entrance)) {
+                    qFilters = new QFilter[]{new QFilter("biztype", "=", "211")};
+                    this.setPaymentType(qFilters);
+                } else if (PaymentTypeEnum.OTR.name().equals(entrance)) {
+                    qFilters = new QFilter[]{new QFilter("biztype", "=", "999")};
+                    this.setPaymentType(qFilters);
+                }
+
+                billTypeID = BillTypeConstants.PAYBILL_OTR;
+            }
+
+            this.setValue("issingle", "1");
+            if (billTypeID != 0L && QueryServiceHelper.exists("bos_billtype", billTypeID)) {
+                this.setValue("billtype", billTypeID);
+            }
+        }
+
+        this.fillPayeeType(true);
+        if (CasHelper.isEmpty(this.orgId)) {
+            this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
+            this.getView().showErrorNotification(ResManager.loadKDString("请先选择付款人", "PaymentBillEdit_30", "fi-cas-formplugin", new Object[0]));
+        } else if (InitCheckPluginHelper.checkInitForPlugin(this.getView(), this.getDynamicObject("org"), new String[]{"bar_save", "bar_submit", "bar_beforesubmit"})) {
+            this.getView().setEnable(true, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
+            DynamicObject baseCurrency = OrgHelper.getBaseCurrency(this.orgId);
+            this.setValue("basecurrency", baseCurrency);
+            this.setValue("currency", baseCurrency);
+            this.setValue("dpcurrency", baseCurrency);
+            this.setValue("feecurrency", baseCurrency);
+            this.setDefaultExratetable(this.orgId);
+            DynamicObject defaultSettleType = BaseDataHelper.getDefaultSettleType();
+            this.setValue("settletype", defaultSettleType);
+            DynamicObject defaultPayAccount;
+            if (!BaseDataHelper.isSettleTypeCash(defaultSettleType)) {
+                defaultPayAccount = AccountBankHelper.getDefaultPayAccount(this.orgId);
+                if (defaultPayAccount == null || (!BaseDataHelper.isSettleTypeVirtual(defaultSettleType) || !VisibleVirtualAcctHelper.checkVirtualAcct(defaultPayAccount)) && (BaseDataHelper.isSettleTypeVirtual(defaultSettleType) || VisibleVirtualAcctHelper.checkVirtualAcct(defaultPayAccount))) {
+                    this.getView().setEnable(false, new String[]{"exchangerate"});
+                    this.clearBalanceValue();
+                } else {
+                    this.setValue("payeracctbank", defaultPayAccount);
+                    this.payerAcctBankF7Changed((PropertyChangedArgs)null, defaultPayAccount);
+                    this.currencyF7Changed(false);
+                }
+            }
+
+            defaultPayAccount = BusinessDataServiceHelper.loadSingleFromCache(this.orgId, "bos_org");
+            this.getModel().setValue("payernumber", defaultPayAccount.getString("number"));
+            this.getModel().setValue("uniformsocialcreditcode", defaultPayAccount.getString("uniformsocialcreditcode"));
+            this.setPayerInfo4Lb();
+            this.setOpenOrg();
+        }
+    }
+
+    private void setPayerInfo4Lb() {
+        DynamicObject org = (DynamicObject)this.getModel().getValue("org");
+        if (org != null) {
+            this.getModel().setValue("orgv", CasHelper.getLocalValue(org, "name"));
+            String defaultUrl = "/icons/pc/entrance/cn_fk_80_80.png";
+            Image orgPic = (Image)this.getControl("orgpic");
+            orgPic.setUrl(defaultUrl);
+            DynamicObject payerAcctBank = (DynamicObject)this.getModel().getValue("payeracctbank");
+            DynamicObject payerAcctCash = (DynamicObject)this.getModel().getValue("payeracctcash");
+            String v_payerbanknum = "";
+            if (payerAcctBank != null) {
+                v_payerbanknum = StringUtils.splitString(payerAcctBank.getString("bankaccountnumber"), 4, " ");
+            } else if (payerAcctCash != null) {
+                v_payerbanknum = payerAcctCash.getString("number");
+            }
+
+            ((Label)this.getControl("payerbanknumv")).setText(v_payerbanknum);
+            DynamicObject payerBank = (DynamicObject)this.getModel().getValue("payerbank");
+            String v_payerbankname = "";
+            if (payerBank != null) {
+                v_payerbankname = CasHelper.getLocalValue(payerBank, "name");
+            }
+
+            ((Label)this.getControl("payerbanknamev")).setText(v_payerbankname);
+            boolean isCash = BaseDataHelper.isSettleTypeCash((DynamicObject)this.getModel().getValue("settletype"));
+            this.getView().setVisible(!isCash, new String[]{"payerbanknamev", "payerbanknamelb"});
+        }
+    }
+
+    private void fillPayeeType(boolean setDefaultValue) {
+        ComboEdit payeetypeCbo = (ComboEdit)this.getView().getControl("payeetype");
+        List<ComboItem> comboItem = new ArrayList();
+        String entrance = (String)this.getModel().getValue("entrance");
+        if (PaymentTypeEnum.AP.name().equals(entrance)) {
+            comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.SUPPLIER.getName()), AsstActTypeEnum.SUPPLIER.getValue()));
+            comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.CUSTOMER.getName()), AsstActTypeEnum.CUSTOMER.getValue()));
+            comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.EMPLOYEE.getName()), AsstActTypeEnum.EMPLOYEE.getValue()));
+        } else if (!PaymentTypeEnum.SYN.name().equals(entrance) && !PaymentTypeEnum.CASH.name().equals(entrance)) {
+            AsstActTypeEnum[] var5 = AsstActTypeEnum.values();
+            int var6 = var5.length;
+
+            for(int var7 = 0; var7 < var6; ++var7) {
+                AsstActTypeEnum asstAct = var5[var7];
+                comboItem.add(new ComboItem(new LocaleString(asstAct.getName()), asstAct.getValue()));
+            }
+        } else {
+            comboItem.add(new ComboItem(new LocaleString(AsstActTypeEnum.COMPANY.getName()), AsstActTypeEnum.COMPANY.getValue()));
+        }
+
+        payeetypeCbo.setComboItems(comboItem);
+        if (setDefaultValue) {
+            this.getModel().setValue("payeetype", ((ComboItem)comboItem.get(0)).getValue());
+        }
+
+    }
+
+    public void afterImportData(ImportDataEventArgs e) {
+        super.afterImportData(e);
+        PaymentFillPropHelper.fillProp(this.getModel().getDataEntity());
+        if (this.getModel().getValue("entrance") == null) {
+            this.setEntrance();
+        }
+
+    }
+
+    public void initImportData(InitImportDataEventArgs e) {
+        super.initImportData(e);
+        this.getPageCache().put("isFromWebApi", "true");
+    }
+
+    public void afterCopyData(EventObject e) {
+        super.afterCopyData(e);
+        DynamicObject billType = (DynamicObject)this.getValue("billtype");
+        if (billType != null && BillTypeConstants.PAYBILL_PUR == billType.getLong("id")) {
+            this.getModel().setValue("entrance", PaymentTypeEnum.AP.name());
+        }
+
+        this.fillPayeeType(false);
+        this.setValue("sourcetype", SourceTypeEnum.CAS);
+        DynamicObject paymentType = (DynamicObject)this.getValue("paymenttype");
+        if (paymentType != null && paymentType.getBoolean("ispartpayment")) {
+            int count = this.getModel().getEntryRowCount("entry");
+
+            for(int i = 0; i < count; ++i) {
+                this.setValue("e_unlockamt", (BigDecimal)this.getModel().getValue("e_payableamt", i), i);
+                this.setValue("e_unsettledamt", (BigDecimal)this.getModel().getValue("e_payableamt", i), i);
+            }
+
+            this.getView().updateView("entry");
+        }
+
+        this.showBalance();
+        this.setNetBankAcctVisible();
+        DynamicObject accountBank = this.getDynamicObject("payeracctbank");
+        this.setPaymentChannelValue(accountBank, Boolean.TRUE);
+        DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype");
+        if (crossTranType0 != null) {
+            DynamicObject crossTransType = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype");
+            DynamicObjectCollection dynamicObjectCollection = crossTransType.getDynamicObjectCollection("entry");
+            this.isCrossTranTypeHide(dynamicObjectCollection);
+        }
+
+        this.getModel().deleteEntryData("cas_draftinfo");
+        this.getModel().setValue("applyorg", (Object)null);
+    }
+
+    public void afterLoadData(EventObject e) {
+        super.afterLoadData(e);
+        this.showBalance();
+        this.setNetBankAcctVisible();
+        DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype");
+        if (crossTranType0 != null) {
+            DynamicObject crossTransType = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype");
+            DynamicObjectCollection dynamicObjectCollection = crossTransType.getDynamicObjectCollection("entry");
+            this.isCrossTranTypeHide(dynamicObjectCollection);
+        }
+
+    }
+
+    private void ctrRefundInfoVisibility() {
+        logger.info("付款单:PaymentBillEdit.ctrRefundInfoVisibility()");
+        this.getView().setVisible(false, new String[]{"bar_refund_save"});
+        String billstatus = (String)this.getValue("billstatus");
+        this.getView().setVisible(BillStatusEnum.REFUND.getValue().equals(billstatus) || BillStatusEnum.RENOTE.getValue().equals(billstatus), new String[]{"e_refundamt", "e_refunddes"});
+        this.getView().setEnable(false, new String[]{"e_refundamt", "e_refunddes"});
+    }
+
+    private void setNetBankAcctVisible() {
+        String paymentchannel = (String)this.getValue("paymentchannel");
+        if (null != paymentchannel && this.isAcctBankExistOnlineBankAcct()) {
+            this.getView().setVisible(true, new String[]{"netbankacct"});
+        } else {
+            this.getView().setVisible(false, new String[]{"netbankacct"});
+        }
+
+    }
+
+    private void setEntrance() {
+        DynamicObject billType = (DynamicObject)this.getModel().getValue("billtype");
+        if (billType != null) {
+            Long billTypeId = billType.getLong("id");
+            if (BillTypeConstants.PAYBILL_PUR.equals(billTypeId)) {
+                this.getModel().setValue("entrance", PaymentTypeEnum.AP.name());
+            } else if (BillTypeConstants.PAYBILL_EXP.equals(billTypeId)) {
+                this.getModel().setValue("entrance", PaymentTypeEnum.OTR.name());
+            } else if (BillTypeConstants.PAYBILL_OTR.equals(billTypeId)) {
+                this.getModel().setValue("entrance", PaymentTypeEnum.OTR.name());
+            } else if (BillTypeConstants.PAYBILL_SYN.equals(billTypeId)) {
+                this.getModel().setValue("entrance", PaymentTypeEnum.SYN.name());
+            } else if (BillTypeConstants.PAYBILL_CASH.equals(billTypeId)) {
+                this.getModel().setValue("entrance", PaymentTypeEnum.CASH.name());
+            } else if (BillTypeConstants.PAYBILL_SPAN.equals(billTypeId)) {
+                this.getModel().setValue("entrance", PaymentTypeEnum.SPAN.name());
+            }
+
+        }
+    }
+
+    public void customPrintDataObject(CustomPrintDataObjectArgs e) {
+        super.customPrintDataObject(e);
+        String entityKey = e.getDataSourceName();
+        if ("nckd_cas_arbill".equals(entityKey)) {
+            List<DynamicObject> dataEntitiesv = new ArrayList();
+            DynamicObject dsv = this.getModel().getDataEntity();
+            DynamicObject basecur = (DynamicObject)this.getModel().getValue("basecurrency");
+            if (basecur != null) {
+                dsv.set("basecurrency", basecur.getString("name"));
+            }
+
+            if (dsv.getString("payeetype") != null && dsv.getString("payeetype").length() > 0) {
+                dsv.set("payeetype", AsstActTypeEnum.getName(dsv.getString("payeetype")));
+            }
+
+            dataEntitiesv.add(dsv);
+            e.setDataEntities(dataEntitiesv);
+        }
+
+    }
+
+    public void propertyChanged(PropertyChangedArgs e) {
+        String key = e.getProperty().getName();
+        ChangeData[] changeData = e.getChangeSet();
+        Object newValue = changeData[0].getNewValue();
+        Object oldValue = changeData[0].getOldValue();
+        int iRow = changeData[0].getRowIndex();
+        if (newValue != oldValue) {
+            DynamicObject applyDo;
+            switch (key) {
+                case "paymenttype":
+                    this.paymentTypeChanged((DynamicObject)newValue);
+                    break;
+                case "bizdate":
+                    this.exratedateChanged(newValue);
+                    break;
+                case "exratetable":
+                    this.currencyF7Changed(false);
+                    this.setRecInfo("dpexratetable", newValue, Boolean.FALSE);
+                    break;
+                case "exratedate":
+                    this.currencyF7Changed(false);
+                    this.setRecInfo("dpexratedate", newValue, Boolean.FALSE);
+                    break;
+                case "payeetype":
+                    this.payeeTypeChanged((String)newValue, true);
+                    break;
+                case "org":
+                    this.setOpenOrg();
+                    this.showBalance();
+                    break;
+                case "payeracctbank":
+                    this.payerAcctBankF7Changed(e, newValue);
+                    this.isOnlinebankVisibility();
+                    break;
+                case "payeracctcash":
+                    this.payerAcctCashChanged((DynamicObject)newValue);
+                    break;
+                case "currency":
+                    this.currencyF7Changed(true);
+                    this.setRecInfo("dpcurrency", newValue, Boolean.TRUE);
+                    this.setExratetableVisibility();
+                    break;
+                case "exchangerate":
+                case "agreedquotation":
+                case "payquotation":
+                case "dppayquotation":
+                    this.calculateAmt();
+                    break;
+                case "settletype":
+                    this.settleTypeChanged(e, newValue);
+                    this.settletNumber((DynamicObject)newValue);
+                    this.isClearSettleType((DynamicObject)oldValue, (DynamicObject)newValue);
+                    if (this.isClearFeeSettleType()) {
+                        this.setValue("fee", (Object)null);
+                    }
+                    break;
+                case "billstatus":
+                    PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView());
+                    break;
+                case "e_payableamt":
+                    this.entries_payableAmtChanged((BigDecimal)newValue, oldValue, iRow);
+                    break;
+                case "e_discountamt":
+                    this.entries_discountAmtChanged((BigDecimal)newValue, oldValue, iRow);
+                    break;
+                case "entrustorg":
+                    this.entrustorgChange(newValue);
+                    break;
+                case "paymentchannel":
+                    this.paymentchannelChange();
+                    break;
+                case "e_refundamt":
+                    this.refundChange((BigDecimal)newValue, (BigDecimal)oldValue, iRow);
+                    break;
+                case "crosstrantype":
+                    DynamicObject crossTranType0 = (DynamicObject)this.getModel().getValue("crosstrantype");
+                    if (crossTranType0 != null) {
+                        applyDo = BusinessDataServiceHelper.loadSingle(crossTranType0.getPkValue(), "bei_crosstrantype");
+                        DynamicObjectCollection dynamicObjectCollection = applyDo.getDynamicObjectCollection("entry");
+                        this.isCrossTranTypeHide(dynamicObjectCollection);
+                        Iterator var16 = dynamicObjectCollection.iterator();
+
+                        while(var16.hasNext()) {
+                            DynamicObject dyobj = (DynamicObject)var16.next();
+                            String settleMethod = ResManager.loadKDString("清算方式", "PaymentBillEdit_27", "fi-cas-formplugin", new Object[0]);
+                            if (kd.bos.dataentity.utils.StringUtils.equals(settleMethod, dyobj.getString("fieldname")) && kd.bos.dataentity.utils.StringUtils.isNotEmpty(dyobj.getString("defaultvalue"))) {
+                                this.getModel().setValue("settlementmethod", dyobj.getString("defaultvalue"));
+                            }
+                        }
+                    }
+                    break;
+                case "applyid":
+                    applyDo = (DynamicObject)newValue;
+                    if (applyDo != null) {
+                        String name = applyDo.getString("name");
+                        String phone = applyDo.getString("phone");
+                        this.getModel().beginInit();
+                        this.getModel().setValue("applyname", name);
+                        this.getModel().endInit();
+                        if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(phone)) {
+                            this.getModel().setValue("applyphone", phone);
+                        }
+
+                        this.getView().updateView("applyname");
+                    }
+                    break;
+                case "reccountry":
+                case "paycountry":
+                    this.setCrossPayValue();
+            }
+
+        }
+    }
+
+    private void isCrossTranTypeHide(DynamicObjectCollection dyobj) {
+        QFilter qFilter = new QFilter("enable", "=", '1');
+        DynamicObject[] crossTransType = BusinessDataServiceHelper.load("bei_crosstranfield", "id,number", new QFilter[]{qFilter});
+        List<Long> number = (List)dyobj.stream().map((e) -> {
+            return e.getLong("id");
+        }).collect(Collectors.toList());
+        Arrays.stream(crossTransType).forEach((e) -> {
+            if (!number.contains(e.getLong("id"))) {
+                this.getView().setVisible(Boolean.FALSE, new String[]{e.getString("number")});
+            }
+
+        });
+    }
+
+    private void isClearSettleType(DynamicObject oldValue, DynamicObject newValue) {
+        String settletnumber = (String)this.getModel().getValue("settletnumber");
+        if (EmptyUtil.isNoEmpty(settletnumber) && Objects.nonNull(oldValue) && SettleMentTypeEnum.CREDIT.getValue().equals(oldValue.getString("settlementtype")) && (Objects.nonNull(newValue) && !SettleMentTypeEnum.CREDIT.getValue().equals(newValue.getString("settlementtype")) || Objects.isNull(newValue))) {
+            this.getModel().setValue("settletnumber", (Object)null);
+            this.getModel().setValue("sourcebilltype", (Object)null);
+            this.getModel().setValue("sourcebillid", (Object)null);
+            this.getModel().setValue("sourcetype", "CAS");
+            this.getModel().deleteEntryData("billhead_lk");
+        }
+
+    }
+
+    private void settletNumber(DynamicObject newValue) {
+        if (!Objects.isNull(newValue)) {
+            Object settlementType = newValue.get("settlementtype");
+            DynamicObject org = (DynamicObject)this.getModel().getValue("org");
+            String appId;
+            if (Objects.nonNull(org)) {
+                appId = AppMetadataCache.getAppInfo("cdm").getId();
+                boolean visible = false;
+                if (!Objects.equals(settlementType, SettleMentTypeEnum.BUSINESS.getValue()) && !Objects.equals(settlementType, SettleMentTypeEnum.BANK.getValue())) {
+                    if (Objects.equals(settlementType, SettleMentTypeEnum.PROMISSORY.getValue())) {
+                        visible = (Boolean) SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "ischeck");
+                    } else if (Objects.equals(settlementType, SettleMentTypeEnum.CHECK.getValue())) {
+                        visible = (Boolean)SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "ispromissorynote");
+                    }
+                } else {
+                    visible = (Boolean)SystemParamServiceHelper.getAppParameter(appId, "08", (Long)org.getPkValue(), "isdraft");
+                }
+
+                this.getView().setVisible(!visible, new String[]{"settletnumber"});
+                this.getView().setVisible(visible, new String[]{"draftbill"});
+            }
+
+            appId = this.getString("settletnumber");
+            if (PayBillHepler.isCreditSettlement(newValue) && appId != null && appId.trim().length() > 0 && "cas_payapplybill".equals(this.getString("sourcebilltype"))) {
+                this.getView().setEnable(false, new String[]{"settletype", "settletnumber"});
+            }
+
+        }
+    }
+
+    private void refundChange(BigDecimal newValue, BigDecimal oldValue, int iRow) {
+        IBillModel model = (IBillModel)this.getModel();
+        BigDecimal e_actamt = (BigDecimal)model.getValue("e_actamt", iRow);
+        if (BigDecimal.ZERO.compareTo(newValue) != 0) {
+            if (BigDecimal.ZERO.compareTo(newValue) > 0) {
+                model.setValue("e_refundamt", oldValue, iRow);
+                this.getView().showTipNotification(ResManager.loadKDString("退款金额不能为零", "PaymentBillEdit_21", "fi-cas-formplugin", new Object[0]));
+            } else if (e_actamt.compareTo(newValue) < 0) {
+                model.setValue("e_refundamt", oldValue, iRow);
+                this.getView().showTipNotification(ResManager.loadKDString("退款金额不能大于付款金额", "PaymentBillEdit_20", "fi-cas-formplugin", new Object[0]));
+            }
+        }
+
+    }
+
+    private void paymentchannelChange() {
+        if (this.isBeiBePay()) {
+            this.setValue("fee", (Object)null);
+        }
+
+        this.isOnlinebankVisibility();
+        this.ctrBeInfoVisibility();
+        this.changePayeeValue();
+    }
+
+    private void entrustorgChange(Object newValue) {
+        if (null != newValue) {
+            this.getModel().setValue("settletype", (Object)null);
+        } else {
+            DynamicObject defaultSettleType = BaseDataHelper.getDefaultSettleType();
+            this.setValue("settletype", defaultSettleType);
+        }
+    }
+
+    private void addEntryCache() {
+        DynamicObjectCollection entry = this.getModel().getEntryEntity("entry");
+        List<Map<String, Object>> list = new ArrayList();
+        Iterator var3 = entry.iterator();
+
+        while(var3.hasNext()) {
+            DynamicObject row = (DynamicObject)var3.next();
+            Map<String, Object> map = new HashMap();
+            map.put("e_expenseitem", row.get("e_expenseitem") == null ? null : ((DynamicObject)row.get("e_expenseitem")).getPkValue());
+            map.put("e_payableamt", row.get("e_payableamt"));
+            map.put("project", row.get("project") == null ? null : row.getDynamicObject("project").getPkValue());
+            map.put("e_fundflowitem", row.get("e_fundflowitem") == null ? null : row.getDynamicObject("e_fundflowitem").getPkValue());
+            map.put("e_remark", row.get("e_remark"));
+            list.add(map);
+        }
+
+        Map<String, List<Map<String, Object>>> map = new HashMap();
+        map.put("entry", list);
+        String mapJson = SerializationUtils.toJsonString(map);
+        this.getPageCache().put("entry", mapJson);
+    }
+
+    private void paymentTypeChanged(DynamicObject paymentType) {
+        String entrance = (String)this.getModel().getValue("entrance");
+        boolean isAp;
+        if (paymentType != null && PaymentTypeEnum.OTR.name().equals(entrance)) {
+            isAp = paymentType.getBoolean("ispartpayment");
+            Long billTypeID = this.getPk("billtype");
+            boolean isChange = false;
+            if (isAp) {
+                if (!BillTypeConstants.PAYBILL_EXP.equals(billTypeID)) {
+                    this.addEntryCache();
+                    this.setValue("billtype", BusinessDataServiceHelper.loadSingleFromCache(BillTypeConstants.PAYBILL_EXP, "bos_billtype"));
+                    isChange = true;
+                }
+            } else if (!BillTypeConstants.PAYBILL_OTR.equals(billTypeID)) {
+                this.addEntryCache();
+                this.setValue("billtype", BusinessDataServiceHelper.loadSingleFromCache(BillTypeConstants.PAYBILL_OTR, "bos_billtype"));
+                isChange = true;
+            }
+
+            if (isChange) {
+                this.getModel().beginInit();
+                this.setValue("paymenttype", paymentType);
+                this.getModel().endInit();
+                this.getView().updateView("paymenttype");
+                Label payeebanknumvLable = (Label)this.getControl("payeebanknumv");
+                payeebanknumvLable.setText("");
+                Label recaccbanknamevLable = (Label)this.getControl("recaccbanknamev");
+                recaccbanknamevLable.setText("");
+                Label payeebanknamevLable = (Label)this.getControl("payeebanknamev");
+                payeebanknamevLable.setText("");
+                Label recbanknumbervLable = (Label)this.getControl("recbanknumberv");
+                recbanknumbervLable.setText("");
+            }
+        }
+
+        this.setEntryAmountCaption();
+        if (paymentType != null) {
+            isAp = paymentType.getBoolean("ispartpayment");
+            this.getView().setVisible(isAp, new String[]{"settleorg"});
+            this.settleOrg(false);
+            DynamicObject fundflowitem = paymentType.getDynamicObject("fundflowitem");
+            this.fillFundflowItem(true, fundflowitem);
+        }
+
+    }
+
+    private void settleTypeChanged(PropertyChangedArgs e, Object newValue) {
+        this.ctrBeInfoVisibility();
+        DynamicObject settleType = (DynamicObject)newValue;
+        DynamicObject accountCash;
+        if (BaseDataHelper.isSettleTypeCash(settleType)) {
+            this.setValue("payeracctbank", (Object)null);
+            this.setValue("payerbank", (Object)null);
+            accountCash = this.getDynamicObject("payeracctcash");
+            if (accountCash == null) {
+                this.setValue("payeracctcash", AccountCashHelper.getDefaultAccountcash(this.getPk("org"), "payer"));
+            }
+
+            this.setValue("isdiffcur", "0");
+            this.getView().setVisible(false, new String[]{"isdiffcur"});
+        } else {
+            this.setValue("payeracctcash", (Object)null);
+            this.getView().setVisible(true, new String[]{"isdiffcur"});
+        }
+
+        this.setPayerInfo4Lb();
+        accountCash = this.getDynamicObject("payeracctbank");
+        this.setPaymentChannelValue(accountCash, Boolean.TRUE);
+        this.changePayeeValue();
+    }
+
+    private void ctrBeInfoVisibility() {
+        boolean isBePay = this.isBePay();
+        this.getView().setVisible(!this.isDraft(), new String[]{"settletnumber"});
+        this.getView().setVisible(this.isDraft(), new String[]{"draftbill"});
+        this.getView().setVisible(isBePay, new String[]{"usage"});
+    }
+
+    private boolean isDraft() {
+        DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype");
+        if (settleType == null) {
+            return false;
+        } else {
+            String settlementType = settleType.getString("settlementtype");
+            return Objects.equals(settlementType, SettleMentTypeEnum.BANK.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.BUSINESS.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.CHECK.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.PROMISSORY.getValue());
+        }
+    }
+
+    private void exratedateChanged(Object newValue) {
+        if (newValue != null) {
+            this.setValue("exratedate", newValue);
+            this.setValue("dpexratedate", newValue);
+        }
+    }
+
+    private void currencyF7Changed(boolean reBalance) {
+        if (reBalance) {
+            this.showBalance();
+        }
+
+        this.setExchangerateEditable();
+    }
+
+    private void entries_payableAmtChanged(BigDecimal payableAmt, Object oldValue, int iRow) {
+        IBillModel model = (IBillModel)this.getModel();
+        BigDecimal discountAmt = (BigDecimal)model.getValue("e_discountamt", iRow);
+        discountAmt = discountAmt != null ? discountAmt : BigDecimal.ZERO;
+        if (discountAmt.abs().compareTo(payableAmt.abs()) > 0) {
+            this.getView().showTipNotification(String.format(ResManager.loadKDString("现金折扣绝对值不允许大于应付金额绝对值!", "PaymentBillEdit_2", "fi-cas-formplugin", new Object[0])));
+            this.setValue("e_payableamt", oldValue, iRow);
+        } else {
+            this.calculateAmt();
+        }
+    }
+
+    private void entries_discountAmtChanged(BigDecimal discountAmt, Object oldValue, int iRow) {
+        IBillModel model = (IBillModel)this.getModel();
+        BigDecimal payableAmt = (BigDecimal)model.getValue("e_payableamt", iRow);
+        payableAmt = payableAmt != null ? payableAmt : BigDecimal.ZERO;
+        if (discountAmt.abs().compareTo(payableAmt.abs()) > 0) {
+            this.getView().showTipNotification(String.format(ResManager.loadKDString("现金折扣绝对值不允许大于应付金额绝对值!", "PaymentBillEdit_2", "fi-cas-formplugin", new Object[0])));
+            this.setValue("e_discountamt", oldValue, iRow);
+        } else {
+            this.calculateAmt();
+        }
+    }
+
+    private void calculateAmt() {
+        DynamicObject basecurrency = this.getDynamicObject("basecurrency");
+        BigDecimal exchangeRate = (BigDecimal)this.getModel().getValue("exchangerate");
+        String quotation = this.getString("payquotation");
+        int round = 10;
+        if (basecurrency != null) {
+            round = basecurrency.getInt("amtprecision");
+        }
+
+        int count = this.getModel().getEntryRowCount("entry");
+        BigDecimal sumAmt = BigDecimal.ZERO;
+        BigDecimal sumLocalAmt = BigDecimal.ZERO;
+
+        for(int i = 0; i < count; ++i) {
+            DynamicObject rowInfo = this.getModel().getEntryRowEntity("entry", i);
+            BigDecimal payAmount = rowInfo.getBigDecimal("e_payableamt");
+            if (payAmount != null) {
+                this.setValue("e_payablelocamt", QuotationHelper.callToCurrency(payAmount, exchangeRate, quotation, round), i);
+            }
+
+            BigDecimal discountAmt = rowInfo.getBigDecimal("e_discountamt");
+            if (discountAmt != null) {
+                this.setValue("e_discountlocamt", QuotationHelper.callToCurrency(discountAmt, exchangeRate, quotation, round), i);
+            }
+
+            if (payAmount != null && discountAmt != null) {
+                BigDecimal actAmt = payAmount.subtract(discountAmt);
+                sumAmt = sumAmt.add(actAmt);
+                BigDecimal actLocalAmt = BigDecimal.ZERO;
+                actLocalAmt = QuotationHelper.callToCurrency(actAmt, exchangeRate, quotation, round);
+                sumLocalAmt = sumLocalAmt.add(actLocalAmt);
+                this.setValue("e_actamt", actAmt, i);
+                this.setValue("e_localamt", actLocalAmt, i);
+            }
+
+            this.setValue("e_unsettledamt", payAmount, i);
+            if (payAmount != null) {
+                this.setValue("e_unsettledlocalamt", QuotationHelper.callToCurrency(payAmount, exchangeRate, quotation, round), i);
+            }
+
+            this.setValue("e_unlockamt", payAmount, i);
+        }
+
+        this.setValue("actpayamt", sumAmt);
+        this.setValue("localamt", sumLocalAmt);
+        this.calculateDpAmt();
+    }
+
+    private void calculateDpAmt() {
+        DynamicObject dpcurrency = this.getDynamicObject("dpcurrency");
+        DynamicObject basecurrency = this.getDynamicObject("basecurrency");
+        DynamicObject currency = this.getDynamicObject("currency");
+        String dppayquotation = this.getString("dppayquotation");
+        String agreedquotation = this.getString("agreedquotation");
+        int round = 10;
+        if (basecurrency != null) {
+            round = basecurrency.getInt("amtprecision");
+        }
+
+        int dppayround = 10;
+        if (dpcurrency != null) {
+            dppayround = dpcurrency.getInt("amtprecision");
+        }
+
+        BigDecimal actPayAmt = this.getBigDecimal("actpayamt");
+        if (currency != null) {
+            actPayAmt = actPayAmt.setScale(currency.getInt("amtprecision"), 4);
+        }
+
+        BigDecimal localAmt = this.getBigDecimal("localamt");
+        BigDecimal agreedRate = this.getBigDecimal("agreedrate");
+        if (agreedRate.compareTo(new BigDecimal(0)) != 0) {
+            BigDecimal dpAmt = BigDecimal.ZERO;
+            dpAmt = QuotationHelper.callToCurrency(actPayAmt, agreedRate, agreedquotation, dppayround);
+            BigDecimal dpExchangeRate = this.getBigDecimal("dpexchangerate");
+            BigDecimal dpLocalAmt = BigDecimal.ZERO;
+            dpLocalAmt = QuotationHelper.callToCurrency(dpAmt, dpExchangeRate, dppayquotation, round);
+            this.getModel().beginInit();
+            this.setValue("dpamt", dpAmt);
+            this.setValue("dplocalamt", dpLocalAmt);
+            this.setValue("lossamt", localAmt.subtract(dpLocalAmt));
+            this.getModel().endInit();
+            this.getView().updateView("dpamt");
+            this.getView().updateView("dplocalamt");
+            this.getView().updateView("lossamt");
+        }
+    }
+
+    private void payeeTypeChanged(String payeeType, boolean isChanged) {
+        if (isChanged) {
+            this.getView().setVisible(true, new String[]{"flex_addpayee"});
+            this.getView().setVisible(false, new String[]{"flex_payeeinfo"});
+            this.clearPayeeValue();
+        }
+
+    }
+
+    private void clearPayeeValue() {
+        Object value = null;
+        this.setValue("payeeformid", value);
+        this.setValue("payee", value);
+        this.setValue("payeename", value);
+        this.setValue("payeeaccformid", value);
+        this.setValue("payeeacctbank", value);
+        this.setValue("payeebanknum", value);
+        this.setValue("payeebank", value);
+        this.setValue("payeebankname", value);
+        this.setValue("recaccbankname", value);
+        this.setValue("recbanknumber", value);
+        this.setValue("payeenumber", (Object)null);
+        this.setValue("supplierBankId", (Object)null);
+    }
+
+    private void payerAcctBankF7Changed(PropertyChangedArgs e, Object newValue) {
+        DynamicObject payerAcctBank = (DynamicObject)newValue;
+        this.ctrBeInfoVisibility();
+        this.showBalance();
+        if (!FeePayerEnum.REC.getValue().equals(this.getString("feepayer"))) {
+            this.setValue("feeactbank", payerAcctBank);
+        }
+
+        if (payerAcctBank == null) {
+            this.setValue("payerbank", (Object)null);
+            this.setPaymentChannelValue((DynamicObject)null, Boolean.TRUE);
+            this.setCurrencyEditable();
+        } else {
+            this.setValue("payerbank", payerAcctBank.getDynamicObject("bank"));
+            Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
+            DynamicObject payCurrency = null;
+            if (isDiffCur) {
+                payCurrency = this.getDynamicObject("dpcurrency");
+            } else {
+                payCurrency = this.getDynamicObject("currency");
+            }
+
+            boolean containCurrency = AccountBankHelper.isAcctBankContainCurrency("bd_accountbanks", payerAcctBank.getPkValue(), payCurrency);
+            if (!containCurrency) {
+                Long defaultCurrencyId = (Long)payerAcctBank.get("defaultcurrency.id");
+                if (isDiffCur) {
+                    this.setValue("dpcurrency", defaultCurrencyId);
+                } else if (this.isBotpCreate()) {
+                    this.setValueIfAbsent("currency", defaultCurrencyId);
+                } else {
+                    this.setValue("currency", defaultCurrencyId);
+                }
+            }
+
+            this.setCurrencyEditable();
+            this.setOpenOrg();
+            this.setPaymentChannelValue(payerAcctBank, Boolean.TRUE);
+            this.setSettleTypeValue(payerAcctBank);
+            this.settleOrg(true);
+        }
+    }
+
+    private void setPaymentChannelValue(DynamicObject payerAcctBank, boolean isAdd) {
+        List<ComboItem> comboItems = new ArrayList(1);
+        ComboEdit paymentChannel = (ComboEdit)this.getControl("paymentchannel");
+        DynamicObject settleType = this.getDynamicObject("settletype");
+        ComboItem comboItem = new ComboItem();
+        comboItem.setValue(PaymentChannelEnum.COUNTER.getValue());
+        comboItem.setCaption(new LocaleString(PaymentChannelEnum.COUNTER.getName()));
+        ComboItem selectedItem = comboItem;
+        comboItems.add(comboItem);
+        DynamicObject billtype = this.getDynamicObject("billtype");
+        if (null != payerAcctBank && (settleType == null || !"14".equals(settleType.getString("settlementtype"))) && (billtype == null || !BillTypeConstants.PAYBILL_CASH.equals(billtype.getPkValue()))) {
+            ComboItem item;
+            if (payerAcctBank.getBoolean("isopenbank")) {
+                item = new ComboItem();
+                item.setValue(PaymentChannelEnum.ONLINEBANK.getValue());
+                item.setCaption(new LocaleString(PaymentChannelEnum.ONLINEBANK.getName()));
+                selectedItem = item;
+                comboItems.add(item);
+            }
+
+            if (payerAcctBank.getBoolean("issetbankinterface")) {
+                item = new ComboItem();
+                item.setValue(PaymentChannelEnum.BEI.getValue());
+                item.setCaption(new LocaleString(ResManager.loadKDString(PaymentChannelEnum.BEI.getName(), "PaymentBillEdit_18", "fi-cas-formplugin", new Object[0])));
+                selectedItem = item;
+                comboItems.add(item);
+            }
+
+            String defaultPaymentChannel = "";
+            String defChannel;
+            if (Objects.nonNull(settleType)) {
+                defChannel = settleType.getString("paymentchannel");
+                defaultPaymentChannel = settleType.getString("defaultpaymentchannel");
+                if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(defChannel)) {
+                    List<String> paymentChannels = (List)Arrays.stream(defChannel.split(",")).filter(kd.bos.dataentity.utils.StringUtils::isNotEmpty).collect(Collectors.toList());
+                    comboItems.removeIf((i) -> {
+                        return !paymentChannels.contains(i.getValue());
+                    });
+                }
+            }
+
+            paymentChannel.setComboItems(comboItems);
+            if (isAdd || this.isBotpNew() && Objects.isNull(this.getModel().getValue("paymentchannel"))) {
+                defChannel = selectedItem.getValue();
+                if (settleType != null && !SettleMentTypeEnum.COLLECT.getValue().equals(settleType.getString("settlementtype"))) {
+                    defChannel = PaymentChannelEnum.COUNTER.getValue();
+                }
+
+                if (kd.bos.dataentity.utils.StringUtils.isNotEmpty(defaultPaymentChannel)) {
+                    defChannel = defaultPaymentChannel;
+                }
+
+                String finalDefChannel = defChannel;
+                boolean contains = comboItems.stream().anyMatch((itemx) -> {
+                    return Objects.equals(finalDefChannel, itemx.getValue());
+                });
+                if (!contains) {
+                    defChannel = null;
+                }
+
+                if ("bei".equalsIgnoreCase(defChannel)) {
+                    this.getModel().setValue("fee", (Object)null);
+                    this.getModel().setValue("singlestream", Boolean.FALSE);
+                }
+
+                this.getModel().setValue("paymentchannel", defChannel);
+            }
+
+        } else {
+            paymentChannel.setComboItems(comboItems);
+            if (isAdd) {
+                this.getModel().setValue("paymentchannel", comboItem.getValue());
+                if ("bei".equalsIgnoreCase(comboItem.getValue())) {
+                    this.getModel().setValue("fee", (Object)null);
+                    this.getModel().setValue("singlestream", Boolean.FALSE);
+                }
+            }
+
+        }
+    }
+
+    private void payerAcctCashChanged(DynamicObject acctCash) {
+        if (acctCash == null) {
+            this.setValue("currency", this.getDynamicObject("basecurrency"));
+            this.setCurrencyEditable();
+            this.showBalance();
+        } else {
+            Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
+            DynamicObject payCurrency = null;
+            if (isDiffCur) {
+                payCurrency = this.getDynamicObject("dpcurrency");
+            } else {
+                payCurrency = this.getDynamicObject("currency");
+            }
+
+            boolean containCurrency = AccountBankHelper.isAcctBankContainCurrency("cas_accountcash", acctCash.getPkValue(), payCurrency);
+            if (!containCurrency) {
+                DynamicObject defaultCurrency = acctCash.getDynamicObject("defaultcurrency");
+                if (isDiffCur) {
+                    this.setValue("dpcurrency", defaultCurrency);
+                } else if (this.isBotpCreate()) {
+                    this.setValueIfAbsent("currency", defaultCurrency);
+                } else {
+                    this.setValue("currency", defaultCurrency);
+                }
+            }
+
+            this.setCurrencyEditable();
+            this.setValue("openorg", acctCash.getDynamicObject("openorg"));
+            this.showBalance();
+        }
+    }
+
+    private void setCurrencyEditable() {
+        Boolean isCurrencyEditable = Boolean.TRUE;
+        DynamicObject settleType = this.getDynamicObject("settletype");
+        boolean isCash = BaseDataHelper.isSettleTypeCash(settleType);
+        DynamicObject accountCash;
+        if (isCash) {
+            accountCash = this.getDynamicObject("payeracctcash");
+            if (accountCash != null) {
+                isCurrencyEditable = !accountCash.getBoolean("isbycurrency");
+            }
+        } else {
+            accountCash = this.getDynamicObject("payeracctbank");
+            if (accountCash != null) {
+                isCurrencyEditable = accountCash.getBoolean("ismulcurrency");
+            }
+        }
+
+        Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
+        if (isDiffCur) {
+            this.getView().setEnable(isCurrencyEditable, new String[]{"dpcurrency"});
+        } else {
+            this.getView().setEnable(isCurrencyEditable, new String[]{"currency"});
+        }
+
+        if (this.isBotpCreate()) {
+            this.getView().setEnable(false, new String[]{"currency"});
+        }
+
+    }
+
+    private void showBalance() {
+        this.getView().setEnable(true, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
+        if (this.getModel().getValue("org") != null) {
+            Long orgID = this.getPk("org");
+            Long acctBankId = this.getPk("payeracctbank");
+            Long acctCashId = this.getPk("payeracctcash");
+            Long currencyId = this.getPk("currency");
+            boolean var5 = (Boolean)this.getValue("isdiffcur");
+            if (var5) {
+                currencyId = this.getPk("dpcurrency");
+            }
+
+            if (orgID != null && (acctBankId != null || acctCashId != null) && currencyId != null) {
+                DynamicObject currency = BusinessDataServiceHelper.loadSingleFromCache(currencyId, "bd_currency");
+
+                try {
+                    BigDecimal currentBalance = BigDecimal.ZERO;
+                    if (CasHelper.isNotEmpty(acctBankId)) {
+                        DynamicObject acctBank = BusinessDataServiceHelper.loadSingle(acctBankId, "am_accountbank", "acctclassify");
+                        if (Objects.equals(acctBank.get("acctclassify"), AcctClassifyEnum.I.getValue())) {
+                            currentBalance = getCurrBalance(acctBank);
+                        } else {
+                            String balanceType = SystemParameterFcsHelper.getParameterString(orgID, "balancevalue");
+                            Object result = DispatchServiceHelper.invokeBizService("tmc", "fbp", "balanceModelService", "getRunningBalance", new Object[]{balanceType, acctBankId, currencyId});
+                            BizBalanceModelBean bizBalanceModelBean = (BizBalanceModelBean)SerializationUtils.fromJsonString(SerializationUtils.toJsonString(result), BizBalanceModelBean.class);
+                            currentBalance = bizBalanceModelBean.getAmount();
+                        }
+                    }
+
+                    if (CasHelper.isNotEmpty(acctCashId)) {
+                        currentBalance = AcctBalanceHelper.getAccountCashCurrBalance(orgID, acctCashId, currencyId, new Date());
+                        ((Label)this.getControl("balancelb")).setText(ResManager.loadKDString("账面余额:", "PaymentBillEdit_4", "fi-cas-formplugin", new Object[0]));
+                        LocaleString content = new LocaleString(ResManager.loadKDString("付款账户为现金账户时,账面余额即为当前时点现金日记账账面余额。", "PaymentBillEdit_3", "fi-cas-formplugin", new Object[0]));
+                        ((Label)this.getControl("balancelb")).addTips(new Tips("text", (LocaleString)null, content, false, (List)null));
+                    }
+
+                    this.labCurrencySign = currency.getString("sign");
+                    this.currencyAmtprecision = currency.getInt("amtprecision");
+                    this.initFormat();
+                    ((Label)this.getControl("balancev")).setText(this.currencyFormat.format(currentBalance == null ? 0 : currentBalance));
+                } catch (Exception var12) {
+                    this.clearBalanceValue();
+                    logger.error(var12);
+                }
+
+            } else {
+                this.clearBalanceValue();
+            }
+        }
+    }
+
+    private static BigDecimal getCurrBalance(DynamicObject bankAcct) {
+        DynamicObject[] load = BusinessDataServiceHelper.load("ifm_accountbalance", "amount", (new QFilter("accountbank", "=", bankAcct.getPkValue())).toArray(), "bizdate desc", 1);
+        return load.length > 0 ? load[0].getBigDecimal("amount") : BigDecimal.ZERO;
+    }
+
+    private void clearBalanceValue() {
+        ((Label)this.getControl("balancelb")).setText(ResManager.loadKDString("即时余额:", "PaymentBillEdit_5", "fi-cas-formplugin", new Object[0]));
+        LocaleString content = new LocaleString(ResManager.loadKDString("付款账户当前时点余额。付款账户即时余额取值来源有银企互联余额表、出纳/资金结算日记账;系统支持四种取值模式:(1)完全取自余额表;(2)完全取自日记账;(3)优先取余额表,再取日记账;(4)开通银企取余额表,未开通银企取日记账。具体采取何种模式请前往【系统服务云】-【配置工具】-【系统参数】-【资金云】-【资金公共服务】中查看。", "PaymentBillEdit_6", "fi-cas-formplugin", new Object[0]));
+        ((Label)this.getControl("balancelb")).addTips(new Tips("text", (LocaleString)null, content, false, (List)null));
+        DynamicObject currency = this.getDynamicObject("currency");
+        Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
+        if (isDiffCur) {
+            currency = this.getDynamicObject("dpcurrency");
+        }
+
+        if (!CasHelper.isEmpty(currency)) {
+            this.labCurrencySign = currency.getString("sign");
+            this.currencyAmtprecision = currency.getInt("amtprecision");
+            this.initFormat();
+            ((Label)this.getControl("balancev")).setText(this.currencyFormat.format(BigDecimal.ZERO));
+        } else {
+            ((Label)this.getControl("balancev")).setText("¥0.00");
+        }
+
+    }
+
+    public void click(EventObject evt) {
+        super.click(evt);
+        this.getView().setEnable(true, 0, new String[]{"e_payableamt", "e_discountamt", "contractnumber", "e_corebillno", "e_corebillentryseq"});
+        Control c = (Control)evt.getSource();
+        switch (c.getKey().toLowerCase()) {
+            case "changepayer":
+                this.changePayerPage();
+                break;
+            case "addpayeelb1":
+                this.addPayee();
+                break;
+            case "addpayeelb2":
+                this.addPayee();
+                break;
+            case "changepayee":
+                this.changePayeePage();
+                break;
+            case "settletnumber":
+                this.settleNumberClick();
+                break;
+            case "applyname":
+                BasedataEdit applyF7 = (BasedataEdit)this.getControl("applyid");
+                applyF7.click();
+        }
+
+    }
+
+    private void settleNumberClick() {
+        DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype");
+        if (EmptyUtil.isNoEmpty(settleType) && SettleMentTypeEnum.CREDIT.getValue().equals(settleType.getString("settlementtype"))) {
+            String appId = AppMetadataCache.getAppInfo("lc").getId();
+            DynamicObject org = (DynamicObject)this.getModel().getValue("org");
+            AppParam param = new AppParam();
+            param.setAppId(appId);
+            param.setOrgId(org.getLong("id"));
+            param.setViewType("08");
+            String paymethod = (String)SystemParamServiceHelper.loadAppParameterFromCache(param, "paymethod");
+            if ("0".equals(paymethod)) {
+                CloseCallBack closeCallBack = new CloseCallBack(this, "settletnumber");
+                QFilter qFilterSour = new QFilter("arrivalstatus", "=", "arrival_confirm");
+                qFilterSour.and("arrivalway", "!=", "protest");
+                qFilterSour.and(QFilter.sqlExpress("arrivalamount", ">", "flockamount"));
+                qFilterSour.and("isinit", "=", '0');
+                qFilterSour.and("eassrcid", "=", "");
+                CasBotpHelper.doBeforeDraw(this.getView(), "lc_arrival", this.getModel().getDataEntityType().getName(), false, qFilterSour, closeCallBack);
+            }
+        }
+
+    }
+
+    private void changePayeePage() {
+        this.opreatePayee(Boolean.FALSE);
+    }
+
+    private void addPayee() {
+        this.opreatePayee(Boolean.TRUE);
+    }
+
+    private void opreatePayee(Boolean isAddNew) {
+        Map<String, Object> paramMap = new HashMap();
+        if (this.isHwControl()) {
+            paramMap.put("hw_payeesiteid", this.getValue("hw_payeesiteid"));
+        }
+
+        paramMap.put("org", this.getPk("org"));
+        paramMap.put("asstActType", this.getString("payeetype"));
+        paramMap.put("isBE", this.isBePay());
+        paramMap.put("billtype", Optional.ofNullable(this.getDynamicObject("billtype")).map(DataEntityBase::getPkValue).orElse((Object)null));
+        FormShowParameter parameter = new FormShowParameter();
+        parameter.getOpenStyle().setShowType(ShowType.Modal);
+        parameter.setFormId("cas_addpayee");
+        parameter.setStatus(isAddNew ? OperationStatus.ADDNEW : OperationStatus.EDIT);
+        parameter.getCustomParams().putAll(paramMap);
+        parameter.setCloseCallBack(new CloseCallBack(this, "addpayee"));
+        this.getView().showForm(parameter);
+    }
+
+    private void addPayeeValue(Map<String, Object> resultMap) {
+        this.setValue("payeeformid", resultMap.get("payeeformid"));
+        this.setValue("payee", resultMap.get("payee"));
+        this.setValue("payeename", resultMap.get("payeename"));
+        if (this.isHwControl()) {
+            this.setValue("hw_payeesiteid", resultMap.get("hw_payeesiteid"));
+            this.setValue("scorg", resultMap.get("scorg"));
+        }
+
+        this.setValue("payeenumber", resultMap.get("payeenumber"));
+        this.setValue("payeeaccformid", resultMap.get("payeeaccformid"));
+        this.setValue("payeeacctbank", resultMap.get("payeeacctbank"));
+        this.setValue("payeeacctcash", resultMap.get("payeeacctcash"));
+        this.setValue("payeebanknum", resultMap.get("payeebanknum"));
+        this.setValue("payeebank", resultMap.get("payeebank"));
+        this.setValue("payeebankname", resultMap.get("payeebankname"));
+        this.setValue("recaccbankname", resultMap.get("recaccbankname"));
+        String beBankNumber = (String)resultMap.get("recbanknumber");
+        this.setValue("recbanknumber", beBankNumber);
+        this.setValue("reccountry", resultMap.get("reccountry"));
+        this.setValue("recprovince", resultMap.get("recprovince"));
+        this.setValue("reccity", resultMap.get("reccity"));
+        this.setValue("recswiftcode", resultMap.get("swift_code"));
+        this.setValue("recroutingnum", resultMap.get("routingnum"));
+        this.setValue("recothercode", resultMap.get("other_code"));
+        this.setValue("recbankaddress", resultMap.get("address_eng"));
+        this.setValue("recemail", resultMap.get("payeeemail"));
+        this.setValue("payeecurrency", resultMap.get("payeecurrency"));
+        this.setValue("recaddress", resultMap.get("payeeaddress"));
+        this.setValue("supplierBankId", resultMap.get("supplierBankId"));
+        PaymentBillPluginHelper.fillProxyBeBankInfo(this.getModel(), this.getView(), true);
+        Boolean isDiffCur = (Boolean)this.getValue("isdiffcur");
+        Object recCurId = resultMap.get("payeecurrency");
+        if (recCurId != null && ((Long)recCurId).intValue() != 0 && !this.isBotpCreate() && isDiffCur) {
+            this.setValue("currency", resultMap.get("payeecurrency"));
+        }
+
+        if (AsstActTypeEnum.SUPPLIER.getValue().equals(this.getModel().getValue("payeetype"))) {
+            DynamicObject new_settletype = (DynamicObject)resultMap.get("settlment");
+            DynamicObject old_settletype = (DynamicObject)this.getModel().getValue("settletype");
+            if (!CasHelper.isEquals(new_settletype, old_settletype) && new_settletype != null) {
+                this.setValue("settletype", new_settletype);
+            }
+        }
+
+        this.setPayeeInfo4Lb();
+        this.getView().setVisible(false, new String[]{"flex_addpayee"});
+        this.getView().setVisible(true, new String[]{"flex_payeeinfo"});
+    }
+
+    private void changePayeeValue() {
+        this.setPayeeInfo4Lb();
+        boolean addpayView = this.hasPayeeInfo();
+        this.getView().setVisible(!addpayView, new String[]{"flex_addpayee"});
+        this.getView().setVisible(addpayView, new String[]{"flex_payeeinfo"});
+    }
+
+    private void setPayeeInfo4Lb() {
+        String payeeformid = this.getString("payeetype");
+        List<String> payeetypeList = Arrays.asList("bos_org", "bd_supplier", "bd_customer", "bos_user");
+        Long payeeId = Long.parseLong(this.getValue("payee") == null ? "0" : this.getValue("payee").toString());
+        String payeeType = this.getString("payeetype");
+        if (isOther(payeeType)) {
+            this.setValue("payeenamev", this.getValue("payeename"));
+        } else if (CasHelper.isNotEmpty(payeeformid) && payeetypeList.contains(payeeformid) && CasHelper.isNotEmpty(payeeId)) {
+            DynamicObject payeeObj = BusinessDataServiceHelper.loadSingleFromCache(payeeId, payeeformid, "name");
+            this.setValue("payeenamev", CasHelper.getLocalValue(payeeObj, "name"));
+        }
+
+        Image payeePic = (Image)this.getControl("payeepic");
+        String defaultUrl = BaseDataHelper.getPictureUrl(payeeId, payeeformid);
+        defaultUrl = defaultUrl == null ? "/icons/pc/entrance/cn_sk_80_80.png" : defaultUrl;
+        payeePic.setUrl(defaultUrl);
+        ((Label)this.getControl("payeebanknumv")).setText(StringUtils.splitString(this.getString("payeebanknum"), 4, " "));
+        ((Label)this.getControl("payeebanknamev")).setText(this.getString("payeebankname"));
+        ((Label)this.getControl("recaccbanknamev")).setText(this.getString("recaccbankname"));
+        ((Label)this.getControl("recbanknumberv")).setText(this.getString("recbanknumber"));
+    }
+
+    private void changePayerPage() {
+        DynamicObject settleType = this.getDynamicObject("settletype");
+        Object sourceBillType = this.getModel().getValue("sourcebilltype");
+        Map<String, Object> payerInfo = new HashMap();
+        payerInfo.put("cash", BaseDataHelper.isSettleTypeCash(settleType));
+        payerInfo.put("virtual", BaseDataHelper.isSettleTypeVirtual(settleType));
+        payerInfo.put("sourceBillType", sourceBillType);
+        FormShowParameter parameter = new FormShowParameter();
+        parameter.getOpenStyle().setShowType(ShowType.Modal);
+        parameter.setFormId("cas_changepayer");
+        parameter.getCustomParams().putAll(payerInfo);
+        parameter.setCloseCallBack(new CloseCallBack(this, "changepayer"));
+        this.getView().showForm(parameter);
+    }
+
+    private void changePayerValue(Map<String, Object> returnMap) {
+        boolean isChangeCur = false;
+        IBillModel model = (IBillModel)this.getModel();
+        DynamicObject new_org = (DynamicObject)returnMap.get("org");
+        DynamicObject old_org = (DynamicObject)model.getValue("org");
+        DynamicObject cur = OrgHelper.getBaseCurrency((Long)new_org.getPkValue());
+        if (!CasHelper.isEquals(new_org, old_org)) {
+            this.setValue("org", new_org);
+            this.setValue("basecurrency", cur);
+            this.setValue("draftbill", (Object)null);
+            isChangeCur = true;
+        }
+
+        DynamicObject new_acctcash = (DynamicObject)returnMap.get("payeracctcash");
+        DynamicObject old_acctcash = (DynamicObject)model.getValue("payeracctcash");
+        if (!CasHelper.isEquals(new_acctcash, old_acctcash)) {
+            this.setValue("payeracctcash", new_acctcash);
+            isChangeCur = false;
+        }
+
+        DynamicObject new_acctbank = (DynamicObject)returnMap.get("payeracctbank");
+        DynamicObject old_acctbank = (DynamicObject)model.getValue("payeracctbank");
+        if (!CasHelper.isEquals(new_acctbank, old_acctbank)) {
+            this.setValue("payeracctbank", new_acctbank);
+            isChangeCur = false;
+        }
+
+        DynamicObject new_bank = (DynamicObject)returnMap.get("payerbank");
+        DynamicObject old_bank = (DynamicObject)model.getValue("payerbank");
+        if (!CasHelper.isEquals(new_bank, old_bank)) {
+            this.setValue("payerbank", new_bank);
+        }
+
+        this.setPayerInfo4Lb();
+        this.settleOrg(true);
+        if (isChangeCur) {
+            this.setValue("currency", cur);
+        }
+
+        String uniformsocialcreditcode = new_org.getString("uniformsocialcreditcode");
+        if (kd.bos.dataentity.utils.StringUtils.isNotBlank(uniformsocialcreditcode)) {
+            this.setValue("uniformsocialcreditcode", uniformsocialcreditcode);
+        }
+
+        String payerNumber = new_org.getString("number");
+        if (kd.bos.dataentity.utils.StringUtils.isNotBlank(payerNumber)) {
+            this.setValue("payernumber", payerNumber);
+        }
+
+        this.setValue("openorg", returnMap.get("openorg"));
+    }
+
+    public void closedCallBack(ClosedCallBackEvent e) {
+        super.closedCallBack(e);
+        Map data;
+        if ("changepayer".equals(e.getActionId())) {
+            data = (Map)e.getReturnData();
+            if (data != null) {
+                this.changePayerValue(data);
+            }
+        } else if ("addpayee".equals(e.getActionId())) {
+            data = (Map)e.getReturnData();
+            if (data != null) {
+                this.addPayeeValue(data);
+                this.setCrossPayValue();
+            }
+        } else {
+            String confirm;
+            if ("beforesubmit".equals(e.getActionId())) {
+                confirm = (String)e.getReturnData();
+                if (confirm != null && confirm.equals("ok")) {
+                    this.getView().invokeOperation("submit");
+                }
+            } else if ("beforesubmitnew".equals(e.getActionId())) {
+                confirm = (String)e.getReturnData();
+                if (confirm != null && confirm.equals("ok")) {
+                    this.getView().invokeOperation("submitandnew");
+                }
+            } else {
+                OperateOption option;
+                if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "KEY_DIFFPAY_CALLBACK")) {
+                    data = (Map)e.getReturnData();
+                    if (data != null) {
+                        option = OperateOption.create();
+                        Iterator var4 = data.entrySet().iterator();
+
+                        while(var4.hasNext()) {
+                            Map.Entry<String, Object> entry = (Map.Entry)var4.next();
+                            if (entry.getValue() != null) {
+                                option.setVariableValue((String)entry.getKey(), entry.getValue().toString());
+                            }
+                        }
+
+                        option.setVariableValue("payConfirm", "1");
+                        this.getView().invokeOperation("pay", option);
+                    }
+                } else if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "CALLBACK_SELECTDRAFT")) {
+                    Object draftIdList = e.getReturnData();
+                    if (draftIdList != null) {
+                        option = OperateOption.create();
+                        option.setVariableValue("draftids", JSON.toJSONString(draftIdList));
+                        this.getView().invokeOperation("pay", option);
+                    }
+                } else if (kd.bos.dataentity.utils.StringUtils.equals(e.getActionId(), "settletnumber")) {
+                    ListSelectedRowCollection rows = (ListSelectedRowCollection)e.getReturnData();
+                    if (EmptyUtil.isNoEmpty(rows)) {
+                        this.getModel().deleteEntryData("entry");
+                        CasBotpHelper.doDraw(this.getView(), "lc_arrival", this.getModel().getDataEntityType().getName(), rows);
+                    }
+                }
+            }
+        }
+
+        PaymentBillPluginHelper.isSchePayEditable(this, this.getModel());
+        DynamicObject org = this.getDynamicObject("org");
+        InitCheckPluginHelper.checkInitForPlugin(this.getView(), org, new String[]{"bar_save", "bar_submit"});
+    }
+
+    public void beforeItemClick(BeforeItemClickEvent evt) {
+        String opKey = evt.getOperationKey();
+        if ("delete".equals(opKey)) {
+            if ("cas_recbill".equals(this.getString("sourcebilltype"))) {
+                evt.setCancel(true);
+                String billno = this.getString("billno");
+                this.getView().showConfirm(String.format(ResManager.loadKDString("%s付款单由内部收付协同业务自动生成,是否确认删除?", "PaymentBillEdit_23", "fi-cas-formplugin", new Object[0]), billno), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_DEL_CALLBACK", this));
+            }
+        } else if ("pay".equals(opKey)) {
+            DynamicObject dataEntity = this.getModel().getDataEntity();
+            long orgDynId = dataEntity.getDynamicObject("org").getLong("id");
+            boolean selectDraftFlag = SystemParameterHelper.getParameterBoolean(orgDynId, "cs122");
+            String settleTypeKey = DraftHelper.getKey(dataEntity.get("settletype"));
+            logger.info("selectDraftFlag is:" + selectDraftFlag + ",key:" + settleTypeKey);
+            boolean isdraft = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "isdraft");
+            boolean ischeck = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "ischeck");
+            boolean ispromissorynote = SystemParameterHelper.getCdmParameterBoolean(orgDynId, "ispromissorynote");
+            if (!CasHelper.isEmpty(settleTypeKey)) {
+                String typeName;
+                switch (settleTypeKey) {
+                    case "isdraft":
+                        if (isdraft && !selectDraftFlag) {
+                            typeName = ResManager.loadKDString("汇票", "DraftHelper_4", "fi-cas-common", new Object[0]);
+                            this.cancelAndWarn(evt, dataEntity, typeName);
+                        }
+                        break;
+                    case "ischeck":
+                        if (ischeck && !selectDraftFlag) {
+                            typeName = ResManager.loadKDString("支票", "DraftHelper_5", "fi-cas-common", new Object[0]);
+                            this.cancelAndWarn(evt, dataEntity, typeName);
+                        }
+                        break;
+                    case "ispromissorynote":
+                        if (ispromissorynote && !selectDraftFlag) {
+                            typeName = ResManager.loadKDString("本票", "DraftHelper_6", "fi-cas-common", new Object[0]);
+                            this.cancelAndWarn(evt, dataEntity, typeName);
+                        }
+                }
+            }
+        }
+
+        if ("commitbe".equals(opKey)) {
+            OperateOption op = OperateOption.create();
+            op.setVariableValue("ishasright", "true");
+            OperationResult operationResult = OperationServiceHelper.executeOperate("beforecommitbe", "nckd_cas_arbill", new Object[]{this.getModel().getDataEntity().getPkValue()}, op);
+            if (!operationResult.isSuccess() && operationResult.isNeedSign()) {
+                SignOperateCallback signOperate = new SignOperateCallback(this.getView(), this, op, ClientCallback.SignClientType.Secondry, "signbeforecommitbe");
+                OperationResult ops = signOperate.sign(operationResult);
+                evt.setCancel(true);
+                if (!ops.isSuccess()) {
+                    logger.info(" beforecommitbe sign error ");
+                    if (ops.isShowMessage() && EmptyUtil.isNoEmpty(ops.getMessage())) {
+                        this.getView().showTipNotification(ops.getMessage());
+                    }
+                }
+            }
+        }
+
+    }
+
+    private void cancelAndWarn(BeforeItemClickEvent evt, DynamicObject dataEntity, String typeName) {
+        String msg = String.format(ResManager.loadKDString("%1$s :结算方式类别为%2$s的付款单不支持确认付款", "DraftHelper_7_1", "fi-cas-common", new Object[0]), dataEntity.getString("billno"), typeName);
+        evt.setCancel(true);
+        this.getView().showTipNotification(msg);
+    }
+
+    public void itemClick(ItemClickEvent evt) {
+        super.itemClick(evt);
+        String key = evt.getItemKey().toLowerCase();
+        if ("bar_beforesubmit".equals(key)) {
+            this.getView().invokeOperation("beforesubmit");
+        } else if ("bar_cancelpay".equals(key)) {
+            this.cancelPay();
+        } else if ("viewsettle".equals(key)) {
+            this.viewSettle();
+        } else if ("bar_save".equals(key)) {
+            this.getView().updateView("feeactbank");
+            this.getView().updateView("feecurrency");
+        }
+
+    }
+
+    public void afterDeleteRow(AfterDeleteRowEventArgs e) {
+        super.afterDeleteRow(e);
+        this.calculateAmt();
+    }
+
+    public void afterBindData(EventObject e) {
+        super.afterBindData(e);
+        DynamicObject org = this.getDynamicObject("org");
+        InitCheckPluginHelper.checkInitForPlugin(this.getView(), org, new String[]{"bar_save", "bar_submit"});
+        DynamicObject paymentBill = this.getModel().getDataEntity();
+        Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
+        Object showConer = customParams.get("showConer");
+        List<IApprovalRecordGroup> workflowlist = WorkflowServiceHelper.getAllApprovalRecord(paymentBill.getPkValue().toString());
+        if (CollectionUtils.isEmpty(workflowlist) || CasHelper.isEmpty(showConer)) {
+            SplitContainer control = (SplitContainer)this.getControl("splitcontainerap");
+            control.hidePanel(SplitDirection.right, true);
+            control.setCollapse("splitpanelap1", true);
+        }
+
+        Long orgId = this.getPk("org");
+        DynamicObject cur;
+        DynamicObject payeracctbank;
+        if (this.isBotpNew()) {
+            if (orgId == null) {
+                this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
+                this.getView().showErrorNotification(ResManager.loadKDString("请在上游单据维护付款组织来源再推付款单。", "PaymentBillEdit_7", "fi-cas-formplugin", new Object[0]));
+                return;
+            }
+
+            cur = OrgHelper.getBaseCurrency(orgId);
+            if (cur == null) {
+                this.getView().setEnable(false, new String[]{"bar_save", "bar_submit", "bar_beforesubmit"});
+                this.getView().setVisible(false, new String[]{"bar_refund_save", "bar_submitandnew", "bar_del", "bar_audit", "bar_unaudit", "bar_pay", "bar_cancelpay", "bar_commitbe", "genvoucher", "deletevoucher", "copyentryrow"});
+                this.getView().getFormShowParameter().setStatus(OperationStatus.VIEW);
+                this.getView().showErrorNotification(SystemStatusCtrolHelper.notFinishInitSetMsg(CasHelper.getLocalValue(this.getDynamicObject("org"), "name")));
+                return;
+            }
+
+            this.setValueIfAbsent("basecurrency", cur);
+            payeracctbank = this.getDynamicObject("payeracctbank");
+            if (payeracctbank != null) {
+                this.setValueIfAbsent("payerbank", payeracctbank.getDynamicObject("bank"));
+                this.setValueIfAbsent("openorg", payeracctbank.getDynamicObject("openorg"));
+            }
+
+            this.setNetBankAcctVisible();
+            DynamicObject paymentType = paymentBill.getDynamicObject("paymenttype");
+            if (paymentType != null) {
+                paymentType = BusinessDataServiceHelper.loadSingleFromCache(paymentType.getPkValue(), "cas_paymentbilltype", "id,fundflowitem");
+                this.fillFundflowItem(false, paymentType.getDynamicObject("fundflowitem"));
+            }
+        }
+
+        if (null == this.getDynamicObject("exratetable")) {
+            this.setDefaultExratetable(orgId);
+        }
+
+        PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView());
+        this.setPayerInfo4Lb();
+        this.changePayeeValue();
+        this.setEntryAmountCaption();
+        this.ctrChangeLableVisible();
+        this.setCurrencyEditable();
+        this.ctrBeInfoVisibility();
+        this.setExchangerateEditable();
+        this.ctrRefundInfoVisibility();
+        cur = this.getDynamicObject("payeracctbank");
+        this.setPaymentChannelValue(cur, Boolean.FALSE);
+        this.setDiffCurInfo();
+        this.setCountryValue();
+        this.setCrossPayValue();
+        this.isDiffCurVisibility();
+        this.isOnlinebankVisibility();
+        this.setPayerAndPayeeInfo(orgId);
+        this.getModel().setDataChanged(false);
+        payeracctbank = (DynamicObject)this.getModel().getValue("settletype");
+        if (Objects.nonNull(payeracctbank)) {
+            this.settletNumber(payeracctbank);
+        } else {
+            this.getView().setVisible(Boolean.FALSE, new String[]{"draftbill"});
+        }
+
+        this.showBalance();
+    }
+
+    private void setPayerAndPayeeInfo(Long orgId) {
+        if (!CasHelper.isEmpty(orgId)) {
+            DynamicObject org = BusinessDataServiceHelper.loadSingleFromCache(orgId, "bos_org");
+            this.getModel().setValue("payernumber", org.getString("number"));
+            this.getModel().setValue("uniformsocialcreditcode", org.getString("uniformsocialcreditcode"));
+            Long payeeId = Long.valueOf(this.getModel().getValue("payee").toString());
+            String type = this.getModel().getValue("payeetype").toString();
+            String number = this.getModel().getValue("payeenumber").toString();
+            if (!number.isEmpty() || !AsstActTypeEnum.SUPPLIER.getValue().equals(type) && !AsstActTypeEnum.CUSTOMER.getValue().equals(type)) {
+                if (number.isEmpty() && (AsstActTypeEnum.EMPLOYEE.getValue().equals(type) || AsstActTypeEnum.COMPANY.getValue().equals(type))) {
+                    number = this.getUserOrOrgNumber(payeeId, type);
+                }
+            } else {
+                number = this.getPayeeOrPayerInfoNumber(payeeId, type, this.getModel().getDataEntityType().getName());
+            }
+
+            this.getModel().setValue("payeenumber", number);
+            if (!this.getModel().getDataEntity().getString("billstatus").equals(BillStatusEnum.SAVE.getValue())) {
+                this.getView().setEnable(false, new String[]{"priority"});
+            }
+
+        }
+    }
+
+    protected void setExchangerateEditable() {
+        DynamicObject srcCurrency = this.getDynamicObject("currency");
+        DynamicObject destCurrency = this.getDynamicObject("basecurrency");
+        if (srcCurrency != null && destCurrency != null) {
+            if (srcCurrency.getLong("id") == destCurrency.getLong("id")) {
+                this.getView().setEnable(false, new String[]{"exchangerate"});
+            }
+
+        }
+    }
+
+    private void setDefaultExratetable(Long orgId) {
+        Long exchangeRateTableId = 0L;
+
+        try {
+            exchangeRateTableId = SystemStatusCtrolHelper.getExrateTable(orgId).getLong("id");
+        } catch (Exception var4) {
+        }
+
+        this.getModel().setValue("exratetable", exchangeRateTableId);
+    }
+
+    private void setEntryAmountCaption() {
+        DynamicObject billType = (DynamicObject)this.getModel().getValue("billtype");
+        if (billType != null) {
+            EntryGrid entryCtr = (EntryGrid)this.getControl("entry");
+            if (BillTypeConstants.PAYBILL_OTR.equals(billType.getPkValue())) {
+                entryCtr.setColumnProperty("e_payableamt", "header", new LocaleString(ResManager.loadKDString("实付金额", "PaymentBillEdit_8", "fi-cas-formplugin", new Object[0])));
+                entryCtr.setColumnProperty("e_payablelocamt", "header", new LocaleString(ResManager.loadKDString("实付折本币", "PaymentBillEdit_9", "fi-cas-formplugin", new Object[0])));
+            } else {
+                entryCtr.setColumnProperty("e_payableamt", "header", new LocaleString(ResManager.loadKDString("应付金额", "PaymentBillEdit_10", "fi-cas-formplugin", new Object[0])));
+                entryCtr.setColumnProperty("e_payablelocamt", "header", new LocaleString(ResManager.loadKDString("应付折本币", "PaymentBillEdit_11", "fi-cas-formplugin", new Object[0])));
+            }
+
+        }
+    }
+
+    private void ctrChangeLableVisible() {
+        Object sourceBillType = this.getModel().getValue("sourcebilltype");
+        if (!"cas_recbill".equals(sourceBillType) && !"bei_transdetail_cas".equals(sourceBillType) && BillStatusEnum.SAVE.getValue().equals(this.getModel().getValue("billstatus"))) {
+            if (!(Boolean)this.getModel().getValue("issupplecontract")) {
+                this.getView().setVisible(true, new String[]{"changepayer", "changepayee"});
+            }
+        } else {
+            this.getView().setVisible(false, new String[]{"changepayer", "changepayee"});
+        }
+
+    }
+
+    private boolean isBePay() {
+        DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank");
+        if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) {
+            return true;
+        } else {
+            return payerAcctBank != null && (Boolean)payerAcctBank.get("issetbankinterface") && "bei".equalsIgnoreCase(this.getString("paymentchannel"));
+        }
+    }
+
+    private boolean isBeiBePay() {
+        DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank");
+        return payerAcctBank != null && (Boolean)payerAcctBank.get("issetbankinterface") && "bei".equalsIgnoreCase(this.getString("paymentchannel"));
+    }
+
+    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
+        super.beforeDoOperation(args);
+        AbstractOperate op = (AbstractOperate)args.getSource();
+        String operateKey = op.getOperateKey();
+        DynamicObject payerAcctBank = this.getDynamicObject("payeracctbank");
+        DynamicObject accountBank;
+        if ("trackdown".equals(operateKey)) {
+            accountBank = this.getDynamicObject("settletype");
+            if (accountBank != null) {
+                String settlementtype = accountBank.getString("settlementtype");
+                if (EmptyUtil.isNoEmpty(settlementtype) && this.settleTypes.contains(settlementtype)) {
+                    op.getOption().setVariableValue("botp_track_edit_status", "true");
+                }
+            }
+        } else if ((!"save".equals(operateKey) || (Boolean)this.getModel().getValue("issupplecontract")) && !"submit".equals(operateKey) && !"submitandnew".equals(operateKey) && !"beforesubmit".equals(operateKey) && !"beforesubmitnew".equals(operateKey)) {
+            DynamicObject orgData;
+            if ("refundsave".equals(operateKey)) {
+                Long rebillid = (Long)this.getView().getFormShowParameter().getCustomParam("rebillid");
+                orgData = BusinessDataServiceHelper.loadSingle(rebillid, "cas_recbill");
+                BigDecimal actrecamt = orgData.getBigDecimal("actrecamt");
+                DynamicObjectCollection payEntrys = this.getModel().getEntryEntity("entry");
+                BigDecimal refundamtTotal = (BigDecimal)payEntrys.stream().map((o) -> {
+                    return o.getBigDecimal("e_refundamt");
+                }).reduce(BigDecimal.ZERO, BigDecimal::add);
+                if (actrecamt.compareTo(refundamtTotal) != 0) {
+                    throw new KDBizException(ResManager.loadKDString("退款金额合计与收款单金额不相等", "PaymentBillEdit_19", "fi-cas-formplugin", new Object[0]));
+                }
+
+                FormOperate operate = (FormOperate)args.getSource();
+                operate.getOption().setVariableValue("rebillid", SerializationUtils.toJsonString(this.getView().getFormShowParameter().getCustomParam("rebillid")));
+                operate.getOption().setVariableValue("billtype", "nckd_cas_arbill");
+            } else if ("recbook".equals(operateKey)) {
+                accountBank = this.getDynamicObject("payeracctbank");
+                if (null != accountBank && AccountBankHelper.isClosed(accountBank.getLong("id"))) {
+                    throw new KDBizException(String.format(ResManager.loadKDString("账户%s当前状态为已销户,暂无法进行业务处理。", "PaymentErrorCode_47", "fi-cas-business", new Object[0]), accountBank.getString("number")));
+                }
+
+                if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) {
+                    throw new KDBizException(ResManager.loadKDString("内部账户请选择内部结算付款。", "PaymentErrorCode_48", "fi-cas-business", new Object[0]));
+                }
+
+                if (PaymentBillPluginHelper.checkPayeeTypeFreeze(Collections.singletonList(this.getModel().getDataEntity()))) {
+                    throw new KDBizException((new PaymentErrorCode()).CANOTDOTHISOP_WHENSUPPLIERFREEZE().getMessage());
+                }
+            } else if ("endorse".equals(operateKey)) {
+                if (payerAcctBank != null && PayBillCrossHelper.isIfmBankAcc(payerAcctBank)) {
+                    throw new KDBizException(ResManager.loadKDString("内部账户请选择内部结算付款。", "PaymentErrorCode_48", "fi-cas-business", new Object[0]));
+                }
+
+                if (PaymentBillPluginHelper.checkPayeeTypeFreeze(Collections.singletonList(this.getModel().getDataEntity()))) {
+                    throw new KDBizException((new PaymentErrorCode()).CANOTDOTHISOP_WHENSUPPLIERFREEZE().getMessage());
+                }
+            } else if ("pay".equals(operateKey)) {
+                String draftIds = op.getOption().getVariableValue("draftids", "");
+                if (kd.bos.dataentity.utils.StringUtils.isEmpty(draftIds)) {
+                    orgData = (DynamicObject)this.getValue("org");
+                    Long pkValue = (Long)orgData.getPkValue();
+                    boolean selectDraftFlag = SystemParameterHelper.getParameterBoolean(pkValue, "cs122");
+                    DynamicObject data = this.getModel().getDataEntity(true);
+                    if (selectDraftFlag && PaymentBillPluginHelper.needSelectedDraft(data)) {
+                        FormShowParameter showParameter = new FormShowParameter();
+                        showParameter.setAppId("cas");
+                        showParameter.setFormId("cas_payment_selectdraft");
+                        showParameter.setCustomParam("payBillId", data.getPkValue());
+                        showParameter.getOpenStyle().setShowType(ShowType.Modal);
+                        showParameter.setCloseCallBack(new CloseCallBack(this, "CALLBACK_SELECTDRAFT"));
+                        this.getView().showForm(showParameter);
+                        args.setCancel(true);
+                    } else if (!DraftHelper.isAllPayDrafBill((DynamicObjectCollection)this.getModel().getValue("draftbill")) && !(Boolean)this.getModel().getValue("feepay")) {
+                        String payConfirm = op.getOption().getVariableValue("payConfirm", "");
+                        if (kd.bos.dataentity.utils.StringUtils.isEmpty(payConfirm)) {
+                            this.pay(args);
+                        }
+                    }
+                }
+            }
+        } else if (!this.isBeConfirmOK) {
+            this.storeFields();
+        }
+
+        if ("submit".equals(operateKey)) {
+            FormUtils.deleteEmptyRows(this.getModel(), new String[]{"e_payableamt"});
+        }
+
+        if (Arrays.asList("unaudit", "chargeback", "invalid", "delete", "pay").contains(operateKey) && PayBillHepler.getViewSettle(this.getModel().getDataEntity()).size() > 0) {
+            this.getView().showErrorNotification(String.format(ResManager.loadKDString("%s已存在结算记录,导致操作失败。如需继续执行操作,请先反结算。", "PaymentBillList_36", "fi-cas-formplugin", new Object[0]), ""));
+            args.setCancel(true);
+        }
+    }
+
+    public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
+        super.confirmCallBack(messageBoxClosedEvent);
+        String id = messageBoxClosedEvent.getCallBackId();
+        MessageBoxResult res = messageBoxClosedEvent.getResult();
+        if (id.equals("CONFIRM_CANCELPAY_CALLBACK") && MessageBoxResult.Yes.equals(res)) {
+            String billno = (String)this.getModel().getValue("billno");
+            DynamicObject payObj = BusinessDataServiceHelper.loadSingle("nckd_cas_arbill", "id,billno", new QFilter[]{new QFilter("billno", "=", billno)});
+            if (!this.cancelPayCheckSettle(payObj)) {
+                this.getView().invokeOperation("cancelpay");
+            }
+        }
+
+        if (id.equals("CONFIRM_CANCELPAY_SETTLE_CALLBACK") && MessageBoxResult.Yes.equals(res)) {
+            this.getView().invokeOperation("cancelpay");
+        }
+
+        if (id.equals("CONFIRM_DEL_CALLBACK")) {
+            OperateOption option = OperateOption.create();
+            if (MessageBoxResult.Yes.equals(res)) {
+                option.setVariableValue("delrecpay", "1");
+                this.getView().invokeOperation("delete", option);
+            }
+        }
+
+    }
+
+    private void storeFields() {
+        IBillModel model = (IBillModel)this.getModel();
+        String entrance = (String)model.getValue("entrance");
+        if (PaymentTypeEnum.OTR.name().equals(entrance)) {
+            DynamicObject paymentType = (DynamicObject)model.getValue("paymenttype");
+            if (paymentType != null && !paymentType.getBoolean("ispartpayment")) {
+                int count = model.getEntryRowCount("entry");
+
+                for(int i = 0; i < count; ++i) {
+                    this.setValue("e_discountamt", (Object)null, i);
+                    this.setValue("e_discountlocamt", (Object)null, i);
+                    this.setValue("e_corebilltype", (Object)null, i);
+                    this.setValue("e_corebillno", (Object)null, i);
+                    this.setValue("e_corebillentryseq", (Object)null, i);
+                    this.setValue("e_lockamt", (Object)null, i);
+                    this.setValue("e_unlockamt", (Object)null, i);
+                    this.setValue("e_settledamt", (Object)null, i);
+                    this.setValue("e_unsettledamt", (Object)null, i);
+                }
+            }
+        } else if (PaymentTypeEnum.SYN.name().equals(entrance) || PaymentTypeEnum.CASH.name().equals(entrance) || PaymentTypeEnum.SPAN.name().equals(entrance)) {
+            int count = model.getEntryRowCount("entry");
+            if (count < 1) {
+                this.getView().updateView("entry");
+                this.getView().invokeOperation("newentry");
+            }
+
+            this.setValue("e_payableamt", this.getBigDecimal("actpayamt"), 0);
+            this.setValue("e_fundflowitem", this.getValue("fundflowitem"), 0);
+        }
+
+    }
+
+    public void afterDoOperation(AfterDoOperationEventArgs arg) {
+        super.afterDoOperation(arg);
+        AbstractOperate op = (AbstractOperate)arg.getSource();
+        OperationResult operationResult = arg.getOperationResult();
+        String key = op.getOperateKey();
+        if ("copyentryrow".equals(key)) {
+            EntryGrid entry = (EntryGrid)this.getControl("entry");
+            if (entry.getSelectRows().length == 0) {
+                this.getView().showTipNotification(ResManager.loadKDString("请选中一行再进行操作", "PaymentBillEdit_12", "fi-cas-formplugin", new Object[0]));
+                return;
+            }
+
+            this.calculateAmt();
+        } else if (!"beforesubmit".equals(key) && !"beforesubmitnew".equals(key)) {
+            if ("newentry".equals(key)) {
+                this.settleOrg(false);
+            } else {
+                IFormView view;
+                if ("refundsave".equals(key) && arg.getOperationResult().isSuccess()) {
+                    view = this.getView().getParentView();
+                    view.close();
+                    this.getView().sendFormAction(view);
+                    return;
+                }
+
+                if ("delete".equals(key) && arg.getOperationResult().isSuccess()) {
+                    view = this.getView();
+                    view.close();
+                    this.getView().sendFormAction(view);
+                } else if (("unsubmit".equals(key) || "unaudit".equals(key)) && arg.getOperationResult().isSuccess()) {
+                    this.getView().setStatus(OperationStatus.EDIT);
+                } else {
+                    String reason;
+                    if (!"pay".equals(key) && !"cancelpay".equals(key)) {
+                        if ("receipt".equals(key) && arg.getOperationResult().isSuccess()) {
+                            this.viewReceipt();
+                        } else if ("chargebacknoreason".equals(key)) {
+                            reason = ResManager.loadKDString("自动退单", "PaymentBillList_37", "fi-cas-formplugin", new Object[0]);
+                            List<Object> successPkIds = operationResult.getSuccessPkIds();
+                            Map<String, Object> data = new HashMap(16);
+                            data.put("billid", successPkIds);
+                            data.put("reason", reason);
+                            data.put("operateKey", "chargeback");
+                            PayBillListPlugnHelper.closeCallBack("CALLBACK_CHARGEBACK", this.getView(), data);
+                        }
+                    } else {
+                        reason = arg.getOperationResult().getMessage();
+                        if (!arg.getOperationResult().isSuccess() && !(new CasErrorCode()).VOUCHER_NOT_CHECK().getMessage().equals(reason)) {
+                            this.getModel().setValue("billstatus", "pay".equals(key) ? BillStatusEnum.AUDIT.getValue() : BillStatusEnum.PAY.getValue());
+                        }
+
+                        if ("pay".equals(key) && (Boolean)this.getValue("isdiffcur")) {
+                            this.getView().updateView("dpamt");
+                            this.getView().updateView("agreedrate");
+                            this.getView().updateView("dplocalamt");
+                            this.getView().updateView("lossamt");
+                            this.getView().updateView("billstatus");
+                            this.getView().updateView("exchangerate");
+                            this.getView().updateView("dpexchangerate");
+                            this.getView().updateView("localamt");
+                            this.getView().updateView("paydate");
+                            this.getView().updateView("feeactbank");
+                            this.getView().updateView("feecurrency");
+                            this.getView().updateView("singlestream");
+                            this.getView().updateView("fee");
+
+                            for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) {
+                                this.getView().updateView("e_payablelocamt", i);
+                                this.getView().updateView("e_discountlocamt", i);
+                                this.getView().updateView("e_localamt", i);
+                            }
+                        }
+
+                        this.getView().updateView("draftbill");
+                        if (arg.getOperationResult().isSuccess()) {
+                            this.getView().invokeOperation("refresh", OperateOption.create());
+                        }
+                    }
+                }
+            }
+        } else if ("beforesubmit".equals(key)) {
+            IDataModel model = this.getModel();
+            if (!CasHelper.isEmpty(model.getValue("entrustorg"))) {
+                model.setValue("payeracctbank", (Object)null);
+                model.setValue("payerbank", (Object)null);
+                ((Label)this.getControl("payerbanknumv")).setText("");
+                ((Label)this.getControl("payerbanknamev")).setText("");
+                model.setValue("settletype", (Object)null);
+            }
+
+            if (arg.getOperationResult().isSuccess()) {
+                DynamicObject company = (DynamicObject)model.getValue("org");
+                boolean isNotCheckBeBankNumb = SystemParameterHelper.getParameterBoolean(company.getLong("id"), "cs125");
+                if (this.isBeiBePay() && CasHelper.isEmpty(this.getString("recbanknumber")) && !isNotCheckBeBankNumb && this.isCrossTranType()) {
+                    this.getView().showTipNotification(ResManager.loadKDString(String.format("单号%s的付款单支付渠道为银企互联,收款行行号不能为空,请补充。", this.getModel().getValue("billno")), "PaymentBillEdit_29", "fi-cas-formplugin", new Object[0]));
+                    return;
+                }
+
+                List<Object> pks = arg.getOperationResult().getSuccessPkIds();
+                if (!EmptyUtil.isEmpty(pks)) {
+                    this.getView().invokeOperation("submit");
+                }
+            }
+        }
+
+        if (Arrays.asList("save", "submit").contains(key) && arg.getOperationResult().isSuccess()) {
+            this.getView().updateView("entrustorg");
+            this.getView().updateView("totalpayamt");
+
+            for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) {
+                this.getView().updateView("e_lockAmt", i);
+                this.getView().updateView("e_unlockAmt", i);
+            }
+        }
+
+        if ("unaudit".equals(key)) {
+            this.getView().invokeOperation("refresh", OperateOption.create());
+        }
+
+        PaymentBillPluginHelper.fillToolBar(this, this.getModel(), this.getView());
+        this.ctrChangeLableVisible();
+        PaymentBillPluginHelper.isSchePayEditable(this, this.getModel());
+    }
+
+    private boolean isCrossTranType() {
+        boolean type = (Boolean)this.getValue("iscrosspay");
+        DynamicObject dentify = (DynamicObject)this.getValue("paymentidentify");
+        return !type || null == dentify || !"0".equals(dentify.getString("type"));
+    }
+
+    public void beforeClosed(BeforeClosedEvent e) {
+        super.beforeClosed(e);
+
+        try {
+            BillShowParameter billShowParameter = (BillShowParameter)this.getView().getFormShowParameter();
+            String billStatus = (String)this.getModel().getValue("billstatus");
+            if (!BillStatusEnum.SAVE.getValue().equals(billStatus) || billShowParameter.getStatus() == OperationStatus.VIEW) {
+                e.setCheckDataChange(false);
+            }
+        } catch (Exception var4) {
+        }
+
+    }
+
+    private void cancelPay() {
+        String billno = (String)this.getModel().getValue("billno");
+        DynamicObject payObj = BusinessDataServiceHelper.loadSingle("nckd_cas_arbill", "id,billno,isvoucher,billstatus,org", new QFilter[]{new QFilter("billno", "=", billno)});
+        String billstatus = payObj.getString("billstatus");
+        if (!billstatus.equals("D")) {
+            this.getView().invokeOperation("cancelpay");
+        } else {
+            Object org = this.getModel().getValue("org");
+            if (org != null) {
+                int CS116 = SystemParameterHelper.getParameterInteger(((DynamicObject)org).getLong("id"), "cs116");
+                Boolean isv = payObj.getBoolean("isvoucher");
+                if (3 == CS116 && isv) {
+                    this.getView().showConfirm(String.format(ResManager.loadKDString("(%s)单据已经生成凭证,是否继续取消付款?", "PaymentBillEdit_15", "fi-cas-formplugin", new Object[0]), billno), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_CANCELPAY_CALLBACK", this));
+                } else if (!this.cancelPayCheckSettle(payObj)) {
+                    this.getView().invokeOperation("cancelpay");
+                }
+
+            }
+        }
+    }
+
+    protected String recPayAccount() {
+        return "payeracctbank";
+    }
+
+    private void settleOrg(boolean isOrg) {
+        if (!this.isLockSettleOrg()) {
+            DynamicObject paymenttype = (DynamicObject)this.getModel().getValue("paymenttype");
+            if (null != paymenttype && paymenttype.getBoolean("ispartpayment")) {
+                Object openOrg = this.getModel().getValue("openorg");
+                if (openOrg != null) {
+                    DynamicObject accountOrg = (DynamicObject)openOrg;
+
+                    for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) {
+                        if (isOrg || CasHelper.isEmpty(this.getModel().getValue("settleorg", i))) {
+                            this.setValue("settleorg", accountOrg.getPkValue(), i);
+                        }
+                    }
+                }
+            }
+
+        }
+    }
+
+    private boolean isHwControl() {
+        return this.getPageCache().getAll().containsKey("isHwControl");
+    }
+
+    private void setRecInfo(String key, Object value, Boolean isCheckDiff) {
+        if (isCheckDiff) {
+            Boolean isDiffCur = (Boolean)this.getModel().getValue("isdiffcur");
+            if (!isDiffCur) {
+                this.getModel().setValue(key, value);
+            }
+        } else {
+            this.getModel().setValue(key, value);
+        }
+
+    }
+
+    private void setDiffCurInfo() {
+        Boolean isDiffCur = (Boolean)this.getModel().getValue("isdiffcur");
+        if (!isDiffCur) {
+            this.setValueIfAbsent("dpcurrency", this.getModel().getValue("currency"));
+            this.setValueIfAbsent("dpamt", this.getModel().getValue("actpayamt"));
+            if (!FeePayerEnum.REC.getValue().equals(this.getString("feepayer"))) {
+                this.setValueIfAbsent("feeactbank", this.getModel().getValue("payeracctbank"));
+                this.setValueIfAbsent("feecurrency", this.getModel().getValue("currency"));
+            }
+
+        }
+    }
+
+    private void setExratetableVisibility() {
+        Long currencyId = this.getPk("currency");
+        Long dpCurrencyId = this.getPk("dpcurrency");
+        Long basecurrencyId = this.getPk("basecurrency");
+        if ((currencyId == null || currencyId.equals(basecurrencyId)) && (dpCurrencyId == null || dpCurrencyId.equals(basecurrencyId))) {
+            this.getView().setVisible(false, new String[]{"exratetable"});
+            this.getView().setVisible(false, new String[]{"exratedate"});
+        } else {
+            this.getView().setVisible(true, new String[]{"exratetable"});
+            this.getView().setVisible(true, new String[]{"exratedate"});
+        }
+
+    }
+
+    private void setSettleTypeValue(DynamicObject payerAcctBank) {
+        if (payerAcctBank != null) {
+            DynamicObjectCollection settlementypes = payerAcctBank.getDynamicObjectCollection("settlementtype");
+            if (settlementypes != null && settlementypes.size() > 0) {
+                Set<Long> idSet = new HashSet();
+                Iterator var4 = settlementypes.iterator();
+
+                DynamicObject settletype;
+                while(var4.hasNext()) {
+                    settletype = (DynamicObject)var4.next();
+                    idSet.add(((DynamicObject)settletype.get("fbasedataid")).getLong("id"));
+                }
+
+                DynamicObject settleType = this.getDynamicObject("settletype");
+                if (idSet.size() == 1) {
+                    settletype = BusinessDataServiceHelper.loadSingleFromCache(idSet.iterator().next(), "bd_settlementtype", "id,settlementtype");
+                    if (!BaseDataHelper.isSettleTypeCash(settletype)) {
+                        this.setValue("settletype", idSet.iterator().next());
+                    }
+                } else if (settleType != null && !idSet.contains((Long)settleType.getPkValue())) {
+                    this.setValue("settletype", (Object)null);
+                }
+            }
+        }
+
+    }
+
+    private void setCrossPayValue() {
+        this.getView().setEnable(true, new String[]{"iscrosspay"});
+        DynamicObject payCountry = this.getDynamicObject("paycountry");
+        DynamicObject recCountry = this.getDynamicObject("reccountry");
+        if ((payCountry == null || CountryHelper.isChina(payCountry)) && (recCountry == null || CountryHelper.isChina(recCountry))) {
+            this.setValue("iscrosspay", Boolean.FALSE);
+        } else {
+            this.setValue("iscrosspay", Boolean.TRUE);
+        }
+
+    }
+
+    private void isDiffCurVisibility() {
+        DynamicObject settleType = this.getDynamicObject("settletype");
+        if (CasHelper.isNotEmpty(settleType) && BaseDataHelper.isSettleTypeCash(settleType)) {
+            this.setValue("isdiffcur", "0");
+            this.getView().setVisible(false, new String[]{"isdiffcur"});
+        } else {
+            this.getView().setVisible(true, new String[]{"isdiffcur"});
+        }
+
+    }
+
+    private void setCountryValue() {
+        DynamicObject payerBank = this.getDynamicObject("payerbank");
+        if (payerBank != null) {
+            this.setValueIfAbsent("paycountry", payerBank.getDynamicObject("country"));
+            this.setCrossPayValue();
+        }
+
+    }
+
+    private void pay(BeforeDoOperationEventArgs evt) {
+        long orgId = (Long)this.getDynamicObject("org").getPkValue();
+        Set<String> cs1046 = SystemParameterHelper.getParameterComboxs(orgId, "cs1046");
+        DynamicObject payBill = this.getModel().getDataEntity();
+        (new PaymentPayImpl()).validate(payBill);
+        if (PaymentBillPluginHelper.isShowPayConfirm(payBill, cs1046)) {
+            FormShowParameter para = new FormShowParameter();
+            para.setFormId("cas_paybill_diffpay");
+            para.setCloseCallBack(new CloseCallBack(this, "KEY_DIFFPAY_CALLBACK"));
+            para.getOpenStyle().setShowType(ShowType.Modal);
+            DataEntityPropertyCollection properties = EntityMetadataCache.getDataEntityType("cas_paybill_diffpay").getProperties();
+            Map<String, Object> customParams = new HashMap(properties.size());
+            Iterator var9 = properties.iterator();
+
+            while(var9.hasNext()) {
+                IDataEntityProperty property = (IDataEntityProperty)var9.next();
+                String propName = property.getName();
+                if (this.getModel().getProperty(propName) != null) {
+                    Object value = this.getValue(propName);
+                    if (value instanceof DynamicObject) {
+                        customParams.put(propName, ((DynamicObject)value).getPkValue());
+                    } else {
+                        customParams.put(propName, value);
+                    }
+                }
+            }
+
+            para.setCustomParams(customParams);
+            para.setCustomParam("payamount", payBill.getBigDecimal("actpayamt"));
+            para.setCustomParam("payamt", payBill.getBigDecimal("dpamt"));
+            para.setCustomParam("matchFlag", payBill.getString("matchflag"));
+            para.setCustomParam("sourcebilltype", payBill.getString("sourcebilltype"));
+            para.setCustomParam("payBillId", payBill.getString("id"));
+            this.getView().showForm(para);
+            evt.setCancel(true);
+        }
+
+    }
+
+    private void setPaymentType(QFilter[] qFilters) {
+        DynamicObject paymentType = BusinessDataServiceHelper.loadSingleFromCache("cas_paymentbilltype", "id,fundflowitem", qFilters);
+        if (paymentType != null) {
+            this.setValue("paymenttype", paymentType.getLong("id"));
+            DynamicObject fundflowitem = paymentType.getDynamicObject("fundflowitem");
+            this.fillFundflowItem(true, fundflowitem);
+        } else {
+            this.setValue("paymenttype", (Object)null);
+        }
+
+    }
+
+    private void viewReceipt() {
+        Long billId = (Long)this.getModel().getDataEntity().getPkValue();
+        if (billId == 0L) {
+            this.getView().showTipNotification(ResManager.loadKDString("暂无对应的电子回单记录!", "ViewReceiptService_0", "fi-cas-business", new Object[0]));
+        } else {
+            ViewReceiptService viewService = new ViewReceiptService();
+            viewService.viewReceipt(this.getView(), "nckd_cas_arbill", billId);
+        }
+    }
+
+    private void viewSettle() {
+        Long billId = (Long)this.getModel().getDataEntity().getPkValue();
+        if (billId == 0L) {
+            this.getView().showTipNotification(ResManager.loadKDString("暂无结算记录。", "PaymentBillList_5", "fi-cas-formplugin", new Object[0]));
+        } else {
+            List<Long> mainSettleIds = SettleRecordQueryHelperForCas.getSettleIdsByMain("ap_settlerecord", "nckd_cas_arbill", new Object[]{billId});
+            List<Long> asstSettleIds = SettleRecordQueryHelperForCas.getSettleIdsByAsst("ap_settlerecord", "nckd_cas_arbill", new Object[]{billId});
+            Set<Long> settleRecordIds = new HashSet();
+            settleRecordIds.addAll(mainSettleIds);
+            settleRecordIds.addAll(asstSettleIds);
+            if (settleRecordIds.size() > 0) {
+                ListShowParameter parameter = new ListShowParameter();
+                parameter.setBillFormId("ap_settlerecord");
+                parameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
+                ListFilterParameter param = new ListFilterParameter();
+                param.setFilter(new QFilter("id", "in", settleRecordIds));
+                parameter.setListFilterParameter(param);
+                parameter.setCustomParam("checkKey", true);
+                this.getView().showForm(parameter);
+            } else {
+                this.getView().showTipNotification(ResManager.loadKDString("暂无结算记录。", "PaymentBillList_5", "fi-cas-formplugin", new Object[0]));
+            }
+
+        }
+    }
+
+    public void afterAddRow(AfterAddRowEventArgs e) {
+        super.afterAddRow(e);
+        EntryProp entryProp = e.getEntryProp();
+        String entryName = entryProp.getName();
+        if ("entry".equals(entryName)) {
+            RowDataEntity[] rows = e.getRowDataEntities();
+            if (rows.length > 0) {
+                RowDataEntity[] var5 = rows;
+                int var6 = rows.length;
+
+                for(int var7 = 0; var7 < var6; ++var7) {
+                    RowDataEntity row = var5[var7];
+                    this.getModel().setValue("e_sourcebillid", this.getValue("sourcebillid"), row.getRowIndex());
+                    this.getModel().setValue("e_sourcebillentryid", this.getValue("sourceentryid"), row.getRowIndex());
+                }
+            }
+        }
+
+    }
+
+    private void isOnlinebankVisibility() {
+        String paymentchannel = (String)this.getValue("paymentchannel");
+        if (paymentchannel != null && this.isAcctBankExistOnlineBankAcct()) {
+            this.getView().setVisible(true, new String[]{"netbankacct"});
+        } else {
+            this.getView().setVisible(false, new String[]{"netbankacct"});
+        }
+
+    }
+
+    private Boolean cancelPayCheckSettle(DynamicObject payObj) {
+        Boolean result = Boolean.FALSE;
+        boolean exists = SettleRecordQueryHelperForCas.isExistsSettlesByMain("ap_settlerecord", "nckd_cas_arbill", new Object[]{payObj.getPkValue()}, (QFilter)null);
+        boolean exists2 = SettleRecordQueryHelperForCas.isExistsSettlesByAsst("ap_settlerecord", "nckd_cas_arbill", new Object[]{payObj.getPkValue()}, (QFilter)null);
+        if (exists || exists2) {
+            StringBuilder settleSb = new StringBuilder();
+            String billno = payObj.getString("billno");
+            settleSb.append(String.format(ResManager.loadKDString("(%s)单据已经完成结算", "PaymentBillList_28", "fi-cas-formplugin", new Object[0]), billno));
+            this.getView().showConfirm(settleSb.append(ResManager.loadKDString(",如果继续操作将会自动反结算对应的结算记录,是否继续?", "PaymentBillList_29", "fi-cas-formplugin", new Object[0])).toString(), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_CANCELPAY_SETTLE_CALLBACK", this));
+            result = Boolean.TRUE;
+        }
+
+        return result;
+    }
+
+    public String getPayeeOrPayerInfoNumber(Object payeeOrPayer, Object payeeOrPayerType, String billName) {
+        String payeenumber = "";
+        String entityNameTemp = "";
+        String addressPropName = "";
+        if (isSupplier(payeeOrPayerType)) {
+            entityNameTemp = AsstActTypeEnum.SUPPLIER.getValue();
+            addressPropName = "supplieraddress";
+        }
+
+        if (isCustomer(payeeOrPayerType)) {
+            entityNameTemp = AsstActTypeEnum.CUSTOMER.getValue();
+            addressPropName = "customeraddress";
+        }
+
+        if (!CasHelper.isEmpty(entityNameTemp) && !CasHelper.isEmpty(payeeOrPayer)) {
+            DynamicObject supplierCustDO = BusinessDataServiceHelper.loadSingleFromCache(payeeOrPayer, entityNameTemp, "number,entry_bank.isdefault_bank,entry_bank.bankaccount,entry_bank.bank,entry_bank.accountname,entry_address." + addressPropName);
+            if (!CasHelper.isEmpty(supplierCustDO)) {
+                payeenumber = supplierCustDO.getString("number");
+            }
+        }
+
+        return payeenumber;
+    }
+
+    public String getUserOrOrgNumber(Object id, Object type) {
+        String entityNameTemp = "";
+        String payeenumber = "";
+        if (isUser(type)) {
+            entityNameTemp = AsstActTypeEnum.EMPLOYEE.getValue();
+        }
+
+        if (isOrg(type)) {
+            entityNameTemp = AsstActTypeEnum.COMPANY.getValue();
+        }
+
+        if (!CasHelper.isEmpty(entityNameTemp) && !CasHelper.isEmpty(id)) {
+            DynamicObject userOrgDO = BusinessDataServiceHelper.loadSingleFromCache(id, entityNameTemp, "number");
+            if (!CasHelper.isEmpty(userOrgDO)) {
+                payeenumber = userOrgDO.getString("number");
+            }
+        }
+
+        return payeenumber;
+    }
+
+    private void fillFundflowItem(boolean isCover, DynamicObject defaultFundsItem) {
+        if (defaultFundsItem != null) {
+            for(int i = 0; i < this.getModel().getEntryRowCount("entry"); ++i) {
+                if (isCover) {
+                    this.setValue("e_fundflowitem", defaultFundsItem.getPkValue(), i);
+                } else {
+                    this.setValueIfAbsent("e_fundflowitem", defaultFundsItem.getPkValue(), i);
+                }
+            }
+
+        }
+    }
+
+    private static boolean isSupplier(Object payeeType) {
+        return isAimType(AsstActTypeEnum.SUPPLIER, payeeType);
+    }
+
+    private static boolean isCustomer(Object payeeType) {
+        return isAimType(AsstActTypeEnum.CUSTOMER, payeeType);
+    }
+
+    private static boolean isUser(Object payeeType) {
+        return isAimType(AsstActTypeEnum.EMPLOYEE, payeeType);
+    }
+
+    private static boolean isOrg(Object payeeType) {
+        return isAimType(AsstActTypeEnum.COMPANY, payeeType);
+    }
+
+    private static boolean isOther(Object payeeType) {
+        return isAimType(AsstActTypeEnum.OTHER, payeeType);
+    }
+
+    private static boolean isAimType(AsstActTypeEnum asstactType, Object payeeType) {
+        return asstactType.getValue().equals(payeeType);
+    }
+
+    private boolean isLockSettleOrg() {
+        String sourceBillType = this.getString("sourcebilltype");
+        return "ap_finapbill".equals(sourceBillType) || "ar_finarbill".equals(sourceBillType) || "ap_payapply".equals(sourceBillType) || "pm_purorderbill".equals(sourceBillType);
+    }
+
+    private boolean isClearFeeSettleType() {
+        DynamicObject settleType = (DynamicObject)this.getModel().getValue("settletype");
+        if (settleType == null) {
+            return true;
+        } else {
+            String settlementType = settleType.getString("settlementtype");
+            return Objects.equals(settlementType, SettleMentTypeEnum.BANK.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.BUSINESS.getValue()) || Objects.equals(settlementType, SettleMentTypeEnum.CHECK.getValue());
+        }
+    }
+
+    private boolean hasPayeeInfo() {
+        String payeeformid = this.getString("payeetype");
+        Long payeeId = Long.parseLong(this.getValue("payee") == null ? "0" : this.getValue("payee").toString());
+        String payeeType = this.getString("payeetype");
+        if (isOther(payeeType)) {
+            return kd.bos.dataentity.utils.StringUtils.isNotBlank(this.getValue("payeename"));
+        } else {
+            return CasHelper.isNotEmpty(payeeformid) && CasHelper.isNotEmpty(payeeId);
+        }
+    }
+
+    public void signCallback(SignCallbackEvent evt) {
+        if (evt.getCallbackId().equals("signbeforecommitbe")) {
+            ClientMethodResult ret = evt.getResult();
+            if (ret.getSuccess()) {
+                OperateOption operateOption = OperateOption.create();
+                operateOption.setVariableValue("ishasright", "true");
+                operateOption.setVariableValue("signCallbackFlag", "true");
+                operateOption.setVariableValue("signFirstSave", "false");
+                operateOption.setVariableValue("signResult", SerializationUtils.toJsonString(evt.getResult().getResult()));
+                operateOption.setVariableValue("clearResult", evt.getClearText());
+                OperationResult operationResult = this.getView().invokeOperation("beforecommitbe", operateOption);
+                if (operationResult.isSuccess()) {
+                    this.getView().invokeOperation("commitbe");
+                } else {
+                    logger.info(" signcallback fail ");
+                    if (EmptyUtil.isNoEmpty(operationResult.getMessage())) {
+                        evt.getView().showTipNotification(operationResult.getMessage());
+                    }
+                }
+            } else {
+                logger.info(" signbeforecommitbe SignCallbackEvent fail ");
+            }
+        }
+
+    }
+}

+ 1296 - 0
src/main/java/fi/cas/formplugin/ArBillListPlugin.java

@@ -0,0 +1,1296 @@
+package fi.cas.formplugin;
+
+import com.alibaba.fastjson.JSON;
+import kd.bos.bill.BillOperationStatus;
+import kd.bos.bill.BillShowParameter;
+import kd.bos.bill.OperationStatus;
+import kd.bos.dataentity.OperateOption;
+import kd.bos.dataentity.RefObject;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.dataentity.serialization.SerializationUtils;
+import kd.bos.dataentity.utils.StringUtils;
+import kd.bos.entity.EntityMetadataCache;
+import kd.bos.entity.datamodel.ListSelectedRow;
+import kd.bos.entity.datamodel.ListSelectedRowCollection;
+import kd.bos.entity.operate.IEntityOperate;
+import kd.bos.entity.operate.result.OperationResult;
+import kd.bos.exception.KDBizException;
+import kd.bos.filter.FilterColumn;
+import kd.bos.form.*;
+import kd.bos.form.control.events.BeforeItemClickEvent;
+import kd.bos.form.control.events.ItemClickEvent;
+import kd.bos.form.events.*;
+import kd.bos.form.operate.AbstractOperate;
+import kd.bos.form.operate.FormOperate;
+import kd.bos.form.operate.SignOperateCallback;
+import kd.bos.list.BillList;
+import kd.bos.list.ListShowParameter;
+import kd.bos.list.events.BeforeShowBillFormEvent;
+import kd.bos.logging.Log;
+import kd.bos.logging.LogFactory;
+import kd.bos.mvc.list.ListView;
+import kd.bos.orm.query.QFilter;
+import kd.bos.orm.util.CollectionUtils;
+import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.bos.servicehelper.DispatchServiceHelper;
+import kd.bos.servicehelper.QueryServiceHelper;
+import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
+import kd.bos.servicehelper.operation.OperationServiceHelper;
+import kd.bos.servicehelper.operation.SaveServiceHelper;
+import kd.fi.cas.business.errorcode.PaymentErrorCode;
+import kd.fi.cas.business.helper.PayBillHepler;
+import kd.fi.cas.business.opservice.impl.PaymentPayImpl;
+import kd.fi.cas.consts.BillTypeConstants;
+import kd.fi.cas.enums.*;
+import kd.fi.cas.formplugin.common.AbstractCasBillListPlugin;
+import kd.fi.cas.formplugin.helper.InitCheckPluginHelper;
+import kd.fi.cas.helper.*;
+import kd.fi.cas.util.EmptyUtil;
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class ArBillListPlugin extends AbstractCasBillListPlugin implements SignCallbackLisenter {
+    private static final String KEY_CHANGECHG_CALLBACK = "KEY_CHANGECHG_CALLBACK";
+    private static final String BAR_VIEWDIAGRAM = "barviewdiagram";
+    private static final String KEY_CALLBACK_CHARGEBACK = "CALLBACK_CHARGEBACK";
+    private static final String KEY_CANCELLATION = "cancellation";
+    private static final String CONFIRM_DEL_CALLBACK = "CONFIRM_DEL_CALLBACK";
+    private static final String KEY_DIFFPAY_CALLBACK = "KEY_DIFFPAY_CALLBACK";
+    private static final String KEY_CLOSECALLBACK_CHARGEBACK = "CALLBACK_SELECTDRAFT";
+    private static final String BAR_BATCH_INPUT = "batchinput";
+    private FilterContainerInitArgs initArgs;
+    private static Log logger = LogFactory.getLog(kd.fi.cas.formplugin.PaymentBillList.class);
+    private List<String> settleTypes;
+
+    public ArBillListPlugin() {
+        this.settleTypes = Arrays.asList(SettleMentTypeEnum.PROMISSORY.getValue(), SettleMentTypeEnum.CHECK.getValue(), SettleMentTypeEnum.DRAFT.getValue(), SettleMentTypeEnum.BUSINESS.getValue(), SettleMentTypeEnum.BANK.getValue());
+    }
+
+    public boolean isFromControlCenter() {
+        FormShowParameter formShowParameter = this.getView().getFormShowParameter();
+        Object isUnTreated = formShowParameter.getCustomParam("isUnTreated");
+        return EmptyUtil.isEmpty(isUnTreated) ? false : (Boolean)isUnTreated;
+    }
+
+    public boolean isTrack() {
+        FormShowParameter formShowParameter = this.getView().getFormShowParameter();
+        Object isTrack = formShowParameter.getCustomParam("isTrack");
+        return EmptyUtil.isEmpty(isTrack) ? false : (Boolean)isTrack;
+    }
+
+    public void setFilter(SetFilterEvent e) {
+        super.setFilter(e);
+        ListShowParameter listShowParameter = (ListShowParameter)this.getView().getFormShowParameter();
+        String parentFormId = listShowParameter.getParentFormId();
+        Object isFromTrack = listShowParameter.getCustomParams().getOrDefault("isFromTrack", (Object)null);
+        PaymentQueryHelper.enhanceNumFilterToIdFilter(e.getQFilters());
+        logger.info("付款单-调度中心 parentFormId :" + parentFormId + "; === " + this.isFromControlCenter());
+        if (this.isFromControlCenter() && "fca_control_index".equals(parentFormId)) {
+            if (e.getMainOrgQFilter() != null) {
+                e.getMainOrgQFilter().clearNests();
+            }
+
+            Object authOrgIds = listShowParameter.getCustomParam("authOrgIds");
+            Long p = 0L;
+            if (authOrgIds instanceof Integer) {
+                p = ((Integer)authOrgIds).longValue();
+            } else if (authOrgIds instanceof Long) {
+                p = (Long)authOrgIds;
+            } else if (authOrgIds instanceof String) {
+                p = Long.valueOf(authOrgIds.toString());
+            }
+
+            e.getQFilters().add(PayBillListPlugnHelper.getFcaFilter((String)listShowParameter.getCustomParam("status"), p));
+        } else if (("cas_apphome_grid".equals(parentFormId) || "fca_apphome".equals(parentFormId) || "fs_apphome".equals(parentFormId)) && (null == isFromTrack || isFromTrack.toString().trim().equals(""))) {
+            e.getQFilters().add(PayBillListPlugnHelper.getListFilter(listShowParameter.getBillFormId(), (String)listShowParameter.getCustomParam("appid")));
+        }
+
+    }
+
+    public void afterBindData(EventObject e) {
+        super.afterBindData(e);
+        if (this.isFromControlCenter()) {
+            String status = (String)this.getView().getFormShowParameter().getCustomParam("status");
+            if (BillStatusEnum.SAVE.getValue().equals(status)) {
+                this.getView().setVisible(false, new String[]{"tblnew", "tblcheck", "tblcopy", "tblpay", "barinfochg", "baritemap2", "tblprint"});
+            } else if (BillStatusEnum.SUBMIT.getValue().equals(status)) {
+                this.getView().setVisible(false, new String[]{"tblnew", "tblsubmit", "tblcopy", "tblpay", "barinfochg", "baritemap2", "tblprint"});
+            } else {
+                this.getView().setVisible(false, new String[]{"tblnew", "tblsubmit", "tblcopy", "tblcheck", "barinfochg", "baritemap2", "tblprint"});
+            }
+        }
+
+    }
+
+    public void beforeItemClick(BeforeItemClickEvent evt) {
+        String opKey = evt.getOperationKey();
+        BillList billList = (BillList)this.getControl("billlistap");
+        ListSelectedRowCollection selectRows = billList.getSelectedRows();
+        Set selectRowsPks;
+        QFilter[] delFilters;
+        DynamicObject[] paybills;
+        if ("delete".equals(opKey) && selectRows.size() > 0) {
+//            selectRowsPks = (Set)selectRows.parallelStream().map((row) -> {
+//                return row.getPrimaryKeyValue();
+//            }).collect(Collectors.toSet());
+//            delFilters = new QFilter[]{new QFilter("id", "in", selectRowsPks), new QFilter("hotaccount", "!=", "2"), new QFilter("sourcebilltype", "=", "cas_recbill")};
+//            paybills = BusinessDataServiceHelper.load("nckd_cas_arbill", "billno", delFilters);
+//            if (EmptyUtil.isNoEmpty(paybills)) {
+//                evt.setCancel(true);
+//                String billnoStr = (String)((Stream)Arrays.stream(paybills).parallel()).map((d) -> {
+//                    return d.getString("billno");
+//                }).collect(Collectors.joining("、"));
+//                this.getView().showConfirm(String.format(ResManager.loadKDString("%s付款单由内部收付协同业务自动生成,是否确认删除?", "PaymentBillEdit_23", "fi-cas-formplugin", new Object[0]), billnoStr), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_DEL_CALLBACK", this));
+//            }
+        } else if ("pay".equals(opKey) && selectRows.size() > 0) {
+            selectRowsPks = (Set)selectRows.parallelStream().map((row) -> {
+                return row.getPrimaryKeyValue();
+            }).collect(Collectors.toSet());
+            delFilters = new QFilter[]{new QFilter("id", "in", selectRowsPks)};
+            paybills = BusinessDataServiceHelper.load("nckd_cas_arbill", "billno,org,settletype", delFilters);
+            if (EmptyUtil.isNoEmpty(paybills)) {
+                boolean hasErrorData = false;
+                DynamicObject[] var9 = paybills;
+                int var10 = paybills.length;
+
+                for(int var11 = 0; var11 < var10; ++var11) {
+                    DynamicObject dataEntity = var9[var11];
+                    long orgId = dataEntity.getDynamicObject("org").getLong("id");
+                    boolean selectDraftFlag = SystemParameterHelper.getParameterBoolean(orgId, "cs122");
+                    String settleTypeKey = DraftHelper.getKey(dataEntity.get("settletype"));
+                    logger.info("selectDraftFlag is:" + selectDraftFlag + ",key:" + settleTypeKey);
+                    boolean isdraft = SystemParameterHelper.getCdmParameterBoolean(orgId, "isdraft");
+                    boolean ischeck = SystemParameterHelper.getCdmParameterBoolean(orgId, "ischeck");
+                    boolean ispromissorynote = SystemParameterHelper.getCdmParameterBoolean(orgId, "ispromissorynote");
+                    if (!CasHelper.isEmpty(settleTypeKey)) {
+                        String typeName;
+                        switch (settleTypeKey) {
+                            case "isdraft":
+                                if (isdraft && !selectDraftFlag) {
+                                    typeName = ResManager.loadKDString("汇票", "DraftHelper_4", "fi-cas-common", new Object[0]);
+                                    this.cancelAndWarn(evt, dataEntity, typeName);
+                                }
+                                break;
+                            case "ischeck":
+                                if (ischeck && !selectDraftFlag) {
+                                    typeName = ResManager.loadKDString("支票", "DraftHelper_5", "fi-cas-common", new Object[0]);
+                                    this.cancelAndWarn(evt, dataEntity, typeName);
+                                }
+                                break;
+                            case "ispromissorynote":
+                                if (ispromissorynote && !selectDraftFlag) {
+                                    typeName = ResManager.loadKDString("本票", "DraftHelper_6", "fi-cas-common", new Object[0]);
+                                    this.cancelAndWarn(evt, dataEntity, typeName);
+                                }
+                        }
+                    }
+                }
+            }
+        }
+
+        if ("commitbe".equals(opKey) && selectRows.size() > 0) {
+            OperateOption op = OperateOption.create();
+            op.setVariableValue("ishasright", "true");
+            Object[] selectedRowPks = this.getSelectedRows().getPrimaryKeyValues();
+            OperationResult operationResult = OperationServiceHelper.executeOperate("beforecommitbe", "nckd_cas_arbill", selectedRowPks, op);
+            if (!operationResult.isSuccess() && operationResult.isNeedSign()) {
+                SignOperateCallback signOperate = new SignOperateCallback(this.getView(), this, op, ClientCallback.SignClientType.Secondry, "signbeforecommitbe");
+                OperationResult ops = signOperate.sign(operationResult);
+                evt.setCancel(true);
+                if (!ops.isSuccess()) {
+                    logger.info(" beforecommitbe sign error ");
+                    if (ops.isShowMessage() && EmptyUtil.isNoEmpty(ops.getMessage())) {
+                        this.getView().showTipNotification(ops.getMessage());
+                    }
+                }
+            }
+        }
+
+    }
+
+    private void cancelAndWarn(BeforeItemClickEvent evt, DynamicObject dataEntity, String typeName) {
+        String msg = String.format(ResManager.loadKDString("%1$s :结算方式类别为%2$s的付款单不支持确认付款", "DraftHelper_7_1", "fi-cas-common", new Object[0]), dataEntity.getString("billno"), typeName);
+        evt.setCancel(true);
+        this.getView().showTipNotification(msg);
+    }
+
+    public void itemClick(ItemClickEvent evt) {
+        super.itemClick(evt);
+        String key = evt.getItemKey();
+        switch (key.toLowerCase(Locale.ENGLISH)) {
+            case "tblnew4ap":
+                this.addNew(PaymentTypeEnum.AP, "nckd_cas_arbill");
+                break;
+            case "tblnew4er":
+                this.addNew(PaymentTypeEnum.ER, "nckd_cas_arbill");
+                break;
+            case "tblnew4otr":
+                this.addNew(PaymentTypeEnum.OTR, "nckd_cas_arbill");
+                break;
+            case "tblnew4syn":
+                this.addNew(PaymentTypeEnum.SYN, "nckd_cas_arbill_synonym");
+                break;
+            case "tblnew4cash":
+                this.addNew(PaymentTypeEnum.CASH, "nckd_cas_arbill_cash");
+            case "tbloffset":
+            default:
+                break;
+            case "tblbeforesubmit":
+                this.beforeSubmit();
+                break;
+            case "barviewdiagram":
+                this.viewDiagram();
+                break;
+            case "viewsettle":
+                this.viewSettle();
+                break;
+            case "tblcancelpay":
+                this.cancelPay();
+                break;
+            case "viewdrafbill":
+                this.viewDrafBill();
+                break;
+            case "tblnewspan":
+                this.addNew(PaymentTypeEnum.SPAN, "nckd_cas_arbill_spanmainpart");
+                break;
+            case "batchinput":
+                this.viewBatchInput();
+        }
+
+    }
+
+    private void openEditView(String opName) {
+        BillList billList = (BillList)this.getView().getControl("billlistap");
+        ListSelectedRowCollection selectedRows = billList.getSelectedRows();
+        Object[] selectedRowPks = selectedRows.getPrimaryKeyValues();
+        if (selectedRowPks.length != 1) {
+            this.getView().showErrorNotification(ResManager.loadKDString("请选中一行再进行操作", "PaymentBillList_22", "fi-cas-formplugin", new Object[0]));
+        } else {
+            ListSelectedRow currentSelectedRowInfo = selectedRows.get(0);
+            String billStatus = currentSelectedRowInfo.getBillStatus();
+            if (!BillStatusEnum.RENOTE.getValue().equals(billStatus) && !BillStatusEnum.CHARGEBANK.getValue().equals(billStatus) && !BillStatusEnum.REFUND.getValue().equals(billStatus) && !BillStatusEnum.DEAD.getValue().equals(billStatus) && !BillStatusEnum.SAVE.getValue().equals(billStatus)) {
+                Object primaryKeyValue = currentSelectedRowInfo.getPrimaryKeyValue();
+                DynamicObject paybillDO = BusinessDataServiceHelper.loadSingle(primaryKeyValue, "nckd_cas_arbill", "paymenttype");
+                DynamicObject paymenttype = paybillDO.getDynamicObject("paymenttype");
+                boolean ispartpayment = paymenttype.getBoolean("ispartpayment");
+                if (!ispartpayment) {
+                    this.getView().showErrorNotification(ResManager.loadKDString("此单据付款类型没有参与应付结算,不能进行此操作", "PaymentBillList_24", "fi-cas-formplugin", new Object[0]));
+                } else {
+                    BillShowParameter showParameter = new BillShowParameter();
+                    showParameter.setCustomParam("op_supplecontract", opName);
+                    showParameter.setPkId(primaryKeyValue);
+                    showParameter.setCaption(ResManager.loadKDString("付款单", "PaymentBillList_25", "fi-cas-formplugin", new Object[0]));
+                    showParameter.setFormId("nckd_cas_arbill_contract");
+                    showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
+                    this.getView().showForm(showParameter);
+                }
+            } else {
+                this.getView().showErrorNotification(ResManager.loadKDString("单据状态不符合,不能进行此操作", "PaymentBillList_23", "fi-cas-formplugin", new Object[0]));
+            }
+        }
+    }
+
+    private void openChangeChg(String sourceType, String sourceAction) {
+        FormShowParameter showParameter = new FormShowParameter();
+        BillList billList = (BillList)this.getView().getControl("billlistap");
+        ListSelectedRowCollection selectedRows = billList.getSelectedRows();
+        Long sourceId = (Long)selectedRows.get(0).getPrimaryKeyValue();
+        StyleCss css = new StyleCss();
+        css.setWidth("700");
+        css.setHeight("400");
+        showParameter.getOpenStyle().setInlineStyleCss(css);
+        showParameter.setCustomParam("sourceId", sourceId);
+        showParameter.setCustomParam("sourceType", sourceType);
+        showParameter.setCustomParam("sourceAction", sourceAction);
+        showParameter.setFormId("cas_changemodeselection");
+        showParameter.getOpenStyle().setShowType(ShowType.Modal);
+        showParameter.setStatus(OperationStatus.ADDNEW);
+        showParameter.setCloseCallBack(new CloseCallBack(this, "KEY_CHANGECHG_CALLBACK"));
+        this.getView().showForm(showParameter);
+    }
+
+    private void addNew(PaymentTypeEnum paymentType, String formId) {
+        this.getPageCache().put("paymentType", paymentType.name());
+        this.getPageCache().put("formId", formId);
+        this.getView().invokeOperation("new");
+    }
+
+    public void closedCallBack(ClosedCallBackEvent e) {
+        super.closedCallBack(e);
+        PayBillListPlugnHelper.closeCallBack(e.getActionId(), this.getView(), e.getReturnData());
+    }
+
+    private void beforeSubmit() {
+        BillList billList = (BillList)this.getControl("billlistap");
+        ListSelectedRowCollection selectedRows = billList.getSelectedRows();
+        if (selectedRows.size() <= 0) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择要执行的数据!", "PaymentBillList_0", "fi-cas-formplugin", new Object[0]));
+        } else {
+            this.getView().invokeOperation("beforesubmit");
+        }
+
+    }
+
+    private void viewDiagram() {
+        BillList billList = (BillList)this.getControl("billlistap");
+        ListSelectedRowCollection selectedRows = billList.getSelectedRows();
+        Object[] selectedRowPks = selectedRows.getPrimaryKeyValues();
+        if (selectedRowPks.length != 1) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择要执行的数据!", "PaymentBillList_0", "fi-cas-formplugin", new Object[0]));
+        } else {
+            ListSelectedRow selectedRow = selectedRows.get(0);
+            Long billId = (Long)selectedRow.getPrimaryKeyValue();
+            FormShowParameter showParameter = new FormShowParameter();
+            showParameter.setFormId("wf_viewflowchart");
+            showParameter.setClientParam("billId", billId);
+            showParameter.getOpenStyle().setShowType(ShowType.NewWindow);
+            this.getView().showForm(showParameter);
+        }
+    }
+
+    private void viewSettle() {
+        BillList billList = (BillList)this.getControl("billlistap");
+        ListSelectedRowCollection selectedRows = billList.getSelectedRows();
+        Object[] selectedRowPks = selectedRows.getPrimaryKeyValues();
+        if (selectedRowPks.length == 0) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择要执行的数据!", "PaymentBillList_3", "fi-cas-formplugin", new Object[0]));
+        } else if (selectedRowPks.length > 1) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择单条数据联查!", "PaymentBillList_4", "fi-cas-formplugin", new Object[0]));
+        } else {
+            Object primaryKey = selectedRowPks[0];
+            List<Long> mainSettleIds = SettleRecordQueryHelperForCas.getSettleIdsByMain("ap_settlerecord", "nckd_cas_arbill", new Object[]{primaryKey});
+            List<Long> asstSettleIds = SettleRecordQueryHelperForCas.getSettleIdsByAsst("ap_settlerecord", "nckd_cas_arbill", new Object[]{primaryKey});
+            Set<Long> settleRecordIds = new HashSet();
+            settleRecordIds.addAll(mainSettleIds);
+            settleRecordIds.addAll(asstSettleIds);
+            if (settleRecordIds.size() > 0) {
+                PayBillListPlugnHelper.viewSettle(settleRecordIds, this.getView());
+            } else {
+                this.getView().showTipNotification(ResManager.loadKDString("暂无结算记录。", "PaymentBillList_5", "fi-cas-formplugin", new Object[0]));
+            }
+        }
+
+    }
+
+    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
+        super.beforeDoOperation(args);
+        AbstractOperate op = (AbstractOperate)args.getSource();
+        String key = op.getOperateKey();
+        BillList list;
+        ListSelectedRowCollection selectedRows;
+        DynamicObject dbData;
+        Object[] selectedRowPks;
+        DynamicObject[] payBills;
+        ListSelectedRowCollection lstCollection;
+        DynamicObject payBill;
+        int var45;
+        if ("trackdown".equals(key)) {
+            list = (BillList)this.getView().getControl("billlistap");
+            selectedRows = list.getSelectedRows();
+            lstCollection = list.getSelectedRows();
+            payBill = BusinessDataServiceHelper.loadSingle(lstCollection.get(0).getPrimaryKeyValue(), "nckd_cas_arbill", "id,settletype");
+            dbData = payBill.getDynamicObject("settletype");
+            if (dbData != null) {
+                String settlementtype = dbData.getString("settlementtype");
+                if (EmptyUtil.isNoEmpty(settlementtype) && this.settleTypes.contains(settlementtype)) {
+                    op.getOption().setVariableValue("botp_track_edit_status", "true");
+                }
+            }
+        } else {
+            FormOperate operate;
+            if ("chargeback".equals(key)) {
+                operate = (FormOperate)args.getSource();
+                operate.getOption().setVariableValue("strictvalidation", String.valueOf(true));
+            } else if ("invalid".equals(key)) {
+                boolean result = op.getOption().tryGetVariableValue("cancellation", new RefObject());
+                if (!result) {
+                    list = (BillList)this.getView().getControl("billlistap");
+                    lstCollection = list.getSelectedRows();
+                    args.cancel = true;
+                    if (CasHelper.getSelectedRowSize(lstCollection) > 1) {
+                        this.getView().showTipNotification(ResManager.loadKDString("作废仅支持对单张单据处理,请修改选择范围。", "PaymentBillList_8", "fi-cas-formplugin", new Object[0]));
+                        return;
+                    }
+
+                    this.getView().showConfirm(ResManager.loadKDString("作废选中记录后,将无法恢复,确认要作废该记录吗?", "PaymentBillList_9", "fi-cas-formplugin", new Object[0]), MessageBoxOptions.OKCancel, new ConfirmCallBackListener("cancellation", this));
+                }
+            } else {
+                DynamicObject settletype;
+                String payConfirm;
+                if ("endorse".equals(key)) {
+                    list = (BillList)this.getView().getControl("billlistap");
+                    selectedRows = list.getSelectedRows();
+                    if (CasHelper.getSelectedRowSize(selectedRows) > 1) {
+                        this.getView().showTipNotification(ResManager.loadKDString("背书仅支持对单张单据处理,请修改选择范围。", "PaymentBillList_20", "fi-cas-formplugin", new Object[0]));
+                        args.cancel = true;
+                        return;
+                    }
+
+                    if (selectedRows.size() == 1) {
+                        DynamicObject info = BusinessDataServiceHelper.loadSingle(selectedRows.get(0).getPrimaryKeyValue(), "nckd_cas_arbill");
+                        payBill = info.getDynamicObject("payeracctbank");
+                        payConfirm = info.getString("billstatus");
+                        if (!BillStatusEnum.AUDIT.getValue().equals(payConfirm)) {
+                            this.getView().showTipNotification(ResManager.loadKDString("只有已审核状态的单据允许背书。", "PaymentBillDraftEditPlugin_2", "fi-cas-formplugin", new Object[0]));
+                            args.cancel = true;
+                            return;
+                        }
+
+                        if (PriorityEnum.DEFER.getValue().equals(info.getString("priority"))) {
+                            this.getView().showTipNotification(ResManager.loadKDString("单据已冻结,不支持该操作。", "PaymentBillFreezeValidator_0", "fi-cas-opplugin", new Object[0]));
+                            args.cancel = true;
+                            return;
+                        }
+
+                        if (!InitCheckPluginHelper.checkInitForPlugin(this.getView(), info.getDynamicObject("org"), new String[0])) {
+                            args.setCancel(true);
+                            return;
+                        }
+
+                        if (PaymentBillPluginHelper.checkPayeeTypeFreeze(Collections.singletonList(info))) {
+                            this.getView().showTipNotification((new PaymentErrorCode()).CANOTDOTHISOP_WHENSUPPLIERFREEZE().getMessage());
+                            args.setCancel(true);
+                            return;
+                        }
+
+                        settletype = info.getDynamicObject("settletype");
+                        DynamicObjectCollection draftbills = info.getDynamicObjectCollection("draftbill");
+                        if (settletype == null || draftbills == null || !settletype.getString("settlementtype").equals("5") && !settletype.getString("settlementtype").equals("6") || draftbills.size() == 0) {
+                            this.getView().showTipNotification(ResManager.loadKDString("背书仅适应结算方式类型是承兑汇票、支票或本票且结算号选择了库存票据的付款单,你所选单据不支持背书", "PaymentBillDraftEditPlugin_3", "fi-cas-formplugin", new Object[0]));
+                            args.cancel = true;
+                            return;
+                        }
+
+                        if (!DraftHelper.isHasRecDrafBill(draftbills)) {
+                            args.setCancel(true);
+                            this.getView().showTipNotification(ResManager.loadKDString("背书仅适用选择了库存应收票据的付款单,你所选单据不支持背书", "PaymentBillDraftEditPlugin_10", "fi-cas-formplugin", new Object[0]));
+                            return;
+                        }
+
+                        if (DraftHelper.isHasPayDrafBill(draftbills)) {
+                            args.setCancel(true);
+                            this.getView().showTipNotification(ResManager.loadKDString("存在应付票据不能确认背书,请在确认付款环节选择需要关联付款的应付票据和已背书的应收票据", "PaymentBillDraftEditPlugin_10_1", "fi-cas-formplugin", new Object[0]));
+                            return;
+                        }
+
+                        if (!DraftHelper.isParameterDraftOn((Long)selectedRows.get(0).getPrimaryKeyValue(), "nckd_cas_arbill")) {
+                            args.setCancel(true);
+                            this.getView().showTipNotification(ResManager.loadKDString("该组织没有启用相应的系统参数,请配置相应的系统参数!", "PaymentBillDraftEditPlugin_4", "fi-cas-formplugin", new Object[0]));
+                            return;
+                        }
+
+                        if (payBill != null && PayBillCrossHelper.isIfmBankAcc(payBill)) {
+                            throw new KDBizException(ResManager.loadKDString("内部账户请选择内部结算付款。", "PaymentErrorCode_48", "fi-cas-business", new Object[0]));
+                        }
+
+                        if (settletype != null && draftbills != null && draftbills.size() > 0 && Arrays.asList("5", "6").contains(settletype.getString("settlementtype"))) {
+                            Pair<String, List<String>> result = (Pair) DispatchServiceHelper.invokeBizService("tmc", "cdm", "EBDraftAllocationService", "doDraftAllocationService", new Object[]{info});
+                            if (result != null) {
+                                if ("ING".equals(result.getLeft())) {
+                                    args.cancel = true;
+                                    info.set("billstatus", BillStatusEnum.DRAFTING.getValue());
+                                    SaveServiceHelper.save(new DynamicObject[]{info});
+                                    this.getView().showSuccessNotification(BillStatusEnum.DRAFTING.getName());
+                                    this.getView().invokeOperation("refresh");
+                                } else if (!"S".equals(result.getLeft())) {
+                                    args.cancel = true;
+                                    this.getView().showErrorNotification(String.join("\n", (Iterable)result.getRight()));
+                                }
+                            }
+                        }
+                    }
+                } else {
+                    DynamicObject[] payableBills;
+                    DynamicObject accountBank;
+                    DynamicObject payableBill;
+                    if ("recbook".equals(key)) {
+                        list = (BillList)this.getControl("billlistap");
+                        selectedRows = list.getSelectedRows();
+                        if (CasHelper.getSelectedRowSize(selectedRows) > 1) {
+                            args.setCancel(true);
+                            this.getView().showTipNotification(ResManager.loadKDString("请选择单条数据!", "ReceivingBillList_10", "fi-cas-formplugin", new Object[0]));
+                        } else {
+                            Long primaryKeyValue = (Long)selectedRows.get(0).getPrimaryKeyValue();
+                            payBill = BusinessDataServiceHelper.loadSingle(primaryKeyValue, "nckd_cas_arbill");
+                            if (!BillStatusEnum.AUDIT.getValue().equals(payBill.getString("billstatus"))) {
+                                args.setCancel(true);
+                                this.getView().showTipNotification(ResManager.loadKDString("只有已审核状态的单据允许开票登记。", "PaymentBillDraftEditPlugin_5", "fi-cas-formplugin", new Object[0]));
+                            } else if (PriorityEnum.DEFER.getValue().equals(payBill.getString("priority"))) {
+                                args.setCancel(true);
+                                this.getView().showTipNotification(ResManager.loadKDString("单据已冻结,不支持该操作。", "PaymentBillFreezeValidator_0", "fi-cas-opplugin", new Object[0]));
+                            } else {
+                                if (!InitCheckPluginHelper.checkInitForPlugin(this.getView(), payBill.getDynamicObject("org"), new String[0])) {
+                                    args.setCancel(true);
+                                    return;
+                                }
+
+                                if (PaymentBillPluginHelper.checkPayeeTypeFreeze(Collections.singletonList(payBill))) {
+                                    this.getView().showTipNotification((new PaymentErrorCode()).CANOTDOTHISOP_WHENSUPPLIERFREEZE().getMessage());
+                                    args.setCancel(true);
+                                    return;
+                                }
+
+                                if (!DraftHelper.isDraftBill(primaryKeyValue, "nckd_cas_arbill")) {
+                                    args.setCancel(true);
+                                    this.getView().showTipNotification(ResManager.loadKDString("开票登记仅适用结算方式类型是承兑汇票、支票或本票的付款单,你所选单据不支持开票登记!", "PaymentBillDraftEditPlugin_6", "fi-cas-formplugin", new Object[0]));
+                                } else if (this.isDraftBill(payBill)) {
+                                    args.setCancel(true);
+                                    if (DraftHelper.isHasRecDrafBill((DynamicObjectCollection)payBill.get("draftbill"))) {
+                                        this.getView().showTipNotification(ResManager.loadKDString("付款单已选择相关应收票据,请进行背书处理!", "PaymentBillDraftEditPlugin_7", "fi-cas-formplugin", new Object[0]));
+                                    } else {
+                                        this.getView().showTipNotification(ResManager.loadKDString("付款单已选择相关应付票据,请进行确认付款处理!", "PaymentBillDraftEditPlugin_11", "fi-cas-formplugin", new Object[0]));
+                                    }
+                                } else if (!DraftHelper.isParameterDraftOn(primaryKeyValue, "nckd_cas_arbill")) {
+                                    args.setCancel(true);
+                                    this.getView().showTipNotification(ResManager.loadKDString("该组织没有启用相应的系统参数,请配置相应的系统参数!", "PaymentBillDraftEditPlugin_4", "fi-cas-formplugin", new Object[0]));
+                                } else {
+                                    Map<String, HashSet<Long>> botpMap = BFTrackerServiceHelper.findTargetBills("nckd_cas_arbill", new Long[]{primaryKeyValue});
+                                    HashSet<Long> pkValues = (HashSet)botpMap.get("cdm_payablebill");
+                                    boolean isExistNotDeadFlag = false;
+                                    if (null != pkValues && pkValues.size() > 0) {
+                                        payableBills = BusinessDataServiceHelper.load("cdm_payablebill", "id,billstatus", new QFilter[]{new QFilter("id", "in", pkValues.toArray())});
+                                        DynamicObject[] var58 = payableBills;
+                                        int var60 = payableBills.length;
+
+                                        for(int var62 = 0; var62 < var60; ++var62) {
+                                            payableBill = var58[var62];
+                                            if (!BillStatusEnum.DEAD.getValue().equals(payableBill.getString("billstatus"))) {
+                                                isExistNotDeadFlag = true;
+                                            }
+                                        }
+                                    }
+
+                                    if (isExistNotDeadFlag) {
+                                        args.setCancel(true);
+                                        this.getView().showTipNotification(ResManager.loadKDString("付款单已进行开票登记!", "PaymentBillDraftEditPlugin_8", "fi-cas-formplugin", new Object[0]));
+                                    }
+
+                                    accountBank = payBill.getDynamicObject("payeracctbank");
+                                    if (null != accountBank && AccountBankHelper.isClosed(accountBank.getLong("id"))) {
+                                        throw new KDBizException(String.format(ResManager.loadKDString("账户%s当前状态为已销户,暂无法进行业务处理。", "PaymentErrorCode_47", "fi-cas-business", new Object[0]), accountBank.getString("number")));
+                                    }
+
+                                    if (accountBank != null && PayBillCrossHelper.isIfmBankAcc(accountBank)) {
+                                        throw new KDBizException(ResManager.loadKDString("内部账户请选择内部结算付款。", "PaymentErrorCode_48", "fi-cas-business", new Object[0]));
+                                    }
+                                }
+                            }
+                        }
+                    } else if ("submit".equals(key)) {
+                        list = (BillList)this.getControl("billlistap");
+                        selectedRowPks = list.getSelectedRows().getPrimaryKeyValues();
+                        if (selectedRowPks != null && selectedRowPks.length > 0) {
+                            payBills = BusinessDataServiceHelper.load(selectedRowPks, EntityMetadataCache.getDataEntityType("nckd_cas_arbill"));
+                            List<DynamicObject> updateBills = new ArrayList(payBills.length);
+                            DynamicObject[] var42 = payBills;
+                            var45 = payBills.length;
+
+                            for(int var50 = 0; var50 < var45; ++var50) {
+                                accountBank = var42[var50];
+                                boolean isRemove = false;
+                                DynamicObjectCollection collection = accountBank.getDynamicObjectCollection("entry");
+                                Iterator<DynamicObject> iterator = collection.iterator();
+
+                                while(iterator.hasNext()) {
+                                    payableBill = (DynamicObject)iterator.next();
+                                    if (CasHelper.isEmpty(payableBill.get("e_payableamt"))) {
+                                        iterator.remove();
+                                        isRemove = true;
+                                    }
+                                }
+
+                                if (isRemove) {
+                                    updateBills.add(accountBank);
+                                }
+                            }
+
+                            if (updateBills.size() > 0) {
+                                SaveServiceHelper.save((DynamicObject[])updateBills.toArray(new DynamicObject[0]));
+                            }
+                        }
+                    } else if ("payschback".equals(key)) {
+                        operate = (FormOperate)args.getSource();
+                        operate.getOption().setVariableValue("strictvalidation", String.valueOf(true));
+                    } else if ("pay".equals(key)) {
+                        list = (BillList)this.getView().getControl("billlistap");
+                        selectedRows = list.getSelectedRows();
+                        Set<Object> selectRowsPks = new HashSet();
+                        selectedRows.forEach((listSelectedRow) -> {
+                            selectRowsPks.add(listSelectedRow.getPrimaryKeyValue());
+                        });
+                        String draftIds = op.getOption().getVariableValue("draftids", "");
+                        if (selectRowsPks.size() == 1 && StringUtils.isEmpty(draftIds)) {
+                            dbData = BusinessDataServiceHelper.loadSingle(selectedRows.get(0).getPrimaryKeyValue(), EntityMetadataCache.getDataEntityType("nckd_cas_arbill"));
+                            settletype = (DynamicObject)dbData.get("org");
+                            Long pkValue = (Long)settletype.getPkValue();
+                            boolean selectDraftFlag = SystemParameterHelper.getParameterBoolean(pkValue, "cs122");
+                            if (selectDraftFlag && PaymentBillPluginHelper.needSelectedDraft(dbData) && BillStatusEnum.AUDIT.getValue().equals(dbData.getString("billstatus"))) {
+                                PayBillListPlugnHelper.showSelectDraftForm(new CloseCallBack(this, "CALLBACK_SELECTDRAFT"), this.getView(), selectedRows.get(0).getPrimaryKeyValue());
+                                args.setCancel(true);
+                                return;
+                            }
+                        }
+
+                        if (StringUtils.isEmpty(draftIds)) {
+                            payConfirm = op.getOption().getVariableValue("payConfirm", "");
+                            if (StringUtils.isEmpty(payConfirm)) {
+                                if (selectedRows.size() <= 0) {
+                                    throw new KDBizException(ResManager.loadKDString("请选择要执行的数据!", "PaymentBillList_0", "fi-cas-formplugin", new Object[0]));
+                                }
+
+                                Object[] pkArray = selectRowsPks.toArray(new Object[0]);
+                                QFilter pkFilter = new QFilter("id", "in", pkArray);
+                                payableBills = BusinessDataServiceHelper.load("nckd_cas_arbill", "org,dpcurrency,basecurrency,isdiffcur", new QFilter[]{pkFilter});
+                                Set<Long> orgIds = new HashSet(10);
+                                boolean isSameCurrency = true;
+                                boolean isSameDpCurrency = true;
+                                boolean isForeignCurrency = false;
+                                boolean isSameParam = true;
+                                Long preDpCurrencyId = 0L;
+                                Long preBasecurrencyId = 0L;
+                                String param = null;
+                                Map<Long, Set<String>> cs1047Params = new HashMap(10);
+                                if (payableBills != null && payableBills.length > 0) {
+                                    DynamicObject[] var21 = payableBills;
+                                    int var22 = payableBills.length;
+
+                                    for(int var23 = 0; var23 < var22; ++var23) {
+                                        payBill = var21[var23];
+                                        long orgId = (Long)payBill.getDynamicObject("org").getPkValue();
+                                        new HashSet(1);
+                                        Set cs1046;
+                                        if (!orgIds.contains(orgId)) {
+                                            cs1046 = SystemParameterHelper.getParameterComboxs(orgId, "cs1046");
+                                            String setParamToString = PayBillListPlugnHelper.setParamToString(cs1046);
+                                            if (param == null) {
+                                                param = setParamToString;
+                                            } else if (!param.equals(setParamToString)) {
+                                                isSameParam = false;
+                                            }
+
+                                            cs1047Params.put(orgId, cs1046);
+                                        } else {
+                                            cs1046 = (Set)cs1047Params.get(orgId);
+                                        }
+
+                                        orgIds.add(orgId);
+                                        if (payBill.getBoolean("isdiffcur") && cs1046.contains(SysParamCs1046Enum.DIFF.getValue()) && selectRowsPks.size() > 1) {
+                                            throw new KDBizException(ResManager.loadKDString("存在异币别需要确认付款的单据,不能批量确认付款。", "PaymentBillList_26", "fi-cas-formplugin", new Object[0]));
+                                        }
+
+                                        Long dpcurrencyId = payBill.getDynamicObject("dpcurrency").getLong("id");
+                                        if (preDpCurrencyId == 0L) {
+                                            preDpCurrencyId = dpcurrencyId;
+                                        } else if (!preDpCurrencyId.equals(dpcurrencyId)) {
+                                            isSameDpCurrency = false;
+                                        }
+
+                                        Long basecurrencyId = payBill.getDynamicObject("basecurrency").getLong("id");
+                                        if (preBasecurrencyId == 0L) {
+                                            preBasecurrencyId = basecurrencyId;
+                                        } else if (!preBasecurrencyId.equals(basecurrencyId)) {
+                                            isSameCurrency = false;
+                                        }
+
+                                        if (!basecurrencyId.equals(dpcurrencyId)) {
+                                            isForeignCurrency = true;
+                                        }
+                                    }
+                                }
+
+                                if (!isSameParam) {
+                                    throw new KDBizException(ResManager.loadKDString("所选单据存在多个付款资金组织系统参数“允许确认付款环节更新/补充信息”选项不一致,不能批量确认付款,请重新选择。", "PaymentBillList_34", "fi-cas-formplugin", new Object[0]));
+                                }
+
+                                Set<String> cs1047 = (Set)cs1047Params.get(orgIds.iterator().next());
+                                if (cs1047.contains(SysParamCs1046Enum.FOREIGN.getValue()) && (!isSameDpCurrency || !isSameCurrency)) {
+                                    throw new KDBizException(ResManager.loadKDString("开启了系统参数确认付款环节更新外币业务的付款汇率,但所选存在付款币别、业务主币别不一致的单据,不能批量确认付款,请重新选择。", "PaymentBillList_35", "fi-cas-formplugin", new Object[0]));
+                                }
+
+                                Object pk;
+                                if (selectRowsPks.size() > 1) {
+                                    if (isForeignCurrency && cs1047.contains(SysParamCs1046Enum.FOREIGN.getValue())) {
+                                        pk = selectedRows.get(0).getPrimaryKeyValue();
+                                        payBill = BusinessDataServiceHelper.loadSingle(pk, "nckd_cas_arbill");
+                                        PayBillListPlugnHelper.showDiffPayRateForm(new CloseCallBack(this, "KEY_DIFFPAY_CALLBACK"), this.getView(), payBill);
+                                        args.setCancel(true);
+                                    } else if (cs1047.contains(SysParamCs1046Enum.PAYDATE.getValue())) {
+                                        PayBillListPlugnHelper.showDiffPayDateForm(new CloseCallBack(this, "KEY_DIFFPAY_CALLBACK"), this.getView());
+                                        args.setCancel(true);
+                                    }
+                                } else {
+                                    pk = selectedRows.get(0).getPrimaryKeyValue();
+                                    payBill = BusinessDataServiceHelper.loadSingle(pk, "nckd_cas_arbill");
+                                    if (PaymentBillPluginHelper.isShowPayConfirm(payBill, cs1047)) {
+                                        if (!DraftHelper.isAllPayDrafBill(payBill.getDynamicObjectCollection("draftbill")) && !payBill.getBoolean("feepay")) {
+                                            (new PaymentPayImpl()).validate(payBill);
+                                            PayBillListPlugnHelper.showDiffPayForm(new CloseCallBack(this, "KEY_DIFFPAY_CALLBACK"), this.getView(), payBill);
+                                            args.setCancel(true);
+                                        }
+                                    } else {
+                                        (new PaymentPayImpl()).validate(payBill);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (Arrays.asList("unaudit", "chargeback", "invalid", "delete", "pay").contains(key) && (!"invalid".equals(key) || "invalid".equals(key) && op.getOption().tryGetVariableValue("cancellation", new RefObject()))) {
+            list = (BillList)this.getControl("billlistap");
+            selectedRowPks = list.getSelectedRows().getPrimaryKeyValues();
+            if (selectedRowPks != null && selectedRowPks.length > 0) {
+                payBills = BusinessDataServiceHelper.load(selectedRowPks, EntityMetadataCache.getDataEntityType("nckd_cas_arbill"));
+                DynamicObject[] var41 = payBills;
+                int var46 = payBills.length;
+
+                for(var45 = 0; var45 < var46; ++var45) {
+                    payBill = var41[var45];
+                    if (PayBillHepler.getViewSettle(payBill).size() > 0) {
+                        this.getView().showErrorNotification(String.format(ResManager.loadKDString("%s已存在结算记录,导致操作失败。如需继续执行操作,请先反结算。", "PaymentBillList_36", "fi-cas-formplugin", new Object[0]), String.join(payBill.getString("billno"), "【", "】")));
+                        args.setCancel(true);
+                        return;
+                    }
+                }
+            }
+        }
+
+    }
+
+    private Boolean isDraftBill(DynamicObject payBill) {
+        return !CasHelper.isEmpty(payBill.get("draftbill")) && ((DynamicObjectCollection)payBill.get("draftbill")).size() != 0 ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    private boolean payInfoChgvaild(String chgtype) {
+        BillList list = (BillList)this.getView().getControl("billlistap");
+        ListSelectedRowCollection selectedRows = list.getSelectedRows();
+        if (CasHelper.getSelectedRowSize(selectedRows) > 1) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择单条数据进行支付信息变更!", "PaymentBillList_10", "fi-cas-formplugin", new Object[0]));
+            return false;
+        } else {
+            DynamicObjectCollection query = QueryServiceHelper.query("nckd_cas_arbill", "billstatus,matchflag", new QFilter[]{new QFilter("id", "=", selectedRows.get(0).getPrimaryKeyValue())});
+            if (query.size() < 1) {
+                this.getView().showTipNotification(ResManager.loadKDString("请选择单条数据进行支付信息变更!", "PaymentBillList_10", "fi-cas-formplugin", new Object[0]));
+                this.getView().invokeOperation("refresh");
+                return false;
+            } else {
+                Object newStatus = ((DynamicObject)query.get(0)).getString("billstatus");
+                if (!newStatus.equals("C")) {
+                    this.getView().showTipNotification(ResManager.loadKDString("只有已审核的单据才能进行支付信息变更。", "PaymentBillList_11", "fi-cas-formplugin", new Object[0]));
+                    return false;
+                } else {
+                    String matchFlag = ((DynamicObject)query.get(0)).getString("matchflag");
+                    if (!AutoMatchFlagEnum.NONE.getValue().equals(matchFlag)) {
+                        this.getView().showTipNotification(ResManager.loadKDString("已匹配的单据不允许发起变更", "PaymentBillList_50", "fi-cas-formplugin", new Object[0]));
+                        return false;
+                    } else {
+                        Object selectPk = selectedRows.get(0).getPrimaryKeyValue();
+                        Boolean ischangepaych = QueryServiceHelper.exists("cas_paychgbill", new QFilter[]{new QFilter("sourcebillid", "=", selectPk), new QFilter("sourcetype", "=", "nckd_cas_arbill"), new QFilter("chgtype", "=", chgtype), new QFilter("iscashconfirm", "!=", "1")});
+                        if (ischangepaych) {
+                            this.getView().showTipNotification(ResManager.loadKDString("该单据正在变更支付信息流程中,无法再次变更。", "PaymentBillList_12", "fi-cas-formplugin", new Object[0]));
+                            return false;
+                        } else {
+                            DynamicObject casPayBill = BusinessDataServiceHelper.loadSingle("nckd_cas_arbill", "id,entrustorg,applyorg", new QFilter[]{new QFilter("id", "=", selectPk)});
+                            if (!CasHelper.isEmpty(casPayBill)) {
+                                if (!CasHelper.isEmpty(casPayBill.get("entrustorg"))) {
+                                    this.getView().showTipNotification(ResManager.loadKDString("委托付款业务不支持支付信息变更。", "PaymentBillList_20", "fi-cas-formplugin", new Object[0]));
+                                    return false;
+                                }
+
+                                if (!CasHelper.isEmpty(casPayBill.get("applyorg"))) {
+                                    this.getView().showTipNotification(ResManager.loadKDString("申请付款组织业务不支持支付信息变更。", "PaymentBillList_21", "fi-cas-formplugin", new Object[0]));
+                                    return false;
+                                }
+                            }
+
+                            return true;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
+        super.confirmCallBack(messageBoxClosedEvent);
+        String id = messageBoxClosedEvent.getCallBackId();
+        MessageBoxResult res = messageBoxClosedEvent.getResult();
+        if (StringUtils.equals(id, "CONFIRM_CANCELPAY_CALLBACK") && MessageBoxResult.Yes.equals(res)) {
+            BillList billList = (BillList)this.getView().getControl("billlistap");
+            ListSelectedRowCollection selectedRows = billList.getSelectedRows();
+            if (selectedRows.size() > 0) {
+                List<Long> paymentBillPks = new LinkedList();
+                Iterator var7 = selectedRows.iterator();
+
+                while(var7.hasNext()) {
+                    ListSelectedRow selectedRow = (ListSelectedRow)var7.next();
+                    paymentBillPks.add((Long)selectedRow.getPrimaryKeyValue());
+                }
+
+                QFilter payPidFilter = new QFilter("id", "in", paymentBillPks);
+                DynamicObject[] payobjs = BusinessDataServiceHelper.load("nckd_cas_arbill", "id,billno", new QFilter[]{payPidFilter});
+                if (!this.cancelPayCheckSettle(paymentBillPks, payobjs)) {
+                    this.getView().invokeOperation("cancelpay");
+                }
+            }
+        }
+
+        if (StringUtils.equals(id, "CONFIRM_CANCELPAY_SETTLE_CALLBACK") && MessageBoxResult.Yes.equals(res)) {
+            this.getView().invokeOperation("cancelpay");
+        }
+
+        OperateOption option;
+        if (StringUtils.equals(id, "cancellation") && MessageBoxResult.Yes.equals(res)) {
+            option = OperateOption.create();
+            option.setVariableValue("cancellation", "yes");
+            this.getView().invokeOperation("invalid", option);
+        }
+
+        if (id.equals("CONFIRM_DEL_CALLBACK")) {
+            option = OperateOption.create();
+            if (MessageBoxResult.Yes.equals(res)) {
+                option.setVariableValue("delrecpay", "1");
+                this.getView().invokeOperation("delete", option);
+            }
+        }
+
+    }
+
+    public void afterDoOperation(AfterDoOperationEventArgs e) {
+        super.afterDoOperation(e);
+        AbstractOperate op = (AbstractOperate)e.getSource();
+        String key = op.getOperateKey();
+        OperationResult operationResult = e.getOperationResult();
+        List successPkIds;
+        if ((!"pay".equals(key) || !operationResult.isSuccess()) && (!"cancelpay".equals(key) || !operationResult.isSuccess())) {
+            if ("unitecommitbe".equals(key) && operationResult.isSuccess()) {
+                this.getView().showSuccessNotification(ResManager.loadKDString("合并提交银企成功!", "PaymentBillList_16", "fi-cas-formplugin", new Object[0]));
+            } else if (("chargeback".equals(key) || "payschback".equals(key)) && operationResult.isSuccess()) {
+                successPkIds = operationResult.getSuccessPkIds();
+                if (!CollectionUtils.isEmpty(successPkIds)) {
+                    this.chargeBack(successPkIds, key);
+                }
+            } else if ("trackdownchgbill".equals(key) && operationResult.isSuccess()) {
+                this.trackdownChgBill();
+            } else if ("chargebacknoreason".equals(key)) {
+                String reason = ResManager.loadKDString("自动退单", "PaymentBillList_37", "fi-cas-formplugin", new Object[0]);
+                successPkIds = operationResult.getSuccessPkIds();
+                Map<String, Object> data = new HashMap(16);
+                data.put("billid", successPkIds);
+                data.put("reason", reason);
+                data.put("operateKey", "chargeback");
+                PayBillListPlugnHelper.closeCallBack("CALLBACK_CHARGEBACK", this.getView(), data);
+            }
+        }
+
+        boolean refreshFlg = !"refresh".equals(key) && !"exportbylist".equals(key) && !"paypushchg".equals(key) && !"recpushchg".equals(key) && !"modify".equals(key);
+        if (refreshFlg) {
+            ((ListView)this.getView()).refresh();
+        }
+
+        if ("beforesubmit".equals(key)) {
+            successPkIds = operationResult.getSuccessPkIds();
+            if (successPkIds != null && successPkIds.size() > 0) {
+                operationResult.setShowMessage(false);
+                this.getView().invokeOperation("submit");
+            }
+        } else if ("chargebackwrite".equals(key) && operationResult.isSuccess()) {
+            ((IEntityOperate)e.getSource()).setCancelRefresh(false);
+        } else if ("supplecontract".equals(key) && operationResult.isSuccess()) {
+            this.openEditView("supplecontract");
+        } else {
+            boolean flag;
+            if ("paypushchg".equals(key) && operationResult.isSuccess()) {
+                flag = this.payInfoChgvaild("paychg");
+                if (flag) {
+                    PayBillListPlugnHelper.payInfoChg("nckd_cas_arbill", "payAction", "cas_paychgbill_paychg", (String)null, this.getView());
+                }
+            } else if ("recpushchg".equals(key) && operationResult.isSuccess()) {
+                flag = this.payInfoChgvaild("recchg");
+                if (flag) {
+                    this.openChangeChg("nckd_cas_arbill", "recAction");
+                }
+            } else if ("urgentpay".equals(key) && operationResult.isSuccess()) {
+                successPkIds = operationResult.getSuccessPkIds();
+                if (!CollectionUtils.isEmpty(successPkIds)) {
+                    this.getView().showSuccessNotification(ResManager.loadKDString("加急成功", "PaymentBillList_38", "fi-cas-formplugin", new Object[0]));
+                }
+            } else if ("cancelurgentpay".equals(key) && operationResult.isSuccess()) {
+                successPkIds = operationResult.getSuccessPkIds();
+                if (!CollectionUtils.isEmpty(successPkIds)) {
+                    this.getView().showSuccessNotification(ResManager.loadKDString("取消加急成功", "PaymentBillList_39", "fi-cas-formplugin", new Object[0]));
+                }
+            }
+        }
+
+        if (Arrays.asList("pay", "cancelpay", "syncbankbillstatus").contains(key) && operationResult != null && operationResult.isSuccess()) {
+            this.getView().invokeOperation("refresh");
+        }
+
+    }
+
+    public void filterContainerInit(FilterContainerInitArgs args) {
+        super.filterContainerInit(args);
+        this.initArgs = args;
+        ListShowParameter listShowParameter = (ListShowParameter)this.getView().getFormShowParameter();
+        String status = (String)listShowParameter.getCustomParam("status");
+        String parentFormId = listShowParameter.getParentFormId();
+        Iterator var5;
+        FilterColumn filterColumn;
+        List defaultValues;
+        if (null == this.getCachedOrgList()) {
+            var5 = args.getCommonFilterColumns().iterator();
+
+            while(var5.hasNext()) {
+                filterColumn = (FilterColumn)var5.next();
+                if ("org.id".equals(filterColumn.getFieldName())) {
+                    defaultValues = filterColumn.getDefaultValues();
+                    if (null != defaultValues && defaultValues.size() > 0) {
+                        List<Long> selectedOrgIdList = (List)defaultValues.stream().filter((t) -> {
+                            return StringUtils.isNotEmpty(t.toString());
+                        }).map((item) -> {
+                            return Long.valueOf(item.toString());
+                        }).collect(Collectors.toList());
+                        this.cacheSelectedOrgIdList(selectedOrgIdList);
+                    }
+                }
+            }
+        }
+
+        if (this.isFromControlCenter() && "fca_control_index".equals(parentFormId) || this.isTrack()) {
+            var5 = args.getCommonFilterColumns().iterator();
+
+            while(var5.hasNext()) {
+                filterColumn = (FilterColumn)var5.next();
+                if ("org.id".equals(filterColumn.getFieldName())) {
+                    filterColumn.setDefaultValue("");
+                }
+
+                if ("billstatus".equals(filterColumn.getFieldName())) {
+                    if (EmptyUtil.isNoEmpty(status)) {
+                        defaultValues = Arrays.asList(status.split(","));
+                        filterColumn.setDefaultValues(defaultValues);
+                    } else {
+                        filterColumn.setDefaultValues(new Object[]{""});
+                    }
+                }
+
+                if ("bizdate".equals(filterColumn.getFieldName())) {
+                    filterColumn.setDefaultValue("");
+                }
+            }
+        }
+
+        this.fillToolBar();
+    }
+
+    public void filterContainerSearchClick(FilterContainerSearchClickArgs args) {
+        super.filterContainerSearchClick(args);
+        List<Long> selectedOrgIdList = args.getSelectMainOrgIds();
+        if (selectedOrgIdList.size() > 0) {
+            List<Object> object = this.getCachedOrgList();
+            if (null == object || !object.toString().equals(selectedOrgIdList.toString())) {
+                this.cacheSelectedOrgIdList(selectedOrgIdList);
+                this.filterContainerInit(this.initArgs);
+            }
+        }
+
+    }
+
+    private void cacheSelectedOrgIdList(List<Long> selectedOrgIdList) {
+        if (selectedOrgIdList != null) {
+            this.getPageCache().put("selectedOrgIdList", SerializationUtils.toJsonString(selectedOrgIdList));
+        } else {
+            this.getPageCache().put("selectedOrgIdList", (String)null);
+        }
+
+    }
+
+    protected List<Object> getCachedOrgList() {
+        return this.getPageCache().get("selectedOrgIdList") != null ? (List)SerializationUtils.fromJsonString(this.getPageCache().get("selectedOrgIdList"), List.class) : null;
+    }
+
+    private void fillToolBar() {
+        this.getView().setVisible(false, new String[]{"recbook", "endorse"});
+        List<Object> object = this.getCachedOrgList();
+        if (object != null && object.size() != 0) {
+            List<Long> cachedOrgList = (List)this.getCachedOrgList().stream().map((item) -> {
+                return Long.valueOf(item.toString());
+            }).collect(Collectors.toList());
+            Iterator var3 = cachedOrgList.iterator();
+
+            boolean isdraft;
+            boolean ischeck;
+            boolean ispromissorynote;
+            do {
+                if (!var3.hasNext()) {
+                    return;
+                }
+
+                Long orgId = (Long)var3.next();
+                isdraft = SystemParameterHelper.getCdmParameterBoolean(orgId, "isdraft");
+                ischeck = SystemParameterHelper.getCdmParameterBoolean(orgId, "ischeck");
+                ispromissorynote = SystemParameterHelper.getCdmParameterBoolean(orgId, "ispromissorynote");
+            } while(!isdraft && !ischeck && !ispromissorynote);
+
+            this.getView().setVisible(true, new String[]{"recbook", "endorse"});
+        } else {
+            this.getView().setVisible(true, new String[]{"recbook", "endorse"});
+        }
+    }
+
+    public void beforeShowBill(BeforeShowBillFormEvent e) {
+        super.beforeShowBill(e);
+        BillShowParameter showParameter = e.getParameter();
+        Object billId = showParameter.getPkId();
+        BillOperationStatus billStatus = showParameter.getBillStatus();
+        OperationStatus operationStatus = showParameter.getStatus();
+        String operateType;
+        if (billId != null) {
+            if (OperationStatus.ADDNEW.equals(operationStatus)) {
+                operateType = this.getPageCache().get("operate");
+                if (operateType != null) {
+                    showParameter.getCustomParams().put("operate", operateType);
+                } else {
+                    showParameter.getCustomParams().put("operate", OperateTypeEnum.COPY);
+                }
+            } else {
+                DynamicObject info = BusinessDataServiceHelper.loadSingle(billId, "nckd_cas_arbill", "id, billtype");
+                DynamicObject billtype = info.getDynamicObject("billtype");
+                if (billtype != null && BillTypeConstants.PAYBILL_SYN.equals(billtype.getPkValue())) {
+                    showParameter.setFormId("nckd_cas_arbill_synonym");
+                    showParameter.setCaption(ResManager.loadKDString("同名转账", "PaymentBillEdit_24", "fi-cas-formplugin", new Object[0]));
+                } else if (billtype != null && BillTypeConstants.PAYBILL_SPAN.equals(billtype.getPkValue())) {
+                    showParameter.setFormId("nckd_cas_arbill_spanmainpart");
+                    showParameter.setCaption(ResManager.loadKDString("跨主体调拨", "PaymentBillEdit_28", "fi-cas-formplugin", new Object[0]));
+                } else if (billtype != null && BillTypeConstants.PAYBILL_CASH.equals(billtype.getPkValue())) {
+                    showParameter.setFormId("nckd_cas_arbill_cash");
+                    showParameter.setCaption(ResManager.loadKDString("现金存取", "PaymentBillEdit_25", "fi-cas-formplugin", new Object[0]));
+                }
+
+                showParameter.setCustomParam("showConer", true);
+            }
+        } else if (BillOperationStatus.ADDNEW == billStatus) {
+            showParameter.getCustomParams().put("paymentType", this.getPageCache().get("paymentType"));
+            operateType = this.getPageCache().get("formId");
+            if (StringUtils.isNotBlank(operateType)) {
+                showParameter.setFormId(operateType);
+            }
+
+            this.getView().showForm(showParameter);
+        }
+
+    }
+
+    private void trackdownChgBill() {
+        BillList list = (BillList)this.getView().getControl("billlistap");
+        ListSelectedRowCollection selectedRows = list.getSelectedRows();
+        Object[] selectedIds = selectedRows.getPrimaryKeyValues();
+        if (selectedIds.length != 1) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择单条数据进行操作!", "AgentPayBillList_20", "fi-cas-formplugin", new Object[0]));
+        }
+
+        DynamicObject[] paychgbill = BusinessDataServiceHelper.load("cas_paychgbill", "id,chgtype", new QFilter[]{new QFilter("sourcebillid", "=", selectedIds[0])});
+        if (EmptyUtil.isEmpty(paychgbill) || paychgbill.length == 0) {
+            this.getView().showTipNotification(ResManager.loadKDString("此单无变更单", "AgentPayBillList_21", "fi-cas-formplugin", new Object[0]));
+        }
+
+        if (paychgbill.length == 1) {
+            String formId = "";
+            if (ChgTypeEnum.RECCHG.getValue().equals(paychgbill[0].getString("chgtype"))) {
+                formId = "cas_paychgbill_recchg";
+            } else {
+                formId = "cas_paychgbill_paychg";
+            }
+
+            BillShowParameter showParameter = new BillShowParameter();
+            showParameter.setFormId(formId);
+            showParameter.setPkId(paychgbill[0].getPkValue());
+            showParameter.getOpenStyle().setShowType(ShowType.NonModal);
+            this.getView().showForm(showParameter);
+        } else {
+            ListShowParameter showParameter = new ListShowParameter();
+            showParameter.setHasRight(true);
+            showParameter.setIsolationOrg(false);
+            showParameter.setBillFormId("cas_paychgbill");
+            List<QFilter> qFilters = new ArrayList();
+            Set<Object> pks = new HashSet(paychgbill.length);
+            DynamicObject[] var8 = paychgbill;
+            int var9 = paychgbill.length;
+
+            for(int var10 = 0; var10 < var9; ++var10) {
+                DynamicObject targetBill = var8[var10];
+                pks.add(targetBill.get("id"));
+            }
+
+            qFilters.add(new QFilter("id", "in", pks));
+            showParameter.getListFilterParameter().setQFilters(qFilters);
+            showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
+            showParameter.setStatus(OperationStatus.VIEW);
+            showParameter.setShowFilter(false);
+            showParameter.setShowQuickFilter(false);
+            showParameter.setCustomParam("isshowtoolbarap", "no");
+            showParameter.setCustomParam("istmctracebillop", "yes");
+            this.getView().showForm(showParameter);
+        }
+
+    }
+
+    private void cancelPay() {
+        BillList billList = (BillList)this.getView().getControl("billlistap");
+        ListSelectedRowCollection selectedRows = billList.getSelectedRows();
+        if (selectedRows.size() <= 0) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择要执行的数据!", "PaymentBillList_0", "fi-cas-formplugin", new Object[0]));
+        } else {
+            List<Long> paymentBillPks = new LinkedList();
+            Iterator var4 = selectedRows.iterator();
+
+            while(var4.hasNext()) {
+                ListSelectedRow selectedRow = (ListSelectedRow)var4.next();
+                paymentBillPks.add((Long)selectedRow.getPrimaryKeyValue());
+            }
+
+            QFilter payPidFilter = new QFilter("id", "in", paymentBillPks);
+            DynamicObject[] payobjs = BusinessDataServiceHelper.load("nckd_cas_arbill", "id,billno,isvoucher,billstatus,org", new QFilter[]{payPidFilter});
+            StringBuilder sb = new StringBuilder();
+            int flag = 0;
+            DynamicObject[] var8 = payobjs;
+            int var9 = payobjs.length;
+
+            for(int var10 = 0; var10 < var9; ++var10) {
+                DynamicObject obj = var8[var10];
+                int CS114 = SystemParameterHelper.getParameterInteger(obj.getDynamicObject("org").getLong("id"), "cs116");
+                if (3 == CS114 && VoucherBookHelper.checkVoucherExist(obj.getPkValue(), "nckd_cas_arbill")) {
+                    ++flag;
+                    String billno = obj.getString("billno");
+                    sb.append(String.format(ResManager.loadKDString("(%s)单据已经生成凭证\r\n", "PaymentBillList_17", "fi-cas-formplugin", new Object[0]), billno));
+                }
+            }
+
+            if (flag == 1) {
+                this.getView().showConfirm(sb.substring(0, sb.length() - 1) + ResManager.loadKDString(",是否继续取消付款?", "PaymentBillList_18", "fi-cas-formplugin", new Object[0]), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_CANCELPAY_CALLBACK", this));
+            } else if (flag > 0) {
+                this.getView().showConfirm(String.format(ResManager.loadKDString("存在%d个已生成凭证的单据,是否继续取消付款?", "PaymentBillList_19", "fi-cas-formplugin", new Object[0]), flag), sb.toString(), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_CANCELPAY_CALLBACK", this));
+            } else if (!this.cancelPayCheckSettle(paymentBillPks, payobjs)) {
+                this.getView().invokeOperation("cancelpay");
+            }
+        }
+
+    }
+
+    private void chargeBack(List<Object> billid, String operateKey) {
+        FormShowParameter showParameter = new FormShowParameter();
+        showParameter.setFormId("cas_chargeback");
+        showParameter.setCustomParam("billid", JSON.toJSONString(billid));
+        showParameter.setCustomParam("operateKey", operateKey);
+        showParameter.getOpenStyle().setShowType(ShowType.NonModal);
+        showParameter.setCloseCallBack(new CloseCallBack(this, "CALLBACK_CHARGEBACK"));
+        this.getView().showForm(showParameter);
+    }
+
+    private Boolean cancelPayCheckSettle(List<Long> paymentBillPks, DynamicObject[] payobjs) {
+        Boolean result = Boolean.FALSE;
+        List<Long> mainBillIds = SettleRecordQueryHelperForCas.getBillIdsByMain("ap_settlerecord", "nckd_cas_arbill", paymentBillPks.toArray(), (QFilter)null);
+        List<Long> asstBillIds = SettleRecordQueryHelperForCas.getBillIdsByAsst("ap_settlerecord", "nckd_cas_arbill", paymentBillPks.toArray(), (QFilter)null);
+        Set<Long> settleRecordIds = new HashSet();
+        settleRecordIds.addAll(mainBillIds);
+        settleRecordIds.addAll(asstBillIds);
+        if (settleRecordIds.size() > 0) {
+            StringBuilder settleSb = new StringBuilder();
+            int settleFlag = 0;
+            DynamicObject[] var9 = payobjs;
+            int var10 = payobjs.length;
+
+            for(int var11 = 0; var11 < var10; ++var11) {
+                DynamicObject obj = var9[var11];
+                if (settleRecordIds.contains(obj.getPkValue())) {
+                    ++settleFlag;
+                    String billno = obj.getString("billno");
+                    settleSb.append(String.format(ResManager.loadKDString("(%s)单据已经完成结算\r\n", "PaymentBillList_28", "fi-cas-formplugin", new Object[0]), billno));
+                }
+            }
+
+            if (settleFlag == 1) {
+                this.getView().showConfirm(settleSb.substring(0, settleSb.length() - 1) + ResManager.loadKDString(",如果继续操作将会自动反结算对应的结算记录,是否继续?", "PaymentBillList_29", "fi-cas-formplugin", new Object[0]), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_CANCELPAY_SETTLE_CALLBACK", this));
+            } else if (settleFlag > 1) {
+                this.getView().showConfirm(String.format(ResManager.loadKDString("存在%d个已经完成结算的单据,如果继续操作将会自动反结算对应的结算记录,是否继续?", "PaymentBillList_30", "fi-cas-formplugin", new Object[0]), settleFlag), settleSb.toString(), MessageBoxOptions.YesNo, ConfirmTypes.Default, new ConfirmCallBackListener("CONFIRM_CANCELPAY_SETTLE_CALLBACK", this));
+            }
+
+            result = Boolean.TRUE;
+        }
+
+        return result;
+    }
+
+    private void viewDrafBill() {
+        BillList billList = (BillList)this.getControl("billlistap");
+        ListSelectedRowCollection selectedRows = billList.getSelectedRows();
+        Object[] selectedRowPks = selectedRows.getPrimaryKeyValues();
+        if (selectedRowPks.length == 0) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择要执行的数据!", "PaymentBillList_3", "fi-cas-formplugin", new Object[0]));
+        } else if (selectedRowPks.length > 1) {
+            this.getView().showTipNotification(ResManager.loadKDString("请选择单条数据联查!", "PaymentBillList_4", "fi-cas-formplugin", new Object[0]));
+        } else {
+            Object primaryKey = selectedRowPks[0];
+            DynamicObject paybill = BusinessDataServiceHelper.loadSingle(primaryKey, "nckd_cas_arbill", "id,draftbill");
+            DynamicObjectCollection draftBills = paybill.getDynamicObjectCollection("draftbill");
+            if (draftBills == null || draftBills.size() <= 0) {
+                this.getView().showTipNotification(ResManager.loadKDString("暂无关联的票据记录。", "PaymentBillDraftEditPlugin_9", "fi-cas-formplugin", new Object[0]));
+                return;
+            }
+
+            Set<Long> idSet = new HashSet();
+            Iterator var8 = draftBills.iterator();
+
+            while(var8.hasNext()) {
+                DynamicObject draftBill = (DynamicObject)var8.next();
+                idSet.add(((DynamicObject)draftBill.get("fbasedataid")).getLong("id"));
+            }
+
+            PayBillListPlugnHelper.viewDrafBill(idSet, this.getView());
+        }
+
+    }
+
+    private void viewBatchInput() {
+        FormShowParameter showPage = new FormShowParameter();
+        showPage.setFormId("cas_batchpaybill");
+        showPage.setAppId("cas");
+        showPage.setStatus(OperationStatus.EDIT);
+        showPage.getOpenStyle().setShowType(ShowType.Modal);
+        this.getView().showForm(showPage);
+    }
+
+    public void signCallback(SignCallbackEvent evt) {
+        if (evt.getCallbackId().equals("signbeforecommitbe")) {
+            ClientMethodResult ret = evt.getResult();
+            if (ret.getSuccess()) {
+                OperateOption operateOption = OperateOption.create();
+                operateOption.setVariableValue("ishasright", "true");
+                operateOption.setVariableValue("signCallbackFlag", "true");
+                operateOption.setVariableValue("signFirstSave", "false");
+                operateOption.setVariableValue("signResult", SerializationUtils.toJsonString(evt.getResult().getResult()));
+                operateOption.setVariableValue("clearResult", evt.getClearText());
+                OperationResult operationResult = this.getView().invokeOperation("beforecommitbe", operateOption);
+                if (operationResult.isSuccess()) {
+                    this.getView().invokeOperation("commitbe");
+                } else {
+                    logger.info(" signcallback fail ");
+                    if (EmptyUtil.isNoEmpty(operationResult.getMessage())) {
+                        evt.getView().showTipNotification(operationResult.getMessage());
+                    }
+                }
+            } else {
+                logger.info(" signbeforecommitbe SignCallbackEvent fail ");
+            }
+        }
+
+    }
+}

+ 2 - 2
src/main/java/fi/gl/business/VoucherValidator.java

@@ -21,7 +21,7 @@ public class VoucherValidator extends AbstractValidator {
         String oKey = this.getOperateKey();
         switch (oKey) {
             case "save":
-            case "tblantipost":
+            case "antipost":
             case "unaudit":
                 checkDatas();
                 break;
@@ -33,7 +33,7 @@ public class VoucherValidator extends AbstractValidator {
             DynamicObject bill = rowDataEntity.getDataEntity();
             DynamicObject org = (DynamicObject) bill.get("org");
             long orgId = org.getLong("id");
-            Date bizdate = bill.getDate("bizdate");
+            Date bizdate = bill.getDate("bookeddate");
             QFilter qFilter_org = new QFilter("nckd_org", QCP.equals,orgId);
             QFilter qFilter_bizdate = new QFilter("nckd_dailydate",QCP.equals,bizdate);
             DynamicObject[] dailybillCol = BusinessDataServiceHelper.load("nckd_gl_dailybill","id",

+ 16 - 9
src/main/java/fi/gl/formplugin/DailyexcuteFormPlugin.java

@@ -23,6 +23,7 @@ import kd.bos.servicehelper.BusinessDataServiceHelper;
 import kd.bos.servicehelper.operation.DeleteServiceHelper;
 import kd.bos.servicehelper.operation.SaveServiceHelper;
 import kd.bos.servicehelper.permission.PermissionServiceHelper;
+import kd.bos.servicehelper.user.UserServiceHelper;
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.*;
@@ -43,10 +44,10 @@ public class DailyexcuteFormPlugin extends AbstractBillPlugIn implements CellCli
     public void registerListener(EventObject e) {
         super.registerListener(e);
         this.addClickListeners(KEY_DAILY, KEY_UNDAILY);
-
+        //注册分录监听
         EntryGrid entryGrid = this.getView().getControl("nckd_entryentity");
         entryGrid.addCellClickListener(this);
-
+        //注册组织字段监听
         BasedataEdit bEdit = this.getView().getControl("nckd_org");
         bEdit.addBeforeF7SelectListener(this);
     }
@@ -71,7 +72,7 @@ public class DailyexcuteFormPlugin extends AbstractBillPlugIn implements CellCli
 
             //先清空分录
             this.getModel().deleteEntryData("nckd_entryentity");
-
+            //执行写入日结表
             String message = dailyData(orgCol,dailydate);
             this.getView().showMessage(message);
         }else if (StringUtils.equals(source.getKey(), KEY_UNDAILY)) {
@@ -86,7 +87,7 @@ public class DailyexcuteFormPlugin extends AbstractBillPlugIn implements CellCli
                 this.getView().showMessage("请先选择日期");
                 return;
             }
-
+            //执行删除日结表记录
             String message = unDailyData(orgCol,dailydate);
             this.getView().showMessage(message);
         }
@@ -182,8 +183,8 @@ public class DailyexcuteFormPlugin extends AbstractBillPlugIn implements CellCli
             dailybillObj.set("nckd_dailydate", dailydate);
             dailybillObj.set("status", "A");
             dailybillObj.set("enable", "1");
-            RequestContext rc = RequestContext.get();
-            dailybillObj.set("creator", rc.getUid());
+            Long userId = UserServiceHelper.getCurrentUserId();
+            dailybillObj.set("creator", userId);
             DynamicObject[] datalist = new DynamicObject[]{dailybillObj};
             SaveServiceHelper.save(datalist);
             messageInfo = orgObjReal.getString("name") + "日结成功;";
@@ -195,6 +196,7 @@ public class DailyexcuteFormPlugin extends AbstractBillPlugIn implements CellCli
 
     @Override
     public void cellClick(CellClickEvent cellClickEvent) {
+        //点击跳转凭证界面
         BillShowParameter billShowParameter = new BillShowParameter();
         billShowParameter.getOpenStyle().setShowType(ShowType.Modal);
         billShowParameter.setFormId("gl_voucher");
@@ -216,9 +218,14 @@ public class DailyexcuteFormPlugin extends AbstractBillPlugIn implements CellCli
             ListShowParameter formShowParameter = (ListShowParameter) beforeF7SelectEvent.getFormShowParameter();
             List<QFilter> qFilters = new ArrayList<>();
             HasPermOrgResult userHasPermOrgs = PermissionServiceHelper.getUserHasPermOrgs(Long.parseLong(RequestContext.get().getUserId()));
-            List<Long> hasPermOrgs = userHasPermOrgs.getHasPermOrgs();
-            qFilters.add(new QFilter("id", QCP.in, hasPermOrgs));
-            formShowParameter.getListFilterParameter().setQFilters(qFilters);
+            boolean hasallOrg = userHasPermOrgs.hasAllOrgPerm();
+            if(hasallOrg==false){
+                List<Long> hasPermOrgs = userHasPermOrgs.getHasPermOrgs();
+                qFilters.add(new QFilter("id", QCP.in, hasPermOrgs));
+                formShowParameter.getListFilterParameter().setQFilters(qFilters);
+            }
         }
+
+
     }
 }

+ 87 - 5
src/main/java/fi/gl/task/AutoDailTask.java

@@ -2,17 +2,21 @@ package fi.gl.task;
 
 import kd.bos.context.RequestContext;
 import kd.bos.dataentity.entity.DynamicObject;
-import kd.bos.dataentity.entity.DynamicObjectCollection;
 import kd.bos.entity.AppInfo;
 import kd.bos.entity.AppMetadataCache;
 import kd.bos.entity.param.AppParam;
 import kd.bos.exception.KDException;
 import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
+import kd.bos.schedule.api.TaskInfo;
 import kd.bos.schedule.executor.AbstractTask;
 import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.bos.servicehelper.operation.SaveServiceHelper;
 import kd.bos.servicehelper.parameter.SystemParamServiceHelper;
+import kd.bos.servicehelper.schedule.ScheduleServiceHelper;
+import kd.bos.servicehelper.user.UserServiceHelper;
 
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Map;
@@ -25,12 +29,26 @@ import java.util.Map;
 public class AutoDailTask extends AbstractTask {
     @Override
     public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
-        System.out.println("打印日志测试:" + df.format(new Date()));// new Date()为获取当前系统时间
+        TaskInfo taskInfo = ScheduleServiceHelper.queryTask(this.taskId);
+        String scheduleId = taskInfo.getScheduleId();
+        DynamicObject schedule = BusinessDataServiceHelper.loadSingleFromCache(scheduleId,"sch_schedule");
+        DynamicObject schprincipal = schedule.getDynamicObject("schprincipal");
+        Long userId = schprincipal.getLong("id");
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String now = sdf.format(new Date());
+        Date nowDate = null;
+        try {
+            nowDate = sdf.parse(now);
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
         QFilter qFilter_enable = new QFilter("enable", QCP.equals,"1");
         QFilter qFilter_status = new QFilter("status", QCP.equals, "C");
+        QFilter qFilter_fisaccounting = new QFilter("fisaccounting", QCP.equals, "1");
+        QFilter qFilter_number = new QFilter("number", QCP.equals, "A002");
         DynamicObject[] orgCol = BusinessDataServiceHelper.load("bos_org","id",
-                new QFilter[]{qFilter_enable,qFilter_status});
+                new QFilter[]{qFilter_enable,qFilter_status,qFilter_fisaccounting,qFilter_number});
         for(DynamicObject orgObj : orgCol){
             //根据应用编码从缓存中获取应用信息
             AppInfo cgfwAppInfo = AppMetadataCache.getAppInfo("gl");
@@ -41,9 +59,73 @@ public class AutoDailTask extends AbstractTask {
             apm.setOrgId(orgObj.getLong("id"));
             Map<String,Object> paramWhole = SystemParamServiceHelper.loadAppParameterFromCache(apm);
             Object nckd_isautodaily = paramWhole.get("nckd_isautodaily");
-            if("true".equals(nckd_isautodaily)){
+            if("true".equals(nckd_isautodaily.toString())){
+                dailyData(orgObj,nowDate,userId);
+            }
+        }
+    }
+
+    private void dailyData(DynamicObject org, Date dailydate, Long userId) {
+        //创建日志对象
+        DynamicObject dailybillLogObj = BusinessDataServiceHelper.newDynamicObject("nckd_gl_autodaillog");
+
+        String messageInfo = "";
+        QFilter qFilter_org = new QFilter("org", QCP.equals,org.getPkValue());
+        QFilter qFilter_bizdate = new QFilter("bizdate",QCP.equals,dailydate);
+        DynamicObject[] voucherCol = BusinessDataServiceHelper.load("gl_voucher","id,ispost,billno,bizdate,org,billstatus",
+                new QFilter[]{qFilter_org,qFilter_bizdate});
+        for(DynamicObject voucherObj : voucherCol){
+            boolean ispost = voucherObj.getBoolean("ispost");
+            if(ispost!=true){//是否过账等于否
+                messageInfo = "所选日期存在未过账凭证";
+                break;
+            }
+        }
 
+        if("".equals(messageInfo)){
+            QFilter qFilter_nckd_org = new QFilter("nckd_org", QCP.equals,org.getPkValue());
+            QFilter qFilter_nckd_dailydate = new QFilter("nckd_dailydate",QCP.equals,dailydate);
+            DynamicObject[] dailybillCol = BusinessDataServiceHelper.load("nckd_gl_dailybill","id",
+                    new QFilter[]{qFilter_nckd_org,qFilter_nckd_dailydate});
+            if(dailybillCol!=null && dailybillCol.length>0){
+                messageInfo = "所选日期已日结";
             }
         }
+
+        if("".equals(messageInfo)){
+            //写入日结记录
+            messageInfo = writeDailybill(org,dailydate,userId);
+        }
+
+        //写入日志
+        dailybillLogObj.set("nckd_orgfield",org.getPkValue());
+        dailybillLogObj.set("nckd_dailydate",dailydate);
+        dailybillLogObj.set("enable","1");
+        dailybillLogObj.set("status","C");
+        if("".equals(messageInfo)){
+            dailybillLogObj.set("nckd_dailstatus","0");
+        }else{
+            dailybillLogObj.set("nckd_dailstatus","1");
+            dailybillLogObj.set("nckd_errorinfo",messageInfo);
+        }
+        DynamicObject[] logDatalist = new DynamicObject[]{dailybillLogObj};
+        SaveServiceHelper.save(logDatalist);
+    }
+
+    private String writeDailybill(DynamicObject orgObjReal, Date dailydate, Long userId) {
+        String messageInfo = "";
+        try {
+            DynamicObject dailybillObj = BusinessDataServiceHelper.newDynamicObject("nckd_gl_dailybill");
+            dailybillObj.set("nckd_org", orgObjReal);
+            dailybillObj.set("nckd_dailydate", dailydate);
+            dailybillObj.set("status", "A");
+            dailybillObj.set("enable", "1");
+            dailybillObj.set("creator", userId);
+            DynamicObject[] datalist = new DynamicObject[]{dailybillObj};
+            SaveServiceHelper.save(datalist);
+        }catch(Exception e){
+            messageInfo = e.getMessage();
+        }
+        return messageInfo;
     }
 }