Authored by caoyan

自助尺码

@@ -23,29 +23,37 @@ @@ -23,29 +23,37 @@
23 <sql id="Query_Sql" > 23 <sql id="Query_Sql" >
24 <if test="selfSizeReq.productName != null and selfSizeReq.productName != '' "> 24 <if test="selfSizeReq.productName != null and selfSizeReq.productName != '' ">
25 <bind name="pattern" value="'%' + selfSizeReq.productName + '%'" /> 25 <bind name="pattern" value="'%' + selfSizeReq.productName + '%'" />
26 - and product_name like #{pattern} 26 + and b.product_name like #{pattern}
27 </if> 27 </if>
28 <if test="selfSizeReq.productCode != null and selfSizeReq.productCode != '' "> 28 <if test="selfSizeReq.productCode != null and selfSizeReq.productCode != '' ">
29 - and product_code=#{selfSizeReq.productCode} 29 + and b.product_code=#{selfSizeReq.productCode}
30 </if> 30 </if>
31 <if test="selfSizeReq.status != null"> 31 <if test="selfSizeReq.status != null">
32 - and status=#{selfSizeReq.status} 32 + and a.status=#{selfSizeReq.status}
33 </if> 33 </if>
34 </sql> 34 </sql>
35 35
36 <select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SelfSizeReq"> 36 <select id="selectTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SelfSizeReq">
37 select count(1) 37 select count(1)
38 - from self_size 38 + from self_size a
  39 + <if test="selfSizeReq.productName != null or selfSizeReq.productCode != ''">
  40 + LEFT JOIN product b
  41 + ON( b.id=a.product_id)
  42 + </if>
39 where 1=1 43 where 1=1
40 <include refid="Query_Sql"></include> 44 <include refid="Query_Sql"></include>
41 </select> 45 </select>
42 46
43 <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.product.model.SelfSizeReq"> 47 <select id="selectByCondition" resultMap="BaseResultMap" parameterType="com.yoho.product.model.SelfSizeReq">
44 - select <include refid="Base_Column_List"></include>  
45 - from self_size 48 + select a.id, a.product_id, a.goods_id, a.size_id, a.audit_time, a.audit_uid, a.status
  49 + from self_size a
  50 + <if test="selfSizeReq.productName != null and selfSizeReq.productName != ''">
  51 + LEFT JOIN product b
  52 + ON( b.id=a.product_id)
  53 + </if>
46 where 1=1 54 where 1=1
47 <include refid="Query_Sql"></include> 55 <include refid="Query_Sql"></include>
48 - order by id desc 56 + order by a.id desc
49 <if test="selfSizeReq.start!=null and selfSizeReq.size != null"> 57 <if test="selfSizeReq.start!=null and selfSizeReq.size != null">
50 limit #{selfSizeReq.start},#{selfSizeReq.size} 58 limit #{selfSizeReq.start},#{selfSizeReq.size}
51 </if> 59 </if>
1 package com.yoho.ufo.service.impl; 1 package com.yoho.ufo.service.impl;
2 2
  3 +import java.util.Collections;
3 import java.util.List; 4 import java.util.List;
4 import java.util.Map; 5 import java.util.Map;
5 import java.util.Map.Entry; 6 import java.util.Map.Entry;
6 import java.util.Set; 7 import java.util.Set;
  8 +import java.util.concurrent.TimeUnit;
7 import java.util.stream.Collectors; 9 import java.util.stream.Collectors;
8 10
9 import org.apache.commons.collections.CollectionUtils; 11 import org.apache.commons.collections.CollectionUtils;
@@ -14,10 +16,12 @@ import org.slf4j.helpers.MessageFormatter; @@ -14,10 +16,12 @@ import org.slf4j.helpers.MessageFormatter;
14 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
16 18
  19 +import com.alibaba.fastjson.JSONObject;
17 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
18 import com.google.common.collect.Maps; 21 import com.google.common.collect.Maps;
19 import com.google.common.collect.Sets; 22 import com.google.common.collect.Sets;
20 import com.yoho.core.common.utils.DateUtil; 23 import com.yoho.core.common.utils.DateUtil;
  24 +import com.yoho.core.rest.client.ServiceCaller;
21 import com.yoho.product.dal.SelfSizeMapper; 25 import com.yoho.product.dal.SelfSizeMapper;
22 import com.yoho.product.dal.SelfSizeUidMapper; 26 import com.yoho.product.dal.SelfSizeUidMapper;
23 import com.yoho.product.model.SelfSize; 27 import com.yoho.product.model.SelfSize;
@@ -72,6 +76,9 @@ public class SelfSizeServiceImpl implements ISelfSizeService { @@ -72,6 +76,9 @@ public class SelfSizeServiceImpl implements ISelfSizeService {
72 @Autowired 76 @Autowired
73 private UserProxyService userProxyService; 77 private UserProxyService userProxyService;
74 78
  79 + @Autowired
  80 + private ServiceCaller serviceCaller;
  81 +
75 @Override 82 @Override
76 public PageResponseBO<SelfSizeRsp> queryList(SelfSizeReq req){ 83 public PageResponseBO<SelfSizeRsp> queryList(SelfSizeReq req){
77 int total = selfSizeMapper.selectTotalByCondition(req); 84 int total = selfSizeMapper.selectTotalByCondition(req);
@@ -217,6 +224,9 @@ public class SelfSizeServiceImpl implements ISelfSizeService { @@ -217,6 +224,9 @@ public class SelfSizeServiceImpl implements ISelfSizeService {
217 // } 224 // }
218 UserHelper userInfo = new UserHelper(); 225 UserHelper userInfo = new UserHelper();
219 int num = selfSizeMapper.upadteAuditResult(req.getId(), req.getStatus(), userInfo.getUserId()); 226 int num = selfSizeMapper.upadteAuditResult(req.getId(), req.getStatus(), userInfo.getUserId());
  227 + //清商品详情缓存
  228 + clearProductDetailCache(selfSize.getProductId());
  229 +
220 if(num > 0 && req.getStatus().intValue() == 1) {//审核通过 230 if(num > 0 && req.getStatus().intValue() == 1) {//审核通过
221 Product product = productMapper.selectByPrimaryKey(selfSize.getProductId()); 231 Product product = productMapper.selectByPrimaryKey(selfSize.getProductId());
222 Size size = ufoSizeMapper.selectOneById(selfSize.getSizeId()); 232 Size size = ufoSizeMapper.selectOneById(selfSize.getSizeId());
@@ -239,6 +249,15 @@ public class SelfSizeServiceImpl implements ISelfSizeService { @@ -239,6 +249,15 @@ public class SelfSizeServiceImpl implements ISelfSizeService {
239 return num; 249 return num;
240 } 250 }
241 251
  252 + private JSONObject clearProductDetailCache(Integer productId) {
  253 + String args = "ufo-gateway.clearProductDetailCache";
  254 + LOGGER.info("asyncCallClearCache call ufo-gateway enter productId is {}, interface is {}", productId, args);
  255 + Map<String,Integer> request = Collections.singletonMap("id", productId);
  256 + JSONObject jsonObject = serviceCaller.asyncCall(args, request, JSONObject.class).get(5, TimeUnit.SECONDS);
  257 + LOGGER.info("asyncCallClearCache call ufo-gateway productId is {}, interface is {},result is {}", productId, args, jsonObject);
  258 + return jsonObject;
  259 + }
  260 +
242 private String getReplacedContent(String content ,Object... params) { 261 private String getReplacedContent(String content ,Object... params) {
243 return MessageFormatter.arrayFormat(content, params).getMessage(); 262 return MessageFormatter.arrayFormat(content, params).getMessage();
244 } 263 }