huangjiajun преди 1 година
родител
ревизия
7238cf8f29
променени са 1 файла, в които са добавени 19 реда и са изтрити 9 реда
  1. +19
    -9
      lianlian/api.go

+ 19
- 9
lianlian/api.go Целия файл

@@ -5,6 +5,7 @@ import (
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"errors"
"fmt"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
@@ -151,7 +152,7 @@ func ProductStatus(params map[string]string) string {
}

//创建渠道订单
func CreateOrder(params map[string]string) string {
func CreateOrder(params map[string]string) (string, error) {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -163,12 +164,15 @@ func CreateOrder(params map[string]string) string {
send, err := Send("channelOrder/createOrder", tmp)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
if err == nil {
err = errors.New(gjson.Get(send, "message").String())
}
return "", err
}
encryptedData := CommEncryptedData(send)
return encryptedData
return encryptedData, nil
}
func CheckCreateOrder(params map[string]string) string {
func CheckCreateOrder(params map[string]string) (string, error) {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -180,10 +184,13 @@ func CheckCreateOrder(params map[string]string) string {
send, err := Send("channelOrder/checkCreateOrder", tmp)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
if err == nil {
err = errors.New(gjson.Get(send, "message").String())
}
return "", err
}
//encryptedData := CommEncryptedData(send)
return send
return send, nil
}

//订单详情
@@ -225,7 +232,7 @@ func OrderExpress(params map[string]string) string {
}

//订单退款
func OrderApplyRefund(params map[string]interface{}) string {
func OrderApplyRefund(params map[string]interface{}) (string, error) {
args := map[string]interface{}{}
for k, v := range params {
if v != "" {
@@ -237,10 +244,13 @@ func OrderApplyRefund(params map[string]interface{}) string {
send, err := Send("order/applyRefund", tmp)
if err != nil || gjson.Get(send, "code").Int() != 200 {
fmt.Println(send)
return ""
if err == nil {
err = errors.New(gjson.Get(send, "message").String())
}
return "", err
}
encryptedData := CommEncryptedData(send)
return encryptedData
return encryptedData, nil
}
func CommEncryptedData(send string) string {
Aeckey1, _ := php2go.Base64Decode(Aeckey)


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