Search in sources :

Example 1 with EditBillExample

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

Aggregations

Bill (com.itrus.portal.db.Bill)1 BillExample (com.itrus.portal.db.BillExample)1 Delivery (com.itrus.portal.db.Delivery)1 DigitalCert (com.itrus.portal.db.DigitalCert)1 EditBill (com.itrus.portal.db.EditBill)1 EditBillExample (com.itrus.portal.db.EditBillExample)1 Enterprise (com.itrus.portal.db.Enterprise)1 EnterpriseQq (com.itrus.portal.db.EnterpriseQq)1 EnterpriseQqExample (com.itrus.portal.db.EnterpriseQqExample)1 Product (com.itrus.portal.db.Product)1 ProductSpec (com.itrus.portal.db.ProductSpec)1 UserInfo (com.itrus.portal.db.UserInfo)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HttpSession (javax.servlet.http.HttpSession)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1