564 lines
21 KiB
Go
564 lines
21 KiB
Go
package mtwmapi
|
||
|
||
import (
|
||
"time"
|
||
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
)
|
||
|
||
const (
|
||
MaxBatchPullPhoneNumberLimit = 1000
|
||
)
|
||
|
||
// http://developer.waimai.meituan.com/home/doc/food/99
|
||
const (
|
||
OrderStatusUserCommitted = "1" // 用户已提交订单
|
||
OrderStatusNew = "2" // 向商家推送订单
|
||
OrderStatusReceived = "3" // 商家已收到
|
||
OrderStatusAccepted = "4" // 商家已确认
|
||
OrderStatusDelivering = "6" // 订单配送中
|
||
OrderStatusDelivered = "7" // 订单已送达
|
||
OrderStatusFinished = "8" // 订单已完成
|
||
OrderStatusCanceled = "9" // 订单已取消
|
||
)
|
||
|
||
const (
|
||
WaybillStatusWait4Delivery = "0" // 配送单发往配送
|
||
WaybillStatusPending = "5" // 配送压单
|
||
WaybillStatusAccepted = "10" // 配送单已确认
|
||
WaybillStatusCourierArrived = "15" // 骑手已到店
|
||
WaybillStatusPickedup = "20" // 骑手已取餐
|
||
WaybillStatusDelivered = "40" // 骑手已送达
|
||
WaybillStatusCanceled = "100" // 配送单已取消
|
||
)
|
||
|
||
// APP方URL 推送用户或客服取消订单(必接)
|
||
const (
|
||
CancelReasonAcceptTimeout = 1001 // 系统取消,超时未确认
|
||
CancelReasonPayTimeout = 1002 // 系统取消,在线支付订单15分钟未支付
|
||
CancelReasonPayCanceled = 1101 // 用户取消,在线支付中取消
|
||
CancelReasonCancelBeforeAccepted = 1102 // 用户取消,商家确认前取消
|
||
CancelReasonRefundCanceled = 1103 // 用户取消,用户退款取消
|
||
CancelReasonWrongOrder = 1201 // 客服取消,用户下错单
|
||
CancelReasonUserTest = 1202 // 客服取消,用户测试
|
||
CancelReasonDuplicatedOrder = 1203 // 客服取消,重复订单
|
||
CancelReasonCSOther = 1204 // 客服取消,其他原因
|
||
CancelReasonOther = 1301 // 其他原因
|
||
)
|
||
|
||
const (
|
||
ResTypePending = 0 // 未处理
|
||
ResTypeMerchantRefused = 1 // 商家驳回退款请求
|
||
ResTypeMerchantAgreed = 2 // 商家同意退款
|
||
ResTypeCSRefused = 3 // 客服驳回退款请求
|
||
ResTypeCSAgreed = 4 // 客服帮商家同意退款
|
||
ResTypeTimeoutAutoAgreed = 5 // 超过3小时自动同意
|
||
ResTypeAutoAgreed = 6 // 系统自动确认
|
||
ResTypeUserCancelApply = 7 // 用户取消退款申请
|
||
ResTypeUserCancelComplain = 8 // 用户取消退款申诉
|
||
)
|
||
|
||
const (
|
||
NotifyTypeApply = "apply" // 发起全款退款
|
||
NotifyTypePartyApply = "part" // 发起部分退款
|
||
NotifyTypeSuccess = "agree" // 确认退款
|
||
NotifyTypeReject = "reject" // 驳回退款
|
||
NotifyTypeCancelRefund = "cancelRefund" // 用户取消退款申请
|
||
NotifyTypeCancelRefundComplaint = "cancelRefundComplaint" // 用户取消退款申诉
|
||
)
|
||
|
||
const (
|
||
UserApplyCancelWaitMinute = 30 // 用户申请退款后,商家未在30分钟内(大连锁商家为3小时内)处理退款请求,系统将自动同意退款
|
||
)
|
||
|
||
const (
|
||
RefundTypeAll = 1
|
||
RefundTypePart = 2
|
||
)
|
||
|
||
const (
|
||
ExtrasPromotionTypeTaoCanZeng = 4 // 套餐赠
|
||
ExtrasPromotionTypeManZeng = 5 // 满赠
|
||
|
||
ExtrasPromotionTypeTeJiaCai = 7 // 特价菜
|
||
ExtrasPromotionTypeZheKouCai = 17 // 折扣菜
|
||
ExtrasPromotionTypeSecondHalfPrice = 20 // 第2份半价活动
|
||
ExtrasPromotionTypeShanGouBaoPin = 56 // 闪购爆品
|
||
)
|
||
|
||
const (
|
||
MaxGap4GetOrderIdByDaySeq = 100
|
||
)
|
||
|
||
type RefundSku struct {
|
||
AppFoodCode string `json:"app_food_code"`
|
||
SkuID string `json:"sku_id,omitempty"`
|
||
Count int `json:"count"`
|
||
}
|
||
|
||
type RefundSkuDetail struct {
|
||
AppFoodCode string `json:"app_food_code"`
|
||
BoxNum float64 `json:"box_num"`
|
||
BoxPrice float64 `json:"box_price"`
|
||
Count int `json:"count"`
|
||
FoodName string `json:"food_name"`
|
||
FoodPrice float64 `json:"food_price"`
|
||
OriginFoodPrice float64 `json:"origin_food_price"`
|
||
RefundPrice float64 `json:"refund_price"`
|
||
SkuID string `json:"sku_id"`
|
||
Spec string `json:"spec"`
|
||
}
|
||
|
||
type RefundOrderDetail struct {
|
||
ApplyReason string `json:"apply_reason"`
|
||
ApplyType int `json:"apply_type"`
|
||
CTime int64 `json:"ctime"`
|
||
Money float64 `json:"money"`
|
||
OrderID int64 `json:"order_id"`
|
||
Pictures string `json:"pictures"`
|
||
PictureList []string `json:"pictureList"`
|
||
RefundType int `json:"refund_type"`
|
||
ResReason string `json:"res_reason"`
|
||
ResType int `json:"res_type"`
|
||
UTime int64 `json:"utime"`
|
||
WmAppRetailForOrderPartRefundList []*RefundSkuDetail `json:"wmAppRetailForOrderPartRefundList"`
|
||
WmOrderIDView int64 `json:"wm_order_id_view"`
|
||
}
|
||
|
||
type OrderExtraInfo struct {
|
||
ActDetailID int `json:"act_detail_id,omitempty"`
|
||
MtCharge float64 `json:"mt_charge,omitempty"`
|
||
PoiCharge float64 `json:"poi_charge,omitempty"`
|
||
ReduceFee float64 `json:"reduce_fee,omitempty"`
|
||
Remark string `json:"remark,omitempty"`
|
||
Type int `json:"type,omitempty"`
|
||
|
||
RiderFee float64 `json:"rider_fee,omitempty"`
|
||
}
|
||
|
||
type FoodInfo struct {
|
||
AppFoodCode string `json:"app_food_code"`
|
||
BoxNum float64 `json:"box_num"`
|
||
BoxPrice float64 `json:"box_price"`
|
||
CartID int `json:"cart_id"`
|
||
FoodDiscount float64 `json:"food_discount"`
|
||
FoodName string `json:"food_name"`
|
||
FoodProperty string `json:"food_property"`
|
||
Price float64 `json:"price"`
|
||
Quantity int `json:"quantity"`
|
||
SkuID string `json:"sku_id"`
|
||
Spec string `json:"spec"`
|
||
Unit string `json:"unit"`
|
||
}
|
||
|
||
type CanRefundFoodInfo struct {
|
||
AppFoodCode string `json:"app_food_code"`
|
||
BoxNum float64 `json:"box_num"`
|
||
BoxPrice float64 `json:"box_price"`
|
||
Count int `json:"count"`
|
||
FoodName string `json:"food_name"`
|
||
FoodPrice float64 `json:"food_price"`
|
||
IsRefundDifference int `json:"is_refund_difference"`
|
||
OriginFoodPrice float64 `json:"origin_food_price"`
|
||
RefundPrice float64 `json:"refund_price"`
|
||
SkuID string `json:"sku_id"`
|
||
}
|
||
|
||
type WmAppOrderActDetailInfo struct {
|
||
ActID int64 `json:"act_id"`
|
||
Count int `json:"count"`
|
||
MtCharge float64 `json:"mtCharge"`
|
||
PoiCharge float64 `json:"poiCharge"`
|
||
Remark string `json:"remark"`
|
||
Type int `json:"type"`
|
||
}
|
||
|
||
type SkuBenefitDetailInfo struct {
|
||
ActivityPrice float64 `json:"activityPrice"`
|
||
AppFoodCode string `json:"app_food_code"`
|
||
BoxNumber float64 `json:"boxNumber"`
|
||
BoxPrice float64 `json:"boxPrice"`
|
||
Count int `json:"count"`
|
||
Name string `json:"name"`
|
||
OriginPrice float64 `json:"originPrice"`
|
||
SkuID string `json:"sku_id"`
|
||
TotalActivityPrice float64 `json:"totalActivityPrice"`
|
||
TotalBoxPrice float64 `json:"totalBoxPrice"`
|
||
TotalMtCharge float64 `json:"totalMtCharge"`
|
||
TotalOriginPrice float64 `json:"totalOriginPrice"`
|
||
TotalPoiCharge float64 `json:"totalPoiCharge"`
|
||
TotalReducePrice float64 `json:"totalReducePrice"`
|
||
WmAppOrderActDetails []*WmAppOrderActDetailInfo `json:"wmAppOrderActDetails"`
|
||
}
|
||
|
||
type ActOrderChargeInfo struct {
|
||
Comment string `json:"comment"`
|
||
FeeTypeDesc string `json:"feeTypeDesc"`
|
||
FeeTypeID int `json:"feeTypeId"`
|
||
MoneyCent int64 `json:"moneyCent"`
|
||
}
|
||
|
||
type PoiReceiveDetailInfo struct {
|
||
ActOrderChargeByMt []*ActOrderChargeInfo `json:"actOrderChargeByMt"`
|
||
ActOrderChargeByPoi []*ActOrderChargeInfo `json:"actOrderChargeByPoi"`
|
||
FoodShareFeeChargeByPoi int64 `json:"foodShareFeeChargeByPoi"`
|
||
LogisticsFee int64 `json:"logisticsFee"`
|
||
OnlinePayment int64 `json:"onlinePayment"`
|
||
WmPoiReceiveCent int64 `json:"wmPoiReceiveCent"`
|
||
}
|
||
|
||
type OrderInfo struct {
|
||
AppOrderCode string `json:"app_order_code"`
|
||
AppPoiCode string `json:"app_poi_code"`
|
||
AvgSendTime float64 `json:"avg_send_time"`
|
||
BackupRecipientPhone string `json:"backup_recipient_phone"`
|
||
Caution string `json:"caution"`
|
||
CityID int `json:"city_id"`
|
||
Ctime int64 `json:"ctime"`
|
||
DaySeq int `json:"day_seq"`
|
||
DeliveryTime int `json:"delivery_time"`
|
||
Detail string `json:"detail"`
|
||
DetailList []*FoodInfo `json:"detailList"`
|
||
DinnersNumber int `json:"dinners_number"`
|
||
ExpectDeliverTime int `json:"expect_deliver_time"`
|
||
Extras string `json:"extras"`
|
||
ExtraList []*OrderExtraInfo `json:"extraList"`
|
||
HasInvoiced int `json:"has_invoiced"`
|
||
InvoiceTitle string `json:"invoice_title"`
|
||
IsFavorites bool `json:"is_favorites"`
|
||
IsPoiFirstOrder bool `json:"is_poi_first_order"`
|
||
IsPre int `json:"is_pre"`
|
||
IsThirdShipping int `json:"is_third_shipping"`
|
||
Latitude float64 `json:"latitude"`
|
||
LogisticsCode string `json:"logistics_code"`
|
||
Longitude float64 `json:"longitude"`
|
||
OrderCompletedTime int `json:"order_completed_time"`
|
||
OrderConfirmTime int `json:"order_confirm_time"`
|
||
OrderID int64 `json:"order_id"`
|
||
OrderSendTime int `json:"order_send_time"`
|
||
OriginalPrice float64 `json:"original_price"`
|
||
PackageBagMoney int `json:"package_bag_money"`
|
||
PayType int `json:"pay_type"`
|
||
PickType int `json:"pick_type"`
|
||
PoiReceiveDetail string `json:"poi_receive_detail"`
|
||
PoiReceiveDetailPtr *PoiReceiveDetailInfo `json:"poi_receive_detail_ptr"`
|
||
RecipientAddress string `json:"recipient_address"`
|
||
RecipientName string `json:"recipient_name"`
|
||
RecipientPhone string `json:"recipient_phone"`
|
||
Remark string `json:"remark"`
|
||
Result string `json:"result"`
|
||
ShipperPhone string `json:"shipper_phone"`
|
||
ShippingFee float64 `json:"shipping_fee"`
|
||
ShippingType int `json:"shipping_type"`
|
||
SkuBenefitDetail string `json:"sku_benefit_detail"`
|
||
SkuBenefitDetailList []*SkuBenefitDetailInfo `json:"sku_benefit_detail_list"`
|
||
SourceID int `json:"source_id"`
|
||
Status int `json:"status"`
|
||
TaxpayerID string `json:"taxpayer_id"`
|
||
Total float64 `json:"total"`
|
||
Utime int64 `json:"utime"`
|
||
WmOrderIDView int64 `json:"wm_order_id_view"`
|
||
WmPoiAddress string `json:"wm_poi_address"`
|
||
WmPoiID int `json:"wm_poi_id"`
|
||
WmPoiName string `json:"wm_poi_name"`
|
||
WmPoiPhone string `json:"wm_poi_phone"`
|
||
}
|
||
|
||
type GetOrderActDetailParamAct struct {
|
||
Type int `json:"type,omitempty"`
|
||
ActID int64 `json:"act_id,omitempty"`
|
||
}
|
||
|
||
type GetOrderActDetailParam struct {
|
||
OrderID int64 `json:"order_id_view"`
|
||
ActParam []*GetOrderActDetailParamAct `json:"act_param,omitempty"`
|
||
}
|
||
|
||
type OrderActInfo struct {
|
||
OrderID int64 `json:"order_id_view"`
|
||
ActDetailList []*struct {
|
||
ActID int64 `json:"act_id"`
|
||
CouponDetail interface{} `json:"coupon_detail"`
|
||
EndTime int64 `json:"end_time"`
|
||
GiftsDetail interface{} `json:"gifts_detail"`
|
||
PoiDetail interface{} `json:"poi_detail"`
|
||
ProductDetail struct {
|
||
AppFoodCode string `json:"app_food_code"`
|
||
CategorySeqence int `json:"category_seqence"`
|
||
Charge string `json:"charge"`
|
||
DayLimit int `json:"day_limit"`
|
||
Name string `json:"name"`
|
||
OrderLimit int `json:"order_limit"`
|
||
Period string `json:"period"`
|
||
Policy string `json:"policy"`
|
||
SettingType int `json:"setting_type"`
|
||
UserType int `json:"user_type"`
|
||
WeeksTime string `json:"weeks_time"`
|
||
} `json:"product_detail"`
|
||
Remark string `json:"remark"`
|
||
StartTime int64 `json:"start_time"`
|
||
Status int `json:"status"`
|
||
Type int `json:"type"`
|
||
TypeName string `json:"type_name"`
|
||
} `json:"act_detail_list"`
|
||
}
|
||
|
||
type GetOrderIdByDaySeqResult struct {
|
||
Result string `json:"result"`
|
||
OrderIDs []int64 `json:"order_ids"`
|
||
}
|
||
|
||
func (a *API) OrderReceived(orderID int64) (err error) {
|
||
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderConfirm(orderID int64) (err error) {
|
||
_, err = a.AccessAPI("order/confirm", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderCancel(orderID int64, cancelReason string, cancelReasonCode int) (err error) {
|
||
_, err = a.AccessAPI("order/cancel", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
"reason": cancelReason,
|
||
"reason_code": cancelReasonCode,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderDelivering(orderID int64) (err error) {
|
||
_, err = a.AccessAPI("order/delivering", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderArrived(orderID int64) (err error) {
|
||
_, err = a.AccessAPI("order/arrived", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderRefundAgree(orderID int64, reason string) (err error) {
|
||
_, err = a.AccessAPI("order/refund/agree", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
"reason": reason,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderRefundReject(orderID int64, reason string) (err error) {
|
||
_, err = a.AccessAPI("order/refund/reject", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
"reason": reason,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderApplyPartRefund(orderID int64, reason string, removeSkuList []*RefundSku) (err error) {
|
||
_, err = a.AccessAPI("order/applyPartRefund", false, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
"reason": reason,
|
||
"food_data": string(utils.MustMarshal(removeSkuList)),
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderViewStatus(orderID int64) (status int, err error) {
|
||
result, err := a.AccessAPI("order/viewstatus", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
if err == nil {
|
||
return int(utils.MustInterface2Int64(result.(map[string]interface{})["status"])), nil
|
||
}
|
||
return 0, err
|
||
}
|
||
|
||
func (a *API) OrderGetOrderDetail(orderID int64, isMTLogistics bool) (orderInfo map[string]interface{}, err error) {
|
||
params := map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
}
|
||
if isMTLogistics {
|
||
params["is_mt_logistics"] = 1
|
||
}
|
||
result, err := a.AccessAPI("order/getOrderDetail", true, params)
|
||
if err == nil {
|
||
return result.(map[string]interface{}), nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) OrderGetOrderDetail2(orderID int64, isMTLogistics bool) (orderInfo *OrderInfo, err error) {
|
||
orderMap, err := a.OrderGetOrderDetail(orderID, isMTLogistics)
|
||
if err == nil {
|
||
if err = utils.Map2StructByJson(orderMap, &orderInfo, false); err == nil {
|
||
if orderInfo.Detail != "" {
|
||
err = utils.UnmarshalUseNumber([]byte(orderInfo.Detail), &orderInfo.DetailList)
|
||
}
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
if orderInfo.Extras != "" {
|
||
err = utils.UnmarshalUseNumber([]byte(orderInfo.Extras), &orderInfo.ExtraList)
|
||
}
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
if orderInfo.SkuBenefitDetail != "" {
|
||
err = utils.UnmarshalUseNumber([]byte(orderInfo.SkuBenefitDetail), &orderInfo.SkuBenefitDetailList)
|
||
}
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
if orderInfo.PoiReceiveDetail != "" {
|
||
err = utils.UnmarshalUseNumber([]byte(orderInfo.PoiReceiveDetail), &orderInfo.PoiReceiveDetailPtr)
|
||
}
|
||
}
|
||
}
|
||
return orderInfo, err
|
||
}
|
||
|
||
func (a *API) OrderGetPartRefundFoods(orderID int64) (canRefundFoodList []*CanRefundFoodInfo, err error) {
|
||
params := map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
}
|
||
result, err := a.AccessAPI("order/getPartRefundFoods", true, params)
|
||
if err == nil {
|
||
err = utils.Map2StructByJson(result, &canRefundFoodList, false)
|
||
}
|
||
return canRefundFoodList, err
|
||
}
|
||
|
||
func (a *API) OrderLogisticsPush(orderID int64, reason string) (err error) {
|
||
_, err = a.AccessAPI("order/logistics/push", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderLogisticsCancel(orderID int64, reason string) (err error) {
|
||
_, err = a.AccessAPI("order/logistics/cancel", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderLogisticsStatus(orderID int64) (status map[string]interface{}, err error) {
|
||
result, err := a.AccessAPI("order/logistics/status", true, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
if err == nil {
|
||
return result.(map[string]interface{}), nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
// limit最大为MaxBatchPullPhoneNumberLimit = 1000
|
||
func (a *API) OrderBatchPullPhoneNumber(poiCode string, offset, limit int) (realNumberList []map[string]interface{}, err error) {
|
||
params := map[string]interface{}{
|
||
"offset": offset,
|
||
"limit": limit,
|
||
}
|
||
if poiCode != "" {
|
||
params[KeyAppPoiCode] = poiCode
|
||
}
|
||
result, err := a.AccessAPI("order/batchPullPhoneNumber", false, params)
|
||
if err == nil {
|
||
return utils.Slice2MapSlice(result.([]interface{})), nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
// 专快混配送转为商家自配送
|
||
func (a *API) OrderLogisticsChange2Self(orderID int64) (err error) {
|
||
_, err = a.AccessAPI("order/logistics/change/poi_self", false, map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
// refundOrderDetailList不能定义为[]*RefundOrderDetail,否则会有解析错误,原因不明
|
||
func (a *API) GetOrderRefundDetail(orderID int64, refundType int) (refundOrderDetailList []*RefundOrderDetail, err error) {
|
||
params := map[string]interface{}{
|
||
"wm_order_id_view": orderID,
|
||
}
|
||
if refundType > 0 {
|
||
params["refund_type"] = refundType
|
||
}
|
||
result, err := a.AccessAPI("ecommerce/order/getOrderRefundDetail", true, params)
|
||
if err == nil {
|
||
if err = utils.Map2StructByJson(result, &refundOrderDetailList, false); err == nil {
|
||
for _, v := range refundOrderDetailList {
|
||
if v.Pictures != "" {
|
||
if err = utils.UnmarshalUseNumber([]byte(v.Pictures), &v.PictureList); err != nil {
|
||
return nil, err
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return refundOrderDetailList, err
|
||
}
|
||
|
||
func (a *API) GetOrderActDetail(queryData []*GetOrderActDetailParam) (orderActList []*OrderActInfo, err error) {
|
||
params := map[string]interface{}{
|
||
"query_data": string(utils.MustMarshal(queryData)),
|
||
}
|
||
result, err := a.AccessAPI("ecommerce/order/getOrderActDetail", true, params)
|
||
if err == nil {
|
||
err = utils.Map2StructByJson(result, &orderActList, false)
|
||
}
|
||
return orderActList, err
|
||
}
|
||
|
||
func (a *API) GetOrderDaySeq(poiCode string) (daySeq int, err error) {
|
||
params := map[string]interface{}{
|
||
KeyAppPoiCode: poiCode,
|
||
}
|
||
result, err := a.AccessAPI("order/getOrderDaySeq", true, params)
|
||
if err == nil {
|
||
daySeq = int(utils.MustInterface2Int64(result.(map[string]interface{})["day_seq"]))
|
||
}
|
||
return daySeq, err
|
||
}
|
||
|
||
// 订单流水号的开始序号,门店内每日的订单流水号都是从1开始。
|
||
// 订单流水号的结束序号,注意开始流水号与结束流水号的跨度需小于100,即差值最大为99
|
||
// 这个函数在给定的区间范围全部没有订单时,返回错误808,但如果有部分订单,返回的错误是0
|
||
func (a *API) GetOrderIdByDaySeq(poiCode string, dateTime time.Time, seqStart, seqEnd int) (vendorOrderIDs []int64, err error) {
|
||
params := map[string]interface{}{
|
||
KeyAppPoiCode: poiCode,
|
||
"date_time": dateTime.Format("20060102"),
|
||
"day_seq_start": seqStart,
|
||
"day_seq_end": seqEnd,
|
||
}
|
||
result, err := a.AccessAPI("ecommerce/order/getOrderIdByDaySeq", true, params)
|
||
if extErr, ok := err.(*utils.ErrorWithCode); (ok && extErr.IntCode() == 0) || err == nil {
|
||
var data GetOrderIdByDaySeqResult
|
||
if err2 := utils.UnmarshalUseNumber([]byte(utils.Interface2String(result)), &data); err2 == nil {
|
||
vendorOrderIDs = data.OrderIDs
|
||
}
|
||
}
|
||
return vendorOrderIDs, err
|
||
}
|
||
|
||
// 众包配送单追加小费
|
||
// https://developer.waimai.meituan.com/home/docDetail/158
|
||
func (a *API) OrderUpdateTip(orderID int64, tipAmount float64) (err error) {
|
||
params := map[string]interface{}{
|
||
KeyOrderID: orderID,
|
||
"tip_amount": tipAmount,
|
||
}
|
||
_, err = a.AccessAPI("order/zhongbao/update/tip", true, params)
|
||
return err
|
||
}
|