Search in sources :

Example 36 with Bill

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

the class ClientPayWebController method generatePayInfo.

private void generatePayInfo(Long userId, String orderNo, String payid, String money) throws Exception {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus s = transactionManager.getTransaction(def);
    try {
        BillExample be = new BillExample();
        BillExample.Criteria bc = be.createCriteria();
        bc.andBillIdEqualTo(orderNo);
        Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByExample", be);
        OnPayInfo payInfo;
        if (bill.getOnPayInfo() == null) {
            payInfo = new OnPayInfo();
            payInfo.setOnlinePay(Long.parseLong(payid));
            payInfo.setPaySum(Double.parseDouble(money));
            payInfo.setPayStatus(0);
            payInfo.setDyTime(new Date());
            payInfo.setName(String.valueOf(userId));
            sqlSession.insert("com.itrus.portal.db.OnPayInfoMapper.insert", payInfo);
            sqlSession.flushStatements();
            if (payInfo.getId() == null) {
                throw new Exception(orderNo + "生成支付记录报错。");
            }
            bill.setOnPayInfo(payInfo.getId());
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        } else {
            payInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
            payInfo.setOnlinePay(Long.parseLong(payid));
            payInfo.setPaySum(Double.parseDouble(money));
            payInfo.setDyTime(new Date());
            payInfo.setName(String.valueOf(userId));
            sqlSession.update("com.itrus.portal.db.OnPayInfoMapper.updateByPrimaryKeySelective", payInfo);
        }
        transactionManager.commit(s);
    } catch (Exception e) {
        LogUtil.syslog(sqlSession, "在线支付", orderNo + "在线支付生成支付记录错误:" + e.toString());
        throw new Exception(orderNo + "在线支付生成支付记录错误:" + e.toString());
    } finally {
        if (!s.isCompleted()) {
            transactionManager.rollback(s);
        }
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) BillExample(com.itrus.portal.db.BillExample) OnPayInfo(com.itrus.portal.db.OnPayInfo) Bill(com.itrus.portal.db.Bill) TransactionStatus(org.springframework.transaction.TransactionStatus) Date(java.util.Date)

Example 37 with Bill

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

the class ClientPayWebController method updatePayInfo.

private void updatePayInfo(String billId, Long payConfigId, String transactionId, String payType, String payTime) throws Exception {
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus s = null;
    try {
        s = transactionManager.getTransaction(def);
        BillExample be = new BillExample();
        BillExample.Criteria bc = be.createCriteria();
        bc.andBillIdEqualTo(billId);
        bc.andBillStatusIn(Arrays.asList(new Integer[] { 1, 11 }));
        Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByExample", be);
        if (null == bill) {
            return;
        }
        bill.setBillStatus(3);
        bill.setPayTime(new Date(Long.parseLong(payTime)));
        // 产品
        Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
        // pfx流程判断begin
        DigitalCert digitalCert = null;
        if (null != product.getCert()) {
            digitalCert = digitalCertService.getDigitalCert(product.getCert());
            if (null != digitalCert && null != digitalCert.getCertType() && digitalCert.getCertType().equals(ComNames.DIGITALCERT_CERTTYPE_PFX)) {
                // 这个用户,这个企业,这个项目,有通过了实名认证的订单,则直接进入待下载,
                List<Bill> bills = billService.hasAuthticationLevel(bill.getUniqueId(), bill.getEnterprise(), product.getProject());
                if (null != bills && bills.size() > 0 && digitalCert.getInitBuy().equals(ComNames.DIGITALCERT_INITBUYS_2)) {
                    bill.setBillStatus(ComNames.BILL_STATUS_13);
                    // 新增审核通过的记录
                    reviewService.agreeBillReview(bill);
                }
            }
        }
        // 解锁产品流程判断gegin
        if (null != product.getKeyUnlockType()) {
            bill = unLockKeyBillService.updateBillStatusWhileHasPay(bill, product);
        }
        // 解锁产品流程判断end
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        OnPayInfo payInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
        payInfo.setPayStatus(1);
        payInfo.setWcTime(bill.getPayTime());
        payInfo.setPayNo(transactionId);
        OnlinePayExample ope = new OnlinePayExample();
        OnlinePayExample.Criteria opc = ope.createCriteria();
        opc.andPayConfigEqualTo(payConfigId);
        // 1支付宝 2微信
        opc.andWayEqualTo((Integer.parseInt(payType) == 0 ? 1 : 2));
        OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByExample", ope);
        payInfo.setOnlinePay(onlinePay.getId());
        // payInfo.setComment(m.get("return_msg"));
        sqlSession.update("com.itrus.portal.db.OnPayInfoMapper.updateByPrimaryKeySelective", payInfo);
        transactionManager.commit(s);
    } catch (Exception e) {
        LogUtil.syslog(sqlSession, "在线支付", billId + "回调更新数据库错误:" + e.toString());
        throw new Exception(billId + "回调更新数据库错误:" + e.toString());
    } finally {
        if (null != s && !s.isCompleted()) {
            transactionManager.rollback(s);
        }
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) OnlinePayExample(com.itrus.portal.db.OnlinePayExample) TransactionStatus(org.springframework.transaction.TransactionStatus) Product(com.itrus.portal.db.Product) Date(java.util.Date) DigitalCert(com.itrus.portal.db.DigitalCert) BillExample(com.itrus.portal.db.BillExample) OnPayInfo(com.itrus.portal.db.OnPayInfo) Bill(com.itrus.portal.db.Bill) OnlinePay(com.itrus.portal.db.OnlinePay)

Example 38 with Bill

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

the class DownLoadCertWebController method savecertinfo.

// 保存certinfo信息至 uid 字段
@RequestMapping(value = "/save/{id}", produces = "text/html")
@ResponseBody
public Map<String, Object> savecertinfo(@RequestParam(value = "certinfo", required = false) String certinfo, @PathVariable("id") Long id) {
    Map<String, Object> ret = new HashMap<String, Object>();
    Bill bill = billService.getBill(id);
    bill.setUid(certinfo);
    billService.updateBill(bill);
    ret.put("status", 0);
    return ret;
}
Also used : HashMap(java.util.HashMap) Bill(com.itrus.portal.db.Bill) JSONObject(com.alibaba.fastjson.JSONObject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 39 with Bill

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

the class DownLoadCertWebController method downLoadCert.

@RequestMapping("/{id}")
@ResponseBody
public Map<String, Object> downLoadCert(@PathVariable(value = "id") Long id, @RequestParam(value = "uidIdx", required = true) Integer uidIdx, @RequestParam(value = "csr", required = true) String csr, @RequestParam(value = "keySn", required = false) String keySn, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 2标识登录已经失效,需跳转到登录页面
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录状态失效");
        return retMap;
    }
    Bill bill = billService.getBill(id);
    if (null == bill) {
        retMap.put("retMsg", "该订单不存在");
        return retMap;
    }
    // 订单是否为当前用户当前企业
    if (!webuserInfo.getId().equals(bill.getUniqueId()) || !webenterprise.getId().equals(bill.getEnterprise())) {
        retMap.put("retMsg", "您不能操作该订单");
        return retMap;
    }
    // 判断该订单状态是否为待下载,是否已经关联了证书
    List<String> certStatus = new ArrayList<String>();
    certStatus.add(ComNames.CERT_STATUS_1);
    certStatus.add(ComNames.CERT_STATUS_2);
    List<UserCert> userCerts = userCertService.getUserCertByBill(bill.getId(), certStatus);
    if (!bill.getBillStatus().equals(ComNames.BILL_STATUS_13) || !userCerts.isEmpty()) {
        retMap.put("retMsg", "该证书状态为已下载或订单还未审核");
        return retMap;
    }
    Product product = productService.getProduct(bill.getProduct());
    DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
    RaAccount ra = raAccountService.getRaAccount(product.getRa());
    // 下载证书
    String autoidType = "";
    Integer autoidValue = 0;
    try {
        // 下载证书
        CertInfo racertinfo = downLoadCertService.downLoadCert(product, ra, bill, digitalCert, uidIdx, csr, autoidType, autoidValue);
        // 保存证书
        downLoadCertService.saveCertInfo(racertinfo, bill, ra.getId(), uidIdx, keySn, autoidType, autoidValue);
        // 返回数字证书
        retMap.put("retCode", 1);
        retMap.put("certChain", racertinfo.getCertSignBufP7());
        retMap.put("certSn", racertinfo.getCertSerialNumber());
        retMap.put("certSignBuf", racertinfo.getCertSignBuf());
        retMap.put("certKmcRep1", racertinfo.getCertKmcRep1());
        retMap.put("certKmcRep2", racertinfo.getCertKmcRep2());
        // 加密证书
        retMap.put("encUserCert", racertinfo.getCertSignBufKmc());
        // 记录日志
        UserLog userlog = new UserLog();
        userlog.setProject(webuserInfo.getProject());
        userlog.setType("用户下载证书");
        userlog.setInfo(webenterprise.getEnterpriseName() + "下载证书成功");
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
    } catch (Exception e) {
        e.printStackTrace();
        retMap.put("retMsg", e.getMessage());
        // 记录日志
        UserLog userlog = new UserLog();
        userlog.setProject(webuserInfo.getProject());
        userlog.setType("用户下载证书");
        userlog.setInfo("url:downLoadCert,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        return retMap;
    }
    return retMap;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) GenP10Exception(com.itrus.Exception.GenP10Exception) IOException(java.io.IOException) DigitalCert(com.itrus.portal.db.DigitalCert) RaAccount(com.itrus.portal.db.RaAccount) Enterprise(com.itrus.portal.db.Enterprise) Bill(com.itrus.portal.db.Bill) JSONObject(com.alibaba.fastjson.JSONObject) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 40 with Bill

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

the class UnlockKeyBillController method reSubmitUnlockBill.

/**
 * 解锁订单重新提交授权书,注意授权书的id不能为null
 * @param billId
 * @param certSn
 * @param keySn
 * @param proxy
 * @param request
 * @return
 */
@RequestMapping("/reSubmitUnlockBill")
@ResponseBody
public Map<String, Object> reSubmitUnlockBill(@RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @ModelAttribute("proxy") Proxy proxy, HttpServletRequest request) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    UserInfo webUserInfo = null;
    Project project = null;
    // 校验证书和证书所绑定的用户和企业
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        retMap.put("retMsg", "该证书未注册,请您先注册");
        return retMap;
    }
    // if(null == userCert.getUserinfo()){
    // retMap.put("retMsg", "该证书未绑定用户,请检查您插入的key是否正确");
    // return retMap;
    // }
    // 校验订单和证书所对应的用户与企业
    Bill bill = billService.getBill(billId);
    if (null == bill) {
        retMap.put("retMsg", "订单不存在");
        return retMap;
    }
    webUserInfo = userInfoService.selectByPrimaryKey(bill.getUniqueId());
    if (null == webUserInfo) {
        retMap.put("retMsg", "订单所对应的用户不存在,请检查");
        return retMap;
    }
    if (!(bill.getBillStatus().equals(ComNames.BILL_STATUS_1) || bill.getBillStatus().equals(ComNames.BILL_STATUS_2) || bill.getBillStatus().equals(ComNames.BILL_STATUS_15))) {
        retMap.put("errorMsg", "该订单不处于可以重新提交的状态");
        return retMap;
    }
    if (!bill.getUnlockUserCert().equals(userCert.getId())) {
        retMap.put("errorMsg", "您无权操作该订单");
        return retMap;
    }
    Product product = productService.getProduct(bill.getProduct());
    if (null == product.getKeyUnlockType()) {
        retMap.put("retMsg", "您选择的产品不属于解锁产品,请重新选择");
        return retMap;
    }
    project = projectService.selectByPrimaryKey(product.getProject());
    DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
    dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(dtd);
    try {
        if (null != proxy && (StringUtils.isNotBlank(proxy.getImgFile()) || null != proxy.getId())) {
            // 保存授权书
            Proxy oldProxy = null;
            if (null != proxy.getId()) {
                oldProxy = new Proxy();
                oldProxy.setId(proxy.getId());
                proxy.setId(null);
            }
            proxy = proxyService.saveProxy1(bill.getEnterprise(), webUserInfo.getUniqueId(), bill.getId(), bill.getUniqueId(), proxy, oldProxy, project);
        }
        // 审核拒绝后的订单,重新提交,则修改订单状态和审核拒绝的短信发送
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_15)) {
            bill.setBillStatus(ComNames.BILL_STATUS_14);
            bill.setIsSms(false);
            billService.updateBill(bill);
        }
        transactionManager.commit(status);
        LogUtil.userlog(sqlSession, project.getId(), "重新提交解锁订单", webUserInfo.getmPhone() + "重新提交解锁订单:" + bill.getBillId(), "未知", "", null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
        retMap.put("retCode", 1);
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted()) {
            transactionManager.rollback(status);
        }
        UserLog userlog = new UserLog();
        userlog.setProject(project.getId());
        userlog.setType("重新提交解锁订单");
        userlog.setInfo("url:reSubmitUnlockBill,详细错误:" + e.getMessage() + ",订单号" + bill.getBillId());
        userlog.setHostId("未知");
        userlog.setSn(null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        return retMap;
    } finally {
        if (!status.isCompleted()) {
            transactionManager.rollback(status);
        }
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) Product(com.itrus.portal.db.Product) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Project(com.itrus.portal.db.Project) Proxy(com.itrus.portal.db.Proxy) Bill(com.itrus.portal.db.Bill) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

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