getstoresskus查询趋势
This commit is contained in:
@@ -1529,12 +1529,12 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
storeSku = storeSkus[0]
|
storeSku = storeSkus[0]
|
||||||
shouldStockOut = utils.Float64TwoInt64(math.Ceil(float64(storeSku.Stock) / float64(60))) //每个时间点应出货 = 总库存/60 = N
|
shouldStockOut = utils.Float64TwoInt64(math.Ceil(float64(storeSku.Stock) / float64(60))) //每个时间点应出货 = 总库存/60 = N
|
||||||
actualStockOut int64 //每个时间点实际出货 = C
|
actualStockOut int64 //每个时间点实际出货 = C
|
||||||
pricePercentage float64 //每次涨跌值为 原价的 2%,即原价100,每个时间点降价为2,涨价也为2
|
pricePercentage float64 //每次涨跌值为 原价的 2%,即原价100,每个时间点降价为2,涨价也为2
|
||||||
actualPricePercentage float64
|
actualPrice int64
|
||||||
minJxPrice int64
|
minJxPrice int64
|
||||||
)
|
)
|
||||||
if storeSku.Stock == 0 {
|
if storeSku.Stock == 0 {
|
||||||
continue
|
continue
|
||||||
@@ -1552,23 +1552,22 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) {
|
|||||||
//第一档时间内
|
//第一档时间内
|
||||||
if (time.Now().Hour() >= 10 && time.Now().Hour() < 20) || (time.Now().Hour() == 20 && time.Now().Minute() < 1) {
|
if (time.Now().Hour() >= 10 && time.Now().Hour() < 20) || (time.Now().Hour() == 20 && time.Now().Minute() < 1) {
|
||||||
pricePercentage = 0.02
|
pricePercentage = 0.02
|
||||||
|
actualPrice = utils.Float64TwoInt64(float64(actStoreSku.OriginalPrice) * pricePercentage)
|
||||||
if actStoreSku.TrendType == model.TrendTypeUp {
|
if actStoreSku.TrendType == model.TrendTypeUp {
|
||||||
actualPricePercentage = float64(actStoreSku.OriginalPrice) * (float64(1) + pricePercentage)
|
storeSku.JxPrice = storeSku.JxPrice + int(actualPrice)
|
||||||
} else if actStoreSku.TrendType == model.TrendTypeDown {
|
} else if actStoreSku.TrendType == model.TrendTypeDown {
|
||||||
actualPricePercentage = float64(actStoreSku.OriginalPrice) * (float64(1) - pricePercentage)
|
storeSku.JxPrice = storeSku.JxPrice - int(actualPrice)
|
||||||
} else {
|
|
||||||
actualPricePercentage = 1
|
|
||||||
}
|
}
|
||||||
if utils.Float64TwoInt64(float64(storeSku.JxPrice)*actualPricePercentage) >= actStoreSku.OriginalPrice {
|
if storeSku.JxPrice >= int(actStoreSku.OriginalPrice) {
|
||||||
storeSku.JxPrice = int(actStoreSku.OriginalPrice)
|
storeSku.JxPrice = int(actStoreSku.OriginalPrice)
|
||||||
}
|
}
|
||||||
//判断活动的折扣类型是最低价还是最低折扣
|
//判断活动的折扣类型是最低价还是最低折扣(第一档)
|
||||||
if act.DiscountType == model.ActDiscountTypePrice {
|
if act.DiscountType == model.ActDiscountTypePrice {
|
||||||
minJxPrice = int64(act.DiscountValue1)
|
minJxPrice = int64(act.DiscountValue1)
|
||||||
} else if act.DiscountType == model.ActDiscountTypePercentage {
|
} else if act.DiscountType == model.ActDiscountTypePercentage {
|
||||||
minJxPrice = actStoreSku.OriginalPrice * int64(act.DiscountValue1) / 100
|
minJxPrice = actStoreSku.OriginalPrice * int64(act.DiscountValue1) / 100
|
||||||
}
|
}
|
||||||
if utils.Float64TwoInt64(float64(storeSku.JxPrice)*actualPricePercentage) <= minJxPrice {
|
if storeSku.JxPrice <= int(minJxPrice) {
|
||||||
storeSku.JxPrice = int(minJxPrice)
|
storeSku.JxPrice = int(minJxPrice)
|
||||||
}
|
}
|
||||||
if _, err = dao.UpdateEntity(db, storeSku, "JxPrice"); err != nil {
|
if _, err = dao.UpdateEntity(db, storeSku, "JxPrice"); err != nil {
|
||||||
@@ -1582,13 +1581,14 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) {
|
|||||||
} else {
|
} else {
|
||||||
actStoreSku.TrendType = model.TrendTypeNothing
|
actStoreSku.TrendType = model.TrendTypeNothing
|
||||||
}
|
}
|
||||||
if _, err = dao.UpdateEntity(db, actStoreSku, "TrendType"); err != nil {
|
actStoreSku.TrendPrcie = int(actualPrice)
|
||||||
|
if _, err = dao.UpdateEntity(db, actStoreSku, "TrendType", "TrendPrcie"); err != nil {
|
||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
}
|
}
|
||||||
} else { //第二档时间内
|
} else { //第二档时间内
|
||||||
pricePercentage = 0.1
|
pricePercentage = 0.1
|
||||||
actualPricePercentage = float64(actStoreSku.OriginalPrice) * (float64(1) - pricePercentage)
|
actualPrice = utils.Float64TwoInt64(float64(actStoreSku.OriginalPrice) * pricePercentage)
|
||||||
//判断活动的折扣类型是最低价还是最低折扣
|
//判断活动的折扣类型是最低价还是最低折扣(第二档)
|
||||||
if act.DiscountType == model.ActDiscountTypePrice {
|
if act.DiscountType == model.ActDiscountTypePrice {
|
||||||
minJxPrice = int64(act.DiscountValue2)
|
minJxPrice = int64(act.DiscountValue2)
|
||||||
} else if act.DiscountType == model.ActDiscountTypePercentage {
|
} else if act.DiscountType == model.ActDiscountTypePercentage {
|
||||||
@@ -1599,10 +1599,12 @@ func ChangeJxPriceByDiscountAct(ctx *jxcontext.Context) {
|
|||||||
} else {
|
} else {
|
||||||
actStoreSku.TrendType = model.TrendTypeDown
|
actStoreSku.TrendType = model.TrendTypeDown
|
||||||
}
|
}
|
||||||
if _, err = dao.UpdateEntity(db, actStoreSku, "TrendType"); err != nil {
|
actStoreSku.TrendPrcie = int(actualPrice)
|
||||||
|
if _, err = dao.UpdateEntity(db, actStoreSku, "TrendType", "TrendPrcie"); err != nil {
|
||||||
dao.Rollback(db)
|
dao.Rollback(db)
|
||||||
}
|
}
|
||||||
if utils.Float64TwoInt64(float64(storeSku.JxPrice)*actualPricePercentage) <= minJxPrice {
|
storeSku.JxPrice = storeSku.JxPrice - int(actualPrice)
|
||||||
|
if storeSku.JxPrice <= int(minJxPrice) {
|
||||||
storeSku.JxPrice = int(minJxPrice)
|
storeSku.JxPrice = int(minJxPrice)
|
||||||
}
|
}
|
||||||
if _, err = dao.UpdateEntity(db, storeSku, "JxPrice"); err != nil {
|
if _, err = dao.UpdateEntity(db, storeSku, "JxPrice"); err != nil {
|
||||||
|
|||||||
@@ -265,7 +265,9 @@ type StoreSkuExt struct {
|
|||||||
EarningPrice int `json:"earningPrice"`
|
EarningPrice int `json:"earningPrice"`
|
||||||
EarningActID int `orm:"column(earning_act_id)" json:"earningActID"`
|
EarningActID int `orm:"column(earning_act_id)" json:"earningActID"`
|
||||||
|
|
||||||
EclpID string `orm:"column(eclp_id)" json:"eclpID"`
|
EclpID string `orm:"column(eclp_id)" json:"eclpID"`
|
||||||
|
TrendType int `json:"trendType"`
|
||||||
|
TrendPrice int `json:"trendPrice"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SkuNameAndPlace struct {
|
type SkuNameAndPlace struct {
|
||||||
@@ -1363,6 +1365,8 @@ func UpdateActPrice4StoreSkuNameNew(db *DaoDB, storeIDs, skuIDs []int, skuNamesI
|
|||||||
v.ActID = actStoreSku.ActID
|
v.ActID = actStoreSku.ActID
|
||||||
v.ActType = actStoreSku.Type
|
v.ActType = actStoreSku.Type
|
||||||
v.EarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.ActPrice), skuName.PayPercentage))
|
v.EarningPrice = int(jxutils.CaculateSkuEarningPrice(int64(v.BindPrice), int64(v.ActPrice), skuName.PayPercentage))
|
||||||
|
v.TrendType = actStoreSku.TrendType
|
||||||
|
v.TrendPrice = actStoreSku.TrendPrcie
|
||||||
}
|
}
|
||||||
if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
|
if actStoreSku := actStoreSkuMap4EarningPrice.GetActStoreSku(skuName.StoreID, v.SkuID, -1); actStoreSku != nil {
|
||||||
v.EarningPrice = int(actStoreSku.EarningPrice)
|
v.EarningPrice = int(actStoreSku.EarningPrice)
|
||||||
|
|||||||
Reference in New Issue
Block a user