• 写法


        /**
         * 如果号码相邻的发票号码没有用“-”连接,就修改为“-”连接
         * @param controller
         * @return 发票说明
         * @throws ActiveRecordException
         */
        private static String createInvoiceDescription(String payUuid) throws ActiveRecordException {
            // 查询发票号码
            String selSql = String.format(
                    "select invoice_no from %s where draft_id=? and sys_status=%s order by invoice_no asc",
                    BizInvoiceDraft.dao.getTable().getName(), BlConstant.SYS_STATUS_VALUE);
            // db查询
            List<Record> records = Db.find(selSql, payUuid);
            BigDecimal b1 = null;
            BigDecimal b2 = null;
            if (records.size() == 0) {
                // 没有发票信息,发票说明为空
                return "";
            } else if (records.size() == 1) {
                // 只有一条发票信息
                return records.get(0).get("invoiceNo");
            } else if (records.size() == 2) {
                // 只有两条发票信息
                b1 = new BigDecimal(records.get(0).get("invoiceNo").toString());
                b2 = new BigDecimal(records.get(1).get("invoiceNo").toString());
                // 判断发票号码是否相邻
                if (b2.compareTo(b1.add(new BigDecimal(1))) == 0) {
                    // 相邻
                    return records.get(0).get("invoiceNo").toString() + "-" + records.get(1).get("invoiceNo").toString();
                } else {
                    // 不相邻
                    return records.get(0).get("invoiceNo").toString() + "," + records.get(1).get("invoiceNo").toString();
                }
            } else {
                // 发票信息记录数大于2
                String tmpRtnStr = records.get(0).get("invoiceNo");
                String rtnStr = "";
                for (int i = 1; i < records.size(); i++) {
                    b1 = new BigDecimal(records.get(i - 1).get("invoiceNo").toString());
                    b2 = new BigDecimal(records.get(i).get("invoiceNo").toString());
                    if (b2.compareTo(b1.add(new BigDecimal("1"))) == 0) {
                        // 当前两个发票号码相邻
                    } else {
                        // 当前两个发票号码不相邻
                        if (new BigDecimal(tmpRtnStr)
                                .compareTo(new BigDecimal(records.get(i - 1).get("invoiceNo").toString())) == 0) {
                            rtnStr = rtnStr + records.get(i - 1).get("invoiceNo").toString() + ",";
                        } else {
                            tmpRtnStr = tmpRtnStr + "-" + records.get(i - 1).get("invoiceNo").toString();
                            rtnStr = rtnStr + tmpRtnStr + ",";
                        }
    
                        tmpRtnStr = records.get(i).get("invoiceNo").toString();
                    }
                    if (i == records.size() - 1) {
                        if ((new BigDecimal(tmpRtnStr))
                                .compareTo(new BigDecimal(records.get(i).get("invoiceNo").toString())) == 0) {
    
                        } else {
                            tmpRtnStr += "-" + records.get(i).get("invoiceNo").toString();
                        }
                        rtnStr = rtnStr + tmpRtnStr + ",";
                    }
                }
                return rtnStr.substring(0, rtnStr.length() - 1);
            }
    
        }
    if (!duplicatedPayIds.isEmpty()) {
                        // 记录校验不通过
                        isCheckPass = false;
                        // comment
                        String comment = "该付款确认书的BIP编码与";
                        int countNum = 0;
                        for (Record r : duplicatedPayIds) {
                            if (0 < countNum) {
                                comment += "、";
                            }
                            comment += r.getStr("payId");
                            countNum ++;
                        }
                        comment += "的BIP编码重复;";
                        // 数据校验不通过
                        bizPayComfirmDraftErrorStr.append(comment);
                    }
  • 相关阅读:
    脚本(js)控制页面输入
    Javascript小技巧(6)
    解析 XML
    防止用户不输入正确用户名,密码登陆
    Javascript小技巧(5)
    自己想了一下为什么在ajax方法里找不到服务器控件
    Javascript小技巧(4)
    C#后台绑事件 和前台js方法
    Community Server专题九:MemberRole之Profile(转载)
    Community Server专题六:Delegates & Events(转载)
  • 原文地址:https://www.cnblogs.com/xiaoniuniu886/p/10979432.html
Copyright © 2020-2023  润新知