This commit is contained in:
parent
764c144f86
commit
0a5b5de491
@ -126,6 +126,8 @@ func (c *Controller) providerChange(ctx context.Context, message string) error {
|
|||||||
c.provider.CalculateProcess = provider.CalculateProcess
|
c.provider.CalculateProcess = provider.CalculateProcess
|
||||||
|
|
||||||
if needUpdate {
|
if needUpdate {
|
||||||
|
provider.Status = v2.ProviderStatus_Calculating
|
||||||
|
_ = c.storage.Provider().UpdateStatus(provider)
|
||||||
var results = make([]v2.ProviderArticle, 0, 20)
|
var results = make([]v2.ProviderArticle, 0, 20)
|
||||||
err = c.storage.ProviderArticle().FindInBatches(storage.NewGetProviderArticleQuery().SetProviderId(c.providerId), &results, func(tx *gorm.DB, batch int) error {
|
err = c.storage.ProviderArticle().FindInBatches(storage.NewGetProviderArticleQuery().SetProviderId(c.providerId), &results, func(tx *gorm.DB, batch int) error {
|
||||||
for idx := range results {
|
for idx := range results {
|
||||||
@ -135,8 +137,19 @@ func (c *Controller) providerChange(ctx context.Context, message string) error {
|
|||||||
"exchangeRate": c.provider.Config.ExchangeRate,
|
"exchangeRate": c.provider.Config.ExchangeRate,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return tx.Select("id", "cost").Save(&results).Error
|
if err = tx.Select("id", "cost").Save(&results).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ids := lo.Map(results, func(item v2.ProviderArticle, index int) string {
|
||||||
|
return fmt.Sprintf("%d", item.ID)
|
||||||
|
})
|
||||||
|
if err = c.subscribeClient.Publish(c.ctx, utils.ProfitRate_Channel, strings.Join(ids, ",")); err != nil {
|
||||||
|
logrus.Errorf("通知商品利润率失败: %v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
|
provider.Status = v2.ProviderStatus_Normal
|
||||||
|
_ = c.storage.Provider().UpdateStatus(provider)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user