Browse Source

供应商接口id判空

mainqaq 2 years ago
parent
commit
9e52d14847
1 changed files with 23 additions and 4 deletions
  1. 23 4
      service/supply_service.go

+ 23 - 4
service/supply_service.go View File

@@ -52,7 +52,17 @@ func UpdateSupplyAndContact(thisStockIn []interface{}, suid, orgId, supplierType
52 52
 		name := items["name"].(string)
53 53
 		phone := items["phone"].(string)
54 54
 		address := items["address"].(string)
55
-		isfirst := int64(items["is_first"].(float64))
55
+		var tmpfirst int64
56
+		//tmptype :=  reflect.TypeOf(items["is_first"])
57
+		switch items["is_first"].(type) {
58
+		case int:
59
+			var aint int = items["is_first"].(int)
60
+			tmpfirst = int64(aint)
61
+		case float64:
62
+			tmpfirst = int64(items["is_first"].(float64))
63
+		}
64
+		isfirst := tmpfirst
65
+
56 66
 		updatecontacts := models.SpSupplierContacts{
57 67
 			ID:           id,
58 68
 			Name:         name,
@@ -89,7 +99,6 @@ func UpdateSupplyAndContact(thisStockIn []interface{}, suid, orgId, supplierType
89 99
 			if id == 0 {
90 100
 				var spconid []*models.SpSupplierContacts
91 101
 				spconid, err = SaveContactsId(tx)
92
-
93 102
 				if err != nil {
94 103
 					return err
95 104
 				}
@@ -176,7 +185,17 @@ func SaveSupplyAndContact(thisStockIn []interface{}, orgId, supplierType, tcreat
176 185
 		name := items["name"].(string)
177 186
 		phone := items["phone"].(string)
178 187
 		address := items["address"].(string)
179
-		isfirst := int64(items["is_first"].(float64))
188
+		//isfirst := int64(items["is_first"].(float64))
189
+		var tmpfirst int64
190
+		//tmptype :=  reflect.TypeOf(items["is_first"])
191
+		switch items["is_first"].(type) {
192
+		case int:
193
+			var aint int = items["is_first"].(int)
194
+			tmpfirst = int64(aint)
195
+		case float64:
196
+			tmpfirst = int64(items["is_first"].(float64))
197
+		}
198
+		isfirst := tmpfirst
180 199
 
181 200
 		spcontacts := models.SpSupplierContacts{
182 201
 			Name:         name,
@@ -265,7 +284,7 @@ func SaveSupply(supply models.SpSupplierName, tx *gorm.DB) error {
265 284
 
266 285
 //获取联系人的id
267 286
 func SaveContactsId(tx *gorm.DB) (spconid []*models.SpSupplierContacts, err error) {
268
-	err = tx.Model(&models.SpSupplierContacts{}).Select("id").Where("and status = 1").Order("id desc").First(&spconid).Error
287
+	err = tx.Model(&models.SpSupplierContacts{}).Select("id").Where("status = 1").Order("id desc").First(&spconid).Error
269 288
 	return
270 289
 }
271 290