Browse Source

二级库正式环境bug

mainqaq 2 years ago
parent
commit
71b4bf25df
2 changed files with 20 additions and 10 deletions
  1. 4 3
      controllers/secondary_order_api_contorller.go
  2. 16 7
      service/secondary_service.go

+ 4 - 3
controllers/secondary_order_api_contorller.go View File

@@ -338,13 +338,15 @@ func (this *SecondaryOrderApiController) AddStorehouse() {
338 338
 		StorehouseAdminId: admin_id,
339 339
 		Ctime:             time.Now().Unix(),
340 340
 	}
341
-	err = service.AddStroehouse(storehouse)
341
+	var shiwu string
342
+	shiwu, err = service.AddStroehouse(storehouse)
342 343
 	if err != nil {
343 344
 		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "保存失败")
344 345
 		return
345 346
 	}
346 347
 	this.ServeSuccessJSON(map[string]interface{}{
347
-		"list": "保存成功",
348
+		"list":  "保存成功",
349
+		"shiwu": shiwu,
348 350
 	})
349 351
 	return
350 352
 }
@@ -1957,7 +1959,6 @@ func (this *SecondaryOrderApiController) GetuserName() {
1957 1959
 	//viewModels, _, _ := service.GetAdminUsersAndLoginInfo(10164, 12123, 1, 100)
1958 1960
 	c, _ := service.Getcreateid(adminUserInfo.CurrentOrgId)
1959 1961
 	//c, _ := service.Getcreateid(10164)
1960
-	//c.Creator
1961 1962
 	admin := []*service.AdminUserManageViewModel{} //记录当前管理员的信息
1962 1963
 	//去除禁用的角色
1963 1964
 	tmp := []*service.AdminUserManageViewModel{}

+ 16 - 7
service/secondary_service.go View File

@@ -109,36 +109,45 @@ func IsStorehouseAddress(orgid int64, storehouse_address string) (bool, error) {
109 109
 }
110 110
 
111 111
 //新增仓库
112
-func AddStroehouse(storehouse models.Storehouse) error {
112
+func AddStroehouse(storehouse models.Storehouse) (shiwu string, err error) {
113 113
 	tx := XTWriteDB().Begin()
114 114
 	defer func() {
115 115
 		if err != nil {
116
+			utils.ErrorLog("事务失败,原因为: %v", err)
117
+			shiwu = "失败"
116 118
 			tx.Rollback()
117 119
 		} else {
120
+			shiwu = "成功"
118 121
 			tx.Commit()
119 122
 		}
120 123
 	}()
121 124
 	//创建仓库
122
-	err := tx.Create(&storehouse).Error
125
+	err = tx.Create(&storehouse).Error
123 126
 	if err != nil {
124
-		return err
127
+		return shiwu, err
125 128
 	}
129
+	utils.ErrorLog("创建仓库成功")
126 130
 	var id models.Storehouse
127 131
 	//获取创建仓库的id
128 132
 	err = tx.Model(&models.Storehouse{}).Select("id").Where("status = 1 and user_org_id = ?", storehouse.UserOrgId).Order("id desc").First(&id).Error
129 133
 	if err != nil {
130
-		return err
134
+		return shiwu, err
131 135
 	}
136
+
132 137
 	//判断是否存在仓库配置
133 138
 	boolean := IsStorehouseconfigXT(storehouse.UserOrgId, tx)
134 139
 	if boolean == false {
135 140
 		//创建仓库配置
136 141
 		err = CreateStorehouseConfigXT(storehouse.UserOrgId, id.ID, tx)
142
+		if err != nil {
143
+			utils.ErrorLog("仓库配置失败")
144
+			return shiwu, err
145
+		}
137 146
 	} else {
138 147
 		utils.ErrorLog("仓库配置已存在")
139 148
 	}
140
-
141
-	return err
149
+	utils.ErrorLog("结束")
150
+	return shiwu, err
142 151
 }
143 152
 
144 153
 //修改仓库
@@ -209,7 +218,7 @@ func GetDefaultStorehouse(orgid int64) error {
209 218
 		Status:            1,
210 219
 		Ctime:             time.Now().Unix(),
211 220
 	}
212
-	err = AddStroehouse(storehouse)
221
+	_, err = AddStroehouse(storehouse)
213 222
 	return err
214 223
 }
215 224