bug fix --商品是否可售控制
This commit is contained in:
parent
855d7e7ea4
commit
9615aa33b3
|
|
@ -2,7 +2,6 @@ package com.czg.controller.admin;
|
|||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.czg.account.service.ShopConfigService;
|
||||
import com.czg.annotation.SaStaffCheckPermission;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.exception.CzgException;
|
||||
|
|
@ -15,6 +14,7 @@ import com.czg.product.param.*;
|
|||
import com.czg.product.service.ProdConsRelationService;
|
||||
import com.czg.product.service.ProductService;
|
||||
import com.czg.product.service.ShopSyncService;
|
||||
import com.czg.product.service.UProductService;
|
||||
import com.czg.product.vo.ProductStatisticsVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
|
|
@ -48,7 +48,7 @@ public class ProductController {
|
|||
@Resource
|
||||
private ShopSyncService shopSyncService;
|
||||
@Resource
|
||||
private ShopConfigService shopConfigService;
|
||||
private UProductService uProductService;
|
||||
|
||||
/**
|
||||
* 商品-分页
|
||||
|
|
@ -72,6 +72,9 @@ public class ProductController {
|
|||
param.setShopId(shopId);
|
||||
List<ProductDTO> productList = productService.getProductCacheList(param);
|
||||
productService.refreshProductStock(param, productList);
|
||||
productList.forEach(prod -> {
|
||||
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
|
||||
});
|
||||
return CzgResult.success(productList);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class UProductController {
|
|||
uProductService.refreshProductStock(productStock, item.getProductList());
|
||||
item.getProductList().forEach(prod -> {
|
||||
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
|
||||
prod.setIsSaleTime(uProductService.calcIsSaleTime(item.getUseTime(), item.getSaleStartTime(), item.getSaleEndTime()));
|
||||
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getIsSaleTime(), item.getUseTime(), item.getSaleStartTime(), item.getSaleEndTime()));
|
||||
});
|
||||
});
|
||||
return CzgResult.success(list);
|
||||
|
|
|
|||
|
|
@ -78,12 +78,13 @@ public interface UProductService extends IService<Product> {
|
|||
/**
|
||||
* 分组计算是否在可售时间内
|
||||
*
|
||||
* @param prodIsSaleTime 商品是否可售
|
||||
* @param useTime 开启时间管控 0:否;1:是
|
||||
* @param startTime 起售时间
|
||||
* @param endTime 停售时间
|
||||
* @return 是否可售时间 1-是,0-否
|
||||
*/
|
||||
Integer calcIsSaleTime(Integer useTime, LocalTime startTime, LocalTime endTime);
|
||||
Integer calcIsSaleTime(int prodIsSaleTime, Integer useTime, LocalTime startTime, LocalTime endTime);
|
||||
|
||||
/**
|
||||
* 商品计算是否在可售时间内
|
||||
|
|
|
|||
|
|
@ -407,12 +407,9 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|||
}
|
||||
super.updateById(entity);
|
||||
// 清除商品分类列表缓存
|
||||
Long categoryId = ObjUtil.defaultIfNull(dto.getCategoryId(), old.getCategoryId());
|
||||
if (!old.getCategoryId().equals(categoryId)) {
|
||||
// 清除旧分类缓存&新分类缓存
|
||||
clearProductCache(old.getCategoryId(), entity.getCategoryId());
|
||||
} else {
|
||||
clearProductCache(old.getCategoryId());
|
||||
clearProductCache(old.getCategoryId());
|
||||
if (!old.getCategoryId().equals(dto.getCategoryId())) {
|
||||
clearProductCache(entity.getCategoryId());
|
||||
}
|
||||
if (ObjUtil.defaultIfNull(dto.getIsStock(), old.getIsStock()) == YesNoEnum.NO.value()) {
|
||||
redisService.del(StrUtil.format(CacheConstant.SHOP_PRODUCT_STOCK, shopId, dto.getId()));
|
||||
|
|
|
|||
|
|
@ -233,9 +233,9 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
|
|||
* @return 是否可售时间 1-是,0-否
|
||||
*/
|
||||
@Override
|
||||
public Integer calcIsSaleTime(Integer useTime, LocalTime startTime, LocalTime endTime) {
|
||||
public Integer calcIsSaleTime(int prodIsSaleTime, Integer useTime, LocalTime startTime, LocalTime endTime) {
|
||||
if (NumberUtil.nullToZero(useTime) == 0) {
|
||||
return YesNoEnum.YES.value();
|
||||
return prodIsSaleTime;
|
||||
}
|
||||
if (ObjUtil.isNull(startTime) || ObjUtil.isNull(endTime)) {
|
||||
return YesNoEnum.NO.value();
|
||||
|
|
|
|||
Loading…
Reference in New Issue