Browse Source

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

XMLWAN 3 years ago
parent
commit
a5f15ec2cc
1 changed files with 58 additions and 31 deletions
  1. 58 31
      controllers/supply_order_api_contorller.go

+ 58 - 31
controllers/supply_order_api_contorller.go View File

183
 
183
 
184
 //保存供应商及联系人(用于更改)
184
 //保存供应商及联系人(用于更改)
185
 func (this *SupplyOrderApiController) UpdateSupply() {
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
 	if supplierName == "" {
194
 	if supplierName == "" {
188
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称不能为空")
195
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称不能为空")
189
 		return
196
 		return
190
 	}
197
 	}
191
-	supplierCode := this.GetString("suppliercode") //供应商编码
198
+	//upplierCode := this.GetString("suppliercode") //供应商编码
199
+	supplierCode := dataBody["suppliercode"].(string)
192
 	if supplierCode == "" {
200
 	if supplierCode == "" {
193
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
201
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
194
 		return
202
 		return
195
 	}
203
 	}
196
-	supplierid, _ := this.GetInt64("id") //供应商id
204
+	//supplierid, _ := this.GetInt64("id") //供应商id
205
+	supplierid := int64(dataBody["id"].(float64))
197
 	if supplierid == 0 {
206
 	if supplierid == 0 {
198
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商id不能为空")
207
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商id不能为空")
199
 		return
208
 		return
221
 			return
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
 	orgId := this.GetAdminUserInfo().CurrentOrgId
243
 	orgId := this.GetAdminUserInfo().CurrentOrgId
230
 	//contacts := this.Get("contacts")//联系人
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
 	if dataBody["contacts"] != nil && reflect.TypeOf(dataBody["contacts"]).String() == "[]interface {}" {
253
 	if dataBody["contacts"] != nil && reflect.TypeOf(dataBody["contacts"]).String() == "[]interface {}" {
240
 		thisStockIn, _ := dataBody["contacts"].([]interface{})
254
 		thisStockIn, _ := dataBody["contacts"].([]interface{})
242
 			if len(thisStockIn) == 1 {
256
 			if len(thisStockIn) == 1 {
243
 				for _, item := range thisStockIn {
257
 				for _, item := range thisStockIn {
244
 					items := item.(map[string]interface{})
258
 					items := item.(map[string]interface{})
245
-					items["IsFirst"] = 1
259
+					items["isfirst"] = 1
246
 				}
260
 				}
247
 			}
261
 			}
248
 			tmodify := this.GetAdminUserInfo().AdminUser.Id
262
 			tmodify := this.GetAdminUserInfo().AdminUser.Id
370
 
384
 
371
 //保存供应商
385
 //保存供应商
372
 func (this *SupplyOrderApiController) SaveSupply() {
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
 	if supplierName == "" {
396
 	if supplierName == "" {
375
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称不能为空")
397
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称不能为空")
376
 		return
398
 		return
381
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称重复")
403
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称重复")
382
 		return
404
 		return
383
 	}
405
 	}
384
-	supplierCode := this.GetString("suppliercode") //供应商编码
406
+	//supplierCode := this.GetString("suppliercode") //供应商编码
407
+	supplierCode := dataBody["suppliercode"].(string) //供应商编码
385
 	if supplierCode == "" {
408
 	if supplierCode == "" {
386
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
409
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
387
 		return
410
 		return
392
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号重复")
415
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号重复")
393
 		return
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
 	orgId := this.GetAdminUserInfo().CurrentOrgId
428
 	orgId := this.GetAdminUserInfo().CurrentOrgId
401
 	//contacts := this.Get("contacts")//联系人
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
 	if dataBody["contacts"] != nil && reflect.TypeOf(dataBody["contacts"]).String() == "[]interface {}" {
437
 	if dataBody["contacts"] != nil && reflect.TypeOf(dataBody["contacts"]).String() == "[]interface {}" {
411
 		thisStockIn, _ := dataBody["contacts"].([]interface{})
438
 		thisStockIn, _ := dataBody["contacts"].([]interface{})
413
 			if len(thisStockIn) == 1 {
440
 			if len(thisStockIn) == 1 {
414
 				for _, item := range thisStockIn {
441
 				for _, item := range thisStockIn {
415
 					items := item.(map[string]interface{})
442
 					items := item.(map[string]interface{})
416
-					items["IsFirst"] = 1
443
+					items["isfirst"] = 1
417
 				}
444
 				}
418
 			}
445
 			}
419
 			tcreater := this.GetAdminUserInfo().AdminUser.Id
446
 			tcreater := this.GetAdminUserInfo().AdminUser.Id