huangjiajun преди 5 месеца
родител
ревизия
73b558547b
променени са 14 файла, в които са добавени 748 реда и са изтрити 0 реда
  1. +8
    -0
      comm/api.go
  2. +119
    -0
      didi/api.go
  3. +22
    -0
      didi/order.go
  4. +31
    -0
      elm/api.go
  5. +78
    -0
      md/wph/goods.go
  6. +71
    -0
      md/wph/order.go
  7. +14
    -0
      md/wph/url.go
  8. +5
    -0
      qianzhu/api.go
  9. +54
    -0
      t3/api.go
  10. +20
    -0
      t3/order.go
  11. +79
    -0
      wph/api.go
  12. +103
    -0
      wph/goods.go
  13. +73
    -0
      wph/order.go
  14. +71
    -0
      wph/url.go

+ 8
- 0
comm/api.go Целия файл

@@ -2,6 +2,9 @@ package comm

import (
"bytes"
"crypto/hmac"
"crypto/md5"
"encoding/hex"
"encoding/json"
"sort"
"strings"
@@ -59,3 +62,8 @@ func GetSortJson(o interface{}) string {
marshal := strings.TrimSpace(buffer.String()) // Trim掉末尾的换行符
return marshal
}
func HmacMd5(key, data string) string {
h := hmac.New(md5.New, []byte(key))
h.Write([]byte(data))
return strings.ToUpper(hex.EncodeToString(h.Sum([]byte(""))))
}

+ 119
- 0
didi/api.go Целия файл

@@ -0,0 +1,119 @@
package didi

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"crypto/sha1"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"github.com/tidwall/gjson"
"io"
"net/url"
"sort"
"strings"
"time"
)

func GetDidiUrl(key, secret string, param map[string]interface{}) map[string]string {
send, _ := PostSend("/openapi/v1.0/link/generate", key, secret, param)
res := map[string]string{
"app_id": gjson.Get(send, "data.app_id").String(),
"app_source": gjson.Get(send, "data.app_source").String(),
"dsi": gjson.Get(send, "data.dsi").String(),
"link": gjson.Get(send, "data.link").String(),
}
return res
}
func GetDidiQrcode(key, secret string, param map[string]interface{}) map[string]string {
send, _ := GetSend("/openapi/v1.0/code/generate", key, secret, param)
res := map[string]string{
"code_link": gjson.Get(send, "data.code_link").String(),
}
return res
}
func GetDidiPoster(key, secret string, param map[string]interface{}) map[string]string {
send, _ := GetSend("/openapi/v1.0/poster/generate", key, secret, param)
res := map[string]string{
"poster_link": gjson.Get(send, "data.poster_link").String(),
}
return res
}
func GetDidiOrder(key, secret string, param map[string]interface{}) []DidiOrder {
send, _ := GetSend("/openapi/v1.0/order/list", key, secret, param)
list := make([]DidiOrder, 0)
json.Unmarshal([]byte(gjson.Get(send, "data.order_list").String()), &list)
return list
}

func GetSend(method, key, secret string, param map[string]interface{}) (string, error) {
param["Timestamp"] = zhios_third_party_utils.Int64ToStr(time.Now().Unix())
param["App-Key"] = key
param["Sign"] = GetSign(param, secret)
headers := map[string]string{
"Timestamp": zhios_third_party_utils.AnyToString(param["Timestamp"]),
"App-Key": zhios_third_party_utils.AnyToString(param["App-Key"]),
"Sign": zhios_third_party_utils.AnyToString(param["Sign"]),
}
urls := "https://union.didi.cn" + method

for k, v := range param {
if strings.Contains(urls, "?") == false {
urls += "?" + k + "=" + zhios_third_party_utils.AnyToString(v)
} else {
urls += "&" + k + "=" + zhios_third_party_utils.AnyToString(v)
}
}
fmt.Println(urls)
post, err := zhios_third_party_utils.CurlGet(urls, headers)
fmt.Println(string(post))
fmt.Println(err)
return string(post), err
}
func PostSend(method, key, secret string, param map[string]interface{}) (string, error) {
paramStr := comm.GetSortJson(param)
param["Timestamp"] = time.Now().Unix()
param["App-Key"] = key
param["Sign"] = GetSign(param, secret)
headers := map[string]string{
"Timestamp": zhios_third_party_utils.Int64ToStr(zhios_third_party_utils.AnyToInt64(param["Timestamp"])),
"App-Key": zhios_third_party_utils.AnyToString(param["App-Key"]),
"Sign": zhios_third_party_utils.AnyToString(param["Sign"]),
}
urls := "https://union.didi.cn" + method
post, err := zhios_third_party_utils.CurlPost(urls, paramStr, headers)
fmt.Println(string(post))
fmt.Println(err)
return string(post), err
}

func GetSign(params map[string]interface{}, accessKey string) string {
// key排序
arr := sort.StringSlice{}
for k := range params {
if k != "sign" {
arr = append(arr, k)
}
}
arr.Sort()
// 参数拼接
var build strings.Builder
for idx, k := range arr {
if idx != 0 {
build.WriteString("&")
}
build.WriteString(fmt.Sprintf("%s=%v", k, params[k]))
}
build.WriteString(accessKey)
// URL encode
sourceStr := url.QueryEscape(build.String())
// sha1加密
h := sha1.New()
_, _ = io.WriteString(h, sourceStr)
shaStr := hex.EncodeToString(h.Sum([]byte("")))
// 返回base64字符串
b64Str := base64.StdEncoding.EncodeToString([]byte(shaStr))
// base64字符串含有=和/,再一次URL encode
return url.QueryEscape(b64Str)
}

+ 22
- 0
didi/order.go Целия файл

@@ -0,0 +1,22 @@
package didi

type DidiOrder struct {
ActivityId int64 `json:"activity_id"`
CpaProfit int `json:"cpa_profit"`
CpaType string `json:"cpa_type"`
CpsProfit int `json:"cps_profit"`
FailReason string `json:"fail_reason"`
IsRisk int `json:"is_risk"`
OpenUid string `json:"open_uid"`
OrderId string `json:"order_id"`
OrderStatus int `json:"order_status"`
PayPrice int `json:"pay_price"`
PayTime int `json:"pay_time"`
ProductId int `json:"product_id"`
PromotionId int64 `json:"promotion_id"`
RefundPrice int `json:"refund_price"`
RefundTime int `json:"refund_time"`
SourceId string `json:"source_id"`
Status int `json:"status"`
Title string `json:"title"`
}

+ 31
- 0
elm/api.go Целия файл

@@ -0,0 +1,31 @@
package elm

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao/topsdk"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao/topsdk/defaultability"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao/topsdk/defaultability/request"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao/topsdk/defaultability/response"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
)

const (
ELM_URL = "http://gw.api.taobao.com/router/rest"
)

func ElemePromotionOrder(ak, sk string, args map[string]string) (*response.AlibabaAlscUnionKbcpxPositiveOrderGetResponse, error) {
client := topsdk.NewDefaultTopClient(ak, sk, ELM_URL, 20000, 20000)
ability := defaultability.NewDefaultability(&client)

AlibabaAlscUnionKbcpxPositiveOrderGetRequest := request.AlibabaAlscUnionKbcpxPositiveOrderGetRequest{}
AlibabaAlscUnionKbcpxPositiveOrderGetRequest.SetBizUnit(2)
AlibabaAlscUnionKbcpxPositiveOrderGetRequest.SetDateType(4) //时间维度,1-付款时间 2-创建时间 3-结算时间 4-更新时间
AlibabaAlscUnionKbcpxPositiveOrderGetRequest.SetEndDate(args["end_time"])
AlibabaAlscUnionKbcpxPositiveOrderGetRequest.SetPageNumber(zhios_third_party_utils.StrToInt64(args["p"]))
AlibabaAlscUnionKbcpxPositiveOrderGetRequest.SetPageSize(zhios_third_party_utils.StrToInt64(args["size"]))
AlibabaAlscUnionKbcpxPositiveOrderGetRequest.SetStartDate(args["start_time"])
resp, err := ability.AlibabaAlscUnionKbcpxPositiveOrderGet(&AlibabaAlscUnionKbcpxPositiveOrderGetRequest)
if err != nil {
return nil, err
}
return resp, nil
}

+ 78
- 0
md/wph/goods.go Целия файл

@@ -0,0 +1,78 @@
package wph

type WphGoods struct {
Gid string `json:"gid"`
AdCode string `json:"adCode"`
GoodsTitle string `json:"goods_title"`
GoodsDesc string `json:"goods_desc"`
GoodsImg string `json:"goods_img"`
ImgList []string `json:"img_list"`
SourceType string `json:"sourceType"`
GoodsPrice string `json:"goods_price"`
GoodsCostPrice string `json:"goods_cost_price"`
Commission string `json:"commission"`
CommissionRate string `json:"commission_rate"`
Discount string `json:"discount"`
YhqPrice string `json:"yhq_price"`
CouponPrice string `json:"coupon_price"`
}
type OfficialGoods struct {
IsAllowanceGoods int `json:"isAllowanceGoods"`
MarketPrice string `json:"marketPrice"`
CommissionRate string `json:"commissionRate"`
WhiteImage string `json:"whiteImage"`
GoodsId string `json:"goodsId"`
GoodsDesc string `json:"goodsDesc"`
Discount string `json:"discount"`
CouponPriceType int `json:"couponPriceType"`
GoodsCarouselPictures []string `json:"goodsCarouselPictures"`
GoodsDetailPictures []string `json:"goodsDetailPictures"`
CategoryName string `json:"categoryName"`
HaiTao int `json:"haiTao"`
Cat2NdName string `json:"cat2ndName"`
IsSubsidyActivityGoods bool `json:"isSubsidyActivityGoods"`
GoodsPromotionInfo struct {
MarketPrice string `json:"marketPrice"`
LowPriceTag string `json:"lowPriceTag"`
SalePriceDesc string `json:"salePriceDesc"`
SalePrice string `json:"salePrice"`
Discount string `json:"discount"`
} `json:"goodsPromotionInfo"`
Cat1StName string `json:"cat1stName"`
DestUrlPc string `json:"destUrlPc"`
AdCode string `json:"adCode"`
VipPrice string `json:"vipPrice"`
Commission string `json:"commission"`
ProductSales string `json:"productSales"`
Sn string `json:"sn"`
Cat1StId int `json:"cat1stId"`
GoodsName string `json:"goodsName"`
BrandName string `json:"brandName"`
BrandLogoFull string `json:"brandLogoFull"`
BrandStoreSn string `json:"brandStoreSn"`
Weight int `json:"weight"`
SellTimeFrom int64 `json:"sellTimeFrom"`
SchemeStartTime int64 `json:"schemeStartTime"`
SchemeEndTime int64 `json:"schemeEndTime"`
SourceType int `json:"sourceType"`
SellTimeTo int64 `json:"sellTimeTo"`
BrandId int `json:"brandId"`
GoodsThumbUrl string `json:"goodsThumbUrl"`
Cat2NdId int `json:"cat2ndId"`
SpuId string `json:"spuId"`
StoreInfo struct {
StoreName string `json:"storeName"`
StoreId string `json:"storeId"`
} `json:"storeInfo"`
EstimatePrice string `json:"estimatePrice"`
GoodsMainPicture string `json:"goodsMainPicture"`
DestUrl string `json:"destUrl"`
CategoryId int `json:"categoryId"`
Status int `json:"status"`
CouponInfo struct {
Fav string `json:"fav"`
} `json:"couponInfo"`
ExclusiveCoupon struct {
Fav string `json:"fav"`
} `json:"exclusiveCoupon"`
}

+ 71
- 0
md/wph/order.go Целия файл

@@ -0,0 +1,71 @@
package wph

type GetOrder struct {
OrderType int `json:"orderType"`
OrderSn string `json:"orderSn"`
OpenId string `json:"openId"`
FdsBlackOrder int `json:"fdsBlackOrder"`
EstimateCommissionAfterDeduction string `json:"estimateCommissionAfterDeduction"`
Pid string `json:"pid"`
OrderTrackReason int `json:"orderTrackReason"`
OrderSubStatusName string `json:"orderSubStatusName"`
OrderQuality string `json:"orderQuality"`
StatParam string `json:"statParam"`
OrderTime int64 `json:"orderTime"`
NewCustomer int `json:"newCustomer"`
AdCode string `json:"adCode"`
Commission string `json:"commission"`
AppKey string `json:"appKey"`
IsSplit int `json:"isSplit"`
OrderSource string `json:"orderSource"`
SignTime int64 `json:"signTime"`
Settled int `json:"settled"`
CommissionEnterTime int64 `json:"commissionEnterTime"`
DeductionCommission string `json:"DeductionCommission"`
IsPrepay int `json:"isPrepay"`
BaseCommissionSettleRate string `json:"baseCommissionSettleRate"`
DetailList []struct {
SizeId string `json:"sizeId"`
CommissionRate string `json:"commissionRate"`
GoodsId string `json:"goodsId"`
GoodsFinalPrice string `json:"goodsFinalPrice"`
BrandStoreName string `json:"brandStoreName"`
EstimateCommissionAfterDeduction string `json:"estimateCommissionAfterDeduction"`
Cat2Code string `json:"cat2Code"`
CommCode string `json:"commCode"`
IsSubsidyTaskOrder bool `json:"isSubsidyTaskOrder"`
Commission string `json:"commission"`
Cat3Code string `json:"cat3Code"`
Cat1Name string `json:"cat1Name"`
GoodsName string `json:"goodsName"`
CommissionTotalCost string `json:"commissionTotalCost"`
OrderSource string `json:"orderSource"`
BrandStoreSn string `json:"brandStoreSn"`
DeductionCommission string `json:"DeductionCommission"`
Cat2Name string `json:"cat2Name"`
BaseCommissionSettleRate string `json:"baseCommissionSettleRate"`
GoodsCount int `json:"goodsCount"`
GoodsThumb string `json:"goodsThumb"`
CommName string `json:"commName"`
SpuId string `json:"spuId"`
Cat1Code string `json:"cat1Code"`
Cat3Name string `json:"cat3Name"`
Status int `json:"status"`
AfterSaleInfo []struct {
AfterSaleStatus int `json:"afterSaleStatus"`
AfterSaleSn string `json:"afterSaleSn"`
AfterSaleFinishTime int64 `json:"afterSaleFinishTime"`
AfterSaleType int `json:"afterSaleType"`
} `json:"afterSaleInfo,omitempty"`
} `json:"detailList"`
SettledTime int64 `json:"settledTime"`
ChannelTag string `json:"channelTag"`
SelfBuy int `json:"selfBuy"`
TotalCost string `json:"totalCost"`
Status int `json:"status"`
LastUpdateTime int64 `json:"lastUpdateTime"`
}
type GetRefundOrder struct {
OrderSn string `json:"orderSn"`
AfterSaleStatus int `json:"afterSaleStatus"`
}

+ 14
- 0
md/wph/url.go Целия файл

@@ -0,0 +1,14 @@
package wph

type UrlInfoList struct {
Url string `json:"url"`
DeeplinkUrl string `json:"deeplinkUrl"`
VipWxUrl string `json:"vipWxUrl"`
}
type ParesUrlData struct {
GoodsId string `json:"goodsId"`
LandUrl string `json:"landUrl"`
BrandId string `json:"brandId"`
AdCode string `json:"adCode"`
LinkType string `json:"linkType"`
}

+ 5
- 0
qianzhu/api.go Целия файл

@@ -0,0 +1,5 @@
package qianzhu

func GetKfcUrl(key, secret string, param map[string]string) {

}

+ 54
- 0
t3/api.go Целия файл

@@ -0,0 +1,54 @@
package t3

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"fmt"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"time"
)

func GetT3Url(key, secret string, param map[string]string) map[string]string {
jsonStr := comm.GetSortJson(param)
send, _ := GetSend("/openapi/marketing/union/v1/generate/link", key, secret, param["sourceId"], jsonStr)
res := map[string]string{
"link": gjson.Get(send, "data.link").String(),
"appId": gjson.Get(send, "data.appId").String(),
"appSource": gjson.Get(send, "data.appSource").String(),
}
return res
}
func GetT3Order(key, secret string, param map[string]string) []T3Order {
jsonStr := comm.GetSortJson(param)
send, _ := GetSend("/openapi/api/v1/marketing/union/activity/order/page", key, secret, param["sourceId"], jsonStr)
list := make([]T3Order, 0)
json.Unmarshal([]byte(gjson.Get(send, "data.data").String()), &list)
return list
}
func GetSend(method, key, secret, sourceId, jsonStr string) (string, error) {
url := "https://exchange.t3go.cn" + method
now := zhios_third_party_utils.Int64ToStr(time.Now().Unix() * 1000)
tmp := map[string]string{
"x-t3-nonce": php2go.Md5(sourceId + now),
"x-t3-timestamp": now,
"x-t3-version": "V1",
"x-t3-key": key,
"x-t3-signature-method": "MD5",
}
signStr := "POST" + method
headers := make(map[string]string)
keyList := []string{"x-t3-key", "x-t3-nonce", "x-t3-signature-method", "x-t3-timestamp", "x-t3-version"}
for _, v := range keyList {
headers[v] = tmp[v]
signStr += v + ":" + tmp[v]
}
signStr += php2go.Md5(jsonStr) + secret
headers["x-t3-signature-headers"] = "x-t3-nonce,x-t3-timestamp,x-t3-version,x-t3-key,x-t3-signature-method"
headers["x-t3-signature"] = php2go.Md5(signStr)
post, err := zhios_third_party_utils.CurlPost(url, jsonStr, headers)
fmt.Println(string(post))
fmt.Println(err)
return string(post), err
}

+ 20
- 0
t3/order.go Целия файл

@@ -0,0 +1,20 @@
package t3

type T3Order struct {
SourceId string `json:"sourceId"`
Amount int `json:"amount"`
BusinessId string `json:"businessId"`
CpaType string `json:"cpaType"`
SpotUuid string `json:"spotUuid"`
Uuid string `json:"uuid"`
OrderAmount float64 `json:"orderAmount"`
PayAmount float64 `json:"payAmount"`
CreateTime int64 `json:"createTime"`
Rate int `json:"rate"`
ParticipationStatus int `json:"participationStatus"`
FailReason string `json:"failReason"`
ActivityUuid string `json:"activityUuid"`
AttributionalFirstOrder bool `json:"attributionalFirstOrder"`
UnionActivityUuid string `json:"unionActivityUuid"`
RefundAmount int `json:"refundAmount"`
}

+ 79
- 0
wph/api.go Целия файл

@@ -0,0 +1,79 @@
package wph

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt"
"github.com/syyongx/php2go"
"strings"
"time"
)

//func SendGet(serviceMethod, method string, serviceParam map[string]string, param string) (string, error) {
// serviceParamNew := map[string]string{
// "service": serviceMethod, //服务名称
// "method": method, //方法名称
// "version": "1.0.0", //版本号
// "timestamp": zhios_third_party_utils.Int64ToStr(time.Now().Unix()),
// "format": "json",
// "appKey": serviceParam["key"],
// }
// if serviceParam["token"] != "" {
// serviceParamNew["accessToken"] = serviceParam["token"]
// }
// sortParam := comm.KsortToStr(serviceParamNew)
// str := ""
// for _, v := range sortParam {
// str += v + serviceParamNew[v]
// }
// str += param
// serviceParamNew["sign"] = strings.ToUpper(comm.HmacMd5(serviceParam["secret"], str))
// url := "https://vop.vipapis.com"
// for k, v := range serviceParamNew {
// if strings.Contains(url, "?") == false {
// url += "?" + k + "=" + php2go.URLEncode(v)
// }
// }
// get, err := zhios_third_party_utils.CurlGet(url, nil)
// fmt.Println(string(get))
// fmt.Println(err)
// return string(get), err
//}
func SendPost(serviceMethod, method string, serviceParam map[string]string, param string) (string, error) {
serviceParamNew := map[string]string{
"service": serviceMethod, //服务名称
"method": method, //方法名称
"version": "1.0.0", //版本号
"timestamp": zhios_third_party_utils.Int64ToStr(time.Now().Unix()),
"format": "json",
"appKey": serviceParam["key"],
}
if serviceParam["token"] != "" {
serviceParamNew["accessToken"] = serviceParam["token"]
}
sortParam := comm.KsortToStr(serviceParamNew)
str := ""
for _, v := range sortParam {
str += v + serviceParamNew[v]
}
str += param
fmt.Println(str)
serviceParamNew["sign"] = strings.ToUpper(comm.HmacMd5(serviceParam["secret"], str))
fmt.Println(serviceParamNew["sign"])

url := "https://vop.vipapis.com"
for k, v := range serviceParamNew {
if strings.Contains(url, "?") == false {
url += "?" + k + "=" + php2go.URLEncode(v)
} else {
url += "&" + k + "=" + php2go.URLEncode(v)
}
}
fmt.Println(url)
// 读取响应体
responseData, err := zhios_third_party_utils.CurlPost(url, param, nil)

fmt.Println(string(responseData))
fmt.Println(err)
return string(responseData), err
}

+ 103
- 0
wph/goods.go Целия файл

@@ -0,0 +1,103 @@
package wph

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/wph"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"github.com/tidwall/gjson"
)

//关键字查询
func QueryWithOauth(serviceParam map[string]string, param string) []wph.WphGoods {
post, _ := SendPost("com.vip.adp.api.open.service.UnionGoodsService", "queryWithOauth", serviceParam, param)
var goods = make([]wph.OfficialGoods, 0)
json.Unmarshal([]byte(gjson.Get(post, "result.goodsInfoList").String()), &goods)
list := make([]wph.WphGoods, 0)
for _, v := range goods {
tmp := wph.WphGoods{
Gid: v.GoodsId + "adCode" + v.AdCode,
AdCode: v.AdCode,
GoodsTitle: v.GoodsName,
GoodsDesc: v.GoodsDesc,
GoodsImg: v.GoodsMainPicture,
ImgList: v.GoodsCarouselPictures,
SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
GoodsPrice: v.VipPrice,
GoodsCostPrice: v.MarketPrice,
Commission: v.Commission,
CommissionRate: v.CommissionRate,
Discount: v.Discount,
YhqPrice: v.CouponInfo.Fav,
CouponPrice: v.CouponInfo.Fav,
}
if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
tmp.YhqPrice = v.ExclusiveCoupon.Fav
tmp.CouponPrice = v.ExclusiveCoupon.Fav
}
list = append(list, tmp)
}
return list
}

//联盟在推商品列表
func GoodsListWithOauth(serviceParam map[string]string, param string) []wph.WphGoods {
post, _ := SendPost("com.vip.adp.api.open.service.UnionGoodsService", "goodsListWithOauth", serviceParam, param)
var goods = make([]wph.OfficialGoods, 0)
json.Unmarshal([]byte(gjson.Get(post, "result.goodsInfoList").String()), &goods)
list := make([]wph.WphGoods, 0)
for _, v := range goods {
tmp := wph.WphGoods{
Gid: v.GoodsId + "adCode" + v.AdCode,
AdCode: v.AdCode,
GoodsTitle: v.GoodsName,
GoodsDesc: v.GoodsDesc,
GoodsImg: v.GoodsMainPicture,
ImgList: v.GoodsCarouselPictures,
SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
GoodsPrice: v.VipPrice,
GoodsCostPrice: v.MarketPrice,
Commission: v.Commission,
CommissionRate: v.CommissionRate,
Discount: v.Discount,
YhqPrice: v.CouponInfo.Fav,
CouponPrice: v.CouponInfo.Fav,
}
if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
tmp.YhqPrice = v.ExclusiveCoupon.Fav
tmp.CouponPrice = v.ExclusiveCoupon.Fav
}
list = append(list, tmp)
}
return list
}

func GetByGoodsIdsWithOauth(serviceParam map[string]string, param string) []wph.WphGoods {
post, _ := SendPost("com.vip.adp.api.open.service.UnionGoodsService", "getByGoodsIdsWithOauth", serviceParam, param)
var goods = make([]wph.OfficialGoods, 0)
json.Unmarshal([]byte(gjson.Get(post, "result").String()), &goods)
list := make([]wph.WphGoods, 0)
for _, v := range goods {
tmp := wph.WphGoods{
Gid: v.GoodsId + "adCode" + v.AdCode,
AdCode: v.AdCode,
GoodsTitle: v.GoodsName,
GoodsDesc: v.GoodsDesc,
GoodsImg: v.GoodsMainPicture,
ImgList: v.GoodsCarouselPictures,
SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
GoodsPrice: v.VipPrice,
GoodsCostPrice: v.MarketPrice,
Commission: v.Commission,
CommissionRate: v.CommissionRate,
Discount: v.Discount,
YhqPrice: v.CouponInfo.Fav,
CouponPrice: v.CouponInfo.Fav,
}
if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
tmp.YhqPrice = v.ExclusiveCoupon.Fav
tmp.CouponPrice = v.ExclusiveCoupon.Fav
}
list = append(list, tmp)
}
return list
}

+ 73
- 0
wph/order.go Целия файл

@@ -0,0 +1,73 @@
package wph

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/wph"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"fmt"
"github.com/tidwall/gjson"
)

func GetOrder(serviceParam map[string]string, param string) []map[string]string {
post, _ := SendPost("com.vip.adp.api.open.service.UnionOrderService", "orderListWithOauth", serviceParam, param)
var data []wph.GetOrder
msg := gjson.Get(post, "result.orderInfoList").String()
json.Unmarshal([]byte(msg), &data)
var list = make([]map[string]string, 0)
stateArr := map[string]string{
"已下单": "待定", "已付款": "订单付款", "已签收": "订单成功", "待结算": "订单成功", "已结算": "已完结", "已失效": "不合格",
}
for _, v := range data {
gid := ""
if len(v.DetailList) > 0 {
gid = v.DetailList[0].GoodsId
}
tmp := map[string]string{
"oid": v.OrderSn,
"gid": gid,
"commission": "0",
"payment": "0",
"status": stateArr[v.OrderSubStatusName],
"channelTag": v.ChannelTag,
"create_time": zhios_third_party_utils.Int64ToStr(v.OrderTime / 1000),
"newCustomer": zhios_third_party_utils.IntToStr(v.NewCustomer),
"js_time": "",
}
if v.Status == 2 {
tmp["status"] = "已完结"
}
if v.SettledTime > 0 {
tmp["js_time"] = zhios_third_party_utils.Int64ToStr(v.SettledTime / 1000)
}
var commission float64 = 0
var payment float64 = 0
for _, v1 := range v.DetailList {
commission += zhios_third_party_utils.StrToFloat64(v1.Commission)
payment += zhios_third_party_utils.StrToFloat64(v1.CommissionTotalCost)
}
tmp["payment"] = zhios_third_party_utils.Float64ToStr(payment)
tmp["commission"] = zhios_third_party_utils.Float64ToStr(commission)
list = append(list, tmp)
}
fmt.Println(zhios_third_party_utils.SerializeStr(list))
return list
}
func GetRefundOrder(serviceParam map[string]string, param string) []map[string]string {
post, _ := SendPost("com.vip.adp.api.open.service.UnionOrderService", "refundOrderListWithOauth", serviceParam, param)
var data []wph.GetRefundOrder
msg := gjson.Get(post, "result.refundOrderInfoList").String()
json.Unmarshal([]byte(msg), &data)
var list = make([]map[string]string, 0)
for _, v := range data {

tmp := map[string]string{
"oid": v.OrderSn,
"status": "",
}
if v.AfterSaleStatus == 2 {
tmp["status"] = "不合格"
}
list = append(list, tmp)
}
return list
}

+ 71
- 0
wph/url.go Целия файл

@@ -0,0 +1,71 @@
package wph

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/wph"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json"
"fmt"
"github.com/tidwall/gjson"
"strings"
)

func GetUrl(serviceParam map[string]string, param string) wph.UrlInfoList {
post, err := SendPost("com.vip.adp.api.open.service.UnionUrlService", "genByGoodsIdWithOauth", serviceParam, param)
fmt.Println(post)
fmt.Println(err)
UrlInfoList := gjson.Get(post, "result.urlInfoList").String()
list := make([]wph.UrlInfoList, 0)
json.Unmarshal([]byte(UrlInfoList), &list)
data := wph.UrlInfoList{}
for _, v := range list {
if strings.Contains(v.Url, "t.vip.com") {
v.Url = strings.ReplaceAll(v.Url, "t.vip.com", "click.union.vip.com")
}
data = wph.UrlInfoList{
Url: v.Url,
DeeplinkUrl: v.DeeplinkUrl,
VipWxUrl: v.VipWxUrl,
}
}
fmt.Println(zhios_third_party_utils.SerializeStr(data))
return data
}
func GetActUrl(serviceParam map[string]string, param string) wph.UrlInfoList {
post, err := SendPost("com.vip.adp.api.open.service.UnionUrlService", "genByVIPUrlWithOauth", serviceParam, param)
fmt.Println(post)
fmt.Println(err)
UrlInfoList := gjson.Get(post, "result.urlInfoList").String()
list := make([]wph.UrlInfoList, 0)
json.Unmarshal([]byte(UrlInfoList), &list)
data := wph.UrlInfoList{}
for _, v := range list {
if strings.Contains(v.Url, "t.vip.com") {
v.Url = strings.ReplaceAll(v.Url, "t.vip.com", "click.union.vip.com")
}
data = wph.UrlInfoList{
Url: v.Url,
DeeplinkUrl: v.DeeplinkUrl,
VipWxUrl: v.VipWxUrl,
}
}
return data
}
func GetParseUrl(serviceParam map[string]string, param string) map[string]interface{} {
post, err := SendPost("com.vip.adp.api.open.service.UnionUrlService", "vipLinkCheckWithOuth", serviceParam, param)
fmt.Println(post)
fmt.Println(err)
successMap := gjson.Get(post, "result.successMap").String()
var list = make(map[string]interface{})
json.Unmarshal([]byte(successMap), &list)
url := gjson.Get(param, "vipLinkCheckReq.content").String()
_, ok := list[url]
data := map[string]interface{}{}
if ok {
urlData, ok1 := list[url].(map[string]interface{})
if ok1 {
data = urlData
}
}
fmt.Println(zhios_third_party_utils.SerializeStr(data))
return data
}

Зареждане…
Отказ
Запис