- 修复GetPricePercentage的BUG

This commit is contained in:
gazebo
2019-07-18 11:54:05 +08:00
parent d0768e914b
commit c7736952b3
3 changed files with 6 additions and 6 deletions

View File

@@ -248,10 +248,10 @@ func GetPricePercentage(l model.PricePercentagePack, unitPrice int, defPricePerc
if len(l) > 0 { if len(l) > 0 {
var lastItem *model.PricePercentageItem var lastItem *model.PricePercentageItem
for _, v := range l { for _, v := range l {
lastItem = v
if v.BeginPrice > unitPrice { if v.BeginPrice > unitPrice {
break break
} }
lastItem = v
} }
if lastItem != nil { if lastItem != nil {
pricePercentage = lastItem.PricePercentage pricePercentage = lastItem.PricePercentage
@@ -265,10 +265,10 @@ func GetPricePercentageByVendorPrice(l model.PricePercentagePack, vendorPrice in
if len(l) > 0 { if len(l) > 0 {
var lastItem *model.PricePercentageItem var lastItem *model.PricePercentageItem
for _, v := range l { for _, v := range l {
lastItem = v
if CaculateSkuVendorPrice(v.BeginPrice, v.PricePercentage, 0) > vendorPrice { if CaculateSkuVendorPrice(v.BeginPrice, v.PricePercentage, 0) > vendorPrice {
break break
} }
lastItem = v
} }
if lastItem != nil { if lastItem != nil {
pricePercentage = lastItem.PricePercentage pricePercentage = lastItem.PricePercentage

View File

@@ -230,8 +230,8 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
storeSku := batchItemList[0].(*tStoreSkuFullInfo) storeSku := batchItemList[0].(*tStoreSkuFullInfo)
pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, storeSku.UnitPrice, int(storeDetail.PricePercentage)) pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, storeSku.UnitPrice, int(storeDetail.PricePercentage))
globals.SugarLogger.Debugf("skuID:%d, price:%d, pricePercentage:%d", storeSku.SkuID, storeSku.Price, pricePercentage) // globals.SugarLogger.Debugf("skuID:%d, price:%d, pricePercentage:%d", storeSku.SkuID, storeSku.Price, pricePercentage)
globals.SugarLogger.Debugf(utils.Format4Output(storeDetail.PricePercentagePackObj, false)) // globals.SugarLogger.Debugf(utils.Format4Output(storeDetail.PricePercentagePackObj, false))
updateFields := []string{model.FieldEbaiSyncStatus} updateFields := []string{model.FieldEbaiSyncStatus}
if storeSku.NameID == 0 || storeSku.EbaiSyncStatus&model.SyncFlagDeletedMask != 0 { if storeSku.NameID == 0 || storeSku.EbaiSyncStatus&model.SyncFlagDeletedMask != 0 {
if storeSku.EbaiSyncStatus&model.SyncFlagNewMask == 0 && !jxutils.IsEmptyID(storeSku.EbaiID) { if storeSku.EbaiSyncStatus&model.SyncFlagNewMask == 0 && !jxutils.IsEmptyID(storeSku.EbaiID) {

View File

@@ -307,8 +307,8 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
err = fmt.Errorf("SKUNAME%d:%s没有图片同步失败", skuItem.NameID, skuItem.Name) err = fmt.Errorf("SKUNAME%d:%s没有图片同步失败", skuItem.NameID, skuItem.Name)
} else { } else {
pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(skuItem.UnitPrice), int(storeDetail.PricePercentage)) pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(skuItem.UnitPrice), int(storeDetail.PricePercentage))
globals.SugarLogger.Debugf("skuID:%d, price:%d, pricePercentage:%d", skuItem.SkuID, skuItem.Price, pricePercentage) // globals.SugarLogger.Debugf("skuID:%d, price:%d, pricePercentage:%d", skuItem.SkuID, skuItem.Price, pricePercentage)
globals.SugarLogger.Debugf(utils.Format4Output(storeDetail.PricePercentagePackObj, false)) // globals.SugarLogger.Debugf(utils.Format4Output(storeDetail.PricePercentagePackObj, false))
foodData["name"] = jxutils.ComposeSkuName(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, mtwmapi.MaxSkuNameCharCount) foodData["name"] = jxutils.ComposeSkuName(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, mtwmapi.MaxSkuNameCharCount)
foodData["description"] = skuItem.Comment foodData["description"] = skuItem.Comment
foodData["price"] = jxutils.IntPrice2Standard(int64(jxutils.CaculateSkuVendorPrice(int(skuItem.Price), pricePercentage, skuItem.CatPricePercentage))) foodData["price"] = jxutils.IntPrice2Standard(int64(jxutils.CaculateSkuVendorPrice(int(skuItem.Price), pricePercentage, skuItem.CatPricePercentage)))