Authored by caoyan

自助尺码

... ... @@ -23,29 +23,37 @@
<sql id="Query_Sql" >
<if test="selfSizeReq.productName != null and selfSizeReq.productName != '' ">
<bind name="pattern" value="'%' + selfSizeReq.productName + '%'" />
and product_name like #{pattern}
and b.product_name like #{pattern}
</if>
<if test="selfSizeReq.productCode != null and selfSizeReq.productCode != '' ">
and product_code=#{selfSizeReq.productCode}
and b.product_code=#{selfSizeReq.productCode}
</if>
<if test="selfSizeReq.status != null">
and status=#{selfSizeReq.status}
and a.status=#{selfSizeReq.status}
</if>
</sql>
<select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SelfSizeReq">
select count(1)
from self_size
from self_size a
<if test="selfSizeReq.productName != null or selfSizeReq.productCode != ''">
LEFT JOIN product b
ON( b.id=a.product_id)
</if>
where 1=1
<include refid="Query_Sql"></include>
</select>
<select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.product.model.SelfSizeReq">
select <include refid="Base_Column_List"></include>
from self_size
select a.id, a.product_id, a.goods_id, a.size_id, a.audit_time, a.audit_uid, a.status
from self_size a
<if test="selfSizeReq.productName != null and selfSizeReq.productName != ''">
LEFT JOIN product b
ON( b.id=a.product_id)
</if>
where 1=1
<include refid="Query_Sql"></include>
order by id desc
order by a.id desc
<if test="selfSizeReq.start!=null and selfSizeReq.size != null">
limit #{selfSizeReq.start},#{selfSizeReq.size}
</if>
... ...
package com.yoho.ufo.service.impl;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -14,10 +16,12 @@ import org.slf4j.helpers.MessageFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.product.dal.SelfSizeMapper;
import com.yoho.product.dal.SelfSizeUidMapper;
import com.yoho.product.model.SelfSize;
... ... @@ -72,6 +76,9 @@ public class SelfSizeServiceImpl implements ISelfSizeService {
@Autowired
private UserProxyService userProxyService;
@Autowired
private ServiceCaller serviceCaller;
@Override
public PageResponseBO<SelfSizeRsp> queryList(SelfSizeReq req){
int total = selfSizeMapper.selectTotalByCondition(req);
... ... @@ -217,6 +224,9 @@ public class SelfSizeServiceImpl implements ISelfSizeService {
// }
UserHelper userInfo = new UserHelper();
int num = selfSizeMapper.upadteAuditResult(req.getId(), req.getStatus(), userInfo.getUserId());
//清商品详情缓存
clearProductDetailCache(selfSize.getProductId());
if(num > 0 && req.getStatus().intValue() == 1) {//审核通过
Product product = productMapper.selectByPrimaryKey(selfSize.getProductId());
Size size = ufoSizeMapper.selectOneById(selfSize.getSizeId());
... ... @@ -239,6 +249,15 @@ public class SelfSizeServiceImpl implements ISelfSizeService {
return num;
}
private JSONObject clearProductDetailCache(Integer productId) {
String args = "ufo-gateway.clearProductDetailCache";
LOGGER.info("asyncCallClearCache call ufo-gateway enter productId is {}, interface is {}", productId, args);
Map<String,Integer> request = Collections.singletonMap("id", productId);
JSONObject jsonObject = serviceCaller.asyncCall(args, request, JSONObject.class).get(5, TimeUnit.SECONDS);
LOGGER.info("asyncCallClearCache call ufo-gateway productId is {}, interface is {},result is {}", productId, args, jsonObject);
return jsonObject;
}
private String getReplacedContent(String content ,Object... params) {
return MessageFormatter.arrayFormat(content, params).getMessage();
}
... ...