浏览代码

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

csx 3 年前
父节点
当前提交
ed4753b5ca
共有 2 个文件被更改,包括 10 次插入38 次删除
  1. 8 32
      controllers/supply_order_api_contorller.go
  2. 2 6
      service/supply_service.go

+ 8 - 32
controllers/supply_order_api_contorller.go 查看文件

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

+ 2 - 6
service/supply_service.go 查看文件

16
 //供应商分页
16
 //供应商分页
17
 func GetSupplyList(ctype int64, page int64, limit int64, keyword string, orgid int64) (supplylist []*models.SpSupplierName, total int64, err error) {
17
 func GetSupplyList(ctype int64, page int64, limit int64, keyword string, orgid int64) (supplylist []*models.SpSupplierName, total int64, err error) {
18
 	db := XTReadDB().Model(&supplylist).Where("xt_supplier_name.status = 1 and xt_supplier_name.user_org_id = ?", orgid)
18
 	db := XTReadDB().Model(&supplylist).Where("xt_supplier_name.status = 1 and xt_supplier_name.user_org_id = ?", orgid)
19
-
20
 	offset := (page - 1) * limit
19
 	offset := (page - 1) * limit
21
-
22
 	if len(keyword) > 0 {
20
 	if len(keyword) > 0 {
23
 		keyword = "%" + keyword + "%" //联系人
21
 		keyword = "%" + keyword + "%" //联系人
24
 		db = db.Joins("join xt_supplier_contacts on xt_supplier_contacts.supplier_code = xt_supplier_name.supplier_code")
22
 		db = db.Joins("join xt_supplier_contacts on xt_supplier_contacts.supplier_code = xt_supplier_name.supplier_code")
48
 			var tmp float64 = 0
46
 			var tmp float64 = 0
49
 			items["id"] = tmp
47
 			items["id"] = tmp
50
 		}
48
 		}
51
-		//id, _ := strconv.ParseInt(items["id"].(string), 10, 64)
52
 		id := int64(items["id"].(float64))
49
 		id := int64(items["id"].(float64))
53
 		name := items["name"].(string)
50
 		name := items["name"].(string)
54
 		phone := items["phone"].(string)
51
 		phone := items["phone"].(string)
55
 		address := items["address"].(string)
52
 		address := items["address"].(string)
56
 		var tmpfirst int64
53
 		var tmpfirst int64
57
-		//tmptype :=  reflect.TypeOf(items["is_first"])
58
 		switch items["is_first"].(type) {
54
 		switch items["is_first"].(type) {
59
 		case int:
55
 		case int:
60
 			var aint int = items["is_first"].(int)
56
 			var aint int = items["is_first"].(int)
282
 //查询供应商的名字是否有重复
278
 //查询供应商的名字是否有重复
283
 func FindSupplierName(supplierName string, orgId int64) (sbool bool, err error) {
279
 func FindSupplierName(supplierName string, orgId int64) (sbool bool, err error) {
284
 	var total int
280
 	var total int
285
-	err = XTReadDB().Model(&models.SpSupplierName{}).Where("supplier_name = ? and status = 1", supplierName).Count(&total).Error
281
+	err = XTReadDB().Model(&models.SpSupplierName{}).Where("supplier_name = ? and user_org_id = ? and status = 1", supplierName, orgId).Count(&total).Error
286
 	if total != 0 {
282
 	if total != 0 {
287
 		sbool = true
283
 		sbool = true
288
 	} else {
284
 	} else {
530
 
526
 
531
 func UpdateGoodWarehouseOutOrder(order *models.SpSupplierWarehousingOutOrder) error {
527
 func UpdateGoodWarehouseOutOrder(order *models.SpSupplierWarehousingOutOrder) error {
532
 
528
 
533
-	err := XTWriteDB().Model(&order).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{"project_id": order.ProjectId, "is_source": order.IsSource, "count": order.Count, "price": order.Count, "remark": order.Remark, "supply_batch_number": order.SupplyBatchNumber, "supply_product_date": order.SupplyProductDate, "supply_expiry_date": order.SupplyExpiryDate, "supply_type": order.SupplyType, "supply_specification_name": order.SupplySpecificationName, "supply_total": order.SupplyTotal, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name, "supply_unit": order.SupplyUnit, "manufacturer_id": order.ManufacturerId, "supply_license_number": order.SupplyLicenseNumber, "warehousing_id": order.WarehousingId, "warehouse_info_id": order.WarehouseInfoId, "min_price": order.MinPrice}).Error
529
+	err := XTWriteDB().Model(&order).Where("id = ? and status = 1", order.ID).Updates(map[string]interface{}{"project_id": order.ProjectId, "is_source": order.IsSource, "count": order.Count, "price": order.Price, "remark": order.Remark, "supply_batch_number": order.SupplyBatchNumber, "supply_product_date": order.SupplyProductDate, "supply_expiry_date": order.SupplyExpiryDate, "supply_type": order.SupplyType, "supply_specification_name": order.SupplySpecificationName, "supply_total": order.SupplyTotal, "supply_manufacturer": order.SupplyManufacturer, "name": order.Name, "supply_unit": order.SupplyUnit, "manufacturer_id": order.ManufacturerId, "supply_license_number": order.SupplyLicenseNumber, "warehousing_id": order.WarehousingId, "warehouse_info_id": order.WarehouseInfoId, "min_price": order.MinPrice}).Error
534
 	return err
530
 	return err
535
 }
531
 }
536
 
532