Search in sources :

Example 6 with Certification

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

the class ReviewServiceImpl method getCertificationItems.

/**
 * 获取订单产品的实名认证项
 *
 * @param productId
 * @return
 */
public Long[] getCertificationItems(Long productId) {
    // 获取产品的认证等级需要认证的项
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId);
    Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", product.getAuthentication());
    /**
     * 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者
     */
    Long[] items = StringTools.getLong(certification.getCertItems());
    return items;
}
Also used : Product(com.itrus.portal.db.Product) Certification(com.itrus.portal.db.Certification)

Example 7 with Certification

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

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

the class BankCertificationController method create.

// 跳转yinhangkarenzheng页面
@RequestMapping("/create/{productId}")
public String create(@PathVariable("productId") Long productId, HttpServletRequest request, Model uiModel) {
    // 得到当前个人用户信息
    HttpSession session = request.getSession();
    PersonInfo personInfo = (PersonInfo) session.getAttribute("webuserInfo");
    // PersonInfo personInfo =personInfoService.getSelectById(personId);
    // 得到对应的产品
    Product product = productService.getProductById(productId);
    // 得到对应的认证项
    Certification certification = certificationService.getSelectById(product.getAuthentication());
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("personInfo", personInfo);
    uiModel.addAttribute("certification", certification);
    return "gerenrenzheng/yinhangkarenzheng";
}
Also used : PersonInfo(com.itrus.portal.db.PersonInfo) HttpSession(javax.servlet.http.HttpSession) Product(com.itrus.portal.db.Product) Certification(com.itrus.portal.db.Certification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Certification

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

the class IdCertificationController method create.

// 跳转shenfenrenzheng页面
@RequestMapping("/create/{productId}")
public String create(@PathVariable("productId") Long productId, HttpServletRequest request, Model uiModel) {
    // 得到当前个人用户信息
    HttpSession session = request.getSession();
    PersonInfo personInfo = (PersonInfo) session.getAttribute("webuserInfo");
    // PersonInfo personInfo =personInfoService.getSelectById(personId);
    // 得到对应的产品
    Product product = productService.getProductById(productId);
    // 得到对应的认证项
    Certification certification = certificationService.getSelectById(product.getAuthentication());
    uiModel.addAttribute("personInfo", personInfo);
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("certification", certification);
    return "gerenrenzheng/shenfenrenzheng";
}
Also used : PersonInfo(com.itrus.portal.db.PersonInfo) HttpSession(javax.servlet.http.HttpSession) Product(com.itrus.portal.db.Product) Certification(com.itrus.portal.db.Certification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with Certification

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

the class APIService method entAuth.

/**
 * 提交企业认证申请
 *
 * @param authHmac
 *            hmac签名值,采用HmacSHA1算法
 * @param appId
 *            应用标识
 * @param productId
 *            项目产品标识
 * @param orderNumber
 *            申请流水号,审核拒绝修改提交时必填 (创建申请为空,修改申请不为空)
 * @param enterpriseType
 *            企业类型 1.企业,2.个体工商户,3.事业单位/政府机关
 * @param isThreeInOne
 *            是否三证合一
 * @param enterpriseName
 *            企业名称,事业单位名称
 * @param licenseNo
 *            营业执照注册号或统一社会信用代码,事业单位法人证书编号
 * @param orgCode
 *            组织机构代码(三证合一时非必填)
 * @param taxNo
 *            税务登记证号码(三证合一时非必填,或根据业务需要选填)
 * @param legalName
 *            法定代表人姓名(根据业务需要选填)
 * @param legalCardType
 *            证件类型(1代表身份证,2护照,3其他)
 * @param legalIdCardNo
 *            证件号码
 * @param agentName
 *            代理人姓名
 * @param agentPhone
 *            代理人手机号
 * @param agentEmail
 *            代理人邮箱
 * @param agentTelephone
 *            代理人固定电话(非必填)
 * @param agentCardType
 *            证件类型(1代表身份证,2护照,3其他)
 * @param agentIdCardNo
 *            证件号码
 * @return status 1: 表示处理正常, billId: 订单编号, orderNumber: 申请流水号 status 0:
 *         表示处理失败, message: 失败原因
 */
@PostMapping(value = "/auth/entAuth")
@ResponseBody
public Map<String, Object> entAuth(@RequestHeader("Content-Signature") String authHmac, @RequestParam(value = "appId", required = true) String appId, @RequestParam(value = "productId", required = true) String productId, @RequestParam(value = "orderNumber", required = false) String orderNumber, @RequestParam(value = "enterpriseType", required = false) String enterpriseType, @RequestParam(value = "isThreeInOne", required = true) boolean isThreeInOne, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, @RequestParam(value = "licenseNo", required = false) String licenseNo, @RequestParam(value = "orgCode", required = false) String orgCode, @RequestParam(value = "taxNo", required = false) String taxNo, @RequestParam(value = "legalName", required = false) String legalName, @RequestParam(value = "legalCardType", required = false) Integer legalCardType, @RequestParam(value = "legalIdCardNo", required = false) String legalIdCardNo, @RequestParam(value = "agentName", required = false) String agentName, @RequestParam(value = "agentPhone", required = false) String agentPhone, @RequestParam(value = "agentEmail", required = false) String agentEmail, @RequestParam(value = "agentTelephone", required = false) String agentTelephone, @RequestParam(value = "agentCardType", required = false) Integer agentCardType, @RequestParam(value = "agentIdCardNo", required = false) String agentIdCardNo, HttpServletRequest request) {
    log.error("【APIService 提交申请日志】appId=" + appId + ",productId=" + productId + ",orderNumber=" + orderNumber + ",enterpriseType=" + enterpriseType + ",isThreeInOne=" + isThreeInOne + ",enterpriseName" + enterpriseName + ",licenseNo=" + licenseNo + ",orgCode=" + orgCode + ",taxNo=" + taxNo + ",legalName=" + legalName + ",legalCardType=" + legalCardType + ",legalIdCardNo=" + legalIdCardNo + ",agentName=" + agentName + ",agentPhone=" + agentPhone + ",agentEmail=" + agentEmail + ",agentTelephone=" + agentTelephone + ",agentCardType=" + agentCardType + ",agentIdCardNo=" + agentIdCardNo);
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("status", 0);
    // 验证参数是否完整
    if (StringUtils.isEmpty(authHmac) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(productId) || StringUtils.isEmpty(enterpriseType) || StringUtils.isEmpty(enterpriseName) || StringUtils.isEmpty(licenseNo) || StringUtils.isEmpty(agentName) || StringUtils.isEmpty(agentPhone) || StringUtils.isEmpty(agentEmail)) {
        result.put("status", 0);
        result.put("message", "提交的参数信息不完整");
        return result;
    }
    // 得到对应产品信息
    Product product = productService.getProductById(StringTools.getLong(productId)[0]);
    if (product == null) {
        result.put("status", 0);
        result.put("message", "提交的项目产品标识有误");
        return result;
    }
    // 得到应用信息 改成service
    Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
    ApplicationInfo applicationInfo = appInfoMap.get(appId);
    if (applicationInfo == null) {
        ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
        ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
        appInfoExampleCriteria.andAppIdEqualTo(appId);
        applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
    }
    if (applicationInfo == null) {
        result.put("message", "应用标识不存在");
        return result;
    }
    if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
        result.put("status", -1);
        result.put("message", "没有此服务权限");
        log.error("APIService_AccsessIp : " + request.getRemoteAddr());
        return result;
    }
    // 验证hmac有效性
    try {
        String macVal = CertService.hmacSha1(applicationInfo.getSecretKey().getBytes(), (appId + productId + orderNumber + enterpriseType + isThreeInOne + enterpriseName + licenseNo + orgCode + taxNo + legalName + legalCardType + legalIdCardNo + agentName + agentPhone + agentEmail + agentTelephone + agentCardType + agentIdCardNo).getBytes("utf-8"));
        // sc.getAddressKey()), false);
        if (!authHmac.equals("HMAC-SHA1 " + macVal)) {
            result.put("status", -2);
            result.put("message", "服务密钥错误");
            return result;
        }
    } catch (Exception e) {
        result.put("status", -3);
        result.put("message", "Hmac验证错误");
        e.printStackTrace();
        return result;
    }
    // orderNumber==null true:新建 , false:审核拒绝修改提交
    if (StringUtils.isEmpty(orderNumber)) {
        UserInfo userInfo = null;
        Certification certification = null;
        // 获取产品的认证等级需要认证的项
        certification = certificationService.getSelectById(product.getAuthentication());
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        TransactionStatus status = transactionManager.getTransaction(def);
        try {
            // 判断手机号是否存在
            userInfo = userInfoService.getUserInfoByMphone(agentPhone);
            if (userInfo != null) {
            /*
					 * result.put("status", 0); result.put("message",
					 * "该手机号已经存在关联用户"); return result;
					 */
            } else {
                try {
                    int passNumber = (int) ((Math.random() * 9 + 1) * 10000000);
                    // 新建用户 随机密码默认
                    userInfo = userInfoService.registerUserInfo(agentPhone, String.valueOf(passNumber), product.getProject());
                } catch (Exception e) {
                    result.put("status", 0);
                    result.put("message", "新建用户失败,请重试");
                    return result;
                }
            }
            /**
             * 需要认证的项:0营业执照,1组织机构代码,2税务登记证,3授权书,4法定代表人/经营者 5代理人
             */
            Long[] items = StringTools.getLong(certification.getCertItems());
            // 保存企业信息
            Enterprise enterprise = new Enterprise();
            enterprise.setEnterpriseName(enterpriseName);
            enterprise.setEnterpriseNature(Integer.parseInt(enterpriseType));
            enterprise.setAuthenticationLevel(product.getAuthentication());
            enterprise = enterpriseService.saveOrUpdateEnterprise(enterprise);
            // 保存代理人信息
            userInfo.setEmail(agentEmail);
            userInfo.setRealName(agentName);
            userInfo = userInfoService.updateUserInfo(userInfo);
            // 添加企业-代理人关联关系
            userInfoEnterpriseServiceImpl.saveUserInfoEnterprise(userInfo.getId(), enterprise.getId());
            // 生成订单
            Bill bill = billService.saveBill(userInfo.getId(), enterprise.getId(), product.getId(), null, null, null, null, product.getProject(), 1, product.getPrice(), userInfo.getId(), ComNames.BILL_STATUS_3);
            String billId = UniqueIDUtils.genBilUID(bill);
            bill.setBillId(billId);
            bill.setAppId(appId);
            bill.setUid("{}");
            bill.setUid0("{}");
            bill.setOrderNumber(billId.substring(4, billId.length()));
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
            sqlSession.flushStatements();
            // 保持执照证件信息
            // 是否有营业执照信息,默认false没有
            boolean hasBl = false;
            BusinessLicense businessLicense = new BusinessLicense();
            OrgCode org = new OrgCode();
            TaxRegisterCert taxregisterCert = new TaxRegisterCert();
            IdentityCard identityCard = new IdentityCard();
            Agent agent = new Agent();
            Proxy proxy = new Proxy();
            for (Long item : items) {
                if (ComNames.BUSINESS_ITEM.equals(item) && !enterprise.getEnterpriseNature().equals(3)) {
                    // 事业单位不填写营业执照
                    hasBl = true;
                    // 设置企业唯一标识
                    if (enterprise.getEnterpriseNature().equals(1) || enterprise.getEnterpriseNature().equals(2)) {
                        // 类型为企业和个体工商户:当三证合一时,企业标识为统一社会信用代码;当非三证合一时,企业标识为营业执照注册号;
                        enterprise.setEnterpriseSn(licenseNo);
                    }
                    // 保存营业执照
                    businessLicense.setEnterpriseName(enterpriseName);
                    if (isThreeInOne) {
                        businessLicense.setBusinessType(1);
                    } else {
                        businessLicense.setBusinessType(0);
                    }
                    businessLicense.setLicenseNo(licenseNo);
                    businessLicense = businessService.portSaveBusiness(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), businessLicense, null != businessLicense.getId() ? 2 : 1);
                } else if (ComNames.ORG_CODE_ITEM.equals(item)) {
                    if (hasBl && businessLicense.getBusinessType().equals(1))
                        // 五证合一企业不用提交组织机构代码、税务登记信息
                        continue;
                    if (enterprise.getEnterpriseNature().equals(3)) {
                        // 类型为政府机关/事业单位:企业标识为组织机构代码
                        enterprise.setEnterpriseSn(orgCode);
                    }
                    // 保存组织机构代码
                    org.setEnterpriseName(enterpriseName);
                    org.setOrgCode(orgCode);
                    org = orgCodeService.saveOrgCode(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), org, null != org.getId() ? 2 : 1);
                } else if (ComNames.TAX_CERT_ITEM.equals(item)) {
                    if (hasBl && businessLicense.getBusinessType().equals(1))
                        // 五证合一企业不用提交组织机构代码、税务登记信息
                        continue;
                    // 保存税务登记证
                    if (enterprise.getEnterpriseNature().equals(3))
                        // 事业单位不填写税务登记信息
                        continue;
                    taxregisterCert.setEnterpriseName(enterpriseName);
                    taxregisterCert.setCertNo(taxNo);
                    taxregisterCert = taxCertService.saveTaxCert(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), taxregisterCert, null != taxregisterCert.getId() ? 2 : 1);
                } else if (ComNames.IDENTITY_CARD_ITEM.equals(item)) {
                    // 保存法定代表人
                    identityCard.setEnterpriseName(enterpriseName);
                    identityCard.setName(legalName);
                    identityCard.setCardType(legalCardType);
                    identityCard.setIdCode(legalIdCardNo);
                    identityCard = identityCardService.portSaveIdentityCard(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), identityCard, null != identityCard.getId() ? 2 : 1);
                } else if (ComNames.AGENT_ITEM.equals(item)) {
                    // 保存代理人
                    agent.setEnterpriseName(enterpriseName);
                    agent.setName(agentName);
                    agent.setIdCode(agentIdCardNo);
                    agent.setCardType(agentCardType);
                    agent = agentService.portSaveAgent(enterprise.getId(), enterprise.getEnterpriseSn(), bill.getId(), userInfo.getId(), agent, null != agent.getId() ? 2 : 1);
                } else if (ComNames.PROXY_ITEM.equals(item)) {
                    // 保存授权书
                    proxy = proxyService.portSaveProxy(enterprise.getId(), userInfo.getUniqueId(), bill.getId(), userInfo.getId(), proxy);
                }
            }
            // 更新企业唯一标识
            enterprise = enterpriseService.updateEnterpriseSn(enterprise);
            transactionManager.commit(status);
            // 返回第三方数据
            result.put("status", 1);
            result.put("billId", bill.getBillId());
            result.put("orderNumber", bill.getOrderNumber());
            // 记录日志
            UserLog userlog = new UserLog();
            userlog.setProject(userInfo.getProject());
            userlog.setType("购买产品");
            userlog.setInfo(userInfo.getmPhone() + "购买了" + product.getName() + ",应用标识:" + appId);
            userlog.setHostId("未知");
            userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
            LogUtil.userlog(sqlSession, userlog);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            if (!status.isCompleted())
                transactionManager.rollback(status);
            UserLog userlog = new UserLog();
            userlog.setProject(product.getProject());
            userlog.setType("购买产品");
            userlog.setInfo("url:/api/auth/search,应用标识:" + appId + ",详细错误:" + e.getMessage());
            userlog.setHostId("未知");
            userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
            LogUtil.userlog(sqlSession, userlog);
            if (e.getMessage().contains("请提交完整") || e.getMessage().contains("请确认输入是否有误")) {
                result.put("message", e.getMessage());
                return result;
            }
            result.put("message", "服务端出现未知错误,请联系管理员");
            return result;
        } finally {
            if (!status.isCompleted())
                transactionManager.rollback(status);
        }
    } else {
        // 提交企业认证申请(审核拒绝修改提交时)
        Bill bill = billService.getBillByOrderNumber(orderNumber);
        if (bill == null) {
            result.put("message", "申请流水号不存在");
            return result;
        }
        UserInfo userInfo = userInfoService.getUserInfoByBillId(bill.getId());
        Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
        if (bill.getBillStatus() != ComNames.BILL_STATUS_4) {
            result.put("message", "该订单未审核拒绝");
            return result;
        }
        // 根据订单id获取产品需要认证项,
        List<String> certItems = sqlSession.selectList("com.itrus.portal.db.CertificationMapper.selectCertItemsByBillId", bill.getId());
        if (null == certItems || certItems.isEmpty()) {
            result.put("message", "服务端出现异常,请联系管理员");
            return result;
        }
        // 记录旧的企业唯一标识:
        String oldEnterpriseSn = enterprise.getEnterpriseSn();
        // 设置企业唯一标识
        if (enterpriseType.equals(1) || enterpriseType.equals(2)) {
            // 类型为企业和个体工商户:当三证合一时,企业标识为统一社会信用代码;当非三证合一时,企业标识为营业执照注册号;
            enterprise.setEnterpriseSn(licenseNo);
        }
        if (enterpriseType.equals(3)) {
            // 类型为政府机关/事业单位:企业标识为组织机构代码
            enterprise.setEnterpriseSn(orgCode);
        }
        // 修改企业名称
        enterprise.setEnterpriseName(enterpriseName.replace(" ", ""));
        // 修改企业性质
        enterprise.setEnterpriseNature(Integer.parseInt(enterpriseType));
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        TransactionStatus status = transactionManager.getTransaction(def);
        try {
            // 将参数传入对象
            BusinessLicense businessLicense = new BusinessLicense();
            OrgCode orgCd = new OrgCode();
            TaxRegisterCert taxregisterCert = new TaxRegisterCert();
            IdentityCard identityCard = new IdentityCard();
            Agent agent = new Agent();
            Proxy proxy = new Proxy();
            businessLicense.setEnterpriseName(enterpriseName);
            if (isThreeInOne) {
                businessLicense.setBusinessType(1);
            } else {
                businessLicense.setBusinessType(0);
            }
            businessLicense.setLicenseNo(licenseNo);
            orgCd.setEnterpriseName(enterpriseName);
            orgCd.setOrgCode(orgCode);
            taxregisterCert.setEnterpriseName(enterpriseName);
            taxregisterCert.setCertNo(taxNo);
            identityCard.setEnterpriseName(enterpriseName);
            identityCard.setName(legalName);
            identityCard.setCardType(legalCardType);
            identityCard.setIdCode(legalIdCardNo);
            agent.setEnterpriseName(enterpriseName);
            agent.setName(agentName);
            agent.setIdCode(agentIdCardNo);
            agent.setCardType(agentCardType);
            // 删除订单关联的旧认证项,新增订单对应的新认证项
            billWebService.portSaveBillAuthenticationItems(certItems.get(0), Integer.parseInt(enterpriseType), bill.getId(), businessLicense, orgCd, taxregisterCert, identityCard, agent, proxy, enterprise, userInfo);
            // 3、判断该订单对应的企业的认证项是否为通过,若是通过,则重新设置为不通过
            if (null != enterprise.getAuthenticationLevel())
                enterprise.setAuthenticationLevel(product.getAuthentication());
            if (null != enterprise.getHasBl())
                enterprise.setHasBl(null);
            if (null != enterprise.getHasOrgCode())
                enterprise.setHasOrgCode(null);
            if (null != enterprise.getHasTaxCert())
                enterprise.setHasTaxCert(null);
            if (null != enterprise.getHasIdCard())
                enterprise.setHasIdCard(null);
            if (null != enterprise.getHasAgent())
                enterprise.setHasAgent(null);
            sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey", enterprise);
            bill.setBillStatus(ComNames.BILL_STATUS_3);
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
            transactionManager.commit(status);
            // 企业标识改变后,将旧目录中的图片复制到新目录中
            if (!oldEnterpriseSn.equals(enterprise.getEnterpriseSn())) {
                CopyFile.copyFile(systemConfigService.getTrustDir().getPath() + File.separator + oldEnterpriseSn, systemConfigService.getTrustDir().getPath() + File.separator + enterprise.getEnterpriseSn());
            }
            // 判断代理人手机号是否存在 true:把全部订单关联到新手机号用户
            UserInfo userInfo1 = userInfoService.getUserInfoByMphone(agentPhone);
            if (userInfo1 != null) {
                BillExample be = new BillExample();
                BillExample.Criteria bec = be.createCriteria();
                bec.andUniqueIdEqualTo(userInfo.getId());
                List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", be);
                // 循环修改订单关联的用户信息
                for (Bill b : billList) {
                    b.setUniqueId(userInfo1.getId());
                    sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", b);
                }
                userInfo1.setEnterprise(userInfo.getEnterprise());
                sqlSession.update("com.itrus.portal.db.UserInfoMapper.updateByPrimaryKeySelective", userInfo1);
                userInfo.setEnterprise(null);
                sqlSession.update("com.itrus.portal.db.UserInfoMapper.updateByPrimaryKeySelective", userInfo);
                UserinfoEnterpriseExample uee = new UserinfoEnterpriseExample();
                UserinfoEnterpriseExample.Criteria ueec = uee.createCriteria();
                ueec.andUserInfoEqualTo(userInfo.getId());
                List<UserinfoEnterprise> ueList = sqlSession.selectList("com.itrus.portal.db.UserinfoEnterpriseMapper.selectByExample", uee);
                for (UserinfoEnterprise ue : ueList) {
                    ue.setUserInfo(userInfo1.getId());
                    sqlSession.update("com.itrus.portal.db.UserinfoEnterpriseMapper.updateByPrimaryKeySelective", ue);
                }
            } else {
                userInfo.setmPhone(agentPhone);
                sqlSession.update("com.itrus.portal.db.UserInfoMapper.updateByPrimaryKeySelective", userInfo);
            }
            result.put("status", 1);
            result.put("billId", bill.getBillId());
        } catch (UserInfoServiceException e) {
            if (!status.isCompleted())
                transactionManager.rollback(status);
            result.put("message", "服务端出现未知错误,请联系管理员");
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            if (!status.isCompleted())
                transactionManager.rollback(status);
            UserLog userlog = new UserLog();
            userlog.setType("修改订单");
            userlog.setInfo("url:/api/auth/search,应用标识:" + appId + ",详细错误:" + e.getMessage());
            userlog.setHostId("未知");
            userlog.setProject(userInfo.getProject());
            LogUtil.userlog(sqlSession, userlog);
            result.put("message", "服务端出现未知错误,请联系管理员");
            if (e.getMessage().contains("有误")) {
                result.put("message", e.getMessage());
            }
            return result;
        } finally {
            if (!status.isCompleted())
                transactionManager.rollback(status);
        }
        return result;
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) Product(com.itrus.portal.db.Product) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) Proxy(com.itrus.portal.db.Proxy) BillExample(com.itrus.portal.db.BillExample) UserinfoEnterpriseExample(com.itrus.portal.db.UserinfoEnterpriseExample) IdentityCard(com.itrus.portal.db.IdentityCard) ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) Agent(com.itrus.portal.db.Agent) UserLog(com.itrus.portal.db.UserLog) JSONException(org.json.JSONException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Certification(com.itrus.portal.db.Certification) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) Bill(com.itrus.portal.db.Bill) JSONObject(com.alibaba.fastjson.JSONObject) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Certification (com.itrus.portal.db.Certification)14 Product (com.itrus.portal.db.Product)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 Enterprise (com.itrus.portal.db.Enterprise)7 BusinessLicense (com.itrus.portal.db.BusinessLicense)5 IdentityCard (com.itrus.portal.db.IdentityCard)5 OrgCode (com.itrus.portal.db.OrgCode)5 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)5 UserInfo (com.itrus.portal.db.UserInfo)5 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)5 HashMap (java.util.HashMap)5 Bill (com.itrus.portal.db.Bill)4 Proxy (com.itrus.portal.db.Proxy)4 Agent (com.itrus.portal.db.Agent)3 BillExample (com.itrus.portal.db.BillExample)3 DigitalCert (com.itrus.portal.db.DigitalCert)3 TransactionStatus (org.springframework.transaction.TransactionStatus)3 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)3 JSONObject (com.alibaba.fastjson.JSONObject)2 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)2