Bladeren bron

修改二级库bug390引起的后续bug

mainqaq 2 jaren geleden
bovenliggende
commit
20ad854bc8
2 gewijzigde bestanden met toevoegingen van 28 en 2 verwijderingen
  1. 2 2
      controllers/secondary_order_api_contorller.go
  2. 26 0
      service/secondary_service.go

+ 2 - 2
controllers/secondary_order_api_contorller.go Bestand weergeven

@@ -396,13 +396,13 @@ func (this *SecondaryOrderApiController) UpdateStorehouse() {
396 396
 	}
397 397
 	//判断仓库名称是否重复
398 398
 	var bo bool
399
-	bo, err = service.IsStorehouseName(orgId, name)
399
+	bo, err = service.IsStorehouseNameUp(orgId, id, name)
400 400
 	if bo == true {
401 401
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "该仓库已存在,请重新输入")
402 402
 		return
403 403
 	}
404 404
 	//判断仓库地址是否重复
405
-	bo, err = service.IsStorehouseAddress(orgId, address)
405
+	bo, err = service.IsStorehouseAddressUp(orgId, id, address)
406 406
 	if bo == true {
407 407
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "该地址已存在,请重新输入")
408 408
 		return

+ 26 - 0
service/secondary_service.go Bestand weergeven

@@ -82,6 +82,32 @@ func IsStorehouseAddress(orgid int64, storehouse_address string) (bool, error) {
82 82
 	return tmp, err
83 83
 }
84 84
 
85
+//查询仓库名称是否重复(用于修改)
86
+func IsStorehouseNameUp(orgid, id int64, storehouse_name string) (bool, error) {
87
+	var total int
88
+	var tmp bool
89
+	err := XTReadDB().Model(&models.Storehouse{}).Where("storehouse_name = ? and user_org_id = ? and status = 1 and id != ?", storehouse_name, orgid, id).Count(&total).Error
90
+	if total > 0 {
91
+		tmp = true //有重复的
92
+	} else {
93
+		tmp = false
94
+	}
95
+	return tmp, err
96
+}
97
+
98
+//查询仓库地址是否重复(用于修改)
99
+func IsStorehouseAddressUp(orgid, id int64, storehouse_address string) (bool, error) {
100
+	var total int
101
+	var tmp bool
102
+	err := XTReadDB().Model(&models.Storehouse{}).Where("storehouse_address = ? and user_org_id = ? and status = 1 and id != ?", storehouse_address, orgid, id).Count(&total).Error
103
+	if total > 0 {
104
+		tmp = true //有重复的
105
+	} else {
106
+		tmp = false
107
+	}
108
+	return tmp, err
109
+}
110
+
85 111
 //新增仓库
86 112
 func AddStroehouse(storehouse models.Storehouse) error {
87 113
 	tx := XTWriteDB().Begin()