- 将美团配送门店相关的API单独拆分出来
- 去掉美团配送CheckCallbackValidation中的强制参数检查
This commit is contained in:
@@ -68,16 +68,14 @@ func (a *API) CheckCallbackValidation(request *http.Request) (callbackResponse *
|
|||||||
baseapi.SugarLogger.Infof("Signature is not ok, mine:%v, get:%v", sign, request.FormValue(signKey))
|
baseapi.SugarLogger.Infof("Signature is not ok, mine:%v, get:%v", sign, request.FormValue(signKey))
|
||||||
return SignatureIsNotOk
|
return SignatureIsNotOk
|
||||||
}
|
}
|
||||||
|
// for _, valueKey := range []string{"delivery_id", "mt_peisong_id", "order_id"} {
|
||||||
for _, valueKey := range []string{"delivery_id", "mt_peisong_id", "order_id"} {
|
// if request.FormValue(valueKey) == "" {
|
||||||
if request.FormValue(valueKey) == "" {
|
// baseapi.SugarLogger.Errorf("Missing mandatory param PostForm:%v, valueKey:%v", request.PostForm, valueKey)
|
||||||
baseapi.SugarLogger.Errorf("Missing mandatory param PostForm:%v, valueKey:%v", request.PostForm, valueKey)
|
// return &CallbackResponse{
|
||||||
return &CallbackResponse{
|
// Code: -1,
|
||||||
Code: -1,
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return Err2CallbackResponse(err, "")
|
return Err2CallbackResponse(err, "")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,21 +99,6 @@ const (
|
|||||||
CancelReasonRideerOther = 399
|
CancelReasonRideerOther = 399
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
ShopStatusAuditRejected = 10 // 审核驳回
|
|
||||||
ShopStatusAuditPassed = 20 // 审核通过
|
|
||||||
ShopStatusCreateSuccess = 30 // 创建成功
|
|
||||||
ShopStatusOnline = 40 // 上线可发单
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
ShopCategoryMarket = 120 // 生活超市
|
|
||||||
ShopCategoryMarketConvenience = 120001 // 便利店
|
|
||||||
|
|
||||||
ShopCategoryFruit = 150 // 生鲜果蔬
|
|
||||||
ShopCategoryFruitFruit = 150001 // 果蔬
|
|
||||||
)
|
|
||||||
|
|
||||||
type OrderInfoCommon struct {
|
type OrderInfoCommon struct {
|
||||||
DeliveryID int64
|
DeliveryID int64
|
||||||
MtPeisongID string
|
MtPeisongID string
|
||||||
@@ -170,35 +155,6 @@ type GoodsDetail struct {
|
|||||||
Goods []*GoodsItem `json:"goods"`
|
Goods []*GoodsItem `json:"goods"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BusinessHour struct {
|
|
||||||
BeginTime string `json:"beginTime"`
|
|
||||||
EndTime string `json:"endTime"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ShopInfo struct {
|
|
||||||
ShopID string `json:"shop_id,omitempty"`
|
|
||||||
ShopName string `json:"shop_name,omitempty"`
|
|
||||||
Category int `json:"category,omitempty"`
|
|
||||||
SecondCategory int `json:"second_category,omitempty"`
|
|
||||||
ContactName string `json:"contact_name,omitempty"`
|
|
||||||
ContactPhone string `json:"contact_phone,omitempty"`
|
|
||||||
ContactEmail string `json:"contact_email,omitempty"`
|
|
||||||
ShopAddress string `json:"shop_address,omitempty"`
|
|
||||||
ShopAddressDetail string `json:"shop_address_detail,omitempty"`
|
|
||||||
ShopLng int `json:"shop_lng,omitempty"`
|
|
||||||
ShopLat int `json:"shop_lat,omitempty"`
|
|
||||||
CoordinateType int `json:"coordinate_type"`
|
|
||||||
DeliveryServiceCodes string `json:"delivery_service_codes,omitempty"`
|
|
||||||
BusinessHours string `json:"business_hours,omitempty"`
|
|
||||||
|
|
||||||
// 以下为查询专有的
|
|
||||||
City int `json:"city,omitempty"`
|
|
||||||
DeliveryHours string `json:"delivery_hours,omitempty"`
|
|
||||||
Prebook int `json:"prebook,omitempty"`
|
|
||||||
PrebookOutOfBizTime int `json:"prebook_out_of_biz_time,omitempty"`
|
|
||||||
PrebookPeriod string `json:"prebook_period,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
appKey string
|
appKey string
|
||||||
secret string
|
secret string
|
||||||
@@ -330,25 +286,6 @@ func (a *API) CancelOrder(deliveryId int64, mtPeiSongId string, cancelReasonId i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) ShopCreate(shopInfo *ShopInfo) (status int, err error) {
|
|
||||||
params := utils.Struct2MapByJson(shopInfo)
|
|
||||||
result, err := a.AccessAPI("shop/create", params)
|
|
||||||
if err == nil {
|
|
||||||
status = int(utils.Interface2Int64WithDefault(result.Data["status"], 0))
|
|
||||||
}
|
|
||||||
return status, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) ShopQuery(shopID string) (shopInfo *ShopInfo, err error) {
|
|
||||||
result, err := a.AccessAPI("shop/query", map[string]interface{}{
|
|
||||||
"shop_id": shopID,
|
|
||||||
})
|
|
||||||
if err == nil {
|
|
||||||
err = utils.Map2StructByJson(result.Data, &shopInfo, false)
|
|
||||||
}
|
|
||||||
return shopInfo, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) simulateOrderBehavior(action string, deliveryId int64, mtPeiSongId string) (err error) {
|
func (a *API) simulateOrderBehavior(action string, deliveryId int64, mtPeiSongId string) (err error) {
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
"delivery_id": deliveryId,
|
"delivery_id": deliveryId,
|
||||||
@@ -377,12 +314,3 @@ func (a *API) SimulateRearrange(deliveryId int64, mtPeiSongId string) (err error
|
|||||||
func (a *API) SimulateReportException(deliveryId int64, mtPeiSongId string) (err error) {
|
func (a *API) SimulateReportException(deliveryId int64, mtPeiSongId string) (err error) {
|
||||||
return a.simulateOrderBehavior("reportException", deliveryId, mtPeiSongId)
|
return a.simulateOrderBehavior("reportException", deliveryId, mtPeiSongId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrShopNotExist(err error) bool {
|
|
||||||
if err != nil {
|
|
||||||
if errExt, ok := err.(*utils.ErrorWithCode); ok && errExt.IntCode() == ResponseCodeShopNotExist {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|||||||
84
platformapi/mtpsapi/shop.go
Normal file
84
platformapi/mtpsapi/shop.go
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
package mtpsapi
|
||||||
|
|
||||||
|
import "git.rosy.net.cn/baseapi/utils"
|
||||||
|
|
||||||
|
const (
|
||||||
|
ShopStatusAuditRejected = 10 // 审核驳回
|
||||||
|
ShopStatusAuditPassed = 20 // 审核通过
|
||||||
|
ShopStatusCreateSuccess = 30 // 创建成功
|
||||||
|
ShopStatusOnline = 40 // 上线可发单
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ShopCategoryMarket = 120 // 生活超市
|
||||||
|
ShopCategoryMarketConvenience = 120001 // 便利店
|
||||||
|
|
||||||
|
ShopCategoryFruit = 150 // 生鲜果蔬
|
||||||
|
ShopCategoryFruitFruit = 150001 // 果蔬
|
||||||
|
)
|
||||||
|
|
||||||
|
type BusinessHour struct {
|
||||||
|
BeginTime string `json:"beginTime"`
|
||||||
|
EndTime string `json:"endTime"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ShopInfo struct {
|
||||||
|
ShopID string `json:"shop_id,omitempty"`
|
||||||
|
ShopName string `json:"shop_name,omitempty"`
|
||||||
|
Category int `json:"category,omitempty"`
|
||||||
|
SecondCategory int `json:"second_category,omitempty"`
|
||||||
|
ContactName string `json:"contact_name,omitempty"`
|
||||||
|
ContactPhone string `json:"contact_phone,omitempty"`
|
||||||
|
ContactEmail string `json:"contact_email,omitempty"`
|
||||||
|
ShopAddress string `json:"shop_address,omitempty"`
|
||||||
|
ShopAddressDetail string `json:"shop_address_detail,omitempty"`
|
||||||
|
ShopLng int `json:"shop_lng,omitempty"`
|
||||||
|
ShopLat int `json:"shop_lat,omitempty"`
|
||||||
|
CoordinateType int `json:"coordinate_type"`
|
||||||
|
DeliveryServiceCodes string `json:"delivery_service_codes,omitempty"`
|
||||||
|
BusinessHours string `json:"business_hours,omitempty"`
|
||||||
|
|
||||||
|
// 以下为查询专有的
|
||||||
|
City int `json:"city,omitempty"`
|
||||||
|
DeliveryHours string `json:"delivery_hours,omitempty"`
|
||||||
|
Prebook int `json:"prebook,omitempty"`
|
||||||
|
PrebookOutOfBizTime int `json:"prebook_out_of_biz_time,omitempty"`
|
||||||
|
PrebookPeriod string `json:"prebook_period,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) ShopCreate(shopInfo *ShopInfo) (status int, err error) {
|
||||||
|
params := utils.Struct2MapByJson(shopInfo)
|
||||||
|
result, err := a.AccessAPI("shop/create", params)
|
||||||
|
if err == nil {
|
||||||
|
status = int(utils.Interface2Int64WithDefault(result.Data["status"], 0))
|
||||||
|
}
|
||||||
|
return status, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) ShopQuery(shopID string) (shopInfo *ShopInfo, err error) {
|
||||||
|
result, err := a.AccessAPI("shop/query", map[string]interface{}{
|
||||||
|
"shop_id": shopID,
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
err = utils.Map2StructByJson(result.Data, &shopInfo, false)
|
||||||
|
}
|
||||||
|
return shopInfo, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsErrShopNotExist(err error) bool {
|
||||||
|
if err != nil {
|
||||||
|
if errExt, ok := err.(*utils.ErrorWithCode); ok && errExt.IntCode() == ResponseCodeShopNotExist {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *API) SimulateShopStatus(shopID string, status int) (err error) {
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"shop_id": shopID,
|
||||||
|
"status": status,
|
||||||
|
}
|
||||||
|
_, err = a.AccessAPI("test/shop/status/callback", params)
|
||||||
|
return err
|
||||||
|
}
|
||||||
12
platformapi/mtpsapi/shop_test.go
Normal file
12
platformapi/mtpsapi/shop_test.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package mtpsapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSimulateShopStatus(t *testing.T) {
|
||||||
|
err := api.SimulateShopStatus("1", ShopStatusAuditRejected)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user