From 727d16a6d0336daa6c2f9541564d1500444e44a2 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期四, 16 十一月 2023 09:43:47 +0800
Subject: [PATCH] 采购单与wms通信

---
 api/v1/test/product.go |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/api/v1/test/product.go b/api/v1/test/product.go
index 0cab86a..dfb82c9 100644
--- a/api/v1/test/product.go
+++ b/api/v1/test/product.go
@@ -36,6 +36,19 @@
 		response.FailWithMessage(err.Error(), c)
 		return
 	}
+	for _, t := range p.List {
+		var num int64
+		db := global.GVA_DB.Model(&test.Product{})
+		err := db.Where("number = ?", t.Number).Where("supplier_id = ?", t.SupplierId).Count(&num).Error
+		if err != nil {
+			response.FailWithMessage(err.Error(), c)
+			return
+		}
+		if num > 0 {
+			response.FailWithMessage("褰撳墠渚涘簲鍟嗗凡缁忔彁渚涙浜у搧", c)
+			return
+		}
+	}
 	if err := pService.CreateProduct(p.List); err != nil {
 		global.GVA_LOG.Error("鍒涘缓澶辫触!", zap.Error(err))
 		response.FailWithMessage("鍒涘缓澶辫触", c)
@@ -160,6 +173,10 @@
 		global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err))
 		response.FailWithMessage("鑾峰彇澶辫触", c)
 	} else {
+		//娣诲姞渚涘簲鍟嗗悕绉�
+		for i := 0; i < len(list); i++ {
+			list[i].SupplierName = list[i].Supplier.Name
+		}
 		response.OkWithDetailed(response.PageResult{
 			List:     list,
 			Total:    total,

--
Gitblit v1.8.0