diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index c427da090..836ccf94e 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -211,16 +211,16 @@ func CaculateSkuPrice(unitPrice int, specQuality float32, specUnit string, skuNa return unitPrice } specQuality2 := RegularizeSkuQuality(specQuality, specUnit) - price := int(math.Round(float64(unitPrice * specQuality2 / model.SpecialSpecQuality))) + floatPrice := float64(unitPrice) * float64(specQuality2) / float64(model.SpecialSpecQuality) // if specQuality2 < 250 { - // price = price * 110 / 100 + // floatPrice = floatPrice * 110 / 100 // } else if specQuality2 < 500 { - // price = price * 105 / 100 + // floatPrice = floatPrice * 105 / 100 // } - if price <= 0 { - price = 1 + if floatPrice <= 1 { + floatPrice = 1 } - return price + return int(math.Round(floatPrice)) } // 计算SKU标准价格,CaculateSkuPrice的逆过程 @@ -268,7 +268,7 @@ func CaculateSkuPriceFromVendor(vendorPrice, percentage, catPercentage int) int catPercentage = 100 } percentage = percentage * catPercentage / 100 - price := int(math.Round(float64(vendorPrice * 100 / percentage))) + price := int(math.Round(float64(vendorPrice) * 100 / float64(percentage))) if price < 0 { price = 0 } diff --git a/business/jxutils/jxutils_cms_test.go b/business/jxutils/jxutils_cms_test.go index 2782fbf6b..d447b160e 100644 --- a/business/jxutils/jxutils_cms_test.go +++ b/business/jxutils/jxutils_cms_test.go @@ -126,3 +126,41 @@ func TestCalcPolygonAreaAutonavi(t *testing.T) { } t.Log(strBuilder.String()) } + +func TestCaculateSkuPrice(t *testing.T) { + type tTestInfo struct { + DesiredPrice int + UnitPrice int + SpecQuality float32 + SpecUnit string + Unit string + } + for _, v := range []*tTestInfo{ + &tTestInfo{ + DesiredPrice: 458, + UnitPrice: 915, + SpecQuality: 250, + SpecUnit: "g", + Unit: "份", + }, + &tTestInfo{ + DesiredPrice: 123, + UnitPrice: 123, + SpecQuality: 888, + SpecUnit: "g", + Unit: "个", + }, + &tTestInfo{ + DesiredPrice: 1, + UnitPrice: 5, + SpecQuality: 1, + SpecUnit: "g", + Unit: "份", + }, + } { + price := CaculateSkuPrice(v.UnitPrice, v.SpecQuality, v.SpecUnit, v.Unit) + if price != v.DesiredPrice { + t.Errorf("price:%d,desiredPrice:%d", price, v.DesiredPrice) + } + } +} diff --git a/business/partner/purchase/jd/store.go b/business/partner/purchase/jd/store.go index 7cf04dcad..86de5ca96 100644 --- a/business/partner/purchase/jd/store.go +++ b/business/partner/purchase/jd/store.go @@ -143,13 +143,15 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin storeParams.DeliveryRangeRadius = int(utils.Str2Int64WithDefault(store.DeliveryRange, 0)) } } + modifyCloseStatus := false if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagDeletedMask|model.SyncFlagStoreStatus) != 0 { + modifyCloseStatus = true _, storeParams.CloseStatus = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus)) } fillOpTimeParams(storeParams, store.GetOpTimeList()) globals.SugarLogger.Debug(utils.Format4Output(storeParams, false)) if globals.EnableJdStoreWrite { - if err = getAPI("").UpdateStoreInfo4Open2(storeParams); err != nil { + if err = getAPI("").UpdateStoreInfo4Open2(storeParams, modifyCloseStatus); err != nil { return err } } @@ -208,7 +210,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask storeParams.OutSystemID = store.VendorStoreID } if globals.EnableJdStoreWrite { - err = getAPI("").UpdateStoreInfo4Open2(storeParams) + err = getAPI("").UpdateStoreInfo4Open2(storeParams, false) } return nil, err }, stores) @@ -300,7 +302,7 @@ func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, StationNo: vendorStoreID, Operator: ctx.GetUserName(), CloseStatus: closeStatus, - }) + }, true) } return err } @@ -335,7 +337,7 @@ func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, } fillOpTimeParams(params, opTimeList) if globals.EnableJdStoreWrite { - err = getAPI("").UpdateStoreInfo4Open2(params) + err = getAPI("").UpdateStoreInfo4Open2(params, false) } return err } @@ -457,7 +459,7 @@ func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStor StationNo: vendorStoreID, Operator: ctx.GetUserName(), OutSystemID: utils.Int2Str(int(storeID)), - }) + }, false) } return err }