- IPurchasePlatformHandler中添加
AgreeOrRefuseRefund CancelOrder AdjustOrder
This commit is contained in:
@@ -75,6 +75,13 @@ func GetShowStoreIDFromOrder(order *model.GoodsOrder) (retVal int) {
|
||||
return order.JxStoreID
|
||||
}
|
||||
|
||||
func GetSkuIDFromOrderSku(sku *model.OrderSku) (skuID int) {
|
||||
if sku.JxSkuID > 0 {
|
||||
return sku.JxSkuID
|
||||
}
|
||||
return sku.SkuID
|
||||
}
|
||||
|
||||
func SplitUniversalOrderID(universalOrderID string) (orderID string, vendorID int) {
|
||||
index := strings.Index(universalOrderID, "|")
|
||||
if index != -1 {
|
||||
|
||||
@@ -133,6 +133,8 @@ type IStoreManager interface {
|
||||
// 所有非以Sync,Refresh开头的函数不用自己清理sync_status标记(VendorSync统一处理)
|
||||
|
||||
type IPurchasePlatformHandler interface {
|
||||
GetVendorID() int
|
||||
|
||||
GetStatusFromVendorStatus(vendorStatus string) int
|
||||
Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder)
|
||||
GetOrder(vendorOrderID string) (order *model.GoodsOrder, err error)
|
||||
@@ -153,6 +155,15 @@ type IPurchasePlatformHandler interface {
|
||||
// 完全自送的门店表示配送完成
|
||||
SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error)
|
||||
|
||||
GetOrderRealMobile(ctx *jxcontext.Context, order *model.GoodsOrder) (mobile string, err error)
|
||||
|
||||
ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error)
|
||||
|
||||
AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error)
|
||||
CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error)
|
||||
// order.Skus要包含原始订单中的Sku信息,removedSkuList中是要移除的Sku信息
|
||||
AdjustOrder(ctx *jxcontext.Context, order *model.GoodsOrder, removedSkuList []*model.OrderSku, reason string) (err error)
|
||||
|
||||
////////
|
||||
// Store
|
||||
ReadStore(vendorStoreID string) (store *model.Store, err error)
|
||||
@@ -167,10 +178,6 @@ type IPurchasePlatformHandler interface {
|
||||
// !!!注意,此操作会先清除门店已有的商品,一般用于初始化,小心使用
|
||||
FullSyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error)
|
||||
DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error)
|
||||
GetVendorID() int
|
||||
GetOrderRealMobile(ctx *jxcontext.Context, order *model.GoodsOrder) (mobile string, err error)
|
||||
|
||||
ReplyOrderComment(ctx *jxcontext.Context, orderComment *model.OrderComment, replyComment string) (err error)
|
||||
UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error)
|
||||
GetStoreStatus(ctx *jxcontext.Context, vendorStoreID string) (storeStatus int, err error)
|
||||
}
|
||||
|
||||
@@ -347,3 +347,35 @@ func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *mode
|
||||
mobile, err = api.EbaiAPI.GetRealMobile4Order(order.VendorOrderID)
|
||||
return mobile, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if isAgree {
|
||||
err = api.EbaiAPI.OrderAgreeRefund(order.VendorOrderID)
|
||||
} else {
|
||||
err = api.EbaiAPI.OrderDisagreeRefund(order.VendorOrderID, reason)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.OrderCancel(order.VendorOrderID, ebaiapi.CancelTypeCustom, reason)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.GoodsOrder, removedSkuList []*model.OrderSku, reason string) (err error) {
|
||||
var skuList []*ebaiapi.RefundSku
|
||||
for _, sku := range removedSkuList {
|
||||
skuList = append(skuList, &ebaiapi.RefundSku{
|
||||
CustomeSkuID: utils.Int2Str(jxutils.GetSkuIDFromOrderSku(sku)),
|
||||
Number: utils.Int2Str(sku.Count),
|
||||
})
|
||||
}
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
err = api.EbaiAPI.OrderPartRefund(order.VendorOrderID, skuList)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -331,3 +331,15 @@ func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *mode
|
||||
err = errors.New("饿了么还未实现GetOrderRealMobile")
|
||||
return mobile, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.GoodsOrder, removedSkuList []*model.OrderSku, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -297,3 +298,44 @@ func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *mode
|
||||
mobile, err = api.JdAPI.GetRealMobile4Order(order.VendorOrderID, order.VendorStoreID)
|
||||
return mobile, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.JdAPI.OrderCancelOperate(order.VendorOrderID, isAgree, ctx.GetUserName(), reason)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||
err = errors.New("京东到家不支持主动取消订单,请联系用户取消")
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.GoodsOrder, removedSkuList []*model.OrderSku, reason string) (err error) {
|
||||
removedSkuMap := make(map[int]*model.OrderSku)
|
||||
for _, sku := range removedSkuList {
|
||||
removedSkuMap[jxutils.GetSkuIDFromOrderSku(sku)] = sku
|
||||
}
|
||||
var oaosAdjustDTOList []*jdapi.OAOSAdjustDTO
|
||||
for _, sku := range order.Skus {
|
||||
skuID := jxutils.GetSkuIDFromOrderSku(sku)
|
||||
tmp := &jdapi.OAOSAdjustDTO{
|
||||
OutSkuID: utils.Int2Str(skuID),
|
||||
SkuCount: sku.Count,
|
||||
}
|
||||
if removedSkuMap[skuID] != nil {
|
||||
if removedSkuMap[skuID].Count >= sku.Count {
|
||||
tmp = nil
|
||||
} else {
|
||||
tmp.SkuCount -= removedSkuMap[skuID].Count
|
||||
}
|
||||
}
|
||||
if tmp != nil {
|
||||
oaosAdjustDTOList = append(oaosAdjustDTOList, tmp)
|
||||
}
|
||||
}
|
||||
if globals.EnableStoreWrite {
|
||||
err = api.JdAPI.AdjustOrder(order.VendorOrderID, ctx.GetUserName(), reason, oaosAdjustDTOList)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
}
|
||||
} else {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.OrderCancel(utils.Str2Int64(order.VendorOrderID))
|
||||
err = api.MtwmAPI.OrderCancel(utils.Str2Int64(order.VendorOrderID), "bu", mtwmapi.CancelReasonOther)
|
||||
}
|
||||
}
|
||||
return err
|
||||
@@ -314,3 +314,37 @@ func (c *PurchaseHandler) GetStatusActionTimeout(order *model.GoodsOrder, status
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
if isAgree {
|
||||
err = api.MtwmAPI.OrderRefundAgree(utils.Str2Int64(order.VendorOrderID), reason)
|
||||
} else {
|
||||
err = api.MtwmAPI.OrderRefundReject(utils.Str2Int64(order.VendorOrderID), reason)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.OrderCancel(utils.Str2Int64(order.VendorOrderID), reason, mtwmapi.CancelReasonOther)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.GoodsOrder, removedSkuList []*model.OrderSku, reason string) (err error) {
|
||||
var skuList []*mtwmapi.RefundSku
|
||||
for _, sku := range removedSkuList {
|
||||
skuID := utils.Int2Str(jxutils.GetSkuIDFromOrderSku(sku))
|
||||
skuList = append(skuList, &mtwmapi.RefundSku{
|
||||
AppFoodCode: skuID,
|
||||
SkuID: skuID,
|
||||
Count: sku.Count,
|
||||
})
|
||||
}
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.OrderApplyPartRefund(utils.Str2Int64(order.VendorOrderID), reason, skuList)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -341,3 +341,15 @@ func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *mode
|
||||
err = errors.New("微盟微商城还未实现GetOrderRealMobile")
|
||||
return mobile, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) AdjustOrder(ctx *jxcontext.Context, order *model.GoodsOrder, removedSkuList []*model.OrderSku, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user