Преглед изворни кода

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

mainqaq пре 3 година
родитељ
комит
e50d7a9007
2 измењених фајлова са 25 додато и 9 уклоњено
  1. 22 9
      controllers/supply_order_api_contorller.go
  2. 3 0
      service/supply_service.go

+ 22 - 9
controllers/supply_order_api_contorller.go Прегледај датотеку

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

+ 3 - 0
service/supply_service.go Прегледај датотеку

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