Merge branch 'master' of https://e.coding.net/rosydev/baseapi
This commit is contained in:
@@ -115,26 +115,26 @@ type AbnormalReportNotify struct {
|
||||
}
|
||||
|
||||
// 获取门店状态回调消息
|
||||
func (a *API) GetChainstoreStatusNotify(request *http.Request) (shopStatusMsg *ChainstoreStatusNotify, callbackResponse *CallbackResponse) {
|
||||
func (a *API) GetChainstoreStatusNotify(request *http.Request) (shopStatusMsg *ChainstoreStatusNotify, storeNotify *ShortStatus, callbackResponse *CallbackResponse) {
|
||||
data, err := ioutil.ReadAll(request.Body)
|
||||
if err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
storeNotify := &ShortStatus{}
|
||||
storeNotify = &ShortStatus{}
|
||||
if err := json.Unmarshal(data, &storeNotify); err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
fnNotify := &ChainstoreStatusNotify{}
|
||||
if err := json.Unmarshal([]byte(storeNotify.BusinessData), fnNotify); err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
return fnNotify, SuccessResponse
|
||||
return fnNotify, storeNotify, SuccessResponse
|
||||
}
|
||||
|
||||
// 获取订单状态回调消息
|
||||
@@ -159,26 +159,26 @@ func (a *API) GetChainOrderStatusNotify(request *http.Request) (shopStatusMsg *O
|
||||
}
|
||||
|
||||
// 异常配送
|
||||
func (a *API) GetChainAbnormaltatusNotify(request *http.Request) (shopStatusMsg *AbnormalStatusNotify, callbackResponse *CallbackResponse) {
|
||||
func (a *API) GetChainAbnormaltatusNotify(request *http.Request) (shopStatusMsg *AbnormalStatusNotify, storeNotify *ShortStatus, callbackResponse *CallbackResponse) {
|
||||
data, err := ioutil.ReadAll(request.Body)
|
||||
if err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
storeNotify := &ShortStatus{}
|
||||
storeNotify = &ShortStatus{}
|
||||
if err := json.Unmarshal(data, &storeNotify); err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
fnNotify := &AbnormalStatusNotify{}
|
||||
if err := json.Unmarshal([]byte(storeNotify.BusinessData), fnNotify); err != nil {
|
||||
callbackResponse = &CallbackResponse{Code: -1}
|
||||
return nil, callbackResponse
|
||||
return nil, nil, callbackResponse
|
||||
}
|
||||
|
||||
return fnNotify, SuccessResponse
|
||||
return fnNotify, storeNotify, SuccessResponse
|
||||
}
|
||||
|
||||
func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *CallbackResponse) {
|
||||
|
||||
@@ -132,31 +132,44 @@ func IsErrShopExist(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
const (
|
||||
FengNiaoCallbackTypeOrder = "order" // 订单
|
||||
FengNiaoCallbackTypeStore = "store" // 门店
|
||||
FengNiaoCallbackTypeAbnormal = "abnormal" // 异常
|
||||
FengNiaoCallbackTypeToken = "token" // token更新
|
||||
)
|
||||
|
||||
// HttpToGuoYuanFN 订单消息推送果园
|
||||
func HttpToGuoYuanFN(param map[string]interface{}, requestType string) (*http.Response, error) {
|
||||
var paramData []byte
|
||||
var err error
|
||||
if requestType == "order" || requestType == "waybill" {
|
||||
param["data"] = utils.Format4Output(param["data"], false)
|
||||
paramData, err = json.Marshal([]interface{}{param})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
paramData, err = json.Marshal(param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//if requestType == "order" || requestType == "waybill" {
|
||||
// param["data"] = utils.Format4Output(param["data"], false)
|
||||
// paramData, err = json.Marshal([]interface{}{param})
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//} else {
|
||||
// paramData, err = json.Marshal(param)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//}
|
||||
paramData, err = json.Marshal(param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body := strings.NewReader(string(paramData))
|
||||
url := ""
|
||||
switch requestType {
|
||||
case "store": // 订单相关
|
||||
case FengNiaoCallbackTypeStore:
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnStore"
|
||||
case "order": // 门店
|
||||
case FengNiaoCallbackTypeOrder:
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnOrder"
|
||||
case "abnormal": // 异常
|
||||
case FengNiaoCallbackTypeAbnormal:
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnAbnormal"
|
||||
case FengNiaoCallbackTypeToken:
|
||||
url = "http://callback-jxgy.jxc4.com/fn/fnToken"
|
||||
}
|
||||
httpReq, err := http.NewRequest(http.MethodPost, url, body)
|
||||
if err != nil {
|
||||
|
||||
@@ -239,6 +239,14 @@ func TestDeleteActSku(t *testing.T) {
|
||||
|
||||
}
|
||||
func TestSync(t *testing.T) {
|
||||
ans := 1 & 4
|
||||
fmt.Println(ans)
|
||||
aa := &struct {
|
||||
Token string `json:"token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}{
|
||||
Token: "11",
|
||||
RefreshToken: "222",
|
||||
}
|
||||
|
||||
fmt.Println(utils.Struct2MapByJson(aa))
|
||||
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// 菜市
|
||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
|
||||
// 果园
|
||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_u368I2OxTY4ys4wWuVVMOQ") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_qO_Kv9pX4lHVTb2IX19JzQ") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
cookieStr := `
|
||||
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||
`
|
||||
|
||||
@@ -765,6 +765,12 @@ func (a *API) OrderStatusAndPsInfo(params map[string]interface{}) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// ApplyCompensation 取消的订单申请订单赔付
|
||||
func (a *API) ApplyCompensation(param *ApplyCompensationRes) (err error) {
|
||||
_, err = a.AccessAPI2("order/applyCompensation", false, utils.Struct2MapByJson(param), resultKeySuccessMsg, "")
|
||||
return err
|
||||
}
|
||||
|
||||
// 获取取消跑腿理由刘表
|
||||
// https://open-shangou.meituan.com/home/docDetail/482
|
||||
func (a *API) GetCancelDeliveryReason(orderId int64, appPoiCode string) (string, error) {
|
||||
@@ -784,21 +790,6 @@ func (a *API) GetCancelDeliveryReason(orderId int64, appPoiCode string) (string,
|
||||
return string(list), nil
|
||||
}
|
||||
|
||||
type DeliveryData struct {
|
||||
Code int `json:"code"`
|
||||
Title string `json:"title"`
|
||||
ReasonList []*ReasonList `json:"reasonList"`
|
||||
Msg string `json:"msg"`
|
||||
DeliveryStatus int `json:"deliveryStatus"`
|
||||
}
|
||||
|
||||
type ReasonList struct {
|
||||
Code string `json:"code"`
|
||||
Content string `json:"content"`
|
||||
PreCancelCode int `json:"preCancelCode"`
|
||||
PreCancelMsg string `json:"preCancelMsg"`
|
||||
}
|
||||
|
||||
// 取消跑腿配送
|
||||
func (a *API) CancelLogisticsByWmOrderId(reasonCode, detailContent, appPoiCode, orderId string) error {
|
||||
param := &CancelOrderParam{
|
||||
@@ -821,19 +812,3 @@ func (a *API) CancelLogisticsByWmOrderId(reasonCode, detailContent, appPoiCode,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ResultMsg struct {
|
||||
Data string `json:"data"`
|
||||
Error *struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
}
|
||||
|
||||
// 取消跑腿配送请求参数
|
||||
type CancelOrderParam struct {
|
||||
ReasonCode string `json:"reason_code"` // 取消原因code 请开发者一定要先调用
|
||||
DetailContent string `json:"detail_content"` // 取消原因
|
||||
AppPoiCode string `json:"app_poi_code"` // 门店号
|
||||
OrderId string `json:"order_id"` // 订单id
|
||||
}
|
||||
|
||||
@@ -5,6 +5,11 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
ApplyCompensationStatusOne = 110 // 第一次申请赔付
|
||||
ApplyCompensationStatusTwo = 120 // 第二次申请赔付
|
||||
)
|
||||
|
||||
type DistributeOrderDetail struct {
|
||||
WmOrderID int `json:"wm_order_id"`
|
||||
WmPoiID int `json:"wm_poi_id"`
|
||||
@@ -39,6 +44,50 @@ type DistributeOrderDetail struct {
|
||||
DelayPushSecond int `json:"delay_push_second"`
|
||||
}
|
||||
|
||||
type DeliveryData struct {
|
||||
Code int `json:"code"`
|
||||
Title string `json:"title"`
|
||||
ReasonList []*ReasonList `json:"reasonList"`
|
||||
Msg string `json:"msg"`
|
||||
DeliveryStatus int `json:"deliveryStatus"`
|
||||
}
|
||||
|
||||
type ReasonList struct {
|
||||
Code string `json:"code"`
|
||||
Content string `json:"content"`
|
||||
PreCancelCode int `json:"preCancelCode"`
|
||||
PreCancelMsg string `json:"preCancelMsg"`
|
||||
}
|
||||
|
||||
type ResultMsg struct {
|
||||
Data string `json:"data"`
|
||||
Error *struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyCompensationRes 申请赔付
|
||||
type ApplyCompensationRes struct {
|
||||
OrderId int64 `json:"order_id"` // 订单id
|
||||
Reason string `json:"reason"` // 原因
|
||||
ApplyStatus int `json:"apply_status"` // 申请状态类型:110-第一次申请;120-第二次申诉。
|
||||
Amount float64 `json:"amount"` // 申请赔付金额,单位是元
|
||||
//FoodData []FoodDataList `json:"food_data"` // 惨损商品列表
|
||||
}
|
||||
type FoodDataList struct {
|
||||
AppSpuCode string `json:"app_spu_code"` // 即商家中台系统里商品的编码
|
||||
SkuId string `json:"sku_id"` // SKU码(商家的规格编码)
|
||||
}
|
||||
|
||||
// 取消跑腿配送请求参数
|
||||
type CancelOrderParam struct {
|
||||
ReasonCode string `json:"reason_code"` // 取消原因code 请开发者一定要先调用
|
||||
DetailContent string `json:"detail_content"` // 取消原因
|
||||
AppPoiCode string `json:"app_poi_code"` // 门店号
|
||||
OrderId string `json:"order_id"` // 订单id
|
||||
}
|
||||
|
||||
//美团骑手修改小费,单位为元,最多小数点后一位
|
||||
//order/receive/processed/w/distribute/tipAmount/v2?ignoreSetRouterProxy=true
|
||||
func (a *API) OrderModityTips(orderID, poiCode string, tipAmount float64) (err error) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func TestOrderViewStatus(t *testing.T) {
|
||||
@@ -228,54 +227,16 @@ func TestOrderDelivering(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// 88 67 【组合菜】尖椒茄子(茄子500g 青尖椒200g)700g/组(茄子500g 青椒200g)
|
||||
// 90 60
|
||||
func TestLen(t *testing.T) {
|
||||
aa := "【组合菜】尖椒茄子(茄子500g 青尖椒200g)700g/组(茄子500g 青椒200g)"
|
||||
var count int // 中文
|
||||
var punctZh int // 中文标点
|
||||
var punctEn int // 英文标点
|
||||
var punctAZ int // 字母
|
||||
var punctNum int // 字母
|
||||
var spance int // 空格
|
||||
for _, v := range aa {
|
||||
if unicode.Is(unicode.Han, v) { // 中文
|
||||
count++
|
||||
continue
|
||||
}
|
||||
if unicode.IsPunct(v) { // 字符
|
||||
if v >= 1000 {
|
||||
fmt.Println(v)
|
||||
punctZh++
|
||||
} else {
|
||||
punctEn++
|
||||
}
|
||||
continue
|
||||
}
|
||||
if unicode.IsLetter(v) {
|
||||
punctAZ++
|
||||
continue
|
||||
}
|
||||
if unicode.IsNumber(v) {
|
||||
punctNum++
|
||||
continue
|
||||
}
|
||||
if unicode.IsSpace(v) {
|
||||
spance++
|
||||
continue
|
||||
}
|
||||
func TestApplyCompensation(t *testing.T) {
|
||||
param := &ApplyCompensationRes{
|
||||
OrderId: 3500902110034359123,
|
||||
Reason: "申请退款",
|
||||
ApplyStatus: 110,
|
||||
Amount: 35.31,
|
||||
//FoodData: nil,
|
||||
}
|
||||
err := api.ApplyCompensation(param)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
fmt.Println("count:= ", count)
|
||||
fmt.Println("count:= ", punctZh)
|
||||
fmt.Println("count:= ", punctEn)
|
||||
fmt.Println("count:= ", punctAZ)
|
||||
fmt.Println("count:= ", punctNum)
|
||||
|
||||
fmt.Println("all = ", (count*2)+(punctZh*2)+punctEn+punctAZ+punctNum+spance)
|
||||
}
|
||||
|
||||
func TestName(t *testing.T) {
|
||||
data := map[int]int{101: 1, 102: 1, 103: 1}
|
||||
|
||||
fmt.Println(data[1] == 1)
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ func (a *API) Print(sn, content, voice string) (string, error) {
|
||||
VoicePlayInterval: 3,
|
||||
Copies: 1,
|
||||
})
|
||||
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return "", errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user