Merge remote-tracking branch 'origin/mark' into su
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
"git.rosy.net.cn/jx-callback/business/jxutils/netprinter"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
|
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
|
||||||
@@ -19,7 +20,9 @@ func (c *OrderManager) OnNewFakeJdOrder(vendorOrderID string) (err error) {
|
|||||||
utils.CallFuncAsync(func() {
|
utils.CallFuncAsync(func() {
|
||||||
orderInfo, err := api.FakeJdAPI.FakeQuerySingleOrderRaw(vendorOrderID)
|
orderInfo, err := api.FakeJdAPI.FakeQuerySingleOrderRaw(vendorOrderID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = c.notifyNewFakeJdOrder(jd.Map2Order(orderInfo))
|
order := jd.Map2Order(orderInfo)
|
||||||
|
jxutils.RefreshOrderSkuRelated(order)
|
||||||
|
err = c.notifyNewFakeJdOrder(order)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Warnf("OnNewFakeJdOrder failed with err:%v", err)
|
globals.SugarLogger.Warnf("OnNewFakeJdOrder failed with err:%v", err)
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ func CaculateUnitPrice(skuPrice int, specQuality float32, specUnit string, skuNa
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ConstrainPricePercentage(percentage int) int {
|
func ConstrainPricePercentage(percentage int) int {
|
||||||
if percentage <= model.MinVendorPricePercentage || percentage >= model.MaxVendorPricePercentage {
|
if percentage < model.MinVendorPricePercentage || percentage > model.MaxVendorPricePercentage {
|
||||||
percentage = model.DefVendorPricePercentage
|
percentage = model.DefVendorPricePercentage
|
||||||
}
|
}
|
||||||
return percentage
|
return percentage
|
||||||
@@ -271,8 +271,8 @@ func CaculateSkuVendorPrice(price, percentage, priceAdd int) (vendorPrice int) {
|
|||||||
func CaculateSkuPriceFromVendor(vendorPrice, percentage, priceAdd int) (price int) {
|
func CaculateSkuPriceFromVendor(vendorPrice, percentage, priceAdd int) (price int) {
|
||||||
percentage = ConstrainPricePercentage(percentage)
|
percentage = ConstrainPricePercentage(percentage)
|
||||||
price = int(math.Round(float64(vendorPrice-priceAdd) * 100 / float64(percentage)))
|
price = int(math.Round(float64(vendorPrice-priceAdd) * 100 / float64(percentage)))
|
||||||
if price < 0 {
|
if price < 1 {
|
||||||
price = 0
|
price = 1
|
||||||
}
|
}
|
||||||
return price
|
return price
|
||||||
}
|
}
|
||||||
@@ -330,6 +330,12 @@ func CaculatePriceByPricePack(l model.PricePercentagePack, defPricePercentage, p
|
|||||||
return CaculateSkuVendorPrice(price, pricePercentage, priceAdd)
|
return CaculateSkuVendorPrice(price, pricePercentage, priceAdd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CaculateJxPriceByPricePack(l model.PricePercentagePack, defPricePercentage, vendorPrice int) (jxPrice int) {
|
||||||
|
pricePercentage, priceAdd := GetPricePercentageByVendorPrice(l, vendorPrice, defPricePercentage)
|
||||||
|
jxPrice = CaculateSkuPriceFromVendor(vendorPrice, pricePercentage, priceAdd)
|
||||||
|
return jxPrice
|
||||||
|
}
|
||||||
|
|
||||||
func ConstrainPayPercentage(payPerCentage int) int {
|
func ConstrainPayPercentage(payPerCentage int) int {
|
||||||
if payPerCentage <= 50 {
|
if payPerCentage <= 50 {
|
||||||
payPerCentage = 70
|
payPerCentage = 70
|
||||||
|
|||||||
@@ -214,5 +214,60 @@ func TestGetPricePercentage(t *testing.T) {
|
|||||||
t.Errorf("price:%d, defPricePercentage:%d, expected pricePercentage:%d, priceAdd:%d, actual pricePercentage:%d, priceAdd:%d",
|
t.Errorf("price:%d, defPricePercentage:%d, expected pricePercentage:%d, priceAdd:%d, actual pricePercentage:%d, priceAdd:%d",
|
||||||
v[2], v[3], v[0], v[1], pricePercentage, priceAdd)
|
v[2], v[3], v[0], v[1], pricePercentage, priceAdd)
|
||||||
}
|
}
|
||||||
|
t.Logf("%d %d,%d,%d\n", CaculateSkuVendorPrice(v[2], pricePercentage, priceAdd), v[2], pricePercentage, priceAdd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCaculateJxPriceByPricePack(t *testing.T) {
|
||||||
|
type tTestInfo struct {
|
||||||
|
DesiredPrice int
|
||||||
|
UnitPrice int
|
||||||
|
SpecQuality float32
|
||||||
|
SpecUnit string
|
||||||
|
Unit string
|
||||||
|
}
|
||||||
|
|
||||||
|
l := []*model.PricePercentageItem{
|
||||||
|
&model.PricePercentageItem{
|
||||||
|
BeginPrice: 0,
|
||||||
|
PricePercentage: 0,
|
||||||
|
PriceAdd: 0,
|
||||||
|
},
|
||||||
|
&model.PricePercentageItem{
|
||||||
|
BeginPrice: 10,
|
||||||
|
PricePercentage: 10,
|
||||||
|
PriceAdd: 1,
|
||||||
|
},
|
||||||
|
&model.PricePercentageItem{
|
||||||
|
BeginPrice: 20,
|
||||||
|
PricePercentage: 20,
|
||||||
|
PriceAdd: 2,
|
||||||
|
},
|
||||||
|
&model.PricePercentageItem{
|
||||||
|
BeginPrice: 30,
|
||||||
|
PricePercentage: 30,
|
||||||
|
PriceAdd: 3,
|
||||||
|
},
|
||||||
|
&model.PricePercentageItem{
|
||||||
|
BeginPrice: 60,
|
||||||
|
PricePercentage: 60,
|
||||||
|
PriceAdd: 6,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range [][]int{
|
||||||
|
[]int{1, 1, 88},
|
||||||
|
[]int{1, 1, 0},
|
||||||
|
[]int{40, 15, 0},
|
||||||
|
[]int{25, 7, 0},
|
||||||
|
[]int{10, 2, 0},
|
||||||
|
[]int{60, 42, 0},
|
||||||
|
[]int{1000, 606, 10},
|
||||||
|
} {
|
||||||
|
jxPrice := CaculateJxPriceByPricePack(l, v[2], v[1])
|
||||||
|
if CaculatePriceByPricePack(l, v[2], jxPrice) != v[1] {
|
||||||
|
t.Fatalf("vendorPrice:%d, defPercentage:%d, expected:%d, actual:%d", v[1], v[2], v[0], jxPrice)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ func GetStoreOrderSkuList(db *DaoDB, storeIDs []int, finishedAtBegin, finishedAt
|
|||||||
FROM order_sku t1
|
FROM order_sku t1
|
||||||
JOIN goods_order t2 ON t2.vendor_order_id = t1.vendor_order_id AND t2.vendor_id = t1.vendor_id
|
JOIN goods_order t2 ON t2.vendor_order_id = t1.vendor_order_id AND t2.vendor_id = t1.vendor_id
|
||||||
LEFT JOIN store t3 ON t3.id = IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id)
|
LEFT JOIN store t3 ON t3.id = IF(t2.jx_store_id > 0, t2.jx_store_id, t2.store_id)
|
||||||
WHERE t2.order_created_at >= ? AND t2.order_created_at <= ?`
|
WHERE t2.order_finished_at >= ? AND t2.order_finished_at <= ?`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
finishedAtBegin,
|
finishedAtBegin,
|
||||||
finishedAtEnd,
|
finishedAtEnd,
|
||||||
|
|||||||
Reference in New Issue
Block a user