mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-11-08 07:47:32 +08:00
由gopath形式改为module
This commit is contained in:
88
agent/controllers/account_history.go
Normal file
88
agent/controllers/account_history.go
Normal file
@@ -0,0 +1,88 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"agent/models"
|
||||
"agent/sys/enum"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type History struct {
|
||||
KeepSession
|
||||
}
|
||||
|
||||
// 账户资产变动列表
|
||||
func (c *History) ShowHistoryListUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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.AgentName
|
||||
c.TplName = "history_record.html"
|
||||
}
|
||||
|
||||
func (c *History) HistoryQueryAndListPage() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
// 分页参数
|
||||
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.AgentUid
|
||||
|
||||
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()
|
||||
}
|
||||
435
agent/controllers/deal_excel.go
Normal file
435
agent/controllers/deal_excel.go
Normal file
@@ -0,0 +1,435 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for 处理Excel文件
|
||||
** @Time : 19.12.6 16:25
|
||||
** @Author : Joker
|
||||
** @File : deal_excel
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 19.12.6 16:25
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"agent/models"
|
||||
"agent/sys/enum"
|
||||
"agent/utils"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/tealeg/xlsx"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DealExcel struct {
|
||||
KeepSession
|
||||
}
|
||||
|
||||
// 下载模板
|
||||
func (c *DealExcel) DownloadExcelModel() {
|
||||
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.Ctx.Output.Download(enum.ExcelModelPath, enum.ExcelModelName)
|
||||
}
|
||||
|
||||
// 导出订单记录
|
||||
func (c *DealExcel) MakeOrderExcel() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
// 查询参数
|
||||
in := make(map[string]string)
|
||||
merchantName := strings.TrimSpace(c.GetString("merchantName"))
|
||||
start := strings.TrimSpace(c.GetString("start"))
|
||||
end := strings.TrimSpace(c.GetString("end"))
|
||||
payType := strings.TrimSpace(c.GetString("pay_type"))
|
||||
status := strings.TrimSpace(c.GetString("status"))
|
||||
|
||||
in["merchant_name__icontains"] = merchantName
|
||||
in["pay_type_code"] = payType
|
||||
in["status"] = status
|
||||
in["agent_uid"] = u.AgentUid
|
||||
|
||||
if start != "" {
|
||||
in["update_time__gte"] = start
|
||||
}
|
||||
if end != "" {
|
||||
in["update_time__lte"] = end
|
||||
}
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.FailedFlag
|
||||
fileName = "trade_order-" + pubMethod.GetNowTimeV2() + pubMethod.RandomString(6) + ".xlsx"
|
||||
|
||||
file *xlsx.File
|
||||
sheet *xlsx.Sheet
|
||||
row *xlsx.Row
|
||||
cell *xlsx.Cell
|
||||
err error
|
||||
)
|
||||
|
||||
// 数据获取
|
||||
list := models.GetOrderProfitByMap(in, -1, 0)
|
||||
if len(list) <= 0 {
|
||||
msg = "没有检索到数据!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
// 写入记录
|
||||
file = xlsx.NewFile()
|
||||
sheet, err = file.AddSheet("订单记录")
|
||||
if err != nil {
|
||||
utils.LogError(fmt.Sprintf("代理商户:%s 导出订单记录,发生错误:%v", u.AgentName, err))
|
||||
msg = enum.FailedToAdmin
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
// 第一行
|
||||
row = sheet.AddRow()
|
||||
row.SetHeightCM(1)
|
||||
cell = row.AddCell()
|
||||
cell.Value = "平台订单号"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "商户订单号"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "支付方式"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "订单金额"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "收入金额"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "平台手续费"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "代理商手续费"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "状 态"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "成功支付时间"
|
||||
for _, v := range list {
|
||||
addRow := sheet.AddRow()
|
||||
addCell := addRow.AddCell()
|
||||
addCell.Value = v.BankOrderId
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.MerchantOrderId
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.PayProductName
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = fmt.Sprintf("%f", v.OrderAmount)
|
||||
|
||||
var (
|
||||
st = ""
|
||||
t string
|
||||
)
|
||||
switch v.Status {
|
||||
case "failed":
|
||||
st = "交易失败"
|
||||
case "wait":
|
||||
st = "等待支付"
|
||||
case "success":
|
||||
st = "交易成功"
|
||||
t = v.UpdateTime
|
||||
}
|
||||
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = fmt.Sprintf("%f", v.UserInAmount)
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = fmt.Sprintf("%f", v.PlatformProfit)
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = fmt.Sprintf("%f", v.AgentProfit)
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = st
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = t
|
||||
}
|
||||
|
||||
err = file.Save(enum.ExcelDownloadPath + fileName)
|
||||
if err != nil {
|
||||
utils.LogError(fmt.Sprintf("代理商户:%s 导出订单记录,保存文件发生错误:%v", u.AgentName, err))
|
||||
msg = enum.FailedToAdmin
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
flag = enum.SuccessFlag
|
||||
msg = fileName
|
||||
|
||||
stopRun:
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, "")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 下载excel
|
||||
func (c *DealExcel) DownloadRecordExcel() {
|
||||
fileName := c.GetString(":params")
|
||||
file := enum.ExcelDownloadPath + fileName
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
logs.Error(fmt.Sprintf("%s此文件不存在", file))
|
||||
time.Sleep(3 * time.Second)
|
||||
}
|
||||
}()
|
||||
// 删除临时文件
|
||||
go func() {
|
||||
tk := time.NewTicker(5 * time.Minute)
|
||||
select {
|
||||
case <-tk.C:
|
||||
_ = os.Remove(file)
|
||||
tk.Stop()
|
||||
}
|
||||
}()
|
||||
|
||||
c.Ctx.Output.Download(file, fileName)
|
||||
}
|
||||
|
||||
// 导出投诉记录
|
||||
func (c *DealExcel) MakeComplaintExcel() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
// 查询参数
|
||||
in := make(map[string]string)
|
||||
merchantName := strings.TrimSpace(c.GetString("merchantName"))
|
||||
start := strings.TrimSpace(c.GetString("start"))
|
||||
end := strings.TrimSpace(c.GetString("end"))
|
||||
payType := strings.TrimSpace(c.GetString("pay_type"))
|
||||
status := strings.TrimSpace(c.GetString("status"))
|
||||
|
||||
in["pay_type_code"] = payType
|
||||
in["merchant_name__icontains"] = merchantName
|
||||
if strings.Compare("YES", status) == 0 {
|
||||
in["freeze"] = enum.YES
|
||||
} else {
|
||||
in["refund"] = enum.YES
|
||||
}
|
||||
in["agent_uid"] = u.AgentUid
|
||||
|
||||
if start != "" {
|
||||
in["update_time__gte"] = start
|
||||
}
|
||||
if end != "" {
|
||||
in["update_time__lte"] = end
|
||||
}
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.FailedFlag
|
||||
fileName = "complaint_order-" + pubMethod.GetNowTimeV2() + pubMethod.RandomString(6) + ".xlsx"
|
||||
|
||||
file *xlsx.File
|
||||
sheet *xlsx.Sheet
|
||||
row *xlsx.Row
|
||||
cell *xlsx.Cell
|
||||
err error
|
||||
)
|
||||
|
||||
// 数据获取
|
||||
list := models.GetOrderByMap(in, -1, 0)
|
||||
if len(list) <= 0 {
|
||||
msg = "没有检索到数据!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
// 写入记录
|
||||
file = xlsx.NewFile()
|
||||
sheet, err = file.AddSheet("投诉记录")
|
||||
if err != nil {
|
||||
utils.LogError(fmt.Sprintf("代理商户:%s 导出投诉记录,发生错误:%v", u.AgentName, err))
|
||||
msg = enum.FailedToAdmin
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
// 第一行
|
||||
row = sheet.AddRow()
|
||||
row.SetHeightCM(1)
|
||||
cell = row.AddCell()
|
||||
cell.Value = "平台流水号"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "商户订单号"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "支付方式"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "订单金额"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "状 态"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "冻结时间"
|
||||
for _, v := range list {
|
||||
addRow := sheet.AddRow()
|
||||
addCell := addRow.AddCell()
|
||||
addCell.Value = v.BankOrderId
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.MerchantOrderId
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.PayProductName
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = fmt.Sprintf("%f", v.OrderAmount)
|
||||
|
||||
var st = ""
|
||||
switch v.Freeze {
|
||||
case "yes":
|
||||
st = "已冻结"
|
||||
case "no":
|
||||
st = "已退款"
|
||||
}
|
||||
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = st
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.UpdateTime
|
||||
}
|
||||
|
||||
err = file.Save(enum.ExcelDownloadPath + fileName)
|
||||
if err != nil {
|
||||
utils.LogError(fmt.Sprintf("代理商户:%s 导出投诉记录,保存文件发生错误:%v", u.AgentName, err))
|
||||
msg = enum.FailedToAdmin
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
flag = enum.SuccessFlag
|
||||
msg = fileName
|
||||
|
||||
stopRun:
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, "")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 导出提现记录
|
||||
func (c *DealExcel) MakeWithdrawExcel() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
// 查询参数
|
||||
in := make(map[string]string)
|
||||
start := strings.TrimSpace(c.GetString("start"))
|
||||
end := strings.TrimSpace(c.GetString("end"))
|
||||
status := strings.TrimSpace(c.GetString("status"))
|
||||
|
||||
in["status"] = status
|
||||
in["merchant_uid"] = u.AgentUid
|
||||
|
||||
if start != "" {
|
||||
in["update_time__gte"] = start
|
||||
}
|
||||
if end != "" {
|
||||
in["update_time__lte"] = end
|
||||
}
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.FailedFlag
|
||||
fileName = "withdraw_order-" + pubMethod.GetNowTimeV2() + pubMethod.RandomString(6) + ".xlsx"
|
||||
|
||||
file *xlsx.File
|
||||
sheet *xlsx.Sheet
|
||||
row *xlsx.Row
|
||||
cell *xlsx.Cell
|
||||
err error
|
||||
)
|
||||
|
||||
// 数据获取
|
||||
list := models.GetPayForByMap(in, -1, 0)
|
||||
if len(list) <= 0 {
|
||||
msg = "没有检索到数据!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
// 写入记录
|
||||
file = xlsx.NewFile()
|
||||
sheet, err = file.AddSheet("提现记录")
|
||||
if err != nil {
|
||||
utils.LogError(fmt.Sprintf("代理商户:%s 导出提现记录,发生错误:%v", u.AgentName, err))
|
||||
msg = enum.FailedToAdmin
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
// 第一行
|
||||
row = sheet.AddRow()
|
||||
row.SetHeightCM(1)
|
||||
cell = row.AddCell()
|
||||
cell.Value = "平台订单号"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "商户订单号"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "结算金额"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "手续费"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "银行名称"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "开户名"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "开户账户"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "状 态"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "创建时间"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "打款时间"
|
||||
cell = row.AddCell()
|
||||
cell.Value = "备注"
|
||||
for _, v := range list {
|
||||
addRow := sheet.AddRow()
|
||||
addCell := addRow.AddCell()
|
||||
addCell.Value = v.BankOrderId
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.MerchantOrderId
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = fmt.Sprintf("%f", v.PayforTotalAmount)
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = fmt.Sprintf("%f", v.PayforFee)
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.BankName
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.BankAccountName
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.BankAccountNo
|
||||
|
||||
var (
|
||||
st = ""
|
||||
t string
|
||||
)
|
||||
switch v.Status {
|
||||
case "payfor_confirm":
|
||||
st = "等待审核"
|
||||
case "payfor_solving":
|
||||
st = "系统处理中"
|
||||
case "payfor_banking":
|
||||
st = "银行处理中"
|
||||
case "success":
|
||||
st = "代付成功"
|
||||
t = v.UpdateTime
|
||||
case "failed":
|
||||
st = "代付失败"
|
||||
}
|
||||
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = st
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.CreateTime
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = t
|
||||
addCell = addRow.AddCell()
|
||||
addCell.Value = v.Remark
|
||||
}
|
||||
|
||||
err = file.Save(enum.ExcelDownloadPath + fileName)
|
||||
if err != nil {
|
||||
utils.LogError(fmt.Sprintf("代理商户:%s 导出提现记录,保存文件发生错误:%v", u.AgentName, err))
|
||||
msg = enum.FailedToAdmin
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
flag = enum.SuccessFlag
|
||||
msg = fileName
|
||||
|
||||
stopRun:
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, "")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
158
agent/controllers/index.go
Normal file
158
agent/controllers/index.go
Normal file
@@ -0,0 +1,158 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for 首页
|
||||
** @Time : 19.11.30 11:49
|
||||
** @Author : Joker
|
||||
** @File : index
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 19.11.30 11:49
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"agent/models"
|
||||
"agent/sys/enum"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Index struct {
|
||||
KeepSession
|
||||
}
|
||||
|
||||
// 首页
|
||||
func (c *Index) ShowUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
c.Data["userName"] = u.AgentName
|
||||
c.TplName = "index.html"
|
||||
}
|
||||
|
||||
// 加载用户账户金额信息
|
||||
func (c *Index) LoadUserAccountInfo() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
ac := models.GetAccountByUid(u.AgentUid)
|
||||
|
||||
info := make(map[string]interface{})
|
||||
// 账户余额
|
||||
info["balanceAmt"] = pubMethod.FormatFloat64ToString(ac.Balance)
|
||||
|
||||
// 可用余额
|
||||
info["settAmount"] = pubMethod.FormatFloat64ToString(ac.WaitAmount)
|
||||
|
||||
// 冻结金额
|
||||
info["freezeAmt"] = pubMethod.FormatFloat64ToString(ac.FreezeAmount)
|
||||
|
||||
// 押款金额
|
||||
info["amountFrozen"] = pubMethod.FormatFloat64ToString(ac.LoanAmount)
|
||||
|
||||
c.Data["json"] = info
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 加载总订单信息
|
||||
func (c *Index) LoadCountOrder() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
md := models.GetMerchantDeployByUid(u.AgentUid)
|
||||
|
||||
type orderInPayWay struct {
|
||||
PayWayName string // 支付方式名
|
||||
OrderCount int // 订单数
|
||||
SucOrderCount int // 成功订单数
|
||||
SucRate string // 成功率
|
||||
}
|
||||
|
||||
ways := make([]orderInPayWay, len(md))
|
||||
|
||||
for k, v := range md {
|
||||
in := make(map[string]string)
|
||||
in["agent_uid"] = u.AgentUid
|
||||
|
||||
ways[k].PayWayName = models.GetRoadInfoByRoadUid(v.SingleRoadUid).ProductName
|
||||
|
||||
in["road_uid"] = v.SingleRoadUid
|
||||
ways[k].OrderCount = models.GetOrderLenByMap(in)
|
||||
|
||||
in["status"] = enum.SUCCESS
|
||||
ways[k].SucOrderCount = models.GetOrderLenByMap(in)
|
||||
|
||||
if ways[k].OrderCount == 0 {
|
||||
ways[k].SucRate = "0"
|
||||
continue
|
||||
}
|
||||
ways[k].SucRate = fmt.Sprintf("%0.4f", float64(ways[k].SucOrderCount)/float64(ways[k].OrderCount))
|
||||
}
|
||||
|
||||
c.Data["json"] = ways
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 加载总订单数
|
||||
func (c *Index) LoadOrderCount() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
out := make(map[string]interface{})
|
||||
|
||||
in := make(map[string]string)
|
||||
in["agent_uid"] = u.AgentUid
|
||||
out["orders"] = models.GetOrderLenByMap(in)
|
||||
|
||||
in["status"] = enum.SUCCESS
|
||||
out["suc_orders"] = models.GetOrderLenByMap(in)
|
||||
|
||||
if out["orders"].(int) == 0 {
|
||||
out["suc_rate"] = 0
|
||||
} else {
|
||||
out["suc_rate"] = fmt.Sprintf("%0.4f", float64(out["suc_orders"].(int))/float64(out["orders"].(int)))
|
||||
}
|
||||
|
||||
c.Data["json"] = out
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 加载用户支付配置
|
||||
func (c *Index) LoadUserPayWayUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
c.Data["userName"] = u.AgentName
|
||||
c.TplName = "pay_way.html"
|
||||
}
|
||||
|
||||
func (c *Index) LoadUserPayWay() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
md := models.GetMerchantDeployByUid(u.AgentUid)
|
||||
|
||||
type payConfig struct {
|
||||
No string // 通道编号
|
||||
Name string // 产品名
|
||||
PlatRate float64 // 通道费率
|
||||
AgentRate float64 // 通道费率
|
||||
}
|
||||
|
||||
ways := make([]payConfig, len(md))
|
||||
|
||||
for k, v := range md {
|
||||
road := models.GetRoadInfoByRoadUid(v.SingleRoadUid)
|
||||
ways[k].No = road.RoadUid
|
||||
|
||||
ways[k].Name = road.ProductName
|
||||
|
||||
ways[k].PlatRate = road.BasicFee + v.SingleRoadPlatformRate + v.SingleRoadAgentRate
|
||||
ways[k].AgentRate = v.SingleRoadAgentRate
|
||||
}
|
||||
|
||||
c.Data["json"] = ways
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
51
agent/controllers/keep_session.go
Normal file
51
agent/controllers/keep_session.go
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for 保持会话
|
||||
** @Time : 19.11.29 13:55
|
||||
** @Author : Joker
|
||||
** @File : keep_session
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 19.11.29 13:55
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"agent/sys/enum"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type KeepSession struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
// 生成随机md5值,客户端和服务端各保存一份
|
||||
// 客户端每次请求都将重写md5值
|
||||
// 若用户在30分钟内没有操作行为或连续操作时间超过3小时,则自动退出
|
||||
func (c *KeepSession) Prepare() {
|
||||
// 以免session值不是string类型而panic
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
c.DelSession(enum.UserSession)
|
||||
c.Ctx.Redirect(302, "/")
|
||||
}
|
||||
}()
|
||||
|
||||
us := c.GetSession(enum.UserSession)
|
||||
uc := c.GetSession(enum.UserCookie)
|
||||
if us == nil || uc == nil {
|
||||
c.DelSession(enum.UserSession)
|
||||
c.Ctx.Redirect(302, "/")
|
||||
}
|
||||
|
||||
if uc.(string) == "" {
|
||||
c.DelSession(enum.UserSession)
|
||||
c.Ctx.Redirect(302, "/")
|
||||
}
|
||||
|
||||
_, b := c.Ctx.GetSecureCookie(uc.(string), enum.UserCookie)
|
||||
//utils.LogNotice(fmt.Sprintf("客户端cookie:%s,服务端cookie:%s", cookie, uc.(string)))
|
||||
if !b {
|
||||
c.DelSession(enum.UserSession)
|
||||
c.Ctx.Redirect(302, "/")
|
||||
}
|
||||
}
|
||||
156
agent/controllers/login.go
Normal file
156
agent/controllers/login.go
Normal file
@@ -0,0 +1,156 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for 用户登录
|
||||
** @Time : 19.11.29 13:52
|
||||
** @Author : Joker
|
||||
** @File : login
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 19.11.29 13:52
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"agent/models"
|
||||
"agent/sys"
|
||||
"agent/sys/enum"
|
||||
"agent/utils"
|
||||
"fmt"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/dchest/captcha"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var pubMethod = sys.PublicMethod{}
|
||||
var encrypt = utils.Encrypt{}
|
||||
|
||||
type Login struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *Login) UserLogin() {
|
||||
captchaCode := c.GetString("captchaCode")
|
||||
captchaId := c.GetString("captchaId")
|
||||
userName := strings.TrimSpace(c.GetString("userName"))
|
||||
password := c.GetString("Password")
|
||||
|
||||
var (
|
||||
flag = enum.FailedFlag
|
||||
msg = ""
|
||||
url = "/"
|
||||
|
||||
pwdMd5 string
|
||||
ran string
|
||||
ranMd5 string
|
||||
|
||||
verify bool
|
||||
u models.AgentInfo
|
||||
)
|
||||
|
||||
us := c.GetSession(enum.UserSession)
|
||||
fmt.Println(us)
|
||||
if us != nil {
|
||||
url = enum.DoMainUrl
|
||||
flag = enum.SuccessFlag
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
if userName == "" || password == "" {
|
||||
msg = "登录账号或密码不能为空!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
verify = captcha.VerifyString(captchaId, captchaCode)
|
||||
if !verify {
|
||||
url = strconv.Itoa(enum.FailedFlag)
|
||||
msg = "验证码不正确!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
u = models.GetAgentInfoByPhone(userName)
|
||||
if u.AgentPassword == "" {
|
||||
msg = "账户信息错误,请联系管理人员!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
if strings.Compare(enum.ACTIVE, u.Status) != 0 {
|
||||
msg = "登录账号或密码错误!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
//验证密码
|
||||
pwdMd5 = encrypt.EncodeMd5([]byte(password))
|
||||
if strings.Compare(strings.ToUpper(pwdMd5), u.AgentPassword) != 0 {
|
||||
msg = "登录账号或密码错误!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
c.SetSession(enum.UserSession, u)
|
||||
|
||||
// 设置客户端用户信息有效保存时间
|
||||
ran = pubMethod.RandomString(46)
|
||||
ranMd5 = encrypt.EncodeMd5([]byte(ran))
|
||||
c.Ctx.SetSecureCookie(ranMd5, enum.UserCookie, ranMd5, enum.CookieExpireTime)
|
||||
c.SetSession(enum.UserCookie, ranMd5)
|
||||
|
||||
url = enum.DoMainUrl
|
||||
flag = enum.SuccessFlag
|
||||
//logs.Notice(fmt.Sprintf("【%s】代理商登录成功,请求IP:%s", u.AgentName, c.Ctx.Input.IP())
|
||||
|
||||
stopRun:
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, url)
|
||||
fmt.Println(c.Data["json"])
|
||||
c.ServeJSON()
|
||||
//c.StopRun()
|
||||
}
|
||||
|
||||
func (c *Login) Index() {
|
||||
capt := struct {
|
||||
CaptchaId string
|
||||
}{
|
||||
captcha.NewLen(4),
|
||||
}
|
||||
c.Data["CaptchaId"] = capt.CaptchaId
|
||||
c.TplName = "login.html"
|
||||
}
|
||||
|
||||
// 验证输入的验证码
|
||||
func (c *Login) VerifyCaptcha() {
|
||||
captchaValue := c.Ctx.Input.Param(":value")
|
||||
captchaId := c.Ctx.Input.Param(":chaId")
|
||||
|
||||
verify := captcha.VerifyString(captchaId, captchaValue)
|
||||
if verify {
|
||||
c.Data["json"] = pubMethod.JsonFormat(enum.SuccessFlag, "", "", "")
|
||||
} else {
|
||||
c.Data["json"] = pubMethod.JsonFormat(enum.FailedFlag, "", "验证码不匹配!", "")
|
||||
}
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 重绘验证码
|
||||
func (c *Login) FlushCaptcha() {
|
||||
capt := struct {
|
||||
CaptchaId string
|
||||
}{
|
||||
captcha.NewLen(4),
|
||||
}
|
||||
c.Data["json"] = pubMethod.JsonFormat(enum.SuccessFlag, capt.CaptchaId, "验证码不匹配!", "")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
func (c *Login) LoginOut() {
|
||||
c.DelSession(enum.UserSession)
|
||||
|
||||
c.Data["json"] = pubMethod.JsonFormat(enum.FailedFlag, "", "", "/")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 对接文档
|
||||
func (c *Login) PayDoc() {
|
||||
c.TplName = "api_doc/pay_doc.html"
|
||||
}
|
||||
250
agent/controllers/multi_withdraw.go
Normal file
250
agent/controllers/multi_withdraw.go
Normal file
@@ -0,0 +1,250 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for 批量提现
|
||||
** @Time : 19.12.6 17:07
|
||||
** @Author : Joker
|
||||
** @File : multi_withdraw
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 19.12.6 17:07
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"agent/common"
|
||||
"agent/models"
|
||||
"agent/sys/enum"
|
||||
"agent/utils"
|
||||
"fmt"
|
||||
"github.com/rs/xid"
|
||||
"github.com/tealeg/xlsx"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MultiWithdraw struct {
|
||||
KeepSession
|
||||
}
|
||||
|
||||
func (c *MultiWithdraw) ShowMultiWithdrawUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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["userName"] = u.AgentName
|
||||
c.TplName = "withdraw/multi_withdraw.html"
|
||||
}
|
||||
|
||||
// 申请批量提现
|
||||
func (c *Withdraw) LaunchMultiWithdraw() {
|
||||
mobileCode := strings.TrimSpace(c.GetString("mobileCode"))
|
||||
file, header, err := c.GetFile("file")
|
||||
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.FailedFlag
|
||||
|
||||
b bool
|
||||
|
||||
url string
|
||||
)
|
||||
|
||||
fileName := header.Filename
|
||||
defer file.Close()
|
||||
split := strings.Split(fileName, ".")
|
||||
if len(split) < 2 {
|
||||
msg = "请选择批量文件!"
|
||||
goto stopRun
|
||||
}
|
||||
if strings.Compare(strings.ToLower(split[1]), "xls") != 0 &&
|
||||
strings.Compare(strings.ToLower(split[1]), "xlsx") != 0 {
|
||||
msg = "仅支持“xls”、“xlsx”格式文件!"
|
||||
goto stopRun
|
||||
}
|
||||
if err != nil {
|
||||
msg = "请上传批量文件! " + err.Error()
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
if u.PayPassword == "" {
|
||||
msg = "请设置支付密码!"
|
||||
goto stopRun
|
||||
}
|
||||
if strings.Compare(strings.ToUpper(encrypt.EncodeMd5([]byte(mobileCode))), u.PayPassword) != 0 {
|
||||
msg = "支付密码输入错误!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
u = models.GetAgentInfoByAgentUid(u.AgentUid)
|
||||
if strings.Compare(enum.ACTIVE, u.Status) != 0 {
|
||||
msg = "商户状态异常,请联系管理人员!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
b, msg = handleFileContent(split[0], u, c)
|
||||
if b {
|
||||
flag = enum.SuccessFlag
|
||||
url = "/withdraw/show_list_ui"
|
||||
}
|
||||
|
||||
stopRun:
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, url)
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
func handleFileContent(name string, u models.AgentInfo, c *Withdraw) (bool, string) {
|
||||
// 重命名文件
|
||||
fileName := name + " - " + pubMethod.GetNowTimeV2() + pubMethod.RandomString(4) + ".xlsx"
|
||||
|
||||
// 保存文件
|
||||
_ = c.SaveToFile("file", path.Join(enum.ExcelPath, fileName))
|
||||
|
||||
// 读取文件内容
|
||||
xlFile, err := xlsx.OpenFile(enum.ExcelPath + fileName)
|
||||
if err != nil {
|
||||
msg := "文件内容错误:" + err.Error()
|
||||
utils.LogInfo(msg)
|
||||
return false, msg
|
||||
}
|
||||
|
||||
// 只读取文档中第一个工作表,忽略其他工作表
|
||||
sheet := xlFile.Sheets[0]
|
||||
line, err := sheet.Row(0).Cells[1].Int()
|
||||
if err != nil {
|
||||
msg := "请输入正确的总笔数:" + err.Error()
|
||||
utils.LogInfo(msg)
|
||||
return false, msg
|
||||
}
|
||||
if line <= 0 {
|
||||
msg := "请输入正确的总笔数!"
|
||||
return false, msg
|
||||
}
|
||||
if line > 300 {
|
||||
line = 300
|
||||
}
|
||||
|
||||
ac := models.GetAccountByUid(u.AgentUid)
|
||||
if strings.Compare(enum.ACTIVE, ac.Status) != 0 {
|
||||
msg := "账户状态异常,请联系管理人员!"
|
||||
return false, msg
|
||||
}
|
||||
// 后台处理文件,不让用户等待
|
||||
go func() {
|
||||
for k, row := range sheet.Rows {
|
||||
if k == 0 || k == 1 {
|
||||
continue
|
||||
}
|
||||
|
||||
// 数据行数不得超过指定行数
|
||||
if k == line+2 || k == 301 {
|
||||
break
|
||||
}
|
||||
|
||||
// 出现空行,则忽略后面记录
|
||||
if row.Cells[0].String() == "" || row.Cells[4].String() == "" {
|
||||
break
|
||||
}
|
||||
|
||||
bankAccountType := row.Cells[3].String()
|
||||
ac := models.GetAccountByUid(u.AgentUid)
|
||||
b, msg, code := verifyFileContent(row.Cells[0].String(), row.Cells[1].String(), row.Cells[2].String(), bankAccountType,
|
||||
row.Cells[4].String(), ac)
|
||||
if !b {
|
||||
utils.LogInfo(fmt.Sprintf("用户:%s 批量代付中,第 %d 行记录出现错误:%s", u.AgentName, k+1, msg))
|
||||
// 账户可用余额不足,终止读取记录
|
||||
if code == 5009 {
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Compare("对公", bankAccountType) == 0 {
|
||||
bankAccountType = enum.PublicAccount
|
||||
} else {
|
||||
bankAccountType = enum.PrivateDebitAccount
|
||||
}
|
||||
|
||||
money, _ := strconv.ParseFloat(row.Cells[4].String(), 10)
|
||||
payFor := models.PayforInfo{
|
||||
PayforUid: "pppp" + xid.New().String(),
|
||||
MerchantUid: u.AgentUid,
|
||||
MerchantName: u.AgentName,
|
||||
PhoneNo: u.AgentPhone,
|
||||
MerchantOrderId: xid.New().String(),
|
||||
BankOrderId: "4444" + xid.New().String(),
|
||||
PayforFee: common.PAYFOR_FEE,
|
||||
Type: common.SELF_MERCHANT,
|
||||
PayforAmount: money,
|
||||
PayforTotalAmount: money + common.PAYFOR_FEE,
|
||||
BankCode: "C",
|
||||
BankName: row.Cells[2].String(),
|
||||
IsSend: common.NO,
|
||||
BankAccountName: row.Cells[0].String(),
|
||||
BankAccountNo: row.Cells[1].String(),
|
||||
BankAccountType: bankAccountType,
|
||||
BankAccountAddress: row.Cells[2].String(),
|
||||
Status: common.PAYFOR_COMFRIM,
|
||||
CreateTime: pubMethod.GetNowTime(),
|
||||
UpdateTime: pubMethod.GetNowTime(),
|
||||
}
|
||||
|
||||
models.InsertPayfor(payFor)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
}()
|
||||
|
||||
return true, "提交成功,等待审核中,请在结算信息中查询状态!"
|
||||
}
|
||||
|
||||
// 验证文件内容是否规范
|
||||
func verifyFileContent(accountName, cardNo, bankAccountAddress, bankAccountType, amount string, ac models.AccountInfo) (bool, string, int) {
|
||||
if accountName == "" || cardNo == "" {
|
||||
msg := "账户名或卡号不能为空!"
|
||||
return false, msg, 5001
|
||||
}
|
||||
// 账户类型
|
||||
if strings.Compare("对公", bankAccountType) == 0 {
|
||||
if bankAccountAddress == "" {
|
||||
msg := "收款方开户机构名称不能为空!"
|
||||
return false, msg, 5002
|
||||
}
|
||||
}
|
||||
if amount == "" {
|
||||
msg := "金额不能为空!"
|
||||
return false, msg, 5003
|
||||
}
|
||||
matched, _ := regexp.MatchString(enum.MoneyReg, amount)
|
||||
if !matched {
|
||||
msg := "请输入正确的金额!"
|
||||
return false, msg, 5004
|
||||
}
|
||||
f, err := strconv.ParseFloat(amount, 10)
|
||||
if err != nil {
|
||||
msg := "请输入正确的金额! " + err.Error()
|
||||
return false, msg, 5007
|
||||
}
|
||||
|
||||
if f > enum.WithdrawalMaxAmount || f < enum.WithdrawalMinAmount || f+enum.SettlementFee > ac.WaitAmount {
|
||||
msg := fmt.Sprintf("单笔提现金额超出限制,提现金额:%f,账户可结算余额:%f,提现最小额:%d,最大额:%d,手续费:%d",
|
||||
f, ac.WaitAmount, enum.WithdrawalMinAmount, enum.WithdrawalMaxAmount, enum.SettlementFee)
|
||||
return false, msg, 5008
|
||||
}
|
||||
|
||||
if f+enum.SettlementFee > ac.Balance || ac.Balance <= 0 {
|
||||
msg := fmt.Sprintf("账户金额不足,提现金额:%f,账户余额:%f,手续费:%d",
|
||||
f, ac.Balance, enum.SettlementFee)
|
||||
return false, msg, 5009
|
||||
}
|
||||
return true, "", 5000
|
||||
}
|
||||
173
agent/controllers/trade_record.go
Normal file
173
agent/controllers/trade_record.go
Normal file
@@ -0,0 +1,173 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for 交易记录
|
||||
** @Time : 19.12.2 16:34
|
||||
** @Author : Joker
|
||||
** @File : trade_record
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 19.12.2 16:34
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"agent/models"
|
||||
"agent/sys/enum"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type TradeRecord struct {
|
||||
KeepSession
|
||||
}
|
||||
|
||||
func (c *TradeRecord) ShowUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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.GetPayType()
|
||||
c.Data["status"] = enum.GetOrderStatus()
|
||||
c.Data["userName"] = u.AgentName
|
||||
c.TplName = "trade_record.html"
|
||||
}
|
||||
|
||||
// 订单记录查询分页
|
||||
func (c *TradeRecord) TradeQueryAndListPage() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
// 分页参数
|
||||
page, _ := strconv.Atoi(c.GetString("page"))
|
||||
limit, _ := strconv.Atoi(c.GetString("limit"))
|
||||
if limit == 0 {
|
||||
limit = 15
|
||||
}
|
||||
|
||||
// 查询参数
|
||||
in := make(map[string]string)
|
||||
merchantNo := strings.TrimSpace(c.GetString("MerchantNo"))
|
||||
merchantName := strings.TrimSpace(c.GetString("merchantName"))
|
||||
start := strings.TrimSpace(c.GetString("start"))
|
||||
end := strings.TrimSpace(c.GetString("end"))
|
||||
payType := strings.TrimSpace(c.GetString("pay_type"))
|
||||
status := strings.TrimSpace(c.GetString("status"))
|
||||
|
||||
in["merchant_order_id"] = merchantNo
|
||||
in["merchant_name__icontains"] = merchantName
|
||||
in["pay_type_code"] = payType
|
||||
in["status"] = status
|
||||
in["agent_uid"] = u.AgentUid
|
||||
|
||||
if start != "" {
|
||||
in["update_time__gte"] = start
|
||||
}
|
||||
if end != "" {
|
||||
in["update_time_lte"] = end
|
||||
}
|
||||
|
||||
// 计算分页数
|
||||
count := models.GetOrderProfitLenByMap(in)
|
||||
totalPage := count / limit // 计算总页数
|
||||
if count%limit != 0 { // 不满一页的数据按一页计算
|
||||
totalPage++
|
||||
}
|
||||
|
||||
// 数据获取
|
||||
var list []models.OrderProfitInfo
|
||||
if page <= totalPage {
|
||||
list = models.GetOrderProfitByMap(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()
|
||||
}
|
||||
|
||||
func (c *TradeRecord) ShowComplaintUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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.GetPayType()
|
||||
c.Data["status"] = enum.GetComOrderStatus()
|
||||
c.Data["userName"] = u.AgentName
|
||||
c.TplName = "complaint_record.html"
|
||||
}
|
||||
|
||||
// 投诉列表查询分页
|
||||
func (c *TradeRecord) ComplaintQueryAndListPage() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
// 分页参数
|
||||
page, _ := strconv.Atoi(c.GetString("page"))
|
||||
limit, _ := strconv.Atoi(c.GetString("limit"))
|
||||
if limit == 0 {
|
||||
limit = 15
|
||||
}
|
||||
|
||||
// 查询参数
|
||||
in := make(map[string]string)
|
||||
merchantNo := strings.TrimSpace(c.GetString("MerchantNo"))
|
||||
merchantName := strings.TrimSpace(c.GetString("merchantName"))
|
||||
start := strings.TrimSpace(c.GetString("start"))
|
||||
end := strings.TrimSpace(c.GetString("end"))
|
||||
payType := strings.TrimSpace(c.GetString("pay_type"))
|
||||
status := strings.TrimSpace(c.GetString("status"))
|
||||
|
||||
in["merchant_order_id"] = merchantNo
|
||||
in["merchant_name__icontains"] = merchantName
|
||||
in["pay_type_code"] = payType
|
||||
if strings.Compare("YES", status) == 0 {
|
||||
in["freeze"] = enum.YES
|
||||
} else {
|
||||
in["refund"] = enum.YES
|
||||
}
|
||||
in["agent_uid"] = u.AgentUid
|
||||
|
||||
if start != "" {
|
||||
in["update_time__gte"] = start
|
||||
}
|
||||
if end != "" {
|
||||
in["update_time__lte"] = end
|
||||
}
|
||||
|
||||
// 计算分页数
|
||||
count := models.GetOrderLenByMap(in)
|
||||
totalPage := count / limit // 计算总页数
|
||||
if count%limit != 0 { // 不满一页的数据按一页计算
|
||||
totalPage++
|
||||
}
|
||||
|
||||
// 数据获取
|
||||
var list []models.OrderInfo
|
||||
if page <= totalPage {
|
||||
list = models.GetOrderByMap(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()
|
||||
}
|
||||
332
agent/controllers/user_info.go
Normal file
332
agent/controllers/user_info.go
Normal file
@@ -0,0 +1,332 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for 用户信息控制
|
||||
** @Time : 19.12.3 10:38
|
||||
** @Author : Joker
|
||||
** @File : user_info
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 19.12.3 10:38
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"agent/models"
|
||||
"agent/sys/enum"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type UserInfo struct {
|
||||
KeepSession
|
||||
}
|
||||
|
||||
func (c *UserInfo) ShowModifyUserInfoUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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["userName"] = u.AgentName
|
||||
c.TplName = "modify_userInfo.html"
|
||||
}
|
||||
|
||||
// 修改用户信息
|
||||
func (c *UserInfo) ModifyUserInfo() {
|
||||
or_pwd := strings.TrimSpace(c.GetString("or_pwd"))
|
||||
new_pwd := strings.TrimSpace(c.GetString("new_pwd"))
|
||||
confirm_pwd := strings.TrimSpace(c.GetString("confirm_pwd"))
|
||||
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.FailedFlag
|
||||
|
||||
md bool
|
||||
ud bool
|
||||
pwdMd5 string
|
||||
)
|
||||
|
||||
if or_pwd == "" ||
|
||||
new_pwd == "" ||
|
||||
confirm_pwd == "" {
|
||||
msg = "密码不能为空!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
pwdMd5 = encrypt.EncodeMd5([]byte(or_pwd))
|
||||
if strings.Compare(strings.ToUpper(pwdMd5), u.AgentPassword) != 0 {
|
||||
msg = "原始密码错误!"
|
||||
}
|
||||
|
||||
md, _ = regexp.MatchString(enum.PasswordReg, new_pwd)
|
||||
if !md {
|
||||
msg = "密码只能输入6-20个以字母开头、可带数字、“_”、“.”的字串!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
md, _ = regexp.MatchString(enum.PasswordReg, confirm_pwd)
|
||||
if !md {
|
||||
msg = "密码只能输入6-20个以字母开头、可带数字、“_”、“.”的字串!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
if strings.Compare(new_pwd, confirm_pwd) != 0 {
|
||||
msg = "两次密码不匹配!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
u.AgentPassword = strings.ToUpper(encrypt.EncodeMd5([]byte(new_pwd)))
|
||||
u.UpdateTime = pubMethod.GetNowTime()
|
||||
ud = models.UpdateAgentInfo(u)
|
||||
if ud {
|
||||
msg = enum.SuccessString
|
||||
flag = enum.SuccessFlag
|
||||
|
||||
// 退出重新登录
|
||||
c.DelSession(enum.UserSession)
|
||||
}
|
||||
|
||||
stopRun:
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, "")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 验证原始密码
|
||||
func (c *UserInfo) ConfirmOriginPwd() {
|
||||
ori := strings.TrimSpace(c.GetString("c"))
|
||||
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.FailedFlag
|
||||
)
|
||||
|
||||
pwdMd5 := encrypt.EncodeMd5([]byte(ori))
|
||||
if strings.Compare(strings.ToUpper(pwdMd5), u.AgentPassword) != 0 {
|
||||
msg = "原始密码错误!"
|
||||
} else {
|
||||
flag = enum.SuccessFlag
|
||||
}
|
||||
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, "")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 设置支付密码
|
||||
func (c *UserInfo) SetPayPassword() {
|
||||
or_pwd := strings.TrimSpace(c.GetString("or_pwd"))
|
||||
new_pwd := strings.TrimSpace(c.GetString("new_pwd"))
|
||||
confirm_pwd := strings.TrimSpace(c.GetString("confirm_pwd"))
|
||||
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.FailedFlag
|
||||
|
||||
md bool
|
||||
ud bool
|
||||
pwdMd5 string
|
||||
)
|
||||
|
||||
if new_pwd == "" || confirm_pwd == "" {
|
||||
msg = "密码不能为空!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
if u.PayPassword != "" {
|
||||
pwdMd5 = encrypt.EncodeMd5([]byte(or_pwd))
|
||||
if strings.Compare(strings.ToUpper(pwdMd5), u.AgentPassword) != 0 {
|
||||
msg = "原始密码错误!"
|
||||
}
|
||||
}
|
||||
|
||||
md, _ = regexp.MatchString(enum.PasswordReg, new_pwd)
|
||||
if !md {
|
||||
msg = "密码只能输入6-20个以字母开头、可带数字、“_”、“.”的字串!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
md, _ = regexp.MatchString(enum.PasswordReg, confirm_pwd)
|
||||
if !md {
|
||||
msg = "密码只能输入6-20个以字母开头、可带数字、“_”、“.”的字串!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
if strings.Compare(new_pwd, confirm_pwd) != 0 {
|
||||
msg = "两次密码不匹配!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
u.PayPassword = strings.ToUpper(encrypt.EncodeMd5([]byte(new_pwd)))
|
||||
u.UpdateTime = pubMethod.GetNowTime()
|
||||
ud = models.UpdateAgentInfo(u)
|
||||
if ud {
|
||||
msg = enum.SuccessString
|
||||
flag = enum.SuccessFlag
|
||||
|
||||
// 重新写入缓存信息
|
||||
c.SetSession(enum.UserSession, u)
|
||||
}
|
||||
|
||||
stopRun:
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, "")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 验证原始支付密码
|
||||
func (c *UserInfo) ConfirmOriginPayPwd() {
|
||||
ori := strings.TrimSpace(c.GetString("c"))
|
||||
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.SuccessFlag
|
||||
)
|
||||
|
||||
if u.PayPassword != "" {
|
||||
pwdMd5 := encrypt.EncodeMd5([]byte(ori))
|
||||
if strings.Compare(strings.ToUpper(pwdMd5), u.AgentPassword) != 0 {
|
||||
msg = "原始密码错误!"
|
||||
flag = enum.FailedFlag
|
||||
}
|
||||
}
|
||||
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, "")
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 展示用户信息
|
||||
func (c *UserInfo) ShowUserInfoUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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["userName"] = u.AgentName
|
||||
c.TplName = "show_userInfo.html"
|
||||
}
|
||||
|
||||
// 代理商列表
|
||||
func (c *UserInfo) ShowMerchantUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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.GetPayType()
|
||||
c.Data["status"] = enum.GetOrderStatus()
|
||||
c.Data["userName"] = u.AgentName
|
||||
c.TplName = "merchant.html"
|
||||
}
|
||||
|
||||
func (c *UserInfo) MerchantQueryAndListPage() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
mt := make(map[string]string)
|
||||
mt["belong_agent_uid"] = u.AgentUid
|
||||
mt["status"] = enum.ACTIVE
|
||||
|
||||
// 该代理商下所有正常商户
|
||||
merchants := models.GetMerchantByParams(mt, -1, 0)
|
||||
|
||||
type account struct {
|
||||
UId string
|
||||
MerchantName string // 商户名
|
||||
Mobile string // 手机号
|
||||
Balance float64 // 账户余额
|
||||
SettleAmount float64 // 已结算金额
|
||||
WaitAmount float64 // 待结算金额
|
||||
LoanAmount float64 // 押款金额
|
||||
FreezeAmount float64 // 账户冻结金额
|
||||
PayAmount float64 // 代付中金额
|
||||
}
|
||||
|
||||
type deploy struct {
|
||||
ChannelName string // 通道名
|
||||
PlatRate float64 // 平台费率
|
||||
AgentRate float64 // 代理商费率
|
||||
}
|
||||
|
||||
mtd := make(map[string]string)
|
||||
mtd["status"] = enum.ACTIVE
|
||||
var (
|
||||
count = 0 // 计算该代理商下的商户有多少个通道
|
||||
accounts []account // 每个商户的账户信息
|
||||
)
|
||||
for _, m := range merchants {
|
||||
mtd["merchant_uid"] = m.MerchantUid
|
||||
lens := models.GetMerchantDeployLenByMap(mtd)
|
||||
count += lens
|
||||
|
||||
ac := models.GetAccountByUid(m.MerchantUid)
|
||||
accounts = append(accounts, account{
|
||||
UId: m.MerchantUid,
|
||||
MerchantName: m.MerchantName,
|
||||
Mobile: m.LoginAccount,
|
||||
Balance: ac.Balance,
|
||||
SettleAmount: ac.SettleAmount,
|
||||
WaitAmount: ac.WaitAmount,
|
||||
LoanAmount: ac.LoanAmount,
|
||||
FreezeAmount: ac.FreezeAmount,
|
||||
PayAmount: ac.PayforAmount,
|
||||
})
|
||||
}
|
||||
|
||||
// 每个商户的通道信息
|
||||
deploys := make(map[string][]deploy)
|
||||
if count != 0 {
|
||||
for _, a := range accounts {
|
||||
mtd["merchant_uid"] = a.UId
|
||||
|
||||
mdl := models.GetMerchantDeployListByMap(mtd, -1, 0)
|
||||
for _, m := range mdl {
|
||||
road := models.GetRoadInfoByRoadUid(m.SingleRoadUid)
|
||||
fee := road.BasicFee + m.SingleRoadPlatformRate + m.SingleRoadAgentRate
|
||||
if fee < 0.00000001 {
|
||||
fee = road.BasicFee + m.RollRoadPlatformRate + m.RollRoadAgentRate
|
||||
}
|
||||
afee := m.SingleRoadAgentRate
|
||||
if afee < 0.00000001 {
|
||||
afee = m.RollRoadAgentRate
|
||||
}
|
||||
deploys[a.UId] = append(deploys[a.UId], deploy{
|
||||
ChannelName: road.ProductName,
|
||||
PlatRate: fee,
|
||||
AgentRate: afee,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 数据回显
|
||||
out := make(map[string]interface{})
|
||||
out["ac"] = accounts
|
||||
out["dp"] = deploys
|
||||
out["count"] = count
|
||||
|
||||
c.Data["json"] = out
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
269
agent/controllers/withdraw.go
Normal file
269
agent/controllers/withdraw.go
Normal file
@@ -0,0 +1,269 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for 代付申请和记录
|
||||
** @Time : 19.12.4 10:50
|
||||
** @Author : Joker
|
||||
** @File : withdraw
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 19.12.4 10:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"agent/common"
|
||||
"agent/models"
|
||||
"agent/sys/enum"
|
||||
"agent/utils"
|
||||
"fmt"
|
||||
"github.com/rs/xid"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Withdraw struct {
|
||||
KeepSession
|
||||
}
|
||||
|
||||
func (c *Withdraw) ShowWithdrawUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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["bankInfo"] = enum.GetBankInfo()
|
||||
c.Data["userName"] = u.AgentName
|
||||
c.TplName = "withdraw/withdraw.html"
|
||||
}
|
||||
|
||||
// 获取账户提现余额
|
||||
func (c *Withdraw) UserBalance() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
ac := models.GetAccountByUid(u.AgentUid)
|
||||
balance := ac.Balance
|
||||
if balance < 0 {
|
||||
balance = 0
|
||||
}
|
||||
|
||||
out := make(map[string]interface{})
|
||||
out["fee"] = enum.SettlementFee
|
||||
out["balance"] = fmt.Sprintf("%0.2f", balance)
|
||||
|
||||
c.Data["json"] = out
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 验证卡号和金额是否正确
|
||||
func verifyAccountAndMoney(bankCode, accountName, cardNo, bankAccountType, province, city, bankAccountAddress, moblieNo, amount string, ac models.AccountInfo) (b bool, msg string) {
|
||||
if bankCode == "" || accountName == "" || cardNo == "" {
|
||||
msg = "银行名、账户名或卡号不能为空!"
|
||||
return false, msg
|
||||
}
|
||||
if moblieNo == "" || amount == "" {
|
||||
msg = "手机号或金额不能为空!"
|
||||
return false, msg
|
||||
}
|
||||
matched, _ := regexp.MatchString(enum.MobileReg, moblieNo)
|
||||
if !matched {
|
||||
msg = "请输入正确的手机号!"
|
||||
return false, msg
|
||||
}
|
||||
matched, _ = regexp.MatchString(enum.MoneyReg, amount)
|
||||
if !matched {
|
||||
msg = "请输入正确的金额!"
|
||||
return false, msg
|
||||
}
|
||||
f, err := strconv.ParseFloat(amount, 10)
|
||||
if err != nil {
|
||||
msg = "请输入正确的金额!"
|
||||
return false, msg
|
||||
}
|
||||
|
||||
if strings.Compare(enum.PublicAccount, bankAccountType) == 0 {
|
||||
if province == "" || city == "" || bankAccountAddress == "" {
|
||||
msg = "开户行全称、所在省份或所在城市不能为空!"
|
||||
return false, msg
|
||||
}
|
||||
}
|
||||
|
||||
if f > enum.WithdrawalMaxAmount || f < enum.WithdrawalMinAmount || f+enum.SettlementFee > ac.WaitAmount {
|
||||
utils.LogInfo(fmt.Sprintf("提现金额超出限制,提现金额:%f,账户可结算余额:%f,提现最小额:%d,最大额:%d,手续费:%d",
|
||||
f, ac.WaitAmount, enum.WithdrawalMinAmount, enum.WithdrawalMaxAmount, enum.SettlementFee))
|
||||
msg = "提现金额超出限制!"
|
||||
return false, msg
|
||||
}
|
||||
|
||||
if f+enum.SettlementFee > ac.Balance || ac.Balance <= 0 {
|
||||
utils.LogInfo(fmt.Sprintf("账户金额不足,提现金额:%f,账户余额:%f,手续费:%d",
|
||||
f, ac.Balance, enum.SettlementFee))
|
||||
msg = "账户可用金额不足!"
|
||||
return false, msg
|
||||
}
|
||||
// 由于没有发生错误,必须把msg重置为初始值,而不是空值
|
||||
return true, enum.FailedToAdmin
|
||||
}
|
||||
|
||||
// 单笔提现申请
|
||||
func (c *Withdraw) LaunchSingleWithdraw() {
|
||||
bankCode := strings.TrimSpace(c.GetString("bankCode"))
|
||||
accountName := strings.TrimSpace(c.GetString("accountName"))
|
||||
cardNo := strings.TrimSpace(c.GetString("cardNo"))
|
||||
bankAccountType := strings.TrimSpace(c.GetString("bankAccountType"))
|
||||
province := strings.TrimSpace(c.GetString("province"))
|
||||
city := strings.TrimSpace(c.GetString("city"))
|
||||
bankAccountAddress := strings.TrimSpace(c.GetString("bankAccountAddress"))
|
||||
moblieNo := strings.TrimSpace(c.GetString("moblieNo"))
|
||||
money := strings.TrimSpace(c.GetString("amount"))
|
||||
mobileCode := strings.TrimSpace(c.GetString("smsVerifyCode"))
|
||||
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
var (
|
||||
msg = enum.FailedString
|
||||
flag = enum.FailedFlag
|
||||
|
||||
matched bool
|
||||
|
||||
amount float64
|
||||
|
||||
ac models.AccountInfo
|
||||
sett models.PayforInfo
|
||||
url string
|
||||
)
|
||||
|
||||
if u.PayPassword == "" {
|
||||
msg = "请设置支付密码!"
|
||||
goto stopRun
|
||||
}
|
||||
if strings.Compare(strings.ToUpper(encrypt.EncodeMd5([]byte(mobileCode))), u.PayPassword) != 0 {
|
||||
msg = "支付密码输入错误!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
ac = models.GetAccountByUid(u.AgentUid)
|
||||
matched, msg = verifyAccountAndMoney(bankCode, accountName, cardNo, bankAccountType, province, city,
|
||||
bankAccountAddress, moblieNo, money, ac)
|
||||
if !matched {
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
u = models.GetAgentInfoByAgentUid(u.AgentUid)
|
||||
if strings.Compare(enum.ACTIVE, u.Status) != 0 {
|
||||
msg = "账户状态异常,请联系管理人员!"
|
||||
goto stopRun
|
||||
}
|
||||
|
||||
amount, _ = strconv.ParseFloat(money, 10)
|
||||
sett = models.PayforInfo{
|
||||
PayforUid: "pppp" + xid.New().String(),
|
||||
MerchantUid: u.AgentUid,
|
||||
MerchantName: u.AgentName,
|
||||
PhoneNo: u.AgentPhone,
|
||||
MerchantOrderId: xid.New().String(),
|
||||
BankOrderId: "4444" + xid.New().String(),
|
||||
PayforFee: common.PAYFOR_FEE,
|
||||
Type: common.SELF_MERCHANT,
|
||||
PayforAmount: amount,
|
||||
PayforTotalAmount: amount + common.PAYFOR_FEE,
|
||||
BankCode: bankCode,
|
||||
BankName: enum.GetBankInfo()[bankCode],
|
||||
IsSend: common.NO,
|
||||
BankAccountName: accountName,
|
||||
BankAccountNo: cardNo,
|
||||
BankAccountType: bankAccountType,
|
||||
BankAccountAddress: province + city + bankAccountAddress,
|
||||
Status: common.PAYFOR_COMFRIM,
|
||||
CreateTime: pubMethod.GetNowTime(),
|
||||
UpdateTime: pubMethod.GetNowTime(),
|
||||
}
|
||||
|
||||
matched = models.InsertPayfor(sett)
|
||||
if matched {
|
||||
flag = enum.SuccessFlag
|
||||
msg = "提交成功,等待审核中,请在结算信息中查询状态!"
|
||||
url = "/withdraw/show_list_ui"
|
||||
}
|
||||
|
||||
stopRun:
|
||||
c.Data["json"] = pubMethod.JsonFormat(flag, "", msg, url)
|
||||
c.ServeJSON()
|
||||
c.StopRun()
|
||||
}
|
||||
|
||||
// 提现列表
|
||||
func (c *Withdraw) ShowListUI() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
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.GetSettlementStatus()
|
||||
c.Data["userName"] = u.AgentName
|
||||
c.TplName = "withdraw/withdraw_record.html"
|
||||
}
|
||||
|
||||
func (c *Withdraw) WithdrawQueryAndListPage() {
|
||||
us := c.GetSession(enum.UserSession)
|
||||
u := us.(models.AgentInfo)
|
||||
|
||||
// 分页参数
|
||||
page, _ := strconv.Atoi(c.GetString("page"))
|
||||
limit, _ := strconv.Atoi(c.GetString("limit"))
|
||||
if limit == 0 {
|
||||
limit = 15
|
||||
}
|
||||
|
||||
// 查询参数
|
||||
in := make(map[string]string)
|
||||
merchantNo := strings.TrimSpace(c.GetString("MerchantNo"))
|
||||
bankNo := strings.TrimSpace(c.GetString("BankNo"))
|
||||
start := strings.TrimSpace(c.GetString("start"))
|
||||
end := strings.TrimSpace(c.GetString("end"))
|
||||
status := strings.TrimSpace(c.GetString("status"))
|
||||
|
||||
in["bank_order_id"] = bankNo
|
||||
in["merchant_order_id"] = merchantNo
|
||||
in["status"] = status
|
||||
in["merchant_uid"] = u.AgentUid
|
||||
|
||||
if start != "" {
|
||||
in["create_time__gte"] = start
|
||||
}
|
||||
if end != "" {
|
||||
in["create_time__lte"] = end
|
||||
}
|
||||
|
||||
// 计算分页数
|
||||
count := models.GetPayForLenByMap(in)
|
||||
totalPage := count / limit // 计算总页数
|
||||
if count%limit != 0 { // 不满一页的数据按一页计算
|
||||
totalPage++
|
||||
}
|
||||
|
||||
// 数据获取
|
||||
var list []models.PayforInfo
|
||||
if page <= totalPage {
|
||||
list = models.GetPayForByMap(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()
|
||||
}
|
||||
Reference in New Issue
Block a user