Skip to content

Commit 1f2e63f

Browse files
committed
api/donation: update the endpoint according API change
This patch updates the endpoint according to the record api change. If the `bank_transaction_id` or `rec_trade_id` is not specified, append the time filter with the one month range ends now.
1 parent 223d553 commit 1f2e63f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

controllers/donation.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,16 @@ type (
217217
ReceiptHeader null.String `json:"receipt_header"`
218218
}
219219

220+
queryFilterTime struct {
221+
StartTime null.Int `json:"start_time"`
222+
EndTime null.Int `json:"end_time"`
223+
}
224+
220225
queryFilter struct {
221-
OrderNumber string `json:"order_number" binding:"required"`
226+
OrderNumber string `json:"order_number" binding:"required"`
227+
BankTransactionID null.String `json:"bank_transaction_id"`
228+
RecTradeID null.String `json:"rec_trade_id"`
229+
Time *queryFilterTime `json:"time"`
222230
}
223231

224232
queryReq struct {
@@ -941,6 +949,13 @@ func (mc *MembershipController) QueryTappayServer(c *gin.Context) (int, gin.H, e
941949
}}, nil
942950
}
943951

952+
// If the required fields `bank_transaction_id` or `rec_trade_id` are not specified, append the time filter of one month range from now
953+
if reqBody.Filters.RecTradeID.IsZero() && reqBody.Filters.BankTransactionID.IsZero() {
954+
end := time.Now()
955+
start := end.AddDate(0, -1, 0)
956+
reqBody.Filters.Time.EndTime = null.IntFrom(end.Unix())
957+
reqBody.Filters.Time.StartTime = null.IntFrom(start.Unix())
958+
}
944959
tapPayResp, err := reqBody.QueryServer()
945960

946961
if err != nil {

0 commit comments

Comments
 (0)