|
@@ -20,11 +20,11 @@ type SupplyOrderApiController struct {
|
20
|
20
|
}
|
21
|
21
|
|
22
|
22
|
func SupplyOrderApiRegistRouters() {
|
23
|
|
- //获取供应商列表(orgid)
|
|
23
|
+ //获取供应商列表
|
24
|
24
|
beego.Router("/api/supply/getsupplylist", &SupplyOrderApiController{}, "get:GetSupplyList")
|
25
|
|
- //保存供应商及联系人(用于更改N)
|
|
25
|
+ //保存供应商及联系人(用于更改)
|
26
|
26
|
beego.Router("/api/supply/updatesupply", &SupplyOrderApiController{}, "post:UpdateSupply")
|
27
|
|
- //删除单条联系人(N)
|
|
27
|
+ //删除单条联系人
|
28
|
28
|
beego.Router("/api/supply/delcontactone", &SupplyOrderApiController{}, "get:DelContactOne")
|
29
|
29
|
//获取单条供应商和涉及到的联系人记录
|
30
|
30
|
beego.Router("/api/supply/getsupplyandcontactone", &SupplyOrderApiController{}, "get:GetSupplyAndContactOne")
|
|
@@ -131,10 +131,6 @@ func (this *SupplyOrderApiController) GetSupplyList() {
|
131
|
131
|
if err != nil {
|
132
|
132
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
133
|
133
|
}
|
134
|
|
- //if page == 0 || limit == 0 {
|
135
|
|
- // this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "page或limit参数不能为空")
|
136
|
|
- // return
|
137
|
|
- //}
|
138
|
134
|
keyword := this.GetString("keyword") //供应商编号\供应商名称\联系人名字
|
139
|
135
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
140
|
136
|
//获取分页的数据
|
|
@@ -204,7 +200,6 @@ func (this *SupplyOrderApiController) GetSupplyList() {
|
204
|
200
|
phonemap[list[i].SupplierCode],
|
205
|
201
|
}
|
206
|
202
|
tmplist = append(tmplist, tlist)
|
207
|
|
-
|
208
|
203
|
}
|
209
|
204
|
this.ServeSuccessJSON(map[string]interface{}{
|
210
|
205
|
"list": tmplist,
|
|
@@ -225,13 +220,11 @@ func (this *SupplyOrderApiController) UpdateSupply() {
|
225
|
220
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
226
|
221
|
return
|
227
|
222
|
}
|
228
|
|
-
|
229
|
223
|
supplierName := dataBody["suppliername"].(string)
|
230
|
224
|
if supplierName == "" {
|
231
|
225
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称不能为空")
|
232
|
226
|
return
|
233
|
227
|
}
|
234
|
|
- //upplierCode := this.GetString("suppliercode") //供应商编码
|
235
|
228
|
supplierCode := dataBody["suppliercode"].(string)
|
236
|
229
|
if supplierCode == "" {
|
237
|
230
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
|
|
@@ -265,7 +258,6 @@ func (this *SupplyOrderApiController) UpdateSupply() {
|
265
|
258
|
return
|
266
|
259
|
}
|
267
|
260
|
}
|
268
|
|
- //supplierType, _ := this.GetInt64("suppliertype") //供应商类别
|
269
|
261
|
if dataBody["suppliertype"] == "" || dataBody["suppliertype"] == 0 {
|
270
|
262
|
var tmp float64 = 0
|
271
|
263
|
dataBody["suppliertype"] = tmp
|
|
@@ -282,13 +274,10 @@ func (this *SupplyOrderApiController) UpdateSupply() {
|
282
|
274
|
case string:
|
283
|
275
|
tmpvarrate, _ = strconv.ParseFloat(dataBody["vatrate"].(string), 64)
|
284
|
276
|
}
|
285
|
|
- vatRate := tmpvarrate //增值税税率
|
286
|
|
- //number := this.GetString("number") //纳税人识别号
|
287
|
|
- number := dataBody["number"].(string) //纳税人识别号
|
288
|
|
- //bank := this.GetString("bank") //开户银行
|
289
|
|
- bank := dataBody["bank"].(string) //纳税人识别号
|
290
|
|
- //bankAccount := this.GetString("bankAccount") //银行账号
|
291
|
|
- bankAccount := dataBody["bankaccount"].(string)
|
|
277
|
+ vatRate := tmpvarrate //增值税税率
|
|
278
|
+ number := dataBody["number"].(string) //纳税人识别号
|
|
279
|
+ bank := dataBody["bank"].(string) //开户银行
|
|
280
|
+ bankAccount := dataBody["bankaccount"].(string) //银行账号
|
292
|
281
|
tmodify := this.GetAdminUserInfo().AdminUser.Id //修改者
|
293
|
282
|
//保存联系人
|
294
|
283
|
if dataBody["contacts"] != nil && reflect.TypeOf(dataBody["contacts"]).String() == "[]interface {}" {
|
|
@@ -378,10 +367,6 @@ func (this *SupplyOrderApiController) GetSupplyAndContactOne() {
|
378
|
367
|
if err != nil {
|
379
|
368
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
|
380
|
369
|
}
|
381
|
|
- //if id == 0 {
|
382
|
|
- // this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商id不能为空")
|
383
|
|
- // return
|
384
|
|
- //}
|
385
|
370
|
supply, contact, err := service.GetSupplyAndContactOne(id, orgId)
|
386
|
371
|
//获取供应商类别
|
387
|
372
|
costClassify := "供应商类别"
|
|
@@ -481,7 +466,6 @@ func (this *SupplyOrderApiController) DelSupply() {
|
481
|
466
|
func (this *SupplyOrderApiController) DelContactOne() {
|
482
|
467
|
id, _ := this.GetInt64("id")
|
483
|
468
|
if id == 0 {
|
484
|
|
- //this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "联系人id不能为空")
|
485
|
469
|
this.ServeSuccessJSON(map[string]interface{}{
|
486
|
470
|
"list": "删除成功,没有走数据库",
|
487
|
471
|
})
|
|
@@ -507,7 +491,6 @@ func (this *SupplyOrderApiController) GetSupplyCode() {
|
507
|
491
|
return
|
508
|
492
|
}
|
509
|
493
|
if len(supply) == 0 { //如果数据库中没有gys类型的编码则设置默认值
|
510
|
|
- //supply[0].SupplierCode ="gys001"
|
511
|
494
|
supply = []*models.SpSupplierName{
|
512
|
495
|
{
|
513
|
496
|
SupplierCode: "gys001",
|
|
@@ -532,10 +515,9 @@ func (this *SupplyOrderApiController) GetSupplyCode() {
|
532
|
515
|
return
|
533
|
516
|
}
|
534
|
517
|
|
535
|
|
-//保存供应商
|
|
518
|
+//保存供应商(用于新增)
|
536
|
519
|
func (this *SupplyOrderApiController) SaveSupply() {
|
537
|
520
|
orgId := this.GetAdminUserInfo().CurrentOrgId
|
538
|
|
- //supplierName := this.GetString("suppliername") //供应商名称
|
539
|
521
|
dataBody := make(map[string]interface{}, 0)
|
540
|
522
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
541
|
523
|
if err != nil {
|
|
@@ -554,7 +536,6 @@ func (this *SupplyOrderApiController) SaveSupply() {
|
554
|
536
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商名称重复")
|
555
|
537
|
return
|
556
|
538
|
}
|
557
|
|
- //supplierCode := this.GetString("suppliercode") //供应商编码
|
558
|
539
|
supplierCode := dataBody["suppliercode"].(string) //供应商编码
|
559
|
540
|
if supplierCode == "" {
|
560
|
541
|
this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "供应商编号不能为空")
|
|
@@ -573,13 +554,11 @@ func (this *SupplyOrderApiController) SaveSupply() {
|
573
|
554
|
if dataBody["vatrate"] == "" {
|
574
|
555
|
dataBody["vatrate"] = "0"
|
575
|
556
|
}
|
576
|
|
- //supplierType, _ := this.GetInt64("suppliertype")
|
577
|
557
|
if dataBody["suppliertype"] == "" || dataBody["suppliertype"] == 0 {
|
578
|
558
|
var tmp float64 = 0
|
579
|
559
|
dataBody["suppliertype"] = tmp
|
580
|
560
|
}
|
581
|
561
|
supplierType := int64(dataBody["suppliertype"].(float64)) //供应商类别
|
582
|
|
- //vatRate, _ := this.GetFloat("vatrate")
|
583
|
562
|
var tmpvarrate float64
|
584
|
563
|
datavarrate := dataBody["vatrate"]
|
585
|
564
|
switch datavarrate.(type) {
|
|
@@ -589,11 +568,8 @@ func (this *SupplyOrderApiController) SaveSupply() {
|
589
|
568
|
tmpvarrate, _ = strconv.ParseFloat(dataBody["vatrate"].(string), 64)
|
590
|
569
|
}
|
591
|
570
|
vatRate := tmpvarrate //增值税税率
|
592
|
|
- //number := dataBody["number"].(string)
|
593
|
571
|
number, _ := dataBody["number"].(string)
|
594
|
|
- //bank := this.GetString("bank")
|
595
|
572
|
bank := dataBody["bank"].(string)
|
596
|
|
- //bankAccount := this.GetString("bankAccount")
|
597
|
573
|
bankAccount := dataBody["bankaccount"].(string)
|
598
|
574
|
tcreater := this.GetAdminUserInfo().AdminUser.Id
|
599
|
575
|
//保存联系人
|