|
- package utils
-
- import (
- "applet/app/utils"
- "crypto/hmac"
- "crypto/sha1"
- "encoding/hex"
- "encoding/json"
- "fmt"
- "github.com/syyongx/php2go"
- "sort"
- "strings"
- )
-
- const (
- //1688api接口官方域名请求路径
- API1688OfficialUrl = "http://gw.open.1688.com/openapi/"
- //获取所有选品组列表
- API1688ListCybUserGroupUrlPath = "param2/1/com.alibaba.p4p/alibaba.cps.op.listCybUserGroup/"
- //获取已选商品列表
- API1688ListCybUserGroupFeedUrlPath = "param2/1/com.alibaba.p4p/alibaba.cps.op.listCybUserGroupFeed/"
- //商品列表API(如需要自建选品平台的使用此接口)
- API1688SearchCybOffersUrlPath = "param2/1/com.alibaba.p4p/alibaba.cps.op.searchCybOffers/"
- //商品详情(含运费模版)API
- API1688ProductInfoUrlPath = "param2/1/com.alibaba.product/alibaba.cpsMedia.productInfo/"
- //营销活动信息查询
- API1688QueryOfferDetailActivityUrlPath = "param2/1/com.alibaba.p4p/alibaba.cps.queryOfferDetailActivity/"
- //创建订单前预览接口API
- API1688Preview4CybMediaUrlPath = "param2/1/com.alibaba.trade/alibaba.createOrder.preview4CybMedia/"
- //下单API
- API1688CreateOrder4CybMediaUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.createOrder4CybMedia/"
- //订单取消API
- API1688OrderCancelUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.cancel/"
- //订单查询API
- API1688OrderBuyerViewUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.get.buyerView/"
- //支付API(使用支付宝协议代扣,无需调用此接口)
- API1688AlipayUrlGetUrlPath = "param2/1/com.alibaba.p4p/alibaba.alipay.url.get/"
- //支付宝协议代扣支付
- API1688AliProtocolPayUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.pay.protocolPay/"
- //获取交易订单的物流信息API
- API1688GetLogisticsInfosUrlPath = "param2/1/com.alibaba.logistics/alibaba.trade.getLogisticsInfos.buyerView/"
- //获取交易订单的物流跟踪信息API
- API1688GetLogisticsTraceInfoUrlPath = "param2/1/com.alibaba.logistics/alibaba.trade.getLogisticsTraceInfo.buyerView/"
- //根据类目Id查询类目
- API1688GetCategoryUrlPath = "param2/1/com.alibaba.product/alibaba.category.get/"
- //标题及图片改写(beta)
- API1688CpsMediaProductInfoUrlPath = "param2/1/com.alibaba.p4p/alibaba.cpsMedia.productInfo/"
- //查询退款单详情-根据退款单ID
- API1688RefundOpQueryOrderRefundUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.refund.OpQueryOrderRefund/"
- //创建退款退货申请
- API1688CreateRefundUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.createRefund/"
- //查询退款退货原因(用于创建退款退货)
- API1688GetRefundReasonListUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.getRefundReasonList/"
- //上传退款退货凭证
- API1688UploadRefundVoucherUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.uploadRefundVoucher/"
- //买家提交退款货信息
- API1688RefundReturnGoodsUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.refund.returnGoods/"
- //物流公司列表-自联物流
- API1688OpQueryLogisticCompanyListUrlPath = "param2/1/com.alibaba.logistics/alibaba.logistics.OpQueryLogisticCompanyList.offline/"
- )
-
- //
- var RefundActionMap = map[string]string{
- "BUYER_APPLY_REFUND": "买家申请退款",
- "BUYER_RECEIVE_CLOSE": "买家确认收货关闭",
- "SELLER_SEND_GOODS_CLOSE": "卖家发货关闭",
- "BUYER_CANCEL_REFUND_CLOSE": "买家撤销退款申请关闭",
- "BUYER_UPLOAD_BILL": "买家上传凭证",
- "SELLER_UPLOAD_BILL": "卖家上传凭证",
- "SELLER_REJECT_REFUND": "卖家拒绝退款",
- "SELLER_AGREE_REFUND": "卖家同意退款",
- "SELLER_RECEIVE_GOODS": "卖家确认收货",
- "BUYER_SEND_GOODS": "买家声明发货",
- "BUYER_MODIFY_REFUND_PROTOCOL": "买家修改退款协议",
- "BUYER_APPLY_SUPPORT": "买家申请客服介入",
- "SELLER_APPLY_SUPPORT": "卖家申请客服介入",
- "SYSTEM_AGREE_REFUND_PROTOCOL": "系统超时同意退款协议",
- "SYSTEM_AGREE_REFUND": "系统超时同意退款,即退款成功",
- "SYSTEM_SEND_GOODS": "系统超时退货,主交易流程的退货",
- "SYSTEM_MODIFY_REFUND_PROTOCOL": "系统超时修改协议",
- "SYSTEM_NOTIFY_APPLY_SUPPORT": "系统通知申请客服介入",
- "SELLER_AGREE_REFUND_PROCOTOL": "卖家同意退款协议",
- "SELLER_REJECT_REFUND_PROCOTOL": "卖家拒绝退款协议",
- "CRM_APPLY_TIMEOUT_CLOSE": "申请客服介入超时关闭目前仅售后业务在用",
- "CRM_APPLY_SUPPORT": "CRM申请介入",
- "CRM_INTERVENE_TASK": "CRM介入处理",
- "CRM_DISMISS_TASK": "CRM撤销工单",
- "CRM_FINISH_TASK": "CRM完结工单",
- "BUYER_STEP_PAY_ORDER_CLOSE": "买家支付,退款关闭,分阶段订单情况",
- "BUYER_STEP_CONFIRM_CLOSE": "买家确认,退款关闭,分阶段订单情况",
- "BUYER_CLOSE_TRADE_CLOSE": "买家终止交易,退款关闭,分阶段订单情况",
- "SELLER_CONFIRM_ORDER_CLOSE": "卖家确认,退款关闭,分阶段订单情况",
- "SELLER_STEP_PUSH_CLOSE": "卖家推进,退款关闭,分阶段订单情况",
- }
-
- type General1688CallBack struct {
- Data interface{} `json:"data"`
- GmtBorn int64 `json:"gmtBorn"`
- MsgID int64 `json:"msgId"`
- Type string `json:"type"`
- UserInfo string `json:"userInfo"`
- }
-
- type OrderAnnounceSendGoodsData struct {
- BuyerMemberID string `json:"buyerMemberId" label:"买家中文站会员ID"`
- BuyerOpenUID string `json:"buyerOpenUid"`
- OrderID int64 `json:"orderId" label:"订单ID"`
- CurrentStatus string `json:"currentStatus" label:"当前订单状态,状态值为waitbuyerreceive"`
- MsgSendTime string `json:"msgSendTime" label:"消息发送时间"`
- }
- type OrderBuyerViewOrderRefundAfterSales struct {
- BuyerMemberID string `json:"buyerMemberId" label:"买家中文站会员ID"`
- OrderID int64 `json:"orderId" label:"订单ID"`
- CurrentStatus string `json:"currentStatus" label:"当前订单状态"`
- RefundAction string `json:"refundAction" label:"退款操作"`
- SellerMemberID string `json:"sellerMemberId" label:"卖家中文站会员ID"`
- MsgSendTime string `json:"msgSendTime" label:"消息发送时间"`
- Operator string `json:"operator" label:"操作的发起人,buyer(买家),seller(卖家),system(系统)"`
- RefundID string `json:"refundId" label:"退款单ID"`
- }
- type OrderBuyerViewOrderBuyerRefundInSales struct {
- BuyerMemberID string `json:"buyerMemberId" label:"买家中文站会员ID"`
- OrderID int64 `json:"orderId" label:"订单ID"`
- CurrentStatus string `json:"currentStatus" label:"当前订单状态"`
- RefundAction string `json:"refundAction" label:"退款操作"`
- SellerMemberID string `json:"sellerMemberId" label:"卖家中文站会员ID"`
- MsgSendTime string `json:"msgSendTime" label:"消息发送时间"`
- Operator string `json:"operator" label:"操作的发起人,buyer(买家),seller(卖家),system(系统)"`
- RefundID string `json:"refundId" label:"退款单ID"`
- }
-
- func HmacSHA1(key string, data string) string {
- mac := hmac.New(sha1.New, []byte(key))
- mac.Write([]byte(data))
- return hex.EncodeToString(mac.Sum(nil))
- }
-
- //shejiao
- //urlPath =
- //appKey = 2821195
- //appSecret = qaMVhzoS3nT
- //access_token = 2101cd32-8762-49ed-a87b-94e25ab0c40d
-
- //fenxiao
- //appKey = 4535867
- //appSecret = lKXjQAP5EK
- //access_token = 6ddddfe6-d0cd-4e58-abbf-a265eb41be0b
- //Refresh Token = 5d358adb-3184-4411-8197-e152eed9d198
- func API1688(url, urlPath, appKey, appSecret string, parameters []string, parameterMap map[string]interface{}) (map[string]interface{}, error) {
- urlPath = urlPath + appKey
- assembleParameter := ""
- parameterUrl := ""
- //进行切片排序
- sort.Strings(parameters)
- for _, parameter := range parameters {
- switch parameterMap[parameter].(type) {
- case string:
- str := utils.AnyToString(parameterMap[parameter])
- fmt.Println(str)
- assembleParameter = assembleParameter + parameter + str
- if parameter == "imageData" {
- str = php2go.URLEncode(str)
- }
- if parameter == "addressParam" {
- str = php2go.URLEncode(str)
- }
- if parameterUrl == "" {
- parameterUrl = "?" + parameter + "=" + str
- } else {
- parameterUrl = parameterUrl + "&" + parameter + "=" + str
- }
- default:
- str := utils.SerializeStr(parameterMap[parameter])
- fmt.Println(str)
- assembleParameter = assembleParameter + parameter + str
- if parameter == "imageData" {
- str = php2go.URLEncode(str)
- fmt.Println("URLEncode", str)
- }
- if parameter == "addressParam" {
- str = php2go.URLEncode(str)
- }
- if parameterUrl == "" {
- parameterUrl = "?" + parameter + "=" + str
- } else {
- parameterUrl = parameterUrl + "&" + parameter + "=" + str
- }
- }
- }
- hmacSHA1 := HmacSHA1(appSecret, urlPath+assembleParameter)
- toUpper := strings.ToUpper(hmacSHA1)
- url = url + urlPath + parameterUrl + "&_aop_signature=" + toUpper
- headers := map[string]string{
- "Content-Type": "application/x-www-form-urlencoded",
- "Content-Length": utils.AnyToString(len(url)),
- //"Charset": "utf-8",
- }
- utils.FilePutContents("API1688", utils.SerializeStr(map[string]interface{}{
- "url": url,
- "headers": headers,
- }))
- res, err := utils.CurlGet(url, headers)
- if err != nil {
- return nil, err
- }
- resp := make(map[string]interface{})
- if err := json.Unmarshal(res, &resp); err != nil {
- return nil, err
- }
- return resp, nil
-
- }
- func GetCategoryFrom1688(appKey, appSecret, categoryID string) (map[string]interface{}, error) {
- if categoryID == "" {
- categoryID = "0"
- }
- api1688, err := API1688(API1688OfficialUrl, API1688GetCategoryUrlPath, appKey, appSecret, []string{"categoryID"}, map[string]interface{}{
- "categoryID": categoryID,
- })
- return api1688, err
- }
-
- type SearchCybOffersReq struct {
- AccessToken string `json:"access_token"`
-
- BizType string `json:"biztype"`
- Page string `json:"page"`
- PageSize string `json:"pageSize"`
- PostCategoryId string `json:"postCategoryId"`
- KeyWords string `json:"keyWords"`
- PriceStart string `json:"priceStart"` //最低价
- PriceEnd string `json:"priceEnd"` //最高价
- SortType string `json:"sortType"` //normal:综合 saleQuantity:销量
- DescendOrder bool `json:"descendOrder"` //是否倒序;正序: false;倒序:true
- OfferIds string `json:"offerIds"`
- }
-
- func GetSearchCybOffersFrom1688(appKey, appSecret string, req *SearchCybOffersReq) (map[string]interface{}, error) {
- if req.AccessToken == "" {
- req.AccessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := utils.Struct2Map(req)
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688SearchCybOffersUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- func GetProductInfoFrom1688(appKey, appSecret, accessToken, offerId string) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := make(map[string]interface{})
- reqMap["access_token"] = accessToken
- reqMap["offerId"] = utils.StrToInt64(offerId)
- reqMap["needCpsSuggestPrice"] = true
- reqMap["needIntelligentInfo"] = true
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688ProductInfoUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- func GetListCybUserGroupFrom1688(appKey, appSecret, accessToken, pageNo, pageSize string) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := make(map[string]interface{})
- reqMap["access_token"] = accessToken
- reqMap["pageNo"] = pageNo
- reqMap["pageSize"] = pageSize
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688ListCybUserGroupUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type ListCybUserGroupFeedReq struct {
- AccessToken string `json:"access_token" form:"access_token"`
-
- GroupId int64 `json:"groupId" form:"groupId"` //选品组id,不传表示取默认选品组下商品;
- PageNo int `json:"pageNo" form:"pageNo"`
- PageSize string `json:"pageSize" form:"pageSize"`
- FeedId int64 `json:"feedId" form:"feedId"` //商品id
- Title string `json:"title" form:"title"` //商品标题模糊搜索
- }
-
- func GetListCybUserGroupFeedFrom1688(appKey, appSecret string, req *ListCybUserGroupFeedReq) (map[string]interface{}, error) {
- if req.AccessToken == "" {
- req.AccessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := utils.Struct2Map(req)
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if utils.AnyToString(value) != "" && utils.AnyToString(value) != "0" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688ListCybUserGroupFeedUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type AddressParam struct {
- AddressId int64 `json:"addressId" label:"收货地址id,是否必填:否"`
- FullName string `json:"fullName" label:"收货人姓名,是否必填:是"`
- Mobile string `json:"mobile" label:"手机 15251667788,是否必填:是"`
- Phone string `json:"phone" label:"电话 0517-88990077,是否必填:是"`
- PostCode string `json:"postCode" label:"邮编,是否必填:是"`
- CityText string `json:"cityText" label:"市文本,是否必填:是"`
- ProvinceText string `json:"provinceText" label:"省份文本,是否必填:是"`
- AreaText string `json:"areaText" label:"区文本,是否必填:是"`
- TownText string `json:"townText" label:"镇文本,是否必填:是"`
- Address string `json:"address" label:"街道地址,是否必填:是"`
- DistrictCode string `json:"districtCode" label:"地址编码,是否必填:是"`
- }
- type CargoParam struct {
- OfferId int64 `json:"offerId" label:"商品对应的offer id,是否必填:是"`
- SpecId string `json:"specId" label:"商品规格id 无sku商品不传,是否必填:否"`
- Quantity float64 `json:"quantity" label:"商品数量(计算金额用),是否必填:是"`
- }
- type Preview4CybMediaReq struct {
- AddressParam AddressParam `json:"addressParam" label:"收货地址信息,是否必填:是"`
- CargoParamList []*CargoParam `json:"cargoParamList" label:"商品信息,是否必填:是"`
- AccessToken string `json:"access_token"`
- Flow string `json:"flow" label:"不传,价格逻辑由useChannelPrice控制;传入general使用批发价,即useChannelPrice的价格逻辑失效;传入paired使用火拼价,若该商品未参与伙拼,则下单失败。
- general(批发),paired(火拼),是否必填:否"`
- UseChannelPrice bool `json:"useChannelPrice" label:"是否走渠道专属价,传true优先使用渠道传享价,不传或者传false则不走渠道专享价,走普通的分销价,是否必填:否"`
- }
-
- type Cargo struct {
- Amount float64 `json:"amount"`
- FinalUnitPrice float64 `json:"finalUnitPrice"`
- SpecID string `json:"specId"`
- SkuID int64 `json:"skuId"`
- OfferID int64 `json:"offerId"`
- CargoPromotionList []interface{} `json:"cargoPromotionList"`
- }
- type TradeModel struct {
- TradeWay string `json:"tradeWay"`
- Name string `json:"name"`
- TradeType string `json:"tradeType"`
- Description string `json:"description"`
- OpSupport bool `json:"opSupport"`
- }
- type ShopPromotion struct {
- PromotionId string `json:"promotionId"`
- Selected bool `json:"selected"`
- Text string `json:"text"`
- Desc string `json:"desc"`
- FreePostage bool `json:"freePostage"`
- DiscountFee int64 `json:"discountFee"`
- }
- type OrderPreviewResuslt struct {
- TradeModeNameList []string `json:"tradeModeNameList"`
- Status bool `json:"status"`
- SumPayment int `json:"sumPayment"`
- SumCarriage int `json:"sumCarriage"`
- SumPaymentNoCarriage int `json:"sumPaymentNoCarriage"`
- FlowFlag string `json:"flowFlag"`
- Message string `json:"message"`
- ResultCode string `json:"resultCode"`
- CargoList []Cargo `json:"cargoList"`
- ShopPromotionList []ShopPromotion `json:"shopPromotionList"`
- TradeModelList []TradeModel `json:"tradeModelList"`
- }
-
- type Preview4CybMediaResp struct {
- OrderPreviewResuslt []OrderPreviewResuslt `json:"orderPreviewResuslt"`
- Success bool `json:"success"`
- ErrorCode string `json:"errorCode"`
- ErrorMsg string `json:"errorMsg"`
- PostFeeByDescOfferList []int64 `json:"postFeeByDescOfferList"`
- ConsignOfferList []int64 `json:"consignOfferList"`
- }
-
- func Preview4CybMedia(appKey, appSecret string, req *Preview4CybMediaReq) (map[string]interface{}, error) {
- reqMap := utils.Struct2Map(req)
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688Preview4CybMediaUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type CreateOrder4CybMediaReq struct {
- AddressParam AddressParam `json:"addressParam" label:"收货地址信息,是否必填:是"`
- CargoParamList []*CargoParam `json:"cargoParamList" label:"商品信息,是否必填:是"`
- AccessToken string `json:"access_token"`
- OuterOrderInfo string `json:"outerOrderInfo" label:"机构的订单信息,json格式,如果校验不通过,不能创建订单。业务线原因机构订单信息不能放在上面的下单参数结构体中,只能新增该字段用于机构订单信息回写,没有幂等校验,纯记录统计分析。mediaOrderId:机构订单号;phone:电话;offers.id:Long,1688商品id;offers.specId:String,1688商品specId(可能无);offers.price:Long,媒体溢价单价(单位分);offers.num:Long,售卖数量`
- }
- type OuterOrderInfo struct {
- MediaOrderID int64 `json:"mediaOrderId" label:"业务产生的订单id,唯一"`
- Phone string `json:"phone"`
- Offers []*Offer `json:"offers"`
- }
- type Offer struct {
- ID int64 `json:"id" label:"1688云链的产品的offerId,对应goods表的cloud_chain_goods_id"` //1688云链的产品的offerId,对应goods表的cloud_chain_goods_id
- SpecID string `json:"specId" label:"1688云链的sku的specId,对应sku表的specId"` //1688云链的sku的specId,对应sku表的specId
- Price float64 `json:"price" label:"业务销售金额"` //业务销售金额
- Num float64 `json:"num" label:"销售数量"` //销售数量
- }
-
- func CreateOrder4CybMedia(appKey, appSecret string, req *CreateOrder4CybMediaReq, outerOrderInfo *OuterOrderInfo) (map[string]interface{}, error) {
- req.OuterOrderInfo = utils.SerializeStr(outerOrderInfo)
- reqMap := utils.Struct2Map(req)
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688CreateOrder4CybMediaUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- func AliProtocolPay(appKey, appSecret, accessToken, orderId string) (map[string]interface{}, error) {
- api1688, err := API1688(API1688OfficialUrl, API1688AliProtocolPayUrlPath, appKey, appSecret, []string{"orderId", "access_token"}, map[string]interface{}{
- "orderId": utils.StrToInt64(orderId),
- "access_token": accessToken,
- })
- return api1688, err
- }
-
- type OrderCancel1688 struct {
- TradeID int64 `json:"tradeID" label:"交易id,订单号"`
- CancelReason string `json:"cancelReason" label:"原因描述;buyerCancel:买家取消订单;sellerGoodsLack:卖家库存不足;other:其它"`
- Remark string `json:"remark" label:"备注" `
- }
-
- func OrderCancel(appKey, appSecret, accessToken string, req *OrderCancel1688) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := utils.Struct2Map(req)
- reqMap["access_token"] = accessToken
- reqMap["webSite"] = "1688"
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688OrderCancelUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type OrderGetLogisticsInfosResp struct {
- Result []struct {
- LogisticsBillNo string `json:"logisticsBillNo"`
- LogisticsCompanyID string `json:"logisticsCompanyId"`
- LogisticsCompanyName string `json:"logisticsCompanyName"`
- LogisticsID string `json:"logisticsId"`
- OrderEntryIds string `json:"orderEntryIds"`
- Receiver struct {
- Encrypt string `json:"encrypt"`
- ReceiverAddress string `json:"receiverAddress"`
- ReceiverCity string `json:"receiverCity"`
- ReceiverCityCode string `json:"receiverCityCode"`
- ReceiverCounty string `json:"receiverCounty"`
- ReceiverCountyCode string `json:"receiverCountyCode"`
- ReceiverMobile string `json:"receiverMobile"`
- ReceiverName string `json:"receiverName"`
- ReceiverPhone string `json:"receiverPhone"`
- ReceiverProvince string `json:"receiverProvince"`
- ReceiverProvinceCode string `json:"receiverProvinceCode"`
- } `json:"receiver"`
- Remarks string `json:"remarks"`
- SendGoods []struct {
- GoodName string `json:"goodName"`
- Quantity string `json:"quantity"`
- Unit string `json:"unit"`
- } `json:"sendGoods"`
- Sender struct {
- Encrypt string `json:"encrypt"`
- SenderAddress string `json:"senderAddress"`
- SenderCity string `json:"senderCity"`
- SenderCityCode string `json:"senderCityCode"`
- SenderCounty string `json:"senderCounty"`
- SenderCountyCode string `json:"senderCountyCode"`
- SenderMobile string `json:"senderMobile"`
- SenderName string `json:"senderName"`
- SenderProvince string `json:"senderProvince"`
- SenderProvinceCode string `json:"senderProvinceCode"`
- } `json:"sender"`
- Status string `json:"status"`
- } `json:"result"`
- Success bool `json:"success"`
- }
-
- func OrderGetLogisticsInfos(appKey, appSecret, accessToken string, ordId int64) (map[string]interface{}, error) {
- api1688, err := API1688(API1688OfficialUrl, API1688GetLogisticsInfosUrlPath, appKey, appSecret, []string{"orderId", "access_token", "webSite"}, map[string]interface{}{
- "orderId": ordId,
- "access_token": accessToken,
- "webSite": 1688,
- })
- return api1688, err
- }
-
- func OrderGetLogisticsTraceInfo(appKey, appSecret, accessToken string, ordId int64) (map[string]interface{}, error) {
- api1688, err := API1688(API1688OfficialUrl, API1688GetLogisticsTraceInfoUrlPath, appKey, appSecret, []string{"orderId", "access_token", "webSite"}, map[string]interface{}{
- "orderId": ordId,
- "access_token": accessToken,
- "webSite": 1688,
- })
- return api1688, err
- }
-
- type GetRefundReasonList1688Req struct {
- OrderId int64 `json:"orderId" label:"主订单id"`
- OrderEntryIds []int64 `json:"orderEntryIds" label:"子订单id,无子订单的等于主订单编号"`
- //售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive"; 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived"; 售后已收到货:"aftersaleBuyerReceived"
- GoodsStatus string `json:"goodsStatus" label:"货物状态:售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive"; 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived"; 售后已收到货:"aftersaleBuyerReceived"" `
- }
-
- func GetRefundReasonList(appKey, appSecret, accessToken string, req *GetRefundReasonList1688Req) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- if len(req.OrderEntryIds) == 0 {
- req.OrderEntryIds = append(req.OrderEntryIds, req.OrderId)
- }
- reqMap := utils.Struct2Map(req)
- reqMap["access_token"] = accessToken
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688GetRefundReasonListUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- func UploadRefundVoucher(appKey, appSecret, accessToken string, imageData []byte) (map[string]interface{}, error) {
- api1688, err := API1688(API1688OfficialUrl, API1688UploadRefundVoucherUrlPath, appKey, appSecret, []string{"access_token", "imageData"}, map[string]interface{}{
- "access_token": accessToken,
- "imageData": imageData,
- })
- return api1688, err
- }
-
- type CreateRefundReq struct {
- OrderId int64 `json:"orderId" label:"主订单id"`
- OrderEntryIds []int64 `json:"orderEntryIds" label:"子订单id,无子订单的等于主订单编号"`
- DisputeRequest string `json:"disputeRequest" label:"退款/退款退货。只有已收到货,才可以选择退款退货。" sample:" 退款:refund; 退款退货:returnRefund" `
- ApplyPayment int64 `json:"applyPayment" label:"退款金额(单位:分)。不大于实际付款金额;等待卖家发货时,必须为商品的实际付款金额。" sample:""`
- ApplyCarriage int64 `json:"applyCarriage" label:"退运费金额(单位:分)。" sample:""`
- ApplyReasonId int64 `json:"applyReasonId" label:"退款原因id(从API getRefundReasonList获取)" sample:""`
- Description string `json:"description" label:"退款申请理由,2-150字" sample:""`
- //售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive"; 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived"; 售后已收到货:"aftersaleBuyerReceived"
- GoodsStatus string `json:"goodsStatus" label:"货物状态:售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive"; 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived"; 售后已收到货:"aftersaleBuyerReceived"" `
- Vouchers []string `json:"vouchers" label:"凭证图片URLs。1-5张,必须使用API uploadRefundVoucher返回的“图片域名/相对路径”" sample:""`
- }
-
- type CreateRefundResult struct {
- Code string `json:"code"`
- Message string `json:"message"`
- Result struct {
- RefundID string `json:"refundId"`
- } `json:"result"`
- Success bool `json:"success"`
- }
-
- func CreateRefund(appKey, appSecret, accessToken string, req *CreateRefundReq) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- if len(req.OrderEntryIds) == 0 {
- req.OrderEntryIds = append(req.OrderEntryIds, req.OrderId)
- }
- reqMap := utils.Struct2Map(req)
- reqMap["access_token"] = accessToken
- if len(req.Vouchers) == 0 {
- delete(reqMap, "vouchers")
- }
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688CreateRefundUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type RefundReturnGoodsReq struct {
- RefundId string `json:"refundId" label:"退款单号,TQ开头"`
- LogisticsCompanyNo string `json:"logisticsCompanyNo" label:"物流公司编码,调用alibaba.logistics.OpQueryLogisticCompanyList.offline接口查询"`
- FreightBill string `json:"freightBill" label:"物流公司运单号,请准确填写,否则卖家有权拒绝退款" `
- Description string `json:"description" label:"发货说明,内容在2-200个字之间" sample:""`
- Vouchers []string `json:"vouchers" label:"凭证图片URLs。1-5张,必须使用API uploadRefundVoucher返回的“图片域名/相对路径”" sample:""`
- }
- type RefundReturnGoodsResp struct {
- Result struct {
- ErrorCode string `json:"errorCode"`
- ErrorInfo string `json:"errorInfo"`
- Success bool `json:"success"`
- } `json:"result"`
- }
-
- func RefundReturnGoods(appKey, appSecret, accessToken string, req *RefundReturnGoodsReq) (*RefundReturnGoodsResp, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := utils.Struct2Map(req)
- reqMap["access_token"] = accessToken
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688RefundReturnGoodsUrlPath, appKey, appSecret, parameters, reqMap)
- var resp RefundReturnGoodsResp
- resp.Result.Success = false
- utils.Unserialize(utils.Serialize(api1688), &resp)
- return &resp, err
- }
-
- func OpQueryLogisticCompanyList(appKey, appSecret, accessToken string) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := make(map[string]interface{})
- reqMap["access_token"] = accessToken
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688OpQueryLogisticCompanyListUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type OrderDetailsResp struct {
- Result Result `json:"result"`
- Success string `json:"success"`
- }
- type Result struct {
- BaseInfo BaseInfo `json:"baseInfo"`
- ExtAttributes []interface{} `json:"extAttributes"`
- GuaranteesTerms GuaranteesTerms `json:"guaranteesTerms"`
- NativeLogistics NativeLogistics `json:"nativeLogistics"`
- OrderBizInfo OrderBizInfo `json:"orderBizInfo"`
- OrderRateInfo OrderRateInfo `json:"orderRateInfo"`
- ProductItems []ProductItem `json:"productItems"`
- TradeTerms []TradeTerm `json:"tradeTerms"`
- }
- type BaseInfo struct {
- BusinessType string `json:"businessType"`
- BuyerContact struct {
- CompanyName string `json:"companyName"`
- ImInPlatform string `json:"imInPlatform"`
- Name string `json:"name"`
- Phone string `json:"phone"`
- } `json:"buyerContact"`
- BuyerID string `json:"buyerID"`
- BuyerLoginID string `json:"buyerLoginId"`
- CloseOperateType string `json:"closeOperateType"`
- CouponFee int `json:"couponFee"`
- CreateTime string `json:"createTime"`
- Discount int `json:"discount"`
- FlowTemplateCode string `json:"flowTemplateCode"`
- ID int64 `json:"id"`
- IDOfStr string `json:"idOfStr"`
- ModifyTime string `json:"modifyTime"`
- OverSeaOrder bool `json:"overSeaOrder"`
- PayChannelCodeList []interface{} `json:"payChannelCodeList"`
- PayChannelList []interface{} `json:"payChannelList"`
- PayTimeout int `json:"payTimeout"`
- PayTimeoutType int `json:"payTimeoutType"`
- ReceiverInfo struct {
- ToArea string `json:"toArea"`
- ToDivisionCode string `json:"toDivisionCode"`
- ToFullName string `json:"toFullName"`
- ToMobile string `json:"toMobile"`
- ToPhone string `json:"toPhone"`
- ToPost string `json:"toPost"`
- } `json:"receiverInfo"`
- Refund int `json:"refund"`
- RefundPayment int `json:"refundPayment"`
- SellerContact struct {
- CompanyName string `json:"companyName"`
- ImInPlatform string `json:"imInPlatform"`
- Name string `json:"name"`
- Phone string `json:"phone"`
- } `json:"sellerContact"`
- SellerID string `json:"sellerID"`
- SellerLoginID string `json:"sellerLoginId"`
- SellerOrder bool `json:"sellerOrder"`
- ShippingFee int `json:"shippingFee"`
- Status string `json:"status"`
- StepPayAll bool `json:"stepPayAll"`
- SumProductPayment float64 `json:"sumProductPayment"`
- TotalAmount float64 `json:"totalAmount"`
- TradeType string `json:"tradeType"`
- TradeTypeCode string `json:"tradeTypeCode"`
- TradeTypeDesc string `json:"tradeTypeDesc"`
- }
- type GuaranteesTerms struct {
- AssuranceInfo string `json:"assuranceInfo"`
- AssuranceType string `json:"assuranceType"`
- QualityAssuranceType string `json:"qualityAssuranceType"`
- }
- type NativeLogistics struct {
- Address string `json:"address"`
- Area string `json:"area"`
- AreaCode string `json:"areaCode"`
- City string `json:"city"`
- ContactPerson string `json:"contactPerson"`
- Mobile string `json:"mobile"`
- Province string `json:"province"`
- Telephone string `json:"telephone"`
- Zip string `json:"zip"`
- }
- type OrderBizInfo struct {
- CreditOrder bool `json:"creditOrder"`
- OdsCyd bool `json:"odsCyd"`
- }
- type OrderRateInfo struct {
- BuyerRateStatus int `json:"buyerRateStatus"`
- SellerRateStatus int `json:"sellerRateStatus"`
- }
- type ProductItem struct {
- EntryDiscount int `json:"entryDiscount"`
- GmtCreate string `json:"gmtCreate"`
- GmtModified string `json:"gmtModified"`
- GmtPayExpireTime string `json:"gmtPayExpireTime"`
- GuaranteesTerms []struct {
- AssuranceInfo string `json:"assuranceInfo"`
- AssuranceType string `json:"assuranceType"`
- QualityAssuranceType string `json:"qualityAssuranceType"`
- } `json:"guaranteesTerms"`
- ItemAmount float64 `json:"itemAmount"`
- LogisticsStatus int `json:"logisticsStatus"`
- Name string `json:"name"`
- Price float64 `json:"price"`
- ProductCargoNumber string `json:"productCargoNumber"`
- ProductID int64 `json:"productID"`
- ProductImgURL []string `json:"productImgUrl"`
- ProductSnapshotURL string `json:"productSnapshotUrl"`
- Quantity int `json:"quantity"`
- QuantityFactor int `json:"quantityFactor"`
- Refund int `json:"refund"`
- Status string `json:"status"`
- StatusStr string `json:"statusStr"`
- SubItemID int64 `json:"subItemID"`
- SubItemIDString string `json:"subItemIDString"`
- Type string `json:"type"`
- Unit string `json:"unit"`
- }
- type TradeTerm struct {
- CardPay bool `json:"cardPay"`
- ExpressPay bool `json:"expressPay"`
- PayStatus string `json:"payStatus"`
- PayStatusDesc string `json:"payStatusDesc"`
- PayTime string `json:"payTime"`
- PayWay string `json:"payWay"`
- PayWayDesc string `json:"payWayDesc"`
- PhasAmount float64 `json:"phasAmount"`
- Phase int64 `json:"phase"`
- }
-
- func OrderDetails(appKey, appSecret, accessToken string, ordId int64) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := make(map[string]interface{})
- reqMap["access_token"] = accessToken
- reqMap["webSite"] = "1688"
- reqMap["orderId"] = ordId
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688OrderBuyerViewUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type OrderAfterSaleDetailsResp struct {
- Result OrderAfterSaleDetailsRespResult `json:"result"`
- }
- type OrderAfterSaleDetailsRespResult struct {
- OpOrderRefundModelDetail OpOrderRefundModelDetail `json:"opOrderRefundModelDetail"`
- }
- type OpOrderRefundModelDetail struct {
- AlipayPaymentID string `json:"alipayPaymentId"`
- ApplyCarriage int `json:"applyCarriage"`
- ApplyPayment int `json:"applyPayment"`
- ApplyReason string `json:"applyReason"`
- ApplyReasonID int `json:"applyReasonId"`
- ApplySubReasonID int `json:"applySubReasonId"`
- BuyerLoginID string `json:"buyerLoginId"`
- BuyerMemberID string `json:"buyerMemberId"`
- BuyerSendGoods bool `json:"buyerSendGoods"`
- BuyerUserID int `json:"buyerUserId"`
- CanRefundPayment int `json:"canRefundPayment"`
- CrmModifyRefund bool `json:"crmModifyRefund"`
- DisputeRequest int `json:"disputeRequest"`
- DisputeType int `json:"disputeType"`
- ExtInfo ExtInfo `json:"extInfo"`
- FrozenFund int `json:"frozenFund"`
- GmtApply string `json:"gmtApply"`
- GmtCreate string `json:"gmtCreate"`
- GmtModified string `json:"gmtModified"`
- GmtTimeOut string `json:"gmtTimeOut"`
- GoodsReceived bool `json:"goodsReceived"`
- GoodsStatus int `json:"goodsStatus"`
- ID int64 `json:"id"`
- InstantRefundType string `json:"instantRefundType"`
- NewRefundReturn bool `json:"newRefundReturn"`
- OnlyRefund bool `json:"onlyRefund"`
- OrderEntryCountMap OrderEntryCountMap `json:"orderEntryCountMap"`
- OrderEntryIDList []int64 `json:"orderEntryIdList"`
- OrderID int64 `json:"orderId"`
- ProductName string `json:"productName"`
- RefundCarriage int `json:"refundCarriage"`
- RefundGoods bool `json:"refundGoods"`
- RefundID string `json:"refundId"`
- RefundOperationList []RefundOperation `json:"refundOperationList"`
- RefundPayment int `json:"refundPayment"`
- RejectReason string `json:"rejectReason"`
- RejectReasonID int `json:"rejectReasonId"`
- RejectTimes int `json:"rejectTimes"`
- SellerDelayDisburse bool `json:"sellerDelayDisburse"`
- SellerLoginID string `json:"sellerLoginId"`
- SellerMemberID string `json:"sellerMemberId"`
- SellerMobile string `json:"sellerMobile"`
- SellerRealName string `json:"sellerRealName"`
- SellerReceiveAddress string `json:"sellerReceiveAddress"`
- SellerTel string `json:"sellerTel"`
- SellerUserID int64 `json:"sellerUserId"`
- Status string `json:"status"`
- SupportNewSteppay bool `json:"supportNewSteppay"`
- TimeOutFreeze bool `json:"timeOutFreeze"`
- TimeOutOperateType string `json:"timeOutOperateType"`
- TradeTypeStr string `json:"tradeTypeStr"`
- }
- type ExtInfo struct {
- EXmrf string `json:"EXmrf"`
- Afterlast string `json:"afterlast"`
- AppName string `json:"appName"`
- ApplyInitRefundFee string `json:"apply_init_refund_fee"`
- ApplyReasonText string `json:"apply_reason_text"`
- B2BBt string `json:"b2b_bt"`
- B2BBuyerMID string `json:"b2b_buyer_mId"`
- B2BExchange string `json:"b2b_exchange"`
- B2BSellerMID string `json:"b2b_seller_mId"`
- BCfRsc string `json:"b_cf_rsc"`
- BFsc string `json:"b_fsc"`
- BPf string `json:"b_pf"`
- Bgmtc string `json:"bgmtc"`
- BizCode string `json:"bizCode"`
- BsSync string `json:"bs_sync"`
- CbuFstRsn string `json:"cbu_fst_rsn"`
- CljZeroSecondRefund string `json:"clj_zero_second_refund"`
- Enfunddetail string `json:"enfunddetail"`
- Instant string `json:"instant"`
- InterceptItemListResult string `json:"interceptItemListResult"`
- InterceptStatus string `json:"interceptStatus"`
- IsVirtual string `json:"isVirtual"`
- ItemBuyAmount string `json:"itemBuyAmount"`
- ItemPrice string `json:"itemPrice"`
- LastOrder string `json:"lastOrder"`
- NewRefund string `json:"newRefund"`
- OlTf string `json:"ol_tf"`
- OpRole string `json:"opRole"`
- PartRefund string `json:"part_refund"`
- PayMode string `json:"payMode"`
- RefuseReasonID string `json:"refuse_reason_id"`
- RefuseReasonMsg string `json:"refuse_reason_msg"`
- RefuseReasonTxt string `json:"refuse_reason_txt"`
- Rp3 string `json:"rp3"`
- SdkCode string `json:"sdkCode"`
- SellerAudit string `json:"seller_audit"`
- SellerBatch string `json:"seller_batch"`
- SellerRefuseCount string `json:"seller_refuse_count"`
- Sgr string `json:"sgr"`
- Tod string `json:"tod"`
- Tos string `json:"tos"`
- Ttid string `json:"ttid"`
- UserCredit string `json:"userCredit"`
- WorkflowName string `json:"workflowName"`
- }
- type OrderEntryCountMap struct {
- Num1662822517468979191 int `json:"1662822517468979191"`
- }
- type RefundOperation struct {
- AfterOperateStatus string `json:"afterOperateStatus,omitempty"`
- BeforeOperateStatus string `json:"beforeOperateStatus,omitempty"`
- CloseRefundStepID int `json:"closeRefundStepId"`
- CrmModifyRefund bool `json:"crmModifyRefund"`
- Discription string `json:"discription"`
- GmtCreate string `json:"gmtCreate"`
- GmtModified string `json:"gmtModified"`
- ID int64 `json:"id"`
- MessageStatus int `json:"messageStatus"`
- MsgType int `json:"msgType"`
- OperateRemark string `json:"operateRemark"`
- OperateTypeInt int `json:"operateTypeInt"`
- OperatorLoginID string `json:"operatorLoginId"`
- OperatorRoleID int `json:"operatorRoleId"`
- OperatorUserID int64 `json:"operatorUserId"`
- RefundID string `json:"refundId"`
- RejectReason string `json:"rejectReason,omitempty"`
- Vouchers []string `json:"vouchers,omitempty"`
- }
-
- func OrderAfterSaleDetails(appKey, appSecret, accessToken, refundId string) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := make(map[string]interface{})
- reqMap["access_token"] = accessToken
- reqMap["needTimeOutInfo"] = true
- reqMap["needOrderRefundOperation"] = true
- reqMap["refundId"] = refundId
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688RefundOpQueryOrderRefundUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- const (
- //
- // 精选货源商品查询标获取
- API1688AlibabaFenXiaoProductSearchTagListUrlPath = "param2/1/com.alibaba.fenxiao/alibaba.pifatuan.product.search.tag.list/"
- // 精选货源商品列表查询
- API1688AlibabaFenXiaoProductListUrlPath = "param2/1/com.alibaba.fenxiao/alibaba.pifatuan.product.list/"
-
- NewAPI1688AlibabaFenXiaoProductListUrlPath = "param2/1/com.alibaba.fenxiao/jxhy.product.getPageList/"
-
- // 精选货源商品详情批量查询
- API1688AlibabaFenXiaoProductDetailUrlPath = "param2/1/com.alibaba.fenxiao/alibaba.pifatuan.product.detail.list/"
- // 精选货源商品详情批量查询(精选货源商品详情批量查询去除没有retailPrice的sku)
- API1688AlibabaFenXiaoProductDetail2UrlPath = "param2/2/com.alibaba.fenxiao/alibaba.pifatuan.product.detail.list/"
- // 创建采购订单
- API1688AlibabaFenXiaoFastCreateOrderUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.fastCreateOrder/"
- // 创建订单前预览数据接口
- API1688AlibabaFenXiaoFastCreateOrderPreviewUrlPath = "param2/1/com.alibaba.trade/alibaba.createOrder.preview/"
- // 取消交易
- API1688AlibabaFenXiaoOrderCancelUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.cancel/"
- // 修改订单备忘
- API1688AlibabaFenXiaoOrderMemoAddUrlPath = "param2/1/com.alibaba.trade:alibaba.order.memoAdd-1/"
- // 发起免密支付
- API1688AlibabaFenXiaoPreparePayUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.pay.protocolPay.preparePay/"
- )
-
- func GetTagFrom1688(appKey, appSecret, accessToken string) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "6ddddfe6-d0cd-4e58-abbf-a265eb41be0b"
- }
- reqMap := make(map[string]interface{})
- reqMap["access_token"] = accessToken
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoProductSearchTagListUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type FenXiaoSearchCybOffersReq struct {
- AccessToken string `json:"access_token"`
-
- Page string `json:"pageNo"`
- PageSize string `json:"pageSize"`
- CategoryId string `json:"categoryId"`
- RuleId string `json:"ruleId"`
- }
-
- type NewFenXiaoSearchCybOffersReq struct {
- AccessToken string `json:"access_token"`
-
- Keyword string `json:"keyword"`
- Page string `json:"pageNum"`
- PageSize string `json:"pageSize"`
- PriceStart string `json:"priceStart"`
- PriceEnd string `json:"priceEnd"`
- CategoryId string `json:"categoryId"`
- RuleIds []string `json:"ruleIds"`
- }
-
- func GetFenXiaoSearchCybOffersFrom1688(appKey, appSecret string, req *FenXiaoSearchCybOffersReq) (map[string]interface{}, error) {
- if req.AccessToken == "" {
- req.AccessToken = "6ddddfe6-d0cd-4e58-abbf-a265eb41be0b"
- }
- reqMap := utils.Struct2Map(req)
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- utils.FilePutContents("1688", utils.SerializeStr(reqMap))
- api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoProductListUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- func NewGetFenXiaoSearchCybOffersFrom1688(appKey, appSecret string, req *NewFenXiaoSearchCybOffersReq) (map[string]interface{}, error) {
- if req.AccessToken == "" {
- req.AccessToken = "6ddddfe6-d0cd-4e58-abbf-a265eb41be0b"
- }
- reqMap := utils.Struct2Map(req)
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- utils.FilePutContents("1688", utils.SerializeStr(reqMap))
- api1688, err := API1688(API1688OfficialUrl, NewAPI1688AlibabaFenXiaoProductListUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- func GetFenXiaoProductInfoFrom1688(appKey, appSecret, accessToken string, offerIds []string) (map[string]interface{}, error) {
- if accessToken == "" {
- accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
- }
- reqMap := make(map[string]interface{})
- reqMap["access_token"] = accessToken
- reqMap["offerIds"] = offerIds
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoProductDetail2UrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- func FenXiaoPreview4CybMedia(appKey, appSecret string, req *Preview4CybMediaReq) (map[string]interface{}, error) {
- req.Flow = "ttpft"
- reqMap := utils.Struct2Map(req)
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoFastCreateOrderPreviewUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- type FenXiaoCreateOrder4CybMediaReq struct {
- AddressParam AddressParam `json:"addressParam" label:"收货地址信息,是否必填:是"`
- CargoParamList []*CargoParam `json:"cargoParamList" label:"商品信息,是否必填:是"`
- Flow string `json:"flow" label:"general(创建大市场订单),saleproxy(创建代销市场订单),fenxiao(最新淘货源下单),ttpft(精选货源下单),是否必填:是"`
- AccessToken string `json:"access_token"`
- IsvBizTypeStr string `json:"isvBizTypeStr"`
- //EncryptOutOrderInfo EncryptOutOrderInfo `json:"encryptOutOrderInfo" label:"下游加密订单信息`
- }
- type EncryptOutOrderInfo struct {
- EncryptOrder bool `json:"encryptOrder" label:"是否加密订单"`
- OutPlatformOrderNo string `json:"outPlatformOrderNo" label:"下游平台订单号"`
- OutPlatformCode string `json:"outPlatformCode" label:"淘宝-thyny,天猫-tm,淘特-taote,阿里巴巴C2M-c2m,京东-jingdong,拼多多-pinduoduo,微信-weixin,跨境-kuajing,快手-kuaishou,有赞-youzan,抖音-douyin,寺库-siku,美团团好货-meituan,小红书-xiaohongshu,当当-dangdang,苏宁-suning,大V店-davdian,行云-xingyun,蜜芽-miya,菠萝派商城-boluo,其他-other"`
- OutPlatformAppkey string `json:"outPlatformAppkey" label:"下游平台获取订单的appkey"`
- Oaid string `json:"oaid" label:"淘宝oaid"`
- }
-
- func FenXiaoCreateOrder4CybMedia(appKey, appSecret string, req *FenXiaoCreateOrder4CybMediaReq) (map[string]interface{}, error) {
- req.Flow = "ttpft"
- req.IsvBizTypeStr = "fenxiaoMedia"
- reqMap := utils.Struct2Map(req)
- parameters := make([]string, 0)
- for key, value := range reqMap {
- if value != "" {
- parameters = append(parameters, key)
- }
- }
- api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoFastCreateOrderUrlPath, appKey, appSecret, parameters, reqMap)
- return api1688, err
- }
-
- func FenXiaoAliProtocolPay(appKey, appSecret, accessToken, orderId string) (map[string]interface{}, error) {
- api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoPreparePayUrlPath, appKey, appSecret, []string{"tradeWithholdPreparePayParam", "access_token"}, map[string]interface{}{
- "tradeWithholdPreparePayParam": map[string]string{
- "orderId": orderId,
- },
- "access_token": accessToken,
- })
- return api1688, err
- }
|