Sfoglia il codice sorgente

Merge branch '20211122' of http://git.shengws.com/csx/XT_New into 20211122

XMLWAN 2 anni fa
parent
commit
a5f15ec2cc
1 ha cambiato i file con 58 aggiunte e 31 eliminazioni
  1. 58 31
      controllers/supply_order_api_contorller.go

+ 58 - 31
controllers/supply_order_api_contorller.go Vedi File

@@ -183,17 +183,26 @@ func (this *SupplyOrderApiController) GetSupplyList() {
183 183
 
184 184
 //保存供应商及联系人(用于更改)
185 185
 func (this *SupplyOrderApiController) UpdateSupply() {
186
-	supplierName := this.GetString("suppliername") //供应商名称
186
+	dataBody := make(map[string]interface{}, 0)
187
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
188
+	if err != nil {
189
+		utils.ErrorLog(err.Error())
190
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
191
+		return
192
+	}
193
+	supplierName := dataBody["suppliername"].(string)
187 194
 	if supplierName == "" {
188 195
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称不能为空")
189 196
 		return
190 197
 	}
191
-	supplierCode := this.GetString("suppliercode") //供应商编码
198
+	//upplierCode := this.GetString("suppliercode") //供应商编码
199
+	supplierCode := dataBody["suppliercode"].(string)
192 200
 	if supplierCode == "" {
193 201
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
194 202
 		return
195 203
 	}
196
-	supplierid, _ := this.GetInt64("id") //供应商id
204
+	//supplierid, _ := this.GetInt64("id") //供应商id
205
+	supplierid := int64(dataBody["id"].(float64))
197 206
 	if supplierid == 0 {
198 207
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商id不能为空")
199 208
 		return
@@ -221,20 +230,25 @@ func (this *SupplyOrderApiController) UpdateSupply() {
221 230
 			return
222 231
 		}
223 232
 	}
224
-	supplierType, _ := this.GetInt64("suppliertype") //供应商类别
225
-	vatRate, _ := this.GetFloat("vatrate")           //增值税税率
226
-	number := this.GetString("number")               //纳税人识别号
227
-	bank := this.GetString("bank")                   //开户银行
228
-	bankAccount := this.GetString("bankAccount")     //银行账号
233
+	//supplierType, _ := this.GetInt64("suppliertype") //供应商类别
234
+	supplierType := int64(dataBody["suppliertype"].(float64)) //供应商类别
235
+	//vatRate, _ := this.GetFloat("vatrate")           //增值税税率
236
+	vatRate, _ := dataBody["suppliertype"].(float64) //增值税税率
237
+	//number := this.GetString("number")               //纳税人识别号
238
+	number := dataBody["number"].(string) //纳税人识别号
239
+	//bank := this.GetString("bank")                   //开户银行
240
+	bank := dataBody["bank"].(string) //纳税人识别号
241
+	//bankAccount := this.GetString("bankAccount")     //银行账号
242
+	bankAccount := dataBody["bankaccount"].(string)
229 243
 	orgId := this.GetAdminUserInfo().CurrentOrgId
230 244
 	//contacts := this.Get("contacts")//联系人
231
-	dataBody := make(map[string]interface{}, 0)
232
-	err = json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
233
-	if err != nil {
234
-		utils.ErrorLog(err.Error())
235
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
236
-		return
237
-	}
245
+	//dataBody := make(map[string]interface{}, 0)
246
+	//err = json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
247
+	//if err != nil {
248
+	//	utils.ErrorLog(err.Error())
249
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
250
+	//	return
251
+	//}
238 252
 	//保存联系人
239 253
 	if dataBody["contacts"] != nil && reflect.TypeOf(dataBody["contacts"]).String() == "[]interface {}" {
240 254
 		thisStockIn, _ := dataBody["contacts"].([]interface{})
@@ -242,7 +256,7 @@ func (this *SupplyOrderApiController) UpdateSupply() {
242 256
 			if len(thisStockIn) == 1 {
243 257
 				for _, item := range thisStockIn {
244 258
 					items := item.(map[string]interface{})
245
-					items["IsFirst"] = 1
259
+					items["isfirst"] = 1
246 260
 				}
247 261
 			}
248 262
 			tmodify := this.GetAdminUserInfo().AdminUser.Id
@@ -370,7 +384,15 @@ func (this *SupplyOrderApiController) GetSupplyCode() {
370 384
 
371 385
 //保存供应商
372 386
 func (this *SupplyOrderApiController) SaveSupply() {
373
-	supplierName := this.GetString("suppliername") //供应商名称
387
+	//supplierName := this.GetString("suppliername") //供应商名称
388
+	dataBody := make(map[string]interface{}, 0)
389
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
390
+	if err != nil {
391
+		utils.ErrorLog(err.Error())
392
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
393
+		return
394
+	}
395
+	supplierName := dataBody["suppliername"].(string)
374 396
 	if supplierName == "" {
375 397
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称不能为空")
376 398
 		return
@@ -381,7 +403,8 @@ func (this *SupplyOrderApiController) SaveSupply() {
381 403
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称重复")
382 404
 		return
383 405
 	}
384
-	supplierCode := this.GetString("suppliercode") //供应商编码
406
+	//supplierCode := this.GetString("suppliercode") //供应商编码
407
+	supplierCode := dataBody["suppliercode"].(string) //供应商编码
385 408
 	if supplierCode == "" {
386 409
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
387 410
 		return
@@ -392,20 +415,24 @@ func (this *SupplyOrderApiController) SaveSupply() {
392 415
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号重复")
393 416
 		return
394 417
 	}
395
-	supplierType, _ := this.GetInt64("suppliertype") //供应商类别
396
-	vatRate, _ := this.GetFloat("vatrate")           //增值税税率
397
-	number := this.GetString("number")               //纳税人识别号
398
-	bank := this.GetString("bank")                   //开户银行
399
-	bankAccount := this.GetString("bankAccount")     //银行账号
418
+	//supplierType, _ := this.GetInt64("suppliertype") //供应商类别
419
+	supplierType, _ := dataBody["suppliertype"].(int64) //供应商类别
420
+	//vatRate, _ := this.GetFloat("vatrate")           //增值税税率
421
+	vatRate, _ := dataBody["suppliertype"].(float64) //增值税税率
422
+	//number := this.GetString("number")
423
+	number := dataBody["number"].(string)
424
+	//bank := this.GetString("bank")
425
+	bank := dataBody["bank"].(string)
426
+	//bankAccount := this.GetString("bankAccount")
427
+	bankAccount := dataBody["bankaccount"].(string)
400 428
 	orgId := this.GetAdminUserInfo().CurrentOrgId
401 429
 	//contacts := this.Get("contacts")//联系人
402
-	dataBody := make(map[string]interface{}, 0)
403
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
404
-	if err != nil {
405
-		utils.ErrorLog(err.Error())
406
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
407
-		return
408
-	}
430
+	//err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
431
+	//if err != nil {
432
+	//	utils.ErrorLog(err.Error())
433
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
434
+	//	return
435
+	//}
409 436
 	//保存联系人
410 437
 	if dataBody["contacts"] != nil && reflect.TypeOf(dataBody["contacts"]).String() == "[]interface {}" {
411 438
 		thisStockIn, _ := dataBody["contacts"].([]interface{})
@@ -413,7 +440,7 @@ func (this *SupplyOrderApiController) SaveSupply() {
413 440
 			if len(thisStockIn) == 1 {
414 441
 				for _, item := range thisStockIn {
415 442
 					items := item.(map[string]interface{})
416
-					items["IsFirst"] = 1
443
+					items["isfirst"] = 1
417 444
 				}
418 445
 			}
419 446
 			tcreater := this.GetAdminUserInfo().AdminUser.Id