Merge branch 'test6.9.17' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.17
Showing
8 changed files
with
111 additions
and
7 deletions
@@ -38,7 +38,10 @@ | @@ -38,7 +38,10 @@ | ||
38 | 38 | ||
39 | <select id="selectTypeCount" resultType="java.lang.Integer"> | 39 | <select id="selectTypeCount" resultType="java.lang.Integer"> |
40 | SELECT count(1) count FROM ${tableName} force index (`uid`) WHERE uid = #{uid} | 40 | SELECT count(1) count FROM ${tableName} force index (`uid`) WHERE uid = #{uid} |
41 | - and is_read = #{isRead} and is_del = #{isDel} AND type = #{type} | 41 | + and is_read = #{isRead} and is_del = #{isDel} |
42 | + <if test="type != null"> | ||
43 | + AND type = #{type} | ||
44 | + </if> | ||
42 | <if test="time != 0 and isRead ='N'"> | 45 | <if test="time != 0 and isRead ='N'"> |
43 | and create_time >= #{time} | 46 | and create_time >= #{time} |
44 | </if> | 47 | </if> |
@@ -411,4 +411,39 @@ public class ProductSearchController { | @@ -411,4 +411,39 @@ public class ProductSearchController { | ||
411 | 411 | ||
412 | return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build(); | 412 | return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build(); |
413 | } | 413 | } |
414 | + | ||
415 | + @ApiOperation(name = "ufo.product.search.list", desc="首页商品推荐") | ||
416 | + @RequestMapping(params = "method=ufo.product.search.common.list") | ||
417 | + @IgnoreSession | ||
418 | + @Cachable(expire = 180) | ||
419 | + public ApiResponse searchCommonProductList( | ||
420 | + @RequestParam(value = "order", required = false)String order, | ||
421 | + @RequestParam(value = "product_id", required = false)String id, | ||
422 | + @RequestParam(value = "not_product_id", required = false)String notId, | ||
423 | + @RequestParam(value = "productPool", required = false) String productPool, | ||
424 | + @RequestParam(value = "sort", required = false)String sort, | ||
425 | + @RequestParam(value = "brand", required = false)String brand, | ||
426 | + @RequestParam(value = "series", required = false)String series, | ||
427 | + @RequestParam(value = "gender", required = false) String gender, | ||
428 | + @RequestParam(value = "size", required = false) String size, | ||
429 | + @RequestParam(value = "query", required = false)String query, | ||
430 | + @RequestParam(value = "limit", required = false)Integer limit, | ||
431 | + @RequestParam(value = "page", required = false)Integer page | ||
432 | + ) { | ||
433 | + if (StringUtils.isNotBlank(productPool) && StringUtils.isBlank(query) && StringUtils.isBlank(order)) { | ||
434 | + order = "pools.order_by:desc"; // 如果走商品池接口,默认走排序倒序接口 | ||
435 | + } | ||
436 | + SortIdLevel sortIdLevel = productSearchService.getSortLevelById(sort); | ||
437 | + ProductSearchReq req = new ProductSearchReq().setOrder(order).setId(id).setNot_id(notId).setPool(productPool).setBrand(brand) | ||
438 | + .setSeries(series).setGender(gender).setSize(size).setViewNum(limit).setPage(page); | ||
439 | + searchHelpService.setQuery(query, req); | ||
440 | + if(StringUtils.isNotBlank(sort)) { | ||
441 | + req.setMidSort(sortIdLevel.getMidSortId()).setMaxSort(sortIdLevel.getMaxSortId()); | ||
442 | + } | ||
443 | + | ||
444 | + LOG.info("in method=ufo.product.search.common.list req={}", req.toString()); | ||
445 | + JSONObject resp = productSearchService.searchCommonProductList(req); | ||
446 | + | ||
447 | + return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build(); | ||
448 | + } | ||
414 | } | 449 | } |
@@ -58,4 +58,6 @@ public interface ProductSearchService { | @@ -58,4 +58,6 @@ public interface ProductSearchService { | ||
58 | * @return | 58 | * @return |
59 | */ | 59 | */ |
60 | SearchProductListFilterResp searchSecondhandSkupListFilter(ProductSearchReq req); | 60 | SearchProductListFilterResp searchSecondhandSkupListFilter(ProductSearchReq req); |
61 | + | ||
62 | + JSONObject searchCommonProductList(ProductSearchReq req); | ||
61 | } | 63 | } |
@@ -721,4 +721,21 @@ public class ProductSearchServiceImpl implements ProductSearchService { | @@ -721,4 +721,21 @@ public class ProductSearchServiceImpl implements ProductSearchService { | ||
721 | } | 721 | } |
722 | return data; | 722 | return data; |
723 | } | 723 | } |
724 | + | ||
725 | + @Override | ||
726 | + public JSONObject searchCommonProductList(ProductSearchReq req) { | ||
727 | + SearchParam searchParam = new SearchParam().buildPageSearchParam(req); | ||
728 | + String url = null; | ||
729 | + if (StringUtils.isNotBlank(req.getPool())) { | ||
730 | + url = ProductSearchConstants.PRODUCT_POOL_URL; | ||
731 | + } else { | ||
732 | + url = ProductSearchConstants.PRODUCT_LIST_URL; | ||
733 | + } | ||
734 | + JSONObject data = searchAssistService.search(searchParam.getParam(), url); | ||
735 | + if (null != data) { | ||
736 | + searchAssistService.processProductList(data.getJSONArray("product_list")); | ||
737 | + searchAssistService.setRecId(data); | ||
738 | + } | ||
739 | + return data; | ||
740 | + } | ||
724 | } | 741 | } |
@@ -33,6 +33,18 @@ public enum CacheEnum { | @@ -33,6 +33,18 @@ public enum CacheEnum { | ||
33 | * 消息盒子-是否是新消息引导,缓存20分钟 | 33 | * 消息盒子-是否是新消息引导,缓存20分钟 |
34 | */ | 34 | */ |
35 | USERS_INBOX_NEW_MARK("ufo:users:inbox_new_mark", 24 * 60 * 60, "ufo.users.cachetime.inbox_new_mark"), | 35 | USERS_INBOX_NEW_MARK("ufo:users:inbox_new_mark", 24 * 60 * 60, "ufo.users.cachetime.inbox_new_mark"), |
36 | + | ||
37 | + | ||
38 | + /** | ||
39 | + * 消息盒子-最新一条消息,缓存5分钟 | ||
40 | + */ | ||
41 | + USERS_INBOX_VO_LAST_INFO("ufo:users:inbox_last_info", 5 * 60, "users.cachetime.inbox_last_info"), | ||
42 | + | ||
43 | + /** | ||
44 | + * 消息盒子-未读消息总数,缓存5分钟 | ||
45 | + */ | ||
46 | + USERS_INBOX_LIST_UNREAD_TOTAL("ufo:users:inbox_list_total", 5 * 60, "users.cachetime.inbox_unread_total"), | ||
47 | + | ||
36 | /* | 48 | /* |
37 | * end | 49 | * end |
38 | */; | 50 | */; |
@@ -60,7 +60,7 @@ public class InBoxController { | @@ -60,7 +60,7 @@ public class InBoxController { | ||
60 | logger.warn("getTotalUnread:Uid is null or 0."); | 60 | logger.warn("getTotalUnread:Uid is null or 0."); |
61 | throw new ServiceException(ServiceError.SMS_INBOX_UID_NULL); | 61 | throw new ServiceException(ServiceError.SMS_INBOX_UID_NULL); |
62 | } | 62 | } |
63 | - JSONObject result = inBoxService.getTotalUnread(reqBO.getUid()); | 63 | + JSONObject result = inBoxService.getTotalUnreadEx(reqBO.getUid()); |
64 | return new ApiResponse(200,"操作成功",result); | 64 | return new ApiResponse(200,"操作成功",result); |
65 | } | 65 | } |
66 | 66 |
@@ -25,4 +25,6 @@ public interface IInBoxService { | @@ -25,4 +25,6 @@ public interface IInBoxService { | ||
25 | JSONObject getTotalUnread(int uid); | 25 | JSONObject getTotalUnread(int uid); |
26 | 26 | ||
27 | void addBatchInboxByUids(String uids, Integer type, Integer businessType, String params); | 27 | void addBatchInboxByUids(String uids, Integer type, Integer businessType, String params); |
28 | + | ||
29 | + JSONObject getTotalUnreadEx(int uid); | ||
28 | } | 30 | } |
@@ -274,7 +274,10 @@ public class InBoxServiceImpl implements IInBoxService { | @@ -274,7 +274,10 @@ public class InBoxServiceImpl implements IInBoxService { | ||
274 | log.info("listInboxByTypes updateReadedByUidAndType param is {}", reqVO); | 274 | log.info("listInboxByTypes updateReadedByUidAndType param is {}", reqVO); |
275 | inBoxDao.updateReadedByUidAndType(getTableName(reqVO.getUid()),reqVO.getUid(),reqVO.getType(),DateUtil.getCurrentTimeSecond(),getUnreadBeginTime()); | 275 | inBoxDao.updateReadedByUidAndType(getTableName(reqVO.getUid()),reqVO.getUid(),reqVO.getType(),DateUtil.getCurrentTimeSecond(),getUnreadBeginTime()); |
276 | RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(reqVO.getUid(),reqVO.getType()); | 276 | RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(reqVO.getUid(),reqVO.getType()); |
277 | - redisTemplate.delete(key); | 277 | + RedisKeyBuilder key1 = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(reqVO.getUid()); |
278 | + RedisKeyBuilder key2 = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(reqVO.getUid()); | ||
279 | + | ||
280 | + redisTemplate.delete(key, key1, key2); | ||
278 | } | 281 | } |
279 | } | 282 | } |
280 | 283 | ||
@@ -410,16 +413,46 @@ public class InBoxServiceImpl implements IInBoxService { | @@ -410,16 +413,46 @@ public class InBoxServiceImpl implements IInBoxService { | ||
410 | return result; | 413 | return result; |
411 | } | 414 | } |
412 | 415 | ||
416 | + public JSONObject getTotalUnreadEx(int uid) { | ||
417 | + JSONObject result = new JSONObject(); | ||
418 | + | ||
419 | + RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(uid); | ||
420 | + InBox inbox = redisTemplate.get(inboxKey, InBox.class); | ||
421 | + if (null == inbox) { | ||
422 | + List<InBox> inBoxes = inBoxDao.selectInboxs(getTableName(uid), null, uid, 0, 1); //查询最新一条未读消息 | ||
423 | + if(CollectionUtils.isNotEmpty(inBoxes)){ | ||
424 | + result.put("lastMessage", inBoxes.get(0).getContent()); | ||
425 | + result.put("createTime", inBoxes.get(0).getCreateTime()); | ||
426 | + } | ||
427 | + redisTemplate.setEx(inboxKey, inBoxes.get(0), CacheEnum.USERS_INBOX_VO_LAST_INFO.getCacheTime()); | ||
428 | + } else { | ||
429 | + result.put("lastMessage", inbox.getContent()); | ||
430 | + result.put("createTime", inbox.getCreateTime()); | ||
431 | + } | ||
432 | + | ||
433 | + //查询未读消息总数 | ||
434 | + RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(uid); | ||
435 | + Integer total = redisTemplate.get(inboxTotalKey,Integer.class); | ||
436 | + if (null == total) { | ||
437 | + int i = inBoxDao.selectTypeCount(getTableName(uid), uid, "N", "N", null, getUnreadBeginTime()); | ||
438 | + result.put("count", i); | ||
439 | + redisTemplate.setEx(inboxTotalKey, i, CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.getCacheTime()); | ||
440 | + } else { | ||
441 | + result.put("count", total); | ||
442 | + } | ||
443 | + return result; | ||
444 | + } | ||
445 | + | ||
413 | private void deleteIboxsByRedis(int uid,int type){ | 446 | private void deleteIboxsByRedis(int uid,int type){ |
414 | log.info("deleteIboxsByRedis params uid is {} type is {}",uid,type); | 447 | log.info("deleteIboxsByRedis params uid is {} type is {}",uid,type); |
415 | RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_VO_LIST.generateKey(uid); | 448 | RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_VO_LIST.generateKey(uid); |
416 | - redisTemplate.delete(inboxKey); | ||
417 | RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(uid,type); | 449 | RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(uid,type); |
418 | - redisTemplate.delete(key); | ||
419 | RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,"N"); | 450 | RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,"N"); |
420 | - redisTemplate.delete(inboxTotalKey); | ||
421 | RedisKeyBuilder inboxTypeTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,type); | 451 | RedisKeyBuilder inboxTypeTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,type); |
422 | - redisTemplate.delete(inboxTypeTotalKey); | 452 | + RedisKeyBuilder key1 = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(uid); |
453 | + RedisKeyBuilder key2 = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(uid); | ||
454 | + | ||
455 | + redisTemplate.delete(inboxKey, key, inboxTotalKey, inboxTypeTotalKey, key1, key2); | ||
423 | } | 456 | } |
424 | 457 | ||
425 | private String createContent(String template, String params){ | 458 | private String createContent(String template, String params){ |
-
Please register or login to post a comment