Merge remote-tracking branch 'refs/remotes/origin/master'

This commit is contained in:
gazebo
2018-08-10 23:13:38 +08:00
3 changed files with 55 additions and 1 deletions

View File

@@ -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里的内容而不用再次去查

View 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())
}
}

View File

@@ -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 (