Authored by Lixiaodi

新销售日历

@@ -178,6 +178,36 @@ public class ProductSearchController { @@ -178,6 +178,36 @@ public class ProductSearchController {
178 JSONObject timeJson = productSearchService.getSaleCalendarCountData(); 178 JSONObject timeJson = productSearchService.getSaleCalendarCountData();
179 return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.saleCalendar").data(timeJson).build(); 179 return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.saleCalendar").data(timeJson).build();
180 } 180 }
  181 +
  182 + @ApiOperation(name = "ufo.product.search.newSaleCalendar", desc="销售日历列表")
  183 + @RequestMapping(params = "method=ufo.product.search.newSaleCalendar")
  184 + @IgnoreSession
  185 + public ApiResponse searchNewSaleCalendar(@RequestParam(value = "uid", required = false)Integer uid,
  186 + @RequestParam(value = "start_time", required = false)String startTime,
  187 + @RequestParam(value = "end_time", required = false)String endTime) {
  188 + if (StringUtils.isBlank(startTime) || StringUtils.isBlank(endTime)) {
  189 + return new ApiResponse.ApiResponseBuilder().code(400).message("参数错误!").data(null).build();
  190 + }
  191 + LOG.info("in method=ufo.product.search.newSaleCalendar uid={}, start_time={}, end_time={}", uid, startTime, endTime);
  192 + Integer start = getValidTimestamp(startTime, true);
  193 + Integer end = getValidTimestamp(endTime, false);
  194 + if (start == null || end == null) {
  195 + return new ApiResponse.ApiResponseBuilder().code(400).message("参数错误!").data(null).build();
  196 + }
  197 + JSONObject productJson = productSearchService.searchNewSaleCalendar(start, end);
  198 + productSearchService.processUserFavoriteProductList(productJson, uid);
  199 + return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.newSaleCalendar").data(productJson).build();
  200 + }
  201 +
  202 + @ApiOperation(name = "ufo.product.search.newSaleCalendarCount", desc="销售日历列汇总数量")
  203 + @RequestMapping(params = "method=ufo.product.search.newSaleCalendarCount")
  204 + @IgnoreSession
  205 + @Cachable(expire=180)
  206 + public ApiResponse searchNewSaleCalendarCount() {
  207 + LOG.info("in method=ufo.product.search.newSaleCalendarCount");
  208 + JSONObject timeJson = productSearchService.getNewSaleCalendarCountData();
  209 + return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.newSaleCalendarCount").data(timeJson).build();
  210 + }
181 211
182 @IgnoreSignature 212 @IgnoreSignature
183 @ApiOperation(name = "ufo.product.search.hotSale", desc="热销列表") 213 @ApiOperation(name = "ufo.product.search.hotSale", desc="热销列表")
@@ -28,12 +28,14 @@ public interface ProductSearchService { @@ -28,12 +28,14 @@ public interface ProductSearchService {
28 List<ProductBrandSeriesResp> searchSeriesList(); 28 List<ProductBrandSeriesResp> searchSeriesList();
29 29
30 JSONObject searchSaleCalendar(Integer startTime, Integer endTime); 30 JSONObject searchSaleCalendar(Integer startTime, Integer endTime);
  31 + JSONObject searchNewSaleCalendar(Integer startTime, Integer endTime);
31 32
32 JSONObject searchHotSale(Integer page, Integer limit); 33 JSONObject searchHotSale(Integer page, Integer limit);
33 34
34 void processUserFavoriteProductList(JSONObject productJSON, Integer uid); 35 void processUserFavoriteProductList(JSONObject productJSON, Integer uid);
35 36
36 JSONObject getSaleCalendarCountData(); 37 JSONObject getSaleCalendarCountData();
  38 + JSONObject getNewSaleCalendarCountData();
37 39
38 JSONObject searchUvscoreProductList(ProductSearchReq req); 40 JSONObject searchUvscoreProductList(ProductSearchReq req);
39 41
@@ -91,6 +91,10 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -91,6 +91,10 @@ public class ProductSearchServiceImpl implements ProductSearchService {
91 91
92 public static final String SALE_CALENDAR_LIST_URL = "/yohosearch/ufo/saleCalendarProductList.json"; 92 public static final String SALE_CALENDAR_LIST_URL = "/yohosearch/ufo/saleCalendarProductList.json";
93 public static final String SALE_CALENDAR_COUNT_URL = "/yohosearch/ufo/SaleDateCountList.json"; 93 public static final String SALE_CALENDAR_COUNT_URL = "/yohosearch/ufo/SaleDateCountList.json";
  94 +
  95 + public static final String NEW_SALE_CALENDAR_LIST_URL = "/yohosearch/ufo/saleCalendarNewProductList.json";
  96 + public static final String NEW_SALE_CALENDAR_COUNT_URL = "/yohosearch/ufo/saleDateNewCountList.json";
  97 +
94 public static final String HOT_SALE_LIST_URL = "/yohosearch/ufo/hotSaleProductList.json"; 98 public static final String HOT_SALE_LIST_URL = "/yohosearch/ufo/hotSaleProductList.json";
95 99
96 public static final String PRODUCT_POOL_URL = "/yohosearch/ufo/pool/productList.json"; 100 public static final String PRODUCT_POOL_URL = "/yohosearch/ufo/pool/productList.json";
@@ -463,39 +467,47 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -463,39 +467,47 @@ public class ProductSearchServiceImpl implements ProductSearchService {
463 467
464 @Override 468 @Override
465 public JSONObject getSaleCalendarCountData() { 469 public JSONObject getSaleCalendarCountData() {
466 - JSONObject countMap = new JSONObject();  
467 -  
468 - try {  
469 - SearchParam searchParam = new SearchParam();  
470 - String url = SALE_CALENDAR_COUNT_URL;  
471 - countMap = search(searchParam.getParam(), url).getJSONObject("sale_date_count_list");  
472 - } catch (Exception e) {  
473 - logger.error("调用销售日历汇总数据出错: " + e.getMessage(), e);  
474 - }  
475 -  
476 - JSONObject jo = new JSONObject();  
477 - String ymd = new SimpleDateFormat("yyyy-MM-dd").format(new Date());  
478 - jo.put("today", ymd);  
479 - JSONArray yearArray = new JSONArray();  
480 - int year = Integer.parseInt(ymd.substring(0, 4));  
481 - int month = Integer.parseInt(ymd.substring(5, 7));  
482 - for (int y = year - 1; y <= year + 1; y++) {  
483 - JSONObject yearData = new JSONObject();  
484 - JSONArray monthArray = new JSONArray();  
485 - for (int m = ((y == year - 1)? month:1); m <= ((y == year + 1)?month:12); m++) {  
486 - String ym = y + "-" + (m < 10 ? "0" + m : Integer.toString(m));  
487 - Integer count = countMap.getInteger(ym);  
488 - JSONObject ymData = new JSONObject();  
489 - ymData.put("month", m);  
490 - ymData.put("count", count == null ? Integer.valueOf(0) : count);  
491 - monthArray.add(ymData);  
492 - }  
493 - yearData.put(Integer.toString(y), monthArray);  
494 - yearArray.add(yearData);  
495 - }  
496 - jo.put("countData", yearArray);  
497 - return jo; 470 + return getSaleCalendarCountData(SALE_CALENDAR_COUNT_URL);
498 } 471 }
  472 +
  473 + @Override
  474 + public JSONObject getNewSaleCalendarCountData() {
  475 + return getSaleCalendarCountData(NEW_SALE_CALENDAR_COUNT_URL);
  476 + }
  477 +
  478 + private JSONObject getSaleCalendarCountData(String url) {
  479 + JSONObject countMap = new JSONObject();
  480 +
  481 + try {
  482 + SearchParam searchParam = new SearchParam();
  483 + countMap = search(searchParam.getParam(), url).getJSONObject("sale_date_count_list");
  484 + } catch (Exception e) {
  485 + logger.error("调用销售日历汇总数据出错: " + e.getMessage(), e);
  486 + }
  487 +
  488 + JSONObject jo = new JSONObject();
  489 + String ymd = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  490 + jo.put("today", ymd);
  491 + JSONArray yearArray = new JSONArray();
  492 + int year = Integer.parseInt(ymd.substring(0, 4));
  493 + int month = Integer.parseInt(ymd.substring(5, 7));
  494 + for (int y = year - 1; y <= year + 1; y++) {
  495 + JSONObject yearData = new JSONObject();
  496 + JSONArray monthArray = new JSONArray();
  497 + for (int m = ((y == year - 1)? month:1); m <= ((y == year + 1)?month:12); m++) {
  498 + String ym = y + "-" + (m < 10 ? "0" + m : Integer.toString(m));
  499 + Integer count = countMap.getInteger(ym);
  500 + JSONObject ymData = new JSONObject();
  501 + ymData.put("month", m);
  502 + ymData.put("count", count == null ? Integer.valueOf(0) : count);
  503 + monthArray.add(ymData);
  504 + }
  505 + yearData.put(Integer.toString(y), monthArray);
  506 + yearArray.add(yearData);
  507 + }
  508 + jo.put("countData", yearArray);
  509 + return jo;
  510 + }
499 511
500 @Override 512 @Override
501 @Cachable(expire=180) 513 @Cachable(expire=180)
@@ -511,6 +523,20 @@ public class ProductSearchServiceImpl implements ProductSearchService { @@ -511,6 +523,20 @@ public class ProductSearchServiceImpl implements ProductSearchService {
511 return data; 523 return data;
512 } 524 }
513 525
  526 + @Override
  527 + @Cachable(expire=180)
  528 + public JSONObject searchNewSaleCalendar(Integer startTime, Integer endTime) {
  529 + ProductSearchReq req = new ProductSearchReq();
  530 + req.setStartTime(startTime).setEndTime(endTime);
  531 + SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
  532 + JSONObject data = search(searchParam.getParam(), NEW_SALE_CALENDAR_LIST_URL);
  533 + // 将图片的相对路径转成绝对路径
  534 + if (null != data) {
  535 + processProductList(data.getJSONArray("product_list"));
  536 + }
  537 + return data;
  538 + }
  539 +
514 @Override 540 @Override
515 public JSONObject searchHotSale(Integer page, Integer limit) { 541 public JSONObject searchHotSale(Integer page, Integer limit) {
516 ProductSearchReq req = new ProductSearchReq().setViewNum(limit).setPage(page); 542 ProductSearchReq req = new ProductSearchReq().setViewNum(limit).setPage(page);