剩余数量

商品上下架
This commit is contained in:
wangw 2024-11-12 15:45:31 +08:00
parent 679ff0acaf
commit b3b27a0aa7
4 changed files with 14 additions and 0 deletions

View File

@ -120,6 +120,7 @@ public class TbShopCouponServiceImpl extends ServiceImpl<TbShopCouponMapper, TbS
@Override
public boolean update(TbShopCouponVo param) {
if (param.getId() == null) {
param.setLeftNumber(param.getNumber());
tbShopCouponmapper.insert(param);
} else {
tbShopCouponmapper.updateById(param);

View File

@ -53,6 +53,10 @@ public interface TbProductRepository extends JpaRepository<TbProduct, Integer>,
@Query(value = "select b.* from tb_product_sku as a left join tb_product as b on a.product_id=b.id where a.id=:skuId", nativeQuery = true)
TbProduct selectBySkuId(@Param("skuId") Integer skuId);
@Modifying
@Query("update TbProduct set isGrounding=0 where id=:id")
void upGrounding(@Param("id") Integer id);
@Modifying
@Query("update TbProduct set lowPrice=:lowPrice where id=:id")
void upLowPrice(@Param("id") Integer id, @Param("lowPrice") BigDecimal lowPrice);

View File

@ -32,6 +32,9 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
@Query(value = "SELECT min(sale_price) from tb_product_sku where product_id = ?1 and id != ?2", nativeQuery = true)
BigDecimal searchMinSalePrice(@Param("productId") Integer productId, @Param("skuId") Integer skuId);
@Query(value = "SELECT count() from tb_product_sku where product_id = ?1 and is_grounding = 1 and id != ?2", nativeQuery = true)
int countGrounding(@Param("productId") Integer productId, @Param("skuId") Integer skuId);
@Modifying
@Query("update FROM TbProductSku sku set sku.costPrice=:cost WHERE sku.productId=:productId")

View File

@ -194,6 +194,12 @@ public class StockServiceImpl implements StockService {
sqlQuery.append(" set is_grounding = ").append(updateValueVO.getValue());
wxMsgUtils.aboardOperationMsg(("1".equals(updateValueVO.getValue()) ? "上架: " : "下架: ") + description, Integer.valueOf(product.getShopId()));
description.append("0".equals(updateValueVO.getValue()) ? "已下架" : "已上架");
if("0".equals(updateValueVO.getValue())){
int i = tbProductSkuRepository.countGrounding(product.getId(), tbProductSku.getId());
if (i == 0) {
tbProductRepository.upGrounding(product.getId());
}
}
break;
case "salePrice"://价格
description.append("修改价格为").append(updateValueVO.getValue());