Search in sources :

Example 21 with Agent

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

the class AgentServiceImpl method saveAgentExtraBill.

/**
 * 增值订单保存代理人信息
 * @param enterpriseId
 * @param enterpriseSn
 * @param billId
 * @param userInfoId
 * @param agent
 * @param itemStatus
 * @param old
 * @return
 * @throws Exception
 */
public Agent saveAgentExtraBill(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.setExtraBill(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()) || StringUtils.isBlank(agent.getFrontImg())) {
        throw new UserInfoServiceException("请提交完整的代理人信息");
    }
    agent.setCreateTime(new Date());
    agent.setLastModify(new Date());
    // 审核状态:1未审核,2已审核,3已拒绝
    agent.setItemStatus(itemStatus);
    agent.setEnterprise(enterpriseId);
    agent.setExtraBill(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.updateByPrimaryKeySelective", 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)

Example 22 with Agent

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

the class AgentServiceImpl method portUpdateAgent.

/**
 * 代理人证件图片上传(接口)
 *
 * @param billId
 * @param enterpriseSn
 * @param identityCard
 * @return
 * @throws Exception
 */
public Agent portUpdateAgent(Long billId, String enterpriseSn, String image1, String image2) throws Exception {
    Agent agent = this.getAgentByBillId(billId, null);
    if (null == agent) {
        return null;
    }
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    if (StringUtils.isNotBlank(agent.getBackImg())) {
        FileUtils.deleteQuietly(new File(imgDir, agent.getBackImg()));
    }
    if (StringUtils.isNotBlank(agent.getFrontImg())) {
        FileUtils.deleteQuietly(new File(imgDir, agent.getFrontImg()));
    }
    // 正面(或者合成)图片
    if (StringUtils.isNotBlank(image1)) {
        File frontImg = filePathUtils.saveImg(imgDir, null, image1, IMG_DEFAULT_TYPE, IMG_NAME_ID_FRONT);
        if (frontImg != null && frontImg.isFile()) {
            agent.setFrontImg(frontImg.getName());
            agent.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
        }
    }
    // 反面图片
    if (StringUtils.isNotBlank(image2)) {
        File backImg = filePathUtils.saveImg(imgDir, null, image2, IMG_DEFAULT_TYPE, IMG_NAME_ID_BACK);
        if (backImg != null && backImg.isFile()) {
            agent.setBackImg(backImg.getName());
            agent.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
        }
    }
    sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKeySelective", agent);
    sqlSession.flushStatements();
    return agent;
}
Also used : Agent(com.itrus.portal.db.Agent) File(java.io.File)

Example 23 with Agent

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

the class AgentServiceImpl method saveAgent1.

public Agent saveAgent1(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()) || StringUtils.isBlank(agent.getFrontImg())) {
        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)

Example 24 with Agent

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

the class AgentServiceImpl method updateAgent.

/**
 * 修改代理人信息
 *
 * @param a_Id
 * @param enterpriseSn
 * @param agent
 * @return
 * @throws Exception
 */
public Agent updateAgent(Long a_Id, String enterpriseSn, Agent agent) throws Exception {
    if (null == agent) {
        return null;
    }
    agent.setId(a_Id);
    Agent agent1 = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectByPrimaryKey", a_Id);
    File imgDir = filePathUtils.getEnterpriseFile(enterpriseSn);
    if (StringUtils.isNotBlank(agent.getBackImg())) {
        FileUtils.deleteQuietly(new File(imgDir, agent1.getBackImg()));
    }
    if (StringUtils.isNotBlank(agent.getFrontImg())) {
        FileUtils.deleteQuietly(new File(imgDir, agent1.getFrontImg()));
    }
    // 正面(或者合成)图片
    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()) {
            agent.setFrontImg(frontImg.getName());
            agent.setFrontImgHash(HMACSHA1.genSha1HashOfFile(frontImg));
        }
    } else {
        agent.setFrontImg(agent1.getFrontImg());
    }
    // 反面图片
    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()) {
            agent.setBackImg(backImg.getName());
            agent.setBackImgHash(HMACSHA1.genSha1HashOfFile(backImg));
        }
    } else {
        agent.setBackImg(agent1.getBackImg());
    }
    sqlSession.update("com.itrus.portal.db.AgentMapper.updateByPrimaryKeySelective", agent);
    sqlSession.flushStatements();
    return agent;
}
Also used : Agent(com.itrus.portal.db.Agent) File(java.io.File)

Example 25 with Agent

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

the class ReviewServiceImpl method agreeBillReview.

/**
 * pfx证书,当不要审核的时候,自动生成审核记录
 * @param bill
 */
public void agreeBillReview(Bill bill) {
    if (null == bill) {
        return;
    }
    // 填充营业执照运营时间
    Enterprise enterpriseInBill = enterpriseService.getEnterpriseByBillId(bill.getId());
    String soperationStart = null;
    String soperationEnd = null;
    List<BusinessLicense> oldBusinessLicenses = businessService.getBusinessLicensesNews(bill.getEnterprise());
    if (null != oldBusinessLicenses && !oldBusinessLicenses.isEmpty()) {
        for (BusinessLicense businessLicense1 : oldBusinessLicenses) {
            if (null != businessLicense1.getOperationStart() || null != businessLicense1.getOperationEnd()) {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                if (null != businessLicense1.getOperationStart()) {
                    soperationStart = format.format(businessLicense1.getOperationStart());
                }
                if (null != businessLicense1.getOperationEnd()) {
                    soperationEnd = format.format(businessLicense1.getOperationEnd());
                }
                break;
            }
        }
    }
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
    Certification certification = sqlSession.selectOne("com.itrus.portal.db.CertificationMapper.selectByPrimaryKey", product.getAuthentication());
    Project project = billService.getProjectByBillId(bill.getId());
    BusinessLicense businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
    OrgCode orgCode = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
    TaxRegisterCert taxregisterCert = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
    IdentityCard identityCard = identityCardService.getIdentityCardByBillId(bill.getId(), null);
    Agent agent = agentService.getAgentByBillId(bill.getId(), null);
    Proxy proxy = proxyService.getProxyByBillId(bill.getId());
    // 更新管理员提交的认证项资料信息
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        Long businessId = null;
        Long orgCodeId = null;
        Long taxregisterId = null;
        Long identityCardId = null;
        Long agentId = null;
        Long proxyId = null;
        // 更新营业执照信息
        if (null != businessLicense && null != businessLicense.getId()) {
            businessLicense = businessService.updateBusinessLicense(soperationStart, soperationEnd, businessLicense, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            businessId = businessLicense.getId();
        }
        // 更新组织机构代码
        if (null != orgCode && null != orgCode.getId()) {
            orgCode = orgCodeService.updateOrgCode(orgCode, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            orgCodeId = orgCode.getId();
        }
        // 更新税务登记
        if (null != taxregisterCert && null != taxregisterCert.getId()) {
            taxregisterCert = taxCertService.updateTaxRegisterCert(taxregisterCert, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            taxregisterId = taxregisterCert.getId();
        }
        // 更新法定代表人
        if (null != identityCard && null != identityCard.getId()) {
            identityCard = identityCardService.updateIdentityCard(identityCard, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            identityCardId = identityCard.getId();
        }
        // 更新代理人
        if (null != agent && null != agent.getId()) {
            agent = agentService.updateAgent(agent, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null);
            agentId = agent.getId();
        }
        // 更新授权书
        if (null != proxy && null != proxy.getId()) {
            proxy = proxyService.updateProxy(proxy, ComNames.ITEM_STATUS_2, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), null, project);
            proxyId = proxy.getId();
        }
        // 设置第一个admin账号
        AdminExample adminExample = new AdminExample();
        adminExample.setOrderByClause("create_time ASC");
        List<Admin> admins = sqlSession.selectList("com.itrus.portal.db.AdminMapper.selectByExample", adminExample);
        // 更新企业信息
        Enterprise enterprise = enterpriseService.updateEnterprise(bill.getEnterprise(), certification.getId(), businessId, orgCodeId, taxregisterId, identityCardId, agentId);
        // 生成认证记录
        reviewLogService.saveReviewLog(2, admins.get(0).getId(), 1, null, bill.getEnterprise(), bill.getId(), bill.getUniqueId(), businessId, orgCodeId, taxregisterId, identityCardId, agentId, proxyId);
        bill.setCheckTime(new Date());
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
        transactionManager.commit(status);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
}
Also used : Agent(com.itrus.portal.db.Agent) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Product(com.itrus.portal.db.Product) TransactionStatus(org.springframework.transaction.TransactionStatus) Admin(com.itrus.portal.db.Admin) Certification(com.itrus.portal.db.Certification) Date(java.util.Date) ParseException(java.text.ParseException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) DigitalCert(com.itrus.portal.db.DigitalCert) Project(com.itrus.portal.db.Project) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) Proxy(com.itrus.portal.db.Proxy) Enterprise(com.itrus.portal.db.Enterprise) SimpleDateFormat(java.text.SimpleDateFormat) AdminExample(com.itrus.portal.db.AdminExample) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) IdentityCard(com.itrus.portal.db.IdentityCard)

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