Browse Source

修复退款

shaoguo 3 weeks ago
parent
commit
7f3e838f99
1 changed files with 192 additions and 18 deletions
  1. 192 18
      services/refunddomestic/models.go

+ 192 - 18
services/refunddomestic/models.go

@@ -13,6 +13,7 @@ package refunddomestic
 import (
 	"encoding/json"
 	"fmt"
+	"time"
 )
 
 // Account * `AVAILABLE` - 可用余额, 多账户资金准备退款可用余额出资账户类型 * `UNAVAILABLE` - 不可用余额, 多账户资金准备退款不可用余额出资账户类型
@@ -34,10 +35,18 @@ type Amount struct {
 	Total *int64 `json:"total"`
 	// 退款标价金额,单位为分,可以做部分退款
 	Refund *int64 `json:"refund"`
-
 	// 退款出资的账户类型及金额信息
 	From []FundsFromItem `json:"from,omitempty"`
-
+	// 现金支付金额,单位为分,只能为整数
+	PayerTotal *int64 `json:"payer_total"`
+	// 退款给用户的金额,不包含所有优惠券金额
+	PayerRefund *int64 `json:"payer_refund"`
+	// 去掉非充值代金券退款金额后的退款金额,单位为分,退款金额=申请退款金额-非充值代金券退款金额,退款金额<=申请退款金额
+	SettlementRefund *int64 `json:"settlement_refund"`
+	// 应结订单金额=订单金额-免充值代金券金额,应结订单金额<=订单金额,单位为分
+	SettlementTotal *int64 `json:"settlement_total"`
+	// 优惠退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为现金,说明详见代金券或立减优惠,单位为分
+	DiscountRefund *int64 `json:"discount_refund"`
 	// 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
 	Currency *string `json:"currency"`
 }
@@ -59,7 +68,30 @@ func (o Amount) MarshalJSON() ([]byte, error) {
 		toSerialize["from"] = o.From
 	}
 
+	if o.PayerTotal == nil {
+		return nil, fmt.Errorf("field `PayerTotal` is required and must be specified in Amount")
+	}
+	toSerialize["payer_total"] = o.PayerTotal
+
+	if o.PayerRefund == nil {
+		return nil, fmt.Errorf("field `PayerRefund` is required and must be specified in Amount")
+	}
+	toSerialize["payer_refund"] = o.PayerRefund
+
+	if o.SettlementRefund == nil {
+		return nil, fmt.Errorf("field `SettlementRefund` is required and must be specified in Amount")
+	}
+	toSerialize["settlement_refund"] = o.SettlementRefund
 
+	if o.SettlementTotal == nil {
+		return nil, fmt.Errorf("field `SettlementTotal` is required and must be specified in Amount")
+	}
+	toSerialize["settlement_total"] = o.SettlementTotal
+
+	if o.DiscountRefund == nil {
+		return nil, fmt.Errorf("field `DiscountRefund` is required and must be specified in Amount")
+	}
+	toSerialize["discount_refund"] = o.DiscountRefund
 
 	if o.Currency == nil {
 		return nil, fmt.Errorf("field `Currency` is required and must be specified in Amount")
@@ -84,6 +116,36 @@ func (o Amount) String() string {
 
 	ret += fmt.Sprintf("From:%v, ", o.From)
 
+	if o.PayerTotal == nil {
+		ret += "PayerTotal:<nil>, "
+	} else {
+		ret += fmt.Sprintf("PayerTotal:%v, ", *o.PayerTotal)
+	}
+
+	if o.PayerRefund == nil {
+		ret += "PayerRefund:<nil>, "
+	} else {
+		ret += fmt.Sprintf("PayerRefund:%v, ", *o.PayerRefund)
+	}
+
+	if o.SettlementRefund == nil {
+		ret += "SettlementRefund:<nil>, "
+	} else {
+		ret += fmt.Sprintf("SettlementRefund:%v, ", *o.SettlementRefund)
+	}
+
+	if o.SettlementTotal == nil {
+		ret += "SettlementTotal:<nil>, "
+	} else {
+		ret += fmt.Sprintf("SettlementTotal:%v, ", *o.SettlementTotal)
+	}
+
+	if o.DiscountRefund == nil {
+		ret += "DiscountRefund:<nil>, "
+	} else {
+		ret += fmt.Sprintf("DiscountRefund:%v, ", *o.DiscountRefund)
+	}
+
 	if o.Currency == nil {
 		ret += "Currency:<nil>"
 	} else {
@@ -113,6 +175,30 @@ func (o Amount) Clone() *Amount {
 		}
 	}
 
+	if o.PayerTotal != nil {
+		ret.PayerTotal = new(int64)
+		*ret.PayerTotal = *o.PayerTotal
+	}
+
+	if o.PayerRefund != nil {
+		ret.PayerRefund = new(int64)
+		*ret.PayerRefund = *o.PayerRefund
+	}
+
+	if o.SettlementRefund != nil {
+		ret.SettlementRefund = new(int64)
+		*ret.SettlementRefund = *o.SettlementRefund
+	}
+
+	if o.SettlementTotal != nil {
+		ret.SettlementTotal = new(int64)
+		*ret.SettlementTotal = *o.SettlementTotal
+	}
+
+	if o.DiscountRefund != nil {
+		ret.DiscountRefund = new(int64)
+		*ret.DiscountRefund = *o.DiscountRefund
+	}
 
 	if o.Currency != nil {
 		ret.Currency = new(string)
@@ -246,6 +332,11 @@ type CreateRequest struct {
 	Amount *AmountReq `json:"amount"`
 	// 指定商品退款需要传此参数,其他场景无需传递
 	GoodsDetail []GoodsDetail `json:"goods_detail,omitempty"`
+
+	//商户号
+	MchId *string `json:"mch_id,omitempty"`
+
+	Appid *string `json:"appid,omitempty"`
 }
 
 func (o CreateRequest) MarshalJSON() ([]byte, error) {
@@ -412,17 +503,19 @@ const (
 
 // FundsFromItem
 type FundsFromItem struct {
-	FundSource *string `json:"funds_source"`
+	// 下面枚举值多选一。 枚举值: AVAILABLE : 可用余额 UNAVAILABLE : 不可用余额 * `AVAILABLE` - 可用余额 * `UNAVAILABLE` - 不可用余额
+	Account *Account `json:"account"`
+	// 对应账户出资金额
 	Amount *int64 `json:"amount"`
 }
 
 func (o FundsFromItem) MarshalJSON() ([]byte, error) {
 	toSerialize := map[string]interface{}{}
 
-	if o.FundSource == nil {
-		return nil, fmt.Errorf("field `FundSource` is required and must be specified in FundsFromItem")
+	if o.Account == nil {
+		return nil, fmt.Errorf("field `Account` is required and must be specified in FundsFromItem")
 	}
-	toSerialize["funds_source"] = o.FundSource
+	toSerialize["account"] = o.Account
 
 	if o.Amount == nil {
 		return nil, fmt.Errorf("field `Amount` is required and must be specified in FundsFromItem")
@@ -433,11 +526,12 @@ func (o FundsFromItem) MarshalJSON() ([]byte, error) {
 
 func (o FundsFromItem) String() string {
 	var ret string
-	if o.FundSource == nil {
-		ret += "FundSource:<nil>, "
+	if o.Account == nil {
+		ret += "Account:<nil>, "
 	} else {
-		ret += fmt.Sprintf("FundSource:%v, ", *o.FundSource)
+		ret += fmt.Sprintf("Account:%v, ", *o.Account)
 	}
+
 	if o.Amount == nil {
 		ret += "Amount:<nil>"
 	} else {
@@ -450,7 +544,10 @@ func (o FundsFromItem) String() string {
 func (o FundsFromItem) Clone() *FundsFromItem {
 	ret := FundsFromItem{}
 
-
+	if o.Account != nil {
+		ret.Account = new(Account)
+		*ret.Account = *o.Account
+	}
 
 	if o.Amount != nil {
 		ret.Amount = new(int64)
@@ -776,19 +873,22 @@ type Refund struct {
 	TransactionId *string `json:"transaction_id"`
 	// 原支付交易对应的商户订单号
 	OutTradeNo *string `json:"out_trade_no"`
-	Reason *string `json:"reason,omitempty"`
-
-	Source *string `json:"source,omitempty"`
-
+	// 枚举值: - ORIGINAL—原路退款 - BALANCE—退回到余额 - OTHER_BALANCE—原账户异常退到其他余额账户 - OTHER_BANKCARD—原银行卡异常退到其他银行卡 * `ORIGINAL` - 原路退款 * `BALANCE` - 退回到余额 * `OTHER_BALANCE` - 原账户异常退到其他余额账户 * `OTHER_BANKCARD` - 原银行卡异常退到其他银行卡
+	Channel *Channel `json:"channel"`
+	// 取当前退款单的退款入账方,有以下几种情况: 1)退回银行卡:{银行名称}{卡类型}{卡尾号} 2)退回支付用户零钱:支付用户零钱 3)退还商户:商户基本账户商户结算银行账户 4)退回支付用户零钱通:支付用户零钱通
+	UserReceivedAccount *string `json:"user_received_account"`
+	// 退款成功时间,退款状态status为SUCCESS(退款成功)时,返回该字段。遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
+	SuccessTime *time.Time `json:"success_time,omitempty"`
+	// 退款受理时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
+	CreateTime *time.Time `json:"create_time"`
+	// 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。 枚举值: - SUCCESS—退款成功 - CLOSED—退款关闭 - PROCESSING—退款处理中 - ABNORMAL—退款异常 * `SUCCESS` - 退款成功 * `CLOSED` - 退款关闭 * `PROCESSING` - 退款处理中 * `ABNORMAL` - 退款异常
+	Status *Status `json:"status"`
+	// 退款所使用资金对应的资金账户类型 枚举值: - UNSETTLED : 未结算资金 - AVAILABLE : 可用余额 - UNAVAILABLE : 不可用余额 - OPERATION : 运营户 - BASIC : 基本账户(含可用余额和不可用余额) * `UNSETTLED` - 未结算资金 * `AVAILABLE` - 可用余额 * `UNAVAILABLE` - 不可用余额 * `OPERATION` - 运营户 * `BASIC` - 基本账户(含可用余额和不可用余额)
 	FundsAccount *FundsAccount `json:"funds_account,omitempty"`
 	// 金额详细信息
 	Amount *Amount `json:"amount"`
 	// 优惠退款信息
 	PromotionDetail []Promotion `json:"promotion_detail,omitempty"`
-
-	MchId *string `json:"mch_id,omitempty"`
-	AppId *string `json:"app_id,omitempty"`
-
 }
 
 func (o Refund) MarshalJSON() ([]byte, error) {
@@ -814,6 +914,29 @@ func (o Refund) MarshalJSON() ([]byte, error) {
 	}
 	toSerialize["out_trade_no"] = o.OutTradeNo
 
+	if o.Channel == nil {
+		return nil, fmt.Errorf("field `Channel` is required and must be specified in Refund")
+	}
+	toSerialize["channel"] = o.Channel
+
+	if o.UserReceivedAccount == nil {
+		return nil, fmt.Errorf("field `UserReceivedAccount` is required and must be specified in Refund")
+	}
+	toSerialize["user_received_account"] = o.UserReceivedAccount
+
+	if o.SuccessTime != nil {
+		toSerialize["success_time"] = o.SuccessTime.Format(time.RFC3339)
+	}
+
+	if o.CreateTime == nil {
+		return nil, fmt.Errorf("field `CreateTime` is required and must be specified in Refund")
+	}
+	toSerialize["create_time"] = o.CreateTime.Format(time.RFC3339)
+
+	if o.Status == nil {
+		return nil, fmt.Errorf("field `Status` is required and must be specified in Refund")
+	}
+	toSerialize["status"] = o.Status
 
 	if o.FundsAccount != nil {
 		toSerialize["funds_account"] = o.FundsAccount
@@ -856,7 +979,35 @@ func (o Refund) String() string {
 		ret += fmt.Sprintf("OutTradeNo:%v, ", *o.OutTradeNo)
 	}
 
+	if o.Channel == nil {
+		ret += "Channel:<nil>, "
+	} else {
+		ret += fmt.Sprintf("Channel:%v, ", *o.Channel)
+	}
+
+	if o.UserReceivedAccount == nil {
+		ret += "UserReceivedAccount:<nil>, "
+	} else {
+		ret += fmt.Sprintf("UserReceivedAccount:%v, ", *o.UserReceivedAccount)
+	}
+
+	if o.SuccessTime == nil {
+		ret += "SuccessTime:<nil>, "
+	} else {
+		ret += fmt.Sprintf("SuccessTime:%v, ", *o.SuccessTime)
+	}
 
+	if o.CreateTime == nil {
+		ret += "CreateTime:<nil>, "
+	} else {
+		ret += fmt.Sprintf("CreateTime:%v, ", *o.CreateTime)
+	}
+
+	if o.Status == nil {
+		ret += "Status:<nil>, "
+	} else {
+		ret += fmt.Sprintf("Status:%v, ", *o.Status)
+	}
 
 	if o.FundsAccount == nil {
 		ret += "FundsAccount:<nil>, "
@@ -894,7 +1045,30 @@ func (o Refund) Clone() *Refund {
 		*ret.OutTradeNo = *o.OutTradeNo
 	}
 
+	if o.Channel != nil {
+		ret.Channel = new(Channel)
+		*ret.Channel = *o.Channel
+	}
 
+	if o.UserReceivedAccount != nil {
+		ret.UserReceivedAccount = new(string)
+		*ret.UserReceivedAccount = *o.UserReceivedAccount
+	}
+
+	if o.SuccessTime != nil {
+		ret.SuccessTime = new(time.Time)
+		*ret.SuccessTime = *o.SuccessTime
+	}
+
+	if o.CreateTime != nil {
+		ret.CreateTime = new(time.Time)
+		*ret.CreateTime = *o.CreateTime
+	}
+
+	if o.Status != nil {
+		ret.Status = new(Status)
+		*ret.Status = *o.Status
+	}
 
 	if o.FundsAccount != nil {
 		ret.FundsAccount = new(FundsAccount)