- 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
|
||||
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) {
|
||||
status := utils.MustInterface2Int64(data["status"])
|
||||
if status == 200 {
|
||||
return data["synchronized"].(bool), nil
|
||||
}
|
||||
return nil, utils.NewErrorIntCode(data["message"].(string), int(status))
|
||||
})
|
||||
result, err := a.AccessAPINoPage("search/syncProduct", utils.Params2Map(KeyStoreId, storeId, KeySkuId, skuId), nil, nil, genNoPageResultParser("status", "message", "synchronized", "200"))
|
||||
if err == nil {
|
||||
return result.(bool), nil
|
||||
}
|
||||
|
||||
@@ -95,32 +95,32 @@ func TestQueryKeyWordDicInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSyncProduct(t *testing.T) {
|
||||
result, err := api.SyncProduct("11732425", "2015717812")
|
||||
result, err := api.SyncProduct(mustExistStoreID, "2022250244")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
baseapi.SugarLogger.Debug(result)
|
||||
result, err = api.SyncProduct("wrongstoreid", "2015717812")
|
||||
result, err = api.SyncProduct("wrongstoreid", "2022250244")
|
||||
if err == nil {
|
||||
t.Fatal("SyncProduct should return error")
|
||||
}
|
||||
result, err = api.SyncProduct("11732425", "wrongskuid")
|
||||
result, err = api.SyncProduct(mustExistStoreID, "wrongskuid")
|
||||
if err == nil {
|
||||
t.Fatal("SyncProduct should return error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetProductStatust(t *testing.T) {
|
||||
result, err := api.GetProductStatus("11732425", "2015717812")
|
||||
result, err := api.GetProductStatus(mustExistStoreID, "2022250244")
|
||||
if err != nil || result == nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// baseapi.SugarLogger.Debug(result)
|
||||
result, err = api.GetProductStatus("wrongstoreid", "2015717812")
|
||||
result, err = api.GetProductStatus("wrongstoreid", "2022250244")
|
||||
if err == nil {
|
||||
t.Fatal("GetProductStatus should return error")
|
||||
}
|
||||
result, err = api.GetProductStatus("11732425", "wrongskuid")
|
||||
result, err = api.GetProductStatus(mustExistStoreID, "wrongskuid")
|
||||
if err == nil {
|
||||
t.Fatal("GetProductStatus should return error")
|
||||
}
|
||||
|
||||
@@ -157,58 +157,126 @@ type CanRefundFoodInfo struct {
|
||||
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 {
|
||||
AppOrderCode string `json:"app_order_code"`
|
||||
AppPoiCode string `json:"app_poi_code"`
|
||||
AvgSendTime int `json:"avg_send_time"`
|
||||
BackupRecipientPhone string `json:"backup_recipient_phone"`
|
||||
Caution string `json:"caution"`
|
||||
CityID int `json:"city_id"`
|
||||
Ctime int64 `json:"ctime"`
|
||||
DaySeq int `json:"day_seq"`
|
||||
DeliveryTime int `json:"delivery_time"`
|
||||
Detail string `json:"detail"`
|
||||
DetailList []*FoodInfo `json:"detailList"`
|
||||
DinnersNumber int `json:"dinners_number"`
|
||||
ExpectDeliverTime int `json:"expect_deliver_time"`
|
||||
Extras string `json:"extras"`
|
||||
ExtraList []*OrderExtraInfo `json:"extraList"`
|
||||
HasInvoiced int `json:"has_invoiced"`
|
||||
InvoiceTitle string `json:"invoice_title"`
|
||||
IsFavorites bool `json:"is_favorites"`
|
||||
IsPoiFirstOrder bool `json:"is_poi_first_order"`
|
||||
IsPre int `json:"is_pre"`
|
||||
IsThirdShipping int `json:"is_third_shipping"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
LogisticsCode string `json:"logistics_code"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
OrderCompletedTime int `json:"order_completed_time"`
|
||||
OrderConfirmTime int `json:"order_confirm_time"`
|
||||
OrderID int64 `json:"order_id"`
|
||||
OrderSendTime int `json:"order_send_time"`
|
||||
OriginalPrice float64 `json:"original_price"`
|
||||
PackageBagMoney int `json:"package_bag_money"`
|
||||
PayType int `json:"pay_type"`
|
||||
PickType int `json:"pick_type"`
|
||||
PoiReceiveDetail string `json:"poi_receive_detail"`
|
||||
RecipientAddress string `json:"recipient_address"`
|
||||
RecipientName string `json:"recipient_name"`
|
||||
RecipientPhone string `json:"recipient_phone"`
|
||||
Remark string `json:"remark"`
|
||||
Result string `json:"result"`
|
||||
ShipperPhone string `json:"shipper_phone"`
|
||||
ShippingFee float64 `json:"shipping_fee"`
|
||||
ShippingType int `json:"shipping_type"`
|
||||
SourceID int `json:"source_id"`
|
||||
Status int `json:"status"`
|
||||
TaxpayerID string `json:"taxpayer_id"`
|
||||
Total float64 `json:"total"`
|
||||
Utime int64 `json:"utime"`
|
||||
WmOrderIDView int64 `json:"wm_order_id_view"`
|
||||
WmPoiAddress string `json:"wm_poi_address"`
|
||||
WmPoiID int `json:"wm_poi_id"`
|
||||
WmPoiName string `json:"wm_poi_name"`
|
||||
WmPoiPhone string `json:"wm_poi_phone"`
|
||||
AppOrderCode string `json:"app_order_code"`
|
||||
AppPoiCode string `json:"app_poi_code"`
|
||||
AvgSendTime int `json:"avg_send_time"`
|
||||
BackupRecipientPhone string `json:"backup_recipient_phone"`
|
||||
Caution string `json:"caution"`
|
||||
CityID int `json:"city_id"`
|
||||
Ctime int64 `json:"ctime"`
|
||||
DaySeq int `json:"day_seq"`
|
||||
DeliveryTime int `json:"delivery_time"`
|
||||
Detail string `json:"detail"`
|
||||
DetailList []*FoodInfo `json:"detailList"`
|
||||
DinnersNumber int `json:"dinners_number"`
|
||||
ExpectDeliverTime int `json:"expect_deliver_time"`
|
||||
Extras string `json:"extras"`
|
||||
ExtraList []*OrderExtraInfo `json:"extraList"`
|
||||
HasInvoiced int `json:"has_invoiced"`
|
||||
InvoiceTitle string `json:"invoice_title"`
|
||||
IsFavorites bool `json:"is_favorites"`
|
||||
IsPoiFirstOrder bool `json:"is_poi_first_order"`
|
||||
IsPre int `json:"is_pre"`
|
||||
IsThirdShipping int `json:"is_third_shipping"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
LogisticsCode string `json:"logistics_code"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
OrderCompletedTime int `json:"order_completed_time"`
|
||||
OrderConfirmTime int `json:"order_confirm_time"`
|
||||
OrderID int64 `json:"order_id"`
|
||||
OrderSendTime int `json:"order_send_time"`
|
||||
OriginalPrice float64 `json:"original_price"`
|
||||
PackageBagMoney int `json:"package_bag_money"`
|
||||
PayType int `json:"pay_type"`
|
||||
PickType int `json:"pick_type"`
|
||||
PoiReceiveDetail string `json:"poi_receive_detail"`
|
||||
RecipientAddress string `json:"recipient_address"`
|
||||
RecipientName string `json:"recipient_name"`
|
||||
RecipientPhone string `json:"recipient_phone"`
|
||||
Remark string `json:"remark"`
|
||||
Result string `json:"result"`
|
||||
ShipperPhone string `json:"shipper_phone"`
|
||||
ShippingFee float64 `json:"shipping_fee"`
|
||||
ShippingType int `json:"shipping_type"`
|
||||
SkuBenefitDetail string `json:"sku_benefit_detail"`
|
||||
SkuBenefitDetailList []*SkuBenefitDetailInfo `json:"sku_benefit_detail_list"`
|
||||
SourceID int `json:"source_id"`
|
||||
Status int `json:"status"`
|
||||
TaxpayerID string `json:"taxpayer_id"`
|
||||
Total float64 `json:"total"`
|
||||
Utime int64 `json:"utime"`
|
||||
WmOrderIDView int64 `json:"wm_order_id_view"`
|
||||
WmPoiAddress string `json:"wm_poi_address"`
|
||||
WmPoiID int `json:"wm_poi_id"`
|
||||
WmPoiName string `json:"wm_poi_name"`
|
||||
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) {
|
||||
@@ -301,9 +369,23 @@ func (a *API) OrderGetOrderDetail2(orderID int64, isMTLogistics bool) (orderInfo
|
||||
orderMap, err := a.OrderGetOrderDetail(orderID, isMTLogistics)
|
||||
if 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)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if orderInfo.SkuBenefitDetail != "" {
|
||||
err = utils.UnmarshalUseNumber([]byte(orderInfo.SkuBenefitDetail), &orderInfo.SkuBenefitDetailList)
|
||||
}
|
||||
}
|
||||
}
|
||||
return orderInfo, err
|
||||
@@ -381,3 +463,14 @@ func (a *API) GetOrderRefundDetail(orderID int64, refundType int) (refundOrderDe
|
||||
}
|
||||
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) {
|
||||
result, err := api.OrderGetOrderDetail(69299961008767093, false)
|
||||
result, err := api.OrderGetOrderDetail(69760842061320598, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func TestOrderGetOrderDetail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderGetOrderDetail2(t *testing.T) {
|
||||
result, err := api.OrderGetOrderDetail2(68689721416501384, false)
|
||||
result, err := api.OrderGetOrderDetail2(69760842061320598, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -90,7 +90,24 @@ func TestOrderBatchPullPhoneNumber(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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user