Search in sources :

Example 6 with BillExample

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

the class BillServiceImpl method getBillWaitingForUnlock.

/**
 * 根据用户证书id,获取对应的解锁订单,只获取最新的一张,且订单状态是提交到已解锁待开票
 * @param userCertId
 * @return
 */
public Bill getBillWaitingForUnlock(Long userCertId) {
    List<Integer> status = new ArrayList<>();
    status.add(ComNames.BILL_STATUS_1);
    status.add(ComNames.BILL_STATUS_2);
    status.add(ComNames.BILL_STATUS_11);
    status.add(ComNames.BILL_STATUS_14);
    status.add(ComNames.BILL_STATUS_15);
    status.add(ComNames.BILL_STATUS_16);
    status.add(ComNames.BILL_STATUS_17);
    Bill bill = null;
    BillExample example = new BillExample();
    example.or().andUnlockUserCertEqualTo(userCertId).andBillStatusIn(status);
    example.setLimit(1);
    example.setOrderByClause("create_time desc");
    bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByExample", example);
    return bill;
}
Also used : BillExample(com.itrus.portal.db.BillExample) ArrayList(java.util.ArrayList) Bill(com.itrus.portal.db.Bill)

Example 7 with BillExample

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

the class PersonalBillServiceImpl method getBill.

/**
 * 获取对应的订单
 *
 * @param enterpriseId
 * @param userInfoId
 * @param billStatus
 * @return
 */
public Bill getBill(Long enterpriseId, Long userInfoId, List<Integer> billStatus) {
    BillExample example = new BillExample();
    BillExample.Criteria criteria = example.or();
    criteria.andEnterpriseEqualTo(enterpriseId);
    criteria.andUniqueIdEqualTo(userInfoId);
    criteria.andIsDeleteEqualTo(false);
    if (null != billStatus && !billStatus.isEmpty())
        criteria.andBillStatusIn(billStatus);
    example.setOrderByClause("create_time desc");
    example.setLimit(1);
    return sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByExample", example);
}
Also used : BillExample(com.itrus.portal.db.BillExample)

Example 8 with BillExample

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

the class BillWebController method billList.

/**
 * 订单列表
 *
 * @param billStatus
 *            0未完成订单,1已完成订单
 * @param request
 * @param uiModel
 * @return
 */
@RequestMapping(produces = "text/html")
public String billList(@RequestParam(value = "billStatus", required = false) Integer billStatus, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "page2", required = false) Integer page2, @RequestParam(value = "size2", required = false) Integer size2, HttpServletRequest request, Model uiModel) {
    HttpSession session = request.getSession();
    Boolean verifyCodeStatus = (Boolean) session.getAttribute("webverifyCodeStatus");
    Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo) {
        // 登录状态失效,跳转到登录页面
        return "redirect:/userInfoWeb/denglu.html";
    }
    if (userInfo != null && enterprise == null) {
        // 登录未获取到企业信息,跳转到选择企业页面
        return "redirect:/userInfoWeb/choiceEnterprise";
    }
    uiModel.addAttribute("billStatus", billStatus);
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 5;
    }
    BillExample billExampl = new BillExample();
    BillExample.Criteria criteria = billExampl.or();
    // web页面不显示解锁的订单产品
    List<Long> keyUnlockProductIds = productService.getKeyUnlockProductIds();
    if (null != keyUnlockProductIds && !keyUnlockProductIds.isEmpty()) {
        criteria.andProductNotIn(keyUnlockProductIds);
    }
    // 查询当前用户当前企业的订单
    // 当前用户
    criteria.andUniqueIdEqualTo(userInfo.getId());
    // 当前企业 v 76
    criteria.andEnterpriseEqualTo(enterprise.getId());
    if (null == billStatus || 0 == billStatus) {
        // 未完成订单:订单状态不为8
        criteria.andBillStatusNotEqualTo(ComNames.BILL_STATUS_8);
        criteria.andIsDeleteEqualTo(false);
    } else if (1 == billStatus) {
        // 订单状态为已完成
        criteria.andBillStatusEqualTo(ComNames.BILL_STATUS_8);
    }
    Integer count = sqlSession.selectOne("com.itrus.portal.db.BillMapper.countByExample", billExampl);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    Integer offset = size * (page - 1);
    billExampl.setOffset(offset);
    billExampl.setLimit(size);
    billExampl.setOrderByClause("create_time desc");
    List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExampl);
    uiModel.addAttribute("billList", billList);
    uiModel.addAttribute("itemcount", billList.size());
    Map<Long, Delivery> deliveryMap = sqlSession.selectMap("com.itrus.portal.db.DeliveryMapper.selectByExample", null, "id");
    uiModel.addAttribute("deliveryMap", deliveryMap);
    // 填写中订单
    if (page2 == null || page2 < 1) {
        page2 = 1;
    }
    if (size2 == null || size2 < 1) {
        size2 = 5;
    }
    EditBillExample ebEx = new EditBillExample();
    EditBillExample.Criteria criteria2 = ebEx.or();
    // 查询当前用户当前企业的订单
    // 当前用户
    criteria2.andUserInfoIdEqualTo(userInfo.getId());
    // 
    criteria2.andEnterpriseIdEqualTo(enterprise.getId());
    Integer count2 = sqlSession.selectOne("com.itrus.portal.db.EditBillMapper.countByExample", ebEx);
    if (page2 > 1 && size2 * (page2 - 1) >= count2) {
        page2 = (count2 + size2 - 1) / size2;
    }
    uiModel.addAttribute("count2", count2);
    uiModel.addAttribute("pages2", (count2 + size2 - 1) / size2);
    uiModel.addAttribute("page2", page2);
    uiModel.addAttribute("size2", size2);
    Integer offset2 = size2 * (page2 - 1);
    // 产品信息:
    /*Map<Long, Product> productMap = billService
				.getProductMapByUserInfoId(userInfo.getId());*/
    // if ((null == billStatus || billStatus.equals(2)) && count2 != 0) {
    Map<Long, Product> productMap = sqlSession.selectMap("com.itrus.portal.db.ProductMapper.selectByExample", "id");
    // }
    uiModel.addAttribute("productMap", productMap);
    // 获取产品关联的数字证书id
    Set<Long> certIds = productService.getDigitalCertIds(productMap);
    // 产品关联的数字证书:
    Map<Long, DigitalCert> digitalCertMap = digitalCertService.getDigitalCertByProductMap(certIds);
    uiModel.addAttribute("digitalCertMap", digitalCertMap);
    // 获取订单对应的产品规格
    Map<Long, ProductSpec> productSpecMap = productSpecService.getProductSpec(billList);
    uiModel.addAttribute("productSpecMap", productSpecMap);
    ebEx.setOffset(offset2);
    ebEx.setLimit(size2);
    ebEx.setOrderByClause("create_time desc");
    List<EditBill> editBillList = sqlSession.selectList("com.itrus.portal.db.EditBillMapper.selectByExample", ebEx);
    // 获取填写中订单对应的产品规格
    Map<Long, ProductSpec> editBill_productSpecMap = productSpecService.getEditBillProductSpec(editBillList);
    uiModel.addAttribute("editBill_productSpecMap", editBill_productSpecMap);
    uiModel.addAttribute("editBillList", editBillList);
    uiModel.addAttribute("itemcount2", editBillList.size());
    // 订单是否对应的pfx的用户下载证书.
    Map<Long, Long> pfxMap = billWebService.getPfxCertBufByBills(billList);
    uiModel.addAttribute("pfxmap", pfxMap);
    session.removeAttribute("sessionPlist");
    session.removeAttribute("enterpriseqqE");
    System.out.println(enterprise.getId());
    Map param = new HashMap();
    param.put("id", enterprise.getId());
    if (userInfo.getmPhone() != null) {
        param.put("phone", userInfo.getmPhone());
    }
    List<Map<String, Object>> plist = sqlSession.selectList("com.itrus.portal.db.ProjectMapper.selectProjectId", param);
    Map<Long, EnterpriseQq> qqMap = new HashMap<Long, EnterpriseQq>();
    for (int i = 0; i < plist.size(); i++) {
        EnterpriseQqExample enterpriseQ = new EnterpriseQqExample();
        EnterpriseQqExample.Criteria qqEx = enterpriseQ.createCriteria();
        // System.out.println(plist.get(i));
        Long pid = Long.parseLong(plist.get(i).get("id").toString());
        // System.out.println(pid);
        qqEx.andProjectIdEqualTo(pid);
        EnterpriseQq enterpriseqq = sqlSession.selectOne("com.itrus.portal.db.EnterpriseQqMapper.selectByExample", enterpriseQ);
        if (enterpriseqq != null) {
            // uiModel.addAttribute("eid", enterpriseqq.getId());
            qqMap.put(pid, enterpriseqq);
        // session.setAttribute("enterpriseqqE", enterpriseqq.getEnterpriseQqLinks());
        }
    }
    session.setAttribute("sessionqqMap", qqMap);
    session.setAttribute("sessionPlist", plist);
    return "ixinweb/zhanghuguanli_dingdanxinxi";
}
Also used : HashMap(java.util.HashMap) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) EditBillExample(com.itrus.portal.db.EditBillExample) DigitalCert(com.itrus.portal.db.DigitalCert) EditBillExample(com.itrus.portal.db.EditBillExample) BillExample(com.itrus.portal.db.BillExample) EnterpriseQqExample(com.itrus.portal.db.EnterpriseQqExample) EditBill(com.itrus.portal.db.EditBill) HttpSession(javax.servlet.http.HttpSession) ProductSpec(com.itrus.portal.db.ProductSpec) EnterpriseQq(com.itrus.portal.db.EnterpriseQq) Enterprise(com.itrus.portal.db.Enterprise) EditBill(com.itrus.portal.db.EditBill) Bill(com.itrus.portal.db.Bill) Delivery(com.itrus.portal.db.Delivery) Map(java.util.Map) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with BillExample

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

use of com.itrus.portal.db.BillExample 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)

Aggregations

BillExample (com.itrus.portal.db.BillExample)21 Bill (com.itrus.portal.db.Bill)18 Product (com.itrus.portal.db.Product)10 HashMap (java.util.HashMap)8 Enterprise (com.itrus.portal.db.Enterprise)7 UserInfo (com.itrus.portal.db.UserInfo)7 ArrayList (java.util.ArrayList)7 Date (java.util.Date)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 DigitalCert (com.itrus.portal.db.DigitalCert)4 OnPayInfo (com.itrus.portal.db.OnPayInfo)4 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)4 Map (java.util.Map)4 TransactionStatus (org.springframework.transaction.TransactionStatus)4 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)4 JSONObject (com.alibaba.fastjson.JSONObject)3 Agent (com.itrus.portal.db.Agent)3 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)3 ApplicationInfoExample (com.itrus.portal.db.ApplicationInfoExample)3 BusinessLicense (com.itrus.portal.db.BusinessLicense)3