diff --git a/business/controller/elm/order.go b/business/controller/elm/order.go index a9fed6200..aef73b72d 100644 --- a/business/controller/elm/order.go +++ b/business/controller/elm/order.go @@ -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里的内容,而不用再次去查 diff --git a/business/controller/elm/order_test.go b/business/controller/elm/order_test.go new file mode 100644 index 000000000..2968fa458 --- /dev/null +++ b/business/controller/elm/order_test.go @@ -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()) + } +} diff --git a/business/model/const.go b/business/model/const.go index 7bed36380..cdd7b9599 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -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 (