@Override public String getGroupTotalCount(int categoryId, String cityId) { Map<Object, Object> params = new HashMap<Object, Object>(); String totalCount = "0"; params.put("city_id", cityId); params.put("category_id", categoryId); totalCount = commonDao.selectObject("taopiao.getGroupTotalCount", params); return totalCount; }
@Override public CommonInfo getCommonInfoDetail(int common_id) { Map<Object, Object> params = new HashMap<Object, Object>(); params.put("id", common_id); // 获取演出基本信息 CommonInfo commonInfo = commonDao.selectObject("commonInfo.getCommonInfoDetail", params); Category category = getShow_category(commonInfo); commonInfo.setCategory(category); // 获取演出时间 Map<Object, Object> timeMap = this.getCommonInfoTimeMap(); CommonInfo time = (CommonInfo) timeMap.get(common_id + ""); String show_time = time.getShow_time(); String limit_time = time.getLimit_time(); if (show_time != null && !show_time.contains("全年")) { Calendar calendar = Calendar.getInstance(); try { calendar.setTime(YYYY_MM_DD_HH_MM.parse(show_time)); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); int week = calendar.get(Calendar.DAY_OF_WEEK); show_time = ""; if (hour < 10) { show_time = show_time + "0" + hour + ":"; } else { show_time = show_time + hour + ":"; } if (minute < 10) { show_time = show_time + "0" + minute; } else { show_time = show_time + minute; } commonInfo.setYear(year + ""); commonInfo.setDay(day + ""); commonInfo.setMonth(month + ""); commonInfo.setWeek(Const.week[week - 1]); commonInfo.setShow_time(show_time); commonInfo.setLimit_time(limit_time); } catch (ParseException e) { e.printStackTrace(); } } Map<Object, CommonInfo> priceMap = this.getCommonInfoPriceMap(); CommonInfo commonPrice = priceMap.get(common_id + ""); if (commonPrice != null) { commonInfo.setPrice(commonPrice.getPrice()); commonInfo.setDiscount(commonPrice.getDiscount()); commonInfo.setMin_price(commonPrice.getMin_price()); commonInfo.setMainURL(commonPrice.getMainURL()); } commonInfo.setCategory(getShow_category(commonInfo)); return commonInfo; }
@Override public Map<Object, CommonInfo> getCommonInfoPriceMap() { Map<Object, CommonInfo> priceMap = new HashMap<Object, CommonInfo>(); Map<Object, Object> params = new HashMap<Object, Object>(); List<CommonInfo> result = null; result = GetByCache.loadByCache(cu, CacheKey.COMMON_PRICE_MAP); if (result == null) { result = commonDao.selectObjects("commonInfo.getCommonPriceList", params); } cu.putCache(CacheKey.COMMON_PRICE_MAP, result, DateTime.getPeriodOfvalidityTime()); if (result != null) { for (CommonInfo commonInfo : result) { priceMap.put(commonInfo.getId() + "", commonInfo); } } return priceMap; }
@Override public List<CommonInfo> getGroupList( int categoryId, String cityId, String pageIndex, String pageCount) { Map<Object, Object> params = new HashMap<Object, Object>(); params = new HashMap<Object, Object>(); params.put("category_id", categoryId); params.put("city_id", cityId); params.put("pageIndex", (Integer.parseInt(pageIndex) - 1) * Integer.parseInt(pageCount)); params.put("pageCount", Integer.parseInt(pageCount)); Map<Object, CommonInfo> priceMap = this.getCommonInfoPriceMap(); List<CommonInfo> groupList = commonDao.selectObjects("taopiao.getGroupList", params); for (int i = 0; i < groupList.size(); i++) { CommonInfo price = priceMap.get(groupList.get(i).getId() + ""); if (price != null) { groupList.get(i).setPrice(price.getPrice()); groupList.get(i).setDiscount(price.getDiscount()); groupList.get(i).setMin_price(price.getMin_price()); groupList.get(i).setAgency_name(price.getAgency_name()); } } return groupList; }
@Override public List<CommonInfo> getCommonInfoList( int categoryId, String cityId, String pageIndex, String pageCount) { Map<Object, Object> params = new HashMap<Object, Object>(); params = new HashMap<Object, Object>(); params.put("category_id", categoryId); params.put("city_id", cityId); params.put("pageIndex", (Integer.parseInt(pageIndex) - 1) * Integer.parseInt(pageCount)); params.put("pageCount", Integer.parseInt(pageCount)); List<CommonInfo> commonList = commonDao.selectObjects("commonInfo.getCommonList", params); Map<Object, Object> timeMap = this.getCommonInfoTimeMap(); Map<Object, CommonInfo> priceMap = this.getCommonInfoPriceMap(); for (int i = 0, length = commonList.size(); i < length; i++) { CommonInfo commonInfo = commonList.get(i); String introduction = commonInfo.getIntroduction().replaceAll("\\s*", ""); if (introduction != null && !"".equals(introduction)) { introduction = Jsoup.parse(introduction).text().trim(); if (introduction.length() > 350) { introduction = introduction.substring(0, 350); } commonList.get(i).setIntroduction(introduction); } if (commonInfo.getStatus() == 0) { commonInfo.setShow_status("预售中"); } else if (commonInfo.getStatus() == 2) { commonInfo.setShow_status("已过期"); } else { commonInfo.setShow_status("热售中"); } CommonInfo time = (CommonInfo) timeMap.get(commonInfo.getId() + ""); if (time != null) { String show_time = time.getShow_time(); String limit_time = time.getLimit_time(); if (show_time != null && !"null".equals(show_time) && !show_time.contains("全年")) { Calendar calendar = Calendar.getInstance(); try { calendar.setTime(YYYY_MM_DD_HH_MM.parse(show_time)); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); int hour = calendar.get(Calendar.HOUR); int minute = calendar.get(Calendar.MINUTE); int week = calendar.get(Calendar.DAY_OF_WEEK); int AM_PM = calendar.get(Calendar.AM_PM); if (AM_PM == 0) { show_time = "早"; } else { show_time = "晚"; } if (hour < 10) { show_time = show_time + "0" + hour + ":"; } else { show_time = show_time + hour + ":"; } if (minute < 10) { show_time = show_time + "0" + minute; } else { show_time = show_time + minute; } commonList.get(i).setYear(year + ""); commonList.get(i).setDay(day + ""); if (month < 10) { commonList.get(i).setMonth("0" + month); } else { commonList.get(i).setMonth(month + ""); } commonList.get(i).setWeek(Const.week[week - 1]); commonList.get(i).setShow_time(show_time); commonList.get(i).setLimit_time(limit_time); } catch (ParseException e) { e.printStackTrace(); } } else { commonList.get(i).setShow_time(show_time); commonList.get(i).setLimit_time(limit_time); } } CommonInfo commonPrice = priceMap.get(commonInfo.getId() + ""); if (commonPrice != null) { commonList.get(i).setPrice(commonPrice.getPrice()); commonList.get(i).setDiscount(commonPrice.getDiscount()); commonList.get(i).setMin_price(commonPrice.getMin_price()); } } return commonList; }