验证各平台cookie是否失效
This commit is contained in:
@@ -4,6 +4,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jd"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api/apimanager"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
@@ -14,6 +22,11 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CheckCookie struct {
|
||||||
|
VendorID int `json:"vendorID"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) {
|
func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) {
|
||||||
var (
|
var (
|
||||||
apiFunction string
|
apiFunction string
|
||||||
@@ -23,8 +36,10 @@ func AddOperateEvent(ctx *jxcontext.Context, accessUUID string) (err error) {
|
|||||||
if url != "" {
|
if url != "" {
|
||||||
apiFunction = url[strings.LastIndex(url, "/")+1 : len(url)]
|
apiFunction = url[strings.LastIndex(url, "/")+1 : len(url)]
|
||||||
}
|
}
|
||||||
if apiFunction[0:2] == "Get" {
|
if apiFunction != "" {
|
||||||
return err
|
if apiFunction[0:3] == "Get" {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
event := &model.OperateEvent{
|
event := &model.OperateEvent{
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
@@ -97,3 +112,71 @@ func GetOperateEvents(ctx *jxcontext.Context, apiFunction, name string, operateT
|
|||||||
}
|
}
|
||||||
return pageInfo, err
|
return pageInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetCheckVendorCookie(ctx *jxcontext.Context, vendorIDs []int, isAuto bool) (ccList []*CheckCookie, err error) {
|
||||||
|
var (
|
||||||
|
ebaiOrderID = "1577329467196263592"
|
||||||
|
ebaiErr = "return not json"
|
||||||
|
mtOrderID = "69761763472881638"
|
||||||
|
mtStoreID = "6976176"
|
||||||
|
jdUpcCode = "6952395700895"
|
||||||
|
jdErr = "请输入用户名"
|
||||||
|
errMsg = ""
|
||||||
|
)
|
||||||
|
for _, v := range vendorIDs {
|
||||||
|
cc := &CheckCookie{}
|
||||||
|
switch v {
|
||||||
|
case 3:
|
||||||
|
resultMap, err := api.EbaiAPI.GetStoreOrderInfo(ebaiOrderID)
|
||||||
|
if len(resultMap) < 1 && err != nil {
|
||||||
|
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
|
if strings.Contains(errExt.ErrMsg(), ebaiErr) {
|
||||||
|
//Cookie无效了
|
||||||
|
errMsg += " 饿百Cookie无效了!"
|
||||||
|
cc.VendorID = v
|
||||||
|
cc.Status = "无效"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Cookie有效
|
||||||
|
cc.VendorID = v
|
||||||
|
cc.Status = "有效"
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
result, err := api.MtwmAPI.GetDistributeOrderDetail(mtOrderID, mtStoreID)
|
||||||
|
if result == nil && err == nil {
|
||||||
|
//Cookie无效
|
||||||
|
errMsg += " 美团Cookie无效了!"
|
||||||
|
cc.VendorID = v
|
||||||
|
cc.Status = "无效"
|
||||||
|
} else if result != nil {
|
||||||
|
//Cookie有效
|
||||||
|
cc.VendorID = v
|
||||||
|
cc.Status = "有效"
|
||||||
|
}
|
||||||
|
case 0:
|
||||||
|
for _, vv := range apimanager.CurAPIManager.GetAppOrgCodeList(v) {
|
||||||
|
result, err := jd.GetAPI(vv).GetJdUpcCodeByName("", jdUpcCode, 1, 5)
|
||||||
|
if len(result) < 1 && err != nil {
|
||||||
|
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
|
if strings.Contains(errExt.ErrMsg(), jdErr) {
|
||||||
|
//Cookie无效
|
||||||
|
errMsg += " 京东Cookie无效了!"
|
||||||
|
cc.VendorID = v
|
||||||
|
cc.Status = "无效"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Cookie有效
|
||||||
|
cc.VendorID = v
|
||||||
|
cc.Status = "有效"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ccList = append(ccList, cc)
|
||||||
|
}
|
||||||
|
if isAuto && len(ccList) > 0 {
|
||||||
|
globals.SugarLogger.Warnf("GetCheckVendorCookie", errMsg)
|
||||||
|
}
|
||||||
|
return ccList, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ var (
|
|||||||
"01:00:00",
|
"01:00:00",
|
||||||
}
|
}
|
||||||
createStorePriceTimeList = []string{
|
createStorePriceTimeList = []string{
|
||||||
|
"08:00:00",
|
||||||
|
"18:00:00",
|
||||||
|
}
|
||||||
|
checkCookieList = []string{
|
||||||
"02:00:00",
|
"02:00:00",
|
||||||
}
|
}
|
||||||
refreshPageActTimeList = []string{
|
refreshPageActTimeList = []string{
|
||||||
@@ -151,6 +155,9 @@ func Init() {
|
|||||||
ScheduleTimerFunc("AutoFocusStoreSkusForTopSkus", func() {
|
ScheduleTimerFunc("AutoFocusStoreSkusForTopSkus", func() {
|
||||||
cms.AutoFocusStoreSkusForTopSkus(jxcontext.AdminCtx, true, true)
|
cms.AutoFocusStoreSkusForTopSkus(jxcontext.AdminCtx, true, true)
|
||||||
}, createStorePriceTimeList)
|
}, createStorePriceTimeList)
|
||||||
|
ScheduleTimerFunc("GetCheckVendorCookie", func() {
|
||||||
|
event.GetCheckVendorCookie(jxcontext.AdminCtx, []int{0, 1, 3}, true)
|
||||||
|
}, checkCookieList)
|
||||||
}
|
}
|
||||||
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
ScheduleTimerFunc("AutoSaleStoreSku", func() {
|
||||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
||||||
@@ -229,7 +236,7 @@ func doDailyWork() {
|
|||||||
//刷新京东门店的等级
|
//刷新京东门店的等级
|
||||||
cms.RefreshJdLevel(jxcontext.AdminCtx)
|
cms.RefreshJdLevel(jxcontext.AdminCtx)
|
||||||
//删除操作日志
|
//删除操作日志
|
||||||
event.DeleteOperateEventAndDetail(jxcontext.AdminCtx, time.Now().AddDate(0, 0, -7))
|
event.DeleteOperateEventAndDetail(jxcontext.AdminCtx, time.Now().AddDate(0, -1, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
|||||||
@@ -44,5 +44,11 @@ func (c *EventController) GetOperateEvents() {
|
|||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /GetCheckVendorCookie [get]
|
// @router /GetCheckVendorCookie [get]
|
||||||
func (c *EventController) GetCheckVendorCookie() {
|
func (c *EventController) GetCheckVendorCookie() {
|
||||||
|
var vendorIDList []int
|
||||||
|
c.callGetCheckVendorCookie(func(params *tEventGetCheckVendorCookieParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
if jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil {
|
||||||
|
retVal, err = event.GetCheckVendorCookie(params.Ctx, vendorIDList, false)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user