103 lines
4.4 KiB
Go
103 lines
4.4 KiB
Go
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
|
|
}
|