Authored by caoyan

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

... ... @@ -165,7 +165,7 @@
<select id="getDepositOffs" resultMap="BaseResultMap">
select * from storage_deposit
where owner_uid = #{uid} and storage_id = #{storageId}
and status=1 and order_status=0 and del_status=0 and out_type!=3 and deposit_end_time &gt; unix_timestamp(now()) limit 0, #{count}
and status=1 and order_status=0 and del_status=0 and out_type!=3 and deposit_end_time &gt; unix_timestamp(now()) order by deposit_end_time asc limit 0, #{count}
</select>
<select id="selectByDepositCode" resultMap="BaseResultMap">
... ...
... ... @@ -12,8 +12,11 @@
<select id="selectAll" resultMap="BaseResultMap">
select id, search_word, order_by, create_time, update_time from search_word
where 1 = 1
<if test="clientType != null">
AND (client_type = #{clientType, jdbcType=INTEGER} or client_type = 2)
<if test="clientType != null and clientType==3">
and (client_type = 3)
</if>
<if test="clientType != null and clientType!=3">
and (client_type = #{clientType} or client_type = 2)
</if>
<if test="wordType != null">
AND word_type = #{wordType, jdbcType=INTEGER}
... ...
... ... @@ -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>
... ...
... ... @@ -4,6 +4,7 @@ import com.google.common.base.Throwables;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.FastDeliveryBatchOnShelfResp;
import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfDetailResp;
import com.yohobuy.ufo.model.response.StorageCheckResp;
import com.yohobuy.ufo.model.response.StorageInfoResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
... ... @@ -31,6 +32,21 @@ public class ErpFastDeliveryController {
@Autowired
IErpFastDeliveryService erpFastDeliveryService;
/**
* 货号+尺寸是否存在
* @param req
* @return
*/
@IgnoreSignature
@IgnoreSession
@RequestMapping("/getStorageInfo")
public ApiResponse getStorageInfo(@RequestBody FastDeliveryBatchOnShelfReq req){
List<StorageCheckResp> data = erpFastDeliveryService.getStorageInfo(req);
return new ApiResponse.ApiResponseBuilder().data(data).build();
}
/**
* 批量上架
* @param req
... ...
... ... @@ -38,7 +38,8 @@ public class MetaConfigController {
@RequestMapping("/orderMetaConfig/cleanCacheByCode")
@ResponseBody
public ApiResponse cleanCacheByCode(@RequestBody JSONObject jsonObject){
String code = jsonObject.getString("jsonObject");
logger.info("MetaConfigController.cleanCacheByCode in. req is :{}",jsonObject);
String code = jsonObject.getString("code");
if(null != code && !"".equals(code)){
logger.info("clean metaConfig cache by code :{}",code);
metaConfigService.clearCacheByCode(code);
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.FastDeliveryBatchOnShelfResp;
import com.yohobuy.ufo.model.order.resp.FastDeliveryGetShelfDetailResp;
import com.yohobuy.ufo.model.response.StorageCheckResp;
import com.yohobuy.ufo.model.response.StorageInfoResp;
import java.util.List;
... ... @@ -41,4 +42,12 @@ public interface IErpFastDeliveryService {
* @return
*/
List<StorageInfoResp> getLeastPriceByProductCode(FastDeliveryLeastPriceReq req);
/**
* 获取货号尺寸信息
* @param req
* @return
*/
public List<StorageCheckResp> getStorageInfo(FastDeliveryBatchOnShelfReq req);
}
... ...
... ... @@ -358,11 +358,13 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
return result.successCnt > 0 ? true : false;
}
@Override
public List<FastDeliveryBatchOnShelfResp> batchOnShelf(FastDeliveryBatchOnShelfReq req) {
// 1.检查入口参数
checkBatchOnShelf(req);
checkBatchOnShelf(req, true, true);
// 2.检查用户权限(极速发货权限)
SellerWrapper sellerWrapper = checkFastDeliveryAuth(req.getUid());
... ... @@ -429,6 +431,19 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
}
/**
* 获取货号尺寸信息
* @param req
* @return
*/
public List<StorageCheckResp> getStorageInfo(FastDeliveryBatchOnShelfReq req){
// 1.检查入口参数
checkBatchOnShelf(req, false,false);
return productProxyService.getStorageInfoList(buildStorageReq(req));
}
private Map<String, StorageCheckResp> getCheckStorageMap(FastDeliveryBatchOnShelfReq req) {
List<StorageCheckResp> storageCheckRespList = productProxyService.getStorageInfoList(buildStorageReq(req));
... ... @@ -500,7 +515,7 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
}
private void checkBatchOnShelf(FastDeliveryBatchOnShelfReq req) {
private void checkBatchOnShelf(FastDeliveryBatchOnShelfReq req, boolean checkNum, boolean checkPrice) {
if (req.getUid() < 0){
logger.warn("uid is empty");
... ... @@ -514,15 +529,23 @@ public class ErpFastDeliveryServiceImpl implements IErpFastDeliveryService {
for(FastDeliveryBatchOnShelfReq.ProductInfo productInfo : req.getProductInfos()){
if (StringUtils.isBlank(productInfo.getSizeName())
|| StringUtils.isBlank(productInfo.getProductCode())
|| productInfo.getNum() == null){
|| StringUtils.isBlank(productInfo.getProductCode())){
logger.warn("productInfo is invalidate {}", productInfo);
throw new UfoServiceException(400, "商品信息不合法");
}
// 价格已9结尾
BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(productInfo.getPrice(), SkupType.FAST_DELIVERY);
productInfo.setConvertedPrice(salePrice);
if (checkNum){
if (productInfo.getNum() == null){
logger.warn("productInfo is invalidate {}", productInfo);
throw new UfoServiceException(400, "商品信息不合法");
}
}
if (checkPrice){
// 价格已9结尾
BigDecimal salePrice = priceComputePrepareProcessor.checkAndAcquireSalePrice(productInfo.getPrice(), SkupType.FAST_DELIVERY);
productInfo.setConvertedPrice(salePrice);
}
}
}
}
... ...
... ... @@ -436,52 +436,48 @@ public class MetaConfigService {
* @param code
*/
public void clearCacheByCode(String code){
switch (code){
case "buyer_penalty":
cacheClient.delete(CacheKeyBuilder.KeyTemp.BUYER_CANCEL_PENALTY.builderKeyOnlyFixed().getKey());
break;
case "seller_enter_threshold":
cacheClient.delete(CacheKeyBuilder.KeyTemp.ENTRY_THRESHOLD.builderKeyOnlyFixed().getKey());
break;
case "seller_earnest_money":
cacheClient.delete(CacheKeyBuilder.KeyTemp.SELLER_EARNEST_MONEY_CONFIG.builderKeyOnlyFixed().getKey());
break;
case "seller_penalty":
cacheClient.delete(CacheKeyBuilder.KeyTemp.SELLER_PENALTY_CONFIG.builderKeyOnlyFixed().getKey());
break;
case "presale_threshold":
cacheClient.delete(CacheKeyBuilder.KeyTemp.PRESALE_THRESHOLD.builderKeyOnlyFixed().getKey());
break;
case "order_code_rule":
cacheClient.delete(CacheKeyBuilder.KeyTemp.ORDER_CODE_RULE.builderKeyOnlyFixed().getKey());
break;
case "seller_goods_fee_rate":
cacheClient.delete(CacheKeyBuilder.KeyTemp.SELLER_GOODS_FEE_RATE.builderKeyOnlyFixed().getKey());
break;
case "seller_goods_platform_fee":
cacheClient.delete(CacheKeyBuilder.KeyTemp.SELLER_GOODS_PLATFORM_FEE.builderKeyOnlyFixed().getKey());
break;
case "buyer_order_fee":
cacheClient.delete(CacheKeyBuilder.KeyTemp.BUYER_ORDER_FEE.builderKeyOnlyFixed().getKey());
break;
case "buyer_overseas_order_cut_policy":
cacheClient.delete(CacheKeyBuilder.KeyTemp.BUYER_ORDER_CUT_POLICY.builderKeyOnlyFixed().getKey());
break;
case "seller_goods_price_limit":
cacheClient.delete(CacheKeyBuilder.KeyTemp.SELLER_SALE_PRICE_LIMIT.builderKeyOnlyFixed().getKey());
break;
case "depositFee":
cacheClient.delete(CacheKeyBuilder.KeyTemp.DEPOSIT_PLATFORM_FEE.builderKeyOnlyFixed().getKey());
break;
case "buyer_bid_config":
cacheClient.delete(CacheKeyBuilder.KeyTemp.BUYER_BID_CONFIG.builderKeyOnlyFixed().getKey());
break;
case "seller_bid_goods_fee_rate":
cacheClient.delete(CacheKeyBuilder.KeyTemp.SELLER_BID_GOODS_FEE_RATE.builderKeyOnlyFixed().getKey());
break;
case "buyer_order_violation_penalty":
cacheClient.delete(CacheKeyBuilder.KeyTemp.BUYER_ORDER_VIOLATION_PENALTY.builderKeyOnlyFixed().getKey());
break;
CacheKeyBuilder.KeyTemp cacheKeyTemp = findMetaCodeCacheKeyMap().get(code);
if (Objects.isNull(cacheKeyTemp)){
logger.warn("clearCacheByCode find no cacheKeyTemp, code {}", code);
}else{
logger.info("clearCacheByCode find cacheKeyTemp {}, code {}", cacheKeyTemp, code);
cacheClient.delete(cacheKeyTemp.builderKeyOnlyFixed().getKey());
logger.info("clearCacheByCode finished, cacheKeyTemp {}, code {}", cacheKeyTemp, code);
}
}
/**
* delay load map data
*/
private static class DataHold{
private static final Map<String,CacheKeyBuilder.KeyTemp> MetaCodeCacheKeyMap ;
static {
MetaCodeCacheKeyMap = new HashMap<>(16);
MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_PENALTY, CacheKeyBuilder.KeyTemp.BUYER_CANCEL_PENALTY);
MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_ENTER_THRESHOLD, CacheKeyBuilder.KeyTemp.ENTRY_THRESHOLD);
MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_EARNEST_MONEY, CacheKeyBuilder.KeyTemp.SELLER_EARNEST_MONEY_CONFIG);
MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_PENALTY, CacheKeyBuilder.KeyTemp.SELLER_PENALTY_CONFIG);
MetaCodeCacheKeyMap.put(MetaConfigKey.PRESALE_THRESHOLD, CacheKeyBuilder.KeyTemp.PRESALE_THRESHOLD);
MetaCodeCacheKeyMap.put(MetaConfigKey.ORDER_CODE_RULE, CacheKeyBuilder.KeyTemp.ORDER_CODE_RULE);
MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_GOODS_FEE_RATE, CacheKeyBuilder.KeyTemp.SELLER_GOODS_FEE_RATE);
MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_GOODS_PLATFORM_FEE, CacheKeyBuilder.KeyTemp.SELLER_GOODS_PLATFORM_FEE);
MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_ORDER_FEE, CacheKeyBuilder.KeyTemp.BUYER_ORDER_FEE);
MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_OVERSEAS_ORDER_CUT_POLICY, CacheKeyBuilder.KeyTemp.BUYER_ORDER_CUT_POLICY);
MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_GOODS_PRICE_LIMIT, CacheKeyBuilder.KeyTemp.SELLER_SALE_PRICE_LIMIT);
MetaCodeCacheKeyMap.put(MetaConfigKey.DEPOSIT_FEE_POLICY, CacheKeyBuilder.KeyTemp.DEPOSIT_PLATFORM_FEE);
MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_BID_CONFIG, CacheKeyBuilder.KeyTemp.BUYER_BID_CONFIG);
MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_BID_GOODS_FEE_RATE, CacheKeyBuilder.KeyTemp.SELLER_BID_GOODS_FEE_RATE);
MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_ORDER_VIOLATION_PENALTY, CacheKeyBuilder.KeyTemp.BUYER_ORDER_VIOLATION_PENALTY);
}
}
/**
* TODO replace all method of get cache key when time is enough
* @return
*/
protected static Map<String,CacheKeyBuilder.KeyTemp> findMetaCodeCacheKeyMap(){
return DataHold.MetaCodeCacheKeyMap;
}
}
... ...
... ... @@ -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,22 @@ 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.processProductSales(data.getJSONArray("product_list"));
searchAssistService.setRecId(data);
}
return data;
}
}
... ...
... ... @@ -2031,8 +2031,8 @@ public class ProductServiceImpl implements ProductService {
if (!Objects.isNull(sort)) {
BigDecimal rate = new BigDecimal("100");
productInfo.setCategoryServiceFeeRate(sort.getServiceFeeRate() == null ? null : sort.getServiceFeeRate().divide(rate));
productInfo.setCategoryServiceFeeMinPrice(sort.getServiceFeeMinPrice() == null ? null : sort.getServiceFeeMinPrice().divide(rate));
productInfo.setCategoryServiceFeeMaxPrice(sort.getServiceFeeMaxPrice() == null ? null : sort.getServiceFeeMaxPrice().divide(rate));
productInfo.setCategoryServiceFeeMinPrice(sort.getServiceFeeMinPrice());
productInfo.setCategoryServiceFeeMaxPrice(sort.getServiceFeeMaxPrice());
}
}
... ...
... ... @@ -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,9 @@ 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 key2 = CacheEnum.USERS_INBOX_LIST_UNREAD_TOTAL.generateKey(reqVO.getUid());
redisTemplate.delete(key, key2);
}
}
... ... @@ -410,16 +412,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){
... ...