Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -211,16 +211,16 @@ func CaculateSkuPrice(unitPrice int, specQuality float32, specUnit string, skuNa
|
|||||||
return unitPrice
|
return unitPrice
|
||||||
}
|
}
|
||||||
specQuality2 := RegularizeSkuQuality(specQuality, specUnit)
|
specQuality2 := RegularizeSkuQuality(specQuality, specUnit)
|
||||||
price := int(math.Round(float64(unitPrice * specQuality2 / model.SpecialSpecQuality)))
|
floatPrice := float64(unitPrice) * float64(specQuality2) / float64(model.SpecialSpecQuality)
|
||||||
// if specQuality2 < 250 {
|
// if specQuality2 < 250 {
|
||||||
// price = price * 110 / 100
|
// floatPrice = floatPrice * 110 / 100
|
||||||
// } else if specQuality2 < 500 {
|
// } else if specQuality2 < 500 {
|
||||||
// price = price * 105 / 100
|
// floatPrice = floatPrice * 105 / 100
|
||||||
// }
|
// }
|
||||||
if price <= 0 {
|
if floatPrice <= 1 {
|
||||||
price = 1
|
floatPrice = 1
|
||||||
}
|
}
|
||||||
return price
|
return int(math.Round(floatPrice))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算SKU标准价格,CaculateSkuPrice的逆过程
|
// 计算SKU标准价格,CaculateSkuPrice的逆过程
|
||||||
@@ -268,7 +268,7 @@ func CaculateSkuPriceFromVendor(vendorPrice, percentage, catPercentage int) int
|
|||||||
catPercentage = 100
|
catPercentage = 100
|
||||||
}
|
}
|
||||||
percentage = percentage * 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 {
|
if price < 0 {
|
||||||
price = 0
|
price = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,3 +126,41 @@ func TestCalcPolygonAreaAutonavi(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(strBuilder.String())
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -143,13 +143,15 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
storeParams.DeliveryRangeRadius = int(utils.Str2Int64WithDefault(store.DeliveryRange, 0))
|
storeParams.DeliveryRangeRadius = int(utils.Str2Int64WithDefault(store.DeliveryRange, 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
modifyCloseStatus := false
|
||||||
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagDeletedMask|model.SyncFlagStoreStatus) != 0 {
|
if store.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagDeletedMask|model.SyncFlagStoreStatus) != 0 {
|
||||||
|
modifyCloseStatus = true
|
||||||
_, storeParams.CloseStatus = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus))
|
_, storeParams.CloseStatus = JxStoreStatus2JdStatus(jxutils.MergeStoreStatus(store.Status, store.JdStoreStatus))
|
||||||
}
|
}
|
||||||
fillOpTimeParams(storeParams, store.GetOpTimeList())
|
fillOpTimeParams(storeParams, store.GetOpTimeList())
|
||||||
globals.SugarLogger.Debug(utils.Format4Output(storeParams, false))
|
globals.SugarLogger.Debug(utils.Format4Output(storeParams, false))
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
if err = getAPI("").UpdateStoreInfo4Open2(storeParams); err != nil {
|
if err = getAPI("").UpdateStoreInfo4Open2(storeParams, modifyCloseStatus); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,7 +210,7 @@ func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask
|
|||||||
storeParams.OutSystemID = store.VendorStoreID
|
storeParams.OutSystemID = store.VendorStoreID
|
||||||
}
|
}
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
err = getAPI("").UpdateStoreInfo4Open2(storeParams)
|
err = getAPI("").UpdateStoreInfo4Open2(storeParams, false)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}, stores)
|
}, stores)
|
||||||
@@ -300,7 +302,7 @@ func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int,
|
|||||||
StationNo: vendorStoreID,
|
StationNo: vendorStoreID,
|
||||||
Operator: ctx.GetUserName(),
|
Operator: ctx.GetUserName(),
|
||||||
CloseStatus: closeStatus,
|
CloseStatus: closeStatus,
|
||||||
})
|
}, true)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -335,7 +337,7 @@ func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int,
|
|||||||
}
|
}
|
||||||
fillOpTimeParams(params, opTimeList)
|
fillOpTimeParams(params, opTimeList)
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
err = getAPI("").UpdateStoreInfo4Open2(params)
|
err = getAPI("").UpdateStoreInfo4Open2(params, false)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -457,7 +459,7 @@ func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStor
|
|||||||
StationNo: vendorStoreID,
|
StationNo: vendorStoreID,
|
||||||
Operator: ctx.GetUserName(),
|
Operator: ctx.GetUserName(),
|
||||||
OutSystemID: utils.Int2Str(int(storeID)),
|
OutSystemID: utils.Int2Str(int(storeID)),
|
||||||
})
|
}, false)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user