From 116443f58285f91dc36f11f763cf6668b9a0e60a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 18 Aug 2020 15:15:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=8D=E4=BB=B7=E6=97=B6=E6=B2=A1=E5=BE=97?= =?UTF-8?q?=E5=AE=88=E4=BB=B7=E4=B8=8D=E5=8F=98=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/act/act.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 { //如果刚好守的价和降的价一样,再判断库存够不够