Merge branch 'master' of e.coding.net:rosydev/baseapi
This commit is contained in:
@@ -0,0 +1,49 @@
|
|||||||
|
package superm_getStoreAutoCallRiderInfo_request
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
superm_getStoreAutoCallRiderInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getStoreAutoCallRiderInfo/response"
|
||||||
|
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SupermGetStoreAutoCallRiderInfoRequest struct {
|
||||||
|
doudian_sdk.BaseDoudianOpApiRequest
|
||||||
|
Param *SupermGetStoreAutoCallRiderInfoParam
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SupermGetStoreAutoCallRiderInfoRequest) GetUrlPath() string {
|
||||||
|
return "/superm/getStoreAutoCallRiderInfo"
|
||||||
|
}
|
||||||
|
|
||||||
|
func New() *SupermGetStoreAutoCallRiderInfoRequest {
|
||||||
|
request := &SupermGetStoreAutoCallRiderInfoRequest{
|
||||||
|
Param: &SupermGetStoreAutoCallRiderInfoParam{},
|
||||||
|
}
|
||||||
|
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||||
|
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||||
|
return request
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SupermGetStoreAutoCallRiderInfoRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_getStoreAutoCallRiderInfo_response.SupermGetStoreAutoCallRiderResponse, error) {
|
||||||
|
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response := &superm_getStoreAutoCallRiderInfo_response.SupermGetStoreAutoCallRiderResponse{}
|
||||||
|
_ = json.Unmarshal([]byte(responseJson), response)
|
||||||
|
return response, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SupermGetStoreAutoCallRiderInfoRequest) GetParamObject() interface{} {
|
||||||
|
return c.Param
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SupermGetStoreAutoCallRiderInfoRequest) GetParams() *SupermGetStoreAutoCallRiderInfoParam {
|
||||||
|
return c.Param
|
||||||
|
}
|
||||||
|
|
||||||
|
type SupermGetStoreAutoCallRiderInfoParam struct {
|
||||||
|
StoreID int64 `json:"store_id"` //店铺的门店ID
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package superm_getStoreAutoCallRiderInfo_response
|
||||||
|
|
||||||
|
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||||
|
|
||||||
|
type SupermGetStoreAutoCallRiderResponse struct {
|
||||||
|
doudian_sdk.BaseDoudianOpApiResponse
|
||||||
|
Data *AutoCallInfo `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AutoCallInfo struct {
|
||||||
|
ServiceStatus int64 `json:"service_status"` //自动呼叫运力设置状态;1:关闭 2:开启
|
||||||
|
ServiceType int64 `json:"service_type"` //自动呼叫运力策略; 0:接单后立即呼叫 1:接单后延迟呼叫
|
||||||
|
DelayTime int64 `json:"delay_time"` //接单后延时呼叫时间,service_type为1时生效,单位min,范围[1,15]
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package superm_setStoreAutoCallRider_request
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
superm_setStoreAutoCallRider_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_setStoreAutoCallRider/response"
|
||||||
|
doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SupermSetStoreAutoCallRiderRequest struct {
|
||||||
|
doudian_sdk.BaseDoudianOpApiRequest
|
||||||
|
Param *SupermSetStoreAutoCallRiderParam
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SupermSetStoreAutoCallRiderRequest) GetUrlPath() string {
|
||||||
|
return "/superm/setStoreAutoCallRider"
|
||||||
|
}
|
||||||
|
|
||||||
|
func New() *SupermSetStoreAutoCallRiderRequest {
|
||||||
|
request := &SupermSetStoreAutoCallRiderRequest{
|
||||||
|
Param: &SupermSetStoreAutoCallRiderParam{},
|
||||||
|
}
|
||||||
|
request.SetConfig(doudian_sdk.GlobalConfig)
|
||||||
|
request.SetClient(doudian_sdk.DefaultDoudianOpApiClient)
|
||||||
|
return request
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SupermSetStoreAutoCallRiderRequest) Execute(accessToken *doudian_sdk.AccessToken) (*superm_setStoreAutoCallRider_response.SpermSetStoreAutoCallRiderResponse, error) {
|
||||||
|
responseJson, err := c.GetClient().Request(c, accessToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response := &superm_setStoreAutoCallRider_response.SpermSetStoreAutoCallRiderResponse{}
|
||||||
|
_ = json.Unmarshal([]byte(responseJson), response)
|
||||||
|
return response, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SupermSetStoreAutoCallRiderRequest) GetParamObject() interface{} {
|
||||||
|
return c.Param
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SupermSetStoreAutoCallRiderRequest) GetParams() *SupermSetStoreAutoCallRiderParam {
|
||||||
|
return c.Param
|
||||||
|
}
|
||||||
|
|
||||||
|
type SupermSetStoreAutoCallRiderParam struct {
|
||||||
|
StoreID int64 `json:"store_id"` //店铺的门店ID
|
||||||
|
OpType string `json:"op_type"` //自动呼叫运力设置状态;open 开启 close 关闭
|
||||||
|
ServiceType int64 `json:"service_type"` //自动呼叫运力策略; 0:接单后立即呼叫 1:接单后延迟呼叫
|
||||||
|
DelayTime int64 `json:"delay_time"` //接单后延时呼叫时间,service_type为1时生效,单位分钟,范围[1,15] 延迟时间仅支持1-15分钟
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package superm_setStoreAutoCallRider_response
|
||||||
|
|
||||||
|
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||||
|
|
||||||
|
type SpermSetStoreAutoCallRiderResponse struct {
|
||||||
|
doudian_sdk.BaseDoudianOpApiResponse
|
||||||
|
Data *SupermGetShipmentInfoData `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SupermGetShipmentInfoData struct {
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package tiktok_api
|
|
||||||
|
|
||||||
type StoreCallbackResponse struct {
|
|
||||||
Data string `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建店铺回调信息
|
|
||||||
type CallbackCreateStore struct {
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,12 @@ import (
|
|||||||
superm_getPlatformPickUpEstimatedCharge_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getPlatformPickUpEstimatedCharge/request"
|
superm_getPlatformPickUpEstimatedCharge_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getPlatformPickUpEstimatedCharge/request"
|
||||||
superm_getShipmentInfo_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getShipmentInfo/request"
|
superm_getShipmentInfo_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getShipmentInfo/request"
|
||||||
superm_getShipmentInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getShipmentInfo/response"
|
superm_getShipmentInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getShipmentInfo/response"
|
||||||
|
superm_getStoreAutoCallRiderInfo_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getStoreAutoCallRiderInfo/request"
|
||||||
|
superm_getStoreAutoCallRiderInfo_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_getStoreAutoCallRiderInfo/response"
|
||||||
superm_orderDispatcher_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_orderDispatcher/request"
|
superm_orderDispatcher_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_orderDispatcher/request"
|
||||||
|
superm_setStoreAutoCallRider_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_setStoreAutoCallRider/request"
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
// /superm/getDispatcherInfo 运力呼叫询价/运力取消询价(正向)
|
// /superm/getDispatcherInfo 运力呼叫询价/运力取消询价(正向)
|
||||||
@@ -49,6 +54,40 @@ func (a *API) ShopOrderDispatcher(storeID int64, shopOrderID string, dispatcherT
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /superm/setStoreAutoCallRider 订单自动呼叫运力 设置操作
|
||||||
|
func (a *API) SetStoreAutoCallRider(params *superm_setStoreAutoCallRider_request.SupermSetStoreAutoCallRiderParam) error {
|
||||||
|
request := superm_setStoreAutoCallRider_request.New()
|
||||||
|
request.Param = params
|
||||||
|
response, err := request.Execute(a.accessTokenObj)
|
||||||
|
globals.SugarLogger.Debugf("订单自动呼叫运力 设置操作=========:%s", request.GetUrlPath())
|
||||||
|
globals.SugarLogger.Debugf("订单自动呼叫运力 设置操作:=%s", utils.Format4Output(response, false))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if response.Code != RequestSuccessCode {
|
||||||
|
return errors.New(response.SubMsg)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// /superm/getStoreAutoCallRiderInfo 查询自动呼叫运力配置
|
||||||
|
func (a *API) GetStoreAutoCallRiderInfo(storeID int64) (*superm_getStoreAutoCallRiderInfo_response.AutoCallInfo, error) {
|
||||||
|
request := superm_getStoreAutoCallRiderInfo_request.New()
|
||||||
|
request.Param = &superm_getStoreAutoCallRiderInfo_request.SupermGetStoreAutoCallRiderInfoParam{
|
||||||
|
StoreID: storeID,
|
||||||
|
}
|
||||||
|
response, err := request.Execute(a.accessTokenObj)
|
||||||
|
globals.SugarLogger.Debugf("查询自动呼叫运力配置=========:%s", request.GetUrlPath())
|
||||||
|
globals.SugarLogger.Debugf("查询自动呼叫运力配置:=%s", utils.Format4Output(response, false))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if response.Code != RequestSuccessCode {
|
||||||
|
return nil, errors.New(response.SubMsg)
|
||||||
|
}
|
||||||
|
return response.Data, nil
|
||||||
|
}
|
||||||
|
|
||||||
// /superm/createVirtualMobile 隐私小号获取
|
// /superm/createVirtualMobile 隐私小号获取
|
||||||
func (a *API) CreateVirtualMobile(shopOrderID int64) (*superm_createVirtualMobile_response.SupermCreateVirtualMobileData, error) {
|
func (a *API) CreateVirtualMobile(shopOrderID int64) (*superm_createVirtualMobile_response.SupermCreateVirtualMobileData, error) {
|
||||||
request := superm_createVirtualMobile_request.New()
|
request := superm_createVirtualMobile_request.New()
|
||||||
|
|||||||
1
platformapi/tiktok_shop/tiktok_api/transport_callback.go
Normal file
1
platformapi/tiktok_shop/tiktok_api/transport_callback.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package tiktok_api
|
||||||
@@ -8,15 +8,18 @@ const (
|
|||||||
|
|
||||||
InquiryTypeDelivery = 1 //配送 默认
|
InquiryTypeDelivery = 1 //配送 默认
|
||||||
InquiryTypeCancel = 2 //取消
|
InquiryTypeCancel = 2 //取消
|
||||||
|
//抖音运力相关常量
|
||||||
ServiceTypeCallNow = 0 //立即呼叫
|
ServiceTypeCallNow = 0 //立即呼叫(用户支付成功节点)
|
||||||
ServiceTypeDelayCall = 1 //延迟呼叫
|
ServiceTypeDelayCall = 1 //延迟呼叫[1-15]min
|
||||||
|
AutoCallRiderOpen = "open" //开启自动呼叫运力
|
||||||
ServiceStatusClose = 1 //自动呼叫运力设置关闭
|
AutoCallRiderClose = "close" //关闭自动呼叫运力
|
||||||
ServiceStatusOpen = 2 //自动呼叫运力设置开启
|
AutoCallDelayTime15 = 15 //默认延后15分钟
|
||||||
|
ServiceStatusClose = 1 //自动呼叫运力设置关闭
|
||||||
|
ServiceStatusOpen = 2 //自动呼叫运力设置开启
|
||||||
|
|
||||||
ShipmentTypeInvoice = 1 //发货单
|
ShipmentTypeInvoice = 1 //发货单
|
||||||
ShipmentTypeVisitInDoor = 2 //上门取
|
ShipmentTypeVisitInDoor = 2 //上门取
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -2,21 +2,60 @@ package tiktok_api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
//运力呼叫询价(正向)
|
//运力呼叫询价(正向)
|
||||||
func TestGetDispatcherInfo(t *testing.T) {
|
func TestGetDispatcherInfo(t *testing.T) {
|
||||||
dispatcherFee, err := a.GetDispatcherInfo(62490423, "5016270839501385439", 1)
|
dispatcherFee, err := a.GetDispatcherInfo(62490423, "5016940182798690015", 1)
|
||||||
fmt.Println(dispatcherFee)
|
fmt.Println(dispatcherFee)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
func TestCancelWaybill(t *testing.T) {
|
func TestCancelWaybill(t *testing.T) {
|
||||||
err := a.ShopOrderDispatcher(62490423, "5016287638112024287", 2)
|
err := a.ShopOrderDispatcher(62490423, "5017358149445080799", 2)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test2222(t *testing.T) {
|
type tete struct {
|
||||||
fmt.Println(2&(model.SyncFlagDeletedMask|model.SyncFlagNewMask|model.SyncFlagModifiedMask) != 0)
|
ids []int64
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test(t *testing.T) {
|
||||||
|
//var a []int64
|
||||||
|
var b interface{}
|
||||||
|
//stType := reflect.TypeOf(a)
|
||||||
|
//stValue := reflect.ValueOf(a)
|
||||||
|
x := reflect.TypeOf(b)
|
||||||
|
fmt.Println(reflect.TypeOf(a) == reflect.TypeOf([]int64{}))
|
||||||
|
switch x {
|
||||||
|
case reflect.TypeOf([]int64{}):
|
||||||
|
|
||||||
|
fmt.Println(1)
|
||||||
|
case reflect.TypeOf([]string{}):
|
||||||
|
fmt.Println(2)
|
||||||
|
|
||||||
|
}
|
||||||
|
//fmt.Println(stType.NumField())
|
||||||
|
//fmt.Println(stType.Field(0))
|
||||||
|
//temp := stType.Field(0)
|
||||||
|
//fmt.Println(temp.Type)
|
||||||
|
|
||||||
|
//Strings2Objs(`[1262627,1723872383]`, &a)
|
||||||
|
//fmt.Printf("%v", reflect.TypeOf(a).NumField())
|
||||||
|
}
|
||||||
|
func Strings2Objs(strAndObjAddPairs ...interface{}) (err error) {
|
||||||
|
str := ""
|
||||||
|
for k, v := range strAndObjAddPairs {
|
||||||
|
if k%2 == 0 {
|
||||||
|
str, _ = v.(string)
|
||||||
|
} else if str != "" {
|
||||||
|
if err = utils.UnmarshalUseNumber([]byte(str), v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
207
platformapi/uuptapi/uupt_model.go
Normal file
207
platformapi/uuptapi/uupt_model.go
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
package uuptapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi"
|
||||||
|
"net/http"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
//正式环境
|
||||||
|
TokenURL = "https://openapi.uupt.com/v2_0/"
|
||||||
|
//沙箱环境
|
||||||
|
//TokenURL = "http://openapi.test.uupt.com/v2_0/"
|
||||||
|
RequestPost = "POST"
|
||||||
|
)
|
||||||
|
const (
|
||||||
|
//运单状态
|
||||||
|
StateConfirmSuccess = 1 //下单成功
|
||||||
|
StateRMGrabsOrder = 3 //跑男抢单
|
||||||
|
StateArrivedStore = 4 //已到达
|
||||||
|
StatePickUp = 5 //已取件
|
||||||
|
StateArrivedDestination = 6 //到达目的地
|
||||||
|
StateReceiverGetGoods = 10 //取件人已收货
|
||||||
|
StateOrderCancel = -1 //订单取消
|
||||||
|
|
||||||
|
//订单小类
|
||||||
|
SendTypeHelpMeDeliver = 0 //帮我送
|
||||||
|
SendTypeHelpMeBuy = 1 //帮我买
|
||||||
|
//预约类型
|
||||||
|
SubscribeTypeRealTime = 0 //实时订单
|
||||||
|
SubscribeTypeReservation = 1 //预约取件时间
|
||||||
|
//加急配送 默认不开启
|
||||||
|
UrgentOrderNormal = 0 //正常配送
|
||||||
|
UrgentOrderOpen = 1 //开启加急配送
|
||||||
|
//推送方式
|
||||||
|
PushTypeOpen = 0 //开放订单
|
||||||
|
PushTypeTest = 1 //测试订单
|
||||||
|
//特殊处理类型
|
||||||
|
SpecialTypeYes = 1 //需要
|
||||||
|
SpecialTypeNo = 0 //不需要
|
||||||
|
//取件是否需要打电话
|
||||||
|
CallMeWithTakeYes = 1 //需要
|
||||||
|
CallMeWithTakeNo = 0 //不需要
|
||||||
|
//支付方式
|
||||||
|
PayTypeBalance = 0 //账户余额支付 默认
|
||||||
|
PayTypeEnterprise = 1 //企业支付
|
||||||
|
//订单来源标识
|
||||||
|
OrderResourceMT = 1 //美团
|
||||||
|
OrderResourceELM = 2 //饿了么
|
||||||
|
OrderResourceOther = 3 //其他
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
var StateUuWaybill = map[int]string{
|
||||||
|
StateConfirmSuccess: "下单成功",
|
||||||
|
StateRMGrabsOrder: "跑男抢单",
|
||||||
|
StateArrivedStore: "已到达",
|
||||||
|
StatePickUp: "已取件",
|
||||||
|
StateArrivedDestination: "到达目的地",
|
||||||
|
StateReceiverGetGoods: "取件人已收货",
|
||||||
|
StateOrderCancel: "订单取消",
|
||||||
|
}
|
||||||
|
var SendType = map[int]string{
|
||||||
|
SendTypeHelpMeDeliver: "帮我送",
|
||||||
|
SendTypeHelpMeBuy: "帮我买",
|
||||||
|
}
|
||||||
|
|
||||||
|
type API struct {
|
||||||
|
openid string `json:"openid"` //用户openid,详情见 获取openid接口
|
||||||
|
appid string `json:"appid"` //appid
|
||||||
|
appKey string `json:"appkey"` //app密钥
|
||||||
|
sign string `json:"sign"` //加密签名
|
||||||
|
noncestr string `json:"nonce_str"` //随机字符串,不长于32位
|
||||||
|
timestamp string `json:"timestamp"` //时间戳,以秒计算时间,即unix-timestamp
|
||||||
|
locker sync.RWMutex
|
||||||
|
client *http.Client
|
||||||
|
config *platformapi.APIConfig
|
||||||
|
}
|
||||||
|
type BaseReqInfo struct {
|
||||||
|
Sign string `json:"sign"` //加密签名
|
||||||
|
NonceStr string `json:"nonce_str"` //随机字符串,不长于32位
|
||||||
|
Timestamp string `json:"timestamp"` //时间戳,以秒计算时间,即unix-timestamp
|
||||||
|
OpenID string `json:"openid"` //用户openid,详情见 获取openid接口
|
||||||
|
AppID string `json:"appid"` //appid
|
||||||
|
}
|
||||||
|
|
||||||
|
type BaseRespInfo struct {
|
||||||
|
Sign string `json:"sign"` //加密签名
|
||||||
|
NonceStr string `json:"nonce_str"` //随机字符串,不长于32位
|
||||||
|
AppID string `json:"appid"` //第三方用户唯一凭证
|
||||||
|
ReturnMsg string `json:"return_msg"` //返回信息,如非空,为错误原因,如签名失败、参数格式校验错误
|
||||||
|
ReturnCode string `json:"return_code"` //状态,ok/fail表示成功
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算订单价格请求体
|
||||||
|
type GetOrderPriceReq struct {
|
||||||
|
//必填
|
||||||
|
BaseReqInfo *BaseReqInfo
|
||||||
|
OriginID string `json:"origin_id"` //第三方对接平台订单id
|
||||||
|
FromAddress string `json:"from_address"` //发货地址
|
||||||
|
ToAddress string `json:"to_address"` //收货人地址
|
||||||
|
CityName string `json:"city_name"` //订单所在城市名 称(如郑州市就填”郑州市“,必须带上“市”)
|
||||||
|
SendType string `json:"send_type"` //订单小类 0帮我送(默认) 1帮我买
|
||||||
|
ToLat string `json:"to_lat"` //收货地址坐标纬度(坐标系为百度地图坐标系)
|
||||||
|
ToLng string `json:"to_lng"` //收货地址坐标经度(坐标系为百度地图坐标系)
|
||||||
|
FromLat string `json:"from_lat"` //发货地址坐标纬度(坐标系为百度地图坐标系)
|
||||||
|
FromLng string `json:"from_lng"` //发货地址坐标经度(坐标系为百度地图坐标系)
|
||||||
|
//非必填
|
||||||
|
FromUserNote string `json:"from_usernote"` //发货详细地址具体门牌号或门店名称
|
||||||
|
ToUserNote string `json:"to_usernote"` //收货人详细地址具体门牌号
|
||||||
|
CountyName string `json:"county_name"` //订单所在县级地名称(如金水区就填“金水区”)
|
||||||
|
SubscribeTime string `json:"subscribe_time"` //预约时间(如:2015-06-18 12:00:00)没有可以传空字符串
|
||||||
|
SubscribeType string `json:"subscribe_type"` //预约类型 0实时订单 1预约取件时间
|
||||||
|
GoodsType string `json:"goods_type"` //物品类型:(美食、鲜花、蛋糕、手机、钥匙、文件、其他)仅支持指定类型不包含按其他发布
|
||||||
|
CouponID string `json:"coupon_id"` //优惠券ID(如果传入-1就不用优惠券否则系统自动匹配)
|
||||||
|
CouponType string `json:"coupon_type"` //优惠券类型 默认空 个人优惠券 1=企业优惠券(必须企业帐号才可以使用)
|
||||||
|
GoodsWeight int `json:"goods_weight"` //物品重量单位:KG(按城市标准进行超重计费)
|
||||||
|
ShopID float64 `json:"shop_id"` //门店编号(门店列表可查看门店编号)
|
||||||
|
GoodsPrice int `json:"goods_price"` //商品保价:价格(1-10000)按照一定费率收取保价费用
|
||||||
|
UrgentOrder string `json:"urgent_order"` //加急配送默认不开启(0=正常配送 1=开启加急配送)
|
||||||
|
}
|
||||||
|
|
||||||
|
//计算订单价格返回体
|
||||||
|
type GetOrderPriceResp struct {
|
||||||
|
//必返回
|
||||||
|
OriginID string `json:"origin_id"` //第三方对接平台订单id
|
||||||
|
TotalMoney string `json:"total_money"` //订单总金额(优惠前)
|
||||||
|
NeedPayMoney string `json:"need_paymoney"` //实际需要支付金额
|
||||||
|
TotalPriceOff string `json:"total_priceoff"` //总优惠金额
|
||||||
|
Distance string `json:"distance"` //配送距离(单位:米)
|
||||||
|
CouponAmount string `json:"coupon_amount"` //优惠券金额
|
||||||
|
AddFee string `json:"addfee"` //加价金额
|
||||||
|
GoodsInsuranceMoney string `json:"goods_insurancemoney"` //商品保价金额
|
||||||
|
ExpiresIn string `json:"expires_in"` //price_token的过期时间(单位:秒)
|
||||||
|
//非必返回
|
||||||
|
PriceToken string `json:"price_token"` //金额令牌,提交订单前必须先计算价格
|
||||||
|
BaseRespInfo *BaseRespInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
//发布订单请求体
|
||||||
|
type AddOrderReq struct {
|
||||||
|
PriceToken string `json:"price_token"` //金额令牌,计算订单价格接口返回的price_token
|
||||||
|
OrderPrice string `json:"order_price"` //订单总金额(优惠前),计算订单价格接口返回的total_money
|
||||||
|
BalancePayMoney string `json:"balance_paymoney"` //实际需要支付金额,计算订单价格接口返回的need_paymoney
|
||||||
|
Receiver string `json:"receiver"` //收件人名称
|
||||||
|
ReceiverPhone string `json:"receiver_phone"` //收件人电话 手机号码; 虚拟号码格式(手机号_分机号码)例如:13700000000_1111
|
||||||
|
Note string `json:"note"` //订单备注 最长140个汉字
|
||||||
|
CallbackUrl string `json:"callback_url"` //订单提交成功后及状态变化的回调地址
|
||||||
|
PushType string `json:"push_type"` //推送方式(0 开放订单,2测试订单)默认传0即可
|
||||||
|
SpecialType string `json:"special_type"` //特殊处理类型,是否需要保温箱 1需要 0不需要
|
||||||
|
CallMeWithTake string `json:"callme_withtake"` //取件是否给我打电话 1需要 0不需要
|
||||||
|
PubUserMobile string `json:"pubusermobile"` //发件人电话,(如果为空则是用户注册的手机号)
|
||||||
|
PayType string `json:"pay_type"` //支付方式:1=企业支付 0账户余额支付(企业余额不足自动转账户余额支付)
|
||||||
|
OrderResource string `json:"orderresource"` //订单来源标示,示例(1=美团 2=饿了么 3=其他)
|
||||||
|
ShortOrderNum string `json:"shortordernum"` //订单平台短单号(0-10000),该单号会展示给骑手突出展示:“美团 #1”
|
||||||
|
ProductDetail string `json:"product_detail"` //商品详细信息:json格式字符串(建议请求接口encodeUrl处理)例如:[{"product_name":"幸福热奶茶(常规)","product_num":"2"},{"product_name":"香酥双鸡堡餐(常规)","product_num":"1"}]
|
||||||
|
ShopExpectTime string `json:"shop_expecttime"` //商家期望送达时间时间戳,以秒计算时间(仅用于展示给配送员)
|
||||||
|
ReceiverRealPhone string `json:"receiver_realphone"` //收件人真实脱敏电话(外卖订单虚拟号时,投递餐柜使用)格式:(137****0000或手机尾号0000)
|
||||||
|
}
|
||||||
|
|
||||||
|
//发布订单返回体
|
||||||
|
type AddOrderResp struct {
|
||||||
|
BaseRespInfo *BaseRespInfo
|
||||||
|
OrderCode string `json:"ordercode"` //订单号
|
||||||
|
OriginID string `json:"origin_id"` //第三方对接平台订单id
|
||||||
|
}
|
||||||
|
|
||||||
|
//取消订单
|
||||||
|
type CancelOrderReq struct {
|
||||||
|
BaseRespInfo *BaseRespInfo
|
||||||
|
OrderCode string `json:"ordercode"` //订单号
|
||||||
|
OriginID string `json:"origin_id"` //第三方对接平台订单id
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取订单详情返回体
|
||||||
|
type GetOrderDetailResp struct {
|
||||||
|
BaseRespInfo *BaseRespInfo
|
||||||
|
OriginID string `json:"origin_id"` //第三方对接平台id
|
||||||
|
OrderCode string `json:"order_code"` //uu跑腿订单编号
|
||||||
|
FromAddress string `json:"from_address"` //发货地址详细地址具体门牌号或门店名称
|
||||||
|
FromLat string `json:"from_lat"` //发货地址坐标纬度(坐标系为百度地图坐标系)
|
||||||
|
FromLng string `json:"from_lng"` //发货地址坐标经度(坐标系为百度地图坐标系)
|
||||||
|
ToAddress string `json:"to_address"` //收货人地址详细地址具体门牌号
|
||||||
|
ToLat string `json:"to_lat"` //收货地址坐标纬度(坐标系为百度地图坐标系)
|
||||||
|
ToLng string `json:"to_lng"` //收货地址坐标经度(坐标系为百度地图坐标系)
|
||||||
|
Distance string `json:"distance"` //订单距离
|
||||||
|
OrderPrice string `json:"order_price"` //订单总金额(优惠前),包含小费
|
||||||
|
Receiver string `json:"receiver"` //收件人
|
||||||
|
ReceiverPhone string `json:"receiver_phone"` //收件人电话
|
||||||
|
Note string `json:"note"` //订单备注
|
||||||
|
PriceOff string `json:"price_off"` //总优惠金额
|
||||||
|
State string `json:"state"` //当前状态1下单成功 3跑男抢单 4已到达 5已取件 6到达目的地 10收件人已收货 -1订单取消
|
||||||
|
AddTime string `json:"add_time"` //发单时间(格式2015-07-01 15:23:56)
|
||||||
|
FinishTime string `json:"finish_time"` //收货时间(格式2015-07-01 15:23:56)
|
||||||
|
StartLevel string `json:"start_level"` //评价星级
|
||||||
|
CommentNote string `json:"comment_note"` //评价内容
|
||||||
|
DriverName string `json:"driver_name"` //跑男姓名(跑男接单后)
|
||||||
|
DriverJobNum string `json:"driver_jobnum"` //跑男工号(跑男接单后)
|
||||||
|
DriverMobile string `json:"driver_mobile"` //跑男电话(跑男接单后)
|
||||||
|
SendType string `json:"send_type"` //订单小类 0帮我送 1帮我买
|
||||||
|
ExpectedarriveTime string `json:"expectedarrive_time"` //跑男接单后预计到达时间(格式2015-07-01 15:23:56)取货前为到达取货地,取货后为到达收货地
|
||||||
|
DriverLastloc string `json:"driver_lastloc"` //跑男的坐标,百度地图坐标系经纬度(格式:113.71776,34.767501)
|
||||||
|
}
|
||||||
|
|
||||||
|
//运单提交后的回调
|
||||||
|
type CallbackResp struct {
|
||||||
|
}
|
||||||
63
platformapi/uuptapi/uupt_test.go
Normal file
63
platformapi/uuptapi/uupt_test.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package uuptapi
|
||||||
|
|
||||||
|
//
|
||||||
|
//import (
|
||||||
|
// "fmt"
|
||||||
|
// "testing"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//var (
|
||||||
|
// api = New("55c4542ae60e4d348edcfc93b06dd302", "76b362c06b1b4baa9e47bab6387a5356", "8d8464e7c9354c1e88a3f5afa2a7922e")
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//func TestSignParam(t *testing.T) {
|
||||||
|
// testStr := map[string]interface{}{
|
||||||
|
// "origin_id": "T00001",
|
||||||
|
// "from_address": "郑州国际会展中心",
|
||||||
|
// "from_usernote": "1层",
|
||||||
|
// "to_address": "商务外环路17号",
|
||||||
|
// "to_usernote": "1楼101",
|
||||||
|
// }
|
||||||
|
// ans := api.signParam(testStr)
|
||||||
|
// fmt.Print(ans)
|
||||||
|
//}
|
||||||
|
//func TestRandStr(t *testing.T) {
|
||||||
|
// fmt.Print(randStr())
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////计算运单价格
|
||||||
|
//func TestGetWaybillPrice(t *testing.T) {
|
||||||
|
// needPayMoney, priceToken, err := api.GetOrderPrice(&GetOrderPriceReq{
|
||||||
|
// //BaseReqInfo: &BaseReqInfo{
|
||||||
|
// //Sign: "A9D4D4380B6012F2E9A00E37243306D4",
|
||||||
|
// // NonceStr: "01c3ce7ce7604ab49d12ec69dfbdcfe8",
|
||||||
|
// //Timestamp: "1672998838",
|
||||||
|
// // OpenID: "8d8464e7c9354c1e88a3f5afa2a7922e",
|
||||||
|
// // AppID: "55c4542ae60e4d348edcfc93b06dd302",
|
||||||
|
// //},
|
||||||
|
// OriginID: "T00001",
|
||||||
|
// FromAddress: "郑州国际会展中心",
|
||||||
|
// ToAddress: "商务外环路17号",
|
||||||
|
// CityName: "郑州市",
|
||||||
|
// SendType: "0",
|
||||||
|
// ToLat: "34.784275",
|
||||||
|
// ToLng: "113.736445",
|
||||||
|
// FromLat: "34.778494",
|
||||||
|
// FromLng: "113.736858",
|
||||||
|
// })
|
||||||
|
//
|
||||||
|
// fmt.Println(needPayMoney, priceToken, err)
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//type testStruct struct {
|
||||||
|
// name string
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func Test(t *testing.T) {
|
||||||
|
// var temp testStruct
|
||||||
|
// //var test bool
|
||||||
|
// //test = true
|
||||||
|
// //temp.name = "hdueu"
|
||||||
|
// fmt.Println(temp == testStruct{})
|
||||||
|
// //fmt.Print(utils.IsNil(temp))
|
||||||
|
//}
|
||||||
107
platformapi/uuptapi/uuptapi.go
Normal file
107
platformapi/uuptapi/uuptapi.go
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
package uuptapi
|
||||||
|
|
||||||
|
//
|
||||||
|
//import (
|
||||||
|
// "crypto/md5"
|
||||||
|
// "encoding/json"
|
||||||
|
// "fmt"
|
||||||
|
// "git.rosy.net.cn/baseapi/platformapi"
|
||||||
|
// "git.rosy.net.cn/baseapi/utils"
|
||||||
|
// "math/rand"
|
||||||
|
// "net/http"
|
||||||
|
// "sort"
|
||||||
|
// "strings"
|
||||||
|
// "time"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//const (
|
||||||
|
// BaseURL = "https://openapi.uupt.com/v2_0"
|
||||||
|
// ReturnSuccess = "ok"
|
||||||
|
// ReturnFail = "fail"
|
||||||
|
// signKey = "sign"
|
||||||
|
// secretKey = "secret"
|
||||||
|
// UUOpenID = "8d8464e7c9354c1e88a3f5afa2a7922e"
|
||||||
|
// UUAppID = "55c4542ae60e4d348edcfc93b06dd302"
|
||||||
|
// letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//func (a *API) MakeUURequestHead() map[string]interface{} {
|
||||||
|
// requestParam := make(map[string]interface{}, 5)
|
||||||
|
// requestParam["sign"] = a.sign
|
||||||
|
// requestParam["timestamp"] = a.timestamp
|
||||||
|
// requestParam["nonce_str"] = a.noncestr
|
||||||
|
// requestParam["openid"] = a.openid
|
||||||
|
// requestParam["appid"] = a.appid
|
||||||
|
// return requestParam
|
||||||
|
//}
|
||||||
|
//func New(appID, appKey, openID string) *API {
|
||||||
|
// if appID == "" {
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// return &API{
|
||||||
|
// appid: appID,
|
||||||
|
// appKey: appKey,
|
||||||
|
// openid: openID,
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (a *API) signParam(params map[string]interface{}) (sign string) {
|
||||||
|
// keyValues := make([]string, 0)
|
||||||
|
// for k, v := range params {
|
||||||
|
// if k != signKey {
|
||||||
|
// if temp := fmt.Sprint(v); temp != "" {
|
||||||
|
// keyValues = append(keyValues, k+"="+temp)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// sort.Sort(sort.StringSlice(keyValues)) //字典升序
|
||||||
|
// sign = strings.Join(keyValues, "&")
|
||||||
|
// sign += "&key=" + a.appKey //末尾拼接密钥
|
||||||
|
// sign = strings.ToUpper(sign) //大写
|
||||||
|
// return fmt.Sprintf("%X", md5.Sum([]byte(sign)))
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (a *API) AccessAPI(baseUrl, actionApi, method string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||||
|
// bizParams["timestamp"] = utils.Int64ToStr(time.Now().Unix() * 1000)
|
||||||
|
// bizParams["sign"] = a.signParam(bizParams)
|
||||||
|
// //序列化
|
||||||
|
// data, err := json.Marshal(bizParams)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// //完整请求url
|
||||||
|
// fullPath := utils.GenerateGetURL(baseUrl, actionApi, nil)
|
||||||
|
// //发送请求
|
||||||
|
// sendUrl := func() *http.Request {
|
||||||
|
// var request *http.Request
|
||||||
|
// if method == RequestPost {
|
||||||
|
// request, _ = http.NewRequest(http.MethodPost, fullPath, strings.NewReader(string(data)))
|
||||||
|
// } else {
|
||||||
|
// request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(baseUrl, actionApi, bizParams), nil)
|
||||||
|
// }
|
||||||
|
// return request
|
||||||
|
// }
|
||||||
|
// //数据解析
|
||||||
|
// dataMarshal := func(response *http.Response, bodyStr string, jsonResp map[string]interface{}) (errMsg string, err error) {
|
||||||
|
// if jsonResp == nil {
|
||||||
|
// return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
|
// }
|
||||||
|
// if jsonResp["return_code"] != ReturnSuccess {
|
||||||
|
// errMsg = platformapi.ErrLevelGeneralFail
|
||||||
|
// err = utils.NewErrorCode(jsonResp["return_msg"].(string), utils.Int64ToStr(utils.MustInterface2Int64(jsonResp["return_code"])))
|
||||||
|
// }
|
||||||
|
// retVal = jsonResp
|
||||||
|
// return errMsg, err
|
||||||
|
// }
|
||||||
|
// err = platformapi.AccessPlatformAPIWithRetry(a.client, sendUrl, a.config, dataMarshal)
|
||||||
|
// return retVal, err
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
////以下为辅助函数
|
||||||
|
//func randStr() string {
|
||||||
|
// b := make([]byte, 16)
|
||||||
|
// for i := range b {
|
||||||
|
// b[i] = letters[rand.Intn(len(letters))]
|
||||||
|
// }
|
||||||
|
// return string(b)
|
||||||
|
//}
|
||||||
31
platformapi/uuptapi/waybill.go
Normal file
31
platformapi/uuptapi/waybill.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package uuptapi
|
||||||
|
|
||||||
|
//
|
||||||
|
//import (
|
||||||
|
// "encoding/json"
|
||||||
|
// "git.rosy.net.cn/baseapi/utils"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
////计算订单价格
|
||||||
|
//func (a *API) GetOrderPrice(req *GetOrderPriceReq) (needPayMoney, priceToken string, err error) {
|
||||||
|
// preOrder := a.MakeUURequestHead()
|
||||||
|
// bytes, err := json.Marshal(req)
|
||||||
|
// if err != nil {
|
||||||
|
// return "", "", err
|
||||||
|
// }
|
||||||
|
// preOrder["param"] = string(bytes)
|
||||||
|
// resp, err := a.AccessAPI(BaseURL, "getorderprice.ashx", RequestPost, preOrder)
|
||||||
|
// if err != nil {
|
||||||
|
// return "", "", err
|
||||||
|
// }
|
||||||
|
// retVal := GetOrderPriceResp{}
|
||||||
|
// if err := json.Unmarshal([]byte(resp["param"].(string)), &retVal); err != nil {
|
||||||
|
// return "", "", err
|
||||||
|
// }
|
||||||
|
// con := retVal == GetOrderPriceResp{}
|
||||||
|
// if !utils.IsNil(retVal) && !con {
|
||||||
|
// needPayMoney = retVal.NeedPayMoney
|
||||||
|
// priceToken = retVal.PriceToken
|
||||||
|
// }
|
||||||
|
// return needPayMoney, priceToken, nil
|
||||||
|
//}
|
||||||
Reference in New Issue
Block a user