aa
This commit is contained in:
102
platformapi/mtwmapi/act_page.go
Normal file
102
platformapi/mtwmapi/act_page.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func (a *API) AccessActPage(subURL string, params map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||||
if a.GetCookieCount() == 0 {
|
||||
return nil, fmt.Errorf("需要设置User Cookie才能使用此方法")
|
||||
}
|
||||
rootURL := getRootURL(subURL)
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
var request *http.Request
|
||||
if isPost {
|
||||
data, _ := json.Marshal(params)
|
||||
fullURL := utils.GenerateGetURL(rootURL, subURL, nil)
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(data)))
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
} else {
|
||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(rootURL, subURL, params), nil)
|
||||
}
|
||||
a.FillRequestCookies(request)
|
||||
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 jsonResult1["code"] == nil {
|
||||
return platformapi.ErrLevelGeneralFail, fmt.Errorf("返回结果格式不正常")
|
||||
}
|
||||
code := int(utils.MustInterface2Int64(jsonResult1["code"]))
|
||||
if code == ResponseCodeSuccess {
|
||||
retVal, _ = jsonResult1["data"].(map[string]interface{})
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
}
|
||||
newErr := utils.NewErrorIntCode(jsonResult1["msg"].(string), code)
|
||||
baseapi.SugarLogger.Debugf("mtwm AccessUserPage failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
type GetCenterListResult struct {
|
||||
ActivityStartTime int `json:"activityStartTime"`
|
||||
ActivityEndTime int `json:"activityEndTime"`
|
||||
ID int `json:"id"`
|
||||
InviteID int `json:"inviteId"`
|
||||
PoiID int `json:"poiId"`
|
||||
SegmentID int `json:"segmentId"`
|
||||
Name string `json:"name"`
|
||||
BriefIntroduction string `json:"briefIntroduction"`
|
||||
EndTime int `json:"endTime"`
|
||||
Status int `json:"status"`
|
||||
ActivityType string `json:"activityType"`
|
||||
RegistrationForm string `json:"registrationForm"`
|
||||
ActivityRule string `json:"activityRule"`
|
||||
ActivityIntroduction string `json:"activityIntroduction"`
|
||||
OperationAdvice string `json:"operationAdvice"`
|
||||
SegmentType int `json:"segmentType"`
|
||||
Faq string `json:"faq"`
|
||||
IsEntered int `json:"isEntered"`
|
||||
EnterTime int `json:"enterTime"`
|
||||
ApproveStatus int `json:"approveStatus"`
|
||||
EnterID int `json:"enterId"`
|
||||
MatchPoiBaseFilter int `json:"matchPoiBaseFilter"`
|
||||
WeekTimes string `json:"weekTimes"`
|
||||
PoiApplyStatus int `json:"poiApplyStatus"`
|
||||
Period string `json:"period"`
|
||||
PoiInviteType int `json:"poiInviteType"`
|
||||
PoiCurrentPolicy interface{} `json:"poiCurrentPolicy"`
|
||||
PoiPolicyType int `json:"poiPolicyType"`
|
||||
EnteredDataUnionStatus int `json:"enteredDataUnionStatus"`
|
||||
ActivityDateList []interface{} `json:"activityDateList"`
|
||||
RejectComment interface{} `json:"rejectComment"`
|
||||
PoiCouponVoListJSON interface{} `json:"poiCouponVoListJson"`
|
||||
PoiRedPackageVoJSON interface{} `json:"poiRedPackageVoJson"`
|
||||
CanEnter int `json:"canEnter"`
|
||||
CreateTime int `json:"createTime"`
|
||||
IsCanModify int `json:"isCanModify"`
|
||||
EnteredDataJSON interface{} `json:"enteredDataJson"`
|
||||
}
|
||||
|
||||
func (a *API) GetCenterList(vendorStoreID string) (getCenterListResult []*GetCenterListResult, err error) {
|
||||
result, err := a.AccessActPage("api/sg/promotion/invite/centerList", map[string]interface{}{
|
||||
"wmPoiId": vendorStoreID,
|
||||
}, true)
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result["items"], &getCenterListResult, false)
|
||||
}
|
||||
return getCenterListResult, err
|
||||
}
|
||||
15
platformapi/mtwmapi/act_page_test.go
Normal file
15
platformapi/mtwmapi/act_page_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func TestGetCenterList(t *testing.T) {
|
||||
result, err := api.GetCenterList("7634034")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
@@ -27,8 +27,8 @@ func init() {
|
||||
//商超
|
||||
// api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_tE0txRtx7CRuPIOjh2BH4w") //token_nH_IlcWQKAkZBqklwItNRw
|
||||
cookieStr := `
|
||||
__mta=188489239.1577327492709.1577327492709.1577327492709.1; uuid=e8034a4d222c4b51b81c.1574126611.1.0.0; _ga=GA1.2.827950563.1574128001; uuid_update=true; _lxsdk_cuid=16eb02a8a02c8-0a92cb9af9798c-3d375b01-15f900-16eb02a8a02c8; _lxsdk=16eb02a8a02c8-0a92cb9af9798c-3d375b01-15f900-16eb02a8a02c8; device_uuid=!aaa93749-2445-4e1e-b178-956ac0ea5e45; t_lxid=1719bfe9d5e30-0cf08957b60ff-3d375b01-15f900-1719bfe9d5fc8-tid; pushToken=0-AQeAm60pIt3VbpGu3MbPpMfRVaeCxP9tacRSFq7lmI*; lsu=; _gid=GA1.2.1480321802.1616033831; e_u_id_3299326472=e5ae16afe444349d24af7d33b66620a1; wpush_server_url=wss://wpush.meituan.com; acctId=57396785; token=0mSedih8udpe6yOnYDkGCYUi1ZoBjKT5Cvky4kBDolyA*; brandId=-1; wmPoiId=-1; isOfflineSelfOpen=0; city_id=0; isChain=1; existBrandPoi=true; ignore_set_router_proxy=true; region_id=; region_version=0; newCategory=true; bsid=yfpaaPKXj1BNDzKZXSLxpftf3dEnZ22uHvnqWXHKQ9ndFU5rb_YFk5vDi01MoEc6K91Ly6a6aqXT07tw1UI4Vg; cityId=510100; provinceId=510000; city_location_id=0; location_id=0; shopCategory=food; set_info=%7B%22wmPoiId%22%3A-1%2C%22ignoreSetRouterProxy%22%3Atrue%7D; cacheTimeMark=2021-03-18; JSESSIONID=8lgvdhuza3yi1gzvnefmo61t8; igateApp=shangouepc; pharmacistAccount=0; _lxsdk_s=17843d476fd-a90-21a-ca1%7C%7C29
|
||||
`
|
||||
uuid=e8034a4d222c4b51b81c.1574126611.1.0.0; _ga=GA1.2.827950563.1574128001; _lxsdk_cuid=16eb02a8a02c8-0a92cb9af9798c-3d375b01-15f900-16eb02a8a02c8; _lxsdk=16eb02a8a02c8-0a92cb9af9798c-3d375b01-15f900-16eb02a8a02c8; t_lxid=1719bfe9d5e30-0cf08957b60ff-3d375b01-15f900-1719bfe9d5fc8-tid; igateApp=recoanalysis; lsu=; mtcdn=K; token=0mSedih8udpe6yOnYDkGCYUi1ZoBjKT5Cvky4kBDolyA*; acctId=57396785; _source=PC; bsid=yfpaaPKXj1BNDzKZXSLxpftf3dEnZ22uHvnqWXHKQ9ndFU5rb_YFk5vDi01MoEc6K91Ly6a6aqXT07tw1UI4Vg; virtual=0; vacctId=0; acctName=null; terminal=bizCenter; logan_custom_report=; wmPoiId=7634034; logan_session_token=fwxhqemst6q8uff1oztv; _lxsdk_s=1787cb12bac-7cd-4f6-eb2%7C%7C172
|
||||
`
|
||||
api.SetCookieWithStr(cookieStr)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
const (
|
||||
userURL = "http://i.waimai.meituan.com"
|
||||
orderURL = "https://shangoue.meituan.com"
|
||||
actURL = "https://waimaieapp.meituan.com"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -45,6 +46,7 @@ var (
|
||||
"reuse/sc/product/packageprice/w/update": orderURL,
|
||||
"reuse/sc/product/packageprice/r/get": orderURL,
|
||||
"reuse/sc/product/retail/r/getStandardProductListWithCond": orderURL,
|
||||
"api/sg/promotion/invite/centerList": actURL,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user