From 6c6839156dde0f99b1695312f67de9f2fa2ed341 Mon Sep 17 00:00:00 2001 From: kanade Date: Thu, 24 Nov 2022 11:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=87=8D=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/v2/logic/third/supply.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/v2/logic/third/supply.go b/internal/v2/logic/third/supply.go index 22a8533..40af3eb 100644 --- a/internal/v2/logic/third/supply.go +++ b/internal/v2/logic/third/supply.go @@ -191,6 +191,13 @@ func (s *supplyLogic) Adopt(data AdoptSkuInfo) error { if len(recookGoodsSkuModels) > 0 { // 已添加过商品 return mysql.Db.Transaction(func(tx *gorm.DB) error { + // 原数据处理 + if tx.Model(&manage.RecookThirdPartySupply{}).Where("id = ?", thirdPartySupply.Id).Updates(map[string]interface{}{ + "status": manage.RecookThirdPartySupplyStatusAdopt, + "goods_id": recookGoodsSkuModels[0].GoodsId, + }).RowsAffected != 1 { + return errors.New("入库失败") + } // 详情 if thirdPartySupply.Content != "" { if tx.Model(&goods.RecookGoodsContentModel{}).Where("goods_id = ?", recookGoodsSkuModels[0].GoodsId).Update("content", thirdPartySupply.Content).Error != nil { @@ -326,13 +333,6 @@ func (s *supplyLogic) Adopt(data AdoptSkuInfo) error { if tx.Create(&sku).Error != nil { return errors.New("入库失败") } - // 原数据处理 - if tx.Model(&manage.RecookThirdPartySupply{}).Where("id = ?", thirdPartySupply.Id).Updates(map[string]interface{}{ - "status": manage.RecookThirdPartySupplyStatusAdopt, - "goods_id": recookGoodsSkuModels[0].GoodsId, - }).RowsAffected != 1 { - return errors.New("入库失败") - } return nil }) } else { @@ -361,6 +361,13 @@ func (s *supplyLogic) Adopt(data AdoptSkuInfo) error { if tx.Create(&recookGoodsInfoModel).Error != nil { return errors.New("入库失败") } + // 原数据处理 + if tx.Model(&manage.RecookThirdPartySupply{}).Where("id = ?", thirdPartySupply.Id).Updates(map[string]interface{}{ + "status": manage.RecookThirdPartySupplyStatusAdopt, + "goods_id": recookGoodsInfoModel.Id, + }).RowsAffected != 1 { + return errors.New("入库失败") + } // 商品详情 recookGoodsContentModel := goods.RecookGoodsContentModel{ @@ -464,13 +471,6 @@ func (s *supplyLogic) Adopt(data AdoptSkuInfo) error { if tx.Create(&sku).Error != nil { return errors.New("入库失败") } - // 原数据处理 - if tx.Model(&manage.RecookThirdPartySupply{}).Where("id = ?", thirdPartySupply.Id).Updates(map[string]interface{}{ - "status": manage.RecookThirdPartySupplyStatusAdopt, - "goods_id": recookGoodsInfoModel.Id, - }).RowsAffected != 1 { - return errors.New("入库失败") - } return nil }) }