- avoid manually build map in CreateOrderByShop.
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platform/common"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -105,20 +107,20 @@ type MTPSResult struct {
|
||||
}
|
||||
|
||||
type MtpsCreateOrderByShopInfo struct {
|
||||
DeliveryId int64
|
||||
OrderId string
|
||||
ShopId string
|
||||
DeliveryServiceCode int
|
||||
ReceiverName string
|
||||
ReceiverAddress string
|
||||
ReceiverPhone string
|
||||
ReceiverLng int
|
||||
ReceiverLat int
|
||||
CoordinateType int
|
||||
GoodsValue float64
|
||||
GoodsWeight float64
|
||||
ExpectedDeliveryTime int64
|
||||
OrderType int
|
||||
DeliveryId int64 `structs:"delivery_id"`
|
||||
OrderId string `structs:"order_id"`
|
||||
ShopId string `structs:"shop_id"`
|
||||
DeliveryServiceCode int `structs:"delivery_service_code"`
|
||||
ReceiverName string `structs:"receiver_name"`
|
||||
ReceiverAddress string `structs:"receiver_address"`
|
||||
ReceiverPhone string `structs:"receiver_phone"`
|
||||
ReceiverLng int `structs:"receiver_lng"`
|
||||
ReceiverLat int `structs:"receiver_lat"`
|
||||
CoordinateType int `structs:"coordinate_type"`
|
||||
GoodsValue float64 `structs:"goods_value"`
|
||||
GoodsWeight float64 `structs:"goods_weight"`
|
||||
ExpectedDeliveryTime int64 `structs:"expected_delivery_time"`
|
||||
OrderType int `structs:"order_type"`
|
||||
}
|
||||
|
||||
type MTPSAPI struct {
|
||||
@@ -215,30 +217,15 @@ func (m *MTPSAPI) result2OrderResponse(result *MTPSResult) (order *MtpsOrderResp
|
||||
}
|
||||
|
||||
func (m *MTPSAPI) CreateOrderByShop(basicParams *MtpsCreateOrderByShopInfo, addParams map[string]interface{}) (order *MtpsOrderResponse, err error) {
|
||||
params := make(map[string]interface{})
|
||||
params["delivery_id"] = basicParams.DeliveryId
|
||||
params["order_id"] = basicParams.OrderId
|
||||
params["shop_id"] = basicParams.ShopId
|
||||
params["delivery_service_code"] = basicParams.DeliveryServiceCode
|
||||
params["receiver_name"] = basicParams.ReceiverName
|
||||
params["receiver_address"] = basicParams.ReceiverAddress
|
||||
params["receiver_phone"] = basicParams.ReceiverPhone
|
||||
params["receiver_lng"] = basicParams.ReceiverLng
|
||||
params["receiver_lat"] = basicParams.ReceiverLat
|
||||
params["coordinate_type"] = basicParams.CoordinateType
|
||||
params := structs.Map(basicParams)
|
||||
params["goods_value"] = strconv.FormatFloat(basicParams.GoodsValue, 'f', 2, 64)
|
||||
params["goods_weight"] = strconv.FormatFloat(basicParams.GoodsWeight, 'f', 2, 64)
|
||||
params["expected_delivery_time"] = basicParams.ExpectedDeliveryTime
|
||||
params["order_type"] = basicParams.OrderType
|
||||
if addParams != nil {
|
||||
for k, v := range addParams {
|
||||
params[k] = v
|
||||
}
|
||||
}
|
||||
allParams := utils.MergeMaps(params, addParams)
|
||||
|
||||
if params["order_type"] != utils.Int2Str(OrderTypeBook) {
|
||||
delete(params, "expected_delivery_time")
|
||||
}
|
||||
if result, err := m.AccessMTPS("order/createByShop", params); err != nil {
|
||||
if result, err := m.AccessMTPS("order/createByShop", allParams); err != nil {
|
||||
baseapi.SugarLogger.Debugf("result:%v", result)
|
||||
return nil, utils.NewErrorIntCode(err.Error(), result.Code)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user