Browse Source

供应商价格 按产品定义条件查询

24282 2 năm trước cách đây
mục cha
commit
eaa959c11f

+ 18 - 3
hx-supply/src/main/java/com/fjhx/supply/service/supplier/impl/SupplierPriceServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.common.constant.SourceConstant;
+import com.fjhx.item.entity.product.po.ProductInfo;
 import com.fjhx.item.service.product.ProductClassifyService;
 import com.fjhx.item.service.product.ProductInfoService;
 import com.fjhx.supply.entity.supplier.dto.SupplierPriceDto;
@@ -15,6 +16,7 @@ import com.fjhx.supply.entity.supplier.vo.SupplierPriceAddVo;
 import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
 import com.fjhx.supply.mapper.supplier.SupplierPriceMapper;
 import com.fjhx.supply.service.supplier.SupplierPriceService;
+import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.common.utils.wrapper.SqlField;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,12 +48,25 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
 
     @Override
     public Page<SupplierPriceVo> getPage(SupplierPriceSelectDto dto) {
+
         IWrapper<SupplierPrice> wrapper = getWrapper();
+
+        if (dto.getDefinition() != null) {
+
+            List<Long> productIdList = productInfoService.listObject(BaseIdPo::getId,
+                    q -> q.eq(ProductInfo::getDefinition, dto.getDefinition()));
+
+            if (productIdList.size() == 0) {
+                return new Page<>();
+            }
+
+            wrapper.in("sp", SupplierPrice::getProductInfoId, productIdList);
+        }
+
         wrapper.orderByDesc("sp", SupplierPrice::getId);
         wrapper.eq("si", SupplierInfo::getType, dto.getSupplierType());
-        wrapper.keyword(dto,
-                new SqlField("si.name")
-        );
+        wrapper.keyword(dto, new SqlField("si.name"));
+
         Page<SupplierPriceVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<SupplierPriceVo> records = page.getRecords();