From b6ee19a92fbb37db486ca7e0e2852aeba0cacdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 26 Mar 2020 16:56:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=B6=E8=B1=B9cookie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/misc/misc.go | 5 +---- business/partner/purchase/yb/store_sku.go | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 90f1d2a0a..c94fad6c2 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -248,9 +248,7 @@ func Init() { if configs, err := dao.QueryConfigs(dao.GetDB(), "jd2StorePageCookie", model.ConfigTypeCookie, ""); err == nil { jd2StorePageCookie = configs[0].Value } - if configs, err := dao.QueryConfigs(dao.GetDB(), "yinbaoCookie", model.ConfigTypeCookie, ""); err == nil { - yinbaoCookie = configs[0].Value - } + if globals.Jd2OrgCode != "" { api.Jd2API.SetJdCookie(jd2StorePageCookie) } @@ -265,7 +263,6 @@ func Init() { api.JdAPI.SetJdCookie(JdStorePageCookie) api.JdPageAPI.SetCookie(jdapi.AccessStorePageCookieName, JdStorePageCookie) api.JdPageAPI.SetCookie(jdapi.AccessStorePageCookieName2, JdStorePageCookie) - api.YinBaoAPI.SetCookie(".POSPALAUTH30220", yinbaoCookie) } func syncStoreSku() { diff --git a/business/partner/purchase/yb/store_sku.go b/business/partner/purchase/yb/store_sku.go index 0a307e539..57e10c78e 100644 --- a/business/partner/purchase/yb/store_sku.go +++ b/business/partner/purchase/yb/store_sku.go @@ -4,6 +4,8 @@ import ( "fmt" "regexp" + "git.rosy.net.cn/jx-callback/business/jxstore/cms" + "git.rosy.net.cn/baseapi/platformapi/yinbaoapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/business/jxutils" @@ -178,9 +180,7 @@ func (p *PurchaseHandler) GetStoreAllCategories(ctx *jxcontext.Context, storeID func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) { if globals.EnableYbStoreWrite { - api.YinBaoAPI.SetCookie("pageOpenCount", utils.Int2Str(api.YinBaoAPI.GetPageCount())) - fmt.Println("test11111111111111111111111111111111111111", api.YinBaoAPI.GetPageCount()) - fmt.Println("test11111111111111111111111111111111111111", api.YinBaoAPI.GetCookie(".POSPALAUTH30220")) + buildYbApiCookie(ctx) vendorOrgCode, err := getVendorOrgCode(storeID) if err != nil { return err @@ -198,8 +198,22 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in return err } +func buildYbApiCookie(ctx *jxcontext.Context) { + yinbaoCookiePageCount := "" + if configs, err := dao.QueryConfigs(dao.GetDB(), "yinbaoCookie", model.ConfigTypeCookie, ""); err == nil { + yinbaoCookie := configs[0].Value + api.YinBaoAPI.SetCookie(".POSPALAUTH30220", yinbaoCookie) + if configs2, err := dao.QueryConfigs(dao.GetDB(), "yinbaoCookiePageCount", model.ConfigTypeCookie, ""); err == nil { + yinbaoCookiePageCount = configs2[0].Value + api.YinBaoAPI.SetCookie("pageOpenCount", yinbaoCookiePageCount) + } + } + cms.UpdateConfig(ctx, "yinbaoCookiePageCount", "Cookie", utils.Int64ToStr(utils.Str2Int64(yinbaoCookiePageCount)+1)) +} + func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) { if globals.EnableYbStoreWrite { + buildYbApiCookie(ctx) vendorOrgCode, err := getVendorOrgCode(storeID) if err != nil { return err @@ -215,6 +229,7 @@ func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID in func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) { if globals.EnableYbStoreWrite { + buildYbApiCookie(ctx) vendorOrgCode, err := getVendorOrgCode(storeID) if err != nil { return err