diff --git a/src/main/java/com/yn/bftl/thirdparty/common/repository/InventoryManagementRepository.java b/src/main/java/com/yn/bftl/thirdparty/common/repository/InventoryManagementRepository.java new file mode 100644 index 0000000..113605c --- /dev/null +++ b/src/main/java/com/yn/bftl/thirdparty/common/repository/InventoryManagementRepository.java @@ -0,0 +1,30 @@ +package com.yn.bftl.thirdparty.common.repository; + +import com.yn.bftl.common.modules.inventory.entity.InventoryManagement; +import com.yn.bftl.common.modules.inventory.entity.Warehouse; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; + + +/** + * InventoryManagementRepository + * + * @author wangwenliang + * @create 2021年4月25日15:39:25 + **/ +@Repository +public interface InventoryManagementRepository extends JpaRepository, JpaSpecificationExecutor { + + @Modifying + @Transactional + @Query("update InventoryManagement i set i.availableInventory = i.availableInventory - 1 where i.availableInventory > 0 and i.defaultWarehouse = :warehouse") + int subStock(@Param("warehouse") Warehouse warehouse); + +}