This commit is contained in:
苏尹岚
2020-08-17 18:24:44 +08:00
parent 5a659f694b
commit ccbe089f96
8 changed files with 167 additions and 24 deletions

View File

@@ -1557,6 +1557,7 @@ 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)
}
if storeSku.JxPrice >= int(actStoreSku.OriginalPrice) {
storeSku.JxPrice = int(actStoreSku.OriginalPrice)
@@ -1570,7 +1571,7 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) {
if storeSku.JxPrice <= int(minJxPrice) {
storeSku.JxPrice = int(minJxPrice)
}
if _, err = dao.UpdateEntity(db, storeSku, "JxPrice"); err != nil {
if _, err = dao.UpdateEntity(db, storeSku, "JxPrice", "Stock"); err != nil {
dao.Rollback(db)
}
//C >= 2N 涨价趋势,最高涨价到无折扣
@@ -1615,3 +1616,26 @@ 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
}
for _, v := range priceDefends {
//如果刚好守的价和降的价一样,再判断库存够不够
if v.DefendPrice <= int64(jxPrice) {
if v.Count <= stock {
stock -= v.Count
v.IsSuccess = model.YES
v.RealPrice = int64(jxPrice)
dao.UpdateEntity(db, v, "IsSuccess", "RealPrice")
} else {
continue
}
} else {
continue
}
}
return stock
}