Search in sources :

Example 16 with Agent

use of com.itrus.portal.db.Agent 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 17 with Agent

use of com.itrus.portal.db.Agent 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 18 with Agent

use of com.itrus.portal.db.Agent 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 19 with Agent

use of com.itrus.portal.db.Agent 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)

Example 20 with Agent

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

the class AgentServiceImpl method portSaveAgent1.

public Agent portSaveAgent1(Long enterpriseId, String enterpriseSn, Long billId, Long userInfoId, Agent agent, Integer itemStatus, Agent old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    // 判断代理信息图片是否重新上传了,没有重新上传,则会提交代理人信息的id,重新上传,还是按照下面的方法处理
    if (null != agent.getId()) {
        Agent newAt = new Agent();
        Agent oldAt = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectByPrimaryKey", agent.getId());
        newAt.setEnterpriseName(agent.getEnterpriseName());
        newAt.setName(agent.getName());
        newAt.setCardType(agent.getCardType());
        newAt.setIdCode(agent.getIdCode());
        newAt.setCreateTime(new Date());
        newAt.setLastModify(new Date());
        // 审核状态:1未审核,2已审核,3已拒绝
        newAt.setItemStatus(oldAt.getItemStatus());
        newAt.setEnterprise(enterpriseId);
        newAt.setBill(billId);
        newAt.setUserInfo(userInfoId);
        // 正面(或者合成)图片
        if (StringUtils.isNotBlank(agent.getFrontImg())) {
            File frontImg = filePathUtils.saveImg(imgDir, null, agent.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
            if (frontImg != null && frontImg.isFile()) {
                newAt.setFrontImg(frontImg.getName());
                newAt.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
            }
        } else {
            newAt.setFrontImg(oldAt.getFrontImg());
            newAt.setFrontImgHash(oldAt.getFrontImgHash());
        }
        // 反面图片
        if (StringUtils.isNotBlank(agent.getBackImg())) {
            File backImg = filePathUtils.saveImg(imgDir, null, agent.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
            if (backImg != null && backImg.isFile()) {
                newAt.setBackImg(backImg.getName());
                newAt.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
            }
        } else {
            newAt.setBackImg(oldAt.getBackImg());
            newAt.setBackImgHash(oldAt.getBackImgHash());
        }
        sqlSession.insert("com.itrus.portal.db.AgentMapper.insert", newAt);
        sqlSession.flushStatements();
        return newAt;
    }
    if (null == agent || StringUtils.isBlank(agent.getEnterpriseName()) || StringUtils.isBlank(agent.getName()) || StringUtils.isBlank(agent.getIdCode())) {
        throw new UserInfoServiceException("请提交完整的代理人信息");
    }
    agent.setCreateTime(new Date());
    agent.setLastModify(new Date());
    // 审核状态:1未审核,2已审核,3已拒绝
    agent.setItemStatus(itemStatus);
    agent.setEnterprise(enterpriseId);
    agent.setBill(billId);
    agent.setUserInfo(userInfoId);
    // 正面(或者合成)图片
    if (StringUtils.isNotBlank(agent.getFrontImg()) && !agent.getFrontImg().equals(ComNames.USE_OLD_IMG)) {
        File frontImg = filePathUtils.saveImg(imgDir, null, agent.getFrontImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
        if (frontImg != null && frontImg.isFile()) {
            agent.setFrontImg(frontImg.getName());
            agent.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
        }
    }
    // 反面图片
    if (StringUtils.isNotBlank(agent.getBackImg()) && !agent.getBackImg().equals(ComNames.USE_OLD_IMG)) {
        File backImg = filePathUtils.saveImg(imgDir, null, agent.getBackImg(), IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
        if (backImg != null && backImg.isFile()) {
            agent.setBackImg(backImg.getName());
            agent.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
        }
    }
    if (old == null)
        sqlSession.insert("com.itrus.portal.db.AgentMapper.insert", agent);
    else {
        agent.setId(old.getId());
        sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKey", agent);
    }
    sqlSession.flushStatements();
    return agent;
}
Also used : Agent(com.itrus.portal.db.Agent) File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Aggregations

Agent (com.itrus.portal.db.Agent)27 BusinessLicense (com.itrus.portal.db.BusinessLicense)20 OrgCode (com.itrus.portal.db.OrgCode)20 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)19 Enterprise (com.itrus.portal.db.Enterprise)18 IdentityCard (com.itrus.portal.db.IdentityCard)18 UserInfo (com.itrus.portal.db.UserInfo)16 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 Proxy (com.itrus.portal.db.Proxy)10 ExtraProduct (com.itrus.portal.db.ExtraProduct)8 OpenBankInfo (com.itrus.portal.db.OpenBankInfo)8 HashMap (java.util.HashMap)8 JSONObject (com.alibaba.fastjson.JSONObject)7 Bill (com.itrus.portal.db.Bill)7 ExtraBill (com.itrus.portal.db.ExtraBill)7 ExtraProductSpec (com.itrus.portal.db.ExtraProductSpec)7 Product (com.itrus.portal.db.Product)7 Project (com.itrus.portal.db.Project)7 File (java.io.File)7