|
@@ -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
|
|