package tiktok_api

const RequestSuccessCode = 10000
const RequestSuccessRepeatedShipment = 50002 // 订单已发货，不允许再次执行发货
const TiktokExpressCode = "chengdouruoxi"

const (
	CallbackSuccessCode = 0
	CallbackSuccess     = "success"
	CallbackFailCode    = 1000
	CallbackFail        = "fail"
)

// 订单消息回调类型(正向订单)
const (
	CallbackCreatedOrderMsgTagId         = "100" // 创建订单回调   ok
	CallbackPayOrderMsgTagId             = "101" // 支付订单回调	ok
	CallbackWaitOrderMsgTagId            = "110" // 支付订待处理   ok
	CallbackPartGoodsMsgTagId            = "108" // 部分发货回调   ok
	CallbackPartAllGoodsMsgTagId         = "102" // 商品发货完成回调 ok
	CallbackCancelOrderMsgTagId          = "106" // 取消订单回调
	CallbackSuccessOrderMsgTagId         = "103" // 确认收货订单回调
	CallbackWayBillChangeOrderMsgTagId   = "104" // 物流消息变更
	CallbackReceivingChangeOrderMsgTagId = "105" // 收货地址变更(商家确认后触发)
	CallbackChangeMoneyMsgTagId          = "109" // 卖家修改订单/运单金额
	CallbackApplyUpdateAddressMsgTagId   = "111" // 买家申请修改配送信息
	CallbackBusinessRemarkMsgTagId       = "113" // 卖家添加备注消息的
	CallbackSendOrderTimeChangeMsgTagId  = "126" // 订单发货时效变更
)

// 订单状态 order_status(回调消息状态)
const (
	CallBackCreateOrderStatus  = 1   // 订单状态1:创建/卖家修改订单金额运费
	CallBackPayOrderStatus     = 2   // 2支付/卖家发货消息的status值为"2"(部分)/收货地址变更
	CallBackWaitOrderStatus    = 105 // 订单等待处理状态105
	CallBackSendAllOrderStatus = 3   // 商家全部发货(已发货)/物流消息变更
	CallBackCancelOrderStatus  = 4   // 取消订单装填
	CallBackSuccessOrderStatus = 5   // 订单交易完成
)

// 订单状态(正向订单创建状态)
const (
	CreateOrderStatusWaitPay         = 1   // 1待支付
	CreateOrderStatusStockUp         = 2   // 2备货中(代发货)
	CreateOrderStatusDelivery        = 3   // 3发货
	CreateOrderStatusCancel          = 4   // 4取消
	CreateOrderStatusOver            = 5   // 5完成
	CreateOrderStatusBeginRefund     = 21  // 21发货前退款完成
	CreateOrderStatusEndRefund       = 22  // 22发货后退款
	CreateOrderStatusReceiptRefund   = 39  // 39收货后退款
	CreateOrderStatusPartialDelivery = 101 // 101部分发货
	CreateOrderStatusSomePay         = 103 // 103部分支付
	CreateOrderStatusAllPay          = 105 // 105已支付
)

// 订单售后状态
const (
	AfterSaleStatusApply          = 6  // 申请售后
	AfterSaleStatusRefuse         = 27 // 拒绝售后申请
	AfterSaleStatusSuccess        = 12 // 售后成功
	AfterSaleStatusLoading        = 7  // 售后退货中
	AfterSaleStatusSendBag        = 11 // 售后已发货
	AfterSaleStatusRefuseBag      = 29 // 售后退货拒绝
	AfterSaleStatusChangeBag      = 13 // 【换货返回：换货售后换货商家发货】，【补寄返回：补寄待用户收货】
	AfterSaleStatusReplenishment  = 14 // 【换货返回：（换货）售后换货用户收货】，【补寄返回：（补寄）用户已收货】
	AfterSaleStatusRefuseFail     = 28 // 售后失败
	AfterSaleStatusCancelOrder    = 51 // 取消订单
	AfterSaleStatusReverseSuccess = 53 // 逆向交易已完成
)

// 支付类型
const (
	PayMethodPayOnArrival   = 0  // 到付
	PayMethodWeChat         = 1  // 微信支付
	PayMethodAliPay         = 2  // 支付宝
	PayMethodCard           = 4  // 银行卡
	PayMethodTiktok         = 5  // 抖音钱包
	PayMethodNo             = 7  // 无需支付
	PayMethodByStages       = 8  // dou分期
	PayMethodNewCard        = 9  // 新卡支付
	PayMethodUsePay         = 12 // 先用后付
	PayMethodCombinationPay = 13 // 组合支付
)

// OrderComeLuBan 订单业务类型，表示买家从哪里看到的这个商品、产生了订单
const (
	OrderComeLuBan       = 1  // 鲁班广告
	OrderComeLianMeng    = 2  // 联盟
	OrderComeShop        = 4  // 商城
	OrderComeMyselfStore = 8  // 自主经营
	OrderComePayTable    = 10 // 线索通支付表单
	OrderComeTiktokStore = 12 // 抖音门店
	OrderComeTiktokBig   = 14 // 抖+
	OrderComePangolin    = 15 // 穿山甲
)

// CallbackRefundOrderMsgTagId 订单退款状态,逆向订单
const (
	// 需要处理的退单消息
	CallbackRefundOrderMsgTagId        = "200" // 买家发起售后申请消息
	CallbackUpdateRefundOrderMsgTagId  = "208" // 买家修改售后申请消息
	CallbackRefundOrderSuccessMsgTagId = "206" // 退款成功消息
	CallbackRefundOrderRefuseMsgTagId  = "204" // 拒绝退款消息
	CallbackRefundShopMsgTagId         = "205" // 拒绝退货申请消息
	CallbackReturnApplyAgreedMsgTagId  = "202" // 同意退货申请消息
	CallbackReturnRefundAgreedMsgTagId = "201" // 同意退款消息
	CallbackRefundClosedMsgTagId       = "207" // 售后关闭消息,当买家取消申请或系统超时机制导致退款取消时，会推送此消息

	// 不需要处理的退单消息
	CallbackExchangeComfirmedMsgTagId         = "211" // 卖家收到买家换货包裹，确认换货并二次发货消息
	CallbackArbitrateDiscussUploadMsgTagId    = "218" // 协商期上传凭证消息
	CallbackArbitrateServiceInterveneMsgTagId = "217" // 仲裁客服介入消息
	CallbackArbitrateCancelledMsgTagId        = "215" // 买家取消仲裁消息
	CallbackArbitrateAuditedMsgTagId          = "216" // 客服仲裁结果消息
	CallbackArbitrateSubmitedMsgTagId         = "214" // 商家上传仲裁凭证消息
	CallbackArbitrateSubmitingMsgTagId        = "213" // 客服要求商家上传凭证消息
	CallbackArbitrateAppliedMsgTagId          = "212" // 买家发起客服仲裁消息
	CallbackExpirationChangeMsgTagId          = "209" // 售后超时时长变更消息
	CallbackBuyerReturnGoodsMsgTagId          = "203" // 买家退货给卖家消息
	CallbackSpecialRefundMsgTagId             = "224" // 特殊权益售后消息
	CallbackSpecialRefundSuccessMsgTagId      = "225" // 特殊权益售后退款成功消息
	CallbackAuditAgreeResendMsgTagId          = "227" // 同意补寄申请
	CallbackResendFillLogisticsMsgTagId       = "226" // 补寄商家发货
)

// 订单售后方式
const (
	AfterSaleTypeAll                    = 0 // 退货退款
	AfterSaleTypeSendPkgOnlyReturnMoney = 1 // 已发货仅退款
	AfterSaleTypeReturnMoney            = 2 // 未发货仅退款
	AfterSaleTypeChangePkg              = 3 // 换货
	AfterSaleTypeSystemCancel           = 4 // 系统取消
	AfterSaleTypeUserCancel             = 5 // 用户取消
	AfterSaleTypeInsuredPrice           = 6 // 价保
	AfterSaleTypeReissue                = 7 // 补寄
	AfterSaleTypeService                = 8 // 维修
)

// 订单售后退款商户操作枚举
// 售后审核接口聚合版
// 售后统一操作接口，此接口可以提供所有售后操作类型。通过此接口操作时，需要通过type字段说明本次期望的操作（详情可见下表）。
// 此接口每次最多支持对20个售后单进行操作。但任意一个售后单操作失败，接口遍会整体报错，因此推荐使用此接口每次操作一个售后单，从而获得更加明确的报错信息。
// type说明:
// 值  前置条件-售后类型 前置条件-售后状态 	说明 				必须参数
// 101 0 				6,27 		同意退货申请（一次审核） 	Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
// 102 0 				6  		 	拒绝退货申请（一次审核） 	reason , evidence
// 111 0 				7,11,29  	同意退货（二次审核）
// 112 0 				11 			拒绝退货 (二次审核) 		reason , evidence
// 121 0 				6,27 		退货转退款
// 201 1 				6,27 		同意仅退款
// 202 1 				6 			拒绝仅退款 				reason , evidence
// 203 1 				6 			同意拒签后退款
// 301 3 				6,27 		同意换货申请（一次审核) 	Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
// 302 3 				6 			拒绝换货申请（一次审核） 	reason,evidence
// 311 3 				7,11,29 	同意换货（二次审核） 		logistics.companyCode,logistics.logisticsCode
// 312 3 				11 			拒绝换货（二次审核） 		reason,evidence
// 321 3 				6,7,11,29 	换货转退款
// 401 2 				6 			同意售前退申请(拒绝售前退款请使用发货接口)
// 501 7 				6,27 		同意补寄
// 502 7 				6 			拒绝补寄
const (
	AfterSaleEmuAgreeToReturnOneApply     = 101 // 同意退货申请（一次审核）不接 	Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
	AfterSaleEmuRefuseToReturnOneApply    = 102 // 拒绝退货申请（一次审核） 	reason , evidence
	AfterSaleEmuAgreeToReturnTwoApply     = 111 // 同意退货（二次审核） 不接
	AfterSaleEmuRefuseToReturnTwoApply    = 112 // 拒绝退货 (二次审核) 		reason , evidence
	AfterSaleEmuReturnGoodsToRefundApply  = 121 // 退货转退款
	AfterSaleEmuAgreeOnlyRefundApply      = 201 // 同意仅退款
	AfterSaleEmuRefuseOnlyRefundApply     = 202 // 拒绝仅退款 				reason , evidence
	AfterSaleEmuRefundAfterRefusalApply   = 203 // 同意拒签后退款 不接
	AfterSaleEmuAgreeChangeGoodsOneApply  = 301 // 同意换货申请（一次审核) 不接	Logistics.ReceiverAddressId 或 Logistics.AfterSaleAddressDetail
	AfterSaleEmuRefundChangeGoodsOneApply = 302 // 拒绝换货申请（一次审核） reason,evidence
	AfterSaleEmuAgreeChangeGoodsTwoApply  = 311 // 同意换货（二次审核） 		logistics.companyCode,logistics.logisticsCode
	AfterSaleEmuRefundChangeGoodsTwoApply = 312 // 拒绝换货（二次审核） 		reason,evidence
	AfterSaleEmuChangeGoodsToRefundApply  = 321 // 换货转退款
	AfterSaleEmuAgreePreSaleReturnApply   = 401 // 同意售前退申请(拒绝售前退款请使用发货接口)
	AfterSaleEmuAgreeReissueApply         = 501 // 同意补寄
	AfterSaleEmuRefundReissueApply        = 502 // 拒绝补寄
)

const (
	MaxSkuNameCharCount              = 30  // SkuName的最大字符数
	MaxStoreSkuBatchSize             = 200 // retail/sku/stock, retail/sku/sellStatus和retail/sku/price这些批量操作的最大值
	MaxRetailListPageSize            = 200
	MaxBatchDeleteSize               = 100 // retailCat/batchdelete/catandretail这个接口的批量最大值
	MaxRetailDiscountCreateBatchSize = 200
	MaxRetailDiscountDeleteBatchSize = 100
)

const (
	TiktokLogisticsStatusCALLRIDER      = "CALL_RIDER"             // 呼叫骑手
	TiktokLogisticsORDERRECEIVED        = "ORDER_RECEIVED"         // 已接单
	TiktokLogisticsRIDERARRIVED         = "RIDER_ARRIVED"          // 已到店
	TiktokLogisticsRIDERPICKUP          = "RIDER_PICK_UP"          // 已取货
	TiktokLogisticsDELIVERED            = "DELIVERED"              // 已送达
	TiktokLogisticsDELIVERYOFFLINE      = "DELIVERY_OFFLINE"       // 此单由商家自行配送，具体配送进度请咨询商家
	TiktokLogisticsCHANGERIDER          = "CHANGE_RIDER"           // 更换骑手,继续为您配送
	TiktokLogisticsINDDELIVERYEXCEPTION = "IND_DELIVERY_EXCEPTION" // 订单配送异常，异常原因
	TiktokLogisticsCANCELDELIVERY       = "CANCEL_DELIVERY"        // 订单配送取消
)

// 商品审核状态: 1-未提交；2-待审核；3-审核通过；4-审核未通过；5-封禁；7-审核通过待上架；详见商品状态机：https://op.jinritemai.com/docs/question-docs/92/2070
const (
	SkuCheckStatusNotCommit    = 1 // 未提交
	SkuCheckStatusWaitCheck    = 2 // 待审核
	SkuCheckStatusPass         = 3 // 审核通过
	SkuCheckStatusNotPass      = 4 // 审核未通过
	SkuCheckStatusProhibit     = 5 // 禁封
	SkuCheckStatusPassNotPutOn = 7 // 通过待上架
)

const (
	TiktokCancelCode201 = 201 // 超出配送范围
	TiktokCancelCode203 = 203 // 运力紧张无可接单骑手
	TiktokCancelCode204 = 204 // 骑手联系不上收货人
	TiktokCancelCode208 = 208 // 商家未营业
	TiktokCancelCode209 = 209 // 商家无法出餐
	TiktokCancelCode210 = 210 // 商家地址错误
	TiktokCancelCode211 = 211 // 用户拒收
	TiktokCancelCode222 = 222 // 用户取消订单
	TiktokCancelCode200 = 200 // 其他原因
)

const (
	TiktokDeliveryTypeSF       = "SF"        //SF:顺丰同城
	TiktokDeliveryTypeDaDa     = "DADA"      //DADA:达达
	TiktokDeliveryTypeFengNiao = "FENG_NIAO" //FENG_NIAO:蜂鸟配送
	TiktokDeliveryTypeMeiTuan  = "MEI_TUAN"  //MEI_TUAN:美团配送
	TiktokDeliveryTypeUU       = "UU"        //UU:UU跑腿
	TiktokDeliveryTypeMerchant = "MERCHANT"  //MERCHANT:商家自配送,使用此枚举需要提前和平台沟通
)

func JxVendorId2TiktokCode(vendorId int) string {
	code := ""
	switch vendorId {
	case 101:
		code = TiktokDeliveryTypeDaDa
	case 102:
		code = TiktokDeliveryTypeMeiTuan
	case 103:
		code = TiktokDeliveryTypeFengNiao
	case 105:
		code = TiktokDeliveryTypeUU
	case 106:
		code = TiktokDeliveryTypeSF
	default:
		code = TiktokDeliveryTypeMerchant
	}
	return code
}
