This commit is contained in:
苏尹岚
2020-06-27 11:51:02 +08:00
parent 4af8248432
commit 55a381d214
5 changed files with 21 additions and 7 deletions

View File

@@ -29,7 +29,7 @@ func init() {
// dadaapi = New("dada9623324449cd250", "30c2abbfe8a8780ad5aace46300c64b9", "73753", "http://callback.jxc4.com/dada/order", false)
// prod
dadaapi = New("dada147f7a190ce7b3c", "2c717ad914767d6e2beb3f743db9e477", "6660", "http://callback.jxc4.com/dada/order", true)
dadaapi = New("dada154e2a41fd6cef3", "7f97d8f258b70b450f04e7ab274ed8f8", "6660", "http://callback.jxc4.com/dadadelivery/msg", true)
// prod
testOrder = &OperateOrderParams{

View File

@@ -40,7 +40,7 @@ func TestAddOrderAfterQuery(t *testing.T) {
}
func TestCancel(t *testing.T) {
cancelResponse, err := dadaapi.CancelOrder("124651497574002", ReasonIDOther, "test")
cancelResponse, err := dadaapi.CancelOrder("88330338129212", ReasonIDOther, "接单时间过长")
if err != nil {
t.Fatal(err)
}

View File

@@ -2,12 +2,14 @@ package jdshopapi
import (
"crypto/aes"
"crypto/md5"
"encoding/base64"
"fmt"
"io/ioutil"
"math"
"net/http"
"strings"
"testing"
"time"
"git.rosy.net.cn/baseapi/utils"
)
@@ -103,8 +105,19 @@ func TestTryGetCookie(t *testing.T) {
}
func TestAAADS(t *testing.T) {
str := "16:00-17:00"
fmt.Println(str[strings.LastIndex(str, "-")+1:])
const prefix = 80
const randPartNum = 100
orderNoBeginTimestamp := utils.Str2Time("2010-01-01 00:00:00").Unix()
orderNo := time.Now().Unix() - orderNoBeginTimestamp
orderNo = orderNo * randPartNum
md5Bytes := md5.Sum([]byte(utils.GetUUID()))
randPart := 0
for k, v := range md5Bytes {
randPart += int(v) << ((k % 3) * 8)
}
orderNo += int64(randPart % randPartNum)
orderNo += int64(math.Pow10(int(math.Log10(float64(orderNo)))+1)) * prefix
fmt.Println(orderNo)
}
func DecryptDESECB(d, key []byte) string {

View File

@@ -1,7 +1,6 @@
package mtpsapi
import (
"fmt"
"net/http"
"strings"
@@ -65,7 +64,6 @@ func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *
err := request.ParseForm()
if err == nil {
sign := a.signParams(request.PostForm)
fmt.Println("testCheckCallbackValidation", utils.Format4Output(request, false))
if sign != request.FormValue(signKey) {
baseapi.SugarLogger.Infof("Signature is not ok, mine:%v, get:%v", sign, request.FormValue(signKey))
return SignatureIsNotOk

View File

@@ -307,6 +307,9 @@ func Time2DateStr(t time.Time) string {
}
func Str2Time(timeStr string) time.Time {
if timeStr == "" {
return ZeroTimeValue
}
retVal, err := TryStr2Time(timeStr)
if err != nil {
baseapi.SugarLogger.Errorf("time.ParseInLocation failed, timeStr:%v, error:%v", timeStr, err)