1487 lines
60 KiB
Go
1487 lines
60 KiB
Go
package ebaiapi
|
||
|
||
import (
|
||
"fmt"
|
||
"net/http"
|
||
"strings"
|
||
"time"
|
||
|
||
"git.rosy.net.cn/baseapi/platformapi"
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
)
|
||
|
||
const (
|
||
storeURL = "https://be.ele.me"
|
||
getStoreURL = "https://newretail.ele.me"
|
||
swithShopURL = "crm/manager/switchshop"
|
||
)
|
||
|
||
const (
|
||
CommentLevelAll = -1
|
||
CommentLevel1 = 1
|
||
CommentLevel2 = 2
|
||
CommentLevel3 = 3
|
||
CommentLevel4 = 4
|
||
CommentLevel5 = 5
|
||
|
||
CommentContentAll = -1
|
||
CommentContentHaveContent = 1
|
||
CommentContentNoContent = 0
|
||
ShopStatusOnLine = 1 //饿百商家中心商户 上线
|
||
ShopStatusOffLine = 2 //饿百商家中心商户 未上线
|
||
ProxyBusinessState = 10 //饿百商家中心商户,除正常营业外的状态
|
||
|
||
EbaiWholeCountryStore = "22267110836"
|
||
)
|
||
|
||
type PageShopUserInfo struct {
|
||
CategoryID string `json:"category_id"`
|
||
CityID string `json:"city_id"`
|
||
CityName string `json:"city_name"`
|
||
DeliveryParty string `json:"delivery_party"`
|
||
EleID string `json:"ele_id"`
|
||
EleSoaToken string `json:"ele_soa_token"`
|
||
IsAPI int `json:"is_api"`
|
||
IsStore interface{} `json:"is_store"`
|
||
MerchantID string `json:"merchant_id"`
|
||
MerchantName string `json:"merchant_name"`
|
||
Role struct {
|
||
Ename string `json:"ename"`
|
||
Name string `json:"name"`
|
||
ShopRoleID int64 `json:"shop_role_id"`
|
||
} `json:"role"`
|
||
SalesID string `json:"sales_id"`
|
||
SalesName string `json:"sales_name"`
|
||
ServicePackage struct {
|
||
BaiduSign int `json:"baiduSign"`
|
||
EleSign int `json:"eleSign"`
|
||
} `json:"service_package"`
|
||
ShopInfo struct {
|
||
AreaID string `json:"area_id"`
|
||
BaiduBusinessState string `json:"baidu_business_state"`
|
||
BaiduOnlineStatus string `json:"baidu_online_status"`
|
||
BaiduTakeoutLogo string `json:"baidu_takeout_logo"`
|
||
CategoryID string `json:"category_id"`
|
||
CategoryIds string `json:"category_ids"`
|
||
CategoryName string `json:"category_name"`
|
||
County string `json:"county"`
|
||
CreateType string `json:"create_type"`
|
||
CreatedAt string `json:"created_at"`
|
||
CrmOncallType int `json:"crm_oncall_type"`
|
||
EffectiveAt string `json:"effective_at"`
|
||
EleBusinessState string `json:"ele_business_state"`
|
||
EleDeliveryParty string `json:"ele_delivery_party"`
|
||
EleID string `json:"ele_id"`
|
||
EleOnlineStatus string `json:"ele_online_status"`
|
||
EleShopLogo interface{} `json:"ele_shop_logo"`
|
||
IsSignZhongbao string `json:"is_sign_zhongbao"`
|
||
OnlineStatus string `json:"online_status"`
|
||
Phone string `json:"phone"`
|
||
ServStatus string `json:"serv_status"`
|
||
ShopTransactionOpen int `json:"shop_transaction_open"`
|
||
SourceName string `json:"source_name"`
|
||
SupplierID string `json:"supplier_id"`
|
||
TakeoutBoxPrice string `json:"takeout_box_price"`
|
||
TakeoutDispatchTime []*BussinessTimeInfo `json:"takeout_dispatch_time"`
|
||
TakeoutOncallType string `json:"takeout_oncall_type"`
|
||
TakeoutOpenTime []*BussinessTimeInfo `json:"takeout_open_time"`
|
||
TakeoutServicePhone string `json:"takeout_service_phone"`
|
||
TakeoutShopLogo string `json:"takeout_shop_logo"`
|
||
TransferStatus string `json:"transfer_status"`
|
||
} `json:"shop_info"`
|
||
ShopRole int `json:"shop_role"`
|
||
ShopUserID string `json:"shop_user_id"`
|
||
SwitchFromSupplier int `json:"switch_from_supplier"`
|
||
UserName string `json:"user_name"`
|
||
UserPhone string `json:"user_phone"`
|
||
YellowPrompt struct {
|
||
Capacity int `json:"capacity"`
|
||
Complete int `json:"complete"`
|
||
Display bool `json:"display"`
|
||
Msg string `json:"msg"`
|
||
MsgCount int `json:"msg_count"`
|
||
MsgList []interface{} `json:"msg_list"`
|
||
Online int `json:"online"`
|
||
PcURL string `json:"pc_url"`
|
||
TransferStatus string `json:"transfer_status"`
|
||
Type int `json:"type"`
|
||
URL string `json:"url"`
|
||
} `json:"yellow_prompt"`
|
||
}
|
||
|
||
type PageShopHealthInfo struct {
|
||
MerchantID string `json:"merchant_id"`
|
||
MerchantName string `json:"merchant_name"`
|
||
|
||
BadOrderRate string `json:"bad_order_rate"`
|
||
Category2 string `json:"category_2"`
|
||
Data string `json:"data"`
|
||
EndTime string `json:"endTime"`
|
||
HasPhotoRate string `json:"has_photo_rate"`
|
||
Hours string `json:"hours"`
|
||
ID string `json:"id"`
|
||
IsButie string `json:"is_butie"`
|
||
IsCp string `json:"is_cp"`
|
||
IsDeliverFee string `json:"is_deliver_fee"`
|
||
IsGood string `json:"is_good"`
|
||
IsHealthy string `json:"is_healthy"`
|
||
IsJiedan string `json:"is_jiedan"`
|
||
IsManjian string `json:"is_manjian"`
|
||
IsQisong string `json:"is_qisong"`
|
||
IsShopNew string `json:"is_shop_new"`
|
||
IsSku string `json:"is_sku"`
|
||
IsYinye string `json:"is_yinye"`
|
||
IsYoutu string `json:"is_youtu"`
|
||
IsZs string `json:"is_zs"`
|
||
MinDeliveryFee string `json:"min_delivery_fee"`
|
||
MinDeliveryPrice string `json:"min_delivery_price"`
|
||
RestaurantSubsidy string `json:"restaurant_subsidy"`
|
||
ShopCategory string `json:"shop_category"`
|
||
ShopID string `json:"shop_id"`
|
||
SkuNum string `json:"sku_num"`
|
||
StartTime string `json:"startTime"`
|
||
TargetButie string `json:"target_butie"`
|
||
TargetCp string `json:"target_cp"`
|
||
TargetDeliverFee string `json:"target_deliver_fee"`
|
||
TargetJiedan string `json:"target_jiedan"`
|
||
TargetQisong string `json:"target_qisong"`
|
||
TargetSku string `json:"target_sku"`
|
||
TargetYinye string `json:"target_yinye"`
|
||
TargetYoutu string `json:"target_youtu"`
|
||
UnvalidOrderNum string `json:"unvalid_order_num"`
|
||
UpdateTime string `json:"update_time"`
|
||
Week string `json:"week"`
|
||
}
|
||
|
||
type ActivityTagInfo struct {
|
||
Color struct {
|
||
BgColor string `json:"bg_color"`
|
||
FrameColor string `json:"frame_color"`
|
||
FrontColor string `json:"front_color"`
|
||
} `json:"color"`
|
||
Discount string `json:"discount"`
|
||
Msg string `json:"msg"`
|
||
Type string `json:"type"`
|
||
}
|
||
|
||
type PageListInnerShopInfo struct {
|
||
ActivityTag []*ActivityTagInfo `json:"activity_tag"`
|
||
BrandName string `json:"brand_name"`
|
||
BusinessStatus int `json:"business_status"`
|
||
BusinessTime []*BussinessTimeInfo `json:"business_time"`
|
||
CanRefund int `json:"can_refund"`
|
||
CashGiftComment string `json:"cash_gift_comment"`
|
||
DeliveryTime int `json:"delivery_time"`
|
||
DisplayRefundLabel int `json:"display_refund_label"`
|
||
Distance float64 `json:"distance"`
|
||
EleID string `json:"ele_id"`
|
||
FlashsalesStyleShop int `json:"flashsales_style_shop"`
|
||
HasFoodEnsurance int `json:"has_food_ensurance"`
|
||
HasServiceCommitment int `json:"has_service_commitment"`
|
||
HitGod int `json:"hit_god"`
|
||
IsBrand int `json:"is_brand"`
|
||
IsDoubleTwelve int `json:"is_double_twelve"`
|
||
IsRank int `json:"is_rank"`
|
||
IsTransfer int `json:"is_transfer"`
|
||
LogoURL string `json:"logo_url"`
|
||
OverallRating float64 `json:"overall_rating"`
|
||
SaledMonth int `json:"saled_month"`
|
||
SameBrandFolding []struct {
|
||
DeliveryTime int `json:"delivery_time"`
|
||
Distance float64 `json:"distance"`
|
||
EleID string `json:"ele_id"`
|
||
IsTransfer int `json:"is_transfer"`
|
||
ShopName string `json:"shop_name"`
|
||
Wid string `json:"wid"`
|
||
} `json:"same_brand_folding"`
|
||
ShopLabels string `json:"shop_labels"`
|
||
ShopName string `json:"shop_name"`
|
||
TakeoutCost float64 `json:"takeout_cost"`
|
||
TakeoutPrice float64 `json:"takeout_price"`
|
||
Type interface{} `json:"type"`
|
||
WelfareInfo []struct {
|
||
IconColor struct {
|
||
BgColor string `json:"bg_color"`
|
||
FrameColor string `json:"frame_color"`
|
||
FrontColor string `json:"front_color"`
|
||
} `json:"icon_color"`
|
||
IconName string `json:"icon_name"`
|
||
IconNameOther string `json:"icon_name_other"`
|
||
Msg string `json:"msg"`
|
||
Type string `json:"type"`
|
||
} `json:"welfare_info"`
|
||
Wid string `json:"wid"`
|
||
}
|
||
|
||
type PageListShopInfo struct {
|
||
ActivityEntry interface{} `json:"activity_entry"`
|
||
AoiID string `json:"aoi_id"`
|
||
DisplayWindow []struct {
|
||
CategoryIds []string `json:"category_ids"`
|
||
CurrentPrice string `json:"current_price"`
|
||
Image string `json:"image"`
|
||
ItemID string `json:"item_id"`
|
||
LeftNum int `json:"left_num"`
|
||
Name string `json:"name"`
|
||
OriginPrice string `json:"origin_price"`
|
||
SkuID string `json:"sku_id"`
|
||
} `json:"display_window"`
|
||
ShopInfo *PageListInnerShopInfo `json:"shop_info"`
|
||
}
|
||
|
||
type PageListInfo struct {
|
||
ShopList []*PageListShopInfo `json:"shop_list"`
|
||
Total int `json:"total"`
|
||
UserType string `json:"user_type"`
|
||
}
|
||
|
||
type PageShopInfo struct {
|
||
Activities []struct {
|
||
IconColor struct {
|
||
BgColor string `json:"bg_color"`
|
||
FrameColor string `json:"frame_color"`
|
||
FrontColor string `json:"front_color"`
|
||
} `json:"icon_color"`
|
||
IconName string `json:"icon_name"`
|
||
IconNameOther string `json:"icon_name_other"`
|
||
Msg string `json:"msg"`
|
||
Type string `json:"type"`
|
||
} `json:"activities"`
|
||
ActivityTag []*ActivityTagInfo `json:"activity_tag"`
|
||
Address string `json:"address"`
|
||
Albums []interface{} `json:"albums"`
|
||
BdHeadBg string `json:"bd_head_bg"`
|
||
BdHeadColor string `json:"bd_head_color"`
|
||
Brand string `json:"brand"`
|
||
BusinessStatus int `json:"business_status"`
|
||
CanRefund int `json:"can_refund"`
|
||
Category string `json:"category"`
|
||
CityID string `json:"city_id"`
|
||
CurrentBusinessTime interface{} `json:"current_business_time"` // 无值时为空字符串,有值时为对象:{"end":"20:45","start":"08:05"}
|
||
DeliveryInfo []interface{} `json:"delivery_info"`
|
||
DeliveryMode struct {
|
||
Tag []interface{} `json:"tag"`
|
||
Text string `json:"text"`
|
||
} `json:"delivery_mode"`
|
||
Description string `json:"description"`
|
||
DisplayRefundLabel int `json:"display_refund_label"`
|
||
Distance int `json:"distance"`
|
||
EleBusinessState int `json:"ele_business_state"`
|
||
EleID string `json:"ele_id"`
|
||
FirstOpenTime *BussinessTimeInfo `json:"first_open_time"`
|
||
HitGod int `json:"hit_god"`
|
||
ImagePath string `json:"image_path"`
|
||
IsColdChain int `json:"is_cold_chain"`
|
||
IsDoubleTwelve int `json:"is_double_twelve"`
|
||
IsMedicineShop int `json:"is_medicine_shop"`
|
||
IsOwnTheme int `json:"is_own_theme"`
|
||
Latitude float64 `json:"latitude"`
|
||
Longitude float64 `json:"longitude"`
|
||
MedicineQualification []*struct {
|
||
AptitudeName string `json:"aptitude_name"`
|
||
AptitudePhoto []string `json:"aptitude_photo"`
|
||
AptitudeType string `json:"aptitude_type"`
|
||
LicenseNumber string `json:"license_number"`
|
||
} `json:"medicine_qualification"`
|
||
Name string `json:"name"`
|
||
NewStyle bool `json:"new_style"`
|
||
OTakoutCost int `json:"o_takout_cost"`
|
||
OTakoutPrice int `json:"o_takout_price"`
|
||
OrderLeadTime interface{} `json:"order_lead_time"`
|
||
Phone string `json:"phone"`
|
||
PromotionInfo string `json:"promotion_info"`
|
||
Qualification string `json:"qualification"`
|
||
RecentOrderNum int `json:"recent_order_num"`
|
||
ShopID string `json:"shop_id"`
|
||
ShopScore float64 `json:"shop_score"`
|
||
ShopSourceFrom int `json:"shop_source_from"`
|
||
SkuCount int `json:"sku_count"`
|
||
TakeoutCost float64 `json:"takeout_cost"`
|
||
TakeoutInvoice float64 `json:"takeout_invoice"`
|
||
TakeoutInvoiceMinPrice string `json:"takeout_invoice_min_price"`
|
||
TakeoutOpenTime string `json:"takeout_open_time"`
|
||
TakeoutPrice float64 `json:"takeout_price"`
|
||
}
|
||
|
||
type ShopList struct {
|
||
Wid string `json:"wid"`
|
||
SalesID string `json:"sales_id"`
|
||
ContractStatus string `json:"contract_status"`
|
||
AuditStatus string `json:"audit_status"`
|
||
BaiduBusinessState string `json:"baidu_business_state"`
|
||
EleBusinessState string `json:"ele_business_state"`
|
||
EleID string `json:"ele_id"`
|
||
TakeoutOpenTime string `json:"takeout_open_time"`
|
||
TakeoutDispatchTime string `json:"takeout_dispatch_time"`
|
||
Name string `json:"name"`
|
||
BaiduOnlineStatus string `json:"baidu_online_status"`
|
||
EleOnlineStatus string `json:"ele_online_status"`
|
||
BusinessState int `json:"business_state"`
|
||
BaiduContractStatus int `json:"baidu_contract_status"`
|
||
EleContractStatus int `json:"ele_contract_status"`
|
||
ProxyBusinessState int `json:"proxy_business_state"`
|
||
}
|
||
|
||
type StoreShowWindowSkuList struct {
|
||
SkuID string `json:"sku_id"`
|
||
UpcID string `json:"upc_id"`
|
||
Wid string `json:"wid"`
|
||
//UpcType string `json:"upc_type"`
|
||
UpdateTime string `json:"update_time"`
|
||
ShelfNumber string `json:"shelf_number"`
|
||
LeftNum string `json:"left_num"`
|
||
MarketPrice float64 `json:"market_price"`
|
||
Ext string `json:"ext"`
|
||
ExtCode string `json:"ext_code"`
|
||
WeightFlag string `json:"weight_flag"`
|
||
IsSupplier string `json:"is_supplier"`
|
||
PurchaseLimit string `json:"purchase_limit"`
|
||
PreparationTime string `json:"preparation_time"`
|
||
Weight string `json:"weight"`
|
||
SalePrice float64 `json:"sale_price"`
|
||
Discount int `json:"discount"`
|
||
Enabled string `json:"enabled"`
|
||
UpcName string `json:"upc_name"`
|
||
Upc string `json:"upc"`
|
||
Photos []struct {
|
||
URL string `json:"url"`
|
||
IsMaster int `json:"is_master"`
|
||
} `json:"photos"`
|
||
BrandID string `json:"brand_id"`
|
||
DeleteTime string `json:"delete_time"`
|
||
CreateTime string `json:"create_time"`
|
||
NeedIce string `json:"need_ice"`
|
||
SkuProperty []interface{} `json:"sku_property"`
|
||
SaleUnit string `json:"sale_unit"`
|
||
PreminusWeight int `json:"preminus_weight"`
|
||
Minimum string `json:"minimum"`
|
||
SaleStep string `json:"sale_step"`
|
||
ProcessType int `json:"process_type"`
|
||
ProcessDetail []interface{} `json:"process_detail"`
|
||
IsInActivity int `json:"is_in_activity"`
|
||
Cat1ID string `json:"cat1_id"`
|
||
Cat2ID string `json:"cat2_id"`
|
||
Cat3ID string `json:"cat3_id"`
|
||
Propertys []interface{} `json:"propertys"`
|
||
Description string `json:"description"`
|
||
Rtf string `json:"rtf"`
|
||
Summary string `json:"summary"`
|
||
ProductionAddr1 string `json:"production_addr1"`
|
||
ProductionAddr2 string `json:"production_addr2"`
|
||
ProductionAddr3 string `json:"production_addr3"`
|
||
Cat1Name string `json:"cat1_name"`
|
||
Cat2Name string `json:"cat2_name"`
|
||
Cat3Name string `json:"cat3_name"`
|
||
Editable int `json:"editable"`
|
||
SkuStatus int `json:"sku_status"`
|
||
}
|
||
|
||
type ExianDaSkus struct {
|
||
Category string `json:"category"`
|
||
CustomGoodsCode interface{} `json:"customGoodsCode"`
|
||
CustomGoodsID int `json:"customGoodsId"`
|
||
ElemeGoodsCode string `json:"elemeGoodsCode"`
|
||
ElemeGoodsID string `json:"elemeGoodsId"`
|
||
ElemeOwnerCode string `json:"elemeOwnerCode"`
|
||
ElemeOwnerID int `json:"elemeOwnerId"`
|
||
ExtValues struct {
|
||
} `json:"extValues"`
|
||
GoodsID int `json:"goodsId"`
|
||
GoodsName string `json:"goodsName"`
|
||
ID int `json:"id"`
|
||
ImageURL string `json:"imageUrl"`
|
||
IsShelflife int `json:"isShelflife"`
|
||
IsWeight int `json:"isWeight"`
|
||
MeasurementUnitID int `json:"measurementUnitId"`
|
||
MeasurementUnitText string `json:"measurementUnitText"`
|
||
OperationType int `json:"operationType"`
|
||
OperationTypeName string `json:"operationTypeName"`
|
||
OwnerID string `json:"ownerId"`
|
||
OwnerName string `json:"ownerName"`
|
||
PurchaseUnitConversionRate string `json:"purchaseUnitConversionRate"`
|
||
PurchaseUnitID int `json:"purchaseUnitId"`
|
||
PurchaseUnitText string `json:"purchaseUnitText"`
|
||
Status int `json:"status"`
|
||
TaxRate string `json:"taxRate"`
|
||
UpcID string `json:"upcId"`
|
||
}
|
||
|
||
type ExianDaSku struct {
|
||
AdventLifeCycle interface{} `json:"adventLifeCycle"`
|
||
CategoryIDFirst int `json:"categoryIdFirst"`
|
||
CategoryIDSecond int `json:"categoryIdSecond"`
|
||
CategoryIDThird int `json:"categoryIdThird"`
|
||
CategoryText string `json:"categoryText"`
|
||
CreatedBy string `json:"createdBy"`
|
||
CustomGoodsCode interface{} `json:"customGoodsCode"`
|
||
CustomGoodsID int `json:"customGoodsId"`
|
||
ElemeGoodsCode string `json:"elemeGoodsCode"`
|
||
ElemeGoodsID string `json:"elemeGoodsId"`
|
||
ElemeOwnerCode string `json:"elemeOwnerCode"`
|
||
ElemeOwnerID int `json:"elemeOwnerId"`
|
||
ExtValues struct {
|
||
} `json:"extValues"`
|
||
GoodsID int `json:"goodsId"`
|
||
GoodsName string `json:"goodsName"`
|
||
GoodsType int `json:"goodsType"`
|
||
Height string `json:"height"`
|
||
ImageCOs []struct {
|
||
ExtValues struct {
|
||
} `json:"extValues"`
|
||
Seq int `json:"seq"`
|
||
URL string `json:"url"`
|
||
} `json:"imageCOs"`
|
||
IsDelete int `json:"isDelete"`
|
||
IsEstimateLifeCycle int `json:"isEstimateLifeCycle"`
|
||
IsShelflife int `json:"isShelflife"`
|
||
IsWeight int `json:"isWeight"`
|
||
Length string `json:"length"`
|
||
LifeCycle int `json:"lifeCycle"`
|
||
LockupLifeCycle interface{} `json:"lockupLifeCycle"`
|
||
MeasurementUnitID int `json:"measurementUnitId"`
|
||
MeasurementUnitText string `json:"measurementUnitText"`
|
||
NetWeight string `json:"netWeight"`
|
||
OperationType int `json:"operationType"`
|
||
OwnerID string `json:"ownerId"`
|
||
OwnerName string `json:"ownerName"`
|
||
PurchaseUnitConversionRate string `json:"purchaseUnitConversionRate"`
|
||
PurchaseUnitID int `json:"purchaseUnitId"`
|
||
PurchaseUnitText string `json:"purchaseUnitText"`
|
||
RejectLifeCycle interface{} `json:"rejectLifeCycle"`
|
||
Status int `json:"status"`
|
||
TaxRate string `json:"taxRate"`
|
||
TemperatureType int `json:"temperatureType"`
|
||
TenantID int `json:"tenantId"`
|
||
UpcIds []string `json:"upcIds"`
|
||
UpdatedBy interface{} `json:"updatedBy"`
|
||
Volume string `json:"volume"`
|
||
Weight string `json:"weight"`
|
||
Width string `json:"width"`
|
||
}
|
||
|
||
type EbaiSku struct {
|
||
SkuID string `json:"sku_id"`
|
||
UpcID string `json:"upc_id"`
|
||
Upc string `json:"upc"`
|
||
Wid string `json:"wid"`
|
||
LeftNum string `json:"left_num"`
|
||
MarketPrice int `json:"market_price"`
|
||
SalePrice float64 `json:"sale_price"`
|
||
Discount int `json:"discount"`
|
||
Enabled string `json:"enabled"`
|
||
PurchaseLimit string `json:"purchase_limit"`
|
||
ShelfNumber string `json:"shelf_number"`
|
||
Ext string `json:"ext"`
|
||
NeedIce string `json:"need_ice"`
|
||
SkuProperty []interface{} `json:"sku_property"`
|
||
ExtCode string `json:"ext_code"`
|
||
WeightFlag string `json:"weight_flag"`
|
||
SaleUnit string `json:"sale_unit"`
|
||
PreminusWeight int `json:"preminus_weight"`
|
||
Minimum string `json:"minimum"`
|
||
SaleStep string `json:"sale_step"`
|
||
PreparationTime string `json:"preparation_time"`
|
||
ProcessType int `json:"process_type"`
|
||
ProcessDetail []interface{} `json:"process_detail"`
|
||
IsInActivity int `json:"is_in_activity"`
|
||
//UpcType string `json:"upc_type"`
|
||
UpcName string `json:"upc_name"`
|
||
BrandID string `json:"brand_id"`
|
||
Description string `json:"description"`
|
||
Rtf string `json:"rtf"`
|
||
Summary string `json:"summary"`
|
||
Photos []struct {
|
||
URL string `json:"url"`
|
||
IsMaster int `json:"is_master"`
|
||
} `json:"photos"`
|
||
Cat1ID string `json:"cat1_id"`
|
||
Cat2ID string `json:"cat2_id"`
|
||
Cat3ID string `json:"cat3_id"`
|
||
Propertys []interface{} `json:"propertys"`
|
||
Length string `json:"length"`
|
||
Width string `json:"width"`
|
||
Height string `json:"height"`
|
||
Weight string `json:"weight"`
|
||
ProductionAddr1 string `json:"production_addr1"`
|
||
ProductionAddr2 string `json:"production_addr2"`
|
||
ProductionAddr3 string `json:"production_addr3"`
|
||
CustomCatID string `json:"custom_cat_id"`
|
||
CustomCatName string `json:"custom_cat_name"`
|
||
Cat1Name string `json:"cat1_name"`
|
||
Cat2Name string `json:"cat2_name"`
|
||
Cat3Name string `json:"cat3_name"`
|
||
BrandName string `json:"brand_name"`
|
||
Brand struct {
|
||
BrandID string `json:"brand_id"`
|
||
BrandName string `json:"brand_name"`
|
||
} `json:"brand"`
|
||
Illustration []interface{} `json:"illustration"`
|
||
IllustrationOrigin []interface{} `json:"illustration_origin"`
|
||
Cat struct {
|
||
Cat1 struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
} `json:"cat1"`
|
||
Cat2 struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
} `json:"cat2"`
|
||
Cat3 struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
} `json:"cat3"`
|
||
} `json:"cat"`
|
||
LengthOrigin string `json:"length_origin"`
|
||
WidthOrigin string `json:"width_origin"`
|
||
HeightOrigin string `json:"height_origin"`
|
||
ProductionAddr1Origin string `json:"production_addr1_origin"`
|
||
ProductionAddr2Origin string `json:"production_addr2_origin"`
|
||
ProductionAddr3Origin string `json:"production_addr3_origin"`
|
||
SummaryOrigin string `json:"summary_origin"`
|
||
Cat1Origin struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
} `json:"cat1_origin"`
|
||
Cat2Origin struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
} `json:"cat2_origin"`
|
||
Cat3Origin struct {
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
} `json:"cat3_origin"`
|
||
BrandOrigin struct {
|
||
BrandID string `json:"brand_id"`
|
||
BrandName string `json:"brand_name"`
|
||
} `json:"brand_origin"`
|
||
IsDrug int `json:"is_drug"`
|
||
SupplierID string `json:"supplier_id"`
|
||
Editable int `json:"editable"`
|
||
IsWaterDiscount int `json:"is_water_discount"`
|
||
DiscountRange int `json:"discount_range"`
|
||
CtrlEdit struct {
|
||
UpcName int `json:"upc_name"`
|
||
Upc int `json:"upc"`
|
||
Cat int `json:"cat"`
|
||
BrandID int `json:"brand_id"`
|
||
Photos int `json:"photos"`
|
||
Description int `json:"description"`
|
||
Volumn int `json:"volumn"`
|
||
Weight int `json:"weight"`
|
||
Discount int `json:"discount"`
|
||
} `json:"ctrl_edit"`
|
||
}
|
||
|
||
type EbaiSkuList struct {
|
||
UpcID string `json:"upc_id"`
|
||
//UpcType string `json:"upc_type"`
|
||
Photos string `json:"photos"`
|
||
UpcName string `json:"upc_name"`
|
||
Upc string `json:"upc"`
|
||
BrandID string `json:"brand_id"`
|
||
Weight string `json:"weight"`
|
||
Wid string `json:"wid"`
|
||
Enabled string `json:"enabled"`
|
||
Cat1ID string `json:"cat1_id"`
|
||
Cat2ID string `json:"cat2_id"`
|
||
Cat3ID string `json:"cat3_id"`
|
||
BrandName string `json:"brand_name"`
|
||
PhotosList []struct {
|
||
URL string `json:"url"`
|
||
IsMaster int `json:"is_master"`
|
||
} `json:"photos_list"`
|
||
Shopsku int `json:"shopsku"`
|
||
IsInActivity int `json:"is_in_activity"`
|
||
}
|
||
|
||
func (a *API) AccessStorePage2(subURL, storeURL2 string, params map[string]interface{}, isPost bool, cookies map[string]string) (retVal map[string]interface{}, err error) {
|
||
if a.GetCookieCount() == 0 {
|
||
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
|
||
}
|
||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||
func() *http.Request {
|
||
var request *http.Request
|
||
var url string
|
||
if storeURL2 != "" {
|
||
url = storeURL2
|
||
} else {
|
||
url = storeURL
|
||
}
|
||
if !isPost {
|
||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(url, subURL, params), nil)
|
||
} else {
|
||
if storeURL2 != "" {
|
||
//result, _ := json.MarshalIndent(params, "", " ")
|
||
request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(url, subURL, nil), strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||
//request.Header.Set("Content-Type", "application/ncp4+json")
|
||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||
} else {
|
||
request, _ = http.NewRequest(http.MethodPost, utils.GenerateGetURL(url, subURL, nil), strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||
request.Header.Set("charset", "UTF-8")
|
||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||
}
|
||
}
|
||
a.FillRequestCookies(request)
|
||
for k, v := range cookies {
|
||
request.AddCookie(&http.Cookie{
|
||
Name: k,
|
||
Value: v,
|
||
})
|
||
}
|
||
return request
|
||
},
|
||
a.config,
|
||
func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||
if jsonResult1 == nil {
|
||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||
}
|
||
retVal = jsonResult1
|
||
if storeURL2 != "" {
|
||
return platformapi.ErrLevelSuccess, nil
|
||
}
|
||
// if jsonResult1["errno"] == nil {
|
||
// if storeURL2 == "" {
|
||
// if jsonResult1[platformapi.KeyData] == nil {
|
||
// baseapi.SugarLogger.Warnf("ebai AccessStorePage2, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||
// } else {
|
||
// return platformapi.ErrLevelRecoverableErr, fmt.Errorf("%s return not json", subURL)
|
||
// }
|
||
// }
|
||
// }
|
||
code := int(utils.MustInterface2Int64(jsonResult1["errno"]))
|
||
if code == ResponseCodeSuccess || code == ResponseCodeSuccess2 {
|
||
if subURL == swithShopURL {
|
||
for _, v := range response.Cookies() {
|
||
if v.Name == "SWITCH_SHOP" {
|
||
retVal = utils.Struct2FlatMap(v)
|
||
break
|
||
}
|
||
}
|
||
} else {
|
||
retVal, _ = jsonResult1["data"].(map[string]interface{})
|
||
}
|
||
return platformapi.ErrLevelSuccess, nil
|
||
}
|
||
newErr := utils.NewErrorIntCode(jsonResult1["errmsg"].(string), code)
|
||
if code == ResponseCodeCallElmFailed {
|
||
return platformapi.ErrLevelRecoverableErr, newErr
|
||
}
|
||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||
})
|
||
return retVal, err
|
||
}
|
||
|
||
func (a *API) AccessStorePage(subURL, storeURL2 string, params map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||
return a.AccessStorePage2(subURL, storeURL2, params, isPost, nil)
|
||
}
|
||
|
||
func (a *API) GetRealMobile4Order(orderId string) (mobile string, err error) {
|
||
retVal, err := a.GetStoreOrderInfo(orderId)
|
||
if err == nil {
|
||
if orderBasic, ok := retVal["order_basic"].(map[string]interface{}); ok {
|
||
return utils.Interface2String(orderBasic["user_phone_call"]), nil
|
||
}
|
||
}
|
||
return "", err
|
||
}
|
||
|
||
func (a *API) GetStoreOrderInfo(orderId string) (storeOrderInfo map[string]interface{}, err error) {
|
||
retVal, err := a.AccessStorePage("crm/orderlist", "", map[string]interface{}{
|
||
"keyword": orderId,
|
||
}, false)
|
||
if err == nil {
|
||
resultList := retVal["order_list"].([]interface{})
|
||
if len(resultList) > 0 {
|
||
return resultList[0].(map[string]interface{}), nil
|
||
}
|
||
return nil, fmt.Errorf("不能找到订单:%s的相关信息", orderId)
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
// todo 与上一个函数重了
|
||
func (a *API) GetStoreOrderInfoList(fromTime, toTime string, shopID string, orderStatus int) (storeOrderList []map[string]interface{}, err error) {
|
||
// pageSize := 20
|
||
pageNo := 1
|
||
params := map[string]interface{}{
|
||
"start_timestamp": utils.Str2Time(fromTime).Unix(),
|
||
"end_timestamp": utils.Str2Time(toTime).Unix(),
|
||
"shop_id": shopID,
|
||
}
|
||
if orderStatus >= 0 {
|
||
params["order_status"] = orderStatus
|
||
}
|
||
for {
|
||
params["page"] = pageNo
|
||
retVal, err2 := a.AccessStorePage("crm/orderlist", "", params, false)
|
||
if err = err2; err == nil {
|
||
resultList := retVal["order_list"].([]interface{})
|
||
storeOrderList = append(storeOrderList, utils.Slice2MapSlice(resultList)...)
|
||
if len(storeOrderList) >= int(utils.MustInterface2Int64(retVal["order_count"])) {
|
||
return storeOrderList, nil
|
||
}
|
||
pageNo++
|
||
} else {
|
||
return nil, err
|
||
}
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) getCommentList(isElm bool, fromTime, toTime time.Time, shopID, supplierID string, replyStatus, level, nonEmpty int) (commentList []map[string]interface{}, err error) {
|
||
pageSize := 200
|
||
pageNo := 1
|
||
|
||
params := map[string]interface{}{
|
||
"start_time": utils.Time2Str(fromTime),
|
||
"end_time": utils.Time2Str(toTime),
|
||
"page_count": pageSize,
|
||
}
|
||
if shopID != "" {
|
||
params["shop_id"] = shopID
|
||
} else if supplierID != "" {
|
||
params["supplier_id"] = supplierID
|
||
}
|
||
if replyStatus != ReplyStatusAll {
|
||
params["reply_status"] = replyStatus
|
||
}
|
||
if level != CommentLevelAll {
|
||
params["level"] = level
|
||
}
|
||
if nonEmpty != CommentContentAll {
|
||
params["nonempty"] = nonEmpty
|
||
}
|
||
fixedURL := fmt.Sprintf("crm/%s", []string{
|
||
"getelecommentlist",
|
||
"getcommentlist",
|
||
}[1-utils.Bool2Int(isElm)])
|
||
for {
|
||
params["page_num"] = pageNo
|
||
retVal, err2 := a.AccessStorePage(fixedURL, "", params, false)
|
||
if err = err2; err == nil && retVal != nil {
|
||
for _, comment := range retVal["comment_list"].([]interface{}) {
|
||
commentMap := comment.(map[string]interface{})
|
||
for _, orderComment := range commentMap["order_commentList"].([]interface{}) {
|
||
orderCommentMap := orderComment.(map[string]interface{})
|
||
orderCommentMap["order_id"] = commentMap["order_id"]
|
||
orderCommentMap["shop_id"] = commentMap["shop_id"]
|
||
commentList = append(commentList, orderComment.(map[string]interface{}))
|
||
}
|
||
}
|
||
if len(commentList) >= int(utils.MustInterface2Int64(retVal["total"])) {
|
||
return commentList, nil
|
||
}
|
||
pageNo++
|
||
} else {
|
||
return nil, err
|
||
}
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) GetEleCommentList(fromTime, toTime time.Time, shopID, supplierID string, replyStatus, level, nonEmpty int) (commentList []map[string]interface{}, err error) {
|
||
return a.getCommentList(false, fromTime, toTime, shopID, supplierID, replyStatus, level, nonEmpty)
|
||
}
|
||
|
||
func (a *API) GetCommentList(fromTime, toTime time.Time, shopID, supplierID string, replyStatus, level, nonEmpty int) (commentList []map[string]interface{}, err error) {
|
||
return a.getCommentList(false, fromTime, toTime, shopID, supplierID, replyStatus, level, nonEmpty)
|
||
}
|
||
|
||
func (a *API) PageGetSkuList(baiduShopID int64) (skuList []map[string]interface{}, err error) {
|
||
pageSize := 200
|
||
pageNo := 1
|
||
params := map[string]interface{}{
|
||
// "upc_type": 2,
|
||
// "weight": 2,
|
||
"wid": baiduShopID,
|
||
"perpage": pageSize,
|
||
}
|
||
for {
|
||
params["curpage"] = pageNo
|
||
retVal, err2 := a.AccessStorePage("commodity/getskulist", "", params, false)
|
||
if err = err2; err == nil {
|
||
for _, sku := range retVal["sku_list"].([]interface{}) {
|
||
skuList = append(skuList, sku.(map[string]interface{}))
|
||
}
|
||
if len(skuList) >= int(utils.Str2Int64(utils.Interface2String(retVal["total"]))) {
|
||
return skuList, nil
|
||
}
|
||
pageNo++
|
||
} else {
|
||
return nil, err
|
||
}
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) PageGetSku(baiduShopID int64, skuID int64) (ebaiSku *EbaiSku, err error) {
|
||
params := map[string]interface{}{
|
||
"wid": baiduShopID,
|
||
"sku_id": skuID,
|
||
}
|
||
retVal, err := a.AccessStorePage("commodity/getsku", "", params, false)
|
||
utils.Map2StructByJson(retVal, &ebaiSku, false)
|
||
return ebaiSku, err
|
||
}
|
||
|
||
func (a *API) PageGetCustomSkuList(baiduShopID int64, customCatID int64) (skuList []map[string]interface{}, err error) {
|
||
params := map[string]interface{}{
|
||
"wid": baiduShopID,
|
||
"custom_cat_id": customCatID,
|
||
}
|
||
retVal, err := a.AccessStorePage("commodity/getCustomSkuList", "", params, false)
|
||
if err == nil {
|
||
return utils.Slice2MapSlice(retVal["sku_list"].([]interface{})), nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) PageGetCustomCatList(baiduShopID int64) (catList []map[string]interface{}, err error) {
|
||
params := map[string]interface{}{
|
||
"wid": baiduShopID,
|
||
}
|
||
retVal, err := a.AccessStorePage("commodity/GetCustomCatList", "", params, false)
|
||
if err == nil {
|
||
return utils.Slice2MapSlice(retVal["cat_list"].([]interface{})), nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) GetStoreList(lng string, lat string, pageNo, pageSize int) (shopListInfo *PageListInfo, err error) {
|
||
if pageNo <= 0 {
|
||
pageNo = 1
|
||
}
|
||
if pageSize > 20 || pageSize <= 0 {
|
||
pageSize = 20
|
||
}
|
||
params := map[string]interface{}{
|
||
"channel": "kitchen",
|
||
"rn": pageSize,
|
||
"pn": pageNo,
|
||
"lng": lng,
|
||
"lat": lat,
|
||
}
|
||
// 水果
|
||
// https://h5.ele.me/restapi/shopping/v3/restaurants?latitude=30.64743&longitude=104.089981&keyword=&offset=0&limit=8&extras[]=activities&extras[]=tags&terminal=h5&rank_id=456ad3b166954bc996324b6fc43a29fb&order_by=0&brand_ids[]=&restaurant_category_ids[]=245
|
||
result, err := a.AccessStorePageNoCookie("newretail/main/shoplist", params)
|
||
if err == nil && result != nil {
|
||
err = utils.Map2StructByJson(result, &shopListInfo, true)
|
||
}
|
||
return shopListInfo, err
|
||
}
|
||
|
||
func (a *API) GetStoreList2(lng float64, lat float64) (shopListInfo *PageListInfo, err error) {
|
||
pageSize := 20
|
||
pageNo := 1
|
||
for {
|
||
retVal, err2 := a.GetStoreList(fmt.Sprintf("%.6f", lng), fmt.Sprintf("%.6f", lat), pageNo, pageSize)
|
||
if err = err2; err == nil {
|
||
if shopListInfo == nil {
|
||
shopListInfo = retVal
|
||
} else {
|
||
shopListInfo.ShopList = append(shopListInfo.ShopList, retVal.ShopList...)
|
||
}
|
||
if len(retVal.ShopList) < pageSize {
|
||
break
|
||
}
|
||
pageNo++
|
||
} else {
|
||
break
|
||
}
|
||
}
|
||
return shopListInfo, err
|
||
}
|
||
|
||
func (a *API) GetStoreInfo(storeId string) (storeInfo map[string]interface{}, err error) {
|
||
params := map[string]interface{}{
|
||
"shop_id": storeId,
|
||
"lng": 0,
|
||
"lat": 0,
|
||
}
|
||
retVal, err := a.AccessStorePageNoCookie("newretail/shop/getshopinfo", params)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
if retVal != nil {
|
||
retVal["shop_id"] = storeId
|
||
}
|
||
return retVal, err
|
||
}
|
||
|
||
func (a *API) GetStoreInfo2(storeID string) (storeInfo *PageShopInfo, err error) {
|
||
retVal, err := a.GetStoreInfo(storeID)
|
||
if err == nil {
|
||
if retVal != nil {
|
||
err = utils.Map2StructByJson(retVal, &storeInfo, true)
|
||
}
|
||
}
|
||
return storeInfo, err
|
||
}
|
||
|
||
func (a *API) AccessStorePageNoCookie(subURL string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||
func() *http.Request {
|
||
fullURL := utils.GenerateGetURL(getStoreURL, subURL, params)
|
||
request, _ := http.NewRequest(http.MethodGet, fullURL, nil)
|
||
if err != nil {
|
||
return nil
|
||
}
|
||
return request
|
||
},
|
||
a.config,
|
||
func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||
if jsonResult1 == nil {
|
||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||
}
|
||
code := int(utils.MustInterface2Int64(jsonResult1["error_no"]))
|
||
if code == ResponseCodeSuccess {
|
||
retVal = jsonResult1["result"].(map[string]interface{})
|
||
return platformapi.ErrLevelSuccess, nil
|
||
} else if code == GetStoreSuccessButUnderfind {
|
||
return platformapi.ErrLevelSuccess, nil
|
||
}
|
||
newErr := utils.NewErrorIntCode(jsonResult1["error_msg"].(string), code)
|
||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||
})
|
||
return retVal, err
|
||
}
|
||
|
||
func (a *API) SwitchShop(baiduShopID int64) (switchShopCookie string, err error) {
|
||
result, err := a.AccessStorePage("crm/manager/switchshop", "", map[string]interface{}{
|
||
"switch_shop_id": baiduShopID,
|
||
}, true)
|
||
if err == nil {
|
||
switchShopCookie = utils.Interface2String(result["Value"])
|
||
}
|
||
return switchShopCookie, err
|
||
}
|
||
|
||
func (a *API) GetShopUserInfo2(switchShopCookie string) (shopUserInfo *PageShopUserInfo, err error) {
|
||
shopInfo, err := a.AccessStorePage2("crm/account/getshopuserinfo", "", nil, true, map[string]string{
|
||
"SWITCH_SHOP": switchShopCookie,
|
||
})
|
||
if err == nil {
|
||
err = utils.Map2StructByJson(shopInfo, &shopUserInfo, true)
|
||
}
|
||
return shopUserInfo, err
|
||
}
|
||
|
||
func (a *API) GetShopUserInfo(baiduShopID int64) (shopUserInfo *PageShopUserInfo, err error) {
|
||
switchShopCookie, err := a.SwitchShop(baiduShopID)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
return a.GetShopUserInfo2(switchShopCookie)
|
||
}
|
||
|
||
func (a *API) GetShopHealthByDetail2(switchShopCookie string) (shopHealthDetail *PageShopHealthInfo, err error) {
|
||
shopInfo, err := a.GetShopUserInfo2(switchShopCookie)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
result, err := a.AccessStorePage2("crm/getshophealthydetail", "", map[string]interface{}{
|
||
"shop_id": shopInfo.EleID,
|
||
}, true, map[string]string{
|
||
"SWITCH_SHOP": switchShopCookie,
|
||
})
|
||
if err == nil {
|
||
if err = utils.Map2StructByJson(result, &shopHealthDetail, true); err == nil {
|
||
shopHealthDetail.MerchantID = shopInfo.MerchantID
|
||
shopHealthDetail.MerchantName = shopInfo.MerchantName
|
||
}
|
||
}
|
||
return shopHealthDetail, err
|
||
}
|
||
|
||
func (a *API) GetShopHealthByDetail(baiduShopID int64) (shopHealthDetail *PageShopHealthInfo, err error) {
|
||
switchShopCookie, err := a.SwitchShop(baiduShopID)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
return a.GetShopHealthByDetail2(switchShopCookie)
|
||
}
|
||
|
||
//查询饿百商家中心商户列表
|
||
// https://be.ele.me/crm/suppliershopstatus?status=1&proxy_business_state=10&pageCount=500&pageNum=1
|
||
func (a *API) GetShopListByPage(status, proxyBusinessState, pageCount, pageNum int) (shopList []*ShopList, totalCount int, err error) {
|
||
params := map[string]interface{}{
|
||
"status": status,
|
||
"proxy_business_state": proxyBusinessState,
|
||
"pageCount": pageCount,
|
||
"pageNum": pageNum,
|
||
}
|
||
retVal, err := a.AccessStorePage("crm/suppliershopstatus", "", params, false)
|
||
if err == nil {
|
||
utils.Map2StructByJson(retVal["shop_list"], &shopList, true)
|
||
totalCount = int(utils.MustInterface2Int64(retVal["total"]))
|
||
}
|
||
return shopList, totalCount, err
|
||
}
|
||
|
||
//饿百骑手增加小费,单位为元,最低0.1元
|
||
// orderID与elemeOrderID任意一个都可以
|
||
// https://be.ele.me/crm/modifytip
|
||
func (a *API) ModifyTip4OrderWaybill(orderID, elemeOrderID string, tip, zhongBaoAskPrice float64) (err error) {
|
||
params := map[string]interface{}{
|
||
"order_id": orderID,
|
||
"eleme_order_id": elemeOrderID,
|
||
"tip": tip,
|
||
"zhongbao_ask_price": zhongBaoAskPrice,
|
||
}
|
||
_, err = a.AccessStorePage("crm/modifytip", "", params, false)
|
||
return err
|
||
}
|
||
|
||
//查询饿百门店橱窗商品信息
|
||
func (a *API) GetStoresShowWindowSkus(baiduShopID int64) (storeShowWindowList []*StoreShowWindowSkuList, err error) {
|
||
// params := map[string]interface{}{
|
||
// "wid": baiduShopID,
|
||
// }
|
||
// result, err := a.AccessStorePage("crm/shop/getcurrshopwindow", "", params, true)
|
||
// if err == nil {
|
||
// err2 := utils.Map2StructByJson(result["sku_list"], &storeShowWindowList, false)
|
||
// if err2 != nil {
|
||
// return storeShowWindowList, err
|
||
// }
|
||
// }
|
||
return storeShowWindowList, err
|
||
}
|
||
|
||
//获取饿鲜达商品库
|
||
func (a *API) GetExianDaSkuDepot(upcID string) (results []*ExianDaSkus, err error) {
|
||
var (
|
||
pageNum = 1
|
||
pageSize = 200
|
||
)
|
||
for {
|
||
params := map[string]interface{}{
|
||
"metas": map[string]interface{}{},
|
||
"params": map[string]interface{}{
|
||
"goodsListQry": map[string]interface{}{
|
||
"pageNum": pageNum,
|
||
"pageSize": pageSize,
|
||
},
|
||
},
|
||
}
|
||
if upcID != "" {
|
||
params["params"].(map[string]interface{})["goodsListQry"].(map[string]interface{})["upcId"] = upcID
|
||
}
|
||
result, err := a.AccessStorePage("bwm_newretail.scm_ic/GoodsServiceI/findGoodsList", "https://ncp.ele.me", params, true)
|
||
if err != nil {
|
||
return results, err
|
||
}
|
||
if result["data"] != nil {
|
||
var exianDaSkus []*ExianDaSkus
|
||
utils.Map2StructByJson(result["data"], &exianDaSkus, false)
|
||
if len(exianDaSkus) > 0 {
|
||
results = append(results, exianDaSkus...)
|
||
}
|
||
if len(exianDaSkus) < pageSize {
|
||
break
|
||
}
|
||
}
|
||
pageNum++
|
||
}
|
||
return results, err
|
||
}
|
||
|
||
//获取饿鲜达单个商品(主要取分类id)
|
||
func (a *API) GetExianDaSku(exdSkuID int64) (results *ExianDaSku, err error) {
|
||
params := map[string]interface{}{
|
||
"metas": map[string]interface{}{},
|
||
"params": map[string]interface{}{
|
||
"goodsGetQry": map[string]interface{}{
|
||
"elemeGoodsId": exdSkuID,
|
||
},
|
||
},
|
||
}
|
||
result, err := a.AccessStorePage("bwm_newretail.scm_ic/GoodsServiceI/findGoodsById", "https://ncp.ele.me", params, true)
|
||
if err != nil {
|
||
return results, err
|
||
}
|
||
utils.Map2StructByJson(result["data"], &results, false)
|
||
return results, err
|
||
}
|
||
|
||
//查询饿百全国账号商品库商品
|
||
func (a *API) GetEbaiDepotSku(supplierID string, upc string) (ebaiSkuList []*EbaiSkuList, err error) {
|
||
params := map[string]interface{}{
|
||
"wid": 0,
|
||
"supplierId": supplierID,
|
||
"upc": upc,
|
||
"curpage": 1,
|
||
"perpage": 20,
|
||
}
|
||
result, err := a.AccessStorePage("commodity/getsuppliergoods", "", params, false)
|
||
if err == nil {
|
||
err2 := utils.Map2StructByJson(result["sku_list"], &ebaiSkuList, false)
|
||
if err2 != nil {
|
||
return ebaiSkuList, err
|
||
}
|
||
}
|
||
return ebaiSkuList, err
|
||
}
|
||
|
||
//查询饿百商品,根据upc
|
||
func (a *API) GetEbaiSku(upcID string, supplierID string) (ebaiSku *EbaiSku, err error) {
|
||
params := map[string]interface{}{
|
||
"supplierId": supplierID,
|
||
"upc_id": upcID,
|
||
}
|
||
result, err := a.AccessStorePage("commodity/getsku", "", params, false)
|
||
if err == nil {
|
||
err2 := utils.Map2StructByJson(result, &ebaiSku, false)
|
||
if err2 != nil {
|
||
return ebaiSku, err
|
||
}
|
||
}
|
||
return ebaiSku, err
|
||
}
|
||
|
||
//饿百分享链接
|
||
func (a *API) GetEbaiShopShareInfo() (err error) {
|
||
_, err = a.AccessStorePage("commodity/getsku", "", nil, false)
|
||
if err == nil {
|
||
|
||
}
|
||
return err
|
||
}
|
||
|
||
type GetMainActivityListResult struct {
|
||
TemplateName interface{} `json:"templateName"`
|
||
BeginTimeRun interface{} `json:"beginTimeRun"`
|
||
EndTimeRun interface{} `json:"endTimeRun"`
|
||
Weeks interface{} `json:"weeks"`
|
||
AllowCancel interface{} `json:"allowCancel"`
|
||
InvestmentType int `json:"investmentType"`
|
||
ActivityPactName interface{} `json:"activityPactName"`
|
||
ActivityPactText interface{} `json:"activityPactText"`
|
||
ActivityPlayRule interface{} `json:"activityPlayRule"`
|
||
OperationalReviewStartTime interface{} `json:"operationalReviewStartTime"`
|
||
OperationalReviewEndTime interface{} `json:"operationalReviewEndTime"`
|
||
SignUpStatus string `json:"signUpStatus"`
|
||
IsLimit bool `json:"is_limit"`
|
||
ActivityType string `json:"activity_type"`
|
||
Weekday interface{} `json:"weekday"`
|
||
Flag string `json:"flag"`
|
||
StopStatus int `json:"stop_status"`
|
||
StopReason string `json:"stop_reason"`
|
||
CreatedAt int64 `json:"created_at"`
|
||
SkuCount int `json:"skuCount"`
|
||
Platform interface{} `json:"platform"`
|
||
PcActivityImgURL interface{} `json:"pcActivityImgUrl"`
|
||
AppActivityImgURL interface{} `json:"appActivityImgUrl"`
|
||
SignUpMinCycleTime interface{} `json:"signUpMinCycleTime"`
|
||
SignUpMaxCycleTime interface{} `json:"signUpMaxCycleTime"`
|
||
ReviewRuleID interface{} `json:"reviewRuleId"`
|
||
ReviewRuleName interface{} `json:"reviewRuleName"`
|
||
InviteActivityType int `json:"inviteActivityType"`
|
||
InvestmentTemplate int `json:"investmentTemplate"`
|
||
InvestmentWay int `json:"investmentWay"`
|
||
IsOld interface{} `json:"isOld"`
|
||
CreatedUserID string `json:"createdUserId"`
|
||
CreatedUserName string `json:"createdUserName"`
|
||
UpdatedAt string `json:"updatedAt"`
|
||
IsDelete int `json:"isDelete"`
|
||
InviteNum int `json:"inviteNum"`
|
||
AcceptNum int `json:"acceptNum"`
|
||
WaitApproveNum int `json:"waitApproveNum"`
|
||
ApproveNum int `json:"approveNum"`
|
||
GoodsNum int `json:"goodsNum"`
|
||
IsNewActivity int `json:"isNewActivity"`
|
||
SubActivityIds []int64 `json:"subActivityIds"`
|
||
CreatedUserNickName string `json:"createdUserNickName"`
|
||
TimeMode int `json:"timeMode"`
|
||
ActivityID int64 `json:"activity_id"`
|
||
StartTime int64 `json:"start_time"`
|
||
EndTime int64 `json:"end_time"`
|
||
Status int `json:"status"`
|
||
RecruitName string `json:"recruit_name"`
|
||
RecruitDesc string `json:"recruit_desc"`
|
||
RecruitStartTime interface{} `json:"recruit_start_time"`
|
||
RecruitEndTime interface{} `json:"recruit_end_time"`
|
||
AllowSign bool `json:"allowSign"`
|
||
Reason string `json:"reason"`
|
||
}
|
||
|
||
//饿百平台流量活动
|
||
//https://ebai-zs.ele.me/api/activities/main-activity-list?pageSize=20&page=1&supplier_id=2233065879
|
||
func (a *API) GetMainActivityList(supplierID int) (getMainActivityListResult []*GetMainActivityListResult, err error) {
|
||
result, err := a.AccessStorePage("api/activities/main-activity-list", "https://ebai-zs.ele.me", map[string]interface{}{
|
||
"supplier_id": supplierID,
|
||
"pageSize": 30,
|
||
"page": 1,
|
||
}, false)
|
||
if err == nil {
|
||
utils.Map2StructByJson(result["data"].(map[string]interface{})["rows"], &getMainActivityListResult, false)
|
||
}
|
||
return getMainActivityListResult, err
|
||
}
|
||
|
||
type GetMainActivityDetailResult struct {
|
||
ID int64 `json:"id"`
|
||
MainActivityID int64 `json:"mainActivityId"`
|
||
ActivityID int64 `json:"activityId"`
|
||
Name string `json:"name"`
|
||
TemplateID int `json:"templateId"`
|
||
TemplateName string `json:"templateName"`
|
||
Description string `json:"description"`
|
||
BeginTime string `json:"beginTime"`
|
||
EndTime string `json:"endTime"`
|
||
BeginTimeRun string `json:"beginTimeRun"`
|
||
EndTimeRun string `json:"endTimeRun"`
|
||
Weeks string `json:"weeks"`
|
||
SigninStartTime string `json:"signinStartTime"`
|
||
SigninEndTime string `json:"signinEndTime"`
|
||
AuditStartTime string `json:"auditStartTime"`
|
||
OperationalReviewStartTime string `json:"operationalReviewStartTime"`
|
||
AuditEndTime string `json:"auditEndTime"`
|
||
OperationalReviewEndTime string `json:"operationalReviewEndTime"`
|
||
WeekRun interface{} `json:"weekRun"`
|
||
ApplyPlatform int `json:"applyPlatform"`
|
||
AllowCancel int `json:"allowCancel"`
|
||
ActivityType int `json:"activityType"`
|
||
InvestmentType int `json:"investmentType"`
|
||
Status int `json:"status"`
|
||
ActivityPactName interface{} `json:"activityPactName"`
|
||
ActivityPactText interface{} `json:"activityPactText"`
|
||
ActivityPlayRule interface{} `json:"activityPlayRule"`
|
||
CreatedAt string `json:"createdAt"`
|
||
SuspendReason interface{} `json:"suspendReason"`
|
||
IsOld int `json:"isOld"`
|
||
InviteActivityType interface{} `json:"inviteActivityType"`
|
||
InvestmentTemplate int `json:"investmentTemplate"`
|
||
IsNewActivity int `json:"isNewActivity"`
|
||
PcActivityImgURL interface{} `json:"pcActivityImgUrl"`
|
||
AppActivityImgURL interface{} `json:"appActivityImgUrl"`
|
||
SignUpMinCycleTime interface{} `json:"signUpMinCycleTime"`
|
||
SignUpMaxCycleTime interface{} `json:"signUpMaxCycleTime"`
|
||
PlayID int `json:"playId"`
|
||
PlayName interface{} `json:"playName"`
|
||
ActivitySignupRecords interface{} `json:"activitySignupRecords"`
|
||
SignUpShopType int `json:"signUpShopType"`
|
||
ResponsePlayDataInfoDTO interface{} `json:"responsePlayDataInfoDTO"`
|
||
GetSubActivityDetailResult *GetSubActivityDetailResult
|
||
}
|
||
|
||
//饿百平台流量活动详情
|
||
//https://ebai-zs.ele.me/api/activities/get-main-activity-detail?id=8134513001
|
||
func (a *API) GetMainActivityDetail(actID int) (getMainActivityDetailResult []*GetMainActivityDetailResult, err error) {
|
||
result, err := a.AccessStorePage("api/activities/get-main-activity-detail", "https://ebai-zs.ele.me", map[string]interface{}{
|
||
"id": actID,
|
||
}, false)
|
||
if err == nil {
|
||
utils.Map2StructByJson(result["data"].(map[string]interface{})["subActivities"], &getMainActivityDetailResult, false)
|
||
}
|
||
return getMainActivityDetailResult, err
|
||
}
|
||
|
||
type GetSubActivityDetailResult struct {
|
||
Activity struct {
|
||
ID int64 `json:"id"`
|
||
MainActivityID int64 `json:"mainActivityId"`
|
||
ActivityID int64 `json:"activityId"`
|
||
Name string `json:"name"`
|
||
TemplateID int `json:"templateId"`
|
||
TemplateName string `json:"templateName"`
|
||
Description string `json:"description"`
|
||
BeginTime string `json:"beginTime"`
|
||
EndTime string `json:"endTime"`
|
||
BeginTimeRun string `json:"beginTimeRun"`
|
||
EndTimeRun string `json:"endTimeRun"`
|
||
Weeks string `json:"weeks"`
|
||
SigninStartTime string `json:"signinStartTime"`
|
||
SigninEndTime string `json:"signinEndTime"`
|
||
AuditStartTime string `json:"auditStartTime"`
|
||
OperationalReviewStartTime interface{} `json:"operationalReviewStartTime"`
|
||
AuditEndTime string `json:"auditEndTime"`
|
||
OperationalReviewEndTime interface{} `json:"operationalReviewEndTime"`
|
||
WeekRun interface{} `json:"weekRun"`
|
||
ApplyPlatform int `json:"applyPlatform"`
|
||
AllowCancel int `json:"allowCancel"`
|
||
ActivityType int `json:"activityType"`
|
||
InvestmentType int `json:"investmentType"`
|
||
Status int `json:"status"`
|
||
ActivityPactName interface{} `json:"activityPactName"`
|
||
ActivityPactText interface{} `json:"activityPactText"`
|
||
ActivityPlayRule interface{} `json:"activityPlayRule"`
|
||
CreatedAt string `json:"createdAt"`
|
||
SuspendReason interface{} `json:"suspendReason"`
|
||
IsOld int `json:"isOld"`
|
||
InviteActivityType int `json:"inviteActivityType"`
|
||
InvestmentTemplate int `json:"investmentTemplate"`
|
||
IsNewActivity int `json:"isNewActivity"`
|
||
PcActivityImgURL interface{} `json:"pcActivityImgUrl"`
|
||
AppActivityImgURL interface{} `json:"appActivityImgUrl"`
|
||
SignUpMinCycleTime interface{} `json:"signUpMinCycleTime"`
|
||
SignUpMaxCycleTime interface{} `json:"signUpMaxCycleTime"`
|
||
PlayID int `json:"playId"`
|
||
PlayName interface{} `json:"playName"`
|
||
ActivitySignupRecords []struct {
|
||
ID int `json:"id"`
|
||
ActivityID int64 `json:"activityId"`
|
||
BeginTime string `json:"beginTime"`
|
||
EndTime string `json:"endTime"`
|
||
SignupStoreCount int `json:"signupStoreCount"`
|
||
SignupCommodityCount int `json:"signupCommodityCount"`
|
||
Status int `json:"status"`
|
||
GatewayActivityID int `json:"gatewayActivityId"`
|
||
ActivityInfoID int `json:"activityInfoId"`
|
||
} `json:"activitySignupRecords"`
|
||
SignUpShopType int `json:"signUpShopType"`
|
||
ResponsePlayDataInfoDTO interface{} `json:"responsePlayDataInfoDTO"`
|
||
MarketPlay struct {
|
||
Model struct {
|
||
UUID string `json:"uuid"`
|
||
WorkspaceUUID string `json:"workspaceUuid"`
|
||
Type string `json:"type"`
|
||
Name string `json:"name"`
|
||
Title string `json:"title"`
|
||
Description string `json:"description"`
|
||
Code struct {
|
||
Content string `json:"content"`
|
||
} `json:"code"`
|
||
Metas []struct {
|
||
Name string `json:"name"`
|
||
Title string `json:"title"`
|
||
Description string `json:"description"`
|
||
FieldType int `json:"fieldType"`
|
||
DataType string `json:"dataType"`
|
||
EditorType string `json:"editorType"`
|
||
DefaultValue interface{} `json:"defaultValue"`
|
||
Props interface{} `json:"props"`
|
||
Array bool `json:"array"`
|
||
FieldIndex int `json:"fieldIndex"`
|
||
Tip interface{} `json:"tip"`
|
||
Group struct {
|
||
Name string `json:"name"`
|
||
Title string `json:"title"`
|
||
} `json:"group"`
|
||
Validator struct {
|
||
ValidatorType string `json:"validatorType"`
|
||
Expression string `json:"expression"`
|
||
ValidatorParameters string `json:"validatorParameters"`
|
||
} `json:"validator"`
|
||
Items interface{} `json:"items"`
|
||
SubFields interface{} `json:"subFields"`
|
||
} `json:"metas"`
|
||
Fields []struct {
|
||
Name string `json:"name"`
|
||
Title string `json:"title"`
|
||
Description interface{} `json:"description"`
|
||
FieldType int `json:"fieldType"`
|
||
DataType string `json:"dataType"`
|
||
EditorType string `json:"editorType"`
|
||
DefaultValue string `json:"defaultValue"`
|
||
Props string `json:"props"`
|
||
Array bool `json:"array"`
|
||
FieldIndex interface{} `json:"fieldIndex"`
|
||
Tip interface{} `json:"tip"`
|
||
Group struct {
|
||
Name string `json:"name"`
|
||
Title string `json:"title"`
|
||
} `json:"group"`
|
||
Validator interface{} `json:"validator"`
|
||
Items interface{} `json:"items"`
|
||
SubFields interface{} `json:"subFields"`
|
||
} `json:"fields"`
|
||
Pipelines []struct {
|
||
ResourceType string `json:"resourceType"`
|
||
Name string `json:"name"`
|
||
Description string `json:"description"`
|
||
FieldMappings []struct {
|
||
FieldName string `json:"fieldName"`
|
||
Expression string `json:"expression"`
|
||
} `json:"fieldMappings"`
|
||
} `json:"pipelines"`
|
||
} `json:"model"`
|
||
Instance struct {
|
||
ID int `json:"id"`
|
||
ComponentType string `json:"componentType"`
|
||
WorkspaceUUID string `json:"workspaceUuid"`
|
||
Metas struct {
|
||
ActivityID string `json:"activityId"`
|
||
ModelUUID string `json:"_model_uuid_"`
|
||
} `json:"metas"`
|
||
Fields struct {
|
||
Creator string `json:"creator"`
|
||
DateRange string `json:"dateRange"`
|
||
UserScope string `json:"userScope"`
|
||
SaleRule string `json:"saleRule"`
|
||
Weekday string `json:"weekday"`
|
||
OutBizContext string `json:"outBizContext"`
|
||
Name string `json:"name"`
|
||
ItemDiscountType string `json:"itemDiscountType"`
|
||
UserLimit string `json:"userLimit"`
|
||
EffectiveChannel string `json:"effectiveChannel"`
|
||
Budget string `json:"budget"`
|
||
TimeRange string `json:"timeRange"`
|
||
} `json:"fields"`
|
||
Features struct {
|
||
} `json:"features"`
|
||
CreateTime string `json:"createTime"`
|
||
} `json:"instance"`
|
||
} `json:"marketPlay"`
|
||
} `json:"activity"`
|
||
Rule struct {
|
||
ID int `json:"id"`
|
||
ActivityID interface{} `json:"activityId"`
|
||
SkuID interface{} `json:"skuId"`
|
||
UpcCode interface{} `json:"upcCode"`
|
||
UpcSet interface{} `json:"upcSet"`
|
||
CommodityName interface{} `json:"commodityName"`
|
||
SkuCatJSON string `json:"skuCatJson"`
|
||
SkuTitleKeyword interface{} `json:"skuTitleKeyword"`
|
||
MaxDiscount interface{} `json:"maxDiscount"`
|
||
MinDiscount interface{} `json:"minDiscount"`
|
||
MaxOriginalPrice string `json:"maxOriginalPrice"`
|
||
MinOriginalPrice string `json:"minOriginalPrice"`
|
||
MaxPresentPrice interface{} `json:"maxPresentPrice"`
|
||
MinPresentPrice interface{} `json:"minPresentPrice"`
|
||
CommodityAmount interface{} `json:"commodityAmount"`
|
||
MaxCommodityAmount int `json:"maxCommodityAmount"`
|
||
SevenDaysMinValidOrderCnt int `json:"sevenDaysMinValidOrderCnt"`
|
||
SevenDaysMaxValidOrderCnt int `json:"sevenDaysMaxValidOrderCnt"`
|
||
ThirtyDaysMinValidOrderCnt int `json:"thirtyDaysMinValidOrderCnt"`
|
||
ThirtyDaysMaxValidOrderCnt int `json:"thirtyDaysMaxValidOrderCnt"`
|
||
SevenDaysMinTotalAmt string `json:"sevenDaysMinTotalAmt"`
|
||
SevenDaysMaxTotalAmt string `json:"sevenDaysMaxTotalAmt"`
|
||
ThirtyDaysMinTotalAmt string `json:"thirtyDaysMinTotalAmt"`
|
||
ThirtyDaysMaxTotalAmt string `json:"thirtyDaysMaxTotalAmt"`
|
||
SevenDaysMinPrice int `json:"sevenDaysMinPrice"`
|
||
FifteenDaysMinPrice int `json:"fifteenDaysMinPrice"`
|
||
Type interface{} `json:"type"`
|
||
MinCommodityStocks int `json:"minCommodityStocks"`
|
||
MaxCommodityStocks int `json:"maxCommodityStocks"`
|
||
SkuCategorySource int `json:"skuCategorySource"`
|
||
} `json:"rule"`
|
||
Status struct {
|
||
Value string `json:"value"`
|
||
Reason string `json:"reason"`
|
||
} `json:"status"`
|
||
CityAgentAllow bool `json:"cityAgentAllow"`
|
||
UploadedBefore bool `json:"uploadedBefore"`
|
||
}
|
||
|
||
//饿百平台流量活动详情
|
||
//https://ebai-zs.ele.me/api/activities/get-sub-activity-detail?id=6134599001&isMobile=0
|
||
func (a *API) GetSubActivityDetail(actID int) (getSubActivityDetailResult *GetSubActivityDetailResult, err error) {
|
||
result, err := a.AccessStorePage("api/activities/get-sub-activity-detail", "https://ebai-zs.ele.me", map[string]interface{}{
|
||
"id": actID,
|
||
}, false)
|
||
if err == nil {
|
||
utils.Map2StructByJson(result["data"].(map[string]interface{}), &getSubActivityDetailResult, false)
|
||
}
|
||
return getSubActivityDetailResult, err
|
||
}
|
||
|
||
//饿百修改门店
|
||
//https://ebai-zs.ele.me/api/activities/get-sub-activity-detail?id=6134599001&isMobile=0
|
||
func (a *API) ModifyShop() (err error) {
|
||
_, err = a.AccessStorePage("h5/mtop.eleme.newretail.shop.admin.ebai.pc.store.modifyshop/1.0/?jsv=2.6.1&appKey=12574478&t=1629193871490&sign=c98e4f2e874ce2300ac77810ca86b1ad&api=mtop.eleme.newretail.shop.admin.ebai.pc.store.modifyShop&v=1.0&H5Request=true&type=originaljson&dataType=json",
|
||
"https://nrshop.ele.me", map[string]interface{}{
|
||
"data": `{"wid":"32267358118","name":"好菜鲜生(龙宫市场店)","categoryId":277,"categoryName":"厨房生鲜","businessFormId":1917869373,"provinceName":"福建省","provinceId":10013,"cityName":"泉州市","cityId":102,"countyName":"鲤城区","countyId":5416,"address":"福建省泉州市鲤城区鲤中街道百源社区龙宫市场内","longitude":"118.5950827921","latitude":"24.903530599638","baiduTakeoutLogo":"https://image-star.elemecdn.com/pb/b79d499b9b0be5deb3ee3ce71bf29ad0a8"}`,
|
||
}, true)
|
||
return err
|
||
}
|