- 门店价限制不能为负数

- 京东门店价限制为最少一分
This commit is contained in:
gazebo
2019-04-17 15:27:43 +08:00
parent 2cde3ba1b5
commit bfc3b5f945
2 changed files with 14 additions and 3 deletions

View File

@@ -178,7 +178,11 @@ func GetSliceLen(list interface{}) int {
}
func CaculateSkuVendorPrice(price int, percentage int) int {
return int(math.Round(float64(price*percentage) / 100))
storePrice := int(math.Round(float64(price*percentage) / 100))
if storePrice < 0 {
storePrice = 0
}
return storePrice
}
// 生成一个不重复的临时ID

View File

@@ -83,7 +83,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
if storeSku.JdSyncStatus&(model.SyncFlagPriceMask|model.SyncFlagNewMask) != 0 {
skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{
OutSkuId: utils.Int2Str(storeSku.SkuID),
Price: jxutils.CaculateSkuVendorPrice(storeSku.Price, storeSku.PricePercentage),
Price: constrainPrice(jxutils.CaculateSkuVendorPrice(storeSku.Price, storeSku.PricePercentage)),
})
}
if storeSku.JdSyncStatus&(model.SyncFlagSaleMask|model.SyncFlagNewMask) != 0 {
@@ -215,7 +215,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
if storeSku.SkuSyncStatus&(model.SyncFlagPriceMask|model.SyncFlagNewMask) != 0 {
skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{
OutSkuId: utils.Int2Str(storeSku.ID),
Price: jxutils.CaculateSkuVendorPrice(int(storeSku.Price), int(storeDetail.PricePercentage)),
Price: constrainPrice(jxutils.CaculateSkuVendorPrice(int(storeSku.Price), int(storeDetail.PricePercentage))),
})
}
if storeSku.SkuSyncStatus&(model.SyncFlagSaleMask|model.SyncFlagNewMask) != 0 {
@@ -271,3 +271,10 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks
func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
return hint, err
}
func constrainPrice(price int) int {
if price <= 0 {
price = 1
}
return price
}