活动平台价直接使用当前存的,不重新计算
不同步的门店或禁用的门店不创建活动
This commit is contained in:
@@ -72,6 +72,18 @@ func init() {
|
||||
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) {
|
||||
wholeValidVendorMap := make(map[int]int)
|
||||
if len(actStoreSku) > 0 {
|
||||
@@ -119,59 +131,62 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac
|
||||
for _, vendorID := range vendorIDs {
|
||||
storeDetail, err2 := dao.GetStoreDetail(db, storeID, vendorID)
|
||||
if err = err2; err == nil {
|
||||
for _, v := range oneStoreSkuParam {
|
||||
validVendorMap[vendorID] = 1
|
||||
validSkuMap[v.SkuID] = 1
|
||||
v.ActID = act.ID
|
||||
actSkuMap := &model.ActStoreSkuMap{
|
||||
ActID: act.ID,
|
||||
StoreID: storeID,
|
||||
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
|
||||
if storeDetail.IsSync != 0 && storeDetail.Status != model.StoreStatusDisabled {
|
||||
for _, v := range oneStoreSkuParam {
|
||||
validVendorMap[vendorID] = 1
|
||||
validSkuMap[v.SkuID] = 1
|
||||
v.ActID = act.ID
|
||||
actSkuMap := &model.ActStoreSkuMap{
|
||||
ActID: act.ID,
|
||||
StoreID: storeID,
|
||||
SkuID: v.SkuID,
|
||||
VendorID: vendorID,
|
||||
}
|
||||
actSkuMap.SyncStatus = model.SyncFlagNewMask
|
||||
if v.ActPrice != 0 {
|
||||
actSkuMap.ActualActPrice = v.ActPrice
|
||||
} else {
|
||||
percentage := act.PricePercentage
|
||||
if v.PricePercentage != 0 {
|
||||
percentage = v.PricePercentage
|
||||
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))
|
||||
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))
|
||||
if actSkuMap.ActualActPrice > 10 {
|
||||
actSkuMap.ActualActPrice = int64(math.Round(float64(actSkuMap.ActualActPrice)/10) * 10)
|
||||
actSkuMap.SyncStatus = model.SyncFlagNewMask
|
||||
if v.ActPrice != 0 {
|
||||
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 {
|
||||
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 err2 == nil {
|
||||
dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName())
|
||||
actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap)
|
||||
}
|
||||
}
|
||||
if err2 == nil {
|
||||
dao.WrapAddIDCULDEntity(actSkuMap, ctx.GetUserName())
|
||||
actStoreSkuMapList = append(actStoreSkuMapList, actSkuMap)
|
||||
}
|
||||
wholeValidVendorMap[vendorID] = 1
|
||||
}
|
||||
wholeValidVendorMap[vendorID] = 1
|
||||
} else if !dao.IsNoRowsError(err) {
|
||||
return nil, nil, nil, err
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user