You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jdsdk/order/afterSale.go

235 lines
10 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package order
import (
"git.oa00.com/go/jdsdk/address"
"git.oa00.com/go/jdsdk/config"
"git.oa00.com/go/jdsdk/request"
)
type AfterSale struct {
}
const (
afterSaleIsCan = "jingdong.ctp.afs.operate.apply.getIsCanApplyInfo"
afterSaleReason = "jingdong.ctp.afs.operate.apply.getApplyReason"
afterSaleApply = "jingdong.ctp.afs.operate.apply.createAfsApply"
afterSaleLogisticsAddress = "jingdong.ctp.afs.logistics.getLogisticsAddress"
afterSaleDelivery = "jingdong.ctp.afs.logistics.postBackLogisticsBillParam"
afterSaleInfo = "jingdong.ctp.afs.servicenbill.getAfsServiceDetail"
afterSaleCancel = "jingdong.ctp.afs.servicenbill.cancelAfsService"
AfterServiceCanApplyFalse = 0 // 不可申请
AfterServiceCanApplyTrue = 1 // 可申请
AfterServiceAfsDetailTypeMaster = 10 // 主品
AfterServiceAfsDetailTypeSlave = 20 // 赠品
)
type canApplyInfoParam struct {
Pin string `json:"pin"` // 下单账号
SkuId uint64 `json:"skuId"` // skuId
OrderId uint64 `json:"orderId"` // 订单号
//AfsDetailType uint `json:"afsDetailType"` // 商品类型 10=主品 20=赠品
}
type resIsCanInfo struct {
CanApply uint `json:"canApply"` // 是否可申请售后 0=不可申请 1=可申请
SkuId uint64 `json:"skuId"` // skuId
AppliedNum uint `json:"appliedNum"` // 已申请售后商品数量
CannotApplyTip string `json:"cannotApplyTip"` // 不可申请原因
OrderId uint64 `json:"orderId"` // 订单号
AfsSupportedTypes []AfterSaleTypeItem `json:"afsSupportedTypes"` // 可售后类型列表
}
type AfterSaleTypeItem struct {
AfsTypeName string `json:"afsTypeName"` // 售后名称
AfsType uint `json:"afsType"` // 售后类型
}
// IsCan @Title 是否能售后
func (a *AfterSale) IsCan(skuId, orderId uint64) (result resIsCanInfo, err error) {
err = request.ExecCtlProtocol(afterSaleIsCan, canApplyInfoParam{
Pin: config.SdkConfig.Pin,
SkuId: skuId,
OrderId: orderId,
}, &result)
return
}
type applyReasonParam struct {
Pin string `json:"pin"` // 账号
SkuId uint64 `json:"skuId"` // skuId
AfsType uint `json:"afsType"` // 售后类型 10=退货 20=换货
OrderId uint64 `json:"orderId"` // 订单号
//AfsDetailType uint `json:"afsDetailType"` // 商品类型 10=主品 20=赠品
}
type reasonItem struct {
ApplyReasonName string `json:"applyReasonName"` // 售后原因
ApplyReasonId uint `json:"applyReasonId"` // 售后Id
NeedUploadPic bool `json:"needUploadPic"` // 是否必须传图
}
// Reason @Title 售后原因
func (a *AfterSale) Reason(skuId, orderId uint64, AfsType uint) (result []reasonItem, err error) {
err = request.ExecCtlProtocol(afterSaleReason, applyReasonParam{
Pin: config.SdkConfig.Pin,
SkuId: skuId,
OrderId: orderId,
AfsType: AfsType,
}, &result)
return
}
type afsApplyParam struct {
Pin string `json:"pin"` // 下单账号
PickWareType uint `json:"pickWareType"` // 取件方式 40=客户发货 固定
PickWareAddress address.Address `json:"pickWareAddress"` // 取件地址
ApplyParam
}
type ApplyParam struct {
ApplyReasonName string `json:"applyReasonName"` // 售后原因
ApplyReasonId uint `json:"applyReasonId"` // 售后原因id
ChannelAfsApplyId string `json:"channelAfsApplyId"` // 渠道售后申请单号
AfsType uint `json:"afsType"` // 期望售后类型 10=退货 20=换货
QuestionPic string `json:"questionPic"` // 问题图片 逗号分隔
OrderId uint `json:"orderId"` // 订单号
SkuQuantity AfterSaleSkuItem `json:"skuQuantity"` // 申请商品信息
}
type AfterSaleSkuItem struct {
SkuId uint64 `json:"skuId"` // skuId
SkuName string `json:"skuName"` // skuName
Quantity uint `json:"quantity"` // 数量
AfsDetailType uint `json:"afsDetailType"` // 商品类型 10=主品 20=赠品
}
type resApply struct {
ChannelAfsApplyId string `json:"channelAfsApplyId"` // 渠道申请单号
AfsApplyId uint64 `json:"afsApplyId"` // 京东申请单号
}
// Apply @Title 售后申请
func (a *AfterSale) Apply(data ApplyParam) (result resApply, err error) {
err = request.ExecCtlProtocol(afterSaleApply, afsApplyParam{
Pin: config.SdkConfig.Pin,
PickWareType: 40,
ApplyParam: data,
}, &result)
return
}
type logisticsAddressParam struct {
AfsServiceId uint64 `json:"afsServiceId"` // 售后id
Pin string `json:"pin"` // 下单账号
}
type resLogisticsAddress struct {
ContactsMobile string `json:"contactsMobile"` // 回寄手机号
ContactsZipCode string `json:"contactsZipCode"` // 回寄邮编
Address string `json:"address"` // 回寄详细地址
ContactsName string `json:"contactsName"` // 回寄联系人
}
// LogisticsAddress @Title 回寄地址
func (a *AfterSale) LogisticsAddress(afsServiceId uint64) (result resLogisticsAddress, err error) {
err = request.ExecCtlProtocol(afterSaleLogisticsAddress, logisticsAddressParam{
AfsServiceId: afsServiceId,
Pin: config.SdkConfig.Pin,
}, &result)
return
}
type logisticsBillParam struct {
Pin string `json:"pin"` // 下单账号
AfsServiceId uint64 `json:"afsServiceId"` // 售后id
LogisticsCompany string `json:"logisticsCompany"` // 物流公司
WaybillCode string `json:"waybillCode"` // 运单号
SendGoodsDate string `json:"sendGoodsDate"` // 运单发货日期 Y-m-d
}
type resDelivery struct {
Message string `json:"message"` // 回传结果描述
PostBackResult bool `json:"postBackResult"` // 回传结果
}
// Delivery @Title 回传客户发货信息
func (a *AfterSale) Delivery(afsServiceId uint64, logisticsCompany, waybillCode, sendGoodsDate string) (result resDelivery, err error) {
err = request.ExecCtlProtocol(afterSaleDelivery, logisticsBillParam{
Pin: config.SdkConfig.Pin,
AfsServiceId: afsServiceId,
LogisticsCompany: logisticsCompany,
WaybillCode: waybillCode,
SendGoodsDate: sendGoodsDate,
}, &result)
return
}
type afsServiceDetailParam struct {
AfsServiceId uint64 `json:"afsServiceId"` // 售后id
Pin string `json:"pin"` // 下单账号
}
type AfterSaleInfo struct {
ProcessResult uint `json:"processResult"` // 处理结果
CustomerName string `json:"customerName"` // 客户名称
ApplyReasonId uint `json:"applyReasonId"` // 售后原因id
ApplyReasonName string `json:"applyReasonName"` // 售后原因
ApproveResult uint `json:"approveResult"` // 审核结果
AfsApplyTime int64 `json:"afsApplyTime"` // 发起售后申请时间 Y-m-d H:i:s
ApproveResultName string `json:"approveResultName"` // 审核结果
ProcessResultName string `json:"processResultName"` // 处理结果
AfsType uint `json:"afsType"` // 售后服务类型id退货(10),换货(20)
ReturnWareType uint `json:"returnWareType"` // 售后返件类型 1客户发货
CustomerMobile string `json:"customerMobile"` // 售后联系人联系方式
QuestionPic string `json:"questionPic"` // 售后描述图片
ApproveNotes string `json:"approveNotes"` // 售后服务单审核意见
ApprovedDate int64 `json:"approvedDate"` // 售后服务单审核时间 Y-m-d H:i:s
CustomerEmail string `json:"customerEmail"` // 售后联系人邮箱
ProcessedDate string `json:"processedDate"` // 售后服务单处理时间 Y-m-d H:i:s
AfsApplyId uint64 `json:"afsApplyId"` // 售后申请单号
AfsTypeName string `json:"afsTypeName"` // 用户期望的售后服务类型 1退货 2换货
AfsServiceState uint `json:"afsServiceState"` // 服务单状态
AfsServiceId uint64 `json:"afsServiceId"` // 京东售后服务单号
NewOrderId uint64 `json:"newOrderId"` // 售后换新订单号
AfsServiceStep uint `json:"afsServiceStep"` // 处理环节
AfsServiceStateName string `json:"afsServiceStateName"` // 售后处理状态
ProcessNotes string `json:"processNotes"` // 售后处理意见
AfsServiceStepName string `json:"afsServiceStepName"` // 售后当前处理环节
OrderId string `json:"orderId"` // 订单号
SkuQuantity skuItem `json:"skuQuantity"` // sku信息
DesenCustomerMobile string `json:"desen_customerMobile"` // 售后联系人联系方式
}
type skuItem struct {
SkuId string `json:"skuId"` // skuId
SkuName string `json:"skuName"` // skuName
Quantity uint `json:"quantity"` // 数量
ValidNumFlag uint `json:"validNumFlag"` // 赠品申请标识 1代表申请了0代表没申请或释放了后续可以继续申请
SkuType uint `json:"skuType"` // 标识商品属性 1单品、2买赠赠品套装中的主商品、3买赠赠品套装中的赠品
}
// Info @Title 售后详情
func (a *AfterSale) Info(afsServiceId uint64) (result AfterSaleInfo, err error) {
err = request.ExecCtlProtocol(afterSaleInfo, afsServiceDetailParam{
AfsServiceId: afsServiceId,
Pin: config.SdkConfig.Pin,
}, &result)
return
}
type cancelAfsServiceParam struct {
AfsServiceId uint64 `json:"afsServiceId"` // 售后id
Pin string `json:"pin"` // 下单账号
}
type resCancel struct {
CancelState uint `json:"cancelState"` // 1=不可取消 2=取消成功 3=取消失败
}
// Cancel @Title 取消售后服务单
func (a *AfterSale) Cancel(afsServiceId uint64) (result resCancel, err error) {
err = request.ExecCtlProtocol(afterSaleCancel, cancelAfsServiceParam{
AfsServiceId: afsServiceId,
Pin: config.SdkConfig.Pin,
}, &result)
return
}