Authored by Lixiaodi

增加日志

... ... @@ -114,4 +114,11 @@ public class StoragePrice {
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
@Override
public String toString() {
return "StoragePrice [id=" + id + ", skup=" + skup + ", productId=" + productId + ", goodsId=" + goodsId
+ ", storageId=" + storageId + ", depotNum=" + depotNum + ", sellerUid=" + sellerUid + ", price="
+ price + ", status=" + status + ", updateTime=" + updateTime + ", createTime=" + createTime + "]";
}
}
\ No newline at end of file
... ...
... ... @@ -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 });
... ...
... ... @@ -35,7 +35,7 @@ public class ProductSearchController {
@ApiOperation(name = "ufo.product.search.list", desc="首页商品推荐")
@RequestMapping(params = "method=ufo.product.search.list")
@IgnoreSession
//@Cachable
@Cachable(expire = 300)
public ApiResponse searchProductList(
@RequestParam(value = "type", required = false)Integer type,
@RequestParam(value = "order", required = false)String order,
... ... @@ -62,7 +62,7 @@ public class ProductSearchController {
@ApiOperation(name = "ufo.product.data.search.recommend", desc="商品详情页的相似商品推荐")
@RequestMapping(params = "method=ufo.product.data.search.recommend")
@IgnoreSession
//@Cachable
@Cachable(expire = 300)
public ApiResponse searchProductRecommendById(
@RequestParam(value = "product_id", required = false) Integer productId) {
... ... @@ -80,7 +80,7 @@ public class ProductSearchController {
@ApiOperation(name = "ufo.product.search.list.filter", desc="列表页筛选项")
@RequestMapping(params = "method=ufo.product.search.list.filter")
@IgnoreSession
//@Cachable
@Cachable(expire = 300)
public ApiResponse searchProductListFilter(
@RequestParam(value = "productPool", required = false) String productPool,
@RequestParam(value = "sort", required = false)String sort,
... ... @@ -113,7 +113,7 @@ public class ProductSearchController {
@ApiOperation(name = "ufo.product.search.brandList", desc="品牌列表")
@RequestMapping(params = "method=ufo.product.search.brandList")
@IgnoreSession
//@Cachable
@Cachable(expire = 300)
public ApiResponse searchBrandList() {
return new ApiResponse.ApiResponseBuilder().code(200).message("product.search.list.filter").data(mocksearchBrandList()).build();
... ...
... ... @@ -103,4 +103,12 @@ public class StoragePriceBo {
public void setSkup(Integer skup) {
this.skup = skup;
}
@Override
public String toString() {
return "StoragePriceBo [skup=" + skup + ", productId=" + productId + ", goodsId=" + goodsId + ", storageId="
+ storageId + ", depotNum=" + depotNum + ", sellerUid=" + sellerUid + ", price=" + price + ", status="
+ status + ", updateTime=" + updateTime + ", createTime=" + createTime + "]";
}
}
\ No newline at end of file
... ...
... ... @@ -218,6 +218,7 @@ public class ProductServiceImpl implements ProductService{
}
private StoragePrice checkSkupCanCancel(Integer skup) {
LOGGER.info("checkSkupCanCancel skup = {}", skup);
StoragePrice sp = storagePriceMapper.selectBySkup(skup);
if (sp == null) {
throw new ServiceException(400, "商品(skup)不存在:" + skup);
... ... @@ -237,6 +238,7 @@ public class ProductServiceImpl implements ProductService{
}
private void addStorageNum(Integer skup, Integer storageId, Integer num) {
LOGGER.info("修改库存:skup={}, storageId={}, num={}", skup, storageId, num);
if (storageId == null) {
StoragePrice sp = storagePriceMapper.selectBySkup(skup);
storageId = sp.getStorageId();
... ... @@ -249,6 +251,7 @@ public class ProductServiceImpl implements ProductService{
}
private StoragePrice checkSkupCanSale(Integer skup) {
LOGGER.info("checkSkupCanSale skup = {}", skup);
StoragePrice sp = storagePriceMapper.selectBySkup(skup);
if (sp == null) {
throw new ServiceException(400, "商品(skup)不存在:" + skup);
... ... @@ -260,6 +263,7 @@ public class ProductServiceImpl implements ProductService{
}
private void checkProductCanSale(Integer productId) {
LOGGER.info("checkProductCanSale productId = {}", productId);
Product p = productMapper.selectByPrimaryKey(productId);
if (p == null) {
throw new ServiceException(400, "商品不存在:" + productId);
... ... @@ -333,6 +337,8 @@ public class ProductServiceImpl implements ProductService{
sp.setCreateTime((int) (System.currentTimeMillis() / 1000));
sp.setUpdateTime(0);
sp.setStatus(1);
LOGGER.info("StoragePrice 解析结果为: {}", sp);
return sp;
}
... ...