- GetOrderActDetail and sku_benefit_detail
This commit is contained in:
@@ -399,13 +399,7 @@ func (a *API) QueryKeyWordDicInfo(pageNo, pageSize int, keyValue string) (values
|
|||||||
// 商家商品状态同步接口
|
// 商家商品状态同步接口
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=180&apiid=5e29d6c9317847e58b8cbcc70702fd52
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=180&apiid=5e29d6c9317847e58b8cbcc70702fd52
|
||||||
func (a *API) SyncProduct(storeId, skuId string) (retVal bool, err error) {
|
func (a *API) SyncProduct(storeId, skuId string) (retVal bool, err error) {
|
||||||
result, err := a.AccessAPINoPage("search/syncProduct", utils.Params2Map(KeyStoreId, storeId, KeySkuId, skuId), nil, nil, func(data map[string]interface{}) (interface{}, error) {
|
result, err := a.AccessAPINoPage("search/syncProduct", utils.Params2Map(KeyStoreId, storeId, KeySkuId, skuId), nil, nil, genNoPageResultParser("status", "message", "synchronized", "200"))
|
||||||
status := utils.MustInterface2Int64(data["status"])
|
|
||||||
if status == 200 {
|
|
||||||
return data["synchronized"].(bool), nil
|
|
||||||
}
|
|
||||||
return nil, utils.NewErrorIntCode(data["message"].(string), int(status))
|
|
||||||
})
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return result.(bool), nil
|
return result.(bool), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,32 +95,32 @@ func TestQueryKeyWordDicInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncProduct(t *testing.T) {
|
func TestSyncProduct(t *testing.T) {
|
||||||
result, err := api.SyncProduct("11732425", "2015717812")
|
result, err := api.SyncProduct(mustExistStoreID, "2022250244")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
baseapi.SugarLogger.Debug(result)
|
baseapi.SugarLogger.Debug(result)
|
||||||
result, err = api.SyncProduct("wrongstoreid", "2015717812")
|
result, err = api.SyncProduct("wrongstoreid", "2022250244")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("SyncProduct should return error")
|
t.Fatal("SyncProduct should return error")
|
||||||
}
|
}
|
||||||
result, err = api.SyncProduct("11732425", "wrongskuid")
|
result, err = api.SyncProduct(mustExistStoreID, "wrongskuid")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("SyncProduct should return error")
|
t.Fatal("SyncProduct should return error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetProductStatust(t *testing.T) {
|
func TestGetProductStatust(t *testing.T) {
|
||||||
result, err := api.GetProductStatus("11732425", "2015717812")
|
result, err := api.GetProductStatus(mustExistStoreID, "2022250244")
|
||||||
if err != nil || result == nil {
|
if err != nil || result == nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// baseapi.SugarLogger.Debug(result)
|
// baseapi.SugarLogger.Debug(result)
|
||||||
result, err = api.GetProductStatus("wrongstoreid", "2015717812")
|
result, err = api.GetProductStatus("wrongstoreid", "2022250244")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("GetProductStatus should return error")
|
t.Fatal("GetProductStatus should return error")
|
||||||
}
|
}
|
||||||
result, err = api.GetProductStatus("11732425", "wrongskuid")
|
result, err = api.GetProductStatus(mustExistStoreID, "wrongskuid")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("GetProductStatus should return error")
|
t.Fatal("GetProductStatus should return error")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,6 +157,33 @@ type CanRefundFoodInfo struct {
|
|||||||
SkuID string `json:"sku_id"`
|
SkuID string `json:"sku_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WmAppOrderActDetailInfo struct {
|
||||||
|
ActID int64 `json:"act_id"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
MtCharge float64 `json:"mtCharge"`
|
||||||
|
PoiCharge float64 `json:"poiCharge"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
Type int `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SkuBenefitDetailInfo struct {
|
||||||
|
ActivityPrice float64 `json:"activityPrice"`
|
||||||
|
AppFoodCode string `json:"app_food_code"`
|
||||||
|
BoxNumber float64 `json:"boxNumber"`
|
||||||
|
BoxPrice float64 `json:"boxPrice"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
OriginPrice float64 `json:"originPrice"`
|
||||||
|
SkuID string `json:"sku_id"`
|
||||||
|
TotalActivityPrice float64 `json:"totalActivityPrice"`
|
||||||
|
TotalBoxPrice float64 `json:"totalBoxPrice"`
|
||||||
|
TotalMtCharge float64 `json:"totalMtCharge"`
|
||||||
|
TotalOriginPrice float64 `json:"totalOriginPrice"`
|
||||||
|
TotalPoiCharge float64 `json:"totalPoiCharge"`
|
||||||
|
TotalReducePrice float64 `json:"totalReducePrice"`
|
||||||
|
WmAppOrderActDetails []*WmAppOrderActDetailInfo `json:"wmAppOrderActDetails"`
|
||||||
|
}
|
||||||
|
|
||||||
type OrderInfo struct {
|
type OrderInfo struct {
|
||||||
AppOrderCode string `json:"app_order_code"`
|
AppOrderCode string `json:"app_order_code"`
|
||||||
AppPoiCode string `json:"app_poi_code"`
|
AppPoiCode string `json:"app_poi_code"`
|
||||||
@@ -199,6 +226,8 @@ type OrderInfo struct {
|
|||||||
ShipperPhone string `json:"shipper_phone"`
|
ShipperPhone string `json:"shipper_phone"`
|
||||||
ShippingFee float64 `json:"shipping_fee"`
|
ShippingFee float64 `json:"shipping_fee"`
|
||||||
ShippingType int `json:"shipping_type"`
|
ShippingType int `json:"shipping_type"`
|
||||||
|
SkuBenefitDetail string `json:"sku_benefit_detail"`
|
||||||
|
SkuBenefitDetailList []*SkuBenefitDetailInfo `json:"sku_benefit_detail_list"`
|
||||||
SourceID int `json:"source_id"`
|
SourceID int `json:"source_id"`
|
||||||
Status int `json:"status"`
|
Status int `json:"status"`
|
||||||
TaxpayerID string `json:"taxpayer_id"`
|
TaxpayerID string `json:"taxpayer_id"`
|
||||||
@@ -211,6 +240,45 @@ type OrderInfo struct {
|
|||||||
WmPoiPhone string `json:"wm_poi_phone"`
|
WmPoiPhone string `json:"wm_poi_phone"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetOrderActDetailParamAct struct {
|
||||||
|
Type int `json:"type,omitempty"`
|
||||||
|
ActID int64 `json:"act_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetOrderActDetailParam struct {
|
||||||
|
OrderID int64 `json:"order_id_view"`
|
||||||
|
ActParam []*GetOrderActDetailParamAct `json:"act_param,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderActInfo struct {
|
||||||
|
OrderID int64 `json:"order_id_view"`
|
||||||
|
ActDetailList []*struct {
|
||||||
|
ActID int64 `json:"act_id"`
|
||||||
|
CouponDetail interface{} `json:"coupon_detail"`
|
||||||
|
EndTime int64 `json:"end_time"`
|
||||||
|
GiftsDetail interface{} `json:"gifts_detail"`
|
||||||
|
PoiDetail interface{} `json:"poi_detail"`
|
||||||
|
ProductDetail struct {
|
||||||
|
AppFoodCode string `json:"app_food_code"`
|
||||||
|
CategorySeqence int `json:"category_seqence"`
|
||||||
|
Charge string `json:"charge"`
|
||||||
|
DayLimit int `json:"day_limit"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
OrderLimit int `json:"order_limit"`
|
||||||
|
Period string `json:"period"`
|
||||||
|
Policy string `json:"policy"`
|
||||||
|
SettingType int `json:"setting_type"`
|
||||||
|
UserType int `json:"user_type"`
|
||||||
|
WeeksTime string `json:"weeks_time"`
|
||||||
|
} `json:"product_detail"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
StartTime int64 `json:"start_time"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
Type int `json:"type"`
|
||||||
|
TypeName string `json:"type_name"`
|
||||||
|
} `json:"act_detail_list"`
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) OrderReceived(orderID int64) (err error) {
|
func (a *API) OrderReceived(orderID int64) (err error) {
|
||||||
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
|
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
|
||||||
KeyOrderID: orderID,
|
KeyOrderID: orderID,
|
||||||
@@ -301,9 +369,23 @@ func (a *API) OrderGetOrderDetail2(orderID int64, isMTLogistics bool) (orderInfo
|
|||||||
orderMap, err := a.OrderGetOrderDetail(orderID, isMTLogistics)
|
orderMap, err := a.OrderGetOrderDetail(orderID, isMTLogistics)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if err = utils.Map2StructByJson(orderMap, &orderInfo, false); err == nil {
|
if err = utils.Map2StructByJson(orderMap, &orderInfo, false); err == nil {
|
||||||
if err = utils.UnmarshalUseNumber([]byte(orderInfo.Detail), &orderInfo.DetailList); err == nil && orderInfo.Extras != "" {
|
if orderInfo.Detail != "" {
|
||||||
|
err = utils.UnmarshalUseNumber([]byte(orderInfo.Detail), &orderInfo.DetailList)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if orderInfo.Extras != "" {
|
||||||
err = utils.UnmarshalUseNumber([]byte(orderInfo.Extras), &orderInfo.ExtraList)
|
err = utils.UnmarshalUseNumber([]byte(orderInfo.Extras), &orderInfo.ExtraList)
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if orderInfo.SkuBenefitDetail != "" {
|
||||||
|
err = utils.UnmarshalUseNumber([]byte(orderInfo.SkuBenefitDetail), &orderInfo.SkuBenefitDetailList)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return orderInfo, err
|
return orderInfo, err
|
||||||
@@ -381,3 +463,14 @@ func (a *API) GetOrderRefundDetail(orderID int64, refundType int) (refundOrderDe
|
|||||||
}
|
}
|
||||||
return refundOrderDetailList, err
|
return refundOrderDetailList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) GetOrderActDetail(queryData []*GetOrderActDetailParam) (orderActList []*OrderActInfo, err error) {
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"query_data": string(utils.MustMarshal(queryData)),
|
||||||
|
}
|
||||||
|
result, err := a.AccessAPI("ecommerce/order/getOrderActDetail", true, params)
|
||||||
|
if err == nil {
|
||||||
|
err = utils.Map2StructByJson(result, &orderActList, false)
|
||||||
|
}
|
||||||
|
return orderActList, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func TestOrderViewStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderGetOrderDetail(t *testing.T) {
|
func TestOrderGetOrderDetail(t *testing.T) {
|
||||||
result, err := api.OrderGetOrderDetail(69299961008767093, false)
|
result, err := api.OrderGetOrderDetail(69760842061320598, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ func TestOrderGetOrderDetail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderGetOrderDetail2(t *testing.T) {
|
func TestOrderGetOrderDetail2(t *testing.T) {
|
||||||
result, err := api.OrderGetOrderDetail2(68689721416501384, false)
|
result, err := api.OrderGetOrderDetail2(69760842061320598, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,24 @@ func TestOrderBatchPullPhoneNumber(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetOrderRefundDetail(t *testing.T) {
|
func TestGetOrderRefundDetail(t *testing.T) {
|
||||||
result, err := api.GetOrderRefundDetail(25236872989387976, RefundTypePart)
|
result, err := api.GetOrderRefundDetail(25236870166465610, RefundTypePart)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetOrderActDetaill(t *testing.T) {
|
||||||
|
result, err := api.GetOrderActDetail([]*GetOrderActDetailParam{
|
||||||
|
&GetOrderActDetailParam{
|
||||||
|
OrderID: 69760842061320598,
|
||||||
|
// ActParam: []*GetOrderActDetailParamAct{
|
||||||
|
// &GetOrderActDetailParamAct{
|
||||||
|
// Type: 1,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user