37 Star 183 Fork 73

史蒂芬-库外 / dongfeng-pay

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
account_history.go 2.23 KB
一键复制 编辑 原始数据 按行查看 历史
Joker 提交于 2019-12-19 16:43 . modify imports name
/***************************************************
** @Desc : This file for 账户变动
** @Time : 19.12.10 10:42
** @Author : Joker
** @File : account_history
** @Last Modified by : Joker
** @Last Modified time: 19.12.10 10:42
** @Software: GoLand
****************************************************/
package controllers
import (
"dongfeng-pay/jhmerchant/sys/enum"
"dongfeng-pay/service/models"
"strconv"
"strings"
)
type History struct {
KeepSession
}
// 账户资产变动列表
// @router /history/show_history_list_ui
func (c *History) ShowHistoryListUI() {
us := c.GetSession(enum.UserSession)
u := us.(models.MerchantInfo)
ranMd5 := encrypt.EncodeMd5([]byte(pubMethod.RandomString(46)))
c.Ctx.SetCookie(enum.UserCookie, ranMd5, enum.CookieExpireTime)
c.Ctx.SetSecureCookie(ranMd5, enum.UserCookie, ranMd5, enum.CookieExpireTime)
c.SetSession(enum.UserCookie, ranMd5)
c.Data["payType"] = enum.GetHistoryStatus()
c.Data["userName"] = u.MerchantName
c.TplName = "history_record.html"
}
// @router /history/list_history_record/?:params [get,post]
func (c *History) HistoryQueryAndListPage() {
us := c.GetSession(enum.UserSession)
u := us.(models.MerchantInfo)
// 分页参数
page, _ := strconv.Atoi(c.GetString("page"))
limit, _ := strconv.Atoi(c.GetString("limit"))
if limit == 0 {
limit = 15
}
// 查询参数
in := make(map[string]string)
start := strings.TrimSpace(c.GetString("start"))
end := strings.TrimSpace(c.GetString("end"))
status := strings.TrimSpace(c.GetString("status"))
in["type"] = status
in["account_uid"] = u.MerchantUid
if start != "" {
in["create_time__gte"] = start
}
if end != "" {
in["create_time__lte"] = end
}
// 计算分页数
count := models.GetAccountHistoryLenByMap(in)
totalPage := count / limit // 计算总页数
if count%limit != 0 { // 不满一页的数据按一页计算
totalPage++
}
// 数据获取
var list []models.AccountHistoryInfo
if page <= totalPage {
list = models.GetAccountHistoryByMap(in, limit, (page-1)*limit)
}
// 数据回显
out := make(map[string]interface{})
out["limit"] = limit // 分页数据
out["page"] = page
out["totalPage"] = totalPage
out["root"] = list // 显示数据
c.Data["json"] = out
c.ServeJSON()
c.StopRun()
}
Go
1
https://gitee.com/kongyuebin/dongfeng-pay.git
git@gitee.com:kongyuebin/dongfeng-pay.git
kongyuebin
dongfeng-pay
dongfeng-pay
8d4382cc82da

搜索帮助