package partner

import (
	"git.rosy.net.cn/baseapi/utils"
	"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
	"git.rosy.net.cn/jx-callback/business/model"
)

type OrderPhoneNumberInfo struct {
	VendorOrderID string
	PhoneNumber   string
}

type OrderAfsInfo struct {
	VendorOrderID     string `json:"vendorOrderID"`
	AfsOrderID        string `json:"afsOrderID"`
	AfsTotalShopMoney int64  `json:"afsTotalShopMoney"`
}

type ReasonList struct {
	Code          string `json:"code"`
	Content       string `json:"content"`
	PreCancelCode int    `json:"preCancelCode"`
	PreCancelMsg  string `json:"preCancelMsg"`
}

// 取消跑腿配送请求参数
type CancelOrderParam struct {
	ReasonCode    string `json:"reason_code"`    // 取消原因code 请开发者一定要先调用
	DetailContent string `json:"detail_content"` // 取消原因
	AppPoiCode    string `json:"app_poi_code"`   // 门店号
	OrderId       string `json:"order_id"`       // 订单id
}

type IPurchasePlatformOrderHandler interface {
	Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder)
	GetOrder(vendorOrgCode, vendorOrderID, vendorStoreID string) (order *model.GoodsOrder, err error)
	GetOrderStatus(vendorOrgCode, vendorOrderID string) (status int, err error)
	GetStatusActionTimeout(order *model.GoodsOrder, statusType, status int) (params *StatusActionParams)

	AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error)
	PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string) (err error)

	AcceptOrRefuseFailedGetOrder(ctx *jxcontext.Context, order *model.GoodsOrder, isAcceptIt bool) (err error)
	CallCourier(ctx *jxcontext.Context, order *model.GoodsOrder) (err error)         // 取货失败后再次招唤平台配送
	ConfirmReceiveGoods(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) // 投递失败后确认收到退货

	// 是否可能转商家自送
	CanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool, err error)
	// 将订单从购物平台配送转为自送
	Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error)
	// 将订单从购物平台配送转为自送后又送达
	Swtich2SelfDelivered(order *model.GoodsOrder, userName string) (err error)
	// 完全自送的门店表示开始配送
	SelfDeliverDelivering(order *model.GoodsOrder, userName string) (err error)
	// 转自配送时取消非专送混合送门店取消理由
	GetCancelDeliveryReason(order *model.GoodsOrder) (string, error)
	// 取消美团外卖理由转使用三方配送
	CancelLogisticsByWmOrderId(order *model.GoodsOrder, reasonCode, detailContent, appPoiCode, orderId string) error
	// 获取运单状态
	OrderLogisticsStatus(orderId string) (*utils.RiderInfo, error)
	// 完全自送的门店表示配送完成
	SelfDeliverDelivered(order *model.GoodsOrder, userName string) (err error)

	GetOrderRealMobile(ctx *jxcontext.Context, order *model.GoodsOrder) (mobile string, err error)
	ReplyOrderComment(ctx *jxcontext.Context, vendorOrgCode string, orderComment *model.OrderComment, replyComment string) (err error)
	AgreeOrRefuseCancel(ctx *jxcontext.Context, order *model.GoodsOrder, isAgree bool, reason string, refundParam interface{}) (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)

	// 售后
	// 发起全款退款
	RefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (err error)
	// 发起部分退款
	PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error)
	// 审核售后单申请
	AgreeOrRefuseRefund(ctx *jxcontext.Context, order *model.AfsOrder, approveType int, reason string, review map[string]interface{}) (err error)
	// // 确认收到退货
	ConfirmReceivedReturnGoods(ctx *jxcontext.Context, order *model.AfsOrder) (err error)
	//获取自提单取货码
	GetSelfTakeCode(ctx *jxcontext.Context, order *model.GoodsOrder) (code string, err error)
	ConfirmSelfTake(ctx *jxcontext.Context, order *model.GoodsOrder, selfTakeCode string) (err error)
	GetOrderAfsInfo(ctx *jxcontext.Context, vendorOrderID, afsOrderID string) (orderAfsInfo *OrderAfsInfo, err error)
	//投诉骑手
	ComplaintRider(vendorOrderId string, resonID int, resonContent string) (err error)
	//推送订单骑手信息
	GetOrderRider(vendorOrgCode, vendorStoreID string, param map[string]interface{}) (err error)

	// 获取各个平台订单的结算信息
	GetOrderSettleAccounts(order *model.GoodsOrder) (int64, error)
	// GetPlatformLogisticsFee 获取美团自配送订单的配送费
	GetPlatformLogisticsFee(order *model.GoodsOrder) (int64, error)

	// 美团和饿百的订单索赔
	ApplyCompensationOrder(order *model.GoodsOrder) (string, error)
}

type IAddWaybillTip interface {
	// GetWaybillTip 获取添加小费
	GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error)
	// UpdateWaybillTip 添加小费
	UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error)
}

type IRidderPositionGetter interface {
	GetRidderPosition(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (lng, lat float64, err error)
}
