Authored by tanling

Merge branch 'test6.9.17' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.17

... ... @@ -38,7 +38,10 @@
<select id="selectTypeCount" resultType="java.lang.Integer">
SELECT count(1) count FROM ${tableName} force index (`uid`) WHERE uid = #{uid}
and is_read = #{isRead} and is_del = #{isDel} AND type = #{type}
and is_read = #{isRead} and is_del = #{isDel}
<if test="type != null">
AND type = #{type}
</if>
<if test="time != 0 and isRead ='N'">
and create_time &gt;= #{time}
</if>
... ...
... ... @@ -411,4 +411,39 @@ public class ProductSearchController {
return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
}
@ApiOperation(name = "ufo.product.search.list", desc="首页商品推荐")
@RequestMapping(params = "method=ufo.product.search.common.list")
@IgnoreSession
@Cachable(expire = 180)
public ApiResponse searchCommonProductList(
@RequestParam(value = "order", required = false)String order,
@RequestParam(value = "product_id", required = false)String id,
@RequestParam(value = "not_product_id", required = false)String notId,
@RequestParam(value = "productPool", required = false) String productPool,
@RequestParam(value = "sort", required = false)String sort,
@RequestParam(value = "brand", required = false)String brand,
@RequestParam(value = "series", required = false)String series,
@RequestParam(value = "gender", required = false) String gender,
@RequestParam(value = "size", required = false) String size,
@RequestParam(value = "query", required = false)String query,
@RequestParam(value = "limit", required = false)Integer limit,
@RequestParam(value = "page", required = false)Integer page
) {
if (StringUtils.isNotBlank(productPool) && StringUtils.isBlank(query) && StringUtils.isBlank(order)) {
order = "pools.order_by:desc"; // 如果走商品池接口,默认走排序倒序接口
}
SortIdLevel sortIdLevel = productSearchService.getSortLevelById(sort);
ProductSearchReq req = new ProductSearchReq().setOrder(order).setId(id).setNot_id(notId).setPool(productPool).setBrand(brand)
.setSeries(series).setGender(gender).setSize(size).setViewNum(limit).setPage(page);
searchHelpService.setQuery(query, req);
if(StringUtils.isNotBlank(sort)) {
req.setMidSort(sortIdLevel.getMidSortId()).setMaxSort(sortIdLevel.getMaxSortId());
}
LOG.info("in method=ufo.product.search.common.list req={}", req.toString());
JSONObject resp = productSearchService.searchCommonProductList(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("Product List.").data(resp).build();
}
}
\ No newline at end of file
... ...
... ... @@ -58,4 +58,6 @@ public interface ProductSearchService {
* @return
*/
SearchProductListFilterResp searchSecondhandSkupListFilter(ProductSearchReq req);
JSONObject searchCommonProductList(ProductSearchReq req);
}
... ...
... ... @@ -721,4 +721,21 @@ public class ProductSearchServiceImpl implements ProductSearchService {
}
return data;
}
@Override
public JSONObject searchCommonProductList(ProductSearchReq req) {
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
String url = null;
if (StringUtils.isNotBlank(req.getPool())) {
url = ProductSearchConstants.PRODUCT_POOL_URL;
} else {
url = ProductSearchConstants.PRODUCT_LIST_URL;
}
JSONObject data = searchAssistService.search(searchParam.getParam(), url);
if (null != data) {
searchAssistService.processProductList(data.getJSONArray("product_list"));
searchAssistService.setRecId(data);
}
return data;
}
}
... ...
... ... @@ -33,6 +33,18 @@ public enum CacheEnum {
* 消息盒子-是否是新消息引导,缓存20分钟
*/
USERS_INBOX_NEW_MARK("ufo:users:inbox_new_mark", 24 * 60 * 60, "ufo.users.cachetime.inbox_new_mark"),
/**
* 消息盒子-最新一条消息,缓存5分钟
*/
USERS_INBOX_VO_LAST_INFO("ufo:users:inbox_last_info", 5 * 60, "users.cachetime.inbox_last_info"),
/**
* 消息盒子-未读消息总数,缓存5分钟
*/
USERS_INBOX_LIST_UNREAD_TOTAL("ufo:users:inbox_list_total", 5 * 60, "users.cachetime.inbox_unread_total"),
/*
* end
*/;
... ...
... ... @@ -60,7 +60,7 @@ public class InBoxController {
logger.warn("getTotalUnread:Uid is null or 0.");
throw new ServiceException(ServiceError.SMS_INBOX_UID_NULL);
}
JSONObject result = inBoxService.getTotalUnread(reqBO.getUid());
JSONObject result = inBoxService.getTotalUnreadEx(reqBO.getUid());
return new ApiResponse(200,"操作成功",result);
}
... ...
... ... @@ -25,4 +25,6 @@ public interface IInBoxService {
JSONObject getTotalUnread(int uid);
void addBatchInboxByUids(String uids, Integer type, Integer businessType, String params);
JSONObject getTotalUnreadEx(int uid);
}
... ...
... ... @@ -274,7 +274,10 @@ public class InBoxServiceImpl implements IInBoxService {
log.info("listInboxByTypes updateReadedByUidAndType param is {}", reqVO);
inBoxDao.updateReadedByUidAndType(getTableName(reqVO.getUid()),reqVO.getUid(),reqVO.getType(),DateUtil.getCurrentTimeSecond(),getUnreadBeginTime());
RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(reqVO.getUid(),reqVO.getType());
redisTemplate.delete(key);
RedisKeyBuilder key1 = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(reqVO.getUid());
RedisKeyBuilder key2 = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(reqVO.getUid());
redisTemplate.delete(key, key1, key2);
}
}
... ... @@ -410,16 +413,46 @@ public class InBoxServiceImpl implements IInBoxService {
return result;
}
public JSONObject getTotalUnreadEx(int uid) {
JSONObject result = new JSONObject();
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(uid);
InBox inbox = redisTemplate.get(inboxKey, InBox.class);
if (null == inbox) {
List<InBox> inBoxes = inBoxDao.selectInboxs(getTableName(uid), null, uid, 0, 1); //查询最新一条未读消息
if(CollectionUtils.isNotEmpty(inBoxes)){
result.put("lastMessage", inBoxes.get(0).getContent());
result.put("createTime", inBoxes.get(0).getCreateTime());
}
redisTemplate.setEx(inboxKey, inBoxes.get(0), CacheEnum.USERS_INBOX_VO_LAST_INFO.getCacheTime());
} else {
result.put("lastMessage", inbox.getContent());
result.put("createTime", inbox.getCreateTime());
}
//查询未读消息总数
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(uid);
Integer total = redisTemplate.get(inboxTotalKey,Integer.class);
if (null == total) {
int i = inBoxDao.selectTypeCount(getTableName(uid), uid, "N", "N", null, getUnreadBeginTime());
result.put("count", i);
redisTemplate.setEx(inboxTotalKey, i, CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.getCacheTime());
} else {
result.put("count", total);
}
return result;
}
private void deleteIboxsByRedis(int uid,int type){
log.info("deleteIboxsByRedis params uid is {} type is {}",uid,type);
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_VO_LIST.generateKey(uid);
redisTemplate.delete(inboxKey);
RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(uid,type);
redisTemplate.delete(key);
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,"N");
redisTemplate.delete(inboxTotalKey);
RedisKeyBuilder inboxTypeTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,type);
redisTemplate.delete(inboxTypeTotalKey);
RedisKeyBuilder key1 = CacheEnum.USERS_INBOX_VO_LAST_INFO.generateKey(uid);
RedisKeyBuilder key2 = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(uid);
redisTemplate.delete(inboxKey, key, inboxTotalKey, inboxTypeTotalKey, key1, key2);
}
private String createContent(String template, String params){
... ...