...
|
...
|
@@ -3,7 +3,6 @@ package com.yohoufo.product.controller; |
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
import com.yohoufo.product.response.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -12,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody; |
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.tools.docs.ApiOperation;
|
|
|
import com.yohoufo.common.ApiResponse;
|
...
|
...
|
@@ -19,10 +19,13 @@ import com.yohoufo.common.annotation.IgnoreSession; |
|
|
import com.yohoufo.common.annotation.IgnoreSignature;
|
|
|
import com.yohoufo.common.cache.Cachable;
|
|
|
import com.yohoufo.common.cache.ControllerCacheAop;
|
|
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
|
|
import com.yohoufo.common.utils.UfoJsonUtil;
|
|
|
import com.yohoufo.dal.product.model.StoragePrice;
|
|
|
import com.yohoufo.product.request.StoragePriceBo;
|
|
|
import com.yohoufo.product.response.ProductDetailResp;
|
|
|
import com.yohoufo.product.response.ProductSeriesTemplateResp;
|
|
|
import com.yohoufo.product.response.ProductSortTemplateResp;
|
|
|
import com.yohoufo.product.response.StorageDataResp;
|
|
|
import com.yohoufo.product.response.StorageLeastPriceResp;
|
|
|
import com.yohoufo.product.service.ProductService;
|
|
|
|
|
|
|
...
|
...
|
@@ -38,7 +41,7 @@ public class ProductController { |
|
|
@IgnoreSignature
|
|
|
@IgnoreSession
|
|
|
@RequestMapping(params = "method=ufo.product.data")
|
|
|
@Cachable(expire=600)
|
|
|
@Cachable(expire = 300)
|
|
|
public ApiResponse queryProductDetailById(
|
|
|
@RequestParam(value = "product_id") Integer productId) {
|
|
|
|
...
|
...
|
@@ -55,7 +58,7 @@ public class ProductController { |
|
|
@IgnoreSignature
|
|
|
@IgnoreSession
|
|
|
@RequestMapping(params = "method=ufo.product.series.template")
|
|
|
//@Cachable(expire=600)
|
|
|
@Cachable(expire = 300)
|
|
|
public ApiResponse querySeriesTemplateData(
|
|
|
@RequestParam(value = "product_ids") String productIds) {
|
|
|
|
...
|
...
|
@@ -70,7 +73,7 @@ public class ProductController { |
|
|
@IgnoreSignature
|
|
|
@IgnoreSession
|
|
|
@RequestMapping(params = "method=ufo.product.sort.template")
|
|
|
//@Cachable(expire=600)
|
|
|
@Cachable(expire = 300)
|
|
|
public ApiResponse querySortTemplateData(
|
|
|
@RequestParam(value = "product_ids") String productIds) {
|
|
|
|
...
|
...
|
@@ -83,7 +86,7 @@ public class ProductController { |
|
|
|
|
|
@ApiOperation(name = "ufo.product.storage.leastprice", desc="sku的最低价")
|
|
|
@RequestMapping(params = "method=ufo.product.storage.leastprice")
|
|
|
//@Cachable(expire=600)
|
|
|
@Cachable(expire = 300)
|
|
|
public StorageLeastPriceResp queryStorageLeastprice(
|
|
|
@RequestParam(value = "storage_id", required = true) Integer storageId) {
|
|
|
|
...
|
...
|
@@ -96,7 +99,7 @@ public class ProductController { |
|
|
|
|
|
@ApiOperation(name = "ufo.product.storage.data", desc="sku信息")
|
|
|
@RequestMapping(params = "method=ufo.product.storage.data")
|
|
|
//@Cachable(expire=600)
|
|
|
@Cachable(expire = 300)
|
|
|
public StorageDataResp queryStorageInfo(
|
|
|
@RequestParam(value = "storage_id", required = true) Integer storageId) {
|
|
|
|
...
|
...
|
@@ -109,8 +112,10 @@ public class ProductController { |
|
|
// 增加库存
|
|
|
@RequestMapping(params = "method=ufo.product.createSkup")
|
|
|
public ApiResponse createSkup(@RequestBody StoragePriceBo skupBo) {
|
|
|
LOG.info("in method=ufo.product.createSkup skupBo = {}", skupBo);
|
|
|
try {
|
|
|
productService.createSkup(skupBo);
|
|
|
LOG.info("createSkup success and async clearProductCache skup = {}", skupBo.getSkup());
|
|
|
clearProductCache(skupBo.getSkup());
|
|
|
return new ApiResponse(200, "创建成功!", Boolean.TRUE);
|
|
|
} catch (Exception e) {
|
...
|
...
|
@@ -123,10 +128,12 @@ public class ProductController { |
|
|
// 售卖
|
|
|
@RequestMapping(params = "method=ufo.product.saleSkup")
|
|
|
public ApiResponse saleSkup(
|
|
|
@RequestParam(value = "product_id", required = false) Integer productId,
|
|
|
@RequestParam(value = "skup", required = false) Integer skup) {
|
|
|
@RequestParam(value = "product_id", required = true) Integer productId,
|
|
|
@RequestParam(value = "skup", required = true) Integer skup) {
|
|
|
LOG.info("in method=ufo.product.createSkup productId = {}, skup={}", productId, skup);
|
|
|
try {
|
|
|
productService.saleSkup(productId, skup);
|
|
|
LOG.info("saleSkup success and async clearProductCache skup = {}", skup);
|
|
|
clearProductCache(skup);
|
|
|
return new ApiResponse(200, "卖出成功!", Boolean.TRUE);
|
|
|
} catch (Exception e) {
|
...
|
...
|
@@ -146,9 +153,11 @@ public class ProductController { |
|
|
// 取消售卖
|
|
|
@RequestMapping(params = "method=ufo.product.cancelSaleSkup")
|
|
|
public ApiResponse cancelSaleSkup(
|
|
|
@RequestParam(value = "skup", required = false) Integer skup) {
|
|
|
@RequestParam(value = "skup", required = true) Integer skup) {
|
|
|
LOG.info("in method=ufo.product.cancelSaleSkup skup={}", skup);
|
|
|
try {
|
|
|
productService.cancelSaleSkup(skup);
|
|
|
LOG.info("saleSkup success and async clearProductCache skup = {}", skup);
|
|
|
clearProductCache(skup);
|
|
|
return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE);
|
|
|
} catch (Exception e) {
|
...
|
...
|
@@ -165,15 +174,18 @@ public class ProductController { |
|
|
private void clearProductCache(Integer skup) {
|
|
|
executors.execute(() -> {
|
|
|
try {
|
|
|
LOG.info("in clearProductCache skup = {}", skup);
|
|
|
StoragePrice sp = productService.getStoragePriceBySkup(skup);
|
|
|
if (sp != null) {
|
|
|
// 商品详情:数量
|
|
|
Integer productId = sp.getProductId();
|
|
|
LOG.info("clearCache queryProductDetailById skup = {}, ", skup);
|
|
|
cacheAop.clearCache(
|
|
|
ProductController.class.getMethod("queryProductDetailById", new Class[] { Integer.class }),
|
|
|
new Object[] { productId });
|
|
|
Integer storageId = sp.getStorageId();
|
|
|
// sku最低价
|
|
|
LOG.info("clearCache queryStorageLeastprice skup = {}, ", skup);
|
|
|
cacheAop.clearCache(
|
|
|
ProductController.class.getMethod("queryStorageLeastprice", new Class[] { Integer.class }),
|
|
|
new Object[] { storageId });
|
...
|
...
|
|