Parcourir la source

供应商模块保存和更改接口改动

mainqaq il y a 3 ans
Parent
révision
e50d7a9007
2 fichiers modifiés avec 25 ajouts et 9 suppressions
  1. 22 9
      controllers/supply_order_api_contorller.go
  2. 3 0
      service/supply_service.go

+ 22 - 9
controllers/supply_order_api_contorller.go Voir le fichier

@@ -183,7 +183,6 @@ func (this *SupplyOrderApiController) GetSupplyList() {
183 183
 
184 184
 //保存供应商及联系人(用于更改)
185 185
 func (this *SupplyOrderApiController) UpdateSupply() {
186
-	fmt.Printf("HAHHAH")
187 186
 	dataBody := make(map[string]interface{}, 0)
188 187
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
189 188
 	if err != nil {
@@ -204,9 +203,9 @@ func (this *SupplyOrderApiController) UpdateSupply() {
204 203
 	}
205 204
 	//supplierid, _ := this.GetInt64("id") //供应商id
206 205
 	//fmt.Println(dataBody["id"])
207
-	utils.InfoLog("+++++++++++++前++++++++++++++++++", dataBody["id"])
206
+	//utils.InfoLog("+++++++++++++前++++++++++++++++++", dataBody["id"])
208 207
 	supplierid := int64(dataBody["id"].(float64))
209
-	utils.InfoLog("+++++++++++++后++++++++++++++++++", supplierid)
208
+	//utils.InfoLog("+++++++++++++后++++++++++++++++++", supplierid)
210 209
 	if supplierid == 0 {
211 210
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商id不能为空")
212 211
 		return
@@ -235,7 +234,14 @@ func (this *SupplyOrderApiController) UpdateSupply() {
235 234
 		}
236 235
 	}
237 236
 	//supplierType, _ := this.GetInt64("suppliertype") //供应商类别
238
-	supplierType := int64(dataBody["suppliertype"].(float64)) //供应商类别
237
+	if dataBody["suppliertype"] == "" {
238
+		var tmp int64 = 0
239
+		dataBody["suppliertype"] = tmp
240
+	}
241
+	if dataBody["vatrate"] == "" {
242
+		dataBody["vatrate"] = 0
243
+	}
244
+	supplierType := dataBody["suppliertype"].(int64) //供应商类别
239 245
 	//vatRate, _ := this.GetFloat("vatrate")           //增值税税率
240 246
 	vatRate, _ := dataBody["suppliertype"].(float64) //增值税税率
241 247
 	//number := this.GetString("number")               //纳税人识别号
@@ -266,7 +272,7 @@ func (this *SupplyOrderApiController) UpdateSupply() {
266 272
 			tmodify := this.GetAdminUserInfo().AdminUser.Id
267 273
 			err = service.UpdateSupplyAndContact(thisStockIn, supplierid, orgId, supplierType, tmodify, supplierCode, supplierName, number, bank, bankAccount, vatRate)
268 274
 			if err != nil {
269
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
275
+				this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
270 276
 				return
271 277
 			}
272 278
 		} else {
@@ -419,9 +425,16 @@ func (this *SupplyOrderApiController) SaveSupply() {
419 425
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号重复")
420 426
 		return
421 427
 	}
422
-	//supplierType, _ := this.GetInt64("suppliertype") //供应商类别
423
-	supplierType := int64(dataBody["suppliertype"].(float64)) //供应商类别
424
-	//vatRate, _ := this.GetFloat("vatrate")           //增值税税率
428
+	if dataBody["suppliertype"] == "" {
429
+		var tmp int64 = 0
430
+		dataBody["suppliertype"] = tmp
431
+	}
432
+	if dataBody["vatrate"] == "" {
433
+		dataBody["vatrate"] = 0
434
+	}
435
+	//supplierType, _ := this.GetInt64("suppliertype")
436
+	supplierType := dataBody["suppliertype"].(int64) //供应商类别
437
+	//vatRate, _ := this.GetFloat("vatrate")
425 438
 	vatRate, _ := dataBody["suppliertype"].(float64) //增值税税率
426 439
 	//number := this.GetString("number")
427 440
 	number := dataBody["number"].(string)
@@ -450,7 +463,7 @@ func (this *SupplyOrderApiController) SaveSupply() {
450 463
 			tcreater := this.GetAdminUserInfo().AdminUser.Id
451 464
 			err = service.SaveSupplyAndContact(thisStockIn, orgId, supplierType, tcreater, supplierCode, supplierName, number, bank, bankAccount, vatRate)
452 465
 			if err != nil {
453
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
466
+				this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
454 467
 				return
455 468
 			}
456 469
 		} else {

+ 3 - 0
service/supply_service.go Voir le fichier

@@ -52,6 +52,9 @@ func UpdateSupplyAndContact(thisStockIn []interface{}, suid, orgId, supplierType
52 52
 	for _, item := range thisStockIn {
53 53
 		items := item.(map[string]interface{})
54 54
 		//查询是否
55
+		if items["id"] == "" {
56
+			items["id"] = "0"
57
+		}
55 58
 		id, _ := strconv.ParseInt(items["id"].(string), 10, 64)
56 59
 		name := items["name"].(string)
57 60
 		phone := items["phone"].(string)