From 1ae2ab7b60ef374c77eebc08d63759a98f625066 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期五, 15 三月 2024 10:10:43 +0800
Subject: [PATCH] crm查询采购信息

---
 service/test/product.go |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/service/test/product.go b/service/test/product.go
index b140e29..57ad6d9 100644
--- a/service/test/product.go
+++ b/service/test/product.go
@@ -26,6 +26,8 @@
 			DeliveryTime:     p.DeliveryTime,
 			ShippingDuration: p.ShippingDuration,
 			Specifications:   p.Specifications,
+			CategoryName:     p.CategoryName,
+			ModelNumber:      p.ModelNumber,
 		})
 	}
 
@@ -71,7 +73,7 @@
 	var ps []test.SupplierMaterial
 	//鎼滅储妗嗗悎涓�娣诲姞鏌ヨ鏉′欢
 	if info.Keyword != "" {
-		db = db.Where("srm_supplier_material.name LIKE ?", "%"+info.Keyword+"%").Joins("srm_supplier").Or("srm_supplier.name LIKE ?", "%"+info.Keyword+"%")
+		db = db.Where("`srm_supplier_material`.name LIKE ?", "%"+info.Keyword+"%").Joins("Supplier").Or("Supplier.name LIKE ?", "%"+info.Keyword+"%")
 	}
 	if info.Name != "" {
 		db = db.Where("name LIKE ?", "%"+info.Name+"%")
@@ -89,7 +91,7 @@
 		return
 	}
 
-	err = db.Limit(limit).Offset(offset).Preload("Supplier").Find(&ps).Error
+	err = db.Limit(limit).Offset(offset).Order("id desc").Preload("Supplier").Find(&ps).Error
 	return ps, total, err
 }
 
@@ -105,3 +107,28 @@
 	}
 	return
 }
+
+// GetMaterials 鑾峰彇鐗╂枡
+func (pService *ProductService) GetMaterials(info testReq.ProductSearch) (list []test.Material, total int64, err error) {
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	// 鍒涘缓db
+	db := global.GVA_DB.Model(&test.Material{})
+	var ps []test.Material
+	if info.Keyword != "" {
+		db = db.Where("name LIKE ? or id LIKE ?", "%"+info.Keyword+"%", "%"+info.Keyword+"%")
+	}
+
+	//绫诲瀷涓洪噰璐�
+	db = db.Where("purchase_types LIKE ?", "%1%")
+
+	db = db.Where("is_storage = ?", 1)
+
+	err = db.Count(&total).Error
+	if err != nil {
+		return
+	}
+
+	err = db.Limit(limit).Offset(offset).Find(&ps).Error
+	return ps, total, err
+}

--
Gitblit v1.8.0