|
@@ -1391,10 +1391,13 @@ func FindAllDrugCancelStockTotal(org_id int64) (total int64, err error) {
|
1391
|
1391
|
func FindNewAllDrugCancelStockTotal(org_id int64, tx *gorm.DB) (total int64, err error) {
|
1392
|
1392
|
|
1393
|
1393
|
err = tx.Model(&models.DrugCancelStock{}).Where("org_id = ?", org_id).Count(&total).Error
|
1394
|
|
- if err != nil {
|
1395
|
|
- tx.Rollback()
|
1396
|
|
- return total, err
|
|
1394
|
+ if err != gorm.ErrRecordNotFound {
|
|
1395
|
+ if err != nil {
|
|
1396
|
+ tx.Rollback()
|
|
1397
|
+ return total, err
|
|
1398
|
+ }
|
1397
|
1399
|
}
|
|
1400
|
+
|
1398
|
1401
|
return total, err
|
1399
|
1402
|
}
|
1400
|
1403
|
|
|
@@ -8139,18 +8142,11 @@ func UpdateGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64) er
|
8139
|
8142
|
}
|
8140
|
8143
|
|
8141
|
8144
|
func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
|
8142
|
|
- tx := XTWriteDB().Begin()
|
8143
|
|
- err := tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
8144
|
|
- if err != nil {
|
8145
|
|
- tx.Rollback()
|
8146
|
|
- return err
|
8147
|
|
- }
|
8148
|
|
- err = tx.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
|
8149
|
|
- if err != nil {
|
8150
|
|
- tx.Rollback()
|
8151
|
|
- return err
|
8152
|
|
- }
|
8153
|
|
- tx.Commit()
|
|
8145
|
+
|
|
8146
|
+ err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
8147
|
+
|
|
8148
|
+ err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
|
|
8149
|
+
|
8154
|
8150
|
return err
|
8155
|
8151
|
}
|
8156
|
8152
|
|
|
@@ -8185,18 +8181,11 @@ func GetCancelWarehouseList(orgId int64, goodId int64, warehouseInfoId int64) (i
|
8185
|
8181
|
}
|
8186
|
8182
|
|
8187
|
8183
|
func CheckCancelStock(stock models.CancelStock, cancel_stock_id int64, orgid int64) error {
|
8188
|
|
- ut := writeDb.Begin()
|
8189
|
|
- err := ut.Model(&models.CancelStock{}).Where("id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
8190
|
|
- if err != nil {
|
8191
|
|
- ut.Rollback()
|
8192
|
|
- return err
|
8193
|
|
- }
|
8194
|
|
- err = ut.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
8195
|
|
- if err != nil {
|
8196
|
|
- ut.Rollback()
|
8197
|
|
- return err
|
8198
|
|
- }
|
8199
|
|
- ut.Commit()
|
|
8184
|
+
|
|
8185
|
+ err := XTWriteDB().Model(&models.CancelStock{}).Where("id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
|
8186
|
+
|
|
8187
|
+ err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
|
|
8188
|
+
|
8200
|
8189
|
return err
|
8201
|
8190
|
}
|
8202
|
8191
|
|
|
@@ -8207,67 +8196,41 @@ func GetCancelStockInfoById(cancel_stock_id int64, orgid int64) (info []*models.
|
8207
|
8196
|
}
|
8208
|
8197
|
|
8209
|
8198
|
func UpdateCancelStockNumber(stock_count int64, warehouse_info_id int64, orgid int64) error {
|
8210
|
|
- ut := writeDb.Begin()
|
8211
|
|
- err := ut.Model(&models.WarehousingInfo{}).Where("id = ? and org_id = ? and status = 1", warehouse_info_id, orgid).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", stock_count)).Error
|
8212
|
|
- if err != nil {
|
8213
|
|
- ut.Rollback()
|
8214
|
|
- return err
|
8215
|
|
- }
|
8216
|
|
- ut.Commit()
|
|
8199
|
+
|
|
8200
|
+ err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and org_id = ? and status = 1", warehouse_info_id, orgid).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", stock_count)).Error
|
|
8201
|
+
|
8217
|
8202
|
return err
|
8218
|
8203
|
}
|
8219
|
8204
|
|
8220
|
8205
|
func UpdateGoodSumCount(sum_count int64, good_id int64, orgid int64) error {
|
8221
|
|
- ut := writeDb.Begin()
|
8222
|
|
- err := ut.Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
|
8223
|
|
- if err != nil {
|
8224
|
|
- ut.Rollback()
|
8225
|
|
- return err
|
8226
|
|
- }
|
8227
|
|
- ut.Commit()
|
|
8206
|
+
|
|
8207
|
+ err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
|
|
8208
|
+
|
8228
|
8209
|
return err
|
8229
|
8210
|
}
|
8230
|
8211
|
|
8231
|
8212
|
func UpdateStockWarehouseInfo(cancel_stock_id int64, orgid int64, stock models.CancelStock) error {
|
8232
|
|
- ut := writeDb.Begin()
|
8233
|
|
- err := ut.Model(&models.CancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
8234
|
|
- if err != nil {
|
8235
|
|
- ut.Rollback()
|
8236
|
|
- return err
|
8237
|
|
- }
|
8238
|
|
- err = ut.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
8239
|
|
- if err != nil {
|
8240
|
|
- ut.Rollback()
|
8241
|
|
- return err
|
8242
|
|
- }
|
8243
|
|
- ut.Commit()
|
|
8213
|
+
|
|
8214
|
+ err := XTWriteDB().Model(&models.CancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
|
8215
|
+
|
|
8216
|
+ err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
|
|
8217
|
+
|
8244
|
8218
|
return err
|
8245
|
8219
|
}
|
8246
|
8220
|
|
8247
|
8221
|
func UpdateStockWarehouseInfoStockFlow(id int64, orgid int64, goodid int64) error {
|
8248
|
|
- ut := writeDb.Begin()
|
8249
|
|
- err = ut.Model(&models.VmStockFlow{}).Where("cancel_out_detail_id = ? and user_org_id = ? and status = 1 and good_id =?", id, orgid, goodid).Update(map[string]interface{}{"status": 0}).Error
|
8250
|
|
- if err != nil {
|
8251
|
|
- ut.Rollback()
|
8252
|
|
- return err
|
8253
|
|
- }
|
8254
|
|
- ut.Commit()
|
|
8222
|
+
|
|
8223
|
+ err = XTWriteDB().Model(&models.VmStockFlow{}).Where("cancel_out_detail_id = ? and user_org_id = ? and status = 1 and good_id =?", id, orgid, goodid).Update(map[string]interface{}{"status": 0}).Error
|
|
8224
|
+
|
8255
|
8225
|
return err
|
8256
|
8226
|
}
|
8257
|
8227
|
|
8258
|
8228
|
func UpdateStockNumberWarehouseInfo(warehouse_info_id int64, good_id int64, org_id int64, stock_count int64) error {
|
8259
|
|
- ut := writeDb.Begin()
|
|
8229
|
+
|
8260
|
8230
|
err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and good_id = ? and org_id = ? and status = 1", warehouse_info_id, good_id, org_id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", stock_count)).Error
|
8261
|
|
- if err != nil {
|
8262
|
|
- ut.Rollback()
|
8263
|
|
- return err
|
8264
|
|
- }
|
|
8231
|
+
|
8265
|
8232
|
err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and status = 1 and org_id = ?", good_id, org_id).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", stock_count)).Error
|
8266
|
|
- if err != nil {
|
8267
|
|
- ut.Rollback()
|
8268
|
|
- return err
|
8269
|
|
- }
|
8270
|
|
- ut.Commit()
|
|
8233
|
+
|
8271
|
8234
|
return err
|
8272
|
8235
|
}
|
8273
|
8236
|
|
|
@@ -8311,18 +8274,10 @@ func GetNewDrugAllStockInfo(storehouse_id int64, orgid int64, drugid int64, tx *
|
8311
|
8274
|
}
|
8312
|
8275
|
|
8313
|
8276
|
func UpdateBaseDrugSumInfo(sum_count int64, drugid int64, orgid int64, sum_in_count int64) error {
|
8314
|
|
- ut := XTWriteDB().Begin()
|
8315
|
|
- err := ut.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
8316
|
|
- if err != nil {
|
8317
|
|
- ut.Rollback()
|
8318
|
|
- return err
|
8319
|
|
- }
|
8320
|
|
- err = ut.Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
|
8321
|
|
- if err != nil {
|
8322
|
|
- ut.Rollback()
|
8323
|
|
- return err
|
8324
|
|
- }
|
8325
|
|
- ut.Commit()
|
|
8277
|
+
|
|
8278
|
+ err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
|
|
8279
|
+
|
|
8280
|
+ err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
|
8326
|
8281
|
return err
|
8327
|
8282
|
}
|
8328
|
8283
|
|
|
@@ -8445,13 +8400,9 @@ func ModifyDrugFlowByCancelId(cancelstock_id int64, drugId int64, orgid int64) e
|
8445
|
8400
|
}
|
8446
|
8401
|
|
8447
|
8402
|
func ModifyDrugMaxNumberWarehouseInfo(id int64, count int64, orgid int64) error {
|
8448
|
|
- ut := XTWriteDB().Begin()
|
8449
|
|
- err := ut.Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
|
8450
|
|
- if err != nil {
|
8451
|
|
- ut.Rollback()
|
8452
|
|
- return err
|
8453
|
|
- }
|
8454
|
|
- ut.Commit()
|
|
8403
|
+
|
|
8404
|
+ err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
|
|
8405
|
+
|
8455
|
8406
|
return err
|
8456
|
8407
|
|
8457
|
8408
|
}
|
|
@@ -8513,14 +8464,8 @@ func CreateGoodStockCount(stock models.XtGoodStockCount) error {
|
8513
|
8464
|
|
8514
|
8465
|
func AddGoodSumInCount(storehouse_id int64, good_id int64, user_org_id int64, count int64) error {
|
8515
|
8466
|
|
8516
|
|
- ut := XTWriteDB().Begin()
|
|
8467
|
+ err := XTWriteDB().Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count + ?", count)).Error
|
8517
|
8468
|
|
8518
|
|
- err := ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_in_count", gorm.Expr("stock_in_count + ?", count)).Error
|
8519
|
|
- if err != nil {
|
8520
|
|
- ut.Rollback()
|
8521
|
|
- return err
|
8522
|
|
- }
|
8523
|
|
- ut.Commit()
|
8524
|
8469
|
return err
|
8525
|
8470
|
}
|
8526
|
8471
|
|
|
@@ -8538,14 +8483,9 @@ func ReduceGoodSumInCount(storehouse_id int64, good_id int64, user_org_id int64,
|
8538
|
8483
|
}
|
8539
|
8484
|
|
8540
|
8485
|
func UpdateGoodFlushCount(storehouse_id int64, good_id int64, user_org_id int64, flush_count int64) error {
|
8541
|
|
- ut := XTWriteDB().Begin()
|
8542
|
8486
|
|
8543
|
|
- err := ut.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id = ? and good_id =?", storehouse_id, user_org_id, good_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
|
8544
|
|
- if err != nil {
|
8545
|
|
- ut.Rollback()
|
8546
|
|
- return err
|
8547
|
|
- }
|
8548
|
|
- ut.Commit()
|
|
8487
|
+ err := XTWriteDB().Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id = ? and good_id =?", storehouse_id, user_org_id, good_id).Update(map[string]interface{}{"flush_count": flush_count}).Error
|
|
8488
|
+
|
8549
|
8489
|
return err
|
8550
|
8490
|
}
|
8551
|
8491
|
|