diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 797a2febb..d6d6bca33 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -1572,7 +1572,13 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) { storeSku.JxPrice = storeSku.JxPrice + int(actualPrice) } else if actStoreSku.TrendType == model.TrendTypeDown { storeSku.JxPrice = storeSku.JxPrice - int(actualPrice) - storeSku.Stock = checkPriceDefendOrderByPrice(db, storeSku.StoreID, storeSku.SkuID, storeSku.Stock, storeSku.JxPrice) + stock := checkPriceDefendOrderByPrice(db, storeSku.StoreID, storeSku.SkuID, storeSku.Stock, storeSku.JxPrice) + if stock != -1 { + storeSku.Stock = stock + if _, err = dao.UpdateEntity(db, storeSku, "Stock"); err != nil { + dao.Rollback(db) + } + } } if storeSku.JxPrice >= int(actStoreSku.OriginalPrice) { storeSku.JxPrice = int(actStoreSku.OriginalPrice) @@ -1586,7 +1592,7 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) { if storeSku.JxPrice <= int(minJxPrice) { storeSku.JxPrice = int(minJxPrice) } - if _, err = dao.UpdateEntity(db, storeSku, "JxPrice", "Stock"); err != nil { + if _, err = dao.UpdateEntity(db, storeSku, "JxPrice"); err != nil { dao.Rollback(db) } //C >= 2N 涨价趋势,最高涨价到无折扣 @@ -1635,7 +1641,7 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) { func checkPriceDefendOrderByPrice(db *dao.DaoDB, storeID, skuID, stock, jxPrice int) (realStock int) { priceDefends, _ := dao.GetPriceDefendOrder(db, []int{storeID}, []int{skuID}, []int{jxutils.GetDefendPriceIssue()}, 0, 0, 0) if len(priceDefends) == 0 { - return + return -1 } for _, v := range priceDefends { //如果刚好守的价和降的价一样,再判断库存够不够