yshop1.8.1修复库存显示问题、修复评价等问题,明细可登陆后台查看
This commit is contained in:
@ -3,6 +3,7 @@ package co.yixiang.modules.shop.repository;
|
||||
import co.yixiang.modules.shop.domain.YxStoreProductAttr;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
@ -12,4 +13,7 @@ public interface YxStoreProductAttrRepository extends JpaRepository<YxStoreProdu
|
||||
//@Modifying
|
||||
//@Query(value = "delete from yx_store_product_attr where product_id =?1",nativeQuery = true)
|
||||
void deleteByProductId(int id);
|
||||
|
||||
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package co.yixiang.modules.shop.repository;
|
||||
import co.yixiang.modules.shop.domain.YxStoreProductAttrValue;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
@ -13,4 +14,8 @@ public interface YxStoreProductAttrValueRepository extends JpaRepository<YxStore
|
||||
//@Modifying
|
||||
// @Query(value = "delete from yx_store_product_attr_value where product_id =?1",nativeQuery = true)
|
||||
void deleteByProductId(Integer id);
|
||||
|
||||
@Query(value = "select sum(stock) from yx_store_product_attr_value " +
|
||||
"where product_id = ?1",nativeQuery = true)
|
||||
Integer sumStock(Integer productId);
|
||||
}
|
@ -68,6 +68,10 @@ public class YxStoreProductServiceImpl implements YxStoreProductService {
|
||||
.findNameById(Integer.valueOf(product.getCateId()));
|
||||
YxStoreProductDTO yxStoreProductDTO = yxStoreProductMapper.toDto(product);
|
||||
yxStoreProductDTO.setCateName(cateName);
|
||||
//规格属性库存
|
||||
Integer newStock = yxStoreProductAttrValueRepository.sumStock(product.getId());
|
||||
if(newStock != null) yxStoreProductDTO.setStock(newStock);
|
||||
|
||||
storeProductDTOS.add(yxStoreProductDTO);
|
||||
}
|
||||
Map<String,Object> map = new LinkedHashMap<>(2);
|
||||
|
Reference in New Issue
Block a user