package jdshopapi import ( "encoding/json" "fmt" "net/http" "regexp" "strings" "time" "git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi/platformapi" "git.rosy.net.cn/baseapi/utils" ) var ( regexpOrderDetailTable = regexp.MustCompile(`([\s\S]*?)
`) regexpOrderDetailTd = regexp.MustCompile(`(.*?)`) regexpOrderDetailMobile = regexp.MustCompile(`(.*?)`) regexpOrderDetailDay = regexp.MustCompile(`期望送货日期:[\s\S]*?(.*?)`) regexpOrderDetailDay2 = regexp.MustCompile(`配送日期:[\s\S]*?(.*?)`) regexpOrderDetailPay = regexp.MustCompile(`应支付金额:[\s\S]*?[\s\S]*?¥(.*?[\s\S]*?)`) regexpOrderDetailMobileKey = regexp.MustCompile(`accesskey="(.*?)"`) ) const ( JdsOrderDeliverTypeStore = 1274 JdsOrderDeleverTypeSelf = 332098 ) func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}, isPost bool) (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 if isPost { request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(bizParams).Encode())) request.Header.Set("Content-Type", "application/x-www-form-urlencoded") } else { request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(fullURL, "", bizParams), 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") } if strings.Contains(bodyStr, "登录") || strings.Contains(bodyStr, "访问的内容") { return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!") } if err == nil { if jsonResult1["error_response"] != nil { errLevel = platformapi.ErrLevelGeneralFail err = utils.NewErrorCode(jsonResult1["error_response"].(map[string]interface{})["zh_desc"].(string), jsonResult1["error_response"].(map[string]interface{})["code"].(string)) baseapi.SugarLogger.Debugf("jdeclp AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true)) } retVal = jsonResult1 } return errLevel, err }) return retVal, err } func (a *API) AccessStorePage2(fullURL string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) { if a.GetCookieCount() == 0 { return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法") } data, _ := json.Marshal(bizParams) err = platformapi.AccessPlatformAPIWithRetry(a.client, func() *http.Request { request, _ := http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(data))) request.Header.Set("Content-Type", "application/json;charset=UTF-8") 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") } if strings.Contains(bodyStr, "登录") || strings.Contains(bodyStr, "访问的内容") { return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!") } if err == nil { if jsonResult1["error_response"] != nil { errLevel = platformapi.ErrLevelGeneralFail err = utils.NewErrorCode(jsonResult1["error_response"].(map[string]interface{})["zh_desc"].(string), jsonResult1["error_response"].(map[string]interface{})["code"].(string)) baseapi.SugarLogger.Debugf("jdeclp AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true)) } retVal = jsonResult1 } return errLevel, err }) return retVal, err } type CreateShopCategoryParam struct { HomeShow string `json:"homeShow"` ID string `json:"id"` Open string `json:"open"` OrderNo string `json:"orderNo"` ParentID string `json:"parentId"` Title string `json:"title"` Type string `json:"type"` } //京东商城创建或修改店内分类 //https://seller.shop.jd.com/vendershop/vendershop_shopCategory.action# func (a *API) CreateShopCategory(createShopCategoryParam []*CreateShopCategoryParam) (status int64, err error) { data, _ := json.MarshalIndent(createShopCategoryParam, "", "") result, err := a.AccessStorePage("https://seller.shop.jd.com/vendershop/vendershop_doShopCategory.action", map[string]interface{}{ "categoryJson": string(data), }, true) if err == nil { status = utils.Interface2Int64WithDefault(result["fakeData"], -1) } return status, err } //京东商城设置门店营业状态 //https://stores.shop.jd.com/stores/updateStoreStatus?storeId=24330156&storeStatus=6 func (a *API) UpdateStoreStatus(storeID, storeStatus int) (err error) { _, err = a.AccessStorePage("https://stores.shop.jd.com/stores/updateStoreStatus", map[string]interface{}{ "storeId": storeID, "storeStatus": storeStatus, }, false) return err } type NewInfoListResult struct { ID int `json:"id"` VenderID int `json:"venderId"` CompanyID interface{} `json:"companyId"` CompanyName interface{} `json:"companyName"` StoreType interface{} `json:"storeType"` Name string `json:"name"` AddCode int `json:"addCode"` AddCodeName interface{} `json:"addCodeName"` AddName string `json:"addName"` AddCode1 int `json:"addCode1"` AddCode2 int `json:"addCode2"` AddCode4 interface{} `json:"addCode4"` BussinessBeginTime interface{} `json:"bussinessBeginTime"` BussinessEndTime interface{} `json:"bussinessEndTime"` AddNameExtend interface{} `json:"addNameExtend"` Coordinate interface{} `json:"coordinate"` CommodityNum int `json:"commodityNum"` Status interface{} `json:"status"` Created interface{} `json:"created"` Modified interface{} `json:"modified"` Phone interface{} `json:"phone"` EncryptPhone interface{} `json:"encryptPhone"` StoreGroupIds interface{} `json:"storeGroupIds"` VirtualStoresIds interface{} `json:"virtualStoresIds"` VirtualStoresInDB interface{} `json:"virtualStoresInDB"` Address interface{} `json:"address"` Account interface{} `json:"account"` UserName interface{} `json:"userName"` Pwd interface{} `json:"pwd"` CrmPwd interface{} `json:"crmPwd"` Type interface{} `json:"type"` AccountIsAuth interface{} `json:"accountIsAuth"` Slogan interface{} `json:"slogan"` Mobilephone interface{} `json:"mobilephone"` EncryptMobilephone interface{} `json:"encryptMobilephone"` UnboundedBizType interface{} `json:"unboundedBizType"` ExStoreID string `json:"exStoreId"` ExStoreSource interface{} `json:"exStoreSource"` MdImg interface{} `json:"mdImg"` AccountName interface{} `json:"accountName"` StoreStatus int `json:"storeStatus"` BusinessTime interface{} `json:"businessTime"` IsBindingPurse interface{} `json:"isBindingPurse"` GroupName interface{} `json:"groupName"` SplitID interface{} `json:"splitId"` BusinessID interface{} `json:"businessId"` BrandID interface{} `json:"brandId"` ReturnType interface{} `json:"returnType"` PhoneType interface{} `json:"phoneType"` AfterPhone interface{} `json:"afterPhone"` DeptID interface{} `json:"deptId"` Remark interface{} `json:"remark"` AuditStatus int `json:"auditStatus"` CategoryID1 interface{} `json:"categoryId1"` CategoryID2 interface{} `json:"categoryId2"` CategoryName1 interface{} `json:"categoryName1"` CategoryName2 interface{} `json:"categoryName2"` ImgURL interface{} `json:"imgUrl"` StoreStatusName string `json:"storeStatusName"` AuditStatusName string `json:"auditStatusName"` OperateStatus interface{} `json:"operateStatus"` Pin interface{} `json:"pin"` } //京东商城查询门店营业状态 //https://stores.shop.jd.com/stores/newInfoList func (a *API) NewInfoList(storeID int64) (newInfoListResult *NewInfoListResult, err error) { var newInfoListResult2 []*NewInfoListResult result, err := a.AccessStorePage2("https://stores.shop.jd.com/stores/newInfoList", map[string]interface{}{ "storeId": storeID, "inCache": 0, "index": 1, "pageSize": 10, "companyName": nil, "exStoreId": nil, "storeName": nil, "storeStatus": nil, }) if err == nil { utils.Map2StructByJson(result["list"], &newInfoListResult2, false) } newInfoListResult = newInfoListResult2[0] return newInfoListResult, err } type AllOrdersParam struct { Current int `json:"current"` PageSize int `json:"pageSize"` SortName string `json:"sortName"` OrderID string `json:"orderId"` SkuName string `json:"skuName"` OrderCreateDateRange []string `json:"orderCreateDateRange"` OrderCompleteDateRange []interface{} `json:"orderCompleteDateRange"` ReceiverName string `json:"receiverName"` ReceiverTel string `json:"receiverTel"` UserPin string `json:"userPin"` SkuID string `json:"skuId"` LogiNo string `json:"logiNo"` PaymentType string `json:"paymentType"` OrderType string `json:"orderType"` OrderSource string `json:"orderSource"` DeliveryType string `json:"deliveryType"` StoreID string `json:"storeId"` HuoHao string `json:"huoHao"` OrderStatusArray []interface{} `json:"orderStatusArray"` SelectedTabName string `json:"selectedTabName"` } type AllOrdersResult struct { TotalCount int `json:"totalCount"` Current int `json:"current"` OrderList []struct { XiaDanTime interface{} `json:"xiaDanTime"` ModifiedTime interface{} `json:"modifiedTime"` CustomsName interface{} `json:"customsName"` MerchantName interface{} `json:"merchantName"` CustomsModelName interface{} `json:"customsModelName"` ProcessStatus interface{} `json:"processStatus"` StorageAndShipStatus interface{} `json:"storageAndShipStatus"` ProcessStatusMsg interface{} `json:"processStatusMsg"` OrderID int64 `json:"orderId"` SelectedTabName interface{} `json:"selectedTabName"` VenderID int `json:"venderId"` OrderCreateTime string `json:"orderCreateTime"` PaymentConfirmTime string `json:"paymentConfirmTime"` OrderCompleteTime interface{} `json:"orderCompleteTime"` OrderItems []struct { WareID interface{} `json:"wareId"` SkuID int64 `json:"skuId"` SkuName string `json:"skuName"` HuoHao interface{} `json:"huoHao"` JdPrice float64 `json:"jdPrice"` SkuNum int `json:"skuNum"` SkuImg interface{} `json:"skuImg"` URL string `json:"url"` ServiceName string `json:"serviceName"` Imei interface{} `json:"imei"` SequenceFlag bool `json:"sequenceFlag"` SequenceInfoList interface{} `json:"sequenceInfoList"` UpdateCount interface{} `json:"updateCount"` CertificateFlag bool `json:"certificateFlag"` CertificateInfoList interface{} `json:"certificateInfoList"` MedicalInfoFlag bool `json:"medicalInfoFlag"` MedicalInfoParamVos interface{} `json:"medicalInfoParamVos"` UniqueCode interface{} `json:"uniqueCode"` InspectReportID interface{} `json:"inspectReportId"` } `json:"orderItems"` PaymentTypeName string `json:"paymentTypeName"` ShouldPay float64 `json:"shouldPay"` Freight float64 `json:"freight"` ServiceFee interface{} `json:"serviceFee"` Commission float64 `json:"commission"` CouponFlag bool `json:"couponFlag"` UserPin string `json:"userPin"` UserRemark string `json:"userRemark"` ConsigneeInfo interface{} `json:"consigneeInfo"` LogiFlag bool `json:"logiFlag"` LogisticsInfos []interface{} `json:"logisticsInfos"` StoreName string `json:"storeName"` CodDT interface{} `json:"codDT"` ScDT interface{} `json:"scDT"` OrderStatusStrCN string `json:"orderStatusStrCN"` OrderStatus int `json:"orderStatus"` InvalidOrderFlag bool `json:"invalidOrderFlag"` OrderType int `json:"orderType"` CustomsModel interface{} `json:"customsModel"` SalesPin interface{} `json:"salesPin"` MdbStoreID interface{} `json:"mdbStoreId"` SuspendType interface{} `json:"suspendType"` SuspendReason interface{} `json:"suspendReason"` SuspendReasonDesc interface{} `json:"suspendReasonDesc"` SuspendDetailReasonFlag interface{} `json:"suspendDetailReasonFlag"` StoreInfo interface{} `json:"storeInfo"` IsDivShow bool `json:"isDivShow"` IsMenDianOrder bool `json:"isMenDianOrder"` IsMenDianBangOrder bool `json:"isMenDianBangOrder"` IsMenDianZiTiOrder bool `json:"isMenDianZiTiOrder"` IsPhoneOrder bool `json:"isPhoneOrder"` IsReturnOrder bool `json:"isReturnOrder"` IsPreSaleOrder bool `json:"isPreSaleOrder"` IsVenderSplitOrder bool `json:"isVenderSplitOrder"` IsAuctionOrder bool `json:"isAuctionOrder"` IsLargeAmountOrder bool `json:"isLargeAmountOrder"` IsMicroShopOrder bool `json:"isMicroShopOrder"` IsRuralPromotionOrder bool `json:"isRuralPromotionOrder"` IsHkMacaoOrder bool `json:"isHkMacaoOrder"` IsTaiWanOrder bool `json:"isTaiWanOrder"` IsOverseasOrder bool `json:"isOverseasOrder"` IsDistributionOrder bool `json:"isDistributionOrder"` IsJdDeliveryOrder bool `json:"isJdDeliveryOrder"` IsEclpOrder bool `json:"isEclpOrder"` IsYiPanHuoOrder bool `json:"isYiPanHuoOrder"` IsJingZunDaOrder bool `json:"isJingZunDaOrder"` IsBrandMall bool `json:"isBrandMall"` IsPinGou bool `json:"isPinGou"` IsYhd bool `json:"isYhd"` IsXtl bool `json:"isXtl"` IsSplitOrder bool `json:"isSplitOrder"` IsCloudWarehouseOrder bool `json:"isCloudWarehouseOrder"` IsTopLifeOrder bool `json:"isTopLifeOrder"` IsTuanGou bool `json:"isTuanGou"` IsDuoBaoDao bool `json:"isDuoBaoDao"` IsJingPinShi bool `json:"isJingPinShi"` BizLinkVo struct { ShowModifyFee bool `json:"showModifyFee"` ShowSingleOut bool `json:"showSingleOut"` ShowModifyAddr bool `json:"showModifyAddr"` ShowDelayDeliveryRemind bool `json:"showDelayDeliveryRemind"` ShowSplitOrder bool `json:"showSplitOrder"` ShowMoreLogisticsDelivery bool `json:"showMoreLogisticsDelivery"` ShowMergeDelivery bool `json:"showMergeDelivery"` ShowInfoCheck bool `json:"showInfoCheck"` ShowLivingAuth bool `json:"showLivingAuth"` ShowModifyWaybill bool `json:"showModifyWaybill"` } `json:"bizLinkVo"` IsOut bool `json:"isOut"` IsMultiLogisticsOutShow bool `json:"isMultiLogisticsOutShow"` PaimaiOrder int `json:"paimaiOrder"` CannotModifyProvinceAndCity bool `json:"cannotModifyProvinceAndCity"` CanWaitInnerShip bool `json:"canWaitInnerShip"` ShowShangChuanHeTong bool `json:"showShangChuanHeTong"` ShowManageCertificate bool `json:"showManageCertificate"` OrderSeqFlag bool `json:"orderSeqFlag"` CustomInfoFlag bool `json:"customInfoFlag"` OrderDaYangFlag bool `json:"orderDaYangFlag"` ShowMedicalInfo bool `json:"showMedicalInfo"` Card3CFlag bool `json:"card3cFlag"` ShowOrderPackage bool `json:"showOrderPackage"` ShowWaybill bool `json:"showWaybill"` IsGlobalZhiYouOrder bool `json:"isGlobalZhiYouOrder"` IsGlobalBaoShuiOrder bool `json:"isGlobalBaoShuiOrder"` ManageImeiFlag bool `json:"manageImeiFlag"` SpecialViewOrder []interface{} `json:"specialViewOrder"` } `json:"orderList"` Cluster interface{} `json:"cluster"` } //尝试扒订单 //https://porder.shop.jd.com/order/orderlist/allOrders func (a *API) AllOrders(allOrdersParam *AllOrdersParam) (allOrdersResult *AllOrdersResult, err error) { result, err := a.AccessStorePage2("https://porder.shop.jd.com/order/orderlist", map[string]interface{}{ "current": allOrdersParam.Current, "pageSize": allOrdersParam.PageSize, "selectedTabName": "allOrders", "sortName": "desc", "orderCreateDateRange": allOrdersParam.OrderCreateDateRange, // "storeId": allOrdersParam.StoreID, "orderStatusArray": allOrdersParam.OrderStatusArray, "orderId": allOrdersParam.OrderID, }) if err == nil { utils.Map2StructByJson(result, &allOrdersResult, false) } return allOrdersResult, err } type OrderDetailResult struct { ConsigneeName string `json:"consigneeName"` ConsigneeAddress string `json:"consigneeAddress"` ConsigneeMobile string `json:"consigneeMobile"` ExpectedDeliveredTime string `json:"expectedDeliveredTime"` ActualPayPrice int64 `json:"actualPayPrice"` MobileKey string `json:"mobileKey"` } //订单详情 //https://neworder.shop.jd.com/order/orderDetail?orderId=122367441996 func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult, err error) { result, err := a.AccessStorePage("https://neworder.shop.jd.com/order/orderDetail", map[string]interface{}{ "orderId": orderId, }, false) if err == nil { orderDetailResult = &OrderDetailResult{} body := result["fakeData"].(string) expectedDeliveredTime := regexpOrderDetailDay.FindStringSubmatch(body) actualPayPrice := regexpOrderDetailPay.FindStringSubmatch(body) consigneeTable := regexpOrderDetailTable.FindStringSubmatch(body) mobileKey := regexpOrderDetailMobileKey.FindStringSubmatch(body) if len(consigneeTable) > 0 { consigneeTd := regexpOrderDetailTd.FindAllStringSubmatch(consigneeTable[1], -1) consigneeMobiles := regexpOrderDetailMobile.FindStringSubmatch(consigneeTable[1]) if len(consigneeTd) > 0 { orderDetailResult.ConsigneeName = consigneeTd[0][1] orderDetailResult.ConsigneeAddress = consigneeTd[1][1] } if len(consigneeMobiles) > 0 { orderDetailResult.ConsigneeMobile = consigneeMobiles[1] } } if len(expectedDeliveredTime) > 0 { expectedDeliveredTime := expectedDeliveredTime[1][:strings.LastIndex(expectedDeliveredTime[1], "-")] + ":00" orderDetailResult.ExpectedDeliveredTime = utils.Time2Str(utils.Str2Time(expectedDeliveredTime).Add(50 * time.Minute)) } else { expectedDeliveredTime2 := regexpOrderDetailDay2.FindStringSubmatch(body) if len(expectedDeliveredTime2) > 0 { times := strings.Split(expectedDeliveredTime2[1], ",") if len(times) > 1 { orderDetailResult.ExpectedDeliveredTime = times[0] + " " + times[1][:strings.Index(times[1], ":")] + ":50:00" } } } if len(actualPayPrice) > 0 { orderDetailResult.ActualPayPrice = utils.Float64TwoInt64(utils.Str2Float64(strings.TrimSpace(actualPayPrice[1])) * 100) } if len(mobileKey) > 0 { orderDetailResult.MobileKey = mobileKey[1] } } return orderDetailResult, err } //尝试获取订单的真实手机号 //https://https://neworder.shop.jd.com/order/json/phoneSensltiveInfo func (a *API) PhoneSensltiveInfo(orderId, accessKey string) (fakeMobile string, err error) { result, err := a.AccessStorePage("https://neworder.shop.jd.com/order/json/phoneSensltiveInfo", map[string]interface{}{ "orderId": orderId, "accessKey": accessKey, "accessType": "0", "token": JdsMobileToken, }, true) if err == nil { if result["model"].(map[string]interface{})["mobile"] == nil { fakeMobile = result["model"].(map[string]interface{})["phone"].(string) } else { fakeMobile = result["model"].(map[string]interface{})["mobile"].(string) } } return fakeMobile, err } //订单的订单号转移 //https://porder.shop.jd.com/order/global/updateWaybill func (a *API) UpdateWaybill(orderId, logiId, logiNo string) (err error) { var waybiilList = []map[string]interface{}{} param := map[string]interface{}{ "logiId": logiId, "logiNos": []string{logiNo}, "overseas": false, "logiNo": logiNo, } waybiilList = append(waybiilList, param) _, err = a.AccessStorePage2("https://porder.shop.jd.com/order/global/updateWaybill", map[string]interface{}{ "orderId": orderId, "globalOrder": false, "waybillList": waybiilList, }) return err } //登录 // Accept: */* // Accept-Encoding: gzip, deflate, br // Accept-Language: zh-CN,zh;q=0.9 // Connection: keep-alive // Content-Length: 2129 // Content-Type: application/x-www-form-urlencoded; charset=UTF-8 // Cookie: __jdu=15913386790311275342874 // Host: passport.jd.com // Origin: https://passport.jd.com // Referer: https://passport.jd.com/common/loginPage?from=pop_vender®Tag=2&ReturnUrl=https%3A%2F%2Fseller.shop.jd.com%2Fseller%2Fsellerinfo%2Fseller_info.action // User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3761.400 QQBrowser/10.6.4121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3EKOTge5S=8UzKiU4yEtSPqpT9OyJ3fk3MIwJtvGalhsngq7B=f9BY04arq_4yWgffGDiywG4G5coPKYeDwPSus_4Dzp_IEP4sW_aId-JZisWZhroPI14Y2_Wl3s7EiGSNK5WEaNag7gztvG-PqxJf-zavmNZaws1IweWImnh6E1MIa_qZ7Gr7frm_I=JuuszIiaqdq5492eqDIPStdG7I7kMDjPJtfpa9jcnZfWh9cyaIZ0auuH4=hpMI4NGyJF_DwcnOweJud6WEhp-U7pJg8GiasWS=dPB=1VMtPjJnW=o=KWZu1kB6JVTZakWtj3n92GSzJ5S_8tTO4P-Oikni8GTPyEa=ckzplPaIW9it1TvIqU4GaczIquMtfJ // X-k39sGHmW-b: a348oo // X-k39sGHmW-c: A_MO-4hlAQAA29XveTX0-KoQbPiy3xbjIijWum-rT-EHQtuHV6skyxlsJAsDAawUIfCucinBwH8AAOfvAAAAAA== // X-k39sGHmW-d: 0 // X-k39sGHmW-uniqueStateKey: A7ae-4hlAQAAngSz4VMCAl-Vlq71Ta_smPn9uLwC7A7bioCLfwLMadcFYPb2AawUIfGLr4YoFOgAAAAAAAAAAA== // X-Requested-With: XMLHttpRequest func (a *API) TryGetCookie() (cookie string, err error) { params := map[string]interface{}{ "uuid": "15fc964c-aa54-4c2d-b718-cd3da5af9d69", "eid": "GS2E2DOSGES5EJGLTQLTXN2FXRWYH2BLDSJ2JGEHLXBBE563VC2OAJEFTO5ZUHRDTRMWOADDAEKFTDAGZHXTULGZBM", "fp": "b5c13ce2badacb92763e140cf2385bfc", "_t": "_t", "loginname": "jxcs_syl", "nloginpwd": "RUUE/EHuNMv88DMcVoMxYix5wjvOSL2rhz1xckkkzgL/Nr4aVKcPvfYDvp9sW1AD32oJ4PM/shLiUAof0KKO3olq5+KwavGQW4UTI2SV+RjSmU830j4v0nSdMKfbszikj4z4R9A7W9HK853tlI0r5cSBuQK5KhsDJf7hWVFgV1c=", "authcode": "3ad7a8a58e8f4122aaa522ec3e034bd3", "pubKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC7kw8r6tq43pwApYvkJ5laljaN9BZb21TAIfT/vexbobzH7Q8SUdP5uDPXEBKzOjx2L28y7Xs1d9v3tdPfKI2LR7PAzWBmDMn8riHrDDNpUpJnlAGUqJG9ooPn8j7YNpcxCa1iybOlc2kEhmJn5uwoanQq+CA6agNkqly2H4j6wIDAQAB", "sa_token": "B68C442BE645754F33277E701208059080DD726A94A73F76DEC3053A838549C06EB7D3797CE1C5BBE7C2B2EF9CA7D4676F3D489984B517943EA13575FA80C7E7ACE37FCFF6F535F07B6FF67F57EA6A0581BD84EA37554047DF10ECB7C873652D89DB5CAEE8F1090FB49A29547319CF16FBF33734EFA4BF8F86849797883219C3E197A604140E904BA7E538273F59893FDF9BFD6EBA3121C9E3CD43FCF0A83781B9A15920719D6C522B442FEB4A3A8C9CC7224AA55DC3877FC1BF5C845DEA80CCFB4D0CF33C8D9563ADF38943F28CEC9013C3BA8916B81844BBA454ACF21EDC3B7364C10CF219ABE7ADFFF42E2063BC2C957642453DA5E5B1E3277AE284D508B740A66BC4913EF086ACA2540C5ABB3E36C7BF693C668DFC806D4A7EFDD347D3C6869E4B529881FE46C9414D0E8E0B2B3BA3689CFCBE5CB26921DA46FABA0098E823B687A7F94DB84900C616284D5F6E49E605BFA8FD4473FD03FACD353DFA026C205B536A0DF325AC713A5B6916A60483BD386F29FF3F28046C4B19E6EE6B18F7C299C4F873C04993A085D6D6DE63C9DFECA20332F02D31EB2BA069EB9FDD3F6C14BEB40ABF57093396EEE3C2C2D727FF8C324016E2BE7BB61F4D7E2669B081E45E24801B6760CEBFE54A188FAD77B99B63D054B55FE09C6FD0A1F7B6EF448E9BBDC4D7554386AB5A2FA0787DB95D788470D913E453AF7E98F05D14B20C342F0A3CD62B833E7AC8B75C5C23ED0FC4FC4C2F23A1FAA047DEB10A856DA39B40BC9E8FC48DF17B98B28FC6C8ED1ABB248D4863083CB04E9DAD58FED19195DC02C2378C10426377996BDA4C1D060D2132BE99C37970727983EFD266A62B498B0116124E6403B18110B868B132C747F08B6DE52FD8BDD1A757E3DC74EC36D62BDF125703CB83DAA362EB086FF567C0549C6BFD26E53EC964405375B6F0CE100B44692D671D7017E45B19B42015F96D2D173B8BDA912FC3C4C8A21528EE0C28E6D4CBB8", "seqSid": "331828644098046192", "useSlideAuthCode": "1", } err = platformapi.AccessPlatformAPIWithRetry(a.client, func() *http.Request { request, _ := http.NewRequest(http.MethodPost, "https://passport.jd.com/common/loginService?nr=1&uuid=094087da-1373-40bf-bba2-63bb64026cfd&from=pop_vender®Tag=2&ReturnUrl=https://seller.shop.jd.com/seller/sellerinfo/seller_info.action&r=0.21554654723242117", strings.NewReader(utils.Map2URLValues(params).Encode())) request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") request.Header.Set("Host", "passport.jd.com") request.Header.Set("Origin", "https://passport.jd.com") request.Header.Set("Referer", "https://passport.jd.com/common/loginPage?from=pop_vender®Tag=2&ReturnUrl=https://seller.shop.jd.com/seller/sellerinfo/seller_info.action") request.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3761.400 QQBrowser/10.6.4121.400") request.Header.Set("X-k39sGHmW-a", "ZtUfrFE109K33EiraIwE4CweB9pexmWIS9jITuItWOvk_upGBNBF7=K6nPW_O0NGwPW_at8qz0hEAaJJ405haPKUBGqUhWqrJtUeSNt7MdcGStLGWtf_hWECJasNSj5h4ke5Nh7ViE8=JnwUSsEf3tOPSKmawFcPzt_pePK6nOw5xUhOi_qIZ=M8Z=oN49KcJ0aG4tvEn-lc1O5UW9KQaZSchZakBr19ipKraXhkidpGJEKyo9UYBj5yaOdNJnTNJuMFotKPhG5OWV2Gaaifh5s1z_hG4=vZJZf_aEqcttie4tjVBXO8_=0yag7eSNwGnuYWh=vxzIzraEws4I8Y4phP4tq5Ju1_Mtc_aj1PSPWfrNE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JWatvPJl3F") request.Header.Set("X-k39sGHmW-b", "-9kt3q0") request.Header.Set("X-k39sGHmW-c", "A_MO-4hlAQAA29XveTX0-KoQbPiy3xbjIijWum-rT-EHQtuHV6skyxlsJAsDAawUIfCucinBwH8AAOfvAAAAAA==") request.Header.Set("X-k39sGHmW-d", "0") request.Header.Set("X-k39sGHmW-uniqueStateKey", "A7ae-4hlAQAAngSz4VMCAl-Vlq71Ta_smPn9uLwC7A7bioCLfwLMadcFYPb2AawUIfGLr4YoFOgAAAAAAAAAAA==") request.Header.Set("X-Requested-With", "XMLHttpRequest") c := &http.Cookie{ Name: "alc", Value: "RinKQBiRr1QceieVnkF+Uw==", } c2 := &http.Cookie{ Name: "_t", Value: "DplFmazbesu5rn1NUKhLBe8yV7ia5OQcE7GXyFv3QCw=", } request.AddCookie(c) request.AddCookie(c2) return request }, a.config, func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) { fmt.Println(utils.Format4Output(response.Cookies(), false)) return errLevel, err }) return cookie, err } func (a *API) JdSSO() (err error) { _, err = a.AccessStorePage("https://sso.jd.com/setCookie?t=https://seller.shop.jd.com/seller/sellerinfo/seller_info.action&callback=https://seller.shop.jd.com/seller/sellerinfo/seller_info.action", nil, false) return err }