1
This commit is contained in:
@@ -3,10 +3,12 @@ package baidunavi
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -16,11 +18,14 @@ const (
|
||||
signKey = "sn"
|
||||
resultKey = "result"
|
||||
prodURL = "http://api.map.baidu.com"
|
||||
prodURL2 = "https://api.map.baidu.com"
|
||||
)
|
||||
|
||||
const (
|
||||
StatusCodeSuccess = 0
|
||||
StatusCodeInternalErr = 1 // 服务器内部错误
|
||||
StatusCodeParamsErr = 2 //参数无效
|
||||
StatusCodeNoReturn = 7 //无返回结果
|
||||
StatusCodeExceedDailyQuota = 301 // 永久配额超限,限制访问
|
||||
StatusCodeExceedQuota = 302 // 天配额超限,限制访问
|
||||
StatusCodeExceedDailyConcurrentQuota = 401 // 当前并发量已经超过约定并发配额,限制访问
|
||||
@@ -55,6 +60,46 @@ type Coordinate struct {
|
||||
Lat float64 `json:"y"`
|
||||
}
|
||||
|
||||
type Coordinate2 struct {
|
||||
Lng string `json:"lng"`
|
||||
Lat string `json:"lat"`
|
||||
}
|
||||
|
||||
type RidingResp struct {
|
||||
Status int `json:"status"` //状态码
|
||||
Message string `json:"message"` // 状态码对应的信息
|
||||
Result struct {
|
||||
Origin struct { //起点
|
||||
Lng float64 `json:"lng"`
|
||||
Lat float64 `json:"lat"`
|
||||
}
|
||||
Destination struct { //终点
|
||||
Lng float64 `json:"lng"`
|
||||
Lat float64 `json:"lat"`
|
||||
}
|
||||
Routers struct {
|
||||
Distance float64 `json:"distance"` //方案距离,单位:米
|
||||
Duration int `json:"duration"` //线路耗时,单位:秒
|
||||
Steps []struct {
|
||||
}
|
||||
Name string `json:"name"` //道路名称
|
||||
Instruction string `json:"instruction"` //路段描述
|
||||
StartLocation struct {
|
||||
Lng float64 `json:"lng"`
|
||||
Lat float64 `json:"lat"`
|
||||
}
|
||||
EndLocation struct {
|
||||
Lng float64 `json:"lng"`
|
||||
Lat float64 `json:"lat"`
|
||||
}
|
||||
Path []struct {
|
||||
Lng float64 `json:"lng"`
|
||||
Lat float64 `json:"lat"`
|
||||
}
|
||||
}
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
type API struct {
|
||||
client *http.Client
|
||||
config *platformapi.APIConfig
|
||||
@@ -121,7 +166,8 @@ func (a *API) AccessAPI(apiStr string, params map[string]interface{}) (retVal in
|
||||
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
request, _ := http.NewRequest(http.MethodGet, genGetURL(prodURL, apiStr, params2), nil)
|
||||
//request, _ := http.NewRequest(http.MethodGet, genGetURL(prodURL, apiStr, params2), nil)
|
||||
request, _ := http.NewRequest(http.MethodGet, genGetURL(prodURL2, apiStr, params2), nil)
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
@@ -165,3 +211,55 @@ func (a *API) BatchCoordinateConvert(coords []*Coordinate, fromCoordSys, toCoord
|
||||
}
|
||||
return outCoords, err
|
||||
}
|
||||
|
||||
// DirectionLiteRide 骑行路线规划
|
||||
func (a *API) DirectionLiteRide(coords []*Coordinate) (retVal interface{}, err error) {
|
||||
var (
|
||||
sCoords string
|
||||
uCoords string
|
||||
timestamp = time.Now().Unix()
|
||||
apiStr = "directionlite/v1/riding"
|
||||
)
|
||||
sCoords = utils.Float64ToStr(coords[0].Lat) + "," + utils.Float64ToStr(coords[0].Lng)
|
||||
uCoords = utils.Float64ToStr(coords[1].Lat) + "," + utils.Float64ToStr(coords[1].Lng)
|
||||
|
||||
param := map[string]interface{}{
|
||||
"origin": sCoords,
|
||||
"destination": uCoords,
|
||||
"timestamp": timestamp,
|
||||
//"steps_info": 2,
|
||||
}
|
||||
//生成签名
|
||||
params2 := utils.MergeMaps(utils.Params2Map("ak", a.ak, "output", "json"), param)
|
||||
sn := a.signParams(apiStr, params2)
|
||||
|
||||
params := url.Values{
|
||||
"origin": []string{sCoords},
|
||||
"destination": []string{uCoords},
|
||||
"ak": []string{a.ak},
|
||||
"sn": []string{sn},
|
||||
"timestamp": []string{utils.Int64ToStr(timestamp)},
|
||||
}
|
||||
|
||||
// 发起请求
|
||||
request, err := url.Parse(prodURL2 + "/" + apiStr + "?" + params.Encode())
|
||||
if nil != err {
|
||||
fmt.Printf("host error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
resp, err1 := http.Get(request.String())
|
||||
fmt.Printf("url: %s\n", request.String())
|
||||
defer resp.Body.Close()
|
||||
if err1 != nil {
|
||||
fmt.Printf("request error: %v", err1)
|
||||
return
|
||||
}
|
||||
body, err2 := ioutil.ReadAll(resp.Body)
|
||||
if err2 != nil {
|
||||
fmt.Printf("response error: %v", err2)
|
||||
}
|
||||
result := string(body)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package baidunavi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
@@ -19,7 +20,8 @@ func init() {
|
||||
sugarLogger = logger.Sugar()
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
api = New("eL94zToVOdGDTkNQxV8dnEQ1ZRcB2UKb", "ZG0OOpOsOVURUwAkkmoHQFKRCbzn0zGb")
|
||||
//api = New("eL94zToVOdGDTkNQxV8dnEQ1ZRcB2UKb", "ZG0OOpOsOVURUwAkkmoHQFKRCbzn0zGb")
|
||||
api = New("wW2AwzPS0hdaPy5QLalzso7ARX5uYZtZ", "ZG0OOpOsOVURUwAkkmoHQFKRCbzn0zGb")
|
||||
}
|
||||
|
||||
func TestBatchCoordinateConvert(t *testing.T) {
|
||||
@@ -39,3 +41,20 @@ func TestBatchCoordinateConvert(t *testing.T) {
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDirectionLiteRide(t *testing.T) {
|
||||
result, err := api.DirectionLiteRide([]*Coordinate{
|
||||
{
|
||||
Lng: 104.063285,
|
||||
Lat: 30.571255,
|
||||
},
|
||||
&Coordinate{
|
||||
Lng: 104.065132,
|
||||
Lat: 30.610506,
|
||||
},
|
||||
})
|
||||
|
||||
fmt.Println(err)
|
||||
fmt.Println(result)
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
@@ -17,3 +18,11 @@ func TestGetRefundSkuDetailFromMsg(t *testing.T) {
|
||||
result := api.GetRefundSkuDetailFromMsg(msg)
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestSplice(t *testing.T) {
|
||||
var params = map[string]interface{}{}
|
||||
var statuss []int
|
||||
params["statuss"] = "[20]"
|
||||
utils.UnmarshalUseNumber([]byte(params["statuss"].(string)), &statuss)
|
||||
fmt.Println(statuss)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
"github.com/gazeboxu/mapstructure"
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/gorilla/websocket"
|
||||
"io"
|
||||
"net/http/httptest"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -17,7 +19,10 @@ const (
|
||||
TestAppID = "589_WMOPEN"
|
||||
TestToken = "wo589i4VsZHFH2fh4uVsr6Dtc3k6vG8Xu0vxpreBQFy6QAvg"
|
||||
|
||||
TestMTIMPushUrl = "wss://wpush.meituan.com/websocket/589_WMOPEN/wo589i4VsZHFH2fh4uVsr6Dtc3k6vG8Xu0vxpreBQFy6QAvg"
|
||||
TestMTIM589 = "wss://wpush.meituan.com/websocket/589_WMOPEN/wo589i4VsZHFH2fh4uVsr6Dtc3k6vG8Xu0vxpreBQFy6QAvg"
|
||||
TestMTIM4123 = "wss://wpush.meituan.com/websocket/4123_WMOPEN/wo4123aAVXDUkZDYucMoTDAZgsMzjrR_porZcLGv2GmWRNOiw"
|
||||
TestWssUrl = "wss://www.jxc4.com:443/v2/event/TestWebsocket"
|
||||
TestWssUrl1 = "wss://www-jxgy.jxc4.com:443/v2/im/StartWebSocket"
|
||||
)
|
||||
|
||||
type ClientManager struct {
|
||||
@@ -68,27 +73,81 @@ var rdb = redis.NewClient(&redis.Options{
|
||||
DB: 0,
|
||||
})
|
||||
|
||||
type TestStr struct {
|
||||
VendorID int `json:"vendorID"` //平台品牌 10-美团 11-饿了么
|
||||
UserID int `json:"userID"` //用户ID
|
||||
NewMessageNum int `json:"NewMessageNum"` //新消息数量
|
||||
LatestMsg string `json:"latestMsg"` //最新一条消息
|
||||
LatestTime int `json:"latestTime"` //最新一条消息发送时间
|
||||
}
|
||||
|
||||
func TestCacher_RPush(t *testing.T) {
|
||||
//ans := TestStr{
|
||||
// VendorID: 22,
|
||||
// UserID: 2222222222,
|
||||
// NewMessageNum: 222,
|
||||
// LatestMsg: "22222222222",
|
||||
// LatestTime: 22222222222,
|
||||
//}
|
||||
//str, _ := json.Marshal(ans)
|
||||
//err := rdb.RPush("test", string(str))
|
||||
keys := []string{"589:7954977:10", "test"}
|
||||
retVal := make(map[string][]interface{}, 0)
|
||||
for _, key := range keys {
|
||||
temp := rdb.LRange(key, 0, -1).Val()
|
||||
for _, v := range temp {
|
||||
retVal[key] = append(retVal[key], v)
|
||||
}
|
||||
}
|
||||
fmt.Printf("%s", utils.Format4Output(retVal, false))
|
||||
//if err != nil {
|
||||
// fmt.Print(err)
|
||||
//}
|
||||
}
|
||||
|
||||
//测试心跳
|
||||
func TestHeartCheck(t *testing.T) {
|
||||
//go func() {
|
||||
// ticker := time.NewTicker(5 * time.Second)
|
||||
// defer ticker.Stop()
|
||||
// for {
|
||||
// <-ticker.C
|
||||
//发送心跳
|
||||
conn, resp, err := websocket.DefaultDialer.Dial(TestMTIMPushUrl, nil)
|
||||
fmt.Println(resp, err)
|
||||
err1 := conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(time.Second))
|
||||
var clientID = make(map[string]*websocket.Conn)
|
||||
//conn, resp, err := websocket.DefaultDialer.Dial(TestMTIMPushUrl, nil)
|
||||
|
||||
//str := "~#HHhehHBBB#~"
|
||||
//data := []byte(str)
|
||||
conn1, resp1, err1 := websocket.DefaultDialer.Dial(TestMTIM4123, nil)
|
||||
fmt.Println(conn1, resp1, err1)
|
||||
clientID["1"] = conn1
|
||||
|
||||
conn, resp, err := websocket.DefaultDialer.Dial(TestMTIM589, nil)
|
||||
clientID["2"] = conn
|
||||
fmt.Println(conn, resp, err)
|
||||
|
||||
if err != nil || resp.StatusCode != 101 {
|
||||
fmt.Printf("连接失败:%v http响应不成功", err)
|
||||
}
|
||||
//关闭
|
||||
defer func(conn *websocket.Conn) {
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}(conn)
|
||||
|
||||
if err := conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(time.Second)); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
//err = conn.WriteMessage(websocket.TextMessage, data)
|
||||
//if err != nil {
|
||||
// fmt.Println(err)
|
||||
//}
|
||||
|
||||
for {
|
||||
_, msg, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
temp := string(msg)
|
||||
if err != nil || temp != "HB" {
|
||||
break
|
||||
}
|
||||
fmt.Printf("%s receive: %s\n", conn.RemoteAddr(), string(msg))
|
||||
}
|
||||
fmt.Println(err1)
|
||||
//}
|
||||
//}()
|
||||
}
|
||||
|
||||
func TestGetConnectionToken(t *testing.T) {
|
||||
@@ -116,81 +175,34 @@ func TestAesCBCDecrypt(t *testing.T) {
|
||||
|
||||
var wsList []*websocket.Conn
|
||||
|
||||
func sendmsg() {
|
||||
for _, conn := range wsList {
|
||||
if err := conn.WriteMessage(websocket.TextMessage, []byte("~#HHHBBB#~")); err != nil {
|
||||
fmt.Printf("%s", err) //"use of closed network connection"
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestPut(t *testing.T) {
|
||||
fmt.Println(wsList)
|
||||
type RetData struct {
|
||||
Code int `json:"code"` //响应code
|
||||
Msg string `json:"msg"` //响应msg success/fail
|
||||
Data interface{} `json:"data"` //信息
|
||||
}
|
||||
|
||||
func TestWebSocketClient(t *testing.T) {
|
||||
//发送webSocket请求
|
||||
conn, resp, err := websocket.DefaultDialer.Dial(TestMTIMPushUrl, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("连接失败:%v", err)
|
||||
}
|
||||
fmt.Printf("响应:%s", fmt.Sprint(resp))
|
||||
//wsList = append(wsList, conn)
|
||||
//关闭
|
||||
conn.SetCloseHandler(func(code int, text string) error {
|
||||
fmt.Printf("WebSocket connection closed with code %d and text: %s\n", code, text)
|
||||
return nil
|
||||
})
|
||||
defer func(conn *websocket.Conn) {
|
||||
err := conn.Close()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}(conn)
|
||||
var retData RetData
|
||||
|
||||
//赋入全局变量
|
||||
//Default(conn)
|
||||
//生成clientID
|
||||
clientID := GenClientId()
|
||||
retData.Code = 0
|
||||
retData.Msg = "success"
|
||||
retData.Data = "发送信息成功"
|
||||
|
||||
//创建实例连接
|
||||
client := &Client{
|
||||
ID: clientID,
|
||||
//AccountId:conn. ,
|
||||
Socket: conn,
|
||||
HeartbeatTime: time.Now().Unix(),
|
||||
}
|
||||
//rdb.Set("testPush", client, 0)
|
||||
|
||||
//注册到连接管理
|
||||
RegisterChan <- client
|
||||
//todo 暂时不确定放哪
|
||||
//go Start()
|
||||
|
||||
done := make(chan SingleChat)
|
||||
//err = conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(time.Second))
|
||||
err = conn.WriteMessage(websocket.TextMessage, []byte("~#HHHBBB#~"))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
for {
|
||||
_, msg, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
//log.Fatal(err)
|
||||
break
|
||||
}
|
||||
fmt.Printf("%s receive: %s\n", conn.RemoteAddr(), string(msg))
|
||||
}
|
||||
<-done
|
||||
retJson, _ := json.Marshal(retData)
|
||||
str := string(retJson)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
_, _ = io.WriteString(w, str)
|
||||
return
|
||||
}
|
||||
|
||||
func TestPUSH(t *testing.T) {
|
||||
key := "589:7954977:10"
|
||||
//rdb.RPush(key, "1111111111")
|
||||
rdb.RPush(key, "1111111111")
|
||||
//rdb.RPush(key, "{\"vendorID\":10,\"userID\":11158569333,\"NewMessageNum\":3,\"latestMsg\":\"hhhhhhhhhhh\",\"latestTime\":1681983980}")
|
||||
//rdb.RPush(key, "{\"vendorID\":10,\"userID\":11158569333,\"NewMessageNum\":3,\"latestMsg\":\"oooooooooo\",\"latestTime\":1681983980}")
|
||||
//rdb.RPush(key, "2222222222222")
|
||||
rdb.RPush(key, "{\"vendorID\":10,\"userID\":11158569333,\"NewMessageNum\":3,\"latestMsg\":\"oooooooooo\",\"latestTime\":1681983980}")
|
||||
rdb.RPush(key, "2222222222222")
|
||||
rdb.RPush(key, "{\"vendorID\":10,\"userID\":11158569333,\"NewMessageNum\":4,\"latestMsg\":\"成功插入新数据,看下cnt\",\"latestTime\":1681983980}")
|
||||
rdb.RPush(key, "{\"vendorID\":10,\"userID\":11158569333,\"NewMessageNum\":5,\"latestMsg\":\"成功插入新数据,看下cnt\",\"latestTime\":1681983980}")
|
||||
}
|
||||
@@ -205,43 +217,72 @@ type UserMessageList struct {
|
||||
}
|
||||
|
||||
func TestNewRedis(t *testing.T) {
|
||||
var flag = 11158569333
|
||||
var key = "589:7954977:10"
|
||||
s2 := rdb.LRange(key, 0, -1).Val()
|
||||
fmt.Printf("before len %d\n", len(s2))
|
||||
fmt.Printf("before ans %s\n", s2)
|
||||
cnt := 0
|
||||
n := rdb.Exists(key).Val()
|
||||
if n > 0 {
|
||||
var (
|
||||
err error
|
||||
flag = 11158569333
|
||||
key = "589:7954977:10"
|
||||
temp = UserMessageList{}
|
||||
)
|
||||
if n := rdb.Exists(key).Val(); n > 0 {
|
||||
s2 := rdb.LRange(key, 0, -1).Val()
|
||||
for i := 0; i < len(s2); i++ {
|
||||
v := UserMessageList{}
|
||||
_ = json.Unmarshal([]byte(s2[i]), &v)
|
||||
if v.UserID == flag {
|
||||
rdb.LSet(key, int64(i), "del")
|
||||
rdb.LRem(key, 0, "del")
|
||||
//删除此条数据
|
||||
err = rdb.LSet(key, int64(i), "del").Err()
|
||||
err = rdb.LRem(key, 0, "del").Err()
|
||||
s2 = append(s2[:i], s2[i+1:]...)
|
||||
i--
|
||||
if v.NewMessageNum == 0 { //目前为首条
|
||||
cnt++ //赋值1
|
||||
} else {
|
||||
cnt = v.NewMessageNum
|
||||
//cnt=0 重新赋值
|
||||
temp = UserMessageList{
|
||||
VendorID: v.VendorID,
|
||||
UserID: v.UserID,
|
||||
NewMessageNum: 0,
|
||||
LatestMsg: v.LatestMsg,
|
||||
LatestTime: v.LatestTime,
|
||||
}
|
||||
}
|
||||
}
|
||||
str, _ := json.Marshal(temp)
|
||||
err = rdb.RPush(key, str).Err()
|
||||
}
|
||||
fmt.Printf("after cnt %d\n", cnt)
|
||||
fmt.Printf("after len %d\n", len(s2))
|
||||
fmt.Printf("after ans %s\n", s2)
|
||||
//存入flag数据
|
||||
ans := UserMessageList{
|
||||
VendorID: 10,
|
||||
UserID: 11158569333,
|
||||
NewMessageNum: cnt,
|
||||
LatestMsg: "成功插入新数据,看下cnt",
|
||||
LatestTime: 1681983980,
|
||||
}
|
||||
param, _ := json.Marshal(ans)
|
||||
rdb.RPush(key, param)
|
||||
fmt.Print(err)
|
||||
//s2 := rdb.LRange(key, 0, -1).Val()
|
||||
//fmt.Printf("before len %d\n", len(s2))
|
||||
//fmt.Printf("before ans %s\n", s2)
|
||||
//cnt := 0
|
||||
//n := rdb.Exists(key).Val()
|
||||
//if n > 0 {
|
||||
// for i := 0; i < len(s2); i++ {
|
||||
// v := UserMessageList{}
|
||||
// _ = json.Unmarshal([]byte(s2[i]), &v)
|
||||
// if v.UserID == flag {
|
||||
// rdb.LSet(key, int64(i), "del")
|
||||
// rdb.LRem(key, 0, "del")
|
||||
// s2 = append(s2[:i], s2[i+1:]...)
|
||||
// i--
|
||||
// if v.NewMessageNum == 0 { //目前为首条
|
||||
// cnt++ //赋值1
|
||||
// } else {
|
||||
// cnt = v.NewMessageNum
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//fmt.Printf("after cnt %d\n", cnt)
|
||||
//fmt.Printf("after len %d\n", len(s2))
|
||||
//fmt.Printf("after ans %s\n", s2)
|
||||
////存入flag数据
|
||||
//ans := UserMessageList{
|
||||
// VendorID: 10,
|
||||
// UserID: 11158569333,
|
||||
// NewMessageNum: cnt,
|
||||
// LatestMsg: "成功插入新数据,看下cnt",
|
||||
// LatestTime: 1681983980,
|
||||
//}
|
||||
//param, _ := json.Marshal(ans)
|
||||
//rdb.RPush(key, param)
|
||||
}
|
||||
|
||||
// 根据账号获取连接
|
||||
|
||||
@@ -20,10 +20,11 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// 菜市
|
||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
|
||||
// 果园
|
||||
// api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
|
||||
@@ -303,7 +303,7 @@ func TestUtilsTime2Date(t *testing.T) {
|
||||
|
||||
//设置门店打包费
|
||||
func TestSetStorePackageFee(t *testing.T) {
|
||||
err := a.SetStorePackageFee(62490423, 5) //单位 分
|
||||
err := a.SetStorePackageFee(94979567, 5) //单位 分
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package trenditapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
var api = New(TiAppID, TiAppSecret)
|
||||
@@ -40,10 +42,7 @@ func TestAPI_Print(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCal(t *testing.T) {
|
||||
str := "豌豆米-手工剥豆约100g/份"
|
||||
//ans := "--------------------------------"
|
||||
cnt := CalWidth(str)
|
||||
fmt.Println(cnt)
|
||||
fmt.Println(utils.Time2Str(time.Now()))
|
||||
}
|
||||
|
||||
//打印取消/退货模板
|
||||
|
||||
@@ -23,16 +23,41 @@ func TestCBMessageTemplateSend(t *testing.T) {
|
||||
// "oYN_usk0AeGc_C6VEZfmFQP5VHMQ": 1, // 周小扬
|
||||
// "oYN_ust9hXKEvEv0X6Mq6nlAWs_E": 1, // me
|
||||
// "oYN_usvnObzrPweIgHTad9-uMf78": 1, // 老赵
|
||||
err := api.CBMessageTemplateSend("oYN_ust9hXKEvEv0X6Mq6nlAWs_E", "_DtNGwmOeR6TkkTVUblxLIlkV2MAPOX57TkvfdqG6nY", "", map[string]interface{}{
|
||||
"appid": "wx4b5930c13f8b1170",
|
||||
"pagepath": "pages/order-manager/main",
|
||||
err := api.CBMessageTemplateSend("oYN_uskWlggFxGNZtagNh-cqfTQs", "b8-tLyWwAmK-1tEU1eGqp_YAAqQtSzoVDZkHuyUe9lk", "", map[string]interface{}{
|
||||
"appid": "wx4b5930c13f8b1170",
|
||||
//"pagepath": "pages/order-manager/main",
|
||||
}, map[string]interface{}{
|
||||
"first": "first",
|
||||
"Day": "Day",
|
||||
"orderId": "orderId",
|
||||
"orderType": "orderType",
|
||||
"customerName": "customerName",
|
||||
"customerPhone": "customerPhone",
|
||||
"first": map[string]interface{}{
|
||||
"value": "这是一个测试头",
|
||||
"color": "#0191EA",
|
||||
},
|
||||
"keyword1": map[string]interface{}{
|
||||
"value": "美团#1",
|
||||
"color": "#173177",
|
||||
},
|
||||
"keyword2": map[string]interface{}{
|
||||
"value": "好菜鲜生(清水塘生鲜农贸市场2店)",
|
||||
"color": "#173177",
|
||||
},
|
||||
//"orderId": "orderId",
|
||||
"keyword3": map[string]interface{}{
|
||||
//"value": "吴廷琦吴吴廷琦吴吴廷琦吴吴廷琦吴吴廷琦吴吴廷琦吴 18727362534,0987",
|
||||
"value": "1234567891234567891234567891234 18727362534,0987",
|
||||
"color": "#173177",
|
||||
},
|
||||
"keyword4": map[string]interface{}{
|
||||
"value": "2023:05:05 14:30:18",
|
||||
"color": "#173177",
|
||||
},
|
||||
//"keyword5": map[string]interface{}{
|
||||
// "value": "立即配送",
|
||||
// "color": "#173177",
|
||||
//},
|
||||
|
||||
//"customerPhone": map[string]interface{}{
|
||||
// "value": "1234567891234567891234567891234",
|
||||
// "color": "#173177",
|
||||
//},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
|
||||
@@ -27,7 +27,7 @@ func init() {
|
||||
|
||||
//weixinapp
|
||||
//api = New("wx18111a41fd17f24f", "c79ac6e1b2d6d7968e72a9658a8b6715")
|
||||
api.CBSetToken("46_sKrKhgoeh0Om1V2_IcTERUux4-pLL5CplvhOh7civG51UCSUTt6g3WkTutvk107i2SMhdcU5q9MYGbciZ4PHyPzhlzx34yBPblf8dpRHx3VYE_a9JbE2wbtjJY93GmXc4KcRHxlEa8s_QWFVOLCgADAKHY")
|
||||
api.CBSetToken("68_McFYD4DjMiawiqWvGstXuxBq5IKTt9xMHRnwqE4nW8c6YVYhPV7cYEpyf0y0nh0m8qiHKCYbzS6Oc3DN-Wu74_WoNXi7PDzjkZWG2dziBqzsGYE8UVZlpi2ezO0NBKeAEAQEN")
|
||||
}
|
||||
|
||||
func handleError(t *testing.T, err error) {
|
||||
|
||||
Reference in New Issue
Block a user