Search in sources :

Example 6 with OrgCode

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

the class ExtraQueryBillController 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());
    if (StringUtils.isNotBlank(enterprise.getProvince())) {
        String province = sysRegionService.getProvince(enterprise.getProvince());
        enterprise.setProvince(province);
    }
    if (StringUtils.isNotBlank(enterprise.getCity())) {
        String city = sysRegionService.getCity(enterprise.getCity());
        enterprise.setCity(city);
    }
    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);
    if (onPayInfo != null) {
        // 在线支付信息
        OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onPayInfo.getOnlinePay());
        uiModel.addAttribute("onlinePay", onlinePay);
    }
    // 电子发票
    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("bl", businessLicense);
    // 税务登记
    TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
    uiModel.addAttribute("trc", taxRegisterCert);
    // 组织机构代码
    OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
    uiModel.addAttribute("oc", orgCode);
    // 代理人
    Agent agent = agentService.getAgentByExtraBillId(id, null);
    uiModel.addAttribute("agent", agent);
    // 开户行信息
    OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
    uiModel.addAttribute("obi", openBankInfo);
    // 法人信息
    IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
    uiModel.addAttribute("ic", identityCard);
    // TODO 还需要补充订单对应的附加信息和第三方回调信息
    return "extrabill/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) OnlinePay(com.itrus.portal.db.OnlinePay) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with OrgCode

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

the class EnterpriseController method detail.

@RequestMapping("/detail")
public String detail(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "item", required = false) Integer item, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", id);
    if (null == enterprise) {
        return "status403";
    }
    uiModel.addAttribute("enterprise", enterprise);
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 10;
    }
    // 总记录数
    Integer count = 0;
    // 当前页记录数
    Integer itemcount = 0;
    // ===0认证信息、1关联用户、2订单列表
    if (null == item || 0 == item) {
        item = 0;
        // 认证信息
        BusinessLicense businessLicense = null;
        OrgCode orgCode = null;
        TaxRegisterCert taxRegisterCert = null;
        IdentityCard identityCard = null;
        if (null != enterprise.getAuthenticationLevel()) {
            // 审核通过:
            // 获取企业的认证等级
            Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", enterprise.getAuthenticationLevel());
            uiModel.addAttribute("certification", certification);
        }
        if (null != enterprise.getHasBl()) {
            businessLicense = sqlSession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByPrimaryKey", enterprise.getHasBl());
        }
        if (null != enterprise.getHasOrgCode()) {
            orgCode = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByPrimaryKey", enterprise.getHasOrgCode());
        }
        if (null != enterprise.getHasTaxCert()) {
            taxRegisterCert = sqlSession.selectOne("com.itrus.portal.db.TaxRegisterCertMapper.selectByPrimaryKey", enterprise.getHasTaxCert());
        }
        if (null != enterprise.getHasIdCard()) {
            identityCard = sqlSession.selectOne("com.itrus.portal.db.IdentityCardMapper.selectByPrimaryKey", enterprise.getHasIdCard());
        }
        uiModel.addAttribute("businessLicense", businessLicense);
        uiModel.addAttribute("orgCode", orgCode);
        uiModel.addAttribute("taxRegisterCert", taxRegisterCert);
        uiModel.addAttribute("identityCard", identityCard);
        // 查询增值订单中开户行信息
        OpenBankInfoExample obie = new OpenBankInfoExample();
        Criteria obiec = obie.createCriteria();
        obiec.andEnterpriseEqualTo(enterprise.getId());
        obie.setOrderByClause("create_time desc");
        List<OpenBankInfo> openBankInfos = sqlSession.selectList("com.itrus.portal.db.OpenBankInfoMapper.selectByExample", obie);
        if (openBankInfos != null && openBankInfos.size() > 0) {
            uiModel.addAttribute("openBankInfos", openBankInfos);
        }
    } else if (1 == item) {
        item = 1;
        // 关联用户
        List<UserInfo> userInfos = new ArrayList<UserInfo>();
        List<Long> userInfoIds = userInfoEnterpriseService.getUserInfoByEnterprise(enterprise.getId());
        if (null != userInfoIds && !userInfoIds.isEmpty()) {
            count = userInfoIds.size();
            UserInfoExample userInfoExample = new UserInfoExample();
            UserInfoExample.Criteria criteria = userInfoExample.or();
            criteria.andIdIn(userInfoIds);
            if (page > 1 && size * (page - 1) >= count) {
                page = (count + size - 1) / size;
            }
            Integer offset = size * (page - 1);
            userInfoExample.setOffset(offset);
            userInfoExample.setLimit(size);
            userInfoExample.setOrderByClause("create_time desc");
            userInfos = sqlSession.selectList("com.itrus.portal.db.UserInfoMapper.selectByExample", userInfoExample);
        }
        itemcount = userInfos.size();
        uiModel.addAttribute("userInfos", userInfos);
    } else if (2 == item) {
        item = 2;
        // 订单列表
        BillExample billExample = new BillExample();
        BillExample.Criteria criteria = billExample.or();
        criteria.andEnterpriseEqualTo(enterprise.getId());
        criteria.andIsDeleteEqualTo(false);
        count = sqlSession.selectOne("com.itrus.portal.db.BillMapper.countByExample", billExample);
        if (page > 1 && size * (page - 1) >= count) {
            page = (count + size - 1) / size;
        }
        Integer offset = size * (page - 1);
        billExample.setOffset(offset);
        billExample.setLimit(size);
        billExample.setOrderByClause("create_time desc");
        List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
        itemcount = billList.size();
        uiModel.addAttribute("billList", billList);
        Map<Long, Project> projectMap = billService.getProjectMapByEnterpriseId(enterprise.getId());
        uiModel.addAttribute("projectMap", projectMap);
        Map<Long, Product> productMap = billService.getProductMapByEnterpriseId(enterprise.getId());
        uiModel.addAttribute("productMap", productMap);
        Map<Long, UserInfo> userInfoMap = billService.getUserInfoMapByEnterpriseId(enterprise.getId());
        uiModel.addAttribute("userInfoMap", userInfoMap);
    } else if (3 == item) {
        item = 3;
        // 增值订单列表
        ExtraBillExample extraBillExample = new ExtraBillExample();
        ExtraBillExample.Criteria criteria = extraBillExample.or();
        criteria.andEnterpriseEqualTo(enterprise.getId());
        criteria.andIsDeleteEqualTo(false);
        count = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.countByExample", extraBillExample);
        if (page > 1 && size * (page - 1) >= count) {
            page = (count + size - 1) / size;
        }
        Integer offset = size * (page - 1);
        extraBillExample.setOffset(offset);
        extraBillExample.setLimit(size);
        extraBillExample.setOrderByClause("create_time desc");
        List<ExtraBill> extraBillList = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByExample", extraBillExample);
        itemcount = extraBillList.size();
        uiModel.addAttribute("billList", extraBillList);
        Map<Long, Project> projectMap = extraBillService.getProjectMapByEnterpriseId(enterprise.getId());
        uiModel.addAttribute("projectMap", projectMap);
        Map<Long, ExtraProduct> productMap = extraBillService.getProductMapByEnterpriseId(enterprise.getId());
        uiModel.addAttribute("productMap", productMap);
        Map<Long, UserInfo> userInfoMap = extraBillService.getUserInfoMapByEnterpriseId(enterprise.getId());
        uiModel.addAttribute("userInfoMap", userInfoMap);
    }
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    uiModel.addAttribute("itemcount", itemcount);
    uiModel.addAttribute("item", item);
    return "enterprise/detail";
}
Also used : Product(com.itrus.portal.db.Product) ExtraProduct(com.itrus.portal.db.ExtraProduct) UserInfo(com.itrus.portal.db.UserInfo) Criteria(com.itrus.portal.db.OpenBankInfoExample.Criteria) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) BillExample(com.itrus.portal.db.BillExample) ExtraBillExample(com.itrus.portal.db.ExtraBillExample) ArrayList(java.util.ArrayList) List(java.util.List) IdentityCard(com.itrus.portal.db.IdentityCard) UserInfoExample(com.itrus.portal.db.UserInfoExample) Certification(com.itrus.portal.db.Certification) ExtraBillExample(com.itrus.portal.db.ExtraBillExample) OrgCode(com.itrus.portal.db.OrgCode) Project(com.itrus.portal.db.Project) BusinessLicense(com.itrus.portal.db.BusinessLicense) Enterprise(com.itrus.portal.db.Enterprise) ExtraBill(com.itrus.portal.db.ExtraBill) Bill(com.itrus.portal.db.Bill) OpenBankInfoExample(com.itrus.portal.db.OpenBankInfoExample) HashMap(java.util.HashMap) Map(java.util.Map) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with OrgCode

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

the class ExtraBillPayController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel, @RequestParam(value = "payStatus", required = false) Integer payStatus) {
    uiModel.addAttribute("payStatus", payStatus);
    // 管理员项目权限
    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);
    if (onPayInfo != null && onPayInfo.getOnlinePay() != null) {
        // 在线支付
        OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onPayInfo.getOnlinePay());
        uiModel.addAttribute("onlinePay", onlinePay);
    }
    // 电子发票
    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 "extrabillpay/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) OnlinePay(com.itrus.portal.db.OnlinePay) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with OrgCode

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

the class ImageByBase64 method getImg.

/**
 * 获取图片文件File
 *
 * @param type
 *            类型:0营业执照图片,1组织机构代码图片,2税务登记图片,3授权书图片,4法人图片
 * @param id
 *            营业执照、组织机构代码、税务登记、授权书、法人中的某一项的id
 * @param num
 *            0表示正面,1标识反面图片
 * @return
 */
public File getImg(Long type, Long id, Long num) {
    File imgFile = null;
    String img = null;
    Long enterpriseId = null;
    Long userInfoId = null;
    try {
        if (type == ComNames.BUSINESS_ITEM) {
            BusinessLicense license = sqlsession.selectOne("com.itrus.portal.db.BusinessLicenseMapper.selectByPrimaryKey", id);
            if (license == null) {
                return null;
            }
            img = license.getImgFile();
            enterpriseId = license.getEnterprise();
        } else if (type == ComNames.ORG_CODE_ITEM) {
            OrgCode code = sqlsession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByPrimaryKey", id);
            if (code == null) {
                return null;
            }
            img = code.getImgFile();
            enterpriseId = code.getEnterprise();
        } else if (type == ComNames.TAX_CERT_ITEM) {
            TaxRegisterCert cert = sqlsession.selectOne("com.itrus.portal.db.TaxRegisterCertMapper.selectByPrimaryKey", id);
            if (cert == null) {
                return null;
            }
            img = cert.getImgFile();
            enterpriseId = cert.getEnterprise();
        } else if (type == ComNames.IDENTITY_CARD_ITEM) {
            IdentityCard card = sqlsession.selectOne("com.itrus.portal.db.IdentityCardMapper.selectByPrimaryKey", id);
            if (card == null) {
                return null;
            }
            if (num == 0) {
                img = card.getFrontImg();
            } else {
                img = card.getBackImg();
            }
            enterpriseId = card.getEnterprise();
        } else if (type == ComNames.PROXY_ITEM) {
            Proxy proxy = sqlsession.selectOne("com.itrus.portal.db.ProxyMapper.selectByPrimaryKey", id);
            if (proxy == null) {
                return null;
            }
            img = proxy.getImgFile();
            // 授权书图片存放在用户唯一标识目录下
            userInfoId = proxy.getUserInfo();
        } else if (type == ComNames.AGENT_ITEM) {
            Agent agent = sqlsession.selectOne("com.itrus.portal.db.AgentMapper.selectByPrimaryKey", id);
            if (agent == null) {
                return null;
            }
            if (num == 0) {
                img = agent.getFrontImg();
            } else {
                img = agent.getBackImg();
            }
            enterpriseId = agent.getEnterprise();
        }
        if (img == null) {
            return null;
        }
        File file = null;
        if (null != enterpriseId) {
            Enterprise enterprise = sqlsession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", enterpriseId);
            file = filePathUtils.getEnterpriseFile(enterprise.getEnterpriseSn());
        } else if (null != userInfoId) {
            // 授权书图片存放在用户唯一标识目录下
            UserInfo userInfo = sqlsession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", userInfoId);
            file = filePathUtils.getUserInfoFIle(userInfo.getUniqueId());
        } else {
            return null;
        }
        if (!file.exists()) {
            file.mkdirs();
        }
        imgFile = new File(file, img);
    } catch (IOException e) {
        // 未找到
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return imgFile;
}
Also used : Agent(com.itrus.portal.db.Agent) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) ServiceNullException(com.itrus.portal.exception.ServiceNullException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Enterprise(com.itrus.portal.db.Enterprise) File(java.io.File) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 10 with OrgCode

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

the class ReviewServiceImpl method queryAudit.

/**
 * 查询送审结果
 *
 * @param appsecret
 * @param appId
 * @param dataid
 * @return
 */
public boolean queryAudit(String appsecret, Long appId, String dataid, Bill bill) throws Exception {
    AuditSystemConfig auditSystemConfig = auditSystemConfigService.getAuditSystemConfig(new AuditSystemConfigExample());
    if (null == auditSystemConfig) {
        // 未配置第三方鉴证信息
        return false;
    }
    Map<String, Object> jsonMap = new HashMap<String, Object>();
    jsonMap.put("appId", appId);
    jsonMap.put("appsecret", appsecret);
    // 待查询的记录id
    jsonMap.put("dataid", dataid);
    String jsonString = jsonTool.writeValueAsString(jsonMap);
    String result = RequestUtils.post(auditSystemConfig.getAuditSystemUrl() + ComNames.QUERYAPIS, jsonString, appsecret);
    JsonNode respNode = jsonTool.readTree(result);
    if (200 == respNode.get("status").asInt()) {
        // 查询成功
        JsonNode statusNode = respNode.get("result");
        // 0是未通过,1是通过,2是审核中
        int auditstatus = statusNode.get("auditstatus").asInt();
        BusinessLicense bl = businessService.getBusinessByBillId(bill.getId(), null);
        OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
        TaxRegisterCert trc = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
        IdentityCard ic = identityCardService.getIdentityCardByBillId(bill.getId(), null);
        Agent at = agentService.getAgentByBillId(bill.getId(), null);
        Proxy p = proxyService.getProxyByBillId(bill.getId());
        // 默认未审核
        Integer itemStatus = 1;
        String reason = null;
        Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
        if (0 == auditstatus) {
            // 未通过(审核拒绝)
            // 记录未通过原因
            reason = statusNode.get("auditresult").getTextValue();
            // 更新订单状态
            bill.setBillStatus(ComNames.BILL_STATUS_4);
            bill.setCancelReason(reason);
            bill.setCheckTime(new Date(statusNode.get("auditdate").asLong()));
            // 发送短信
            if (sendSmsBySHJJ(bill.getId())) {
                bill.setIsSms(true);
                bill.setSendTime(new Date());
            }
            // 更新认证项状态
            itemStatus = 3;
            // 添加系统日志
            LogUtil.syslog(sqlSession, "单条查询送审", "产品ID" + bill.getProduct() + "企业ID:" + bill.getEnterprise() + ",审核结果:审核拒绝");
        } else if (1 == auditstatus) {
            // 通过
            Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
            Product product1 = null;
            Product product2 = null;
            Product product3 = null;
            DigitalCert cert1 = null;
            DigitalCert cert2 = null;
            DigitalCert cert3 = null;
            if (null != bill.getProduct1()) {
                product1 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct1());
                if (null != product1.getCert()) {
                    cert1 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product1.getCert());
                }
            }
            if (null != bill.getProduct2()) {
                product2 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct2());
                if (null != product2.getCert()) {
                    cert2 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product2.getCert());
                }
            }
            if (null != bill.getProduct3()) {
                product3 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct3());
                if (null != product3.getCert()) {
                    cert3 = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product3.getCert());
                }
            }
            DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
            // 更新企业
            if (respNode.get("source") != null) {
                enterprise.setInfo(respNode.get("source").getTextValue().getBytes());
            }
            enterprise.setReviewTime(new Date());
            enterprise.setAuthenticationLevel(product.getAuthentication());
            // 更新订单状态
            bill.setBillStatus(ComNames.BILL_STATUS_5);
            if (bill.getOldUserCert() != null) {
                bill.setBillStatus(ComNames.BILL_STATUS_12);
            }
            // 数字证书操作方式为用户下载(2)的,订单状态设置为待下载
            if (null != cert && null != cert.getInitBuy() && "2".equals(cert.getInitBuy())) {
                bill.setBillStatus(ComNames.BILL_STATUS_13);
            }
            // 当产品没有配置有数字证书的时候
            if (null == cert && null == cert1 && null == cert2 && null == cert3) {
                // 根据订单判断订单是否需要开票:0标识不需要开票,1需要开纸质发票,2需要开电子发票
                int type = billService.getBillInvoiceType(bill);
                switch(type) {
                    case 0:
                        bill.setBillStatus(ComNames.BILL_STATUS_8);
                        break;
                    case 1:
                        if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
                            bill.setBillStatus(ComNames.BILL_STATUS_7);
                        } else {
                            bill.setBillStatus(ComNames.BILL_STATUS_6);
                        }
                        break;
                    case 2:
                        if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
                            bill.setBillStatus(ComNames.BILL_STATUS_8);
                        } else {
                            bill.setBillStatus(ComNames.BILL_STATUS_6);
                        }
                        break;
                    default:
                        break;
                }
            }
            bill.setCheckTime(new Date(statusNode.get("auditdate").asLong()));
            // 更新认证项状态
            itemStatus = 2;
            // 添加系统日志
            LogUtil.syslog(sqlSession, "单条查询送审", "产品ID" + bill.getProduct() + "企业ID:" + bill.getEnterprise() + ",审核结果:审核通过");
        } else if (2 == auditstatus) {
            // 审核中
            throw new UserInfoServiceException(statusNode.get("auditmessage").getTextValue());
        }
        if (null != bl) {
            bl.setItemStatus(itemStatus);
            saveBl(bl, respNode.get("source"));
            enterprise.setHasBl(bl.getId());
        }
        if (null != oc) {
            oc.setItemStatus(itemStatus);
            sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKeySelective", oc);
            enterprise.setHasOrgCode(oc.getId());
        }
        if (null != trc) {
            trc.setItemStatus(itemStatus);
            sqlSession.update("com.itrus.portal.db.TaxRegisterCertMapper.updateByPrimaryKeySelective", trc);
            enterprise.setHasTaxCert(trc.getId());
        }
        if (null != ic) {
            ic.setItemStatus(itemStatus);
            sqlSession.update("com.itrus.portal.db.IdentityCardMapper.updateByPrimaryKeySelective", ic);
            enterprise.setHasIdCard(ic.getId());
        }
        if (null != at) {
            at.setItemStatus(itemStatus);
            sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKeySelective", at);
            enterprise.setHasAgent(at.getId());
        }
        if (null != p) {
            p.setItemStatus(itemStatus);
        }
        // 更新企业
        sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKeyWithBLOBs", enterprise);
        // 更新订单
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
        // 生成鉴证记录
        reviewLogService.saveReviewLog(1, null, auditstatus == 1 ? 1 : 2, reason, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), bl == null ? null : bl.getId(), oc == null ? null : oc.getId(), trc == null ? null : trc.getId(), ic == null ? null : ic.getId(), at == null ? null : at.getId(), p == null ? null : p.getId());
        return true;
    } else if (201 == respNode.get("status").asInt()) {
        // 查询失败
        String message = respNode.get("message").getTextValue();
        throw new UserInfoServiceException(message);
    }
    return false;
}
Also used : Agent(com.itrus.portal.db.Agent) HashMap(java.util.HashMap) AuditSystemConfig(com.itrus.portal.db.AuditSystemConfig) AuditSystemConfigExample(com.itrus.portal.db.AuditSystemConfigExample) Product(com.itrus.portal.db.Product) JsonNode(org.codehaus.jackson.JsonNode) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) OrgCode(com.itrus.portal.db.OrgCode) DigitalCert(com.itrus.portal.db.DigitalCert) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Enterprise(com.itrus.portal.db.Enterprise) JSONObject(com.alibaba.fastjson.JSONObject) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) 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