|
- package hdl
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/md"
- "applet/app/utils"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
- "github.com/gin-gonic/gin"
- )
-
- // GetAmountFlow
- // @Summary 蛋蛋星球-钱包-余额明细(获取)
- // @Tags 钱包
- // @Description 余额明细(获取)
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Param limit query string true "每页大小"
- // @Param page query string true "页数"
- // @Param startAt query string false "开始时间"
- // @Param endAt query string false "结束时间"
- // @Param direction query string false "流水方向(1.收入 2.支出 0.全部)"
- // @Success 200 {object} md.GetAmountFlowResp "具体数据"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/v1/wallet/amountFlow [GET]
- func GetAmountFlow(c *gin.Context) {
- pageStr := c.DefaultQuery("page", "1")
- limitStr := c.DefaultQuery("limit", "10")
- startAt := c.Query("startAt")
- endAt := c.Query("endAt")
- directionStr := c.Query("direction")
-
- val, exists := c.Get("user")
- if !exists {
- e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
- return
- }
- user, ok := val.(*model.User)
- if !ok {
- e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
- return
- }
-
- direction := 0
- switch directionStr {
- case "1":
- direction = 1
- case "2":
- direction = 2
- }
-
- page := utils.StrToInt(pageStr)
- limit := utils.StrToInt(limitStr)
-
- flowDb := implement.NewUserWalletFlowDb(db.Db)
- flows, total, err := flowDb.UserWalletFlowFindByCoinAndUser(page, limit, user.Id, startAt, endAt, direction, false, 0, 0)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- list := make([]md.WalletFlowNode, 0, len(flows))
- for _, flow := range flows {
- temp := md.WalletFlowNode{
- Id: flow.Id,
- Uid: flow.Uid,
- Direction: flow.Direction,
- Amount: flow.Amount,
- BeforeAmount: flow.BeforeAmount,
- AfterAmount: flow.AfterAmount,
- SysFee: flow.SysFee,
- OrdId: flow.OrdId,
- Title: flow.Title,
- Kind: flow.Kind,
- State: flow.State,
- Memo: flow.Memo,
- CreateTime: flow.CreateAt,
- UpdateTime: flow.UpdateAt,
- }
- list = append(list, temp)
- }
-
- resp := md.GetAmountFlowResp{
- List: list,
- Paginate: md.Paginate{
- Limit: limit,
- Page: page,
- Total: total,
- },
- }
- e.OutSuc(c, resp, nil)
- }
-
- // WithdrawGetAmount
- // @Summary 蛋蛋星球-钱包-提现余额(获取)
- // @Tags 钱包
- // @Description 提现余额(获取)
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Success 200 {object} md.WithdrawGetAmountResp "具体数据"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/v1/wallet/withdraw/index [GET]
- func WithdrawGetAmount(c *gin.Context) {
- val, exists := c.Get("user")
- if !exists {
- e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
- return
- }
- user, ok := val.(*model.User)
- if !ok {
- e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
- return
- }
-
- walletDb := implement.NewUserWalletDb(db.Db)
- wallet, err := walletDb.GetUserVirtualWallet(user.Id)
- if err != nil {
- e.OutErr(c, e.ERR_DB_ORM, err.Error())
- return
- }
-
- resp := md.WithdrawGetAmountResp{
- Amount: wallet.Amount,
- }
- e.OutSuc(c, resp, nil)
- }
|