Search in sources :

Example 11 with OrgCode

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

the class SubmitReviewServiceImpl method getAuditJsonParam.

/**
 * 获取单个送审的数据json格式
 *
 * @param bill
 * @return
 */
public String getAuditJsonParam(Bill bill) throws Exception {
    SysConfig sysConfig = cacheCustomer.getSysConfigByType(SystemConfigService.TS_URL);
    if (sysConfig == null || StringUtils.isBlank(sysConfig.getConfig()))
        throw new UserInfoServiceException("缺少终端后台地址配置信息");
    // 查询企业表是是否含有dataid的值
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    String dataId = bill.getDataId();
    // 获取产品的认证等级需要认证的项
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", product.getAuthentication());
    /**
     * 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者
     */
    Long[] items = StringTools.getLong(certification.getCertItems());
    BusinessLicense businessLicense = null;
    OrgCode orgCode = null;
    TaxRegisterCert taxRegister = null;
    IdentityCard identityCard = null;
    Proxy proxy = null;
    Agent agent = null;
    for (Long item : items) {
        if (ComNames.BUSINESS_ITEM == item) {
            // 查询订单的营业执照信息
            businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
        } else if (ComNames.ORG_CODE_ITEM == item) {
            // 查询订单的组织机构代码信息
            orgCode = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
        } else if (ComNames.TAX_CERT_ITEM == item) {
            // 查询订单的税务登记证信息
            taxRegister = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
        } else if (ComNames.IDENTITY_CARD_ITEM == item) {
            // 查询订单的法人信息
            identityCard = identityCardService.getIdentityCardByBillId(bill.getId(), null);
        } else if (ComNames.PROXY_ITEM == item) {
            // 查询订单的授权书信息
            proxy = proxyService.getProxyByBillId(bill.getId());
        } else if (ComNames.AGENT_ITEM == item) {
            agent = agentService.getAgentByBillId(bill.getId(), null);
        }
    }
    Map<String, Object> jsonMap = new HashMap<String, Object>();
    String appId = product.getAppId().toString();
    String appsecret = product.getAppsecret();
    jsonMap.put("appId", appId);
    jsonMap.put("appsecret", appsecret);
    if (StringUtils.isNotBlank(dataId))
        // 用户查询记录回执id,当审核失败后重新提交时,必填(上一次返回的dataid)
        jsonMap.put("dataid", dataId);
    // 企业信息
    // 企业类型(1为企业;
    jsonMap.put("comptype", enterprise.getEnterpriseNature());
    // 2为个体工商户;3为事业单位/政府机关)
    // 注册省份
    jsonMap.put("compaddress", "");
    // 企业名称
    jsonMap.put("companyname", enterprise.getEnterpriseName());
    // 营业执照信息:当企业类型comptype值为1和2时,必填
    if (null != businessLicense) {
        if (businessLicense.getBusinessType() == 1) {
            // 三证合一企业
            jsonMap.put("businesslicensetype", 1);
        } else {
            // 非三证合一企业
            jsonMap.put("businesslicensetype", 0);
        }
        // 统一社会信用代码/营业执照注册号
        jsonMap.put("compcode", businessLicense.getLicenseNo());
        if (StringUtils.isNotBlank(businessLicense.getImgFile()) && StringUtils.isNotBlank(businessLicense.getImgFileHash())) {
            jsonMap.put("businesslicense", sysConfig.getConfig() + "/reviewWeb/audit/img/0/" + businessLicense.getId() + "/0/" + // 营业执照照片的URL
            businessLicense.getImgFileHash());
        }
    }
    // 组织机构代码信息:当企业类型comptype值为3时,必填
    if (null != orgCode) {
        if (null != orgCode.getOrgCodeType() && orgCode.getOrgCodeType().equals(1)) {
            // 三证合一企业
            jsonMap.put("businesslicensetype", 1);
            if (StringUtils.isNotBlank(orgCode.getImgFile()) && StringUtils.isNotBlank(orgCode.getImgFileHash())) {
                jsonMap.put("businesslicense", sysConfig.getConfig() + "/reviewWeb/audit/img/1/" + orgCode.getId() + "/0/" + // 组织机构代码证照片的URL
                orgCode.getImgFileHash());
            }
            // 统一社会信用代码/营业执照注册号
            jsonMap.put("compcode", orgCode.getOrgCode());
        } else {
            // 组织机构代码(号码)
            jsonMap.put("organizationcode", orgCode.getOrgCode());
            if (StringUtils.isNotBlank(orgCode.getImgFile()) && StringUtils.isNotBlank(orgCode.getImgFileHash())) {
                jsonMap.put("orgcodecertificate", sysConfig.getConfig() + "/reviewWeb/audit/img/1/" + orgCode.getId() + "/0/" + // 组织机构代码证照片的URL
                orgCode.getImgFileHash());
            }
        }
    }
    // 税务登记证信息
    if (null != taxRegister) {
        jsonMap.put("taxregistratno", taxRegister.getCertNo());
        jsonMap.put("taxregcertificate", sysConfig.getConfig() + "/reviewWeb/audit/img/2/" + taxRegister.getId() + "/0/" + // 税务登记证的URL
        taxRegister.getImgFileHash());
    }
    // 授权书信息
    if (null != proxy) {
        jsonMap.put("powerofattorney", // 授权书的URL
        sysConfig.getConfig() + "/reviewWeb/audit/img/3/" + proxy.getId() + "/0/" + proxy.getImgFileHash());
    }
    // 法人信息
    if (null != identityCard) {
        // 法人姓名
        jsonMap.put("legalname", identityCard.getName());
        // 法人证件类型(1为身份证;2为护照;3为其他)
        jsonMap.put("legalnotype", identityCard.getCardType());
        // 法人证件号码
        jsonMap.put("legalidcardno", identityCard.getIdCode());
        jsonMap.put("legalpzmzp", sysConfig.getConfig() + "/reviewWeb/audit/img/4/" + identityCard.getId() + "/0/" + // 法人证件正面照片的URL
        identityCard.getFrontImgHash());
        if (StringUtils.isNotBlank(identityCard.getBackImg()) && StringUtils.isNotBlank(identityCard.getBackImgHash())) {
            jsonMap.put("legalpfmzp", sysConfig.getConfig() + "/reviewWeb/audit/img/4/" + identityCard.getId() + "/1/" + // 法人证件反面照片的URL
            identityCard.getBackImgHash());
        }
    }
    // 代理人信息
    // 代理人姓名
    jsonMap.put("proxyname", userInfo.getRealName());
    // 代理人手机号
    jsonMap.put("proxyphone", userInfo.getmPhone());
    // 代理人座机
    jsonMap.put("proxytele", userInfo.getTelephone());
    // 代理人邮箱
    jsonMap.put("proxyemail", userInfo.getEmail());
    if (null != agent) {
        // 代理人证件类型(1为身份证;2为护照;3为其他)
        jsonMap.put("proxynotype", agent.getCardType());
        // 代理人身份证号
        jsonMap.put("proxypidcardno", agent.getIdCode());
        jsonMap.put("proxypzmzp", sysConfig.getConfig() + "/reviewWeb/audit/img/5/" + agent.getId() + "/0/" + // 代理人身份证正面照片
        agent.getFrontImgHash());
        if (StringUtils.isNotBlank(agent.getBackImg()) && StringUtils.isNotBlank(agent.getBackImgHash())) {
            jsonMap.put("proxypfmzp", sysConfig.getConfig() + "/reviewWeb/audit/img/5/" + agent.getId() + "/1/" + // 代理人身份证反面照片
            agent.getBackImgHash());
        }
    }
    return jsonTool.writeValueAsString(jsonMap);
}
Also used : SysConfig(com.itrus.portal.db.SysConfig) HashMap(java.util.HashMap) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Certification(com.itrus.portal.db.Certification) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Enterprise(com.itrus.portal.db.Enterprise) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard)

Example 12 with OrgCode

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

the class OrgCodeServiceImpl method portUpdateOrgCode.

/**
 * 组织机构图片上传(接口)
 * @param billId
 * @param enterpriseSn
 * @param image
 * @return
 * @throws Exception
 */
public OrgCode portUpdateOrgCode(Long billId, String enterpriseSn, String image) throws Exception {
    OrgCode orgCode = this.getOrgCodeByBillId(billId, null);
    if (null == orgCode) {
        return null;
    }
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    if (orgCode.getImgFile() != null) {
        FileUtils.deleteQuietly(new File(imgDir, orgCode.getImgFile()));
    }
    File liceImg = filePathUtils.saveImg(imgDir, null, image, IMG_DEFAULT_TYPE, IMG_NAME_ORG);
    if (liceImg != null && liceImg.isFile()) {
        orgCode.setImgFile(liceImg.getName());
        orgCode.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
    }
    sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKeySelective", orgCode);
    sqlSession.flushStatements();
    return orgCode;
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) File(java.io.File)

Example 13 with OrgCode

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

the class OrgCodeServiceImpl method updateOrgCode.

/**
 * 修改组织机构照片
 *
 * @param o_Id
 * @param enterpriseSn
 * @param orgCode
 * @return
 * @throws Exception
 */
public OrgCode updateOrgCode(Long o_Id, String enterpriseSn, OrgCode orgCode) throws Exception {
    if (null == orgCode) {
        return null;
    }
    orgCode.setId(o_Id);
    OrgCode orgCode1 = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByPrimaryKey", o_Id);
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    if (StringUtils.isNotBlank(orgCode.getImgFile())) {
        FileUtils.deleteQuietly(new File(imgDir, orgCode1.getImgFile()));
        File liceImg = filePathUtils.saveImg(imgDir, null, orgCode.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_ORG);
        if (liceImg != null && liceImg.isFile()) {
            orgCode.setImgFile(liceImg.getName());
            orgCode.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
        }
    } else {
        orgCode.setImgFile(orgCode1.getImgFile());
    }
    sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKeySelective", orgCode);
    sqlSession.flushStatements();
    return orgCode;
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) File(java.io.File)

Example 14 with OrgCode

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

the class OrgCodeServiceImpl method saveOrgCodeExtraBill.

/**
 * 增值订单保存组织机构代码
 * @param enterPriseId
 * @param enterpriseSn
 * @param billId
 * @param userInfoId
 * @param orgCode
 * @param itemStatus
 * @param old
 * @return
 * @throws Exception
 */
public OrgCode saveOrgCodeExtraBill(Long enterPriseId, String enterpriseSn, Long billId, Long userInfoId, OrgCode orgCode, Integer itemStatus, OrgCode old) throws Exception {
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    Enterprise ent = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", enterPriseId);
    // 判断组织机构代码图片是否重新上传了,没有重新上传,则会提交组织机构代码的id,重新上传,还是按照下面的方法处理
    if (null != orgCode.getId()) {
        OrgCode newOrgCode = new OrgCode();
        OrgCode oldOrgCode = sqlSession.selectOne("com.itrus.portal.db.OrgCodeMapper.selectByPrimaryKey", orgCode.getId());
        newOrgCode.setEnterpriseName(orgCode.getEnterpriseName());
        newOrgCode.setOrgCode(orgCode.getOrgCode());
        newOrgCode.setCreateTime(new Date());
        newOrgCode.setLastModify(new Date());
        newOrgCode.setEnterprise(enterPriseId);
        newOrgCode.setExtraBill(billId);
        newOrgCode.setUserInfo(userInfoId);
        // 审核状态:1未审核,2已审核,3已拒绝
        newOrgCode.setItemStatus(oldOrgCode.getItemStatus());
        if (null != orgCode.getOrgCodeType())
            newOrgCode.setOrgCodeType(orgCode.getOrgCodeType());
        if (StringUtils.isNotBlank(orgCode.getImgFile())) {
            File liceImg = filePathUtils.saveImg(imgDir, null, orgCode.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_ORG);
            if (liceImg != null && liceImg.isFile()) {
                newOrgCode.setImgFile(liceImg.getName());
                newOrgCode.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
            }
        } else {
            newOrgCode.setImgFile(oldOrgCode.getImgFile());
            newOrgCode.setImgFileHash(oldOrgCode.getImgFileHash());
        }
        sqlSession.insert("com.itrus.portal.db.OrgCodeMapper.insert", newOrgCode);
        sqlSession.flushStatements();
        return newOrgCode;
    }
    if ((null == orgCode || StringUtils.isBlank(orgCode.getEnterpriseName()) || StringUtils.isBlank(orgCode.getOrgCode())) && ent.getEnterpriseNature() != 2) {
        throw new UserInfoServiceException("请提交完整的组织机构代码信息");
    }
    orgCode.setCreateTime(new Date());
    orgCode.setLastModify(new Date());
    orgCode.setEnterprise(enterPriseId);
    orgCode.setExtraBill(billId);
    orgCode.setUserInfo(userInfoId);
    // 审核状态:1未审核,2已审核,3已拒绝
    orgCode.setItemStatus(itemStatus);
    if (StringUtils.isNotBlank(orgCode.getImgFile()) && !ComNames.USE_OLD_IMG.equals(orgCode.getImgFile())) {
        File liceImg = filePathUtils.saveImg(imgDir, null, orgCode.getImgFile(), IMG_DEFAULT_TYPE, IMG_NAME_ORG);
        if (liceImg != null && liceImg.isFile()) {
            orgCode.setImgFile(liceImg.getName());
            orgCode.setImgFileHash(HMACSHA1.genSha1HashOfFile(liceImg));
        }
    }
    if (old == null) {
        sqlSession.insert("com.itrus.portal.db.OrgCodeMapper.insert", orgCode);
    } else {
        orgCode.setId(old.getId());
        sqlSession.update("com.itrus.portal.db.OrgCodeMapper.updateByPrimaryKeySelective", orgCode);
    }
    sqlSession.flushStatements();
    return orgCode;
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) Enterprise(com.itrus.portal.db.Enterprise) File(java.io.File) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Example 15 with OrgCode

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

the class OrgCodeServiceImpl method getOrgCodesNews2.

/**
 * 查询数据库中是否存在该用户,该企业,未关联订单和增值订单.并且认证通过的信息,按生成时间降序排序
 *
 * @param enterpriseId
 * @return
 */
public OrgCode getOrgCodesNews2(Long enterpriseId, Long userinfoId) {
    List<OrgCode> orgCodes = new ArrayList<OrgCode>();
    OrgCodeExample example = new OrgCodeExample();
    example.setOrderByClause("create_time DESC");
    OrgCodeExample.Criteria criteria = example.or();
    criteria.andEnterpriseEqualTo(enterpriseId);
    criteria.andUserInfoEqualTo(userinfoId);
    criteria.andBillIsNull();
    criteria.andExtraBillIsNull();
    orgCodes = sqlSession.selectList("com.itrus.portal.db.OrgCodeMapper.selectByExample", example);
    if (null == orgCodes || orgCodes.isEmpty()) {
        return null;
    }
    return orgCodes.get(0);
}
Also used : OrgCode(com.itrus.portal.db.OrgCode) ArrayList(java.util.ArrayList) OrgCodeExample(com.itrus.portal.db.OrgCodeExample)

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