Search in sources :

Example 21 with Bill

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

the class MakeCertController method reMakeCert.

/**
 * 已制证的订单修改状态为待制证
 *
 * @param certId
 *            证书id
 * @return
 */
@ResponseBody
@RequestMapping("/reMakeCert")
public Map<String, Object> reMakeCert(@RequestParam(value = "certId", required = true) Long certId) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", certId);
    if (null == userCert) {
        retMap.put("msg", "该证书不存在");
        return retMap;
    }
    // 设置证书id状态为0,标识制证异常
    userCert.setCertStatus("0");
    // 设置注册用户状态(百润)为 0 未注册
    userCert.setIsRegister(0);
    // 修改对应订单状态为待制证状态5
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", userCert.getBill());
    if (null == bill) {
        retMap.put("msg", "对应的订单不存在");
        return retMap;
    }
    bill.setBillStatus(ComNames.BILL_STATUS_5);
    // 判断证书是否为用户下载方式
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    // 判断是否为组合产品
    if (product.getIsCombined() != null && product.getIsCombined().equals(1)) {
        product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct1());
    }
    DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
    // 数字证书操作方式为用户下载(2)的,订单状态设置为待下载
    if (null != cert && null != cert.getInitBuy() && "2".equals(cert.getInitBuy())) {
        bill.setBillStatus(ComNames.BILL_STATUS_13);
    }
    // 待更新
    if (ComNames.TYPE_RENEW.equals(product.getType())) {
        bill.setBillStatus(ComNames.BILL_STATUS_12);
    }
    // 更新数据库
    sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
    sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
    retMap.put("retCode", 1);
    return retMap;
}
Also used : DigitalCert(com.itrus.portal.db.DigitalCert) HashMap(java.util.HashMap) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) JSONObject(com.alibaba.fastjson.JSONObject) UserCert(com.itrus.portal.db.UserCert) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 22 with Bill

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

the class MakeCertController method downloadPfxCert.

/**
 * 后台管理员下载pfx证书的接口
 *
 * @param id,订单id
 * @param request
 * @param response
 * @return
 */
@RequestMapping("/pfx/{id}")
public String downloadPfxCert(@PathVariable(value = "id") Long id, HttpServletRequest request, HttpServletResponse response) {
    Bill bill = billService.getBill(id);
    if (null == bill) {
        return null;
    }
    Integer uidIdx = 1;
    UserInfo webuserInfo = userInfoService.getUserInfoByBillId(id);
    Enterprise webenterprise = enterpriseService.getEnterpriseByBillId(id);
    boolean billFlag = webuserInfo.getId().equals(bill.getUniqueId()) && webenterprise.getId().equals(bill.getEnterprise());
    if (!billFlag) {
        return null;
    }
    // 用户已经下载过了,再次下载
    boolean downLoadFlag = bill.getBillStatus().equals(ComNames.BILL_STATUS_6) || bill.getBillStatus().equals(ComNames.BILL_STATUS_7) || bill.getBillStatus().equals(ComNames.BILL_STATUS_8);
    if (downLoadFlag) {
        // 根据订单号,找到订单对应的证书信息
        CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectPfxCertByBillId", bill.getId());
        Date date = new Date();
        // 获取证书第一次下载时间和当前时间比较,如果超过了十五天,则不允许下载
        int day = DateUtils.daysOfTwo(date, certBuf.getCreateTime());
        if (day > 16) {
            return null;
        }
        // 从数据库中取出数据,返回给客户端.
        // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
        response.reset();
        String filename = webenterprise.getEnterpriseName() + "功能证书.pfx";
        filename = encodeFilename(filename, request);
        response.setHeader("Content-disposition", "attachment;filename=" + filename);
        response.setCharacterEncoding("utf-8");
        // 由于导出格式是pfx的文件,设置导出文件的响应头部信息
        response.setContentType("application/x-pkcs12");
        OutputStream os = null;
        try {
            os = response.getOutputStream();
            // 清理刷新缓冲区,将缓存中的数据将数据导出excel
            byte[] byteCert = Base64.decode(certBuf.getPfxCert());
            os.write(byteCert);
            os.flush();
            // 关闭os
            if (os != null) {
                os.close();
            }
            certBuf.setLastDownloadTime(new Date());
            certBuf.setCertDownloadNumber(certBuf.getCertDownloadNumber() + 1);
            downLoadCertService.updatePfxCert(certBuf);
            // 记录日志
            LogUtil.adminlog(sqlSession, "下载pfx证书", "企业名称:" + webenterprise.getEnterpriseName());
            return null;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            LogUtil.adminlog(sqlSession, "下载pfx证书", "下载失败,错误信息:" + e.getMessage());
        }
    } else {
        // 用户未下载过,第一次下载
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_13)) {
            // 查询项目产品
            Product product = productService.getProduct(bill.getProduct());
            // 企业
            Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
            // 获取产品、RA配置
            RaAccount ra = raAccountService.getRaAccount(product.getRa());
            // 证书配置
            DigitalCert digitalcert = digitalCertService.getDigitalCert(product.getCert());
            // 下载证书
            String autoidType = "";
            Integer autoidValue = 0;
            String pfxCert = "";
            // 用户ID,用来最终匹配公钥证书和密钥对,一个用户id,只能使用一次,所以考虑使用订单号来作为用户id,避免一个用户只能下载一个证书.
            String userid = bill.getBillId() + (Math.random() * 1000 + 9000);
            // TODO
            String certPass = product.getPassword();
            // 20170410pfx私钥证书保护密码:需要根据产品配置的密码或获取
            // 产生CSR证书请求
            String certReqBuf = "";
            // 算法
            String algorithm = digitalCertService.getAlgorithm(digitalcert);
            // 下载证书
            CertInfo racertinfo = null;
            try {
                certReqBuf = GenUtil.GenP10(userid, "", algorithm);
                racertinfo = downLoadCertService.downLoadCert(product, ra, bill, digitalcert, uidIdx, certReqBuf, autoidType, autoidValue);
                pfxCert = GenUtil.GenPFX(userid, certPass, racertinfo.getCertSignBuf(), false, enterprise.getEnterpriseName());
                // 保存证书
                downLoadCertService.savePfxCertInfo(racertinfo, bill, ra.getId(), uidIdx, "", autoidType, autoidValue, pfxCert);
                // 从数据库中取出数据,返回给客户端.
                // 重置response对象中的缓冲区,该方法可以不写,但是你要保证response缓冲区没有其他数据,否则导出可能会出现问题,建议加上
                response.reset();
                String filename = webenterprise.getEnterpriseName() + "通讯证书.pfx";
                filename = encodeFilename(filename, request);
                response.setHeader("Content-disposition", "attachment;filename=" + filename);
                response.setCharacterEncoding("utf-8");
                // 由于导出格式是pfx的文件,设置导出文件的响应头部信息
                response.setContentType("application/x-pkcs12");
                OutputStream os = null;
                os = response.getOutputStream();
                // 清理刷新缓冲区,将缓存中的数据将数据导出excel
                byte[] byteCert = Base64.decode(pfxCert);
                os.write(byteCert);
                os.flush();
                // 关闭os
                if (os != null) {
                    os.close();
                }
                // 记录日志
                LogUtil.adminlog(sqlSession, "下载pfx证书", "下载成功,企业名称:" + webenterprise.getEnterpriseName());
                return null;
            } catch (Exception e) {
                // TODO: handle exception
                LogUtil.adminlog(sqlSession, "下载pfx证书", "下载失败,错误信息:" + e.getMessage());
            }
        }
    }
    return null;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) OutputStream(java.io.OutputStream) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) Date(java.util.Date) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) BigInteger(java.math.BigInteger) DigitalCert(com.itrus.portal.db.DigitalCert) RaAccount(com.itrus.portal.db.RaAccount) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) CertBuf(com.itrus.portal.db.CertBuf) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 23 with Bill

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

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

the class ReviewServiceImpl method sendSmsBySHJJ.

// 拒绝后台的订单,发送短信通知
/**
 * 发送审核拒绝短信通知(模版类型:SHJJ)
 *
 * @param billId
 * @return
 */
public boolean sendSmsBySHJJ(Long billId) {
    if (null == billId) {
        return false;
    }
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        return false;
    }
    // 查询短信模版
    // 查找对应项目的消息模版:SHJJ
    MessageTemplate messageTemplate = messageTemplateService.getMsgTemp(bill.getProject(), "SHJJ");
    if (null == messageTemplate) {
        logger.error("发送短信失败,未找到对应的鉴证审核消息模版");
        return false;
    }
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    String content = messageTemplate.getMessageContent();
    // 替换特定内容:企业名称:enterpriseName,产品名称:productName,项目名称:projectName,拒绝原因:reason
    if (content.contains("enterpriseName")) {
        content = content.replaceAll("enterpriseName", enterprise.getEnterpriseName());
    }
    if (content.contains("productName")) {
        content = content.replaceAll("productName", product.getName());
    }
    if (content.contains("projectName")) {
        content = content.replaceAll("projectName", project.getName());
    }
    if (content.contains("reason")) {
        content = content.replaceAll("reason", bill.getCancelReason());
    }
    // 发送短信
    try {
        if (smsSendService.sendRefuseReview(userInfo.getmPhone(), content, "SHJJ", project.getId(), userInfo.getUniqueId(), bill.getBillId())) {
            // 发送成功
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
Also used : MessageTemplate(com.itrus.portal.db.MessageTemplate) Project(com.itrus.portal.db.Project) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) ParseException(java.text.ParseException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException)

Example 25 with Bill

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

the class SubmitReviewServiceImpl method getQueryBill.

/**
 * 根据产品list 获取送审中的订单(状态为10送审中 的所有订单list)
 *
 * @param productList
 * @return
 */
public Map<Long, List<Bill>> getQueryBill(List<Product> productList) {
    Map<Long, List<Bill>> billListMap = new HashMap<Long, List<Bill>>();
    if (null != productList && !productList.isEmpty()) {
        for (Product product : productList) {
            BillExample example = new BillExample();
            BillExample.Criteria criteria = example.or();
            criteria.andProductEqualTo(product.getId());
            criteria.andBillStatusEqualTo(ComNames.BILL_STATUS_10);
            // 时间逆序排列
            example.setOrderByClause("create_time asc");
            List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", example);
            if (null != billList && !billList.isEmpty()) {
                billListMap.put(product.getId(), billList);
            }
        }
    }
    return billListMap;
}
Also used : BillExample(com.itrus.portal.db.BillExample) HashMap(java.util.HashMap) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Bill (com.itrus.portal.db.Bill)74 HashMap (java.util.HashMap)45 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)42 Product (com.itrus.portal.db.Product)39 UserInfo (com.itrus.portal.db.UserInfo)32 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)27 Enterprise (com.itrus.portal.db.Enterprise)26 UserCert (com.itrus.portal.db.UserCert)22 JSONObject (com.alibaba.fastjson.JSONObject)21 Date (java.util.Date)20 ArrayList (java.util.ArrayList)19 BillExample (com.itrus.portal.db.BillExample)18 IOException (java.io.IOException)18 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)16 DigitalCert (com.itrus.portal.db.DigitalCert)15 Map (java.util.Map)12 TransactionStatus (org.springframework.transaction.TransactionStatus)10 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)10 OnPayInfo (com.itrus.portal.db.OnPayInfo)9 Proxy (com.itrus.portal.db.Proxy)9