diff --git a/business/jxcallback/orderman/waybill.go b/business/jxcallback/orderman/waybill.go index 543ae4fe9..68e547d86 100644 --- a/business/jxcallback/orderman/waybill.go +++ b/business/jxcallback/orderman/waybill.go @@ -214,7 +214,7 @@ func (w *OrderManager) addWaybillStatus(bill *model.Waybill, db *dao.DaoDB, addP "status_time": bill.StatusTime, }, addParams) utils.CallFuncLogError(func() error { - _, err = db.Db.QueryTable("waybill").Filter("vendor_waybill_id", bill.VendorWaybillID).Filter("waybill_vendor_id", bill.WaybillVendorID).Filter("status__lte", bill.Status).Update(params) + _, err = db.Db.QueryTable("waybill").Filter("vendor_waybill_id", bill.VendorWaybillID).Filter("waybill_vendor_id", bill.WaybillVendorID).Filter("status", bill.Status).Update(params) return err }, "addWaybillStatus update waybill status, bill:%v", bill) } else { diff --git a/business/partner/purchase/ebai/order.go b/business/partner/purchase/ebai/order.go index 8cf8e5aaf..1559c2455 100644 --- a/business/partner/purchase/ebai/order.go +++ b/business/partner/purchase/ebai/order.go @@ -1,6 +1,7 @@ package ebai import ( + "encoding/json" "errors" "fmt" "math" @@ -658,9 +659,16 @@ func (c *PurchaseHandler) GetOrderRealMobile(ctx *jxcontext.Context, order *mode func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAcceptIt bool, reason string) (err error) { if globals.EnableEbaiStoreWrite { + var afsOrderInfo *model.AfsOrder + result, err := api.EbaiAPI.OrderPartRefundGet(order.VendorOrderID) + if err != nil { + return err + } + afsOrderInfo = CurPurchaseHandler.AfsOrderDetail2Financial(result) + if isAcceptIt { err = api.EbaiAPI.OrderAgreeRefund(&ebaiapi.RefundOrderExamine{ - ReverseOrderId: "", + ReverseOrderId: afsOrderInfo.AfsOrderID, OrderId: order.VendorOrderID, IdempotentId: utils.Int64ToStr(time.Now().UnixNano()), ActionType: ebaiapi.RefundTypeAgree, @@ -670,16 +678,28 @@ func (c *PurchaseHandler) AgreeOrRefuseCancel(ctx *jxcontext.Context, order *mod if reason == "" { return fmt.Errorf("拒绝退单时,请填写拒单原因") } - - err = api.EbaiAPI.OrderDisagreeRefund(&ebaiapi.RefundOrderExamine{ - ReverseOrderId: "", + param := &ebaiapi.RefundOrderExamine{ + ReverseOrderId: afsOrderInfo.AfsOrderID, OrderId: order.VendorOrderID, IdempotentId: utils.Int64ToStr(time.Now().UnixNano()), - ActionType: ebaiapi.RefundTypeAgree, + ActionType: ebaiapi.RefundTypeRefuse, ReasonCode: "7001", ReasonRemarks: reason, RefundProductList: "", - }) + } + refundProductList := make([]*ebaiapi.RefundProductList, 0, 0) + date, _ := api.EbaiAPI.GetReverseOrder(order.VendorOrderID) + for _, v := range date { + refundProduct := &ebaiapi.RefundProductList{ + SubBizOrderId: v.(map[string]interface{})["sub_biz_order_id"].(string), + PlatformSkuId: utils.Int64ToStr(utils.Interface2Int64WithDefault(v.(map[string]interface{})["platform_sku_id"], 0)), + } + + refundProductList = append(refundProductList, refundProduct) + } + refundProductListStr, _ := json.Marshal(refundProductList) + param.RefundProductList = string(refundProductListStr) + err = api.EbaiAPI.OrderDisagreeRefund(param) } } return err diff --git a/business/partner/purchase/ebai/order_afs.go b/business/partner/purchase/ebai/order_afs.go index 988b078a5..c5a91019c 100644 --- a/business/partner/purchase/ebai/order_afs.go +++ b/business/partner/purchase/ebai/order_afs.go @@ -1,6 +1,7 @@ package ebai import ( + "encoding/json" "errors" "fmt" "strings" @@ -238,6 +239,19 @@ func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *mod ReasonRemarks: reason, RefundProductList: "", } + refundProductList := make([]*ebaiapi.RefundProductList, 0, 0) + date, _ := api.EbaiAPI.GetReverseOrder(order.VendorOrderID) + for _, v := range date { + refundProduct := &ebaiapi.RefundProductList{ + SubBizOrderId: v.(map[string]interface{})["sub_biz_order_id"].(string), + PlatformSkuId: utils.Int64ToStr(utils.Interface2Int64WithDefault(v.(map[string]interface{})["platform_sku_id"], 0)), + } + + refundProductList = append(refundProductList, refundProduct) + } + refundProductListStr, _ := json.Marshal(refundProductList) + param.RefundProductList = string(refundProductListStr) + err = api.EbaiAPI.OrderDisagreeReturnGoods(param) } else if approveType == partner.AfsApproveTypeRefusedToRefundMoney { return errors.New("此平台暂时不支持")