huangjiajun 1 rok temu
rodzic
commit
ad8c078b11
1 zmienionych plików z 58 dodań i 44 usunięć
  1. +58
    -44
      lianlian/api.go

+ 58
- 44
lianlian/api.go Wyświetl plik

@@ -24,27 +24,28 @@ var sysSecret = "WDgCblk9EOduT30aHVdeVg=="
var Aeckey = "WDgCblk9EOduT30aHVdeVg=="
var tbaseUrl = "https://uapid.lianlianlvyou.com/ll/api/"

//var channelId = "3270"
//var sysSecret = "Qqwsr0tozSaZXh4eRBagcg=="
//var Aeckey = "Qqwsr0tozSaZXh4eRBagcg=="
//var tbaseUrl = "https://uapi.lianlianlvyou.com/ll/api/"
var channelIdProd = "3270"
var sysSecretProd = "Qqwsr0tozSaZXh4eRBagcg=="
var AeckeyProd = "Qqwsr0tozSaZXh4eRBagcg=="
var tbaseUrlProd = "https://uapi.lianlianlvyou.com/ll/api/"

//获取渠道账户信息
func GetBalance() string {
func GetBalance(prod bool) string {
args := map[string]interface{}{
"flag": 1,
}
tmp := zhios_third_party_utils.SerializeStr(args)
send, err := Send("channel/getChannelAccountInfo", tmp)
send, err := Send("channel/getChannelAccountInfo", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//查询站点列表
func GetLocationList(params map[string]string) string {
func GetLocationList(params map[string]string, prod bool) string {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -52,17 +53,17 @@ func GetLocationList(params map[string]string) string {
}
}
tmp := zhios_third_party_utils.SerializeStr(args)
send, err := Send("location/getLocationList", tmp)
send, err := Send("location/getLocationList", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//查询产品分类
func ProductCate(params map[string]string) string {
func ProductCate(params map[string]string, prod bool) string {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -70,17 +71,17 @@ func ProductCate(params map[string]string) string {
}
}
tmp := zhios_third_party_utils.SerializeStr(args)
send, err := Send("product/queryProductCategory", tmp)
send, err := Send("product/queryProductCategory", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//查询产品列表
func ProductList(params map[string]string) string {
func ProductList(params map[string]string, prod bool) string {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -88,17 +89,17 @@ func ProductList(params map[string]string) string {
}
}
tmp := zhios_third_party_utils.SerializeStr(args)
send, err := Send("product/queryProductList", tmp)
send, err := Send("product/queryProductList", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//查询产品信息
func ProductDetail(params map[string]string) string {
func ProductDetail(params map[string]string, prod bool) string {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -106,17 +107,17 @@ func ProductDetail(params map[string]string) string {
}
}
tmp := zhios_third_party_utils.SerializeStr(args)
send, err := Send("product/queryProductByCondition", tmp)
send, err := Send("product/queryProductByCondition", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//查询产品图文详情
func ProductDetailImg(params map[string]string) string {
func ProductDetailImg(params map[string]string, prod bool) string {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -124,17 +125,17 @@ func ProductDetailImg(params map[string]string) string {
}
}
tmp := zhios_third_party_utils.SerializeStr(args)
send, err := Send("product/detail/v2/html", tmp)
send, err := Send("product/detail/v2/html", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//查询产品图文详情
func ProductStatus(params map[string]string) string {
func ProductStatus(params map[string]string, prod bool) string {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -142,17 +143,17 @@ func ProductStatus(params map[string]string) string {
}
}
tmp := zhios_third_party_utils.SerializeStr(args)
send, err := Send("product/queryProductStatus", tmp)
send, err := Send("product/queryProductStatus", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//创建渠道订单
func CreateOrder(params map[string]string) (string, error) {
func CreateOrder(params map[string]string, prod bool) (string, error) {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -161,7 +162,7 @@ func CreateOrder(params map[string]string) (string, error) {
}
tmp := zhios_third_party_utils.SerializeStr(args)
fmt.Println(tmp)
send, err := Send("channelOrder/createOrder", tmp)
send, err := Send("channelOrder/createOrder", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
if err == nil {
@@ -169,10 +170,10 @@ func CreateOrder(params map[string]string) (string, error) {
}
return "", err
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData, nil
}
func CheckCreateOrder(params map[string]string) (string, error) {
func CheckCreateOrder(params map[string]string, prod bool) (string, error) {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -181,7 +182,7 @@ func CheckCreateOrder(params map[string]string) (string, error) {
}
tmp := zhios_third_party_utils.SerializeStr(args)
fmt.Println(tmp)
send, err := Send("channelOrder/checkCreateOrder", tmp)
send, err := Send("channelOrder/checkCreateOrder", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
if err == nil {
@@ -189,12 +190,12 @@ func CheckCreateOrder(params map[string]string) (string, error) {
}
return "", err
}
//encryptedData := CommEncryptedData(send)
//encryptedData := CommEncryptedData(send,prod)
return send, nil
}

//订单详情
func OrderDetail(params map[string]string) string {
func OrderDetail(params map[string]string, prod bool) string {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -203,17 +204,17 @@ func OrderDetail(params map[string]string) string {
}
tmp := zhios_third_party_utils.SerializeStr(args)
fmt.Println(tmp)
send, err := Send("orderDetail/queryOrderDetail", tmp)
send, err := Send("orderDetail/queryOrderDetail", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//物流
func OrderExpress(params map[string]string) string {
func OrderExpress(params map[string]string, prod bool) string {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -222,17 +223,17 @@ func OrderExpress(params map[string]string) string {
}
tmp := zhios_third_party_utils.SerializeStr(args)
fmt.Println(tmp)
send, err := Send("orderDetail/queryOrderExpress", tmp)
send, err := Send("orderDetail/queryOrderExpress", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData
}

//订单退款
func OrderApplyRefund(params map[string]interface{}) (string, error) {
func OrderApplyRefund(params map[string]interface{}, prod bool) (string, error) {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -241,7 +242,7 @@ func OrderApplyRefund(params map[string]interface{}) (string, error) {
}
tmp := zhios_third_party_utils.SerializeStr(args)
fmt.Println(tmp)
send, err := Send("order/applyRefund", tmp)
send, err := Send("order/applyRefund", tmp, prod)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
if err == nil {
@@ -249,20 +250,27 @@ func OrderApplyRefund(params map[string]interface{}) (string, error) {
}
return "", err
}
encryptedData := CommEncryptedData(send)
encryptedData := CommEncryptedData(send, prod)
return encryptedData, nil
}
func CommEncryptedData(send string) string {
func CommEncryptedData(send string, prod bool) string {
Aeckey1, _ := php2go.Base64Decode(Aeckey)
if prod {
Aeckey1, _ = php2go.Base64Decode(AeckeyProd)
}
encrptedStr := gjson.Get(send, "data.encryptedData").String()
encrptedStr, _ = php2go.Base64Decode(encrptedStr)
encryptedData := AesDecryptECB([]byte(encrptedStr), []byte(Aeckey1))
fmt.Println(encryptedData)
return encryptedData
}
func Send(method, params string) (string, error) {
func Send(method, params string, prod bool) (string, error) {
reqUrl := tbaseUrl + method + "?"
Aeckey1, _ := php2go.Base64Decode(Aeckey)
if prod {
reqUrl = tbaseUrlProd + method + "?"
Aeckey1, _ = php2go.Base64Decode(AeckeyProd)
}
encryptedData := AesEncryptECB([]byte(params), []byte(Aeckey1))
nowTime := time.Now().Unix() * 1000
sysParams := map[string]interface{}{
@@ -270,7 +278,10 @@ func Send(method, params string) (string, error) {
"channelId": channelId,
"timestamp": nowTime,
}
sysParams["sign"] = getSign(string(encryptedData), nowTime)
if prod {
sysParams["channelId"] = channelIdProd
}
sysParams["sign"] = getSign(string(encryptedData), nowTime, prod)
post, err := zhios_third_party_utils.CurlPost(reqUrl, zhios_third_party_utils.SerializeStr(sysParams), map[string]string{})
if err != nil {
return "", err
@@ -278,7 +289,10 @@ func Send(method, params string) (string, error) {

return string(post), nil
}
func getSign(encryptedData string, timestamp int64) string {
func getSign(encryptedData string, timestamp int64, prod bool) string {
if prod {
return php2go.Md5(encryptedData + channelIdProd + zhios_third_party_utils.Int64ToStr(timestamp))
}
return php2go.Md5(encryptedData + channelId + zhios_third_party_utils.Int64ToStr(timestamp))
}



Ładowanie…
Anuluj
Zapisz