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