Authored by Lixiaodi

增加日志

@@ -114,4 +114,11 @@ public class StoragePrice { @@ -114,4 +114,11 @@ public class StoragePrice {
114 public void setCreateTime(Integer createTime) { 114 public void setCreateTime(Integer createTime) {
115 this.createTime = createTime; 115 this.createTime = createTime;
116 } 116 }
  117 +
  118 + @Override
  119 + public String toString() {
  120 + return "StoragePrice [id=" + id + ", skup=" + skup + ", productId=" + productId + ", goodsId=" + goodsId
  121 + + ", storageId=" + storageId + ", depotNum=" + depotNum + ", sellerUid=" + sellerUid + ", price="
  122 + + price + ", status=" + status + ", updateTime=" + updateTime + ", createTime=" + createTime + "]";
  123 + }
117 } 124 }
@@ -3,7 +3,6 @@ package com.yohoufo.product.controller; @@ -3,7 +3,6 @@ package com.yohoufo.product.controller;
3 import java.util.concurrent.ExecutorService; 3 import java.util.concurrent.ExecutorService;
4 import java.util.concurrent.Executors; 4 import java.util.concurrent.Executors;
5 5
6 -import com.yohoufo.product.response.*;  
7 import org.apache.commons.lang3.StringUtils; 6 import org.apache.commons.lang3.StringUtils;
8 import org.slf4j.Logger; 7 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory; 8 import org.slf4j.LoggerFactory;
@@ -12,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody; @@ -12,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody;
12 import org.springframework.web.bind.annotation.RequestMapping; 11 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.bind.annotation.RequestParam; 12 import org.springframework.web.bind.annotation.RequestParam;
14 import org.springframework.web.bind.annotation.RestController; 13 import org.springframework.web.bind.annotation.RestController;
  14 +
15 import com.yoho.error.exception.ServiceException; 15 import com.yoho.error.exception.ServiceException;
16 import com.yoho.tools.docs.ApiOperation; 16 import com.yoho.tools.docs.ApiOperation;
17 import com.yohoufo.common.ApiResponse; 17 import com.yohoufo.common.ApiResponse;
@@ -19,10 +19,13 @@ import com.yohoufo.common.annotation.IgnoreSession; @@ -19,10 +19,13 @@ import com.yohoufo.common.annotation.IgnoreSession;
19 import com.yohoufo.common.annotation.IgnoreSignature; 19 import com.yohoufo.common.annotation.IgnoreSignature;
20 import com.yohoufo.common.cache.Cachable; 20 import com.yohoufo.common.cache.Cachable;
21 import com.yohoufo.common.cache.ControllerCacheAop; 21 import com.yohoufo.common.cache.ControllerCacheAop;
22 -import com.yohoufo.common.caller.UfoServiceCaller;  
23 -import com.yohoufo.common.utils.UfoJsonUtil;  
24 import com.yohoufo.dal.product.model.StoragePrice; 22 import com.yohoufo.dal.product.model.StoragePrice;
25 import com.yohoufo.product.request.StoragePriceBo; 23 import com.yohoufo.product.request.StoragePriceBo;
  24 +import com.yohoufo.product.response.ProductDetailResp;
  25 +import com.yohoufo.product.response.ProductSeriesTemplateResp;
  26 +import com.yohoufo.product.response.ProductSortTemplateResp;
  27 +import com.yohoufo.product.response.StorageDataResp;
  28 +import com.yohoufo.product.response.StorageLeastPriceResp;
26 import com.yohoufo.product.service.ProductService; 29 import com.yohoufo.product.service.ProductService;
27 30
28 31
@@ -38,7 +41,7 @@ public class ProductController { @@ -38,7 +41,7 @@ public class ProductController {
38 @IgnoreSignature 41 @IgnoreSignature
39 @IgnoreSession 42 @IgnoreSession
40 @RequestMapping(params = "method=ufo.product.data") 43 @RequestMapping(params = "method=ufo.product.data")
41 - @Cachable(expire=600) 44 + @Cachable(expire = 300)
42 public ApiResponse queryProductDetailById( 45 public ApiResponse queryProductDetailById(
43 @RequestParam(value = "product_id") Integer productId) { 46 @RequestParam(value = "product_id") Integer productId) {
44 47
@@ -55,7 +58,7 @@ public class ProductController { @@ -55,7 +58,7 @@ public class ProductController {
55 @IgnoreSignature 58 @IgnoreSignature
56 @IgnoreSession 59 @IgnoreSession
57 @RequestMapping(params = "method=ufo.product.series.template") 60 @RequestMapping(params = "method=ufo.product.series.template")
58 - //@Cachable(expire=600) 61 + @Cachable(expire = 300)
59 public ApiResponse querySeriesTemplateData( 62 public ApiResponse querySeriesTemplateData(
60 @RequestParam(value = "product_ids") String productIds) { 63 @RequestParam(value = "product_ids") String productIds) {
61 64
@@ -70,7 +73,7 @@ public class ProductController { @@ -70,7 +73,7 @@ public class ProductController {
70 @IgnoreSignature 73 @IgnoreSignature
71 @IgnoreSession 74 @IgnoreSession
72 @RequestMapping(params = "method=ufo.product.sort.template") 75 @RequestMapping(params = "method=ufo.product.sort.template")
73 - //@Cachable(expire=600) 76 + @Cachable(expire = 300)
74 public ApiResponse querySortTemplateData( 77 public ApiResponse querySortTemplateData(
75 @RequestParam(value = "product_ids") String productIds) { 78 @RequestParam(value = "product_ids") String productIds) {
76 79
@@ -83,7 +86,7 @@ public class ProductController { @@ -83,7 +86,7 @@ public class ProductController {
83 86
84 @ApiOperation(name = "ufo.product.storage.leastprice", desc="sku的最低价") 87 @ApiOperation(name = "ufo.product.storage.leastprice", desc="sku的最低价")
85 @RequestMapping(params = "method=ufo.product.storage.leastprice") 88 @RequestMapping(params = "method=ufo.product.storage.leastprice")
86 - //@Cachable(expire=600) 89 + @Cachable(expire = 300)
87 public StorageLeastPriceResp queryStorageLeastprice( 90 public StorageLeastPriceResp queryStorageLeastprice(
88 @RequestParam(value = "storage_id", required = true) Integer storageId) { 91 @RequestParam(value = "storage_id", required = true) Integer storageId) {
89 92
@@ -96,7 +99,7 @@ public class ProductController { @@ -96,7 +99,7 @@ public class ProductController {
96 99
97 @ApiOperation(name = "ufo.product.storage.data", desc="sku信息") 100 @ApiOperation(name = "ufo.product.storage.data", desc="sku信息")
98 @RequestMapping(params = "method=ufo.product.storage.data") 101 @RequestMapping(params = "method=ufo.product.storage.data")
99 - //@Cachable(expire=600) 102 + @Cachable(expire = 300)
100 public StorageDataResp queryStorageInfo( 103 public StorageDataResp queryStorageInfo(
101 @RequestParam(value = "storage_id", required = true) Integer storageId) { 104 @RequestParam(value = "storage_id", required = true) Integer storageId) {
102 105
@@ -109,8 +112,10 @@ public class ProductController { @@ -109,8 +112,10 @@ public class ProductController {
109 // 增加库存 112 // 增加库存
110 @RequestMapping(params = "method=ufo.product.createSkup") 113 @RequestMapping(params = "method=ufo.product.createSkup")
111 public ApiResponse createSkup(@RequestBody StoragePriceBo skupBo) { 114 public ApiResponse createSkup(@RequestBody StoragePriceBo skupBo) {
  115 + LOG.info("in method=ufo.product.createSkup skupBo = {}", skupBo);
112 try { 116 try {
113 productService.createSkup(skupBo); 117 productService.createSkup(skupBo);
  118 + LOG.info("createSkup success and async clearProductCache skup = {}", skupBo.getSkup());
114 clearProductCache(skupBo.getSkup()); 119 clearProductCache(skupBo.getSkup());
115 return new ApiResponse(200, "创建成功!", Boolean.TRUE); 120 return new ApiResponse(200, "创建成功!", Boolean.TRUE);
116 } catch (Exception e) { 121 } catch (Exception e) {
@@ -123,10 +128,12 @@ public class ProductController { @@ -123,10 +128,12 @@ public class ProductController {
123 // 售卖 128 // 售卖
124 @RequestMapping(params = "method=ufo.product.saleSkup") 129 @RequestMapping(params = "method=ufo.product.saleSkup")
125 public ApiResponse saleSkup( 130 public ApiResponse saleSkup(
126 - @RequestParam(value = "product_id", required = false) Integer productId,  
127 - @RequestParam(value = "skup", required = false) Integer skup) { 131 + @RequestParam(value = "product_id", required = true) Integer productId,
  132 + @RequestParam(value = "skup", required = true) Integer skup) {
  133 + LOG.info("in method=ufo.product.createSkup productId = {}, skup={}", productId, skup);
128 try { 134 try {
129 productService.saleSkup(productId, skup); 135 productService.saleSkup(productId, skup);
  136 + LOG.info("saleSkup success and async clearProductCache skup = {}", skup);
130 clearProductCache(skup); 137 clearProductCache(skup);
131 return new ApiResponse(200, "卖出成功!", Boolean.TRUE); 138 return new ApiResponse(200, "卖出成功!", Boolean.TRUE);
132 } catch (Exception e) { 139 } catch (Exception e) {
@@ -146,9 +153,11 @@ public class ProductController { @@ -146,9 +153,11 @@ public class ProductController {
146 // 取消售卖 153 // 取消售卖
147 @RequestMapping(params = "method=ufo.product.cancelSaleSkup") 154 @RequestMapping(params = "method=ufo.product.cancelSaleSkup")
148 public ApiResponse cancelSaleSkup( 155 public ApiResponse cancelSaleSkup(
149 - @RequestParam(value = "skup", required = false) Integer skup) { 156 + @RequestParam(value = "skup", required = true) Integer skup) {
  157 + LOG.info("in method=ufo.product.cancelSaleSkup skup={}", skup);
150 try { 158 try {
151 productService.cancelSaleSkup(skup); 159 productService.cancelSaleSkup(skup);
  160 + LOG.info("saleSkup success and async clearProductCache skup = {}", skup);
152 clearProductCache(skup); 161 clearProductCache(skup);
153 return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE); 162 return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE);
154 } catch (Exception e) { 163 } catch (Exception e) {
@@ -165,15 +174,18 @@ public class ProductController { @@ -165,15 +174,18 @@ public class ProductController {
165 private void clearProductCache(Integer skup) { 174 private void clearProductCache(Integer skup) {
166 executors.execute(() -> { 175 executors.execute(() -> {
167 try { 176 try {
  177 + LOG.info("in clearProductCache skup = {}", skup);
168 StoragePrice sp = productService.getStoragePriceBySkup(skup); 178 StoragePrice sp = productService.getStoragePriceBySkup(skup);
169 if (sp != null) { 179 if (sp != null) {
170 // 商品详情:数量 180 // 商品详情:数量
171 Integer productId = sp.getProductId(); 181 Integer productId = sp.getProductId();
  182 + LOG.info("clearCache queryProductDetailById skup = {}, ", skup);
172 cacheAop.clearCache( 183 cacheAop.clearCache(
173 ProductController.class.getMethod("queryProductDetailById", new Class[] { Integer.class }), 184 ProductController.class.getMethod("queryProductDetailById", new Class[] { Integer.class }),
174 new Object[] { productId }); 185 new Object[] { productId });
175 Integer storageId = sp.getStorageId(); 186 Integer storageId = sp.getStorageId();
176 // sku最低价 187 // sku最低价
  188 + LOG.info("clearCache queryStorageLeastprice skup = {}, ", skup);
177 cacheAop.clearCache( 189 cacheAop.clearCache(
178 ProductController.class.getMethod("queryStorageLeastprice", new Class[] { Integer.class }), 190 ProductController.class.getMethod("queryStorageLeastprice", new Class[] { Integer.class }),
179 new Object[] { storageId }); 191 new Object[] { storageId });
@@ -35,7 +35,7 @@ public class ProductSearchController { @@ -35,7 +35,7 @@ public class ProductSearchController {
35 @ApiOperation(name = "ufo.product.search.list", desc="首页商品推荐") 35 @ApiOperation(name = "ufo.product.search.list", desc="首页商品推荐")
36 @RequestMapping(params = "method=ufo.product.search.list") 36 @RequestMapping(params = "method=ufo.product.search.list")
37 @IgnoreSession 37 @IgnoreSession
38 - //@Cachable 38 + @Cachable(expire = 300)
39 public ApiResponse searchProductList( 39 public ApiResponse searchProductList(
40 @RequestParam(value = "type", required = false)Integer type, 40 @RequestParam(value = "type", required = false)Integer type,
41 @RequestParam(value = "order", required = false)String order, 41 @RequestParam(value = "order", required = false)String order,
@@ -62,7 +62,7 @@ public class ProductSearchController { @@ -62,7 +62,7 @@ public class ProductSearchController {
62 @ApiOperation(name = "ufo.product.data.search.recommend", desc="商品详情页的相似商品推荐") 62 @ApiOperation(name = "ufo.product.data.search.recommend", desc="商品详情页的相似商品推荐")
63 @RequestMapping(params = "method=ufo.product.data.search.recommend") 63 @RequestMapping(params = "method=ufo.product.data.search.recommend")
64 @IgnoreSession 64 @IgnoreSession
65 - //@Cachable 65 + @Cachable(expire = 300)
66 public ApiResponse searchProductRecommendById( 66 public ApiResponse searchProductRecommendById(
67 @RequestParam(value = "product_id", required = false) Integer productId) { 67 @RequestParam(value = "product_id", required = false) Integer productId) {
68 68
@@ -80,7 +80,7 @@ public class ProductSearchController { @@ -80,7 +80,7 @@ public class ProductSearchController {
80 @ApiOperation(name = "ufo.product.search.list.filter", desc="列表页筛选项") 80 @ApiOperation(name = "ufo.product.search.list.filter", desc="列表页筛选项")
81 @RequestMapping(params = "method=ufo.product.search.list.filter") 81 @RequestMapping(params = "method=ufo.product.search.list.filter")
82 @IgnoreSession 82 @IgnoreSession
83 - //@Cachable 83 + @Cachable(expire = 300)
84 public ApiResponse searchProductListFilter( 84 public ApiResponse searchProductListFilter(
85 @RequestParam(value = "productPool", required = false) String productPool, 85 @RequestParam(value = "productPool", required = false) String productPool,
86 @RequestParam(value = "sort", required = false)String sort, 86 @RequestParam(value = "sort", required = false)String sort,
@@ -113,7 +113,7 @@ public class ProductSearchController { @@ -113,7 +113,7 @@ public class ProductSearchController {
113 @ApiOperation(name = "ufo.product.search.brandList", desc="品牌列表") 113 @ApiOperation(name = "ufo.product.search.brandList", desc="品牌列表")
114 @RequestMapping(params = "method=ufo.product.search.brandList") 114 @RequestMapping(params = "method=ufo.product.search.brandList")
115 @IgnoreSession 115 @IgnoreSession
116 - //@Cachable 116 + @Cachable(expire = 300)
117 public ApiResponse searchBrandList() { 117 public ApiResponse searchBrandList() {
118 118
119 return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.list.filter").data(mocksearchBrandList()).build(); 119 return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.list.filter").data(mocksearchBrandList()).build();
@@ -103,4 +103,12 @@ public class StoragePriceBo { @@ -103,4 +103,12 @@ public class StoragePriceBo {
103 public void setSkup(Integer skup) { 103 public void setSkup(Integer skup) {
104 this.skup = skup; 104 this.skup = skup;
105 } 105 }
  106 +
  107 + @Override
  108 + public String toString() {
  109 + return "StoragePriceBo [skup=" + skup + ", productId=" + productId + ", goodsId=" + goodsId + ", storageId="
  110 + + storageId + ", depotNum=" + depotNum + ", sellerUid=" + sellerUid + ", price=" + price + ", status="
  111 + + status + ", updateTime=" + updateTime + ", createTime=" + createTime + "]";
  112 + }
  113 +
106 } 114 }
@@ -218,6 +218,7 @@ public class ProductServiceImpl implements ProductService{ @@ -218,6 +218,7 @@ public class ProductServiceImpl implements ProductService{
218 } 218 }
219 219
220 private StoragePrice checkSkupCanCancel(Integer skup) { 220 private StoragePrice checkSkupCanCancel(Integer skup) {
  221 + LOGGER.info("checkSkupCanCancel skup = {}", skup);
221 StoragePrice sp = storagePriceMapper.selectBySkup(skup); 222 StoragePrice sp = storagePriceMapper.selectBySkup(skup);
222 if (sp == null) { 223 if (sp == null) {
223 throw new ServiceException(400, "商品(skup)不存在:" + skup); 224 throw new ServiceException(400, "商品(skup)不存在:" + skup);
@@ -237,6 +238,7 @@ public class ProductServiceImpl implements ProductService{ @@ -237,6 +238,7 @@ public class ProductServiceImpl implements ProductService{
237 } 238 }
238 239
239 private void addStorageNum(Integer skup, Integer storageId, Integer num) { 240 private void addStorageNum(Integer skup, Integer storageId, Integer num) {
  241 + LOGGER.info("修改库存:skup={}, storageId={}, num={}", skup, storageId, num);
240 if (storageId == null) { 242 if (storageId == null) {
241 StoragePrice sp = storagePriceMapper.selectBySkup(skup); 243 StoragePrice sp = storagePriceMapper.selectBySkup(skup);
242 storageId = sp.getStorageId(); 244 storageId = sp.getStorageId();
@@ -249,6 +251,7 @@ public class ProductServiceImpl implements ProductService{ @@ -249,6 +251,7 @@ public class ProductServiceImpl implements ProductService{
249 } 251 }
250 252
251 private StoragePrice checkSkupCanSale(Integer skup) { 253 private StoragePrice checkSkupCanSale(Integer skup) {
  254 + LOGGER.info("checkSkupCanSale skup = {}", skup);
252 StoragePrice sp = storagePriceMapper.selectBySkup(skup); 255 StoragePrice sp = storagePriceMapper.selectBySkup(skup);
253 if (sp == null) { 256 if (sp == null) {
254 throw new ServiceException(400, "商品(skup)不存在:" + skup); 257 throw new ServiceException(400, "商品(skup)不存在:" + skup);
@@ -260,6 +263,7 @@ public class ProductServiceImpl implements ProductService{ @@ -260,6 +263,7 @@ public class ProductServiceImpl implements ProductService{
260 } 263 }
261 264
262 private void checkProductCanSale(Integer productId) { 265 private void checkProductCanSale(Integer productId) {
  266 + LOGGER.info("checkProductCanSale productId = {}", productId);
263 Product p = productMapper.selectByPrimaryKey(productId); 267 Product p = productMapper.selectByPrimaryKey(productId);
264 if (p == null) { 268 if (p == null) {
265 throw new ServiceException(400, "商品不存在:" + productId); 269 throw new ServiceException(400, "商品不存在:" + productId);
@@ -333,6 +337,8 @@ public class ProductServiceImpl implements ProductService{ @@ -333,6 +337,8 @@ public class ProductServiceImpl implements ProductService{
333 sp.setCreateTime((int) (System.currentTimeMillis() / 1000)); 337 sp.setCreateTime((int) (System.currentTimeMillis() / 1000));
334 sp.setUpdateTime(0); 338 sp.setUpdateTime(0);
335 sp.setStatus(1); 339 sp.setStatus(1);
  340 +
  341 + LOGGER.info("StoragePrice 解析结果为: {}", sp);
336 return sp; 342 return sp;
337 } 343 }
338 344