package tm import ( "context" "encoding/json" "github.com/gogf/gf/util/gconv" ) type refundTm struct { } var Refund = refundTm{} type RefundSubmitReq struct { UserId string SubLmOrderId string //子订单号 DisputeId string //售后ID CpCode string //物流编码 LogisticsNo string //物流单号 } //Submit 提交退货物流信息接口 func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *CommonRes, err error) { method := "submitReturnGoodLogistics" request := map[string]string{ "BizUid": server.BizUid, "SubLmOrderId": req.SubLmOrderId, "DisputeId": req.DisputeId, "CpCode": req.CpCode, "LogisticsNo": req.LogisticsNo, "ThirdPartyUserId": req.UserId, "AccountType": typeAnony, } result, err := post(ctx, method, request) _ = json.Unmarshal([]byte(result), &res) return } //Cancel 取消退款申请接口 func (s *refundTm) Cancel(ctx context.Context, UserId, subLmOrderId, disputeId string) (res *CommonRes, err error) { method := "cancelRefund" request := map[string]string{ "BizUid": server.BizUid, "SubLmOrderId": subLmOrderId, "DisputeId": disputeId, "ThirdPartyUserId": UserId, "AccountType": typeAnony, } result, err := post(ctx, method, request) _ = json.Unmarshal([]byte(result), &res) return } type RefundBeforeReq struct { UserId string ChannelOrder string SubLmOrderId string BizClaimType string GoodsStatus string } type RefundBeforeRes struct { Code string `json:"Code"` Message string `json:"Message"` RequestId string `json:"RequestId"` InitApplyRefundData struct { RefundReasonList struct { RefundReasonList []struct { ReasonTextId int64 `json:"ReasonTextId"` ReasonTips string `json:"ReasonTips"` RefundDescRequired bool `json:"RefundDescRequired"` //是否要求留言 ProofRequired bool `json:"ProofRequired"` //是否要求上传凭证 } `json:"RefundReasonList"` } `json:"RefundReasonList"` MaxRefundFeeData struct { MaxRefundFee int64 `json:"MaxRefundFee"` //本单最大可退款金额 MinRefundFee int64 `json:"MinRefundFee"` //本单最小可退款金额 } `json:"MaxRefundFeeData"` BizClaimType int `json:"BizClaimType"` // 支持的订单退货方式,1, 标识仅退款,3,标识退货退款 } `json:"InitApplyRefundData"` } // Before 前置 func (s *refundTm) Before(ctx context.Context, req RefundBeforeReq) (res *RefundBeforeRes, err error) { method := "initApplyRefund" request := map[string]string{ "BizUid": server.BizUid, "SubLmOrderId": req.SubLmOrderId, "GoodsStatus": req.GoodsStatus, "BizClaimType": req.BizClaimType, "ThirdPartyUserId": req.UserId, "AccountType": typeAnony, } result, err := post(ctx, method, request) _ = json.Unmarshal([]byte(result), &res) return } type RefundApplyReq struct { UserId string SubLmOrderId string //子订单号 BizClaimType string //退款类型 ApplyRefundFee string //申请退款金额 ApplyRefundCount string //退货数量 ApplyReasonTextId string //退款原因ID LeaveMessage string //留言 LeavePictureList []*RefundApplyPicture //凭证,某些原因要求必须有凭证。 GoodsStatus string //当退款类型:仅退款时,货物状态:为4未 发货。所有状态:4: 未发货, 6: 已发货, 1: 未收到货, 2: 已收到货, 3:已寄回, 5: 卖家确 认收货 } type RefundApplyPicture struct { Picture string `json:"Picture"` //图片地址 Desc string `json:"Desc"` //图片描述 } type RefundApplyRes struct { Code string `json:"Code"` Message string `json:"Message"` RequestId string `json:"RequestId"` RefundApplicationData struct { SubLmOrderId string `json:"SubLmOrderId"` //当前发起逆向的子订单号 DisputeStatus int `json:"DisputeStatus"` //逆向的状态 DisputeType int `json:"DisputeType"` //任意退款类型 DisputeId int64 `json:"DisputeId"` //shou } `json:"RefundApplicationData"` } //Apply 申请 func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundApplyRes, err error) { method := "applyRefund" request := convert("LeavePictureList", gconv.Maps(req.LeavePictureList)) request["SubLmOrderId"] = req.SubLmOrderId request["BizClaimType"] = req.BizClaimType request["ApplyRefundFee"] = req.ApplyRefundFee request["ApplyRefundCount"] = req.ApplyRefundCount request["ApplyReasonTextId"] = req.ApplyReasonTextId request["LeaveMessage"] = req.LeaveMessage request["GoodsStatus"] = req.GoodsStatus request["BizUid"] = server.BizUid request["AccountType"] = typeAnony request["ThirdPartyUserId"] = req.UserId result, err := post(ctx, method, request) _ = json.Unmarshal([]byte(result), &res) return } type RefundInfoRes struct { Code string `json:"Code"` Message string `json:"Message"` RequestId string `json:"RequestId"` RefundApplicationDetail struct { SubLmOrderId string `json:"SubLmOrderId"` //当前发起逆向的子订单号 RealRefundFee int64 `json:"RealRefundFee"` // 实际买家收到的金额 DisputeCreateTime string `json:"DisputeCreateTime"` //"逆向发起时间" DisputeDesc string `json:"DisputeDesc"` //申请逆向描述 BizClaimType int `json:"BizClaimType"` // 支持的订单退货方式,1, 标识仅退款,3,标识退货退款 ApplyDisputeDesc string `json:"ApplyDisputeDesc"` //当前买家申请退款说明 DisputeType int `json:"DisputeType"` //逆向发生的类型 0: "任意退款类型" 1: "售中退款"2: "售后退款" SellerAgreeMsg string `json:"SellerAgreeMsg"` //卖家同意退货说明,真实的退货地址会在这个字段进行返 回。 ApplyReasonText struct { //买家申请的逆向原因 ReasonTextId int64 `json:"ReasonTextId"` ReasonTips string `json:"ReasonTips"` } `json:"ApplyReasonText"` RefundFee int64 `json:"RefundFee"` // 退款金额(含退平台补贴的金额) SellerRefuseReason string `json:"SellerRefuseReason"` // 卖家拒绝的留言说明 RefunderTel string `json:"RefunderTel"` //退货联系方式,卖家同意退货后才显示 LmOrderId string `json:"LmOrderId"` //对应的主订单号 DisputeEndTime string `json:"DisputeEndTime"` //逆向发起时间 RefunderName string `json:"RefunderName"` //退货收货人,卖家同意退货后才显示 RefunderZipCode string `json:"RefunderZipCode"` //退货地址邮编,卖家同意退货后才显示 RefunderAddress string `json:"RefunderAddress"` //商家退货地址,卖家同意退货后才显示 DisputeStatus int `json:"DisputeStatus"` // 逆向的状态 //1: "买家已经申请退款,等待卖家同意" //2: "卖家已经同意退款,等待买家退货" //3: "买家已经退货,等待卖家确认收货" //4: "退款关闭" //5: "退款成功" //6: "卖家拒绝退款" //7: "等待买家确认重新邮寄的货物" //8: "等待卖家确认退货地址" //9: "没有申请退款" //10: "有活动的退款" //11: "退款结束" //12: "卖家确认收货,等待卖家发货" //14: "换货关闭,转退货退款" //13: "卖家已发货,等待卖家和买家确认收货" //15: "邮费单已创建,待激活" ReturnGoodLogisticsStatus int `json:"ReturnGoodLogisticsStatus"` // 退货物流状态 //0: "未退货" //1: "等待揽收" //2: "快件已揽收" //3: "物流⾛件中" //4: "派送中" //5: "已签收" //6: "签收失败" SelleAgreementMessage string `json:"SelleAgreementMessage"` SellerRefuseAgreementMessage string `json:"SellerRefuseAgreementMessage"` //// 卖家拒绝的留言说明 ReturnGoodCount int `json:"ReturnGoodCount"` //退货数量 DisputeId int64 `json:"DisputeId"` //纠纷ID } `json:"RefundApplicationDetail"` } //Info 详情 func (s *refundTm) Info(ctx context.Context, UserId, subLmOrderId string) (res *RefundInfoRes, err error) { method := "queryRefundApplicationDetail" request := map[string]string{ "BizUid": server.BizUid, "SubLmOrderId": subLmOrderId, "ThirdPartyUserId": UserId, "AccountType": typeAnony, } result, err := post(ctx, method, request) _ = json.Unmarshal([]byte(result), &res) return }