fix 获取历史价格时,排除掉价格为0的历史价格
Some checks failed
Build image / build (push) Failing after 1m19s

This commit is contained in:
timerzz 2024-06-19 21:10:27 +08:00
parent dffffd52d7
commit 8260be804b

View File

@ -132,6 +132,9 @@ func (c *Controller) saveRespData(list []coach_client.Product) error {
var historyPrice []productv1.HistoryPrice
c.db.Model(&productv1.HistoryPrice{}).Find(&historyPrice, "pid = ?", p.Pid)
if len(historyPrice) > 0 {
historyPrice = lo.Filter(historyPrice, func(item productv1.HistoryPrice, index int) bool {
return item.OriginalPrice > 0
})
lowestPrice := lo.MinBy(historyPrice, func(a productv1.HistoryPrice, b productv1.HistoryPrice) bool {
return a.OriginalPrice < b.OriginalPrice
})