Accept Merge Request #3: (lyb -> master)
Merge Request: 实时从饿了么平台API获取数据。 Created By: @LYB-Rosy Accepted By: @XJH-Rosy URL: https://coding.net/u/XJH-Rosy/p/jx-callback/git/merge/3
This commit is contained in:
@@ -192,9 +192,28 @@ func (c *OrderController) GetOrder(orderID string) (order *model.GoodsOrder, err
|
||||
}
|
||||
}
|
||||
}
|
||||
setOrederDetailFee(result, order)
|
||||
return order, err
|
||||
}
|
||||
|
||||
func setOrederDetailFee(result map[string]interface{}, order *model.GoodsOrder) {
|
||||
orderActivities := result["orderActivities"].([]interface{})
|
||||
for _, value := range orderActivities {
|
||||
activity := value.(map[string]interface{})
|
||||
categoryId := utils.MustInterface2Int64(activity["categoryId"])
|
||||
restaurantPart := -jxutils.StandardPrice2Int(utils.MustInterface2Float64(activity["restaurantPart"]))
|
||||
elemePart := -jxutils.StandardPrice2Int(utils.MustInterface2Float64(activity["elemePart"]))
|
||||
if _, ok := model.ElmSkuPromotion[int(categoryId)]; ok {
|
||||
order.SkuPmFee += restaurantPart
|
||||
order.SkuPmSubsidy += elemePart
|
||||
} else {
|
||||
order.OrderPmFee += restaurantPart
|
||||
order.OrderPmSubsidy += elemePart
|
||||
}
|
||||
}
|
||||
order.PlatformFeeRate = int16(utils.MustInterface2Float64(result["serviceRate"]))
|
||||
}
|
||||
|
||||
//
|
||||
func (c *OrderController) onOrderNew(msg map[string]interface{}) (response *elmapi.CallbackResponse) {
|
||||
// todo 这里应该可以直接用msg里的内容,而不用再次去查
|
||||
|
||||
32
business/controller/elm/order_test.go
Normal file
32
business/controller/elm/order_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package elm
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
"git.rosy.net.cn/jx-callback/globals/db"
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
func init() {
|
||||
//E:/goprojects/src/git.rosy.net.cn/jx-callback/conf/app.conf
|
||||
///Users/xujianhua/go/src/git.rosy.net.cn/jx-callback/conf/app.conf
|
||||
beego.InitBeegoBeforeTest("Users/xujianhua/go/src/git.rosy.net.cn/jx-callback/conf/app.conf")
|
||||
beego.BConfig.RunMode = "dev" // InitBeegoBeforeTest会将runmode设置为test
|
||||
|
||||
globals.Init()
|
||||
db.Init()
|
||||
api.Init()
|
||||
}
|
||||
|
||||
func TestGetOrder(t *testing.T) {
|
||||
orderID := "3025427524410871880"
|
||||
order, err := new(OrderController).GetOrder(orderID)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if order.VendorOrderID != orderID {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,10 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
JdSkuPromotion = []int64{2, 3, 4, 6, 8, 1203, 8001, 9998, 9997, 9996}
|
||||
ElmSkuPromotion = map[int]int{
|
||||
11: 1,
|
||||
200: 1,
|
||||
}
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user