瀏覽代碼

维多利亚

24282 2 年之前
父節點
當前提交
262131fa66

+ 22 - 0
hx-service-api/victoriatourist-api/src/main/java/com/fjhx/entity/supplier/GetSupplierPriceByProductIdsDto.java

@@ -0,0 +1,22 @@
+package com.fjhx.entity.supplier;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+@Getter
+@Setter
+public class GetSupplierPriceByProductIdsDto {
+
+    /**
+     * 供应商id
+     */
+    private Long supplierId;
+
+    /**
+     * 产品id
+     */
+    private List<Long> productIdList;
+
+}

+ 12 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/controller/supplier/SupplierPriceController.java

@@ -1,6 +1,7 @@
 package com.fjhx.controller.supplier;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.entity.supplier.GetSupplierPriceByProductIdsDto;
 import com.fjhx.params.supplier.SupplierPriceVo;
 import com.fjhx.service.supplier.SupplierPriceService;
 import org.springblade.core.tool.api.R;
@@ -10,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 import java.util.Map;
 
 /**
@@ -55,5 +57,15 @@ public class SupplierPriceController {
     public R list(@RequestBody Map<String, Object> condition) {
         return R.success(supplierPriceService.getList(condition));
     }
+
+    /**
+     * 查看产品价格
+     */
+    @PostMapping("/getSupplierPriceByProductIds")
+    public R getSupplierPriceByProductIds(@RequestBody GetSupplierPriceByProductIdsDto dto) {
+        Map<Long, BigDecimal> result = supplierPriceService.getSupplierPriceByProductIds(dto);
+        return R.success(result);
+    }
+
 }
 

+ 5 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/supplier/SupplierPriceService.java

@@ -2,9 +2,11 @@ package com.fjhx.service.supplier;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.base.BaseService;
+import com.fjhx.entity.supplier.GetSupplierPriceByProductIdsDto;
 import com.fjhx.entity.supplier.SupplierPrice;
 import com.fjhx.params.supplier.SupplierPriceVo;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -27,4 +29,7 @@ public interface SupplierPriceService extends BaseService<SupplierPrice> {
     void delete(SupplierPriceVo supplierPriceVo);
 
     List<SupplierPrice> getList(Map<String, Object> condition);
+
+    Map<Long, BigDecimal> getSupplierPriceByProductIds(GetSupplierPriceByProductIdsDto dto);
+
 }

+ 14 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/supplier/impl/SupplierPriceServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.entity.product.ProductInfo;
+import com.fjhx.entity.supplier.GetSupplierPriceByProductIdsDto;
 import com.fjhx.entity.supplier.Supplier;
 import com.fjhx.entity.supplier.SupplierPrice;
 import com.fjhx.mapper.supplier.SupplierPriceMapper;
@@ -85,4 +86,17 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
                         JSONObject.parseArray(JSONObject.toJSONString(condition.get("goodsIds")), Long.class))
                 .list();
     }
+
+    @Override
+    public Map<Long, BigDecimal> getSupplierPriceByProductIds(GetSupplierPriceByProductIdsDto dto) {
+        Long supplierId = dto.getSupplierId();
+        Assert.notEmpty(supplierId, "供应商id不能为空");
+
+        List<Long> productIdList = dto.getProductIdList();
+        Assert.notEmpty(productIdList, "产品id数组不能为空");
+
+        return getKV(SupplierPrice::getMaterialId, SupplierPrice::getPrice,
+                q -> q.eq(SupplierPrice::getSupplierId, supplierId).in(SupplierPrice::getMaterialId, productIdList));
+    }
+
 }