活动平台价直接使用当前存的,不重新计算
不同步的门店或禁用的门店不创建活动
This commit is contained in:
@@ -72,6 +72,18 @@ func init() {
|
|||||||
partner.InitActManager(FixedActManager)
|
partner.InitActManager(FixedActManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVendorPriceFromStoreSkuBind(bind *model.StoreSkuBind, vendorID int) (vendorPrice int) {
|
||||||
|
switch vendorID {
|
||||||
|
case model.VendorIDJD:
|
||||||
|
vendorPrice = bind.JdPrice
|
||||||
|
case model.VendorIDMTWM:
|
||||||
|
vendorPrice = bind.MtwmPrice
|
||||||
|
case model.VendorIDEBAI:
|
||||||
|
vendorPrice = bind.EbaiPrice
|
||||||
|
}
|
||||||
|
return vendorPrice
|
||||||
|
}
|
||||||
|
|
||||||
func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Act, vendorIDs []int, actStoreSku []*ActStoreSkuParam) (validVendorIDs []int, actStoreSkuList []*model.ActStoreSku, actStoreSkuMapList []*model.ActStoreSkuMap, err error) {
|
func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Act, vendorIDs []int, actStoreSku []*ActStoreSkuParam) (validVendorIDs []int, actStoreSkuList []*model.ActStoreSku, actStoreSkuMapList []*model.ActStoreSkuMap, err error) {
|
||||||
wholeValidVendorMap := make(map[int]int)
|
wholeValidVendorMap := make(map[int]int)
|
||||||
if len(actStoreSku) > 0 {
|
if len(actStoreSku) > 0 {
|
||||||
@@ -119,59 +131,62 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
|||||||
for _, vendorID := range vendorIDs {
|
for _, vendorID := range vendorIDs {
|
||||||
storeDetail, err2 := dao.GetStoreDetail(db, storeID, vendorID)
|
storeDetail, err2 := dao.GetStoreDetail(db, storeID, vendorID)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
for _, v := range oneStoreSkuParam {
|
if storeDetail.IsSync != 0 && storeDetail.Status != model.StoreStatusDisabled {
|
||||||
validVendorMap[vendorID] = 1
|
for _, v := range oneStoreSkuParam {
|
||||||
validSkuMap[v.SkuID] = 1
|
validVendorMap[vendorID] = 1
|
||||||
v.ActID = act.ID
|
validSkuMap[v.SkuID] = 1
|
||||||
actSkuMap := &model.ActStoreSkuMap{
|
v.ActID = act.ID
|
||||||
ActID: act.ID,
|
actSkuMap := &model.ActStoreSkuMap{
|
||||||
StoreID: storeID,
|
ActID: act.ID,
|
||||||
SkuID: v.SkuID,
|
StoreID: storeID,
|
||||||
VendorID: vendorID,
|
SkuID: v.SkuID,
|
||||||
}
|
VendorID: vendorID,
|
||||||
v.OriginalPrice = actSkuMap.VendorPrice
|
|
||||||
storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)]
|
|
||||||
if storeSkuInfo != nil {
|
|
||||||
jxPrice := storeSkuInfo.Price
|
|
||||||
pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, jxPrice, int(storeDetail.PricePercentage))
|
|
||||||
actSkuMap.VendorPrice = int64(jxutils.CaculateSkuVendorPrice(jxPrice, pricePercentage))
|
|
||||||
v.OriginalPrice = int64(jxPrice)
|
|
||||||
}
|
|
||||||
var err2 error
|
|
||||||
if act.Type != model.ActSkuFake {
|
|
||||||
if storeSkuInfo == nil {
|
|
||||||
v.ErrMsg = fmt.Sprintf("门店:%d没有关注商品:%d", v.StoreID, v.SkuID)
|
|
||||||
wrongSkuList = append(wrongSkuList, v)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
actSkuMap.SyncStatus = model.SyncFlagNewMask
|
v.OriginalPrice = actSkuMap.VendorPrice
|
||||||
if v.ActPrice != 0 {
|
storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)]
|
||||||
actSkuMap.ActualActPrice = v.ActPrice
|
if storeSkuInfo != nil {
|
||||||
} else {
|
jxPrice := storeSkuInfo.Price
|
||||||
percentage := act.PricePercentage
|
// pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, jxPrice, int(storeDetail.PricePercentage))
|
||||||
if v.PricePercentage != 0 {
|
// actSkuMap.VendorPrice = int64(jxutils.CaculateSkuVendorPrice(jxPrice, pricePercentage))
|
||||||
percentage = v.PricePercentage
|
actSkuMap.VendorPrice = int64(getVendorPriceFromStoreSkuBind(storeSkuInfo, vendorID))
|
||||||
|
v.OriginalPrice = int64(jxPrice)
|
||||||
|
}
|
||||||
|
var err2 error
|
||||||
|
if act.Type != model.ActSkuFake {
|
||||||
|
if storeSkuInfo == nil {
|
||||||
|
v.ErrMsg = fmt.Sprintf("门店:%d没有关注商品:%d", v.StoreID, v.SkuID)
|
||||||
|
wrongSkuList = append(wrongSkuList, v)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
actSkuMap.ActualActPrice = int64(jxutils.CaculateSkuVendorPrice(int(actSkuMap.VendorPrice), percentage))
|
actSkuMap.SyncStatus = model.SyncFlagNewMask
|
||||||
if actSkuMap.ActualActPrice > 10 {
|
if v.ActPrice != 0 {
|
||||||
actSkuMap.ActualActPrice = int64(math.Round(float64(actSkuMap.ActualActPrice)/10) * 10)
|
actSkuMap.ActualActPrice = v.ActPrice
|
||||||
|
} else {
|
||||||
|
percentage := act.PricePercentage
|
||||||
|
if v.PricePercentage != 0 {
|
||||||
|
percentage = v.PricePercentage
|
||||||
|
}
|
||||||
|
actSkuMap.ActualActPrice = int64(jxutils.CaculateSkuVendorPrice(int(actSkuMap.VendorPrice), percentage))
|
||||||
|
if actSkuMap.ActualActPrice > 10 {
|
||||||
|
actSkuMap.ActualActPrice = int64(math.Round(float64(actSkuMap.ActualActPrice)/10) * 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if actSkuMap.ActualActPrice <= 0 {
|
||||||
|
actSkuMap.ActualActPrice = 1
|
||||||
|
}
|
||||||
|
if err2 = checkDiscountValidation(act.Type, float64(actSkuMap.ActualActPrice)*100/float64(actSkuMap.VendorPrice)); err2 != nil {
|
||||||
|
v.ErrMsg = err2.Error()
|
||||||
|
v.ActualActPrice = actSkuMap.ActualActPrice
|
||||||
|
wrongSkuList = append(wrongSkuList, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if actSkuMap.ActualActPrice <= 0 {
|
if err2 == nil {
|
||||||
actSkuMap.ActualActPrice = 1
|
dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName())
|
||||||
}
|
actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap)
|
||||||
if err2 = checkDiscountValidation(act.Type, float64(actSkuMap.ActualActPrice)*100/float64(actSkuMap.VendorPrice)); err2 != nil {
|
|
||||||
v.ErrMsg = err2.Error()
|
|
||||||
v.ActualActPrice = actSkuMap.ActualActPrice
|
|
||||||
wrongSkuList = append(wrongSkuList, v)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err2 == nil {
|
wholeValidVendorMap[vendorID] = 1
|
||||||
dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName())
|
|
||||||
actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
wholeValidVendorMap[vendorID] = 1
|
|
||||||
} else if !dao.IsNoRowsError(err) {
|
} else if !dao.IsNoRowsError(err) {
|
||||||
return nil, nil, nil, err
|
return nil, nil, nil, err
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user