- mtwm.GetOrderRefundDetail

This commit is contained in:
gazebo
2019-05-01 13:36:21 +08:00
parent a1bf8690f7
commit 2ae94c589a
4 changed files with 84 additions and 2 deletions

View File

@@ -98,3 +98,8 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR
}
return msg, callbackResponse
}
func (a *API) GetRefundSkuDetailFromMsg(msg *CallbackMsg) (refundSkuDetail []*RefundSkuDetail) {
utils.UnmarshalUseNumber([]byte(msg.Data.Get("food")), &refundSkuDetail)
return refundSkuDetail
}

View File

@@ -0,0 +1,19 @@
package mtwmapi
import (
"net/url"
"testing"
"git.rosy.net.cn/baseapi/utils"
)
func TestGetRefundSkuDetailFromMsg(t *testing.T) {
data, _ := url.ParseQuery(`
/mtwm/orderPartialRefund?timestamp=1556595759&reason=%E5%BA%97%E9%93%BA%E5%A4%AA%E5%BF%99%E4%BA%86%21%E5%AE%A2%E5%AE%98%E6%88%91%E6%80%95%E6%82%A8%E7%AD%89%E7%9A%84%E5%A4%AA%E4%B9%85&food=%5B%7B%22app_food_code%22%3A%2231458%22%2C%22box_num%22%3A0%2C%22box_price%22%3A0%2C%22count%22%3A1%2C%22food_name%22%3A%22%E9%B2%9C%E7%AB%B9%E7%AC%8B%EF%BC%88%E9%B8%A1%E5%A9%86%E7%AC%8B%EF%BC%89%5B%E6%9C%AA%E6%B3%A1%E6%B0%B4%5D%E7%BA%A6250g%2F%E4%BB%BD%22%2C%22food_price%22%3A7.97%2C%22origin_food_price%22%3A7.97%2C%22refund_price%22%3A7.97%2C%22sku_id%22%3A%2231458%22%2C%22spec%22%3A%22250g%22%7D%5D&money=7.97&is_appeal=0&pictures=&notify_type=agree&app_id=589&order_id=67413510345111009&res_type=2&sig=0cef69f37b4a0e924ac4119c3d75117b
`)
msg := &CallbackMsg{
Data: data,
}
result := api.GetRefundSkuDetailFromMsg(msg)
t.Log(utils.Format4Output(result, false))
}

View File

@@ -55,12 +55,45 @@ const (
UserApplyCancelWaitMinute = 30 // 用户申请退款后商家未在30分钟内大连锁商家为3小时内处理退款请求系统将自动同意退款
)
const (
RefundTypeAll = 1
RefundTypePart = 2
)
type RefundSku struct {
AppFoodCode string `json:"app_food_code"`
SkuID string `json:"sku_id,omitempty"`
Count int `json:"count"`
}
type RefundSkuDetail struct {
AppFoodCode string `json:"app_food_code"`
BoxNum float32 `json:"box_num"`
BoxPrice float32 `json:"box_price"`
Count int `json:"count"`
FoodName string `json:"food_name"`
FoodPrice float32 `json:"food_price"`
OriginFoodPrice float32 `json:"origin_food_price"`
RefundPrice float32 `json:"refund_price"`
SkuID string `json:"sku_id"`
Spec string `json:"spec"`
}
type RefundOrderDetail struct {
ApplyReason string `json:"apply_reason"`
ApplyType int `json:"apply_type"`
CTime int64 `json:"ctime"`
Money float32 `json:"money"`
OrderID int64 `json:"order_id"`
Pictures []string `json:"pictures"`
RefundType int `json:"refund_type"`
ResReason string `json:"res_reason"`
ResType int `json:"res_type"`
UTime int64 `json:"utime"`
WmAppRetailForOrderPartRefundList []*RefundSkuDetail `json:"wmAppRetailForOrderPartRefundList"`
WmOrderIDView int64 `json:"wm_order_id_view"`
}
func (a *API) OrderReceived(orderID int64) (err error) {
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
KeyOrderID: orderID,
@@ -195,3 +228,18 @@ func (a *API) OrderLogisticsChange2Self(orderID int64) (err error) {
})
return err
}
func (a *API) GetOrderRefundDetail(orderID int64, refundType int) (refundOrderDetail *RefundOrderDetail, err error) {
params := map[string]interface{}{
"wm_order_id_view": orderID,
}
if refundType > 0 {
params["refund_type"] = refundType
}
result, err := a.AccessAPI("ecommerce/order/getOrderRefundDetail", true, params)
if err == nil {
utils.Map2StructByJson(result.([]interface{})[0], &refundOrderDetail, false)
return refundOrderDetail, nil
}
return nil, err
}

View File

@@ -2,6 +2,8 @@ package mtwmapi
import (
"testing"
"git.rosy.net.cn/baseapi/utils"
)
func TestOrderViewStatus(t *testing.T) {
@@ -13,14 +15,14 @@ func TestOrderViewStatus(t *testing.T) {
}
func TestOrderGetOrderDetail(t *testing.T) {
result, err := api.OrderGetOrderDetail(33762863658107006, false)
result, err := api.OrderGetOrderDetail(67413510345111009, false)
if err != nil {
t.Fatal(err)
}
if len(result) == 0 {
t.Fatal("result should have value")
}
// t.Log(utils.Format4Output(result, false))
t.Log(utils.Format4Output(result, false))
}
func TestOrderLogisticsStatus(t *testing.T) {
@@ -51,3 +53,11 @@ func TestOrderConfirm(t *testing.T) {
t.Fatal(err)
}
}
func TestGetOrderRefundDetail(t *testing.T) {
result, err := api.GetOrderRefundDetail(67413510345111009, 0)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}