golang 的 rabbitmq 消费项目
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

1109 行
50 KiB

  1. package utils
  2. import (
  3. "applet/app/utils"
  4. "crypto/hmac"
  5. "crypto/sha1"
  6. "encoding/hex"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/syyongx/php2go"
  10. "sort"
  11. "strings"
  12. )
  13. const (
  14. //1688api接口官方域名请求路径
  15. API1688OfficialUrl = "http://gw.open.1688.com/openapi/"
  16. //获取所有选品组列表
  17. API1688ListCybUserGroupUrlPath = "param2/1/com.alibaba.p4p/alibaba.cps.op.listCybUserGroup/"
  18. //获取已选商品列表
  19. API1688ListCybUserGroupFeedUrlPath = "param2/1/com.alibaba.p4p/alibaba.cps.op.listCybUserGroupFeed/"
  20. //商品列表API(如需要自建选品平台的使用此接口)
  21. API1688SearchCybOffersUrlPath = "param2/1/com.alibaba.p4p/alibaba.cps.op.searchCybOffers/"
  22. //商品详情(含运费模版)API
  23. API1688ProductInfoUrlPath = "param2/1/com.alibaba.product/alibaba.cpsMedia.productInfo/"
  24. //营销活动信息查询
  25. API1688QueryOfferDetailActivityUrlPath = "param2/1/com.alibaba.p4p/alibaba.cps.queryOfferDetailActivity/"
  26. //创建订单前预览接口API
  27. API1688Preview4CybMediaUrlPath = "param2/1/com.alibaba.trade/alibaba.createOrder.preview4CybMedia/"
  28. //下单API
  29. API1688CreateOrder4CybMediaUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.createOrder4CybMedia/"
  30. //订单取消API
  31. API1688OrderCancelUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.cancel/"
  32. //订单查询API
  33. API1688OrderBuyerViewUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.get.buyerView/"
  34. //支付API(使用支付宝协议代扣,无需调用此接口)
  35. API1688AlipayUrlGetUrlPath = "param2/1/com.alibaba.p4p/alibaba.alipay.url.get/"
  36. //支付宝协议代扣支付
  37. API1688AliProtocolPayUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.pay.protocolPay/"
  38. //获取交易订单的物流信息API
  39. API1688GetLogisticsInfosUrlPath = "param2/1/com.alibaba.logistics/alibaba.trade.getLogisticsInfos.buyerView/"
  40. //获取交易订单的物流跟踪信息API
  41. API1688GetLogisticsTraceInfoUrlPath = "param2/1/com.alibaba.logistics/alibaba.trade.getLogisticsTraceInfo.buyerView/"
  42. //根据类目Id查询类目
  43. API1688GetCategoryUrlPath = "param2/1/com.alibaba.product/alibaba.category.get/"
  44. //标题及图片改写(beta)
  45. API1688CpsMediaProductInfoUrlPath = "param2/1/com.alibaba.p4p/alibaba.cpsMedia.productInfo/"
  46. //查询退款单详情-根据退款单ID
  47. API1688RefundOpQueryOrderRefundUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.refund.OpQueryOrderRefund/"
  48. //创建退款退货申请
  49. API1688CreateRefundUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.createRefund/"
  50. //查询退款退货原因(用于创建退款退货)
  51. API1688GetRefundReasonListUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.getRefundReasonList/"
  52. //上传退款退货凭证
  53. API1688UploadRefundVoucherUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.uploadRefundVoucher/"
  54. //买家提交退款货信息
  55. API1688RefundReturnGoodsUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.refund.returnGoods/"
  56. //物流公司列表-自联物流
  57. API1688OpQueryLogisticCompanyListUrlPath = "param2/1/com.alibaba.logistics/alibaba.logistics.OpQueryLogisticCompanyList.offline/"
  58. )
  59. //
  60. var RefundActionMap = map[string]string{
  61. "BUYER_APPLY_REFUND": "买家申请退款",
  62. "BUYER_RECEIVE_CLOSE": "买家确认收货关闭",
  63. "SELLER_SEND_GOODS_CLOSE": "卖家发货关闭",
  64. "BUYER_CANCEL_REFUND_CLOSE": "买家撤销退款申请关闭",
  65. "BUYER_UPLOAD_BILL": "买家上传凭证",
  66. "SELLER_UPLOAD_BILL": "卖家上传凭证",
  67. "SELLER_REJECT_REFUND": "卖家拒绝退款",
  68. "SELLER_AGREE_REFUND": "卖家同意退款",
  69. "SELLER_RECEIVE_GOODS": "卖家确认收货",
  70. "BUYER_SEND_GOODS": "买家声明发货",
  71. "BUYER_MODIFY_REFUND_PROTOCOL": "买家修改退款协议",
  72. "BUYER_APPLY_SUPPORT": "买家申请客服介入",
  73. "SELLER_APPLY_SUPPORT": "卖家申请客服介入",
  74. "SYSTEM_AGREE_REFUND_PROTOCOL": "系统超时同意退款协议",
  75. "SYSTEM_AGREE_REFUND": "系统超时同意退款,即退款成功",
  76. "SYSTEM_SEND_GOODS": "系统超时退货,主交易流程的退货",
  77. "SYSTEM_MODIFY_REFUND_PROTOCOL": "系统超时修改协议",
  78. "SYSTEM_NOTIFY_APPLY_SUPPORT": "系统通知申请客服介入",
  79. "SELLER_AGREE_REFUND_PROCOTOL": "卖家同意退款协议",
  80. "SELLER_REJECT_REFUND_PROCOTOL": "卖家拒绝退款协议",
  81. "CRM_APPLY_TIMEOUT_CLOSE": "申请客服介入超时关闭目前仅售后业务在用",
  82. "CRM_APPLY_SUPPORT": "CRM申请介入",
  83. "CRM_INTERVENE_TASK": "CRM介入处理",
  84. "CRM_DISMISS_TASK": "CRM撤销工单",
  85. "CRM_FINISH_TASK": "CRM完结工单",
  86. "BUYER_STEP_PAY_ORDER_CLOSE": "买家支付,退款关闭,分阶段订单情况",
  87. "BUYER_STEP_CONFIRM_CLOSE": "买家确认,退款关闭,分阶段订单情况",
  88. "BUYER_CLOSE_TRADE_CLOSE": "买家终止交易,退款关闭,分阶段订单情况",
  89. "SELLER_CONFIRM_ORDER_CLOSE": "卖家确认,退款关闭,分阶段订单情况",
  90. "SELLER_STEP_PUSH_CLOSE": "卖家推进,退款关闭,分阶段订单情况",
  91. }
  92. type General1688CallBack struct {
  93. Data interface{} `json:"data"`
  94. GmtBorn int64 `json:"gmtBorn"`
  95. MsgID int64 `json:"msgId"`
  96. Type string `json:"type"`
  97. UserInfo string `json:"userInfo"`
  98. }
  99. type OrderAnnounceSendGoodsData struct {
  100. BuyerMemberID string `json:"buyerMemberId" label:"买家中文站会员ID"`
  101. BuyerOpenUID string `json:"buyerOpenUid"`
  102. OrderID int64 `json:"orderId" label:"订单ID"`
  103. CurrentStatus string `json:"currentStatus" label:"当前订单状态,状态值为waitbuyerreceive"`
  104. MsgSendTime string `json:"msgSendTime" label:"消息发送时间"`
  105. }
  106. type OrderBuyerViewOrderRefundAfterSales struct {
  107. BuyerMemberID string `json:"buyerMemberId" label:"买家中文站会员ID"`
  108. OrderID int64 `json:"orderId" label:"订单ID"`
  109. CurrentStatus string `json:"currentStatus" label:"当前订单状态"`
  110. RefundAction string `json:"refundAction" label:"退款操作"`
  111. SellerMemberID string `json:"sellerMemberId" label:"卖家中文站会员ID"`
  112. MsgSendTime string `json:"msgSendTime" label:"消息发送时间"`
  113. Operator string `json:"operator" label:"操作的发起人,buyer(买家),seller(卖家),system(系统)"`
  114. RefundID string `json:"refundId" label:"退款单ID"`
  115. }
  116. type OrderBuyerViewOrderBuyerRefundInSales struct {
  117. BuyerMemberID string `json:"buyerMemberId" label:"买家中文站会员ID"`
  118. OrderID int64 `json:"orderId" label:"订单ID"`
  119. CurrentStatus string `json:"currentStatus" label:"当前订单状态"`
  120. RefundAction string `json:"refundAction" label:"退款操作"`
  121. SellerMemberID string `json:"sellerMemberId" label:"卖家中文站会员ID"`
  122. MsgSendTime string `json:"msgSendTime" label:"消息发送时间"`
  123. Operator string `json:"operator" label:"操作的发起人,buyer(买家),seller(卖家),system(系统)"`
  124. RefundID string `json:"refundId" label:"退款单ID"`
  125. }
  126. func HmacSHA1(key string, data string) string {
  127. mac := hmac.New(sha1.New, []byte(key))
  128. mac.Write([]byte(data))
  129. return hex.EncodeToString(mac.Sum(nil))
  130. }
  131. //shejiao
  132. //urlPath =
  133. //appKey = 2821195
  134. //appSecret = qaMVhzoS3nT
  135. //access_token = 2101cd32-8762-49ed-a87b-94e25ab0c40d
  136. //fenxiao
  137. //appKey = 4535867
  138. //appSecret = lKXjQAP5EK
  139. //access_token = 6ddddfe6-d0cd-4e58-abbf-a265eb41be0b
  140. //Refresh Token = 5d358adb-3184-4411-8197-e152eed9d198
  141. func API1688(url, urlPath, appKey, appSecret string, parameters []string, parameterMap map[string]interface{}) (map[string]interface{}, error) {
  142. urlPath = urlPath + appKey
  143. assembleParameter := ""
  144. parameterUrl := ""
  145. //进行切片排序
  146. sort.Strings(parameters)
  147. for _, parameter := range parameters {
  148. switch parameterMap[parameter].(type) {
  149. case string:
  150. str := utils.AnyToString(parameterMap[parameter])
  151. fmt.Println(str)
  152. assembleParameter = assembleParameter + parameter + str
  153. if parameter == "imageData" {
  154. str = php2go.URLEncode(str)
  155. }
  156. if parameter == "addressParam" {
  157. str = php2go.URLEncode(str)
  158. }
  159. if parameterUrl == "" {
  160. parameterUrl = "?" + parameter + "=" + str
  161. } else {
  162. parameterUrl = parameterUrl + "&" + parameter + "=" + str
  163. }
  164. default:
  165. str := utils.SerializeStr(parameterMap[parameter])
  166. fmt.Println(str)
  167. assembleParameter = assembleParameter + parameter + str
  168. if parameter == "imageData" {
  169. str = php2go.URLEncode(str)
  170. fmt.Println("URLEncode", str)
  171. }
  172. if parameter == "addressParam" {
  173. str = php2go.URLEncode(str)
  174. }
  175. if parameterUrl == "" {
  176. parameterUrl = "?" + parameter + "=" + str
  177. } else {
  178. parameterUrl = parameterUrl + "&" + parameter + "=" + str
  179. }
  180. }
  181. }
  182. hmacSHA1 := HmacSHA1(appSecret, urlPath+assembleParameter)
  183. toUpper := strings.ToUpper(hmacSHA1)
  184. url = url + urlPath + parameterUrl + "&_aop_signature=" + toUpper
  185. headers := map[string]string{
  186. "Content-Type": "application/x-www-form-urlencoded",
  187. "Content-Length": utils.AnyToString(len(url)),
  188. //"Charset": "utf-8",
  189. }
  190. utils.FilePutContents("API1688", utils.SerializeStr(map[string]interface{}{
  191. "url": url,
  192. "headers": headers,
  193. }))
  194. res, err := utils.CurlGet(url, headers)
  195. if err != nil {
  196. return nil, err
  197. }
  198. resp := make(map[string]interface{})
  199. if err := json.Unmarshal(res, &resp); err != nil {
  200. return nil, err
  201. }
  202. return resp, nil
  203. }
  204. func GetCategoryFrom1688(appKey, appSecret, categoryID string) (map[string]interface{}, error) {
  205. if categoryID == "" {
  206. categoryID = "0"
  207. }
  208. api1688, err := API1688(API1688OfficialUrl, API1688GetCategoryUrlPath, appKey, appSecret, []string{"categoryID"}, map[string]interface{}{
  209. "categoryID": categoryID,
  210. })
  211. return api1688, err
  212. }
  213. type SearchCybOffersReq struct {
  214. AccessToken string `json:"access_token"`
  215. BizType string `json:"biztype"`
  216. Page string `json:"page"`
  217. PageSize string `json:"pageSize"`
  218. PostCategoryId string `json:"postCategoryId"`
  219. KeyWords string `json:"keyWords"`
  220. PriceStart string `json:"priceStart"` //最低价
  221. PriceEnd string `json:"priceEnd"` //最高价
  222. SortType string `json:"sortType"` //normal:综合 saleQuantity:销量
  223. DescendOrder bool `json:"descendOrder"` //是否倒序;正序: false;倒序:true
  224. OfferIds string `json:"offerIds"`
  225. }
  226. func GetSearchCybOffersFrom1688(appKey, appSecret string, req *SearchCybOffersReq) (map[string]interface{}, error) {
  227. if req.AccessToken == "" {
  228. req.AccessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  229. }
  230. reqMap := utils.Struct2Map(req)
  231. parameters := make([]string, 0)
  232. for key, value := range reqMap {
  233. if value != "" {
  234. parameters = append(parameters, key)
  235. }
  236. }
  237. api1688, err := API1688(API1688OfficialUrl, API1688SearchCybOffersUrlPath, appKey, appSecret, parameters, reqMap)
  238. return api1688, err
  239. }
  240. func GetProductInfoFrom1688(appKey, appSecret, accessToken, offerId string) (map[string]interface{}, error) {
  241. if accessToken == "" {
  242. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  243. }
  244. reqMap := make(map[string]interface{})
  245. reqMap["access_token"] = accessToken
  246. reqMap["offerId"] = utils.StrToInt64(offerId)
  247. reqMap["needCpsSuggestPrice"] = true
  248. reqMap["needIntelligentInfo"] = true
  249. parameters := make([]string, 0)
  250. for key, value := range reqMap {
  251. if value != "" {
  252. parameters = append(parameters, key)
  253. }
  254. }
  255. api1688, err := API1688(API1688OfficialUrl, API1688ProductInfoUrlPath, appKey, appSecret, parameters, reqMap)
  256. return api1688, err
  257. }
  258. func GetListCybUserGroupFrom1688(appKey, appSecret, accessToken, pageNo, pageSize string) (map[string]interface{}, error) {
  259. if accessToken == "" {
  260. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  261. }
  262. reqMap := make(map[string]interface{})
  263. reqMap["access_token"] = accessToken
  264. reqMap["pageNo"] = pageNo
  265. reqMap["pageSize"] = pageSize
  266. parameters := make([]string, 0)
  267. for key, value := range reqMap {
  268. if value != "" {
  269. parameters = append(parameters, key)
  270. }
  271. }
  272. api1688, err := API1688(API1688OfficialUrl, API1688ListCybUserGroupUrlPath, appKey, appSecret, parameters, reqMap)
  273. return api1688, err
  274. }
  275. type ListCybUserGroupFeedReq struct {
  276. AccessToken string `json:"access_token" form:"access_token"`
  277. GroupId int64 `json:"groupId" form:"groupId"` //选品组id,不传表示取默认选品组下商品;
  278. PageNo int `json:"pageNo" form:"pageNo"`
  279. PageSize string `json:"pageSize" form:"pageSize"`
  280. FeedId int64 `json:"feedId" form:"feedId"` //商品id
  281. Title string `json:"title" form:"title"` //商品标题模糊搜索
  282. }
  283. func GetListCybUserGroupFeedFrom1688(appKey, appSecret string, req *ListCybUserGroupFeedReq) (map[string]interface{}, error) {
  284. if req.AccessToken == "" {
  285. req.AccessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  286. }
  287. reqMap := utils.Struct2Map(req)
  288. parameters := make([]string, 0)
  289. for key, value := range reqMap {
  290. if utils.AnyToString(value) != "" && utils.AnyToString(value) != "0" {
  291. parameters = append(parameters, key)
  292. }
  293. }
  294. api1688, err := API1688(API1688OfficialUrl, API1688ListCybUserGroupFeedUrlPath, appKey, appSecret, parameters, reqMap)
  295. return api1688, err
  296. }
  297. type AddressParam struct {
  298. AddressId int64 `json:"addressId" label:"收货地址id,是否必填:否"`
  299. FullName string `json:"fullName" label:"收货人姓名,是否必填:是"`
  300. Mobile string `json:"mobile" label:"手机 15251667788,是否必填:是"`
  301. Phone string `json:"phone" label:"电话 0517-88990077,是否必填:是"`
  302. PostCode string `json:"postCode" label:"邮编,是否必填:是"`
  303. CityText string `json:"cityText" label:"市文本,是否必填:是"`
  304. ProvinceText string `json:"provinceText" label:"省份文本,是否必填:是"`
  305. AreaText string `json:"areaText" label:"区文本,是否必填:是"`
  306. TownText string `json:"townText" label:"镇文本,是否必填:是"`
  307. Address string `json:"address" label:"街道地址,是否必填:是"`
  308. DistrictCode string `json:"districtCode" label:"地址编码,是否必填:是"`
  309. }
  310. type CargoParam struct {
  311. OfferId int64 `json:"offerId" label:"商品对应的offer id,是否必填:是"`
  312. SpecId string `json:"specId" label:"商品规格id 无sku商品不传,是否必填:否"`
  313. Quantity float64 `json:"quantity" label:"商品数量(计算金额用),是否必填:是"`
  314. }
  315. type Preview4CybMediaReq struct {
  316. AddressParam AddressParam `json:"addressParam" label:"收货地址信息,是否必填:是"`
  317. CargoParamList []*CargoParam `json:"cargoParamList" label:"商品信息,是否必填:是"`
  318. AccessToken string `json:"access_token"`
  319. Flow string `json:"flow" label:"不传,价格逻辑由useChannelPrice控制;传入general使用批发价,即useChannelPrice的价格逻辑失效;传入paired使用火拼价,若该商品未参与伙拼,则下单失败。
  320. general(批发),paired(火拼),是否必填:否"`
  321. UseChannelPrice bool `json:"useChannelPrice" label:"是否走渠道专属价,传true优先使用渠道传享价,不传或者传false则不走渠道专享价,走普通的分销价,是否必填:否"`
  322. }
  323. type Cargo struct {
  324. Amount float64 `json:"amount"`
  325. FinalUnitPrice float64 `json:"finalUnitPrice"`
  326. SpecID string `json:"specId"`
  327. SkuID int64 `json:"skuId"`
  328. OfferID int64 `json:"offerId"`
  329. CargoPromotionList []interface{} `json:"cargoPromotionList"`
  330. }
  331. type TradeModel struct {
  332. TradeWay string `json:"tradeWay"`
  333. Name string `json:"name"`
  334. TradeType string `json:"tradeType"`
  335. Description string `json:"description"`
  336. OpSupport bool `json:"opSupport"`
  337. }
  338. type ShopPromotion struct {
  339. PromotionId string `json:"promotionId"`
  340. Selected bool `json:"selected"`
  341. Text string `json:"text"`
  342. Desc string `json:"desc"`
  343. FreePostage bool `json:"freePostage"`
  344. DiscountFee int64 `json:"discountFee"`
  345. }
  346. type OrderPreviewResuslt struct {
  347. TradeModeNameList []string `json:"tradeModeNameList"`
  348. Status bool `json:"status"`
  349. SumPayment int `json:"sumPayment"`
  350. SumCarriage int `json:"sumCarriage"`
  351. SumPaymentNoCarriage int `json:"sumPaymentNoCarriage"`
  352. FlowFlag string `json:"flowFlag"`
  353. Message string `json:"message"`
  354. ResultCode string `json:"resultCode"`
  355. CargoList []Cargo `json:"cargoList"`
  356. ShopPromotionList []ShopPromotion `json:"shopPromotionList"`
  357. TradeModelList []TradeModel `json:"tradeModelList"`
  358. }
  359. type Preview4CybMediaResp struct {
  360. OrderPreviewResuslt []OrderPreviewResuslt `json:"orderPreviewResuslt"`
  361. Success bool `json:"success"`
  362. ErrorCode string `json:"errorCode"`
  363. ErrorMsg string `json:"errorMsg"`
  364. PostFeeByDescOfferList []int64 `json:"postFeeByDescOfferList"`
  365. ConsignOfferList []int64 `json:"consignOfferList"`
  366. }
  367. func Preview4CybMedia(appKey, appSecret string, req *Preview4CybMediaReq) (map[string]interface{}, error) {
  368. reqMap := utils.Struct2Map(req)
  369. parameters := make([]string, 0)
  370. for key, value := range reqMap {
  371. if value != "" {
  372. parameters = append(parameters, key)
  373. }
  374. }
  375. api1688, err := API1688(API1688OfficialUrl, API1688Preview4CybMediaUrlPath, appKey, appSecret, parameters, reqMap)
  376. return api1688, err
  377. }
  378. type CreateOrder4CybMediaReq struct {
  379. AddressParam AddressParam `json:"addressParam" label:"收货地址信息,是否必填:是"`
  380. CargoParamList []*CargoParam `json:"cargoParamList" label:"商品信息,是否必填:是"`
  381. AccessToken string `json:"access_token"`
  382. OuterOrderInfo string `json:"outerOrderInfo" label:"机构的订单信息,json格式,如果校验不通过,不能创建订单。业务线原因机构订单信息不能放在上面的下单参数结构体中,只能新增该字段用于机构订单信息回写,没有幂等校验,纯记录统计分析。mediaOrderId:机构订单号;phone:电话;offers.id:Long,1688商品id;offers.specId:String,1688商品specId(可能无);offers.price:Long,媒体溢价单价(单位分);offers.num:Long,售卖数量`
  383. }
  384. type OuterOrderInfo struct {
  385. MediaOrderID int64 `json:"mediaOrderId" label:"业务产生的订单id,唯一"`
  386. Phone string `json:"phone"`
  387. Offers []*Offer `json:"offers"`
  388. }
  389. type Offer struct {
  390. ID int64 `json:"id" label:"1688云链的产品的offerId,对应goods表的cloud_chain_goods_id"` //1688云链的产品的offerId,对应goods表的cloud_chain_goods_id
  391. SpecID string `json:"specId" label:"1688云链的sku的specId,对应sku表的specId"` //1688云链的sku的specId,对应sku表的specId
  392. Price float64 `json:"price" label:"业务销售金额"` //业务销售金额
  393. Num float64 `json:"num" label:"销售数量"` //销售数量
  394. }
  395. func CreateOrder4CybMedia(appKey, appSecret string, req *CreateOrder4CybMediaReq, outerOrderInfo *OuterOrderInfo) (map[string]interface{}, error) {
  396. req.OuterOrderInfo = utils.SerializeStr(outerOrderInfo)
  397. reqMap := utils.Struct2Map(req)
  398. parameters := make([]string, 0)
  399. for key, value := range reqMap {
  400. if value != "" {
  401. parameters = append(parameters, key)
  402. }
  403. }
  404. api1688, err := API1688(API1688OfficialUrl, API1688CreateOrder4CybMediaUrlPath, appKey, appSecret, parameters, reqMap)
  405. return api1688, err
  406. }
  407. func AliProtocolPay(appKey, appSecret, accessToken, orderId string) (map[string]interface{}, error) {
  408. api1688, err := API1688(API1688OfficialUrl, API1688AliProtocolPayUrlPath, appKey, appSecret, []string{"orderId", "access_token"}, map[string]interface{}{
  409. "orderId": utils.StrToInt64(orderId),
  410. "access_token": accessToken,
  411. })
  412. return api1688, err
  413. }
  414. type OrderCancel1688 struct {
  415. TradeID int64 `json:"tradeID" label:"交易id,订单号"`
  416. CancelReason string `json:"cancelReason" label:"原因描述;buyerCancel:买家取消订单;sellerGoodsLack:卖家库存不足;other:其它"`
  417. Remark string `json:"remark" label:"备注" `
  418. }
  419. func OrderCancel(appKey, appSecret, accessToken string, req *OrderCancel1688) (map[string]interface{}, error) {
  420. if accessToken == "" {
  421. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  422. }
  423. reqMap := utils.Struct2Map(req)
  424. reqMap["access_token"] = accessToken
  425. reqMap["webSite"] = "1688"
  426. parameters := make([]string, 0)
  427. for key, value := range reqMap {
  428. if value != "" {
  429. parameters = append(parameters, key)
  430. }
  431. }
  432. api1688, err := API1688(API1688OfficialUrl, API1688OrderCancelUrlPath, appKey, appSecret, parameters, reqMap)
  433. return api1688, err
  434. }
  435. type OrderGetLogisticsInfosResp struct {
  436. Result []struct {
  437. LogisticsBillNo string `json:"logisticsBillNo"`
  438. LogisticsCompanyID string `json:"logisticsCompanyId"`
  439. LogisticsCompanyName string `json:"logisticsCompanyName"`
  440. LogisticsID string `json:"logisticsId"`
  441. OrderEntryIds string `json:"orderEntryIds"`
  442. Receiver struct {
  443. Encrypt string `json:"encrypt"`
  444. ReceiverAddress string `json:"receiverAddress"`
  445. ReceiverCity string `json:"receiverCity"`
  446. ReceiverCityCode string `json:"receiverCityCode"`
  447. ReceiverCounty string `json:"receiverCounty"`
  448. ReceiverCountyCode string `json:"receiverCountyCode"`
  449. ReceiverMobile string `json:"receiverMobile"`
  450. ReceiverName string `json:"receiverName"`
  451. ReceiverPhone string `json:"receiverPhone"`
  452. ReceiverProvince string `json:"receiverProvince"`
  453. ReceiverProvinceCode string `json:"receiverProvinceCode"`
  454. } `json:"receiver"`
  455. Remarks string `json:"remarks"`
  456. SendGoods []struct {
  457. GoodName string `json:"goodName"`
  458. Quantity string `json:"quantity"`
  459. Unit string `json:"unit"`
  460. } `json:"sendGoods"`
  461. Sender struct {
  462. Encrypt string `json:"encrypt"`
  463. SenderAddress string `json:"senderAddress"`
  464. SenderCity string `json:"senderCity"`
  465. SenderCityCode string `json:"senderCityCode"`
  466. SenderCounty string `json:"senderCounty"`
  467. SenderCountyCode string `json:"senderCountyCode"`
  468. SenderMobile string `json:"senderMobile"`
  469. SenderName string `json:"senderName"`
  470. SenderProvince string `json:"senderProvince"`
  471. SenderProvinceCode string `json:"senderProvinceCode"`
  472. } `json:"sender"`
  473. Status string `json:"status"`
  474. } `json:"result"`
  475. Success bool `json:"success"`
  476. }
  477. func OrderGetLogisticsInfos(appKey, appSecret, accessToken string, ordId int64) (map[string]interface{}, error) {
  478. api1688, err := API1688(API1688OfficialUrl, API1688GetLogisticsInfosUrlPath, appKey, appSecret, []string{"orderId", "access_token", "webSite"}, map[string]interface{}{
  479. "orderId": ordId,
  480. "access_token": accessToken,
  481. "webSite": 1688,
  482. })
  483. return api1688, err
  484. }
  485. func OrderGetLogisticsTraceInfo(appKey, appSecret, accessToken string, ordId int64) (map[string]interface{}, error) {
  486. api1688, err := API1688(API1688OfficialUrl, API1688GetLogisticsTraceInfoUrlPath, appKey, appSecret, []string{"orderId", "access_token", "webSite"}, map[string]interface{}{
  487. "orderId": ordId,
  488. "access_token": accessToken,
  489. "webSite": 1688,
  490. })
  491. return api1688, err
  492. }
  493. type GetRefundReasonList1688Req struct {
  494. OrderId int64 `json:"orderId" label:"主订单id"`
  495. OrderEntryIds []int64 `json:"orderEntryIds" label:"子订单id,无子订单的等于主订单编号"`
  496. //售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive"; 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived"; 售后已收到货:"aftersaleBuyerReceived"
  497. GoodsStatus string `json:"goodsStatus" label:"货物状态:售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive"; 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived"; 售后已收到货:"aftersaleBuyerReceived"" `
  498. }
  499. func GetRefundReasonList(appKey, appSecret, accessToken string, req *GetRefundReasonList1688Req) (map[string]interface{}, error) {
  500. if accessToken == "" {
  501. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  502. }
  503. if len(req.OrderEntryIds) == 0 {
  504. req.OrderEntryIds = append(req.OrderEntryIds, req.OrderId)
  505. }
  506. reqMap := utils.Struct2Map(req)
  507. reqMap["access_token"] = accessToken
  508. parameters := make([]string, 0)
  509. for key, value := range reqMap {
  510. if value != "" {
  511. parameters = append(parameters, key)
  512. }
  513. }
  514. api1688, err := API1688(API1688OfficialUrl, API1688GetRefundReasonListUrlPath, appKey, appSecret, parameters, reqMap)
  515. return api1688, err
  516. }
  517. func UploadRefundVoucher(appKey, appSecret, accessToken string, imageData []byte) (map[string]interface{}, error) {
  518. api1688, err := API1688(API1688OfficialUrl, API1688UploadRefundVoucherUrlPath, appKey, appSecret, []string{"access_token", "imageData"}, map[string]interface{}{
  519. "access_token": accessToken,
  520. "imageData": imageData,
  521. })
  522. return api1688, err
  523. }
  524. type CreateRefundReq struct {
  525. OrderId int64 `json:"orderId" label:"主订单id"`
  526. OrderEntryIds []int64 `json:"orderEntryIds" label:"子订单id,无子订单的等于主订单编号"`
  527. DisputeRequest string `json:"disputeRequest" label:"退款/退款退货。只有已收到货,才可以选择退款退货。" sample:" 退款:refund; 退款退货:returnRefund" `
  528. ApplyPayment int64 `json:"applyPayment" label:"退款金额(单位:分)。不大于实际付款金额;等待卖家发货时,必须为商品的实际付款金额。" sample:""`
  529. ApplyCarriage int64 `json:"applyCarriage" label:"退运费金额(单位:分)。" sample:""`
  530. ApplyReasonId int64 `json:"applyReasonId" label:"退款原因id(从API getRefundReasonList获取)" sample:""`
  531. Description string `json:"description" label:"退款申请理由,2-150字" sample:""`
  532. //售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive"; 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived"; 售后已收到货:"aftersaleBuyerReceived"
  533. GoodsStatus string `json:"goodsStatus" label:"货物状态:售中等待买家发货:”refundWaitSellerSend"; 售中等待买家收货:"refundWaitBuyerReceive"; 售中已收货(未确认完成交易):"refundBuyerReceived" 售后未收货:"aftersaleBuyerNotReceived"; 售后已收到货:"aftersaleBuyerReceived"" `
  534. Vouchers []string `json:"vouchers" label:"凭证图片URLs。1-5张,必须使用API uploadRefundVoucher返回的“图片域名/相对路径”" sample:""`
  535. }
  536. type CreateRefundResult struct {
  537. Code string `json:"code"`
  538. Message string `json:"message"`
  539. Result struct {
  540. RefundID string `json:"refundId"`
  541. } `json:"result"`
  542. Success bool `json:"success"`
  543. }
  544. func CreateRefund(appKey, appSecret, accessToken string, req *CreateRefundReq) (map[string]interface{}, error) {
  545. if accessToken == "" {
  546. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  547. }
  548. if len(req.OrderEntryIds) == 0 {
  549. req.OrderEntryIds = append(req.OrderEntryIds, req.OrderId)
  550. }
  551. reqMap := utils.Struct2Map(req)
  552. reqMap["access_token"] = accessToken
  553. if len(req.Vouchers) == 0 {
  554. delete(reqMap, "vouchers")
  555. }
  556. parameters := make([]string, 0)
  557. for key, value := range reqMap {
  558. if value != "" {
  559. parameters = append(parameters, key)
  560. }
  561. }
  562. api1688, err := API1688(API1688OfficialUrl, API1688CreateRefundUrlPath, appKey, appSecret, parameters, reqMap)
  563. return api1688, err
  564. }
  565. type RefundReturnGoodsReq struct {
  566. RefundId string `json:"refundId" label:"退款单号,TQ开头"`
  567. LogisticsCompanyNo string `json:"logisticsCompanyNo" label:"物流公司编码,调用alibaba.logistics.OpQueryLogisticCompanyList.offline接口查询"`
  568. FreightBill string `json:"freightBill" label:"物流公司运单号,请准确填写,否则卖家有权拒绝退款" `
  569. Description string `json:"description" label:"发货说明,内容在2-200个字之间" sample:""`
  570. Vouchers []string `json:"vouchers" label:"凭证图片URLs。1-5张,必须使用API uploadRefundVoucher返回的“图片域名/相对路径”" sample:""`
  571. }
  572. type RefundReturnGoodsResp struct {
  573. Result struct {
  574. ErrorCode string `json:"errorCode"`
  575. ErrorInfo string `json:"errorInfo"`
  576. Success bool `json:"success"`
  577. } `json:"result"`
  578. }
  579. func RefundReturnGoods(appKey, appSecret, accessToken string, req *RefundReturnGoodsReq) (*RefundReturnGoodsResp, error) {
  580. if accessToken == "" {
  581. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  582. }
  583. reqMap := utils.Struct2Map(req)
  584. reqMap["access_token"] = accessToken
  585. parameters := make([]string, 0)
  586. for key, value := range reqMap {
  587. if value != "" {
  588. parameters = append(parameters, key)
  589. }
  590. }
  591. api1688, err := API1688(API1688OfficialUrl, API1688RefundReturnGoodsUrlPath, appKey, appSecret, parameters, reqMap)
  592. var resp RefundReturnGoodsResp
  593. resp.Result.Success = false
  594. utils.Unserialize(utils.Serialize(api1688), &resp)
  595. return &resp, err
  596. }
  597. func OpQueryLogisticCompanyList(appKey, appSecret, accessToken string) (map[string]interface{}, error) {
  598. if accessToken == "" {
  599. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  600. }
  601. reqMap := make(map[string]interface{})
  602. reqMap["access_token"] = accessToken
  603. parameters := make([]string, 0)
  604. for key, value := range reqMap {
  605. if value != "" {
  606. parameters = append(parameters, key)
  607. }
  608. }
  609. api1688, err := API1688(API1688OfficialUrl, API1688OpQueryLogisticCompanyListUrlPath, appKey, appSecret, parameters, reqMap)
  610. return api1688, err
  611. }
  612. type OrderDetailsResp struct {
  613. Result Result `json:"result"`
  614. Success string `json:"success"`
  615. }
  616. type Result struct {
  617. BaseInfo BaseInfo `json:"baseInfo"`
  618. ExtAttributes []interface{} `json:"extAttributes"`
  619. GuaranteesTerms GuaranteesTerms `json:"guaranteesTerms"`
  620. NativeLogistics NativeLogistics `json:"nativeLogistics"`
  621. OrderBizInfo OrderBizInfo `json:"orderBizInfo"`
  622. OrderRateInfo OrderRateInfo `json:"orderRateInfo"`
  623. ProductItems []ProductItem `json:"productItems"`
  624. TradeTerms []TradeTerm `json:"tradeTerms"`
  625. }
  626. type BaseInfo struct {
  627. BusinessType string `json:"businessType"`
  628. BuyerContact struct {
  629. CompanyName string `json:"companyName"`
  630. ImInPlatform string `json:"imInPlatform"`
  631. Name string `json:"name"`
  632. Phone string `json:"phone"`
  633. } `json:"buyerContact"`
  634. BuyerID string `json:"buyerID"`
  635. BuyerLoginID string `json:"buyerLoginId"`
  636. CloseOperateType string `json:"closeOperateType"`
  637. CouponFee int `json:"couponFee"`
  638. CreateTime string `json:"createTime"`
  639. Discount int `json:"discount"`
  640. FlowTemplateCode string `json:"flowTemplateCode"`
  641. ID int64 `json:"id"`
  642. IDOfStr string `json:"idOfStr"`
  643. ModifyTime string `json:"modifyTime"`
  644. OverSeaOrder bool `json:"overSeaOrder"`
  645. PayChannelCodeList []interface{} `json:"payChannelCodeList"`
  646. PayChannelList []interface{} `json:"payChannelList"`
  647. PayTimeout int `json:"payTimeout"`
  648. PayTimeoutType int `json:"payTimeoutType"`
  649. ReceiverInfo struct {
  650. ToArea string `json:"toArea"`
  651. ToDivisionCode string `json:"toDivisionCode"`
  652. ToFullName string `json:"toFullName"`
  653. ToMobile string `json:"toMobile"`
  654. ToPhone string `json:"toPhone"`
  655. ToPost string `json:"toPost"`
  656. } `json:"receiverInfo"`
  657. Refund int `json:"refund"`
  658. RefundPayment int `json:"refundPayment"`
  659. SellerContact struct {
  660. CompanyName string `json:"companyName"`
  661. ImInPlatform string `json:"imInPlatform"`
  662. Name string `json:"name"`
  663. Phone string `json:"phone"`
  664. } `json:"sellerContact"`
  665. SellerID string `json:"sellerID"`
  666. SellerLoginID string `json:"sellerLoginId"`
  667. SellerOrder bool `json:"sellerOrder"`
  668. ShippingFee int `json:"shippingFee"`
  669. Status string `json:"status"`
  670. StepPayAll bool `json:"stepPayAll"`
  671. SumProductPayment float64 `json:"sumProductPayment"`
  672. TotalAmount float64 `json:"totalAmount"`
  673. TradeType string `json:"tradeType"`
  674. TradeTypeCode string `json:"tradeTypeCode"`
  675. TradeTypeDesc string `json:"tradeTypeDesc"`
  676. }
  677. type GuaranteesTerms struct {
  678. AssuranceInfo string `json:"assuranceInfo"`
  679. AssuranceType string `json:"assuranceType"`
  680. QualityAssuranceType string `json:"qualityAssuranceType"`
  681. }
  682. type NativeLogistics struct {
  683. Address string `json:"address"`
  684. Area string `json:"area"`
  685. AreaCode string `json:"areaCode"`
  686. City string `json:"city"`
  687. ContactPerson string `json:"contactPerson"`
  688. Mobile string `json:"mobile"`
  689. Province string `json:"province"`
  690. Telephone string `json:"telephone"`
  691. Zip string `json:"zip"`
  692. }
  693. type OrderBizInfo struct {
  694. CreditOrder bool `json:"creditOrder"`
  695. OdsCyd bool `json:"odsCyd"`
  696. }
  697. type OrderRateInfo struct {
  698. BuyerRateStatus int `json:"buyerRateStatus"`
  699. SellerRateStatus int `json:"sellerRateStatus"`
  700. }
  701. type ProductItem struct {
  702. EntryDiscount int `json:"entryDiscount"`
  703. GmtCreate string `json:"gmtCreate"`
  704. GmtModified string `json:"gmtModified"`
  705. GmtPayExpireTime string `json:"gmtPayExpireTime"`
  706. GuaranteesTerms []struct {
  707. AssuranceInfo string `json:"assuranceInfo"`
  708. AssuranceType string `json:"assuranceType"`
  709. QualityAssuranceType string `json:"qualityAssuranceType"`
  710. } `json:"guaranteesTerms"`
  711. ItemAmount float64 `json:"itemAmount"`
  712. LogisticsStatus int `json:"logisticsStatus"`
  713. Name string `json:"name"`
  714. Price float64 `json:"price"`
  715. ProductCargoNumber string `json:"productCargoNumber"`
  716. ProductID int64 `json:"productID"`
  717. ProductImgURL []string `json:"productImgUrl"`
  718. ProductSnapshotURL string `json:"productSnapshotUrl"`
  719. Quantity int `json:"quantity"`
  720. QuantityFactor int `json:"quantityFactor"`
  721. Refund int `json:"refund"`
  722. Status string `json:"status"`
  723. StatusStr string `json:"statusStr"`
  724. SubItemID int64 `json:"subItemID"`
  725. SubItemIDString string `json:"subItemIDString"`
  726. Type string `json:"type"`
  727. Unit string `json:"unit"`
  728. }
  729. type TradeTerm struct {
  730. CardPay bool `json:"cardPay"`
  731. ExpressPay bool `json:"expressPay"`
  732. PayStatus string `json:"payStatus"`
  733. PayStatusDesc string `json:"payStatusDesc"`
  734. PayTime string `json:"payTime"`
  735. PayWay string `json:"payWay"`
  736. PayWayDesc string `json:"payWayDesc"`
  737. PhasAmount float64 `json:"phasAmount"`
  738. Phase int64 `json:"phase"`
  739. }
  740. func OrderDetails(appKey, appSecret, accessToken string, ordId int64) (map[string]interface{}, error) {
  741. if accessToken == "" {
  742. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  743. }
  744. reqMap := make(map[string]interface{})
  745. reqMap["access_token"] = accessToken
  746. reqMap["webSite"] = "1688"
  747. reqMap["orderId"] = ordId
  748. parameters := make([]string, 0)
  749. for key, value := range reqMap {
  750. if value != "" {
  751. parameters = append(parameters, key)
  752. }
  753. }
  754. api1688, err := API1688(API1688OfficialUrl, API1688OrderBuyerViewUrlPath, appKey, appSecret, parameters, reqMap)
  755. return api1688, err
  756. }
  757. type OrderAfterSaleDetailsResp struct {
  758. Result OrderAfterSaleDetailsRespResult `json:"result"`
  759. }
  760. type OrderAfterSaleDetailsRespResult struct {
  761. OpOrderRefundModelDetail OpOrderRefundModelDetail `json:"opOrderRefundModelDetail"`
  762. }
  763. type OpOrderRefundModelDetail struct {
  764. AlipayPaymentID string `json:"alipayPaymentId"`
  765. ApplyCarriage int `json:"applyCarriage"`
  766. ApplyPayment int `json:"applyPayment"`
  767. ApplyReason string `json:"applyReason"`
  768. ApplyReasonID int `json:"applyReasonId"`
  769. ApplySubReasonID int `json:"applySubReasonId"`
  770. BuyerLoginID string `json:"buyerLoginId"`
  771. BuyerMemberID string `json:"buyerMemberId"`
  772. BuyerSendGoods bool `json:"buyerSendGoods"`
  773. BuyerUserID int `json:"buyerUserId"`
  774. CanRefundPayment int `json:"canRefundPayment"`
  775. CrmModifyRefund bool `json:"crmModifyRefund"`
  776. DisputeRequest int `json:"disputeRequest"`
  777. DisputeType int `json:"disputeType"`
  778. ExtInfo ExtInfo `json:"extInfo"`
  779. FrozenFund int `json:"frozenFund"`
  780. GmtApply string `json:"gmtApply"`
  781. GmtCreate string `json:"gmtCreate"`
  782. GmtModified string `json:"gmtModified"`
  783. GmtTimeOut string `json:"gmtTimeOut"`
  784. GoodsReceived bool `json:"goodsReceived"`
  785. GoodsStatus int `json:"goodsStatus"`
  786. ID int64 `json:"id"`
  787. InstantRefundType string `json:"instantRefundType"`
  788. NewRefundReturn bool `json:"newRefundReturn"`
  789. OnlyRefund bool `json:"onlyRefund"`
  790. OrderEntryCountMap OrderEntryCountMap `json:"orderEntryCountMap"`
  791. OrderEntryIDList []int64 `json:"orderEntryIdList"`
  792. OrderID int64 `json:"orderId"`
  793. ProductName string `json:"productName"`
  794. RefundCarriage int `json:"refundCarriage"`
  795. RefundGoods bool `json:"refundGoods"`
  796. RefundID string `json:"refundId"`
  797. RefundOperationList []RefundOperation `json:"refundOperationList"`
  798. RefundPayment int `json:"refundPayment"`
  799. RejectReason string `json:"rejectReason"`
  800. RejectReasonID int `json:"rejectReasonId"`
  801. RejectTimes int `json:"rejectTimes"`
  802. SellerDelayDisburse bool `json:"sellerDelayDisburse"`
  803. SellerLoginID string `json:"sellerLoginId"`
  804. SellerMemberID string `json:"sellerMemberId"`
  805. SellerMobile string `json:"sellerMobile"`
  806. SellerRealName string `json:"sellerRealName"`
  807. SellerReceiveAddress string `json:"sellerReceiveAddress"`
  808. SellerTel string `json:"sellerTel"`
  809. SellerUserID int64 `json:"sellerUserId"`
  810. Status string `json:"status"`
  811. SupportNewSteppay bool `json:"supportNewSteppay"`
  812. TimeOutFreeze bool `json:"timeOutFreeze"`
  813. TimeOutOperateType string `json:"timeOutOperateType"`
  814. TradeTypeStr string `json:"tradeTypeStr"`
  815. }
  816. type ExtInfo struct {
  817. EXmrf string `json:"EXmrf"`
  818. Afterlast string `json:"afterlast"`
  819. AppName string `json:"appName"`
  820. ApplyInitRefundFee string `json:"apply_init_refund_fee"`
  821. ApplyReasonText string `json:"apply_reason_text"`
  822. B2BBt string `json:"b2b_bt"`
  823. B2BBuyerMID string `json:"b2b_buyer_mId"`
  824. B2BExchange string `json:"b2b_exchange"`
  825. B2BSellerMID string `json:"b2b_seller_mId"`
  826. BCfRsc string `json:"b_cf_rsc"`
  827. BFsc string `json:"b_fsc"`
  828. BPf string `json:"b_pf"`
  829. Bgmtc string `json:"bgmtc"`
  830. BizCode string `json:"bizCode"`
  831. BsSync string `json:"bs_sync"`
  832. CbuFstRsn string `json:"cbu_fst_rsn"`
  833. CljZeroSecondRefund string `json:"clj_zero_second_refund"`
  834. Enfunddetail string `json:"enfunddetail"`
  835. Instant string `json:"instant"`
  836. InterceptItemListResult string `json:"interceptItemListResult"`
  837. InterceptStatus string `json:"interceptStatus"`
  838. IsVirtual string `json:"isVirtual"`
  839. ItemBuyAmount string `json:"itemBuyAmount"`
  840. ItemPrice string `json:"itemPrice"`
  841. LastOrder string `json:"lastOrder"`
  842. NewRefund string `json:"newRefund"`
  843. OlTf string `json:"ol_tf"`
  844. OpRole string `json:"opRole"`
  845. PartRefund string `json:"part_refund"`
  846. PayMode string `json:"payMode"`
  847. RefuseReasonID string `json:"refuse_reason_id"`
  848. RefuseReasonMsg string `json:"refuse_reason_msg"`
  849. RefuseReasonTxt string `json:"refuse_reason_txt"`
  850. Rp3 string `json:"rp3"`
  851. SdkCode string `json:"sdkCode"`
  852. SellerAudit string `json:"seller_audit"`
  853. SellerBatch string `json:"seller_batch"`
  854. SellerRefuseCount string `json:"seller_refuse_count"`
  855. Sgr string `json:"sgr"`
  856. Tod string `json:"tod"`
  857. Tos string `json:"tos"`
  858. Ttid string `json:"ttid"`
  859. UserCredit string `json:"userCredit"`
  860. WorkflowName string `json:"workflowName"`
  861. }
  862. type OrderEntryCountMap struct {
  863. Num1662822517468979191 int `json:"1662822517468979191"`
  864. }
  865. type RefundOperation struct {
  866. AfterOperateStatus string `json:"afterOperateStatus,omitempty"`
  867. BeforeOperateStatus string `json:"beforeOperateStatus,omitempty"`
  868. CloseRefundStepID int `json:"closeRefundStepId"`
  869. CrmModifyRefund bool `json:"crmModifyRefund"`
  870. Discription string `json:"discription"`
  871. GmtCreate string `json:"gmtCreate"`
  872. GmtModified string `json:"gmtModified"`
  873. ID int64 `json:"id"`
  874. MessageStatus int `json:"messageStatus"`
  875. MsgType int `json:"msgType"`
  876. OperateRemark string `json:"operateRemark"`
  877. OperateTypeInt int `json:"operateTypeInt"`
  878. OperatorLoginID string `json:"operatorLoginId"`
  879. OperatorRoleID int `json:"operatorRoleId"`
  880. OperatorUserID int64 `json:"operatorUserId"`
  881. RefundID string `json:"refundId"`
  882. RejectReason string `json:"rejectReason,omitempty"`
  883. Vouchers []string `json:"vouchers,omitempty"`
  884. }
  885. func OrderAfterSaleDetails(appKey, appSecret, accessToken, refundId string) (map[string]interface{}, error) {
  886. if accessToken == "" {
  887. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  888. }
  889. reqMap := make(map[string]interface{})
  890. reqMap["access_token"] = accessToken
  891. reqMap["needTimeOutInfo"] = true
  892. reqMap["needOrderRefundOperation"] = true
  893. reqMap["refundId"] = refundId
  894. parameters := make([]string, 0)
  895. for key, value := range reqMap {
  896. if value != "" {
  897. parameters = append(parameters, key)
  898. }
  899. }
  900. api1688, err := API1688(API1688OfficialUrl, API1688RefundOpQueryOrderRefundUrlPath, appKey, appSecret, parameters, reqMap)
  901. return api1688, err
  902. }
  903. const (
  904. //
  905. // 精选货源商品查询标获取
  906. API1688AlibabaFenXiaoProductSearchTagListUrlPath = "param2/1/com.alibaba.fenxiao/alibaba.pifatuan.product.search.tag.list/"
  907. // 精选货源商品列表查询
  908. API1688AlibabaFenXiaoProductListUrlPath = "param2/1/com.alibaba.fenxiao/alibaba.pifatuan.product.list/"
  909. NewAPI1688AlibabaFenXiaoProductListUrlPath = "param2/1/com.alibaba.fenxiao/jxhy.product.getPageList/"
  910. // 精选货源商品详情批量查询
  911. API1688AlibabaFenXiaoProductDetailUrlPath = "param2/1/com.alibaba.fenxiao/alibaba.pifatuan.product.detail.list/"
  912. // 精选货源商品详情批量查询(精选货源商品详情批量查询去除没有retailPrice的sku)
  913. API1688AlibabaFenXiaoProductDetail2UrlPath = "param2/2/com.alibaba.fenxiao/alibaba.pifatuan.product.detail.list/"
  914. // 创建采购订单
  915. API1688AlibabaFenXiaoFastCreateOrderUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.fastCreateOrder/"
  916. // 创建订单前预览数据接口
  917. API1688AlibabaFenXiaoFastCreateOrderPreviewUrlPath = "param2/1/com.alibaba.trade/alibaba.createOrder.preview/"
  918. // 取消交易
  919. API1688AlibabaFenXiaoOrderCancelUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.cancel/"
  920. // 修改订单备忘
  921. API1688AlibabaFenXiaoOrderMemoAddUrlPath = "param2/1/com.alibaba.trade:alibaba.order.memoAdd-1/"
  922. // 发起免密支付
  923. API1688AlibabaFenXiaoPreparePayUrlPath = "param2/1/com.alibaba.trade/alibaba.trade.pay.protocolPay.preparePay/"
  924. )
  925. func GetTagFrom1688(appKey, appSecret, accessToken string) (map[string]interface{}, error) {
  926. if accessToken == "" {
  927. accessToken = "6ddddfe6-d0cd-4e58-abbf-a265eb41be0b"
  928. }
  929. reqMap := make(map[string]interface{})
  930. reqMap["access_token"] = accessToken
  931. parameters := make([]string, 0)
  932. for key, value := range reqMap {
  933. if value != "" {
  934. parameters = append(parameters, key)
  935. }
  936. }
  937. api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoProductSearchTagListUrlPath, appKey, appSecret, parameters, reqMap)
  938. return api1688, err
  939. }
  940. type FenXiaoSearchCybOffersReq struct {
  941. AccessToken string `json:"access_token"`
  942. Page string `json:"pageNo"`
  943. PageSize string `json:"pageSize"`
  944. CategoryId string `json:"categoryId"`
  945. RuleId string `json:"ruleId"`
  946. }
  947. type NewFenXiaoSearchCybOffersReq struct {
  948. AccessToken string `json:"access_token"`
  949. Keyword string `json:"keyword"`
  950. Page string `json:"pageNum"`
  951. PageSize string `json:"pageSize"`
  952. PriceStart string `json:"priceStart"`
  953. PriceEnd string `json:"priceEnd"`
  954. CategoryId string `json:"categoryId"`
  955. RuleIds []string `json:"ruleIds"`
  956. }
  957. func GetFenXiaoSearchCybOffersFrom1688(appKey, appSecret string, req *FenXiaoSearchCybOffersReq) (map[string]interface{}, error) {
  958. if req.AccessToken == "" {
  959. req.AccessToken = "6ddddfe6-d0cd-4e58-abbf-a265eb41be0b"
  960. }
  961. reqMap := utils.Struct2Map(req)
  962. parameters := make([]string, 0)
  963. for key, value := range reqMap {
  964. if value != "" {
  965. parameters = append(parameters, key)
  966. }
  967. }
  968. utils.FilePutContents("1688", utils.SerializeStr(reqMap))
  969. api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoProductListUrlPath, appKey, appSecret, parameters, reqMap)
  970. return api1688, err
  971. }
  972. func NewGetFenXiaoSearchCybOffersFrom1688(appKey, appSecret string, req *NewFenXiaoSearchCybOffersReq) (map[string]interface{}, error) {
  973. if req.AccessToken == "" {
  974. req.AccessToken = "6ddddfe6-d0cd-4e58-abbf-a265eb41be0b"
  975. }
  976. reqMap := utils.Struct2Map(req)
  977. parameters := make([]string, 0)
  978. for key, value := range reqMap {
  979. if value != "" {
  980. parameters = append(parameters, key)
  981. }
  982. }
  983. utils.FilePutContents("1688", utils.SerializeStr(reqMap))
  984. api1688, err := API1688(API1688OfficialUrl, NewAPI1688AlibabaFenXiaoProductListUrlPath, appKey, appSecret, parameters, reqMap)
  985. return api1688, err
  986. }
  987. func GetFenXiaoProductInfoFrom1688(appKey, appSecret, accessToken string, offerIds []string) (map[string]interface{}, error) {
  988. if accessToken == "" {
  989. accessToken = "2101cd32-8762-49ed-a87b-94e25ab0c40d"
  990. }
  991. reqMap := make(map[string]interface{})
  992. reqMap["access_token"] = accessToken
  993. reqMap["offerIds"] = offerIds
  994. parameters := make([]string, 0)
  995. for key, value := range reqMap {
  996. if value != "" {
  997. parameters = append(parameters, key)
  998. }
  999. }
  1000. api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoProductDetail2UrlPath, appKey, appSecret, parameters, reqMap)
  1001. return api1688, err
  1002. }
  1003. func FenXiaoPreview4CybMedia(appKey, appSecret string, req *Preview4CybMediaReq) (map[string]interface{}, error) {
  1004. req.Flow = "ttpft"
  1005. reqMap := utils.Struct2Map(req)
  1006. parameters := make([]string, 0)
  1007. for key, value := range reqMap {
  1008. if value != "" {
  1009. parameters = append(parameters, key)
  1010. }
  1011. }
  1012. api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoFastCreateOrderPreviewUrlPath, appKey, appSecret, parameters, reqMap)
  1013. return api1688, err
  1014. }
  1015. type FenXiaoCreateOrder4CybMediaReq struct {
  1016. AddressParam AddressParam `json:"addressParam" label:"收货地址信息,是否必填:是"`
  1017. CargoParamList []*CargoParam `json:"cargoParamList" label:"商品信息,是否必填:是"`
  1018. Flow string `json:"flow" label:"general(创建大市场订单),saleproxy(创建代销市场订单),fenxiao(最新淘货源下单),ttpft(精选货源下单),是否必填:是"`
  1019. AccessToken string `json:"access_token"`
  1020. IsvBizTypeStr string `json:"isvBizTypeStr"`
  1021. //EncryptOutOrderInfo EncryptOutOrderInfo `json:"encryptOutOrderInfo" label:"下游加密订单信息`
  1022. }
  1023. type EncryptOutOrderInfo struct {
  1024. EncryptOrder bool `json:"encryptOrder" label:"是否加密订单"`
  1025. OutPlatformOrderNo string `json:"outPlatformOrderNo" label:"下游平台订单号"`
  1026. 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"`
  1027. OutPlatformAppkey string `json:"outPlatformAppkey" label:"下游平台获取订单的appkey"`
  1028. Oaid string `json:"oaid" label:"淘宝oaid"`
  1029. }
  1030. func FenXiaoCreateOrder4CybMedia(appKey, appSecret string, req *FenXiaoCreateOrder4CybMediaReq) (map[string]interface{}, error) {
  1031. req.Flow = "ttpft"
  1032. req.IsvBizTypeStr = "fenxiaoMedia"
  1033. reqMap := utils.Struct2Map(req)
  1034. parameters := make([]string, 0)
  1035. for key, value := range reqMap {
  1036. if value != "" {
  1037. parameters = append(parameters, key)
  1038. }
  1039. }
  1040. api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoFastCreateOrderUrlPath, appKey, appSecret, parameters, reqMap)
  1041. return api1688, err
  1042. }
  1043. func FenXiaoAliProtocolPay(appKey, appSecret, accessToken, orderId string) (map[string]interface{}, error) {
  1044. api1688, err := API1688(API1688OfficialUrl, API1688AlibabaFenXiaoPreparePayUrlPath, appKey, appSecret, []string{"tradeWithholdPreparePayParam", "access_token"}, map[string]interface{}{
  1045. "tradeWithholdPreparePayParam": map[string]string{
  1046. "orderId": orderId,
  1047. },
  1048. "access_token": accessToken,
  1049. })
  1050. return api1688, err
  1051. }