Search in sources :

Example 21 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class ExtraBillReceiptController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    // 管理员项目权限
    Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
    List<Long> projectsOfAdminList = Arrays.asList(projectsOfAdmin);
    ExtraBillExample billExample = new ExtraBillExample();
    ExtraBillExample.Criteria criteria = billExample.or();
    criteria.andIdEqualTo(id);
    criteria.andProjectIn(projectsOfAdminList);
    ExtraBill bill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByExample", billExample);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "未找到该订单");
        return "status403";
    }
    uiModel.addAttribute("bill", bill);
    // 项目
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
    uiModel.addAttribute("project", project);
    // 企业
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    uiModel.addAttribute("enterprise", enterprise);
    // 产品
    ExtraProduct product = sqlSession.selectOne("com.itrus.portal.db.ExtraProductMapper.selectByPrimaryKey", bill.getExtraProduct());
    uiModel.addAttribute("product", product);
    // 规格
    ExtraProductSpec productSpec = sqlSession.selectOne("com.itrus.portal.db.ExtraProductSpecMapper.selectByPrimaryKey", bill.getExtraProductSpec());
    uiModel.addAttribute("productSpec", productSpec);
    // 服务商
    ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(product.getServiceProvider());
    uiModel.addAttribute("serviceProvider", serviceProvider);
    // 用户
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    uiModel.addAttribute("userInfo", userInfo);
    // 第三方支付信息
    OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
    uiModel.addAttribute("onPayInfo", onPayInfo);
    // 电子发票
    Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
    uiModel.addAttribute("einvoice", einvoice);
    if (einvoice != null && einvoice.geteReiceipt() != null) {
        // 电子发票类型
        Ereceipt ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", einvoice.geteReiceipt());
        uiModel.addAttribute("ereceipt", ereceipt);
    }
    // 其他附加信息
    // 营业执照
    BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
    uiModel.addAttribute("businessLicense", businessLicense);
    // 税务登记
    TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
    uiModel.addAttribute("taxRegisterCert", taxRegisterCert);
    // 组织机构代码
    OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
    uiModel.addAttribute("orgCode", orgCode);
    // 代理人
    Agent agent = agentService.getAgentByExtraBillId(id, null);
    uiModel.addAttribute("agent", agent);
    // 开户行信息
    OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
    uiModel.addAttribute("openBankInfo", openBankInfo);
    // 法人信息
    IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
    uiModel.addAttribute("identityCard", identityCard);
    // TODO 还需要补充订单对应的附加信息和第三方回调信息
    return "extrabillreceipt/show";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) Agent(com.itrus.portal.db.Agent) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) Einvoice(com.itrus.portal.db.Einvoice) ExtraBillExample(com.itrus.portal.db.ExtraBillExample) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) OnPayInfo(com.itrus.portal.db.OnPayInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) ServiceProvider(com.itrus.portal.db.ServiceProvider) Enterprise(com.itrus.portal.db.Enterprise) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 22 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class ExtraBillReviewController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    // 管理员项目权限
    Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
    List<Long> projectsOfAdminList = Arrays.asList(projectsOfAdmin);
    ExtraBillExample billExample = new ExtraBillExample();
    ExtraBillExample.Criteria criteria = billExample.or();
    criteria.andIdEqualTo(id);
    criteria.andProjectIn(projectsOfAdminList);
    ExtraBill bill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByExample", billExample);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "未找到该订单");
        return "status403";
    }
    uiModel.addAttribute("bill", bill);
    // 项目
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
    uiModel.addAttribute("project", project);
    // 企业
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    uiModel.addAttribute("enterprise", enterprise);
    // 产品
    ExtraProduct product = sqlSession.selectOne("com.itrus.portal.db.ExtraProductMapper.selectByPrimaryKey", bill.getExtraProduct());
    uiModel.addAttribute("product", product);
    // 规格
    ExtraProductSpec productSpec = sqlSession.selectOne("com.itrus.portal.db.ExtraProductSpecMapper.selectByPrimaryKey", bill.getExtraProductSpec());
    uiModel.addAttribute("productSpec", productSpec);
    // 服务商
    ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(product.getServiceProvider());
    uiModel.addAttribute("serviceProvider", serviceProvider);
    // 用户
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    uiModel.addAttribute("userInfo", userInfo);
    // 第三方支付信息
    OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
    uiModel.addAttribute("onPayInfo", onPayInfo);
    // 电子发票
    Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
    uiModel.addAttribute("einvoice", einvoice);
    // 其他附加信息
    // 营业执照
    BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
    uiModel.addAttribute("businessLicense", businessLicense);
    // 税务登记
    TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
    uiModel.addAttribute("taxRegisterCert", taxRegisterCert);
    // 组织机构代码
    OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
    uiModel.addAttribute("orgCode", orgCode);
    // 代理人
    Agent agent = agentService.getAgentByExtraBillId(id, null);
    uiModel.addAttribute("agent", agent);
    // 开户行信息
    OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
    uiModel.addAttribute("openBankInfo", openBankInfo);
    // 法人信息
    IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
    uiModel.addAttribute("identityCard", identityCard);
    // TODO 还需要补充订单对应的附加信息和第三方回调信息
    return "extrabillreview/show";
}
Also used : Agent(com.itrus.portal.db.Agent) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) Einvoice(com.itrus.portal.db.Einvoice) ExtraBillExample(com.itrus.portal.db.ExtraBillExample) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) OnPayInfo(com.itrus.portal.db.OnPayInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) ServiceProvider(com.itrus.portal.db.ServiceProvider) Enterprise(com.itrus.portal.db.Enterprise) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 23 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class BillServiceImpl method excelCertData.

/**
 * 导入的内容
 *
 * @return
 */
public ArrayList<ArrayList<String>> excelCertData(List<Map> bills) {
    // 数据集
    ArrayList<ArrayList<String>> fieldDatas = new ArrayList<ArrayList<String>>();
    for (int i = 0; i < bills.size(); i++) {
        // 单行数据集
        ArrayList<String> rowData = new ArrayList<String>();
        String sn = null;
        String licenseNo = null;
        // 电子发票加购买方纳税人识别号字段 值是五证合一的统一社会信用代码或税务登记号 by zhanghongliu on 20170531
        BusinessLicense businessLicense = businessService.getBusinessByBillId(Long.parseLong(String.valueOf(bills.get(i).get("id"))), null);
        if (businessLicense != null && businessLicense.getBusinessType() == 1) {
            sn = businessLicense.getLicenseNo();
            licenseNo = businessLicense.getLicenseNo();
        }
        if (businessLicense == null || businessLicense.getBusinessType() != 1) {
            // 不是五证合一
            TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId(Long.parseLong(String.valueOf(bills.get(i).get("id"))), null);
            if (tc != null) {
                sn = tc.getCertNo();
            }
        }
        if (businessLicense == null || businessLicense.getBusinessType() != 1) {
            // 不是五证合一
            OrgCode oc = orgCodeService.getOrgCodeByBillId(Long.parseLong(String.valueOf(bills.get(i).get("id"))), null);
            if (oc != null) {
                licenseNo = oc.getOrgCode();
            }
        }
        if (bills.get(i).get("pname") == null) {
            rowData.add("-");
        } else {
            // 项目名称
            rowData.add(bills.get(i).get("pname").toString());
        }
        if (bills.get(i).get("bill_id") == null) {
            rowData.add("-");
        } else {
            // 订单id
            rowData.add(bills.get(i).get("bill_id").toString());
        }
        if (bills.get(i).get("enterprise_name") == null) {
            rowData.add("-");
        } else {
            // 企业名称
            rowData.add(bills.get(i).get("enterprise_name").toString());
        }
        if (sn == null) {
            rowData.add("-");
        } else {
            // 纳税人识别号
            rowData.add(sn);
        }
        if (sn == null) {
            rowData.add("-");
        } else {
            // 统一社会信用代码
            rowData.add(licenseNo);
        }
        // 代理人姓名
        if (bills.get(i).get("real_name") == null) {
            rowData.add("-");
        } else {
            rowData.add(bills.get(i).get("real_name").toString());
        }
        if (bills.get(i).get("m_phone") == null) {
            rowData.add("-");
        } else {
            // 手机
            rowData.add(bills.get(i).get("m_phone").toString());
        }
        if (bills.get(i).get("email") == null) {
            rowData.add("-");
        } else {
            // 邮箱
            rowData.add(bills.get(i).get("email").toString());
        }
        if (bills.get(i).get("create_time") == null) {
            rowData.add("-");
        } else {
            // 下单时间
            rowData.add(bills.get(i).get("create_time").toString());
        }
        if (bills.get(i).get("prdname") == null) {
            rowData.add("-");
        } else {
            // 产品名称
            rowData.add(bills.get(i).get("prdname").toString());
        }
        if (bills.get(i).get("bill_sum") == null) {
            rowData.add("-");
        } else {
            // 订单金额
            rowData.add(bills.get(i).get("bill_sum").toString());
        }
        if (bills.get(i).get("bill_status") == null) {
            rowData.add("-");
        } else {
            // 订单状态
            int t = Integer.parseInt(bills.get(i).get("bill_status").toString());
            switch(t) {
                case 1:
                    rowData.add("待支付");
                    break;
                case 2:
                    rowData.add("支付待确认");
                    break;
                case 3:
                    rowData.add("已支付,待审核");
                    break;
                case 4:
                    rowData.add("审核拒绝");
                    break;
                case 5:
                    rowData.add("已审核,待制证");
                    break;
                case 6:
                    rowData.add("已制证,待开票");
                    break;
                case 7:
                    rowData.add("已开票,待配送");
                    break;
                case 8:
                    rowData.add("已完成");
                    ;
                    break;
                case 9:
                    rowData.add("已撤销");
                    ;
                    break;
                case 10:
                    rowData.add("送审中");
                    ;
                    break;
                case 11:
                    rowData.add("支付异常");
                    ;
                    break;
                case 12:
                    rowData.add("待更新证书");
                    ;
                    break;
                case 13:
                    rowData.add("待下载");
                    ;
                    break;
                case 14:
                    rowData.add("已支付,待审批");
                    ;
                    break;
                case 15:
                    rowData.add("解锁审批拒绝");
                    ;
                    break;
                case 16:
                    rowData.add("审批通过,待解锁");
                    ;
                    break;
                case 17:
                    rowData.add("解锁异常");
                    ;
                    break;
                case 18:
                    rowData.add("已解锁,待开票");
                    ;
                    break;
                default:
                    break;
            }
        }
        if (bills.get(i).get("uid") == null) {
            rowData.add("-");
        } else {
            String dn = bills.get(i).get("uid").toString();
            String ADDTIONAL_FIELD1_1 = "";
            String ADDTIONAL_FIELD2_1 = "";
            String ADDTIONAL_FIELD3_1 = "";
            String userAdditionalField2 = null;
            String[] dns = dn.split(",");
            for (int s = 0; s < dns.length; s++) {
                // System.out.println(dns[s]);
                if (dns[s].contains("ADDTIONAL_FIELD1_1")) {
                    ADDTIONAL_FIELD1_1 = dns[s];
                }
                if (dns[s].contains("ADDTIONAL_FIELD2_1")) {
                    ADDTIONAL_FIELD2_1 = dns[s];
                }
                if (dns[s].contains("ADDTIONAL_FIELD3_1")) {
                    ADDTIONAL_FIELD3_1 = dns[s];
                }
                if (dns[s].contains("userAdditionalField2_1")) {
                    userAdditionalField2 = dns[s];
                }
            }
            String cns = "";
            String address = "";
            String businessPlace = "";
            String place = "";
            String userAdditional2 = null;
            String uad2 = null;
            if (ADDTIONAL_FIELD1_1 != null) {
                if (ADDTIONAL_FIELD1_1.contains(":")) {
                    cns = ADDTIONAL_FIELD1_1.split(":")[1].toString();
                }
                String sr = cns.replaceAll("\"", "");
                // ADDTIONAL_FIELD1_1 省份
                rowData.add(sr);
            } else {
                rowData.add(null);
            }
            if (ADDTIONAL_FIELD2_1 != null) {
                if (ADDTIONAL_FIELD2_1.contains(":")) {
                    address = ADDTIONAL_FIELD2_1.split(":")[1].toString();
                }
                String ads = address.replaceAll("\"", "");
                // ADDTIONAL_FIELD2_1 城市
                rowData.add(ads);
            } else {
                rowData.add(null);
            }
            if (ADDTIONAL_FIELD3_1 != null) {
                if (ADDTIONAL_FIELD3_1.contains(":")) {
                    businessPlace = ADDTIONAL_FIELD3_1.split(":")[1].toString();
                }
                String bsp = businessPlace.replaceAll("\"", "");
                if (bsp.contains("}")) {
                    place = bsp.split("}")[0].toString();
                } else {
                    place = bsp;
                }
                // ADDTIONAL_FIELD3_1 营业地址
                rowData.add(place);
            } else {
                rowData.add(null);
            }
            if (userAdditionalField2 != null) {
                if (userAdditionalField2.contains(":")) {
                    userAdditional2 = userAdditionalField2.split(":")[1].toString();
                }
                String uaf = userAdditional2.replaceAll("\"", "");
                if (uaf.contains("}")) {
                    uad2 = uaf.split("}")[0].toString();
                } else {
                    uad2 = uaf;
                }
                // userAdditionalField2_1 企业所属地税机关
                rowData.add(uad2);
            } else {
                rowData.add(null);
            }
        }
        fieldDatas.add(rowData);
    }
    return fieldDatas;
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) ArrayList(java.util.ArrayList) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert)

Example 24 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class BillWebServiceImpl method portSaveBillAuthenticationItems.

/**
 * 保存订单对应的认证项,并删除之前关联的认证项(API接口)
 *
 * @param certItems
 *            需要认证的项
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 *            营业制证
 * @param orgCode
 *            组织机构代码
 * @param taxregisterCert
 *            税务登记
 * @param identityCard
 *            法人
 * @param agent
 *            代理人
 * @param proxy
 *            授权书
 * @param webenterprise
 *            企业
 * @param webuserInfo
 *            用户
 * @throws Exception
 */
public void portSaveBillAuthenticationItems(String certItems, Integer enterpriseNature, Long billId, BusinessLicense businessLicense, OrgCode orgCode, TaxRegisterCert taxregisterCert, IdentityCard identityCard, Agent agent, Proxy proxy, Enterprise webenterprise, UserInfo webuserInfo) throws Exception {
    // 根据订单id,获取该订单的旧认证项:
    BusinessLicense oldBl = businessService.getBusinessByBillId(billId, null);
    OrgCode oldOc = orgCodeService.getOrgCodeByBillId(billId, null);
    TaxRegisterCert oldTc = taxCertService.getTaxRegisterCertByBillId(billId, null);
    IdentityCard oldIc = identityCardService.getIdentityCardByBillId(billId, null);
    Agent oldAgent = agentService.getAgentByBillId(billId, null);
    Proxy oldProxy = proxyService.getProxyByBillId(billId);
    // 新认证项id置null,便于执行新增处理
    businessLicense.setId(null);
    orgCode.setId(null);
    taxregisterCert.setId(null);
    identityCard.setId(null);
    agent.setId(null);
    proxy.setId(null);
    // 从数据库中删除旧认证项
    if (false) {
        if (null != oldBl) {
            sqlSession.delete("com.itrus.portal.db.BusinessLicenseMapper.deleteByPrimaryKey", oldBl.getId());
        }
        if (null != oldOc) {
            sqlSession.delete("com.itrus.portal.db.OrgCodeMapper.deleteByPrimaryKey", oldOc.getId());
        }
        if (null != oldTc) {
            sqlSession.delete("com.itrus.portal.db.TaxRegisterCertMapper.deleteByPrimaryKey", oldTc.getId());
        }
        if (null != oldIc) {
            sqlSession.delete("com.itrus.portal.db.IdentityCardMapper.deleteByPrimaryKey", oldIc.getId());
        }
        if (null != oldAgent) {
            sqlSession.delete("com.itrus.portal.db.AgentMapper.deleteByPrimaryKey", oldAgent.getId());
        }
    }
    /**
     * 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者 5代理人
     */
    Long[] items = StringTools.getLong(certItems);
    // 是否有营业执照信息,默认false没有
    boolean hasBl = false;
    for (Long item : items) {
        if (ComNames.BUSINESS_ITEM.equals(item) && !enterpriseNature.equals(3)) {
            // 事业单位不填写营业执照
            hasBl = true;
            // 判断新认证项是否是使用旧认证项的图片
            if (null != oldBl) {
                businessLicense.setImgFile(ComNames.USE_OLD_IMG);
            }
            businessLicense = businessService.portSaveBusiness1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_1, oldBl);
            if (businessLicense.getImgFile() != null && businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                businessLicense.setImgFile(oldBl.getImgFile());
                businessLicense.setImgFileHash(oldBl.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKey", businessLicense);
            }
        } else if (ComNames.ORG_CODE_ITEM.equals(item)) {
            if (hasBl && businessLicense.getBusinessType().equals(1))
                // 五证合一企业不用提交组织机构代码、税务登记信息
                continue;
            // 假如企业性质为2(个体工商户)并且组织机构代码没有填,则不用保存
            if (enterpriseNature.equals(2) && StringUtils.isBlank(orgCode.getOrgCode()))
                continue;
            // 判断是否需要使用旧的认证项图片
            if (null != oldOc) {
                orgCode.setImgFile(ComNames.USE_OLD_IMG);
            }
            orgCode = orgCodeService.saveOrgCode1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_1, oldOc);
            if (orgCode.getImgFile() != null && orgCode.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                orgCode.setImgFile(oldOc.getImgFile());
                orgCode.setImgFileHash(oldOc.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKey", orgCode);
            }
        } else if (ComNames.TAX_CERT_ITEM.equals(item)) {
            if (hasBl && businessLicense.getBusinessType().equals(1))
                // 五证合一企业不用提交组织机构代码、税务登记信息
                continue;
            // 保存税务登记证
            if (enterpriseNature.equals(3))
                // 事业单位不填写税务登记信息
                continue;
            // 判断是否需要使用旧的认证项图片
            if (null != oldTc) {
                taxregisterCert.setImgFile(ComNames.USE_OLD_IMG);
            }
            taxregisterCert = taxCertService.saveTaxCert1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_1, oldTc);
            if (taxregisterCert.getImgFile() != null && taxregisterCert.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                taxregisterCert.setImgFile(oldTc.getImgFile());
                taxregisterCert.setImgFileHash(oldTc.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.TaxRegisterCertMapper.updateByPrimaryKey", taxregisterCert);
            }
        } else if (ComNames.IDENTITY_CARD_ITEM.equals(item)) {
            // 判断是否需要使用旧的认证项图片
            if (null != oldIc) {
                identityCard.setFrontImg(ComNames.USE_OLD_IMG);
                identityCard.setBackImg(ComNames.USE_OLD_IMG);
            }
            identityCard = identityCardService.portSaveIdentityCard1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_1, oldIc);
            if (identityCard.getFrontImg() != null && identityCard.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
                identityCard.setFrontImg(oldIc.getFrontImg());
                identityCard.setFrontImgHash(oldIc.getFrontImgHash());
                sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
            }
            if (identityCard.getBackImg().equals(ComNames.USE_OLD_IMG)) {
                identityCard.setBackImg(oldIc.getBackImg());
                identityCard.setBackImgHash(oldIc.getBackImgHash());
                sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
            }
        } else if (ComNames.AGENT_ITEM.equals(item)) {
            // 保存代理人
            if (null != oldAgent) {
                agent.setFrontImg(ComNames.USE_OLD_IMG);
                agent.setBackImg(ComNames.USE_OLD_IMG);
            }
            agent = agentService.portSaveAgent1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), agent, ComNames.ITEM_STATUS_1, oldAgent);
            if (agent.getFrontImg() != null && agent.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
                agent.setFrontImg(oldAgent.getFrontImg());
                agent.setFrontImgHash(oldAgent.getFrontImgHash());
                sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
            }
            if (agent.getBackImg() != null && agent.getBackImg().equals(ComNames.USE_OLD_IMG)) {
                agent.setBackImg(oldAgent.getBackImg());
                agent.setBackImgHash(oldAgent.getBackImgHash());
                sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
            }
        } else if (ComNames.PROXY_ITEM.equals(item)) {
            // 保存授权书
            if (null != oldProxy)
                proxy.setImgFile(ComNames.USE_OLD_IMG);
            proxy = proxyService.portSaveProxy1(webenterprise.getId(), webuserInfo.getUniqueId(), billId, webuserInfo.getId(), proxy, oldProxy);
            if (proxy.getImgFile() != null && proxy.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                proxy.setImgFile(oldProxy.getImgFile());
                proxy.setImgFileHash(oldProxy.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.ProxyMapper.updateByPrimaryKey", proxy);
            }
        }
    }
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) Agent(com.itrus.portal.db.Agent) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 25 with OrgCode

use of com.itrus.portal.db.OrgCode in project portal by ixinportal.

the class BillWebServiceImpl method saveBillAuthenticationItems.

/**
 * 保存订单对应的认证项,并删除之前关联的认证项
 *
 * @param certItems
 *            需要认证的项
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 *            营业制证
 * @param orgCode
 *            组织机构代码
 * @param taxregisterCert
 *            税务登记
 * @param identityCard
 *            法人
 * @param agent
 *            代理人
 * @param proxy
 *            授权书
 * @param webenterprise
 *            企业
 * @param webuserInfo
 *            用户
 * @throws Exception
 */
public void saveBillAuthenticationItems(String certItems, Integer enterpriseNature, Long billId, BusinessLicense businessLicense, OrgCode orgCode, TaxRegisterCert taxregisterCert, IdentityCard identityCard, Agent agent, Proxy proxy, Enterprise webenterprise, UserInfo webuserInfo) throws Exception {
    // 根据订单id,获取该订单的旧认证项:
    BusinessLicense oldBl = businessService.getBusinessByBillId(billId, null);
    OrgCode oldOc = orgCodeService.getOrgCodeByBillId(billId, null);
    TaxRegisterCert oldTc = taxCertService.getTaxRegisterCertByBillId(billId, null);
    IdentityCard oldIc = identityCardService.getIdentityCardByBillId(billId, null);
    Agent oldAgent = agentService.getAgentByBillId(billId, null);
    Proxy oldProxy = proxyService.getProxyByBillId(billId);
    // 新认证项id置null,便于执行新增处理
    businessLicense.setId(null);
    orgCode.setId(null);
    taxregisterCert.setId(null);
    identityCard.setId(null);
    agent.setId(null);
    proxy.setId(null);
    // 从数据库中删除旧认证项
    if (false) {
        if (null != oldBl) {
            sqlSession.delete("com.itrus.portal.db.BusinessLicenseMapper.deleteByPrimaryKey", oldBl.getId());
        }
        if (null != oldOc) {
            sqlSession.delete("com.itrus.portal.db.OrgCodeMapper.deleteByPrimaryKey", oldOc.getId());
        }
        if (null != oldTc) {
            sqlSession.delete("com.itrus.portal.db.TaxRegisterCertMapper.deleteByPrimaryKey", oldTc.getId());
        }
        if (null != oldIc) {
            sqlSession.delete("com.itrus.portal.db.IdentityCardMapper.deleteByPrimaryKey", oldIc.getId());
        }
        if (null != oldAgent) {
            sqlSession.delete("com.itrus.portal.db.AgentMapper.deleteByPrimaryKey", oldAgent.getId());
        }
        if (null != oldProxy) {
            sqlSession.delete("com.itrus.portal.db.ProxyMapper.deleteByPrimaryKey", oldProxy.getId());
        }
    }
    /**
     * 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者 5代理人
     */
    Long[] items = StringTools.getLong(certItems);
    // 是否有营业执照信息,默认false没有
    boolean hasBl = false;
    for (Long item : items) {
        if (ComNames.BUSINESS_ITEM.equals(item) && !enterpriseNature.equals(3)) {
            // 事业单位不填写营业执照
            hasBl = true;
            // 判断新认证项是否是使用旧认证项的图片
            if (null != oldBl && StringUtils.isBlank(businessLicense.getImgFile())) {
                businessLicense.setImgFile(ComNames.USE_OLD_IMG);
            }
            // TODO 验证插入重复数据问题item是否重复了:
            System.out.println("BillWebServiceImpl-insert into businessLicense:item=" + item + ",billId=" + billId + ",enterpriseName=" + webenterprise.getEnterpriseName());
            businessLicense = businessService.saveBusiness1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_1, oldBl);
            if (businessLicense.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                businessLicense.setImgFile(oldBl.getImgFile());
                businessLicense.setImgFileHash(oldBl.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.BusinessLicenseMapper.updateByPrimaryKey", businessLicense);
            }
        } else if (ComNames.ORG_CODE_ITEM.equals(item)) {
            if (hasBl && businessLicense.getBusinessType().equals(1))
                // 五证合一企业不用提交组织机构代码、税务登记信息
                continue;
            // 假如企业性质为2(个体工商户)并且组织机构代码没有填,则不用保存
            if (enterpriseNature.equals(2) && StringUtils.isBlank(orgCode.getOrgCode()))
                continue;
            // 判断是否需要使用旧的认证项图片
            if (null != oldOc && StringUtils.isBlank(orgCode.getImgFile())) {
                if (StringUtils.isBlank(oldOc.getImgFile())) {
                    if (orgCode.getOrgCodeType().equals(1)) {
                        throw new UserInfoServiceException("事业单位法人证书不能为空");
                    } else {
                        throw new UserInfoServiceException("组织机构代码图不能为空");
                    }
                }
                orgCode.setImgFile(ComNames.USE_OLD_IMG);
            } else if (StringUtils.isBlank(orgCode.getImgFile())) {
                if (orgCode.getOrgCodeType().equals(1)) {
                    throw new UserInfoServiceException("事业单位法人证书不能为空");
                } else {
                    throw new UserInfoServiceException("组织机构代码图不能为空");
                }
            }
            orgCode = orgCodeService.saveOrgCode1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_1, oldOc);
            if (orgCode.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                orgCode.setImgFile(oldOc.getImgFile());
                orgCode.setImgFileHash(oldOc.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKey", orgCode);
            }
        } else if (ComNames.TAX_CERT_ITEM.equals(item)) {
            if (hasBl && businessLicense.getBusinessType().equals(1))
                // 五证合一企业不用提交组织机构代码、税务登记信息
                continue;
            // 保存税务登记证
            if (enterpriseNature.equals(3))
                // 事业单位不填写税务登记信息
                continue;
            // 判断是否需要使用旧的认证项图片
            if (null != oldTc && StringUtils.isBlank(taxregisterCert.getImgFile())) {
                if (StringUtils.isBlank(oldTc.getImgFile()))
                    throw new UserInfoServiceException("税务登记证不能为空");
                taxregisterCert.setImgFile(ComNames.USE_OLD_IMG);
            }
            taxregisterCert = taxCertService.saveTaxCert1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_1, oldTc);
            if (taxregisterCert.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                taxregisterCert.setImgFile(oldTc.getImgFile());
                taxregisterCert.setImgFileHash(oldTc.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.TaxRegisterCertMapper.updateByPrimaryKey", taxregisterCert);
            }
        } else if (ComNames.IDENTITY_CARD_ITEM.equals(item)) {
            // 判断是否需要使用旧的认证项图片
            if (null != oldIc) {
                if (StringUtils.isBlank(identityCard.getFrontImg())) {
                    identityCard.setFrontImg(ComNames.USE_OLD_IMG);
                    identityCard.setFrontImgHash(oldIc.getFrontImgHash());
                }
                if (StringUtils.isBlank(identityCard.getBackImg()))
                    identityCard.setBackImg(ComNames.USE_OLD_IMG);
            }
            identityCard = identityCardService.saveIdentityCard1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_1, oldIc);
            if (identityCard.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
                identityCard.setFrontImg(oldIc.getFrontImg());
                identityCard.setFrontImgHash(oldIc.getFrontImgHash());
                sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
            }
            if (identityCard.getBackImg().equals(ComNames.USE_OLD_IMG)) {
                identityCard.setBackImg(oldIc.getBackImg());
                identityCard.setBackImgHash(oldIc.getBackImgHash());
                sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKey", identityCard);
            }
        } else if (ComNames.AGENT_ITEM.equals(item)) {
            // 保存代理人
            if (null != oldAgent) {
                if (StringUtils.isBlank(agent.getFrontImg())) {
                    agent.setFrontImg(ComNames.USE_OLD_IMG);
                    agent.setFrontImgHash(oldAgent.getFrontImgHash());
                }
                if (StringUtils.isBlank(agent.getBackImg()))
                    agent.setBackImg(ComNames.USE_OLD_IMG);
            }
            agent = agentService.saveAgent1(webenterprise.getId(), webenterprise.getEnterpriseSn(), billId, webuserInfo.getId(), agent, ComNames.ITEM_STATUS_1, oldAgent);
            if (agent.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
                agent.setFrontImg(oldAgent.getFrontImg());
                agent.setFrontImgHash(oldAgent.getFrontImgHash());
                sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
            }
            if (agent.getBackImg().equals(ComNames.USE_OLD_IMG)) {
                agent.setBackImg(oldAgent.getBackImg());
                agent.setBackImgHash(oldAgent.getBackImgHash());
                sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
            }
        } else if (ComNames.PROXY_ITEM.equals(item)) {
            // 保存授权书
            if (null != oldProxy && StringUtils.isBlank(proxy.getImgFile()))
                proxy.setImgFile(ComNames.USE_OLD_IMG);
            // TODO 验证插入重复数据问题item是否重复了:
            System.out.println("BillWebServiceImpl-insert into proxy:item=" + item + ",billId=" + billId + ",enterpriseName=" + webenterprise.getEnterpriseName());
            Project project = billService.getProjectByBillId(billId);
            proxy = proxyService.saveProxy1(webenterprise.getId(), webuserInfo.getUniqueId(), billId, webuserInfo.getId(), proxy, oldProxy, project);
            if (proxy.getImgFile().equals(ComNames.USE_OLD_IMG)) {
                proxy.setImgFile(oldProxy.getImgFile());
                proxy.setImgFileHash(oldProxy.getImgFileHash());
                sqlSession.update("com.itrus.portal.db.ProxyMapper.updateByPrimaryKey", proxy);
            }
        }
    }
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) Agent(com.itrus.portal.db.Agent) Project(com.itrus.portal.db.Project) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IdentityCard(com.itrus.portal.db.IdentityCard)

Aggregations

OrgCode (com.itrus.portal.db.OrgCode)34 BusinessLicense (com.itrus.portal.db.BusinessLicense)25 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)24 Enterprise (com.itrus.portal.db.Enterprise)23 IdentityCard (com.itrus.portal.db.IdentityCard)22 Agent (com.itrus.portal.db.Agent)20 UserInfo (com.itrus.portal.db.UserInfo)19 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Proxy (com.itrus.portal.db.Proxy)11 ExtraProduct (com.itrus.portal.db.ExtraProduct)10 HashMap (java.util.HashMap)10 OpenBankInfo (com.itrus.portal.db.OpenBankInfo)9 ExtraBill (com.itrus.portal.db.ExtraBill)8 Product (com.itrus.portal.db.Product)8 Project (com.itrus.portal.db.Project)8 File (java.io.File)8 Date (java.util.Date)8 JSONObject (com.alibaba.fastjson.JSONObject)7 Bill (com.itrus.portal.db.Bill)7