Merge branch 'master' of e.coding.net:rosydev/baseapi
This commit is contained in:
@@ -36,6 +36,8 @@ const (
|
|||||||
WaybillStatusWait4Courier = "4" // 等待分配骑士
|
WaybillStatusWait4Courier = "4" // 等待分配骑士
|
||||||
WaybillStatusCourierAccepted = "7" // 骑士接单
|
WaybillStatusCourierAccepted = "7" // 骑士接单
|
||||||
WaybillStatusCourierPickedup = "8" // 骑士取餐
|
WaybillStatusCourierPickedup = "8" // 骑士取餐
|
||||||
|
// 饿百在发送运单取消事件后,如果订单没有及时(具体时间未知)转出自送,则订单会被取消,且不会发送订单取消事件
|
||||||
|
// https://open-be.ele.me/dev/answer/reedit?list_id=23667&question=my
|
||||||
WaybillStatusDeliveryCancled = "15" // 配送取消
|
WaybillStatusDeliveryCancled = "15" // 配送取消
|
||||||
WaybillStatusFinished = "16" // 配送完成
|
WaybillStatusFinished = "16" // 配送完成
|
||||||
WaybillStatusExceptional = "17" // 配送异常
|
WaybillStatusExceptional = "17" // 配送异常
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestOrderGet(t *testing.T) {
|
func TestOrderGet(t *testing.T) {
|
||||||
result, err := api.OrderGet("1572950448227442318")
|
result, err := api.OrderGet("1574590633159550053")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
@@ -16,7 +16,7 @@ func TestOrderGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderGet2(t *testing.T) {
|
func TestOrderGet2(t *testing.T) {
|
||||||
result, err := api.OrderGet2("1572950448227442318")
|
result, err := api.OrderGet2("1574550169196474502")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
@@ -81,6 +81,13 @@ func TestOrderCallDelivery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOrderSwitchselfdelivery(t *testing.T) {
|
||||||
|
err := api.OrderSwitchselfdelivery("1574550169196474502")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestOrderSendOut(t *testing.T) {
|
func TestOrderSendOut(t *testing.T) {
|
||||||
err := api.OrderSendOut("1555731848221773250", "")
|
err := api.OrderSendOut("1555731848221773250", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -104,7 +111,7 @@ func TestOrderPrivateInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderDeliveryGet(t *testing.T) {
|
func TestOrderDeliveryGet(t *testing.T) {
|
||||||
result, err := api.OrderDeliveryGet("15421782068884")
|
result, err := api.OrderDeliveryGet("1574550169196474502")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
AfsPicPrefix = "http://img10.360buyimg.com/o2o"
|
AfsPicPrefix = "http://img10.360buyimg.com/o2o"
|
||||||
|
AfsPicPrefixHttps = "https://img10.360buyimg.com/o2o"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -675,11 +676,19 @@ func (a *API) AfsSubmit(OrderID, pin, questionTypeCode, questionDesc, questionPi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ProcessQuestionPic(questionPic string) (outQuestionPic string) {
|
func ProcessQuestionPic(questionPic string) (outQuestionPic string) {
|
||||||
|
const httpsPrefix = "https:"
|
||||||
if questionPic != "" {
|
if questionPic != "" {
|
||||||
picList := strings.Split(questionPic, ",")
|
picList := strings.Split(questionPic, ",")
|
||||||
picList2 := make([]string, len(picList))
|
var picList2 []string
|
||||||
for index, pic := range picList {
|
for _, pic := range picList {
|
||||||
picList2[index] = AfsPicPrefix + "/" + pic
|
baseURL := AfsPicPrefix
|
||||||
|
pic2 := strings.ReplaceAll(pic, httpsPrefix, "")
|
||||||
|
if pic2 != pic {
|
||||||
|
baseURL = AfsPicPrefixHttps
|
||||||
|
}
|
||||||
|
if pic2 = utils.TrimBlankChar(pic2); pic2 != "" {
|
||||||
|
picList2 = append(picList2, utils.GenerateGetURL(baseURL, pic2, nil))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
outQuestionPic = strings.Join(picList2, ",")
|
outQuestionPic = strings.Join(picList2, ",")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,3 +259,29 @@ func TestCheckSelfPickCode(t *testing.T) {
|
|||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestProcessQuestionPic(t *testing.T) {
|
||||||
|
for _, v := range [][]string{
|
||||||
|
[]string{
|
||||||
|
"http://img10.360buyimg.com/o2o/jfs/a.jpg",
|
||||||
|
",,,jfs/a.jpg",
|
||||||
|
},
|
||||||
|
[]string{
|
||||||
|
"http://img10.360buyimg.com/o2o/jfs/a.jpg,https://img10.360buyimg.com/o2o/jfs/b.jpg",
|
||||||
|
" , ,, jfs/a.jpg,https:jfs/b.jpg",
|
||||||
|
},
|
||||||
|
[]string{
|
||||||
|
"https://img10.360buyimg.com/o2o/jfs/a.jpg",
|
||||||
|
",https:jfs/a.jpg",
|
||||||
|
},
|
||||||
|
[]string{
|
||||||
|
"",
|
||||||
|
",https:",
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
str := ProcessQuestionPic(v[1])
|
||||||
|
if str != v[0] {
|
||||||
|
t.Fatalf("%s, desired:%s, but its:%s", v[1], v[0], str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ func TestUpdateStoreFreightConfigNew(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPrivilegeSearchUser(t *testing.T) {
|
func TestPrivilegeSearchUser(t *testing.T) {
|
||||||
result, err := api.PrivilegeSearchUser(1, 1)
|
result, _, _, err := api.PrivilegeSearchUser(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,6 +175,11 @@ type CouponActInfo struct {
|
|||||||
Status int `json:"status"` // 活动状态
|
Status int `json:"status"` // 活动状态
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ActItemErrMsg struct {
|
||||||
|
ActID int64 `json:"act_id"`
|
||||||
|
ErrorMsg string `json:"error_msg"`
|
||||||
|
}
|
||||||
|
|
||||||
// 批量创建指定商品满减活动或创建店内满减活动
|
// 批量创建指定商品满减活动或创建店内满减活动
|
||||||
// http://developer.waimai.meituan.com/home/docDetail/255
|
// http://developer.waimai.meituan.com/home/docDetail/255
|
||||||
func (a *API) FullDiscountBatchSave(poiCode string, actInfo *FullDiscountActInfo, actList []*FullDiscountActDetail, actSkuList []*FullDiscountSku) (actIDList []int64, err error) {
|
func (a *API) FullDiscountBatchSave(poiCode string, actInfo *FullDiscountActInfo, actList []*FullDiscountActDetail, actSkuList []*FullDiscountSku) (actIDList []int64, err error) {
|
||||||
@@ -318,15 +323,19 @@ func (a *API) FulllDiscountShippingFeeBatchDelete(poiCode string, actIDList []st
|
|||||||
|
|
||||||
// 批量创建或更新零售折扣商品
|
// 批量创建或更新零售折扣商品
|
||||||
// http://developer.waimai.meituan.com/home/docDetail/287
|
// http://developer.waimai.meituan.com/home/docDetail/287
|
||||||
func (a *API) RetailDiscountBatchSave(poiCode string, actData []*RetailDiscountActData) (actResult []*RetailDiscountActResult, err error) {
|
func (a *API) RetailDiscountBatchSave(poiCode string, actData []*RetailDiscountActData) (actResult []*RetailDiscountActResult /*failedList []*AppFoodResult, */, err error) {
|
||||||
result, err := a.AccessAPI2("act/retail/discount/batchsave", false, map[string]interface{}{
|
result, err := a.AccessAPI2("act/retail/discount/batchsave", false, map[string]interface{}{
|
||||||
KeyAppPoiCode: poiCode,
|
KeyAppPoiCode: poiCode,
|
||||||
"act_data": string(utils.MustMarshal(actData)),
|
"act_data": string(utils.MustMarshal(actData)),
|
||||||
}, resultKeySuccessMsg, "")
|
}, "", "")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = utils.UnmarshalUseNumber([]byte(result.(string)), &actResult)
|
resultMap := result.(map[string]interface{})
|
||||||
|
err = utils.UnmarshalUseNumber([]byte(resultMap[resultKeySuccessMsg].(string)), &actResult)
|
||||||
|
// if err == nil {
|
||||||
|
// failedList, err = handleRetailBatchResult(resultMap[resultKeyMsg])
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
return actResult, err
|
return actResult /*failedList, */, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询门店零售折扣商品
|
// 查询门店零售折扣商品
|
||||||
@@ -367,6 +376,16 @@ func (a *API) RetailDiscountDelete(poiCode string, actIDList []string) (err erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ParseErr4RetailDiscountDelete(err error) (failedList []*ActItemErrMsg) {
|
||||||
|
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
|
var mapData map[string]interface{}
|
||||||
|
if err := utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &mapData); err == nil {
|
||||||
|
utils.Map2StructByJson(mapData["error_list"], &failedList, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return failedList
|
||||||
|
}
|
||||||
|
|
||||||
// 批量修改零售折扣商品当日活动库存
|
// 批量修改零售折扣商品当日活动库存
|
||||||
// http://developer.waimai.meituan.com/home/docDetail/290
|
// http://developer.waimai.meituan.com/home/docDetail/290
|
||||||
func (a *API) RetailDiscountBatchStock(poiCode, actDataList []*RetailDiscountActDataLimit) (err error) {
|
func (a *API) RetailDiscountBatchStock(poiCode, actDataList []*RetailDiscountActDataLimit) (err error) {
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ func TestFulllDiscountShippingFeeList(t *testing.T) {
|
|||||||
|
|
||||||
func TestRetailDiscountBatchSave(t *testing.T) {
|
func TestRetailDiscountBatchSave(t *testing.T) {
|
||||||
result, err := api.RetailDiscountBatchSave(testPoiCode, []*RetailDiscountActData{&RetailDiscountActData{
|
result, err := api.RetailDiscountBatchSave(testPoiCode, []*RetailDiscountActData{&RetailDiscountActData{
|
||||||
AppFoodCode: "5246",
|
AppFoodCode: "1140",
|
||||||
UserType: UserTypeAll,
|
UserType: UserTypeAll,
|
||||||
StartTime: time.Now().Unix(),
|
StartTime: time.Now().Unix(),
|
||||||
EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||||
OrderLimit: 1,
|
OrderLimit: 1,
|
||||||
DayLimit: 1,
|
DayLimit: 1,
|
||||||
SettingType: SettingTypeAsDiscount,
|
SettingType: SettingTypeAsDiscount,
|
||||||
DiscountCoefficient: 9.7,
|
DiscountCoefficient: 0.97,
|
||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -102,3 +102,13 @@ func TestInStoreCouponList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseErr4RetailDiscountDelete(t *testing.T) {
|
||||||
|
errStr := `
|
||||||
|
{"error_list":[{"act_id":1053302130,"error_msg":"活动ID不存在"},{"act_id":1053302127,"error_msg":"活动ID不存在"},{"act_id":1053302128,"error_msg":"活动ID不存在"},{"act_id":1053302129,"error_msg":"活动ID不存在"},{"act_id":1053302135,"error_msg":"活动ID不存在"},{"act_id":1053302132,"error_msg":"活动ID不存在"},{"act_id":1053302123,"error_msg":"活动ID不存在"},{"act_id":1053302125,"error_msg":"活动ID不存在"},{"act_id":1053302124,"error_msg":"活动ID不存在"},{"act_id":1053302133,"error_msg":"活动ID不存在"},{"act_id":1053302126,"error_msg":"活动ID不存在"},{"act_id":1053302134,"error_msg":"活动ID不存在"},{"act_id":1053302131,"error_msg":"活动ID不存在"}]}
|
||||||
|
|
||||||
|
`
|
||||||
|
errExt := utils.NewErrorCode(errStr, "")
|
||||||
|
failedList := ParseErr4RetailDiscountDelete(errExt)
|
||||||
|
t.Log(utils.Format4Output(failedList, false))
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,3 +13,10 @@ func TestCommentQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCommentAddReply(t *testing.T) {
|
||||||
|
err := api.CommentAddReply("24617232", 2947288966, "非常抱歉让您没有得到十分满意的购物体验,我们会及时与您联系进行确认并解决问题!")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
|||||||
if jsonResult1 == nil {
|
if jsonResult1 == nil {
|
||||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
}
|
}
|
||||||
retVal = jsonResult1[resultKey]
|
|
||||||
if errObj, ok := jsonResult1["error"]; ok {
|
if errObj, ok := jsonResult1["error"]; ok {
|
||||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||||
errorInfo := errObj.(map[string]interface{})
|
errorInfo := errObj.(map[string]interface{})
|
||||||
@@ -176,6 +175,10 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
|||||||
return platformapi.ErrLevelRecoverableErr, newErr
|
return platformapi.ErrLevelRecoverableErr, newErr
|
||||||
}
|
}
|
||||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||||
|
} else if resultKey != "" {
|
||||||
|
retVal = jsonResult1[resultKey]
|
||||||
|
} else {
|
||||||
|
retVal = jsonResult1
|
||||||
}
|
}
|
||||||
return platformapi.ErrLevelSuccess, nil
|
return platformapi.ErrLevelSuccess, nil
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user