修改网关代码的结构,调整了逻辑,删除了许多无用的代码
parent
706a95317d
commit
2a98cbd9ac
@ -1,6 +1,6 @@
|
|||||||
appname = jhgateway
|
appname = jhgateway
|
||||||
httpport = 12309
|
httpport = 12309
|
||||||
runmode = dev
|
runmode = pro
|
||||||
|
|
||||||
sessionon = true
|
sessionon = true
|
||||||
|
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/11/6 11:37
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : mq_config
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/11/6 11:37
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package conf
|
||||||
|
|
||||||
|
import "net"
|
||||||
|
|
||||||
|
const (
|
||||||
|
mqHost = "127.0.0.1"
|
||||||
|
mqPort = "61613"
|
||||||
|
|
||||||
|
MqOrderQuery = "order_query"
|
||||||
|
MQ_PAYFOR_QUERY = "payfor_query"
|
||||||
|
MqOrderNotify = "order_notify"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetMQAddress() string {
|
||||||
|
return net.JoinHostPort(mqHost, mqPort)
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/10/29 15:01
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : pay_way_code
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/10/29 15:01
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package conf
|
||||||
|
|
||||||
|
var ScanPayWayCodes = []string{
|
||||||
|
"WEIXIN_SCAN",
|
||||||
|
"UNION_SCAN",
|
||||||
|
"ALI_SCAN",
|
||||||
|
"BAIDU_SCAN",
|
||||||
|
"JD_SCAN",
|
||||||
|
"QQ_SCAN",
|
||||||
|
}
|
||||||
|
|
||||||
|
var H5PayWayCodes = []string{
|
||||||
|
"WEIXIN_H5",
|
||||||
|
"ALI_H5",
|
||||||
|
"QQ_H5",
|
||||||
|
"UNION_H5",
|
||||||
|
"BAIDU_H5",
|
||||||
|
"JD_H5",
|
||||||
|
}
|
||||||
|
|
||||||
|
var SytPayWayCodes = []string{
|
||||||
|
"WEIXIN_SYT",
|
||||||
|
"ALI_SYT",
|
||||||
|
"QQ_SYT",
|
||||||
|
"UNION_SYT",
|
||||||
|
"BAIDU_SYT",
|
||||||
|
"JD_SYT",
|
||||||
|
}
|
||||||
|
|
||||||
|
var FastPayWayCodes = []string{
|
||||||
|
"UNION-FAST",
|
||||||
|
}
|
||||||
|
|
||||||
|
var WebPayWayCode = []string{
|
||||||
|
"UNION-WAP",
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetScanPayWayCodes() []string {
|
||||||
|
return ScanPayWayCodes
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetNameByPayWayCode(code string) string {
|
||||||
|
switch code {
|
||||||
|
case "WEIXIN_SCAN":
|
||||||
|
return "微信扫码"
|
||||||
|
case "UNION_SCAN":
|
||||||
|
return "银联扫码"
|
||||||
|
case "ALI_SCAN":
|
||||||
|
return "支付宝扫码"
|
||||||
|
case "BAIDU_SCAN":
|
||||||
|
return "百度扫码"
|
||||||
|
case "JD_SCAN":
|
||||||
|
return "京东扫码"
|
||||||
|
case "QQ_SCAN":
|
||||||
|
return "QQ扫码"
|
||||||
|
|
||||||
|
case "WEIXIN_H5":
|
||||||
|
return "微信H5"
|
||||||
|
case "UNION_H5":
|
||||||
|
return "银联H5"
|
||||||
|
case "ALI_H5":
|
||||||
|
return "支付宝H5"
|
||||||
|
case "BAIDU_H5":
|
||||||
|
return "百度H5"
|
||||||
|
case "JD_H5":
|
||||||
|
return "京东H5"
|
||||||
|
case "QQ_H5":
|
||||||
|
return "QQ-H5"
|
||||||
|
|
||||||
|
case "WEIXIN_SYT":
|
||||||
|
return "微信收银台"
|
||||||
|
case "UNION_SYT":
|
||||||
|
return "银联收银台"
|
||||||
|
case "ALI_SYT":
|
||||||
|
return "支付宝收银台"
|
||||||
|
case "BAIDU_SYT":
|
||||||
|
return "百度收银台"
|
||||||
|
case "JD_SYT":
|
||||||
|
return "京东收银台"
|
||||||
|
case "QQ_SYT":
|
||||||
|
return "QQ-收银台"
|
||||||
|
|
||||||
|
case "UNION_FAST":
|
||||||
|
return "银联快捷"
|
||||||
|
case "UNION_WAP":
|
||||||
|
return "银联web"
|
||||||
|
default:
|
||||||
|
return "未知"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : 处理下游请求的一些公用的逻辑
|
||||||
|
** @Time : 2019/10/28 18:09
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : base_gateway
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/10/28 18:09
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package gateway
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gateway/response"
|
||||||
|
"gateway/service"
|
||||||
|
"github.com/beego/beego/v2/server/web"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BaseGateway struct {
|
||||||
|
web.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取商户请求过来的基本参数参数
|
||||||
|
func (c *BaseGateway) PayPrepare() *response.PayBaseResp {
|
||||||
|
params := make(map[string]string)
|
||||||
|
//获取客户端的ip
|
||||||
|
clientIp := c.Ctx.Input.IP()
|
||||||
|
params["orderNo"] = strings.TrimSpace(c.GetString("orderNo"))
|
||||||
|
params["productName"] = strings.TrimSpace(c.GetString("productName"))
|
||||||
|
params["orderPeriod"] = strings.TrimSpace(c.GetString("orderPeriod"))
|
||||||
|
params["orderPrice"] = strings.TrimSpace(c.GetString("orderPrice"))
|
||||||
|
params["payWayCode"] = strings.TrimSpace(c.GetString("payWayCode"))
|
||||||
|
params["osType"] = strings.TrimSpace(c.GetString("osType"))
|
||||||
|
params["notifyUrl"] = strings.TrimSpace(c.GetString("notifyUrl"))
|
||||||
|
//c.Params["returnUrl"] = strings.TrimSpace(c.GetString("returnUrl"))
|
||||||
|
params["payKey"] = strings.TrimSpace(c.GetString("payKey"))
|
||||||
|
params["sign"] = strings.TrimSpace(c.GetString("sign"))
|
||||||
|
|
||||||
|
p := service.GetMerchantInfo(params)
|
||||||
|
p.ClientIp = clientIp
|
||||||
|
p = service.JudgeParams(p)
|
||||||
|
|
||||||
|
if p.Code != -1 {
|
||||||
|
p.Code = 200
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : 下游请求扫码支付的处理逻辑
|
||||||
|
** @Time : 2019/10/24 11:15
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : gateway
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/10/24 11:15
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package gateway
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gateway/response"
|
||||||
|
"gateway/service"
|
||||||
|
"gateway/supplier/third_party"
|
||||||
|
"gateway/utils"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ScanController struct {
|
||||||
|
BaseGateway
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理错误的返回
|
||||||
|
func (c *ScanController) SolveFailJSON(p *response.PayBaseResp) {
|
||||||
|
scanFailJSON := new(response.ScanFailData)
|
||||||
|
scanFailJSON.StatusCode = "01"
|
||||||
|
scanFailJSON.PayKey = p.Params["payKey"]
|
||||||
|
scanFailJSON.Msg = p.Msg
|
||||||
|
c.Data["json"] = scanFailJSON
|
||||||
|
_ = c.ServeJSON()
|
||||||
|
c.StopRun()
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理扫码的请求
|
||||||
|
func (c *ScanController) Scan() {
|
||||||
|
|
||||||
|
p := c.PayPrepare()
|
||||||
|
|
||||||
|
if p.Code == -1 {
|
||||||
|
c.SolveFailJSON(p)
|
||||||
|
}
|
||||||
|
//签名验证
|
||||||
|
p.Params["returnUrl"] = strings.TrimSpace(c.GetString("returnUrl"))
|
||||||
|
paySecret := p.MerchantInfo.MerchantSecret
|
||||||
|
if !utils.Md5Verify(p.Params, paySecret) {
|
||||||
|
p.Code = -1
|
||||||
|
p.Msg = "签名异常"
|
||||||
|
c.SolveFailJSON(p)
|
||||||
|
}
|
||||||
|
//选择通道
|
||||||
|
p = service.ChooseRoad(p)
|
||||||
|
if p.Code == -1 {
|
||||||
|
c.SolveFailJSON(p)
|
||||||
|
}
|
||||||
|
//生成订单记录
|
||||||
|
orderInfo, _ := service.GenerateRecord(p)
|
||||||
|
if p.Code == -1 {
|
||||||
|
c.SolveFailJSON(p)
|
||||||
|
}
|
||||||
|
//获取到对应的上游
|
||||||
|
supplierCode := p.RoadInfo.ProductUid
|
||||||
|
supplier := third_party.GetPaySupplierByCode(supplierCode)
|
||||||
|
scanData := supplier.Scan(orderInfo, p.RoadInfo, p.MerchantInfo)
|
||||||
|
if scanData.Status == "00" {
|
||||||
|
scanSuccessData := service.GenerateSuccessData(scanData, p)
|
||||||
|
c.Data["json"] = scanSuccessData
|
||||||
|
_ = c.ServeJSON()
|
||||||
|
} else {
|
||||||
|
p.Msg = scanData.Msg
|
||||||
|
c.SolveFailJSON(p)
|
||||||
|
}
|
||||||
|
}
|
@ -1,86 +0,0 @@
|
|||||||
/***************************************************
|
|
||||||
** @Desc : 下游请求扫码支付的处理逻辑
|
|
||||||
** @Time : 2019/10/24 11:15
|
|
||||||
** @Author : yuebin
|
|
||||||
** @File : gateway
|
|
||||||
** @Last Modified by : yuebin
|
|
||||||
** @Last Modified time: 2019/10/24 11:15
|
|
||||||
** @Software: GoLand
|
|
||||||
****************************************************/
|
|
||||||
package gateway
|
|
||||||
|
|
||||||
import (
|
|
||||||
controller "gateway/supplier"
|
|
||||||
"gateway/utils"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ScanController struct {
|
|
||||||
BaseGateway
|
|
||||||
}
|
|
||||||
|
|
||||||
type ScanSuccessData struct {
|
|
||||||
OrderNo string `json:"orderNo"`
|
|
||||||
Sign string `json:"sign"`
|
|
||||||
OrderPrice string `json:"orderPrice"`
|
|
||||||
PayKey string `json:"payKey"`
|
|
||||||
PayUrl string `json:"payURL"`
|
|
||||||
StatusCode string `json:"statusCode"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ScanFailData struct {
|
|
||||||
PayKey string `json:"payKey"`
|
|
||||||
StatusCode string `json:"statusCode"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
}
|
|
||||||
|
|
||||||
//处理错误的返回
|
|
||||||
func (c *ScanController) SolveFailJSON() {
|
|
||||||
scanFailJSON := new(ScanFailData)
|
|
||||||
scanFailJSON.StatusCode = "01"
|
|
||||||
scanFailJSON.PayKey = c.Params["payKey"]
|
|
||||||
scanFailJSON.Msg = c.Msg
|
|
||||||
c.Data["json"] = scanFailJSON
|
|
||||||
c.ServeJSON()
|
|
||||||
c.StopRun()
|
|
||||||
}
|
|
||||||
|
|
||||||
//处理扫码的请求
|
|
||||||
func (c *ScanController) Scan() {
|
|
||||||
|
|
||||||
c.PayPrepare()
|
|
||||||
|
|
||||||
if c.Code == -1 {
|
|
||||||
c.SolveFailJSON()
|
|
||||||
}
|
|
||||||
//签名验证
|
|
||||||
c.Params["returnUrl"] = strings.TrimSpace(c.GetString("returnUrl"))
|
|
||||||
paySecret := c.MerchantInfo.MerchantSecret
|
|
||||||
if !utils.Md5Verify(c.Params, paySecret) {
|
|
||||||
c.Code = -1
|
|
||||||
c.Msg = "签名异常"
|
|
||||||
c.SolveFailJSON()
|
|
||||||
}
|
|
||||||
//选择通道
|
|
||||||
c.ChooseRoad()
|
|
||||||
if c.Code == -1 {
|
|
||||||
c.SolveFailJSON()
|
|
||||||
}
|
|
||||||
//升级订单记录
|
|
||||||
orderInfo, _ := c.GenerateRecord()
|
|
||||||
if c.Code == -1 {
|
|
||||||
c.SolveFailJSON()
|
|
||||||
}
|
|
||||||
//获取到对应的上游
|
|
||||||
supplierCode := c.RoadInfo.ProductUid
|
|
||||||
supplier := controller.GetPaySupplierByCode(supplierCode)
|
|
||||||
scanData := supplier.Scan(orderInfo, c.RoadInfo, c.MerchantInfo)
|
|
||||||
if scanData.Status == "00" {
|
|
||||||
scanSuccessData := c.GenerateSuccessData(scanData)
|
|
||||||
c.Data["json"] = scanSuccessData
|
|
||||||
c.ServeJSON()
|
|
||||||
} else {
|
|
||||||
c.SolveFailJSON()
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,119 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/10/16 11:11
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : account
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/10/16 11:11
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package accounts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AccountInfo struct {
|
||||||
|
Id int
|
||||||
|
Status string
|
||||||
|
AccountUid string
|
||||||
|
AccountName string
|
||||||
|
Balance float64 //账户总余额
|
||||||
|
SettleAmount float64 //已经结算的金额
|
||||||
|
LoanAmount float64 //账户押款金额
|
||||||
|
FreezeAmount float64 //账户冻结金额
|
||||||
|
WaitAmount float64 //待结算资金
|
||||||
|
PayforAmount float64 //代付在途金额
|
||||||
|
//AbleBalance float64 //账户可用金额
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ACCOUNT_INFO = "account_info"
|
||||||
|
|
||||||
|
func InsetAcount(account AccountInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&account)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert account fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAccountByUid(accountUid string) AccountInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var account AccountInfo
|
||||||
|
_, err := o.QueryTable(ACCOUNT_INFO).Filter("account_uid", accountUid).Limit(1).All(&account)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get account by uid fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return account
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAccountLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ACCOUNT_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, err := qs.Limit(-1).OrderBy("-update_time").Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get account len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAccountByMap(params map[string]string, displayCount, offset int) []AccountInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var accountList []AccountInfo
|
||||||
|
qs := o.QueryTable(ACCOUNT_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&accountList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get account by map fail: ", err)
|
||||||
|
}
|
||||||
|
return accountList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllAccount() []AccountInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var accountList []AccountInfo
|
||||||
|
|
||||||
|
_, err := o.QueryTable(ACCOUNT_INFO).Limit(-1).All(&accountList)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get all account fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountList
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateAccount(account AccountInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Update(&account)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update account fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteAccountByUid(accountUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(ACCOUNT_INFO).Filter("account_uid", accountUid).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete account fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/10/19 14:56
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : account_history_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/10/19 14:56
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package accounts
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AccountHistoryInfo struct {
|
||||||
|
Id int
|
||||||
|
AccountUid string
|
||||||
|
AccountName string
|
||||||
|
Type string
|
||||||
|
Amount float64
|
||||||
|
Balance float64
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ACCOUNT_HISTORY_INFO = "account_history_info"
|
||||||
|
|
||||||
|
func InsertAccountHistory(accountHistory AccountHistoryInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(accountHistory)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert account history fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAccountHistoryLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ACCOUNT_HISTORY_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, err := qs.Limit(-1).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get account history len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAccountHistoryByMap(params map[string]string, displayCount, offset int) []AccountHistoryInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ACCOUNT_HISTORY_INFO)
|
||||||
|
var accountHistoryList []AccountHistoryInfo
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&accountHistoryList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get account history by map fail: ", err)
|
||||||
|
}
|
||||||
|
return accountHistoryList
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/9/19 14:41
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : agent_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/9/19 14:41
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package agent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AgentInfo struct {
|
||||||
|
Id int
|
||||||
|
Status string
|
||||||
|
AgentName string
|
||||||
|
AgentPassword string
|
||||||
|
PayPassword string
|
||||||
|
AgentRemark string
|
||||||
|
AgentUid string
|
||||||
|
AgentPhone string
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const AGENT_INFO = "agent_info"
|
||||||
|
|
||||||
|
func IsEixstByAgentName(agentName string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(AGENT_INFO).Filter("agent_name", agentName).Exist()
|
||||||
|
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsExistByAgentUid(uid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(AGENT_INFO).Filter("agent_uid", uid).Exist()
|
||||||
|
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsEixstByAgentPhone(agentPhone string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(AGENT_INFO).Filter("agent_phone", agentPhone).Exist()
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func InsertAgentInfo(agentInfo AgentInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&agentInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert agent info fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAgentInfoByAgentUid(agentUid string) AgentInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var agentInfo AgentInfo
|
||||||
|
_, err := o.QueryTable(AGENT_INFO).Filter("agent_uid", agentUid).Limit(1).All(&agentInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get agent info by agentUid fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return agentInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAgentInfoByPhone(phone string) AgentInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var agentInfo AgentInfo
|
||||||
|
_, err := o.QueryTable(AGENT_INFO).Filter("agent_phone", phone).Limit(1).All(&agentInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get agent info by phone fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return agentInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAgentInfoLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(AGENT_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, err := qs.Limit(-1).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get agentinfo len by map fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAgentInfoByMap(params map[string]string, displayCount, offset int) []AgentInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var agentInfoList []AgentInfo
|
||||||
|
|
||||||
|
qs := o.QueryTable(AGENT_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&agentInfoList)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get agentInfo by map fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return agentInfoList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllAgentByMap(parmas map[string]string) []AgentInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var agentList []AgentInfo
|
||||||
|
|
||||||
|
qs := o.QueryTable(AGENT_INFO)
|
||||||
|
for k, v := range parmas {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := qs.Limit(-1).All(&agentList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get all agent by map fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return agentList
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateAgentInfo(agentInfo AgentInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Update(&agentInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update agentinfo fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteAgentByAgentUid(agentUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(AGENT_INFO).Filter("agent_uid", agentUid).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete agent by agent uid fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -1,10 +1,13 @@
|
|||||||
/***************************************************
|
/***************************************************
|
||||||
** @Desc : 接受上游通道商的订单结果异步回调
|
** @Desc : This file for ...
|
||||||
** @Time : 2019/11/22 23:27
|
** @Time : 2019/12/17 17:50
|
||||||
** @Author : yuebin
|
** @Author : yuebin
|
||||||
** @File : supplier_notify
|
** @File : agent_profit
|
||||||
** @Last Modified by : yuebin
|
** @Last Modified by : yuebin
|
||||||
** @Last Modified time: 2019/11/22 23:27
|
** @Last Modified time: 2019/12/17 17:50
|
||||||
** @Software: GoLand
|
** @Software: GoLand
|
||||||
****************************************************/
|
****************************************************/
|
||||||
package gateway
|
package agent
|
||||||
|
|
||||||
|
type AgentProfit struct {
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/10/7 11:52
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : merchant_deploy_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/10/7 11:52
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package merchant
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MerchantDeployInfo struct {
|
||||||
|
Id int
|
||||||
|
Status string
|
||||||
|
MerchantUid string
|
||||||
|
PayType string
|
||||||
|
SingleRoadUid string
|
||||||
|
SingleRoadName string
|
||||||
|
SingleRoadPlatformRate float64
|
||||||
|
SingleRoadAgentRate float64
|
||||||
|
RollRoadCode string
|
||||||
|
RollRoadName string
|
||||||
|
RollRoadPlatformRate float64
|
||||||
|
RollRoadAgentRate float64
|
||||||
|
IsLoan string
|
||||||
|
LoanRate float64
|
||||||
|
LoanDays int
|
||||||
|
UnfreezeHour int
|
||||||
|
WaitUnfreezeAmount float64
|
||||||
|
LoanAmount float64
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const MERCHANT_DEPLOY_INFO = "merchant_deploy_info"
|
||||||
|
|
||||||
|
func InsertMerchantDeployInfo(merchantDeployInfo MerchantDeployInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&merchantDeployInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert merchant deploy info fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsExistByUidAndPayType(uid, payType string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
isEixst := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).Filter("pay_type", payType).Exist()
|
||||||
|
return isEixst
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMerchantDeployByUidAndPayType(uid, payType string) MerchantDeployInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var merchantDeployInfo MerchantDeployInfo
|
||||||
|
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).Filter("pay_type", payType).Limit(1).All(&merchantDeployInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get merchant deploy by uid and paytype fail:", err)
|
||||||
|
}
|
||||||
|
return merchantDeployInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMerchantDeployByUid(uid string) (ms []MerchantDeployInfo) {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).All(&ms)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get merchant deploy by uid fail:", err)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMerchantDeployByHour(hour int) []MerchantDeployInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var merchantDeployList []MerchantDeployInfo
|
||||||
|
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("unfreeze_hour", hour).Filter("status", "active").Limit(-1).All(&merchantDeployList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get merchant deploy list fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return merchantDeployList
|
||||||
|
}
|
||||||
|
func DeleteMerchantDeployByUidAndPayType(uid, payType string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).Filter("pay_type", payType).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete merchant deploy by uid and payType fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateMerchantDeploy(merchantDeploy MerchantDeployInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Update(&merchantDeploy)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update merchant deploy fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMerchantDeployLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(MERCHANT_DEPLOY_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, err := qs.Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get merchant deploy len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMerchantDeployListByMap(params map[string]string, displayCount, offset int) (md []MerchantDeployInfo) {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(MERCHANT_DEPLOY_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&md)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get merchant deploy list by map fail: ", err)
|
||||||
|
}
|
||||||
|
return md
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/11/22 13:07
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : merchant_load_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/11/22 13:07
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package merchant
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MerchantLoadInfo struct {
|
||||||
|
Id int
|
||||||
|
Status string
|
||||||
|
MerchantUid string
|
||||||
|
RoadUid string
|
||||||
|
LoadDate string
|
||||||
|
LoadAmount float64
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const MERCHANT_LOAD_INFO = "merchant_load_info"
|
||||||
|
|
||||||
|
func GetMerchantLoadInfoByMap(params map[string]string) []MerchantLoadInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(MERCHANT_LOAD_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var merchantLoadList []MerchantLoadInfo
|
||||||
|
_, err := qs.Limit(-11).All(&merchantLoadList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get merchant load info fail: ", err)
|
||||||
|
}
|
||||||
|
return merchantLoadList
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsExistMerchantLoadByParams(params map[string]string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(MERCHANT_LOAD_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return qs.Exist()
|
||||||
|
}
|
@ -0,0 +1,222 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/10/28 10:15
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : order_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/10/28 10:15
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OrderInfo struct {
|
||||||
|
Id int
|
||||||
|
ShopName string //商品名称
|
||||||
|
OrderPeriod string //订单有效时间
|
||||||
|
MerchantOrderId string //商户订单id
|
||||||
|
BankOrderId string //本系统订单id
|
||||||
|
BankTransId string //上游流水id
|
||||||
|
OrderAmount float64 //订单提交的金额
|
||||||
|
ShowAmount float64 //待支付的金额
|
||||||
|
FactAmount float64 //用户实际支付金额
|
||||||
|
RollPoolCode string //轮询池编码
|
||||||
|
RollPoolName string //轮询池名臣
|
||||||
|
RoadUid string //通道标识
|
||||||
|
RoadName string //通道名称
|
||||||
|
PayProductName string //上游支付公司的名称
|
||||||
|
PayProductCode string //上游支付公司的编码代号
|
||||||
|
PayTypeCode string //支付产品编码
|
||||||
|
PayTypeName string //支付产品名称
|
||||||
|
OsType string //操作系统类型
|
||||||
|
Status string //订单支付状态
|
||||||
|
Refund string //退款状态
|
||||||
|
RefundTime string //退款操作时间
|
||||||
|
Freeze string //冻结状态
|
||||||
|
FreezeTime string //冻结时间
|
||||||
|
Unfreeze string //是否已经解冻
|
||||||
|
UnfreezeTime string //解冻时间
|
||||||
|
ReturnUrl string //支付完跳转地址
|
||||||
|
NotifyUrl string //下游回调地址
|
||||||
|
MerchantUid string //商户id
|
||||||
|
MerchantName string //商户名称
|
||||||
|
AgentUid string //该商户所属代理
|
||||||
|
AgentName string //该商户所属代理名称
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ORDER_INFO = "order_info"
|
||||||
|
|
||||||
|
func InsertOrder(orderInfo OrderInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&orderInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert order info fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func OrderNoIsEixst(orderId string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exits := o.QueryTable(ORDER_INFO).Filter("merchant_order_id", orderId).Exist()
|
||||||
|
return exits
|
||||||
|
}
|
||||||
|
|
||||||
|
func BankOrderIdIsEixst(bankOrderId string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exists := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Exist()
|
||||||
|
return exists
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOrderLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ORDER_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, _ := qs.Limit(-1).Count()
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOrderByMap(params map[string]string, display, offset int) []OrderInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var orderInfoList []OrderInfo
|
||||||
|
qs := o.QueryTable(ORDER_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&orderInfoList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get order by map fail: ", err)
|
||||||
|
}
|
||||||
|
return orderInfoList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSuccessRateByMap(params map[string]string) string {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ORDER_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
successRate := "0%"
|
||||||
|
allCount, _ := qs.Limit(-1).Count()
|
||||||
|
successCount, _ := qs.Filter("status", "success").Limit(-1).Count()
|
||||||
|
if allCount == 0 {
|
||||||
|
return successRate
|
||||||
|
}
|
||||||
|
tmp := float64(successCount) / float64(allCount) * 100
|
||||||
|
successRate = fmt.Sprintf("%.1f", tmp)
|
||||||
|
return successRate + "%"
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllAmountByMap(params map[string]string) float64 {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
condition := "select sum(order_amount) as allAmount from order_info "
|
||||||
|
for _, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
condition = condition + "where "
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flag := false
|
||||||
|
if params["create_time__gte"] != "" {
|
||||||
|
flag = true
|
||||||
|
condition = condition + " create_time >= '" + params["create_time__gte"] + "'"
|
||||||
|
}
|
||||||
|
if params["create_time__lte"] != "" {
|
||||||
|
if flag {
|
||||||
|
condition = condition + " and "
|
||||||
|
}
|
||||||
|
condition = condition + " create_time <= '" + params["create_time__lte"] + "'"
|
||||||
|
}
|
||||||
|
if params["merchant_name__icontains"] != "" {
|
||||||
|
if flag {
|
||||||
|
condition = condition + " and "
|
||||||
|
}
|
||||||
|
condition = condition + "merchant_name like %'" + params["merchant_name__icontains"] + "'% "
|
||||||
|
}
|
||||||
|
if params["merchant_order_id"] != "" {
|
||||||
|
if flag {
|
||||||
|
condition = condition + " and "
|
||||||
|
}
|
||||||
|
condition = condition + " merchant_order_id = '" + params["merchant_order_id"] + "'"
|
||||||
|
}
|
||||||
|
if params["bank_order_id"] != "" {
|
||||||
|
if flag {
|
||||||
|
condition = condition + " and "
|
||||||
|
}
|
||||||
|
condition = condition + " bank_order_id = '" + params["bank_order_id"] + "'"
|
||||||
|
}
|
||||||
|
if params["status"] != "" {
|
||||||
|
if flag {
|
||||||
|
condition = condition + " and "
|
||||||
|
}
|
||||||
|
condition = condition + "status = '" + params["status"] + "'"
|
||||||
|
}
|
||||||
|
if params["pay_product_code"] != "" {
|
||||||
|
if flag {
|
||||||
|
condition = condition + " and "
|
||||||
|
}
|
||||||
|
condition = condition + "pay_product_code = " + params["pay_product_code"] + "'"
|
||||||
|
}
|
||||||
|
if params["pay_type_code"] != "" {
|
||||||
|
if flag {
|
||||||
|
condition = condition + " and "
|
||||||
|
}
|
||||||
|
condition = condition + "pay_type_code = " + params["pay_type_code"]
|
||||||
|
}
|
||||||
|
logs.Info("get order amount str = ", condition)
|
||||||
|
var maps []orm.Params
|
||||||
|
allAmount := 0.00
|
||||||
|
num, err := o.Raw(condition).Values(&maps)
|
||||||
|
if err == nil && num > 0 {
|
||||||
|
allAmount, _ = strconv.ParseFloat(maps[0]["allAmount"].(string), 64)
|
||||||
|
}
|
||||||
|
return allAmount
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOrderByBankOrderId(bankOrderId string) OrderInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var orderInfo OrderInfo
|
||||||
|
_, err := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get order info by bankOrderId fail: ", err)
|
||||||
|
}
|
||||||
|
return orderInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOrderByMerchantOrderId(merchantOrderId string) OrderInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var orderInfo OrderInfo
|
||||||
|
_, err := o.QueryTable(ORDER_INFO).Filter("merchant_order_id", merchantOrderId).Limit(1).All(&orderInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get order by merchant_order_id: ", err.Error())
|
||||||
|
}
|
||||||
|
return orderInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOneOrder(bankOrderId string) OrderInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var orderInfo OrderInfo
|
||||||
|
_, err := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get one order fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return orderInfo
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/10/30 11:41
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : order_settle_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/10/30 11:41
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package order
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OrderSettleInfo struct {
|
||||||
|
Id int
|
||||||
|
PayProductCode string
|
||||||
|
PayProductName string
|
||||||
|
PayTypeCode string
|
||||||
|
RoadUid string
|
||||||
|
PayTypeName string
|
||||||
|
MerchantUid string
|
||||||
|
MerchantName string
|
||||||
|
MerchantOrderId string
|
||||||
|
BankOrderId string
|
||||||
|
SettleAmount float64
|
||||||
|
IsAllowSettle string
|
||||||
|
IsCompleteSettle string
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ORDER_SETTLE_INFO = "order_settle_info"
|
||||||
|
|
||||||
|
func GetOrderSettleListByParams(params map[string]string) []OrderSettleInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ORDER_SETTLE_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var orderSettleList []OrderSettleInfo
|
||||||
|
if _, err := qs.Limit(-1).All(&orderSettleList); err != nil {
|
||||||
|
logs.Error("get order settle list fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return orderSettleList
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/12/17 17:50
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : platform_profit
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/12/17 17:50
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package order
|
||||||
|
|
||||||
|
type PlatformProfit struct {
|
||||||
|
MerchantName string
|
||||||
|
AgentName string
|
||||||
|
SupplierName string
|
||||||
|
PayTypeName string
|
||||||
|
OrderAmount float64
|
||||||
|
OrderCount int
|
||||||
|
PlatformProfit float64
|
||||||
|
AgentProfit float64
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/9/8 12:09
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : road_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/9/8 12:09
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package road
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RoadInfo struct {
|
||||||
|
Id int
|
||||||
|
Status string
|
||||||
|
RoadName string
|
||||||
|
RoadUid string
|
||||||
|
Remark string
|
||||||
|
ProductName string
|
||||||
|
ProductUid string
|
||||||
|
PayType string
|
||||||
|
BasicFee float64
|
||||||
|
SettleFee float64
|
||||||
|
TotalLimit float64
|
||||||
|
TodayLimit float64
|
||||||
|
SingleMinLimit float64
|
||||||
|
SingleMaxLimit float64
|
||||||
|
StarHour int
|
||||||
|
EndHour int
|
||||||
|
Params string
|
||||||
|
TodayIncome float64
|
||||||
|
TotalIncome float64
|
||||||
|
TodayProfit float64
|
||||||
|
TotalProfit float64
|
||||||
|
Balance float64
|
||||||
|
RequestAll int
|
||||||
|
RequestSuccess int
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ROAD_INFO = "road_info"
|
||||||
|
|
||||||
|
func GetRoadInfoByRoadUid(roadUid string) RoadInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadInfo RoadInfo
|
||||||
|
_, err := o.QueryTable(ROAD_INFO).Exclude("status", "delete").Filter("road_uid", roadUid).Limit(1).All(&roadInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get road info by road uid fail: ", err)
|
||||||
|
}
|
||||||
|
return roadInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoadInfosByRoadUids(roadUids []string) []RoadInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadInfoList []RoadInfo
|
||||||
|
_, err := o.QueryTable(ROAD_INFO).Filter("road_uid__in", roadUids).OrderBy("update_time").All(&roadInfoList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get roadInfos by roadUids fail: ", err)
|
||||||
|
}
|
||||||
|
return roadInfoList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoadInfoByName(roadName string) RoadInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadInfo RoadInfo
|
||||||
|
_, err := o.QueryTable(ROAD_INFO).Exclude("status", "delete").Filter("road_name", roadName).Limit(1).All(&roadInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get road info by name fail: ", err)
|
||||||
|
}
|
||||||
|
return roadInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoadLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ROAD_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, err := qs.Exclude("status", "delete").Limit(-1).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get road len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoadInfoByMap(params map[string]string, displayCount, offset int) []RoadInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadInfoList []RoadInfo
|
||||||
|
qs := o.QueryTable(ROAD_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := qs.Exclude("status", "delete").Limit(displayCount, offset).OrderBy("-update_time").All(&roadInfoList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get road info by map fail: ", err)
|
||||||
|
}
|
||||||
|
return roadInfoList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllRoad(params map[string]string) []RoadInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadInfoList []RoadInfo
|
||||||
|
qs := o.QueryTable(ROAD_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(-1).All(&roadInfoList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get all road fail: ", err)
|
||||||
|
}
|
||||||
|
return roadInfoList
|
||||||
|
}
|
||||||
|
|
||||||
|
func InsertRoadInfo(roadInfo RoadInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&roadInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert road info fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func RoadInfoExistByRoadUid(roadUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(ROAD_INFO).Filter("status", "active").Filter("road_uid", roadUid).Exist()
|
||||||
|
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateRoadInfo(roadInfo RoadInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Update(&roadInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update road info fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteRoadByRoadUid(roadUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(ROAD_INFO).Filter("road_uid", roadUid).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete road by road uid fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -0,0 +1,127 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/9/9 16:35
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : road_pool_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/9/9 16:35
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package road
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RoadPoolInfo struct {
|
||||||
|
Id int
|
||||||
|
Status string
|
||||||
|
RoadPoolName string
|
||||||
|
RoadPoolCode string
|
||||||
|
RoadUidPool string
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ROAD_POOL_INFO = "road_pool_info"
|
||||||
|
|
||||||
|
func InsertRoadPool(roadPool RoadPoolInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&roadPool)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert road pool fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoadPoolLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ROAD_POOL_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, err := qs.Limit(-1).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get road pool len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoadPoolByMap(params map[string]string, displayCount, offset int) []RoadPoolInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadPoolList []RoadPoolInfo
|
||||||
|
qs := o.QueryTable(ROAD_POOL_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&roadPoolList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get road pool by map fail: ", err)
|
||||||
|
}
|
||||||
|
return roadPoolList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoadPoolByRoadPoolCode(roadPoolCode string) RoadPoolInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadPoolInfo RoadPoolInfo
|
||||||
|
_, err := o.QueryTable(ROAD_POOL_INFO).Filter("road_pool_code", roadPoolCode).Limit(1).All(&roadPoolInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get road pool info by road pool code fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return roadPoolInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllRollPool(params map[string]string) []RoadPoolInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadPoolList []RoadPoolInfo
|
||||||
|
qs := o.QueryTable(ROAD_POOL_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(-1).All(&roadPoolList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get all roll pool fail: ", err)
|
||||||
|
}
|
||||||
|
return roadPoolList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoadPoolByName(roadPoolName string) RoadPoolInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roadPoolInfo RoadPoolInfo
|
||||||
|
_, err := o.QueryTable(ROAD_POOL_INFO).Filter("road_pool_name", roadPoolName).Limit(1).All(&roadPoolInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get road pool by name fail: ", err)
|
||||||
|
}
|
||||||
|
return roadPoolInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteRoadPoolByCode(roadPoolCode string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(ROAD_POOL_INFO).Filter("road_pool_code", roadPoolCode).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete road pool by code fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateRoadPool(roadPool RoadPoolInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Update(&roadPool)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update road pool fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/9/6 10:19
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : bank_card_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/9/6 10:19
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BankCardInfo struct {
|
||||||
|
Id int
|
||||||
|
Uid string
|
||||||
|
UserName string
|
||||||
|
BankName string
|
||||||
|
BankCode string
|
||||||
|
BankAccountType string
|
||||||
|
AccountName string
|
||||||
|
BankNo string
|
||||||
|
IdentifyCard string
|
||||||
|
CertificateNo string
|
||||||
|
PhoneNo string
|
||||||
|
BankAddress string
|
||||||
|
UpdateTime string
|
||||||
|
CreateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const BANK_CARD_INFO = "bank_card_info"
|
||||||
|
|
||||||
|
func InsertBankCardInfo(bankCardInfo BankCardInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&bankCardInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert bank card info fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetBankCardLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(BANK_CARD_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
cnt, err := qs.Limit(-1).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get bank card len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetBankCardByMap(params map[string]string, displayCount, offset int) []BankCardInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var bankCardList []BankCardInfo
|
||||||
|
qs := o.QueryTable(BANK_CARD_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&bankCardList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get bank card by map fail: ", err)
|
||||||
|
}
|
||||||
|
return bankCardList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetBankCardByUid(uid string) BankCardInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var bankCardInfo BankCardInfo
|
||||||
|
_, err := o.QueryTable(bankCardInfo).Filter("uid", uid).Limit(1).All(&bankCardInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get bank card by uid fail: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return bankCardInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteBankCardByUid(uid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(BANK_CARD_INFO).Filter("uid", uid).Delete()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete bank card by uid fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateBankCard(bankCard BankCardInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Update(&bankCard)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update bank card fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -0,0 +1,143 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/8/28 17:59
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : power_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/8/28 17:59
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PowerInfo struct {
|
||||||
|
Id int
|
||||||
|
FirstMenuUid string
|
||||||
|
SecondMenuUid string
|
||||||
|
SecondMenu string
|
||||||
|
PowerId string
|
||||||
|
PowerItem string
|
||||||
|
Creater string
|
||||||
|
Status string
|
||||||
|
CreateTime string
|
||||||
|
UpdateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const POWER_INFO = "power_info"
|
||||||
|
|
||||||
|
type PowerInfoSlice []PowerInfo
|
||||||
|
|
||||||
|
func (sm PowerInfoSlice) Len() int {
|
||||||
|
return len(sm)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sm PowerInfoSlice) Swap(i, j int) {
|
||||||
|
sm[i], sm[j] = sm[j], sm[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sm PowerInfoSlice) Less(i, j int) bool {
|
||||||
|
return sm[i].SecondMenuUid < sm[j].SecondMenuUid
|
||||||
|
}
|
||||||
|
|
||||||
|
func PowerUidExists(powerUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exists := o.QueryTable(POWER_INFO).Filter("power_id", powerUid).Exist()
|
||||||
|
return exists
|
||||||
|
}
|
||||||
|
|
||||||
|
func InsertPowerInfo(powerInfo PowerInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&powerInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert power info fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPower() []PowerInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var powerInfo []PowerInfo
|
||||||
|
_, err := o.QueryTable(POWER_INFO).Limit(-1).All(&powerInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get power fail: ", err)
|
||||||
|
}
|
||||||
|
return powerInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPowerById(powerId string) PowerInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var powerInfo PowerInfo
|
||||||
|
_, err := o.QueryTable(POWER_INFO).Filter("power_id", powerId).Limit(1).All(&powerInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get power by id fail: ", err)
|
||||||
|
}
|
||||||
|
return powerInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPowerByIds(powerIds []string) []PowerInfo {
|
||||||
|
var powerInfoList []PowerInfo
|
||||||
|
for _, v := range powerIds {
|
||||||
|
m := GetPowerById(v)
|
||||||
|
powerInfoList = append(powerInfoList, m)
|
||||||
|
}
|
||||||
|
return powerInfoList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPowerItemLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(POWER_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, err := qs.Limit(-1).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get power item len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPowerItemByMap(params map[string]string, displpay, offset int) []PowerInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var powerItemList []PowerInfo
|
||||||
|
qs := o.QueryTable(POWER_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := qs.Limit(displpay, offset).OrderBy("-update_time").All(&powerItemList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get power item by map fail: ", err)
|
||||||
|
}
|
||||||
|
return powerItemList
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeletePowerItemByPowerID(powerID string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(POWER_INFO).Filter("power_id", powerID).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete power item by powerID fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeletePowerBySecondUid(secondUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(POWER_INFO).Filter("second_menu_uid", secondUid).Delete()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete power by second menu uid fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/8/29 14:43
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : role_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/8/29 14:43
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RoleInfo struct {
|
||||||
|
Id int
|
||||||
|
RoleName string
|
||||||
|
RoleUid string
|
||||||
|
ShowFirstMenu string
|
||||||
|
ShowFirstUid string
|
||||||
|
ShowSecondMenu string
|
||||||
|
ShowSecondUid string
|
||||||
|
ShowPower string
|
||||||
|
ShowPowerUid string
|
||||||
|
Creater string
|
||||||
|
Status string
|
||||||
|
Remark string
|
||||||
|
CreateTime string
|
||||||
|
UpdateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
const ROLE_INFO = "role_info"
|
||||||
|
|
||||||
|
func GetRoleLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(ROLE_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cnt, err := qs.Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get role len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRole() []RoleInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roleInfo []RoleInfo
|
||||||
|
_, err := o.QueryTable(ROLE_INFO).Limit(-1).OrderBy("-update_time").All(&roleInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get all role fail: ", err)
|
||||||
|
}
|
||||||
|
return roleInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoleByMap(params map[string]string, display, offset int) []RoleInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roleInfo []RoleInfo
|
||||||
|
qs := o.QueryTable(ROLE_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&roleInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get role by map fail: ", err)
|
||||||
|
}
|
||||||
|
return roleInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRoleByRoleUid(roleUid string) RoleInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var roleInfo RoleInfo
|
||||||
|
_, err := o.QueryTable(ROLE_INFO).Filter("role_uid", roleUid).Limit(1).All(&roleInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get role by role uid fail: ", err)
|
||||||
|
}
|
||||||
|
return roleInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func RoleNameExists(roleName string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exists := o.QueryTable(ROLE_INFO).Filter("role_name", roleName).Exist()
|
||||||
|
return exists
|
||||||
|
}
|
||||||
|
|
||||||
|
func InsertRole(roleInfo RoleInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&roleInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert role fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteRoleByRoleUid(roleUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(ROLE_INFO).Filter("role_uid", roleUid).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete role by role uid fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateRoleInfo(roleInfo RoleInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Update(&roleInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update role info fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -0,0 +1,216 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/8/26 9:33
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : second_menu_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/8/26 9:33
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package system
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
const SECOND_MENU_INFO = "second_menu_info"
|
||||||
|
|
||||||
|
type SecondMenuInfo struct {
|
||||||
|
Id int
|
||||||
|
FirstMenuOrder int
|
||||||
|
FirstMenuUid string
|
||||||
|
FirstMenu string
|
||||||
|
MenuOrder int
|
||||||
|
SecondMenuUid string
|
||||||
|
SecondMenu string
|
||||||
|
SecondRouter string
|
||||||
|
Creater string
|
||||||
|
Status string
|
||||||
|
CreateTime string
|
||||||
|
UpdateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
type SecondMenuSlice []SecondMenuInfo
|
||||||
|
|
||||||
|
func (sm SecondMenuSlice) Len() int {
|
||||||
|
return len(sm)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sm SecondMenuSlice) Swap(i, j int) {
|
||||||
|
sm[i], sm[j] = sm[j], sm[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sm SecondMenuSlice) Less(i, j int) bool {
|
||||||
|
if sm[i].FirstMenuOrder == sm[j].FirstMenuOrder {
|
||||||
|
return sm[i].MenuOrder < sm[j].MenuOrder
|
||||||
|
}
|
||||||
|
return sm[i].FirstMenuOrder < sm[j].FirstMenuOrder
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuLen() int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
cnt, err := o.QueryTable(SECOND_MENU_INFO).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get second meun len fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuInfoByMenuOrder(menuOrder int, firstMenuUid string) SecondMenuInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var secondMenuInfo SecondMenuInfo
|
||||||
|
_, err := o.QueryTable(SECOND_MENU_INFO).Filter("first_menu_uid", firstMenuUid).Filter("menu_order", menuOrder).Limit(1).All(&secondMenuInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get second menu info by menu order fail: ", err)
|
||||||
|
}
|
||||||
|
return secondMenuInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuLenByFirstMenuUid(firstMenuUid string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
cnt, err := o.QueryTable(SECOND_MENU_INFO).Filter("first_menu_uid", firstMenuUid).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get second menu len by first menu uid fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuList() []SecondMenuInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var secondMenuList []SecondMenuInfo
|
||||||
|
_, err := o.QueryTable(SECOND_MENU_INFO).Limit(-1).OrderBy("-update_time").All(&secondMenuList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get second menu list fail: ", err)
|
||||||
|
}
|
||||||
|
return secondMenuList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuInfoBySecondMenuUid(secondMenuUid string) SecondMenuInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var secondMenuInfo SecondMenuInfo
|
||||||
|
_, err := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu_uid", secondMenuUid).Limit(1).All(&secondMenuInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get scond menu info by second menu uid fail: ", err)
|
||||||
|
}
|
||||||
|
return secondMenuInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuInfoBySecondMenuUids(secondMenuUids []string) []SecondMenuInfo {
|
||||||
|
secondMenuInfoList := make([]SecondMenuInfo, 0)
|
||||||
|
for _, v := range secondMenuUids {
|
||||||
|
sm := GetSecondMenuInfoBySecondMenuUid(v)
|
||||||
|
secondMenuInfoList = append(secondMenuInfoList, sm)
|
||||||
|
}
|
||||||
|
return secondMenuInfoList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuListByFirstMenuUid(firstMenuUid string) []SecondMenuInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var secondMenuList []SecondMenuInfo
|
||||||
|
_, err := o.QueryTable(SECOND_MENU_INFO).Filter("first_menu_uid", firstMenuUid).Limit(-1).OrderBy("-update_time").All(&secondMenuList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get second menu list by first menu uid fail: ", err)
|
||||||
|
}
|
||||||
|
return secondMenuList
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(SECOND_MENU_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
cnt, err := qs.Limit(-1).Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get second menu len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSecondMenuByMap(params map[string]string, displayCount, offset int) []SecondMenuInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var secondMenuList []SecondMenuInfo
|
||||||
|
qs := o.QueryTable(SECOND_MENU_INFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&secondMenuList)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get second menu by map fail: ", err)
|
||||||
|
}
|
||||||
|
return secondMenuList
|
||||||
|
}
|
||||||
|
func InsertSecondMenu(secondMenuInfo SecondMenuInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&secondMenuInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert second menu fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func SecondMenuIsExists(seconfMenu string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu", seconfMenu).Exist()
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func SecondMenuUidIsExists(secondMenuUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu_uid", secondMenuUid).Exist()
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func SecondRouterExists(secondRouter string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(SECOND_MENU_INFO).Filter("second_router", secondRouter).Exist()
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteSecondMenuByFirstMenuUid(firstMenuUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
num, err := o.QueryTable(SECOND_MENU_INFO).Filter("first_menu_uid", firstMenuUid).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete second menu by first menu uid fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
logs.Info("delete second menu by first menu uid success, num: ", num)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteSecondMenuBySecondMenuUid(secondMenuUid string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
num, err := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu_uid", secondMenuUid).Delete()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete second menu by second menu uid fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
logs.Info("delete second menu by second menu uid success, num: ", num)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateSecondMenuOrderBySecondUid(secondUid string, order int) {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu_uid", secondUid).Update(orm.Params{"menu_order": order})
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update second menu order by second menu uid fail: ", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateSecondMenu(secondMenu SecondMenuInfo) {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Update(&secondMenu)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update second menu for first order fail: ", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SecondMenuExistByMenuOrder(menuOrder int) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(SECOND_MENU_INFO).Filter("menu_order", menuOrder).Exist()
|
||||||
|
return exist
|
||||||
|
}
|
@ -0,0 +1,146 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : This file for ...
|
||||||
|
** @Time : 2019/8/9 14:02
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : user_info
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/8/9 14:02
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
USERINFO = "user_info"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserInfo struct {
|
||||||
|
Id int
|
||||||
|
UserId string
|
||||||
|
Passwd string
|
||||||
|
Nick string
|
||||||
|
Remark string
|
||||||
|
Ip string
|
||||||
|
Status string
|
||||||
|
Role string
|
||||||
|
RoleName string
|
||||||
|
CreateTime string
|
||||||
|
UpdateTime string
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetUserInfoByUserID(userID string) UserInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var userInfo UserInfo
|
||||||
|
err := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userID).One(&userInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get user info fail: ", err)
|
||||||
|
}
|
||||||
|
return userInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOperatorByMap(params map[string]string, displayCount, offset int) []UserInfo {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
var userInfo []UserInfo
|
||||||
|
qs := o.QueryTable(USERINFO)
|
||||||
|
for k, v := range params {
|
||||||
|
if len(v) > 0 {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, err := qs.Exclude("status", "delete").Limit(displayCount, offset).OrderBy("-update_time").All(&userInfo)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get operator by map fail: ", err)
|
||||||
|
}
|
||||||
|
return userInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOperatorLenByMap(params map[string]string) int {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
qs := o.QueryTable(USERINFO)
|
||||||
|
for k, v := range params {
|
||||||
|
qs = qs.Filter(k, v)
|
||||||
|
}
|
||||||
|
cnt, err := qs.Exclude("status", "delete").Count()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("get operator len by map fail: ", err)
|
||||||
|
}
|
||||||
|
return int(cnt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateUserInfoIP(userInfo UserInfo) {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
num, err := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userInfo.UserId).Update(orm.Params{"ip": userInfo.Ip})
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("%s update user info ip fail: %v", userInfo.UserId, err)
|
||||||
|
} else {
|
||||||
|
logs.Info("%s update user info ip success, num: %d", userInfo.UserId, num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateUserInfoPassword(userInfo UserInfo) {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
num, err := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userInfo.UserId).Update(orm.Params{"passwd": userInfo.Passwd})
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("%s update user info password fail: %v", userInfo.UserId, err)
|
||||||
|
} else {
|
||||||
|
logs.Info("%s update user info password success, update num: %d", userInfo.UserId, num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateUserInfo(userInfo UserInfo) {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
if num, err := o.Update(&userInfo); err != nil {
|
||||||
|
logs.Error("update user info fail: ", err)
|
||||||
|
} else {
|
||||||
|
logs.Info("update user info success, num: ", num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateStauts(status, userId string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(USERINFO).Filter("user_id", userId).Update(orm.Params{"status": status})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update status fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func UserInfoExistByUserId(userId string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userId).Exist()
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func NickIsExist(nick string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
exist := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("nick", nick).Exist()
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
func InsertUser(userInfo UserInfo) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.Insert(&userInfo)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("insert user fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteUserByUserId(userId string) bool {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
_, err := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userId).Update(orm.Params{"status": "delete"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("delete user by userId fail: ", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : 将代付结果返回给请求方
|
||||||
|
** @Time : 2019/11/20 1:35
|
||||||
|
** @Author : yuebin
|
||||||
|
** @File : payfor_notify
|
||||||
|
** @Last Modified by : yuebin
|
||||||
|
** @Last Modified time: 2019/11/20 1:35
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package notify
|
@ -0,0 +1,36 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gateway/models/merchant"
|
||||||
|
"gateway/models/road"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PayBaseResp struct {
|
||||||
|
Params map[string]string //请求的基本参数
|
||||||
|
ClientIp string //商户ip
|
||||||
|
MerchantInfo merchant.MerchantInfo //商户信息
|
||||||
|
Msg string //信息
|
||||||
|
Code int //状态码 200正常
|
||||||
|
RoadInfo road.RoadInfo
|
||||||
|
RoadPoolInfo road.RoadPoolInfo
|
||||||
|
OrderAmount float64
|
||||||
|
PayWayCode string
|
||||||
|
PlatformRate float64
|
||||||
|
AgentRate float64
|
||||||
|
}
|
||||||
|
|
||||||
|
type ScanSuccessData struct {
|
||||||
|
OrderNo string `json:"orderNo"`
|
||||||
|
Sign string `json:"sign"`
|
||||||
|
OrderPrice string `json:"orderPrice"`
|
||||||
|
PayKey string `json:"payKey"`
|
||||||
|
PayUrl string `json:"payURL"`
|
||||||
|
StatusCode string `json:"statusCode"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ScanFailData struct {
|
||||||
|
PayKey string `json:"payKey"`
|
||||||
|
StatusCode string `json:"statusCode"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回自动代付结果
|
||||||
|
*/
|
||||||
|
type PayForResponse struct {
|
||||||
|
ResultCode string `json:"resultCode,omitempty"`
|
||||||
|
ResultMsg string `json:"resultMsg,omitempty"`
|
||||||
|
MerchantOrderId string `json:"merchantOrderId,omitempty"`
|
||||||
|
SettAmount string `json:"settAmount,omitempty"`
|
||||||
|
SettFee string `json:"settFee,omitempty"`
|
||||||
|
Sign string `json:"sign,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回商户代付结果查询结果
|
||||||
|
*/
|
||||||
|
type PayForQueryResponse struct {
|
||||||
|
ResultMsg string `json:"resultMsg,omitempty"`
|
||||||
|
MerchantOrderId string `json:"merchantOrderId,omitempty"`
|
||||||
|
SettAmount string `json:"settAmount,omitempty"`
|
||||||
|
SettFee string `json:"settFee,omitempty"`
|
||||||
|
SettStatus string `json:"settStatus,omitempty"`
|
||||||
|
Sign string `json:"sign,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回商户查询余额结果
|
||||||
|
*/
|
||||||
|
type BalanceResponse struct {
|
||||||
|
ResultCode string `json:"resultCode,omitempty"`
|
||||||
|
Balance string `json:"balance,omitempty"`
|
||||||
|
AvailableAmount string `json:"availableAmount,omitempty"`
|
||||||
|
FreezeAmount string `json:"freezeAmount,omitempty"`
|
||||||
|
WaitAmount string `json:"waitAmount,omitempty"`
|
||||||
|
LoanAmount string `json:"loanAmount,omitempty"`
|
||||||
|
PayforAmount string `json:"payforAmount,omitempty"`
|
||||||
|
ResultMsg string `json:"resultMsg,omitempty"`
|
||||||
|
Sign string `json:"sign,omitempty"`
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/***************************************************
|
||||||
|
** @Desc : 注册上游支付接口
|
||||||
|
** @Time : 2019/10/28 14:48
|
||||||
|
** @Author : yueBin
|
||||||
|
** @File : init
|
||||||
|
** @Last Modified by : yueBin
|
||||||
|
** @Last Modified time: 2019/10/28 14:48
|
||||||
|
** @Software: GoLand
|
||||||
|
****************************************************/
|
||||||
|
package third_party
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gateway/supplier"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
)
|
||||||
|
|
||||||
|
//添加新的上游通道时,需要添加这里
|
||||||
|
var supplierCode2Name = map[string]string{
|
||||||
|
"KF": "快付支付",
|
||||||
|
"WEIXIN": "官方微信",
|
||||||
|
"ALIPAY": "官方支付宝",
|
||||||
|
"DAILI": "代丽支付",
|
||||||
|
}
|
||||||
|
|
||||||
|
var registerSupplier = make(map[string]supplier.PayInterface)
|
||||||
|
|
||||||
|
//注册各种上游的支付接口
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerSupplier["KF"] = new(KuaiFuImpl)
|
||||||
|
logs.Notice(CheckSupplierByCode("KF"))
|
||||||
|
|
||||||
|
registerSupplier["DAILI"] = new(DaiLiImpl)
|
||||||
|
logs.Notice(CheckSupplierByCode("DAILI"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPaySupplierByCode(code string) supplier.PayInterface {
|
||||||
|
return registerSupplier[code]
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckSupplierByCode(code string) string {
|
||||||
|
for k, v := range supplierCode2Name {
|
||||||
|
if k == code {
|
||||||
|
return v + ",注册完毕"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "未找到上游名称,注册有问题。"
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gateway/conf"
|
||||||
|
_ "gateway/message"
|
||||||
|
_ "gateway/models"
|
||||||
|
"gateway/models/payfor"
|
||||||
|
"gateway/pay_for"
|
||||||
|
"gateway/utils"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
"github.com/rs/xid"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAutoPayFor(t *testing.T) {
|
||||||
|
params := make(map[string]string)
|
||||||
|
|
||||||
|
params["merchantKey"] = "kkkkc254gk8isf001cqrj6p0"
|
||||||
|
params["realname"] = "孔跃彬"
|
||||||
|
params["cardNo"] = "6214830200383973"
|
||||||
|
params["accType"] = "0"
|
||||||
|
params["amount"] = "100"
|
||||||
|
paySecret := "ssssc254gk8isf001cqrj6pg"
|
||||||
|
params["merchantOrderId"] = xid.New().String()
|
||||||
|
keys := utils.SortMap(params)
|
||||||
|
params["sign"] = utils.GetMD5Sign(params, keys, paySecret)
|
||||||
|
payFor := pay_for.AutoPayFor(params, conf.SELF_API)
|
||||||
|
logs.Info(payFor)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPayForFail(t *testing.T) {
|
||||||
|
p := new(payfor.PayforInfo)
|
||||||
|
p.BankOrderId = "4444c4vlk3u7mathho2o8md0"
|
||||||
|
res := pay_for.PayForFail(*p)
|
||||||
|
logs.Info(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPayForSuccess(t *testing.T) {
|
||||||
|
p := new(payfor.PayforInfo)
|
||||||
|
p.BankOrderId = "4444c4vlk3u7mathho2o8md0"
|
||||||
|
res := pay_for.PayForSuccess(*p)
|
||||||
|
logs.Info(res)
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue