stock.go 594 B

123456789101112131415161718192021222324252627
  1. package dao
  2. import (
  3. "go-common/app/service/openplatform/ticket-item/model"
  4. "go-common/library/log"
  5. )
  6. // StockChanged 检查票价下库存是否有变动
  7. func (d *Dao) StockChanged(ids []int64) bool {
  8. if ids == nil {
  9. return false
  10. }
  11. var stocks []model.Stock
  12. if err := d.db.Select("total_stock, stock").Where("sku_id IN (?)", ids).Find(&stocks).Error; err != nil {
  13. log.Error("获取票价库存信息失败:%s", err)
  14. return true
  15. }
  16. for _, v := range stocks {
  17. if (v.TotalStock - v.Stock) != 0 {
  18. log.Error("票价存在库存有变动")
  19. return true
  20. }
  21. }
  22. return false
  23. }