zoukankan      html  css  js  c++  java
  • 获取接口

    package com.qhyf.app.bl.controller;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import com.jfinal.core.ActionKey;
    import com.jfinal.core.action.Rest;
    import com.jfinal.core.pojo.RestMethod;
    import com.qhyf.app.bl.base.controller.QhyfController;
    
    import club.newepoch.persistent.db.common.Db;
    import club.newepoch.persistent.db.pojo.Record;
    import club.newepoch.utils.StringUtils;
    import net.sf.json.JSONArray;
    import net.sf.json.JSONObject;
    
    
    
    /**
     * 获取保理付确认书信息的接口
     *
     * @author lx
     */
    public class InterfaceFactoringPayConfirmationController extends QhyfController {
        /**
         * 获取付款确认书的信息
         */
        @Rest(method = RestMethod.POST)
        @ActionKey("/api/qhyf/paycomfirm/info/")
        public void PayConfirmationInformation() {
            //返回json数据
            JSONObject returnJson = new JSONObject();
            JSONArray data = new JSONArray();
            //存发票号
            JSONArray invoiceNodata = new JSONArray();
    
            // 数据校验是否成功标识
            boolean checkFlag = true;
            StringBuffer errmsgSb = new StringBuffer();
            try {
                //获取金融机构
                String financialInstitutionsId = this.getPara("financial_institutions_id");
                //获取期数
                String period = this.getPara("periods");
                // 获取付款确认书编号
                String payNo = this.getPara("pay_code");
    
                // 当payId 为空,核心企业,期数,金融机构不能为空
                if (StringUtils.isBlank(payNo)) {
                    if (StringUtils.isBlank(financialInstitutionsId)) {
                        errmsgSb.append("金融机构不能为空;");
                        //缺少参数
                        returnJson.put("errcode", "3001");
                        checkFlag = false;
                    }  
                    if (StringUtils.isBlank(period)) {
                        errmsgSb.append("期数不能为空;");
                        //缺少参数
                        returnJson.put("errcode", "3001");
                        checkFlag = false;
                    }
                }
                // 期数存在的情况下,校验期数是否为数值
                if (StringUtils.notBlank(period) && !checkPeriods(period.toString())){
                    errmsgSb.append("期数参数值不合法");
                    returnJson.put("errcode", "3002");
                    checkFlag = false;
                }
                // 校验通过
                if (checkFlag) {
                    // 构造查询sql
                    String sql = "SELECT  " +
                            "  a.uuid,   " +
                            "  a.pay_id ,  " +     // 付款确认书编号
                            "  b.core_enterprise_name ,    " + // 核心企业名字
                            "  a.financial_institutions_id ,    " + //金融机构id
                            "  c.financial_institutions_name ,   " + //金融机构名称  
                            "  d.sign_body_name ,    " + // 原始权益人
                            "  a.periods,   " + // 期数
                            "  e.suppliers_name,    " +  // 供应商名称
                            "  a.suppliers_account,   " +  // 供应商账号
                            "  a.open_account_bank,  " + // 供应商开户行 
                            "  a.account_name,   " + // 账号名称
                            "  a.suppliers_rate_biz,   " + // 供应商利率(业务)
                            "  f.item_company_name,   " +  // 项目公司名称
                            "  a.loan_date,   " + // 实际放款日期(供应商)
                            "  a.account_receivable,  " +  // 应收账款金额
                            "  a.due_date, " +  // 应收账款到期日
                            "  a.suppliers_money,      " + // 供应商放款金额
                            "  a.contract_type,   " + // 合同类型
                            "  a.pay_priority,   " + // 是否加急
                            "  a.item_name ,    " + // 项目名称
                            "  a.transfer_apply_date,   " +  // 提单日
                            "  g.region_name,   " +  // 区域
                            "  h.contract_name,   " + // 合同名称
                            "  a.base_contract_name,   " + // 商务合同名称
                            "  a.base_contract_no ,   " +  // 商务合同编号
                            "  l.large_region_name "  +
                            "FROM  " +
                            "    biz_pay_comfirm_info a ,   " +
                            "    biz_core_enterprise b,   " +
                            "    biz_financial_institutions c,   " +
                            "    biz_signing_body d,   " +
                            "    biz_suppliers e,   " +
                            "    biz_item_company f,   " +
                            "    biz_contract_info h,   " +
                            "  biz_item_region g   " +
                            "  LEFT JOIN biz_large_region_mapping  k  on g.uuid = k.item_region_uuid  and k.sys_status = 1 " +
                            "  LEFT JOIN biz_large_region l on k.large_region_uuid = l.uuid  and l.sys_status = 1 " +
                            "  WHERE  " +
                            "    a.core_enterprise_id = b.uuid  " +
                            "AND a.financial_institutions_id = c.uuid  " +
                            "AND a.signing_body_id = d.uuid  " +
                            "AND a.suppliers_id = e.uuid  " +
                            "AND a.item_company_id = f.uuid  " +
                            "AND f.region_id = g.uuid  " +
                            "AND a.contract_id =  h.uuid   " +
                            "AND a.sys_status = 1  " +
                            "AND b.sys_status = 1  " +
                            "AND c.sys_status = 1  " +
                            "AND d.sys_status = 1  " +
                            "AND f.sys_status = 1  " +
                            "AND g.sys_status = 1  " +
                            "AND h.sys_status = 1  " ;
    
                    // where条件
                    String where = "";
                    List<String> paras = new ArrayList<String>();
    
                    // 金融机构类型不为空时新增查询条件
                    if (StringUtils.notBlank(financialInstitutionsId)) {
                        where += "and a.financial_institutions_id  = ? ";
                        paras.add(financialInstitutionsId);
                    }
                    // 期数不为空时新增查询条件
                    if (StringUtils.notBlank(period)) {
                        where += "and a.periods = ? ";
                        paras.add(period);
                    }
                    // 付款确认书编号不为空时新增查询条件
                    if (StringUtils.notBlank(payNo)) {
                        where += "and a.pay_id = ? ";
                        paras.add(payNo);
                    }
                    List<Record> payConfirmationrecordList = Db.find(sql + where, paras.toArray());
                    // 当查询结果不为空时
                    if (!payConfirmationrecordList.isEmpty()) {
                        for (Record rd : payConfirmationrecordList) {
    
                            JSONObject json = new JSONObject();
                            //核心企业
                            json.put("core_enterprise_name", rd.get("coreEnterpriseName"));
                            // 金融机构id
                            json.put("financial_institutions_id", rd.get("financialInstitutionsId"));
                            // 金融机构名称
                            json.put("financial_institutions_name", rd.get("financialInstitutionsName"));
                            // 签约主体
                            json.put("signing_body_name", rd.get("signBodyName"));
                            // 期数
                            json.put("periods", rd.get("periods"));
                            // 付款确认书编号
                            json.put("pay_code", rd.get("payId"));
                            // 供应商名称
                            json.put("suppliers_name", rd.get("suppliersName"));
                            // 供应商账号
                            json.put("suppliers_account", rd.get("suppliersAccount"));
                            // 供应商开户行
                            json.put("open_account_bank", rd.get("openAccountBank"));
                            // 账号名称
                            json.put("account_name", rd.get("accountName"));
                            // 供应商利率(业务)
                            json.put("suppliers_rate_biz", rd.get("suppliersRateBiz"));
                            // 项目公司名称
                            json.put("item_company_name", rd.get("itemCompanyName"));
                            // 放款时间
                            json.put("loan_date", rd.get("loanDate")==null? "" : rd.get("loanDate").toString());
                            // 应收账款金额
                            json.put("accounts_receivable", rd.get("accountReceivable"));
                            // 应收账款到期日
                            json.put("due_date", rd.get("dueDate")==null? "" : rd.get("dueDate").toString());
                            // 放款金额
                            json.put("loan_amount", rd.get("suppliersMoney"));
                            // 类型(工程 贸易)
                            json.put("contract_type", rd.get("contractType"));
                            // 是否加急(0:是不加急 ,1是加急)
                            json.put("urgent", rd.get("payPriority") == "0" ? 0:1);
    
                            // 是否自垫付
                            String selfAdvanceSql = "SELECT uuid from biz_own_funds_loan_registe WHERE pay_id = ? and sys_status = 1 " ;
                            //获取当前单是否为自垫付
                            String selfAdvance = Db.queryStr(selfAdvanceSql, rd.getStr("uuid")) ;
                            // 数据为空 ,则不存在 ,不是自垫付
                            if (StringUtils.isBlank(selfAdvance)){
                                // 不是自垫付,设置为 0
                                json.put("self_advance", 0);
                            }else {
                                // 是自垫付,设置为 1
                                json.put("self_advance", 1);
                            }
                            
                            //查询是否退单
                            String chargebackSql= "SELECT  " +
                                    "        pay_id  " +
                                    "    FROM  " +
                                    "        biz_rollback_pay  " +
                                    "    WHERE  " +
                                    "        sys_status = 1  " +
                                    "    AND biz_state <> 15   " +
                                    "and pay_id = ? " ;
                            //获取当前单是否为急单
                            String chargeback = Db.queryStr(chargebackSql, rd.getStr("uuid")) ;
                            // 是否退单
                            // 数据为空 ,则不存在 ,不是退单
                            if (StringUtils.isBlank(chargeback)){
                                // 不是退单,设置为 0
                                json.put("ifs_rollback", 0);
                            }else {
                                // 是退单,设置为 1
                                json.put("ifs_rollback", 1);
                            }
                            // 提单日
                            json.put("bl_date", rd.get("transferApplyDate") == null? "" : rd.get("transferApplyDate").toString());
    
                            // 区域(指:项目公司区域)
                            json.put("region_name", rd.get("regionName"));
                            // 合同名称
                            json.put("contract_name", rd.get("contractName"));
                            // 商务合同名称
                            json.put("base_contract_name", rd.get("baseContractName"));
                            // 商务合同编号
                            json.put("base_contract_no", rd.get("baseContractNo"));
                            // 大区域
                            json.put("large_region_name", rd.get("largeRegionName"));
                            
                            //查询 发票号
                            String invoiceNoSql = "SELECT  " +
                                    "        h.invoice_no  " +
                                    "    FROM  " +
                                    "        biz_invoice_info h  " +
                                    "    WHERE  " +
                                    " h.sys_status = 1" +
                                    " AND h.pay_id = ? ";
                            //获取发票号
                            List<Record> invoiceNoList = Db.find(invoiceNoSql, rd.getStr("uuid"));
                            // 发票号
                            for (Record invoiceNo : invoiceNoList) {
                                JSONObject invoiceNoJson = new JSONObject();
                                invoiceNoJson.put("invoiceNo", invoiceNo.get("invoiceNo"));
                                invoiceNodata.add(invoiceNoJson);
                            }
                            json.put("invoiceList", invoiceNodata);
                            // 将json加进响应体
                            data.add(json);
                        }
                        returnJson.put("errcode", "0");
                        returnJson.put("errmsg", "");
                    } else {
                        returnJson.put("errcode", "3003");
                        returnJson.put("errmsg", "未获取到付款确认书信息,请检查请求参数是否正确");
                    }
                } else {
                    //校验不通过
                    returnJson.put("errmsg", errmsgSb.toString());
                }
                returnJson.put("data", data);
            } catch (Exception e) {
                // 异常处理
                returnJson.put("errcode", "9999");
                returnJson.put("errmsg", "内部服务处理异常!");
                returnJson.put("data", data);
            }
            //返回结果
            this.renderJson(returnJson);
        }
    
        /**
         * 期数校验
         * @param param 需要校验的参数
         * @return isCheckThrough 是否满足校验规则
         */
        private boolean checkPeriods(String param) {
            return StringUtils.matchRegex(param, "^\d+$");
        }
    }
  • 相关阅读:
    Django —— DateTimeField格式
    Django——权限组件(中间件判断用户权限--URL初级)
    linux命令
    性能测试--测试分类
    web安全之csrf攻击
    web安全之xss攻击
    测试用例规范
    禅道操作手册
    fiddler弱网测试
    Web测试系列之测试工具
  • 原文地址:https://www.cnblogs.com/xiaoniuniu886/p/10932919.html
Copyright © 2011-2022 走看看