|
@@ -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 });
|