活动
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -268,6 +268,12 @@ func Init() {
|
||||
act.ChangeJxPriceByDiscountAct(jxcontext.AdminCtx)
|
||||
}, discountActJxList)
|
||||
|
||||
ScheduleTimerFunc("CreateOrderByPriceDefend", func() {
|
||||
localjx.CreateOrderByPriceDefend(jxcontext.AdminCtx)
|
||||
}, []string{
|
||||
"22:00:00",
|
||||
})
|
||||
|
||||
if beego.BConfig.RunMode == "jxgy" {
|
||||
ScheduleTimerFunc("SyncMatterC4ToGy", func() {
|
||||
cms.SyncMatterC4ToGy(jxcontext.AdminCtx, true, true)
|
||||
|
||||
Reference in New Issue
Block a user