49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
|
package walletservicelogic
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"tianyuan-api/apps/user/internal/svc"
|
||
|
"tianyuan-api/apps/user/user"
|
||
|
|
||
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
)
|
||
|
|
||
|
type GetRechargeListLogic struct {
|
||
|
ctx context.Context
|
||
|
svcCtx *svc.ServiceContext
|
||
|
logx.Logger
|
||
|
}
|
||
|
|
||
|
func NewGetRechargeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetRechargeListLogic {
|
||
|
return &GetRechargeListLogic{
|
||
|
ctx: ctx,
|
||
|
svcCtx: svcCtx,
|
||
|
Logger: logx.WithContext(ctx),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 充值记录列表篇
|
||
|
func (l *GetRechargeListLogic) GetRechargeList(in *user.RechargeRequest) (*user.RechargeResponse, error) {
|
||
|
list, total, err := l.svcCtx.RechargeModel.FindRechargeListByUserId(l.ctx, in.UserId, in.Page, in.PageSize)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var rechargeItemList []*user.RechargeItem
|
||
|
for _, w := range list {
|
||
|
rechargeItemList = append(rechargeItemList, &user.RechargeItem{
|
||
|
Id: w.Id,
|
||
|
UserId: w.UserId,
|
||
|
TransactionId: w.TransactionId,
|
||
|
OutTradeNo: w.OutTradeNo,
|
||
|
Amount: float32(w.Amount),
|
||
|
PaymentMethod: w.PaymentMethod,
|
||
|
CreatedAt: w.CreatedAt.Format("2006-01-02 15:04:05"),
|
||
|
UpdatedAt: w.UpdatedAt.Format("2006-01-02 15:04:05"),
|
||
|
})
|
||
|
}
|
||
|
return &user.RechargeResponse{
|
||
|
List: rechargeItemList,
|
||
|
Total: total,
|
||
|
}, nil
|
||
|
}
|