mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-11-14 20:47:45 +08:00
由gopath形式改为module
This commit is contained in:
50
boss/common/consts.go
Normal file
50
boss/common/consts.go
Normal file
@@ -0,0 +1,50 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/25 14:14
|
||||
** @Author : yuebin
|
||||
** @File : consts.go
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/25 14:14
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package common
|
||||
|
||||
const (
|
||||
ACTIVE = "active"
|
||||
UNACTIVE = "unactive"
|
||||
DELETE = "delete"
|
||||
REFUND = "refund"
|
||||
ORDERROLL = "order_roll"
|
||||
WAIT = "wait"
|
||||
SUCCESS = "success"
|
||||
FAIL = "fail"
|
||||
YES = "yes"
|
||||
NO = "no"
|
||||
ZERO = 0.0 //0元手续费
|
||||
VERIFY_CODE_LEN = 4 //验证码的长度
|
||||
PAYFOR_FEE = 2.00 //代付手续费
|
||||
PAYFOR_INTERVAL = 5 //每过5分钟执行一次代付
|
||||
|
||||
PLUS_AMOUNT = "plus_amount" //加款操作
|
||||
SUB_AMOUNT = "sub_amount" //减款操作
|
||||
FREEZE_AMOUNT = "freeze_amount" //冻结操作
|
||||
UNFREEZE_AMOUNT = "unfreeze_amount" //解冻操作
|
||||
|
||||
PAYFOR_COMFRIM = "payfor_confirm" //下发带审核
|
||||
PAYFOR_SOLVING = "payfor_solving" //发下处理中
|
||||
PAYFOR_HANDING = "payfor_handing" //手动打款中
|
||||
PAYFOR_BANKING = "payfor_banking" //银行处理中
|
||||
PAYFOR_FAIL = "payfor_fail" //代付失败
|
||||
PAYFOR_SUCCESS = "payfor_success" //代付成功
|
||||
|
||||
PAYFOR_ROAD = "payfor_road" //通道打款
|
||||
PAYFOR_HAND = "payfor_hand" //手动打款
|
||||
PAYFOR_REFUSE = "payfor_refuse" // 拒绝打款
|
||||
|
||||
SELF_API = "self_api" //自助api系统下发
|
||||
SELF_MERCHANT = "self_merchant" //管理手动处理商户下发
|
||||
SELF_HELP = "self_help" //管理自己提现
|
||||
|
||||
PUBLIC = "public" //对公卡
|
||||
PRIVATE = "private" //对私卡
|
||||
)
|
||||
25
boss/common/mq_config.go
Normal file
25
boss/common/mq_config.go
Normal file
@@ -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 common
|
||||
|
||||
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)
|
||||
}
|
||||
99
boss/common/pay_way_code.go
Normal file
99
boss/common/pay_way_code.go
Normal file
@@ -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 common
|
||||
|
||||
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 "未知"
|
||||
}
|
||||
}
|
||||
47
boss/common/supplier.go
Normal file
47
boss/common/supplier.go
Normal file
@@ -0,0 +1,47 @@
|
||||
/***************************************************
|
||||
** @Desc : 上有支付公司的编号
|
||||
** @Time : 2019/10/28 10:47
|
||||
** @Author : yuebin
|
||||
** @File : supplier
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/28 10:47
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package common
|
||||
|
||||
//添加新的上游通道时,需要添加这里
|
||||
var supplierCode2Name = map[string]string{
|
||||
"KF": "快付支付",
|
||||
"WEIXIN": "官方微信",
|
||||
"ALIPAY": "官方支付宝",
|
||||
}
|
||||
|
||||
func GetSupplierMap() map[string]string {
|
||||
return supplierCode2Name
|
||||
}
|
||||
|
||||
func GetSupplierCodes() []string {
|
||||
var supplierCodes []string
|
||||
for k := range supplierCode2Name {
|
||||
supplierCodes = append(supplierCodes, k)
|
||||
}
|
||||
|
||||
return supplierCodes
|
||||
}
|
||||
|
||||
func GetSupplierNames() []string {
|
||||
var supplierNames []string
|
||||
for _, v := range supplierCode2Name {
|
||||
supplierNames = append(supplierNames, v)
|
||||
}
|
||||
return supplierNames
|
||||
}
|
||||
|
||||
func CheckSupplierByCode(code string) string {
|
||||
for k, v := range supplierCode2Name {
|
||||
if k == code {
|
||||
return v + ",注册完毕"
|
||||
}
|
||||
}
|
||||
return "未找到上游名称,注册有问题。"
|
||||
}
|
||||
12
boss/conf/app.conf
Normal file
12
boss/conf/app.conf
Normal file
@@ -0,0 +1,12 @@
|
||||
appname = jhboss
|
||||
httpport = 12306
|
||||
runmode = dev
|
||||
|
||||
sessionon = true
|
||||
|
||||
[mysql]
|
||||
dbhost = localhost
|
||||
dbport = 3306
|
||||
dbuser = root
|
||||
dbpasswd =
|
||||
dbbase = juhe_pay
|
||||
18
boss/conf/config.go
Normal file
18
boss/conf/config.go
Normal file
@@ -0,0 +1,18 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/26 15:30
|
||||
** @Author : yuebin
|
||||
** @File : conf_pro
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/26 15:30
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package conf
|
||||
|
||||
const (
|
||||
DB_HOST = "localhost"
|
||||
DB_PORT = "3306"
|
||||
DB_USER = "root"
|
||||
DB_PASSWORD = "Kyb^15273031604"
|
||||
DB_BASE = "juhe_pay"
|
||||
)
|
||||
998
boss/controllers/addController.go
Normal file
998
boss/controllers/addController.go
Normal file
@@ -0,0 +1,998 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/8/19 18:13
|
||||
** @Author : yuebin
|
||||
** @File : add
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/19 18:13
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
"boss/utils"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/adapter/validation"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/rs/xid"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type AddController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加一级菜单
|
||||
*/
|
||||
func (c *AddController) AddMenu() {
|
||||
oneMenu := c.GetString("oneMenu")
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
menuInfo := models.MenuInfo{MenuUid: xid.New().String(), FirstMenu: oneMenu, Status: "active",
|
||||
Creater: c.GetSession("userID").(string), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
exist := models.FirstMenuIsExists(oneMenu)
|
||||
if !exist {
|
||||
menuInfo.MenuOrder = models.GetMenuLen() + 1
|
||||
flag := models.InsertMenu(menuInfo)
|
||||
if !flag {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "添加菜单失败"
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "一级菜单名已经存在"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加二级菜单
|
||||
*/
|
||||
func (c *AddController) AddSecondMenu() {
|
||||
firstMenuUid := c.GetString("preMenuUid")
|
||||
secondMenu := c.GetString("secondMenu")
|
||||
secondRouter := c.GetString("secondRouter")
|
||||
|
||||
dataJSON := new(KeyDataJSON)
|
||||
|
||||
firstMenuInfo := models.GetMenuInfoByMenuUid(firstMenuUid)
|
||||
routerExists := models.SecondRouterExists(secondRouter)
|
||||
secondMenuExists := models.SecondMenuIsExists(secondMenu)
|
||||
|
||||
if firstMenuInfo.MenuUid == "" {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Key = "pre-menu-error"
|
||||
dataJSON.Msg = "*一级菜单不存在"
|
||||
} else if routerExists {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "*该路由已存在"
|
||||
dataJSON.Key = "second-router-error"
|
||||
} else if secondMenuExists {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Key = "second-menu-error"
|
||||
dataJSON.Msg = "*该菜单名已经存在"
|
||||
} else {
|
||||
sl := models.GetSecondMenuLenByFirstMenuUid(firstMenuUid)
|
||||
secondMenuInfo := models.SecondMenuInfo{MenuOrder: sl + 1, FirstMenuUid: firstMenuInfo.MenuUid,
|
||||
FirstMenu: firstMenuInfo.FirstMenu, SecondMenuUid: xid.New().String(), Status: "active",
|
||||
SecondMenu: secondMenu, SecondRouter: secondRouter, Creater: c.GetSession("userID").(string),
|
||||
CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime(), FirstMenuOrder: firstMenuInfo.MenuOrder}
|
||||
if !models.InsertSecondMenu(secondMenuInfo) {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "添加二级菜单失败"
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "添加二级菜单成功"
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加权限项的处理函数
|
||||
*/
|
||||
func (c *AddController) AddPower() {
|
||||
firstMenuUid := strings.TrimSpace(c.GetString("firstMenuUid"))
|
||||
secondMenuUid := strings.TrimSpace(c.GetString("secondMenuUid"))
|
||||
powerItem := strings.TrimSpace(c.GetString("powerItem"))
|
||||
powerID := strings.TrimSpace(c.GetString("powerID"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
if powerItem == "" || len(powerItem) == 0 {
|
||||
keyDataJSON.Key = ".power-name-error"
|
||||
keyDataJSON.Msg = "*权限项名称不能为空"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
if powerID == "" || len(powerID) == 0 {
|
||||
keyDataJSON.Key = ".power-id-error"
|
||||
keyDataJSON.Msg = "*权限项ID不能为空"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
if models.PowerUidExists(powerID) {
|
||||
keyDataJSON.Key = ".power-id-error"
|
||||
keyDataJSON.Msg = "*权限项ID已经存在"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(powerID)
|
||||
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||
|
||||
powerInfo := models.PowerInfo{SecondMenuUid: secondMenuUid, SecondMenu: secondMenuInfo.SecondMenu,
|
||||
PowerId: powerID, PowerItem: powerItem, Creater: c.GetSession("userID").(string),
|
||||
Status: "active", CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime(),
|
||||
FirstMenuUid: firstMenuUid}
|
||||
|
||||
keyDataJSON.Code = 200
|
||||
if !models.InsertPowerInfo(powerInfo) {
|
||||
keyDataJSON.Key = ".power-save-success"
|
||||
keyDataJSON.Msg = "添加权限项失败"
|
||||
} else {
|
||||
keyDataJSON.Key = ".power-save-success"
|
||||
keyDataJSON.Msg = "添加权限项成功"
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加权限角色
|
||||
*/
|
||||
func (this *AddController) AddRole() {
|
||||
roleName := strings.TrimSpace(this.GetString("roleNameAdd"))
|
||||
roleRemark := strings.TrimSpace(this.GetString("roleRemark"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if len(roleName) == 0 {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".role-name-error"
|
||||
keyDataJSON.Msg = "*角色名称不能为空"
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if models.RoleNameExists(roleName) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".role-name-error"
|
||||
keyDataJSON.Msg = "*角色名称已经存在"
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
roleInfo := models.RoleInfo{RoleName: roleName, RoleUid: xid.New().String(),
|
||||
Creater: this.GetSession("userID").(string), Status: "active", Remark: roleRemark,
|
||||
CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if !models.InsertRole(roleInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".role-save-success"
|
||||
keyDataJSON.Msg = "添加角色失败"
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
keyDataJSON.Code = 200
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (this *AddController) SavePower() {
|
||||
firstMenuUids := this.GetStrings("firstMenuUid[]")
|
||||
secondMenuUids := this.GetStrings("secondMenuUid[]")
|
||||
powerIds := this.GetStrings("powerId[]")
|
||||
roleUid := strings.TrimSpace(this.GetString("roleUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
roleInfo := models.GetRoleByRoleUid(roleUid)
|
||||
if len(roleUid) == 0 || len(roleInfo.RoleUid) == 0 {
|
||||
dataJSON.Code = -1
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
roleInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
roleInfo.ShowFirstUid = strings.Join(firstMenuUids, "||")
|
||||
roleInfo.ShowSecondUid = strings.Join(secondMenuUids, "||")
|
||||
roleInfo.ShowPowerUid = strings.Join(powerIds, "||")
|
||||
|
||||
menuInfoList := models.GetMenuInfosByMenuUids(firstMenuUids)
|
||||
showFirstMenu := make([]string, 0)
|
||||
for _, m := range menuInfoList {
|
||||
showFirstMenu = append(showFirstMenu, m.FirstMenu)
|
||||
}
|
||||
roleInfo.ShowFirstMenu = strings.Join(showFirstMenu, "||")
|
||||
|
||||
secondMenuInfoList := models.GetSecondMenuInfoBySecondMenuUids(secondMenuUids)
|
||||
showSecondMenu := make([]string, 0)
|
||||
for _, m := range secondMenuInfoList {
|
||||
showSecondMenu = append(showSecondMenu, m.SecondMenu)
|
||||
}
|
||||
roleInfo.ShowSecondMenu = strings.Join(showSecondMenu, "||")
|
||||
|
||||
powerList := models.GetPowerByIds(powerIds)
|
||||
showPower := make([]string, 0)
|
||||
for _, p := range powerList {
|
||||
showPower = append(showPower, p.PowerItem)
|
||||
}
|
||||
roleInfo.ShowPower = strings.Join(showPower, "||")
|
||||
|
||||
if !models.UpdateRoleInfo(roleInfo) {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "更新roleInfo失败"
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "更新roleInfo成功"
|
||||
}
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加操作员
|
||||
*/
|
||||
func (this *AddController) AddOperator() {
|
||||
loginAccount := strings.TrimSpace(this.GetString("operatorAccount"))
|
||||
loginPassword := strings.TrimSpace(this.GetString("operatorPassword"))
|
||||
role := strings.TrimSpace(this.GetString("operatorRole"))
|
||||
status := strings.TrimSpace(this.GetString("status"))
|
||||
remark := strings.TrimSpace(this.GetString("remark"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
if len(loginAccount) == 0 {
|
||||
keyDataJSON.Key = ".operator-name-error"
|
||||
keyDataJSON.Msg = "*登录账号不能为空"
|
||||
} else if len(loginPassword) == 0 {
|
||||
keyDataJSON.Key = ".operator-password-error"
|
||||
keyDataJSON.Msg = "*初始密码不能为空"
|
||||
} else if len(role) == 0 || role == "none" {
|
||||
keyDataJSON.Key = ".operator-role-error"
|
||||
keyDataJSON.Msg = "请选择角色"
|
||||
} else if models.UserInfoExistByUserId(loginAccount) {
|
||||
keyDataJSON.Key = ".operator-name-error"
|
||||
keyDataJSON.Msg = "*账号已经存在"
|
||||
} else {
|
||||
if len(remark) == 0 {
|
||||
remark = loginAccount
|
||||
}
|
||||
roleInfo := models.GetRoleByRoleUid(role)
|
||||
userInfo := models.UserInfo{UserId: loginAccount, Passwd: utils.GetMD5Upper(loginPassword), Nick: "壮壮", Remark: remark,
|
||||
Status: status, Role: role, RoleName: roleInfo.RoleName, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
if !models.InsertUser(userInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "添加操作员失败"
|
||||
} else {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "添加操作员成功"
|
||||
}
|
||||
}
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加银行卡
|
||||
*/
|
||||
func (this *AddController) AddBankCard() {
|
||||
userName := strings.TrimSpace(this.GetString("userName"))
|
||||
bankCode := strings.TrimSpace(this.GetString("bankCode"))
|
||||
accountName := strings.TrimSpace(this.GetString("accountName"))
|
||||
certificateType := strings.TrimSpace(this.GetString("certificateType"))
|
||||
phoneNo := strings.TrimSpace(this.GetString("phoneNo"))
|
||||
bankName := strings.TrimSpace(this.GetString("bankName"))
|
||||
bankAccountType := strings.TrimSpace(this.GetString("bankAccountType"))
|
||||
bankNo := strings.TrimSpace(this.GetString("bankNo"))
|
||||
identifyCard := strings.TrimSpace(this.GetString("certificateType"))
|
||||
certificateNo := strings.TrimSpace(this.GetString("certificateNo"))
|
||||
bankAddress := strings.TrimSpace(this.GetString("bankAddress"))
|
||||
uid := strings.TrimSpace(this.GetString("uid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
dataJSON.Code = -1
|
||||
if len(userName) == 0 {
|
||||
dataJSON.Msg = "用户名不能为空"
|
||||
} else if len(bankCode) == 0 {
|
||||
dataJSON.Msg = "银行编码不能为空"
|
||||
} else if len(accountName) == 0 {
|
||||
dataJSON.Msg = "银行开户名不能为空"
|
||||
} else if len(certificateType) == 0 {
|
||||
dataJSON.Msg = "证件种类不能为空"
|
||||
} else if len(phoneNo) == 0 {
|
||||
dataJSON.Msg = "手机号不能为空"
|
||||
} else if len(bankName) == 0 {
|
||||
dataJSON.Msg = "银行名称不能为空"
|
||||
} else if len(bankAccountType) == 0 {
|
||||
dataJSON.Msg = "银行账户类型不能为空"
|
||||
} else if len(bankNo) == 0 {
|
||||
dataJSON.Msg = "银行账号不能为空"
|
||||
} else if len(certificateNo) == 0 {
|
||||
dataJSON.Msg = "身份证号不能为空"
|
||||
} else if len(bankAddress) == 0 {
|
||||
dataJSON.Msg = "银行地址不能为空"
|
||||
} else {
|
||||
|
||||
}
|
||||
if dataJSON.Msg != "" {
|
||||
logs.Error("添加银行卡校验失败")
|
||||
} else {
|
||||
if len(uid) > 0 {
|
||||
bankCardInfo := models.GetBankCardByUid(uid)
|
||||
bankCardInfo = models.BankCardInfo{
|
||||
Id: bankCardInfo.Id, UserName: userName, BankName: bankName,
|
||||
BankCode: bankCode, BankAccountType: bankAccountType,
|
||||
AccountName: accountName, BankNo: bankNo, IdentifyCard: identifyCard,
|
||||
CertificateNo: certificateNo, PhoneNo: phoneNo,
|
||||
BankAddress: bankAddress, UpdateTime: utils.GetBasicDateTime(),
|
||||
CreateTime: bankCardInfo.CreateTime, Uid: bankCardInfo.Uid,
|
||||
}
|
||||
if models.UpdateBankCard(bankCardInfo) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
} else {
|
||||
bankCardInfo := models.BankCardInfo{Uid: "3333" + xid.New().String(), UserName: userName, BankName: bankName,
|
||||
BankCode: bankCode, BankAccountType: bankAccountType, AccountName: accountName, BankNo: bankNo,
|
||||
IdentifyCard: identifyCard, CertificateNo: certificateNo, PhoneNo: phoneNo, BankAddress: bankAddress,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertBankCardInfo(bankCardInfo) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加通道
|
||||
*/
|
||||
func (this *AddController) AddRoad() {
|
||||
roadUid := strings.TrimSpace(this.GetString("roadUid"))
|
||||
roadName := strings.TrimSpace(this.GetString("roadName"))
|
||||
roadRemark := strings.TrimSpace(this.GetString("roadRemark"))
|
||||
productUid := strings.TrimSpace(this.GetString("productName"))
|
||||
payType := strings.TrimSpace(this.GetString("payType"))
|
||||
basicRate := strings.TrimSpace(this.GetString("basicRate"))
|
||||
settleFee := strings.TrimSpace(this.GetString("settleFee"))
|
||||
roadTotalLimit := strings.TrimSpace(this.GetString("roadTotalLimit"))
|
||||
roadEverydayLimit := strings.TrimSpace(this.GetString("roadEverydayLimit"))
|
||||
singleMinLimit := strings.TrimSpace(this.GetString("singleMinLimit"))
|
||||
singleMaxLimit := strings.TrimSpace(this.GetString("singleMaxLimit"))
|
||||
startHour := strings.TrimSpace(this.GetString("startHour"))
|
||||
endHour := strings.TrimSpace(this.GetString("endHour"))
|
||||
params := strings.TrimSpace(this.GetString("params"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
startHourTmp, err1 := strconv.Atoi(startHour)
|
||||
endHourTmp, err2 := strconv.Atoi(endHour)
|
||||
|
||||
if err1 != nil || err2 != nil {
|
||||
dataJSON.Msg = "开始时间或者结束时间设置有误"
|
||||
this.GenerateJSON(dataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
valid := validation.Validation{}
|
||||
if v := valid.Required(roadName, "roadName"); !v.Ok {
|
||||
dataJSON.Msg = "通道名称不能为空"
|
||||
} else if v := valid.Required(productUid, "productUid"); !v.Ok {
|
||||
dataJSON.Msg = "产品名称不能为空"
|
||||
} else if v := valid.Required(payType, "payType"); !v.Ok {
|
||||
dataJSON.Msg = "支付类型不能为空"
|
||||
} else if v := valid.Required(basicRate, ""); !v.Ok {
|
||||
dataJSON.Msg = "成本费率不能为空"
|
||||
} else if v := valid.Range(startHourTmp, 0, 23, ""); !v.Ok {
|
||||
dataJSON.Msg = "开始时间设置有误"
|
||||
} else if v := valid.Range(endHourTmp, 0, 23, ""); !v.Ok {
|
||||
dataJSON.Msg = "结束时间设置有误"
|
||||
} else {
|
||||
basicFee, err := strconv.ParseFloat(basicRate, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "成本汇率设置不符合规范"
|
||||
}
|
||||
settleFeeTmp, err := strconv.ParseFloat(settleFee, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "代付手续费设置不符合规范"
|
||||
}
|
||||
totalLimit, err := strconv.ParseFloat(roadTotalLimit, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "通道总额度设置不符合规范"
|
||||
}
|
||||
todayLimit, err := strconv.ParseFloat(roadEverydayLimit, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "每天额度设置不符合规范"
|
||||
}
|
||||
singleMinLimitTmp, err := strconv.ParseFloat(singleMinLimit, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "单笔最小金额设置不符合规范"
|
||||
}
|
||||
singleMaxLimitTmp, err := strconv.ParseFloat(singleMaxLimit, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "单笔最大金额设置不符合规范"
|
||||
}
|
||||
if len(dataJSON.Msg) > 0 {
|
||||
this.GenerateJSON(dataJSON)
|
||||
return
|
||||
}
|
||||
productName := ""
|
||||
supplierMap := common.GetSupplierMap()
|
||||
for k, v := range supplierMap {
|
||||
if k == productUid {
|
||||
productName = v
|
||||
}
|
||||
}
|
||||
|
||||
if len(roadUid) > 0 {
|
||||
//更新通道
|
||||
roadInfo := models.GetRoadInfoByRoadUid(roadUid)
|
||||
roadInfo.RoadName = roadName
|
||||
roadInfo.Remark = roadRemark
|
||||
roadInfo.ProductUid = productUid
|
||||
roadInfo.ProductName = productName
|
||||
roadInfo.PayType = payType
|
||||
roadInfo.BasicFee = basicFee
|
||||
roadInfo.SettleFee = settleFeeTmp
|
||||
roadInfo.TotalLimit = totalLimit
|
||||
roadInfo.TodayLimit = todayLimit
|
||||
roadInfo.SingleMaxLimit = singleMaxLimitTmp
|
||||
roadInfo.SingleMinLimit = singleMinLimitTmp
|
||||
roadInfo.StarHour = startHourTmp
|
||||
roadInfo.EndHour = endHourTmp
|
||||
roadInfo.Params = params
|
||||
|
||||
if models.UpdateRoadInfo(roadInfo) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Msg = "通道更新失败"
|
||||
}
|
||||
} else {
|
||||
//添加新的通道
|
||||
roadUid = "4444" + xid.New().String()
|
||||
roadInfo := models.RoadInfo{RoadName: roadName, RoadUid: roadUid, Remark: roadRemark,
|
||||
ProductUid: productUid, ProductName: productName, PayType: payType, BasicFee: basicFee, SettleFee: settleFeeTmp,
|
||||
TotalLimit: totalLimit, TodayLimit: todayLimit, SingleMinLimit: singleMinLimitTmp, Balance: common.ZERO,
|
||||
SingleMaxLimit: singleMaxLimitTmp, StarHour: startHourTmp, EndHour: endHourTmp, Status: "active",
|
||||
Params: params, UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime(),
|
||||
}
|
||||
|
||||
if models.InsertRoadInfo(roadInfo) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Msg = "添加新通道失败"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (this *AddController) AddRoadPool() {
|
||||
roadPoolName := strings.TrimSpace(this.GetString("roadPoolName"))
|
||||
roadPoolCode := strings.TrimSpace(this.GetString("roadPoolCode"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
|
||||
if len(roadPoolName) == 0 {
|
||||
keyDataJSON.Msg = "*通道池名称不能为空"
|
||||
} else if len(roadPoolCode) == 0 {
|
||||
keyDataJSON.Msg = "*通道池编号不能为空"
|
||||
}
|
||||
|
||||
roadPoolInfo := models.RoadPoolInfo{Status: "active", RoadPoolName: roadPoolName, RoadPoolCode: roadPoolCode,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertRoadPool(roadPoolInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "添加通道池成功"
|
||||
} else {
|
||||
keyDataJSON.Msg = "添加通道池失败"
|
||||
}
|
||||
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加或者更新通道池中的通道
|
||||
*/
|
||||
func (this *AddController) SaveRoadUid() {
|
||||
roadUids := this.GetStrings("roadUid[]")
|
||||
roadPoolCode := strings.TrimSpace(this.GetString("roadPoolCode"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
roadPoolInfo := models.GetRoadPoolByRoadPoolCode(roadPoolCode)
|
||||
if roadPoolInfo.RoadPoolCode == "" {
|
||||
this.GenerateJSON(dataJSON)
|
||||
return
|
||||
}
|
||||
var uids []string
|
||||
for _, uid := range roadUids {
|
||||
//去掉空格
|
||||
if len(uid) > 0 && models.RoadInfoExistByRoadUid(uid) {
|
||||
uids = append(uids, uid)
|
||||
}
|
||||
}
|
||||
if len(uids) > 0 {
|
||||
roadUid := strings.Join(uids, "||")
|
||||
roadPoolInfo.RoadUidPool = roadUid
|
||||
}
|
||||
roadPoolInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if models.UpdateRoadPool(roadPoolInfo) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加代理信息
|
||||
*/
|
||||
func (this *AddController) AddAgent() {
|
||||
agentName := strings.TrimSpace(this.GetString("agentName"))
|
||||
agentPhone := strings.TrimSpace(this.GetString("agentPhone"))
|
||||
agentLoginPassword := strings.TrimSpace(this.GetString("agentLoginPassword"))
|
||||
agentVertifyPassword := strings.TrimSpace(this.GetString("agentVertifyPassword"))
|
||||
agentRemark := strings.TrimSpace(this.GetString("agentRemark"))
|
||||
status := strings.TrimSpace(this.GetString("status"))
|
||||
agentUid := strings.TrimSpace(this.GetString("agentUid"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if agentName == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-name-error"
|
||||
keyDataJSON.Msg = "代理名不能为空"
|
||||
} else if models.IsEixstByAgentName(agentName) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-name-error"
|
||||
keyDataJSON.Msg = "已存在该代理名称"
|
||||
} else if agentPhone == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-phone-error"
|
||||
keyDataJSON.Msg = "代理注册手机号不能为空"
|
||||
} else if models.IsEixstByAgentPhone(agentPhone) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-phone-error"
|
||||
keyDataJSON.Msg = "代理商手机号已被注册"
|
||||
} else if agentLoginPassword == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-login-password-error"
|
||||
keyDataJSON.Msg = "密码不能为空"
|
||||
} else if agentLoginPassword != agentVertifyPassword {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-vertify-password-error"
|
||||
keyDataJSON.Msg = "二次密码输入不一致"
|
||||
}
|
||||
|
||||
if keyDataJSON.Code == -1 {
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if status == "" {
|
||||
status = "active"
|
||||
}
|
||||
|
||||
if agentUid == "" {
|
||||
|
||||
agentUid = "9999" + xid.New().String()
|
||||
|
||||
agentInfo := models.AgentInfo{Status: status, AgentName: agentName, AgentPhone: agentPhone,
|
||||
AgentPassword: utils.GetMD5Upper(agentLoginPassword), AgentUid: agentUid, UpdateTime: utils.GetBasicDateTime(),
|
||||
CreateTime: utils.GetBasicDateTime(), AgentRemark: agentRemark}
|
||||
|
||||
if !models.InsertAgentInfo(agentInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "添加代理商失败"
|
||||
}
|
||||
}
|
||||
|
||||
//创建新的账户
|
||||
account := models.GetAccountByUid(agentUid)
|
||||
if account.AccountUid == "" {
|
||||
account.Status = "active"
|
||||
account.AccountUid = agentUid
|
||||
account.AccountName = agentName
|
||||
account.Balance = 0.0
|
||||
account.LoanAmount = 0.0
|
||||
account.FreezeAmount = 0.0
|
||||
account.PayforAmount = 0.0
|
||||
account.SettleAmount = 0.0
|
||||
account.WaitAmount = 0.0
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
account.CreateTime = utils.GetBasicDateTime()
|
||||
if models.InsetAcount(account) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "插入成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "掺入失败"
|
||||
}
|
||||
}
|
||||
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (this *AddController) AddMerchant() {
|
||||
merchantName := strings.TrimSpace(this.GetString("merchantName"))
|
||||
phone := strings.TrimSpace(this.GetString("phone"))
|
||||
loginPassword := strings.TrimSpace(this.GetString("loginPassword"))
|
||||
verifyPassword := strings.TrimSpace(this.GetString("verifyPassword"))
|
||||
merchantStatus := strings.TrimSpace(this.GetString("merchantStatus"))
|
||||
remark := strings.TrimSpace(this.GetString("remark"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
if merchantName == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-name-error"
|
||||
keyDataJSON.Msg = "商户名称为空"
|
||||
} else if models.IsExistByMerchantName(merchantName) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-name-error"
|
||||
keyDataJSON.Msg = "商户名已经存在"
|
||||
} else if phone == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-phone-error"
|
||||
keyDataJSON.Msg = "手机号为空"
|
||||
} else if models.IsExistByMerchantPhone(phone) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-phone-error"
|
||||
keyDataJSON.Msg = "该手机号已经注册"
|
||||
} else if loginPassword == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-login-password-error"
|
||||
keyDataJSON.Msg = "登录密码为空"
|
||||
} else if verifyPassword == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-verify-password-error"
|
||||
keyDataJSON.Msg = "密码确认为空"
|
||||
} else if loginPassword != verifyPassword {
|
||||
keyDataJSON.Key = "#merchant-verify-password-error"
|
||||
keyDataJSON.Msg = "两次密码输入不正确"
|
||||
} else if merchantStatus == "" {
|
||||
merchantStatus = "active"
|
||||
}
|
||||
if keyDataJSON.Code == -1 {
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
merchantUid := "8888" + xid.New().String()
|
||||
merchantKey := "kkkk" + xid.New().String() //商户key
|
||||
merchantSecret := "ssss" + xid.New().String() //商户密钥
|
||||
merchantInfo := models.MerchantInfo{MerchantName: merchantName, MerchantUid: merchantUid,
|
||||
LoginAccount: phone, MerchantKey: merchantKey, MerchantSecret: merchantSecret,
|
||||
LoginPassword: utils.GetMD5Upper(loginPassword), Status: merchantStatus, Remark: remark,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertMerchantInfo(merchantInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "插入失败"
|
||||
}
|
||||
//创建新的账户
|
||||
account := models.GetAccountByUid(merchantUid)
|
||||
if account.AccountUid == "" {
|
||||
account.Status = "active"
|
||||
account.AccountUid = merchantUid
|
||||
account.AccountName = merchantName
|
||||
account.Balance = 0.0
|
||||
account.LoanAmount = 0.0
|
||||
account.FreezeAmount = 0.0
|
||||
account.PayforAmount = 0.0
|
||||
account.SettleAmount = 0.0
|
||||
account.WaitAmount = 0.0
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
account.CreateTime = utils.GetBasicDateTime()
|
||||
if models.InsetAcount(account) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "插入成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "掺入失败"
|
||||
}
|
||||
}
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加商戶支付配置參數
|
||||
*/
|
||||
func (this *AddController) AddMerchantDeploy() {
|
||||
//merchantName := strings.TrimSpace(this.GetString("merchantName"))
|
||||
merchantUid := strings.TrimSpace(this.GetString("merchantNo"))
|
||||
isAutoSettle := strings.TrimSpace(this.GetString("isAutoSettle"))
|
||||
isAutoPayfor := strings.TrimSpace(this.GetString("isAutoPayfor"))
|
||||
ipWhite := strings.TrimSpace(this.GetString("ipWhite"))
|
||||
payforRoadChoose := strings.TrimSpace(this.GetString("payforRoadChoose"))
|
||||
rollPayforRoadChoose := strings.TrimSpace(this.GetString("rollPayforRoadChoose"))
|
||||
payforFee := strings.TrimSpace(this.GetString("payforFee"))
|
||||
belongAgentName := strings.TrimSpace(this.GetString("belongAgentName"))
|
||||
belongAgentUid := strings.TrimSpace(this.GetString("belongAgentUid"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
merchantInfo.AutoSettle = isAutoSettle
|
||||
merchantInfo.AutoPayFor = isAutoPayfor
|
||||
merchantInfo.WhiteIps = ipWhite
|
||||
merchantInfo.BelongAgentName = belongAgentName
|
||||
merchantInfo.BelongAgentUid = belongAgentUid
|
||||
|
||||
if payforRoadChoose != "" {
|
||||
roadInfo := models.GetRoadInfoByName(payforRoadChoose)
|
||||
merchantInfo.SinglePayForRoadName = payforRoadChoose
|
||||
merchantInfo.SinglePayForRoadUid = roadInfo.RoadUid
|
||||
}
|
||||
if rollPayforRoadChoose != "" {
|
||||
rollPoolInfo := models.GetRoadPoolByName(rollPayforRoadChoose)
|
||||
merchantInfo.RollPayForRoadName = rollPayforRoadChoose
|
||||
merchantInfo.RollPayForRoadCode = rollPoolInfo.RoadPoolCode
|
||||
}
|
||||
tmp, err := strconv.ParseFloat(payforFee, 64)
|
||||
if err != nil {
|
||||
logs.Error("手续费由字符串转为float64失败")
|
||||
tmp = common.PAYFOR_FEE
|
||||
}
|
||||
merchantInfo.PayforFee = tmp
|
||||
if models.UpdateMerchant(merchantInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (this *AddController) AddMerchantPayType() {
|
||||
merchantNo := strings.TrimSpace(this.GetString("merchantNo"))
|
||||
payType := strings.TrimSpace(this.GetString("payType"))
|
||||
singleRoad := strings.TrimSpace(this.GetString("singleRoad"))
|
||||
singleRoadPlatformFee := strings.TrimSpace(this.GetString("singleRoadPlatformFee"))
|
||||
singleRoadAgentFee := strings.TrimSpace(this.GetString("singleRoadAgentFee"))
|
||||
rollPoolRoad := strings.TrimSpace(this.GetString("rollPoolRoad"))
|
||||
rollRoadPlatformFee := strings.TrimSpace(this.GetString("rollRoadPlatformFee"))
|
||||
rollRoadAgentFee := strings.TrimSpace(this.GetString("rollRoadAgentFee"))
|
||||
isLoan := strings.TrimSpace(this.GetString("isLoan"))
|
||||
loanRate := strings.TrimSpace(this.GetString("loanRate"))
|
||||
loanDays := strings.TrimSpace(this.GetString("loanDays"))
|
||||
unfreezeTimeHour := strings.TrimSpace(this.GetString("unfreezeTimeHour"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if payType == "" || payType == "none" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "操作失败,请选择支付类型"
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
if singleRoad == "" && (singleRoadPlatformFee != "" || singleRoadAgentFee != "") {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "单通道选项不能为空"
|
||||
} else if rollPoolRoad == "" && (rollRoadPlatformFee != "" || rollRoadAgentFee != "") {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "轮询通道选项不能为空"
|
||||
}
|
||||
|
||||
if keyDataJSON.Code == -1 {
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
//将字符串转变为float64或者int类型
|
||||
a, err := strconv.ParseFloat(singleRoadPlatformFee, 64)
|
||||
if err != nil {
|
||||
a = 0.0
|
||||
}
|
||||
b, err := strconv.ParseFloat(singleRoadAgentFee, 64)
|
||||
if err != nil {
|
||||
b = 0.0
|
||||
}
|
||||
c, err := strconv.ParseFloat(rollRoadPlatformFee, 64)
|
||||
if err != nil {
|
||||
c = 0.0
|
||||
}
|
||||
d, err := strconv.ParseFloat(rollRoadAgentFee, 64)
|
||||
if err != nil {
|
||||
d = 0.0
|
||||
}
|
||||
e, err := strconv.ParseFloat(loanRate, 64)
|
||||
if err != nil {
|
||||
e = 0.0
|
||||
}
|
||||
i, err := strconv.Atoi(loanDays)
|
||||
if err != nil {
|
||||
i = 0
|
||||
}
|
||||
j, err := strconv.Atoi(unfreezeTimeHour)
|
||||
if err != nil {
|
||||
j = 0
|
||||
}
|
||||
|
||||
var merchantDeployInfo models.MerchantDeployInfo
|
||||
merchantDeployInfo.MerchantUid = merchantNo
|
||||
merchantDeployInfo.PayType = payType
|
||||
merchantDeployInfo.SingleRoadName = singleRoad
|
||||
merchantDeployInfo.SingleRoadPlatformRate = a
|
||||
merchantDeployInfo.SingleRoadAgentRate = b
|
||||
merchantDeployInfo.RollRoadPlatformRate = c
|
||||
merchantDeployInfo.RollRoadAgentRate = d
|
||||
merchantDeployInfo.IsLoan = isLoan
|
||||
merchantDeployInfo.LoanRate = e
|
||||
merchantDeployInfo.LoanDays = i
|
||||
merchantDeployInfo.UnfreezeHour = j
|
||||
merchantDeployInfo.RollRoadName = rollPoolRoad
|
||||
roadInfo := models.GetRoadInfoByName(singleRoad)
|
||||
rollPoolInfo := models.GetRoadPoolByName(rollPoolRoad)
|
||||
merchantDeployInfo.SingleRoadUid = roadInfo.RoadUid
|
||||
merchantDeployInfo.RollRoadCode = rollPoolInfo.RoadPoolCode
|
||||
|
||||
//如果该用户的改支付类型已经存在,那么进行更新,否则进行添加
|
||||
if models.IsExistByUidAndPayType(merchantNo, payType) {
|
||||
if singleRoad == "" && rollPoolRoad == "" {
|
||||
//表示需要删除该支付类型的通道
|
||||
if models.DeleteMerchantDeployByUidAndPayType(merchantNo, payType) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "删除该支付类型通道成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "删除该支付类型通道失败"
|
||||
}
|
||||
} else {
|
||||
tmpInfo := models.GetMerchantDeployByUidAndPayType(merchantNo, payType)
|
||||
merchantDeployInfo.Id = tmpInfo.Id
|
||||
merchantDeployInfo.Status = tmpInfo.Status
|
||||
merchantDeployInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if models.UpdateMerchantDeploy(merchantDeployInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "更新成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "更新失败"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if singleRoad == "" && rollPoolRoad == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "参数不能为空"
|
||||
} else {
|
||||
merchantDeployInfo.CreateTime = utils.GetBasicDateTime()
|
||||
merchantDeployInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
merchantDeployInfo.Status = common.ACTIVE
|
||||
if models.InsertMerchantDeployInfo(merchantDeployInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "添加支付类型成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "添加支付类型失败"
|
||||
}
|
||||
}
|
||||
}
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
*后台提交的下发记录
|
||||
*/
|
||||
func (c *AddController) AddPayFor() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
merchantName := strings.TrimSpace(c.GetString("merchantName"))
|
||||
bankName := strings.TrimSpace(c.GetString("bankName"))
|
||||
accountName := strings.TrimSpace(c.GetString("accountName"))
|
||||
bankUid := strings.TrimSpace(c.GetString("bankUid"))
|
||||
bankNo := strings.TrimSpace(c.GetString("bankNo"))
|
||||
//cardType := strings.TrimSpace(c.GetString("cardType"))
|
||||
bankAddress := strings.TrimSpace(c.GetString("bankAddress"))
|
||||
phone := strings.TrimSpace(c.GetString("phone"))
|
||||
payForAmount := strings.TrimSpace(c.GetString("payForAmount"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
|
||||
if merchantUid == "" {
|
||||
keyDataJSON.Msg = "请选择需要下发的商户"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if bankUid == "" {
|
||||
keyDataJSON.Msg = "请选择发下银行卡"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
money, err := strconv.ParseFloat(payForAmount, 64)
|
||||
if err != nil {
|
||||
logs.Error("add pay for fail: ", err)
|
||||
keyDataJSON.Msg = "下发金额输入不正确"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
accountInfo := models.GetAccountByUid(merchantUid)
|
||||
if accountInfo.SettleAmount < money+common.PAYFOR_FEE {
|
||||
keyDataJSON.Msg = "用户可用金额不够"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
bankInfo := models.GetBankCardByUid(bankUid)
|
||||
|
||||
if bankInfo.BankNo != bankNo || bankInfo.AccountName != accountName || bankInfo.PhoneNo != phone {
|
||||
keyDataJSON.Msg = "银行卡信息有误,请连接管理员"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
payFor := models.PayforInfo{PayforUid: "pppp" + xid.New().String(), MerchantUid: merchantUid, MerchantName: merchantName, PhoneNo: phone,
|
||||
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: bankInfo.BankCode, BankName: bankName, IsSend: common.NO,
|
||||
BankAccountName: bankInfo.AccountName, BankAccountNo: bankInfo.BankNo, BankAccountType: bankInfo.BankAccountType, BankAccountAddress: bankAddress,
|
||||
Status: common.PAYFOR_COMFRIM, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertPayfor(payFor) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "代付下发提交失败"
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *AddController) AddSelfPayFor() {
|
||||
bankUid := strings.TrimSpace(c.GetString("bankUid"))
|
||||
bankName := strings.TrimSpace(c.GetString("bankName"))
|
||||
accountName := strings.TrimSpace(c.GetString("accountName"))
|
||||
bankNo := strings.TrimSpace(c.GetString("bankNo"))
|
||||
//cardType := strings.TrimSpace(c.GetString("cardType"))
|
||||
bankAddress := strings.TrimSpace(c.GetString("bankAddress"))
|
||||
phone := strings.TrimSpace(c.GetString("phone"))
|
||||
payForAmount := strings.TrimSpace(c.GetString("payForAmount"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
|
||||
if bankUid == "" {
|
||||
keyDataJSON.Msg = "银行卡uid不能为空,请联系技术人员"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
money, err := strconv.ParseFloat(payForAmount, 64)
|
||||
if err != nil {
|
||||
logs.Error("self payfor money fail: ", err)
|
||||
keyDataJSON.Msg = "输入金额有误,请仔细检查"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
bankInfo := models.GetBankCardByUid(bankUid)
|
||||
|
||||
//需要对前端传入的数据做校验,不能完全相信前端的数据
|
||||
if bankInfo.AccountName != accountName || bankInfo.BankNo != bankNo || bankInfo.PhoneNo != phone {
|
||||
keyDataJSON.Msg = "前端页面数据有篡改,请注意资金安全"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
selfPayFor := models.PayforInfo{PayforUid: "pppp" + xid.New().String(), BankOrderId: "4444" + xid.New().String(), PayforFee: common.ZERO, Type: common.SELF_HELP,
|
||||
PayforAmount: money, PayforTotalAmount: money + common.ZERO, BankCode: bankInfo.BankCode, BankName: bankName, IsSend: common.NO,
|
||||
BankAccountName: bankInfo.AccountName, BankAccountNo: bankInfo.BankNo, BankAccountType: bankInfo.BankAccountType, BankAccountAddress: bankAddress,
|
||||
Status: common.PAYFOR_COMFRIM, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertPayfor(selfPayFor) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Msg = "数据处理失败,请重新提交"
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
27
boss/controllers/baseController.go
Normal file
27
boss/controllers/baseController.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package controllers
|
||||
|
||||
import beego "github.com/beego/beego/v2/server/web"
|
||||
|
||||
type BaseController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *BaseController) GenerateJSON(dataJSON interface{}) {
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *BaseController) Prepare() {
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
if !ok || userID == "" {
|
||||
//用户没有登录,或者登录到期了,则跳转登录主页面
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = 404
|
||||
dataJSON.Msg = "登录已经过期!"
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
//重新赋值给session
|
||||
c.SetSession("userID", userID)
|
||||
}
|
||||
}
|
||||
224
boss/controllers/datas.go
Normal file
224
boss/controllers/datas.go
Normal file
@@ -0,0 +1,224 @@
|
||||
package controllers
|
||||
|
||||
import "boss/models"
|
||||
|
||||
type BaseDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
}
|
||||
|
||||
type KeyDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
Key string
|
||||
}
|
||||
|
||||
type MenuDataJSON struct {
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
MenuList []models.MenuInfo
|
||||
}
|
||||
|
||||
type SecondMenuDataJSON struct {
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
SecondMenuList []models.SecondMenuInfo
|
||||
}
|
||||
|
||||
type PowerItemDataJSON struct {
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
PowerItemList []models.PowerInfo
|
||||
}
|
||||
|
||||
type RoleInfoDataJSON struct {
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
RoleInfoList []models.RoleInfo
|
||||
}
|
||||
|
||||
type DeployTreeJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
Key string
|
||||
AllFirstMenu []models.MenuInfo
|
||||
ShowFirstMenuUid map[string]bool
|
||||
AllSecondMenu []models.SecondMenuInfo
|
||||
ShowSecondMenuUid map[string]bool
|
||||
AllPower []models.PowerInfo
|
||||
ShowPowerUid map[string]bool
|
||||
}
|
||||
|
||||
type OperatorDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
OperatorList []models.UserInfo
|
||||
}
|
||||
|
||||
type EditOperatorDataJSON struct {
|
||||
Code int
|
||||
Msg string
|
||||
OperatorList []models.UserInfo
|
||||
RoleList []models.RoleInfo
|
||||
}
|
||||
|
||||
type BankCardDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
BankCardInfoList []models.BankCardInfo
|
||||
}
|
||||
|
||||
type RoadDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
RoadInfoList []models.RoadInfo
|
||||
RoadPool models.RoadPoolInfo
|
||||
}
|
||||
|
||||
type RoadPoolDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
RoadPoolInfoList []models.RoadPoolInfo
|
||||
}
|
||||
|
||||
type MerchantDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
MerchantList []models.MerchantInfo
|
||||
}
|
||||
|
||||
type MerchantDeployDataJSON struct {
|
||||
Code int
|
||||
Msg string
|
||||
MerchantDeploy models.MerchantDeployInfo
|
||||
}
|
||||
|
||||
type AccountDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AccountList []models.AccountInfo
|
||||
}
|
||||
|
||||
type AccountHistoryDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AccountHistoryList []models.AccountHistoryInfo
|
||||
}
|
||||
|
||||
type AgentDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AgentList []models.AgentInfo
|
||||
}
|
||||
|
||||
type ProductDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
ProductMap map[string]string
|
||||
}
|
||||
|
||||
type OrderDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
OrderList []models.OrderInfo
|
||||
AllAmount float64
|
||||
SuccessRate string
|
||||
NotifyUrl string
|
||||
}
|
||||
|
||||
type ListDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
List []models.OrderProfitInfo
|
||||
AllAmount float64
|
||||
SupplierProfit float64
|
||||
AgentProfit float64
|
||||
PlatformProfit float64
|
||||
}
|
||||
|
||||
type PayForDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
PayForList []models.PayforInfo
|
||||
}
|
||||
|
||||
type BalanceDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
Balance float64
|
||||
}
|
||||
|
||||
type NotifyBankOrderIdListJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
NotifyIdList []string
|
||||
}
|
||||
|
||||
type ProfitListJSON struct {
|
||||
TotalAmount float64
|
||||
PlatformTotalProfit float64
|
||||
AgentTotalProfit float64
|
||||
Msg string
|
||||
Code int
|
||||
ProfitList []models.PlatformProfit
|
||||
}
|
||||
340
boss/controllers/deleteController.go
Normal file
340
boss/controllers/deleteController.go
Normal file
@@ -0,0 +1,340 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/8/21 16:51
|
||||
** @Author : yuebin
|
||||
** @File : delete
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/21 16:51
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"boss/models"
|
||||
"boss/utils"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Deletecontroller struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) Finish() {
|
||||
remainderFirstMenuUid := make([]string, 0)
|
||||
remainderFirstMenu := make([]string, 0)
|
||||
remainderSecondMenuUid := make([]string, 0)
|
||||
remainderSecondMenu := make([]string, 0)
|
||||
remainderPowerId := make([]string, 0)
|
||||
remainderPower := make([]string, 0)
|
||||
allRoleInfo := models.GetRole()
|
||||
//如果有删除任何的东西,需要重新赋值权限
|
||||
for _, r := range allRoleInfo {
|
||||
for _, showFirstUid := range strings.Split(r.ShowFirstUid, "||") {
|
||||
if models.FirstMenuUidIsExists(showFirstUid) {
|
||||
remainderFirstMenuUid = append(remainderFirstMenuUid, showFirstUid)
|
||||
menuInfo := models.GetMenuInfoByMenuUid(showFirstUid)
|
||||
remainderFirstMenu = append(remainderFirstMenu, menuInfo.FirstMenu)
|
||||
}
|
||||
}
|
||||
for _, showSecondUid := range strings.Split(r.ShowSecondUid, "||") {
|
||||
if models.SecondMenuUidIsExists(showSecondUid) {
|
||||
remainderSecondMenuUid = append(remainderSecondMenuUid, showSecondUid)
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(showSecondUid)
|
||||
remainderSecondMenu = append(remainderSecondMenu, secondMenuInfo.SecondMenu)
|
||||
}
|
||||
}
|
||||
for _, showPowerId := range strings.Split(r.ShowPowerUid, "||") {
|
||||
if models.PowerUidExists(showPowerId) {
|
||||
remainderPowerId = append(remainderPowerId, showPowerId)
|
||||
powerInfo := models.GetPowerById(showPowerId)
|
||||
remainderPower = append(remainderPower, powerInfo.PowerItem)
|
||||
}
|
||||
}
|
||||
r.ShowFirstUid = strings.Join(remainderFirstMenuUid, "||")
|
||||
r.ShowFirstMenu = strings.Join(remainderFirstMenu, "||")
|
||||
r.ShowSecondUid = strings.Join(remainderSecondMenuUid, "||")
|
||||
r.ShowSecondMenu = strings.Join(remainderSecondMenu, "||")
|
||||
r.ShowPowerUid = strings.Join(remainderPowerId, "||")
|
||||
r.ShowPower = strings.Join(remainderPower, "||")
|
||||
r.UpdateTime = utils.GetBasicDateTime()
|
||||
models.UpdateRoleInfo(r)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteMenu() {
|
||||
menuUid := c.GetString("menuUid")
|
||||
menuInfo := models.GetMenuInfoByMenuUid(menuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if menuInfo.MenuUid == "" {
|
||||
dataJSON.Msg = "不存在该菜单"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
logs.Info(c.GetSession("userID").(string) + ",执行了删除一级菜单操作")
|
||||
models.DeleteMenuInfo(menuUid)
|
||||
//删除该一级目下下的所有二级目录
|
||||
models.DeleteSecondMenuByFirstMenuUid(menuUid)
|
||||
SortFirstMenuOrder()
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSONP()
|
||||
}
|
||||
|
||||
/*
|
||||
* 对一级菜单重新进行排序
|
||||
*/
|
||||
func SortFirstMenuOrder() {
|
||||
menuInfoList := models.GetMenuAll()
|
||||
sort.Sort(models.MenuInfoSlice(menuInfoList))
|
||||
|
||||
for i := 0; i < len(menuInfoList); i++ {
|
||||
m := menuInfoList[i]
|
||||
m.UpdateTime = utils.GetBasicDateTime()
|
||||
m.MenuOrder = i + 1
|
||||
models.UpdateMenuInfo(m)
|
||||
//对应的二级菜单也应该重新分配顺序号
|
||||
SortSecondMenuOrder(m)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 对二级菜单分配顺序号
|
||||
*/
|
||||
func SortSecondMenuOrder(firstMenuInfo models.MenuInfo) {
|
||||
secondMenuInfoList := models.GetSecondMenuListByFirstMenuUid(firstMenuInfo.MenuUid)
|
||||
for _, sm := range secondMenuInfoList {
|
||||
sm.FirstMenuOrder = firstMenuInfo.MenuOrder
|
||||
sm.UpdateTime = utils.GetBasicDateTime()
|
||||
models.UpdateSecondMenu(sm)
|
||||
//删除下下一级的所有权限项
|
||||
models.DeletePowerBySecondUid(sm.SecondMenuUid)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteSecondMenu() {
|
||||
secondMenuUid := strings.TrimSpace(c.GetString("secondMenuUid"))
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if secondMenuUid == "" || secondMenuInfo.SecondMenuUid == "" {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "该二级菜单不存在"
|
||||
} else {
|
||||
if models.DeleteSecondMenuBySecondMenuUid(secondMenuUid) {
|
||||
dataJSON.Code = 200
|
||||
ml := models.GetSecondMenuLenByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||
//删除该二级页面下的所有权限项
|
||||
models.DeletePowerBySecondUid(secondMenuUid)
|
||||
if ml == 0 {
|
||||
//如果该二级类目已经被全部删除,那么对应的一级类目也应当删除
|
||||
models.DeleteMenuInfo(secondMenuInfo.FirstMenuUid)
|
||||
SortFirstMenuOrder()
|
||||
} else {
|
||||
secondMenuInfoList := models.GetSecondMenuListByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||
sort.Sort(models.SecondMenuSlice(secondMenuInfoList))
|
||||
for i := 0; i < len(secondMenuInfoList); i++ {
|
||||
m := secondMenuInfoList[i]
|
||||
models.UpdateSecondMenuOrderBySecondUid(m.SecondMenuUid, i+1)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "删除失败"
|
||||
}
|
||||
}
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除权限项
|
||||
*/
|
||||
func (c *Deletecontroller) DeletePowerItem() {
|
||||
powerID := strings.TrimSpace(c.GetString("powerID"))
|
||||
models.DeletePowerItemByPowerID(powerID)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = 200
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除角色
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteRole() {
|
||||
roleUid := strings.TrimSpace(c.GetString("roleUid"))
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.DeleteRoleByRoleUid(roleUid) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除操作员
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("userId"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.DeleteUserByUserId(userId) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
}
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteBankCardRecord() {
|
||||
uid := strings.TrimSpace(c.GetString("uid"))
|
||||
|
||||
dataJSON := new(BankCardDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
if models.DeleteBankCardByUid(uid) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除通道操作
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteRoad() {
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
if models.DeleteRoadByRoadUid(roadUid) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
params := make(map[string]string)
|
||||
roadPoolInfoList := models.GetAllRollPool(params)
|
||||
//将轮询池中的对应的通道删除
|
||||
for _, roadPoolInfo := range roadPoolInfoList {
|
||||
var uids []string
|
||||
roadInfoList := strings.Split(roadPoolInfo.RoadUidPool, "||")
|
||||
for _, uid := range roadInfoList {
|
||||
if uid != roadUid {
|
||||
uids = append(uids, uid)
|
||||
}
|
||||
}
|
||||
roadPoolInfo.RoadUidPool = strings.Join(uids, "||")
|
||||
roadPoolInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
models.UpdateRoadPool(roadPoolInfo)
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除通道池
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteRoadPool() {
|
||||
roadPoolCode := strings.TrimSpace(c.GetString("roadPoolCode"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
if models.DeleteRoadPoolByCode(roadPoolCode) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Msg = "删除通道池失败"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除商户
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteMerchant() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if merchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if models.DeleteMerchantByUid(merchantUid) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除账户
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteAccount() {
|
||||
accountUid := strings.TrimSpace(c.GetString("accountUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
models.IsExistByMerchantUid(accountUid)
|
||||
if models.IsExistByMerchantUid(accountUid) || models.IsExistByAgentUid(accountUid) {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "用户还存在,不能删除"
|
||||
} else {
|
||||
if models.DeleteAccountByUid(accountUid) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "删除账户成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "删除账户失败"
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteAgent() {
|
||||
agentUid := strings.TrimSpace(c.GetString("agentUid"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
//判断是否有商户还绑定了该代理
|
||||
if models.IsExistMerchantByAgentUid(agentUid) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "已有商户绑定改代理,不能删除"
|
||||
} else {
|
||||
if models.DeleteAgentByAgentUid(agentUid) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "删除失败"
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteAgentRelation() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if merchantInfo.MerchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "不存在这样的商户"
|
||||
} else {
|
||||
merchantInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
merchantInfo.BelongAgentUid = ""
|
||||
merchantInfo.BelongAgentName = ""
|
||||
|
||||
if !models.UpdateMerchant(merchantInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "更新商户失败"
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(merchantInfo)
|
||||
}
|
||||
56
boss/controllers/filterController.go
Normal file
56
boss/controllers/filterController.go
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************
|
||||
** @Desc : 过滤功能
|
||||
** @Time : 2019/8/8 16:10
|
||||
** @Author : yuebin
|
||||
** @File : filter
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/8 16:10
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FilterController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
var FilterLogin = func(ctx *context.Context) {
|
||||
userID, ok := ctx.Input.Session("userID").(string)
|
||||
if !ok || userID == "" {
|
||||
if !strings.Contains(ctx.Request.RequestURI, "/login.html") &&
|
||||
!strings.Contains(ctx.Request.RequestURI, "/getVerifyImg") &&
|
||||
!strings.Contains(ctx.Request.RequestURI, "/favicon.ico") &&
|
||||
!ctx.Input.IsAjax() {
|
||||
ctx.Redirect(302, "/login.html")
|
||||
}
|
||||
} else {
|
||||
if strings.Contains(ctx.Request.RequestURI, "/login.html") {
|
||||
ctx.Redirect(302, "/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//jsonp请求过来的函数
|
||||
func (c *FilterController) Filter() {
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
|
||||
dataJSON := new(struct {
|
||||
Code int
|
||||
})
|
||||
|
||||
if !ok || userID == "" {
|
||||
dataJSON.Code = 404
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
c.SetSession("userID", userID)
|
||||
}
|
||||
fmt.Println(dataJSON)
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
1006
boss/controllers/getController.go
Normal file
1006
boss/controllers/getController.go
Normal file
File diff suppressed because it is too large
Load Diff
106
boss/controllers/loginController.go
Normal file
106
boss/controllers/loginController.go
Normal file
@@ -0,0 +1,106 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
"boss/utils"
|
||||
"github.com/beego/beego/v2/adapter/validation"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type LoginController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *LoginController) Prepare() {
|
||||
|
||||
}
|
||||
|
||||
func (c *LoginController) Login() {
|
||||
|
||||
userID := c.GetString("userID")
|
||||
passWD := c.GetString("passwd")
|
||||
code := c.GetString("Code")
|
||||
|
||||
dataJSON := new(KeyDataJSON)
|
||||
|
||||
valid := validation.Validation{}
|
||||
|
||||
if v := valid.Required(userID, "userID"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "手机号不能为空!"
|
||||
} else if v := valid.Required(passWD, "passWD"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "登录密码不能为空!"
|
||||
} else if v := valid.Length(code, common.VERIFY_CODE_LEN, "code"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "验证码不正确!"
|
||||
}
|
||||
|
||||
userInfo := models.GetUserInfoByUserID(userID)
|
||||
|
||||
if userInfo.UserId == "" {
|
||||
dataJSON.Key = "userID"
|
||||
dataJSON.Msg = "用户不存在,请求联系管理员!"
|
||||
} else {
|
||||
codeInterface := c.GetSession("verifyCode")
|
||||
if userInfo.Passwd != utils.GetMD5Upper(passWD) {
|
||||
dataJSON.Key = "passWD"
|
||||
dataJSON.Msg = "密码不正确!"
|
||||
} else if codeInterface == nil {
|
||||
dataJSON.Key = "code"
|
||||
dataJSON.Msg = "验证码失效!"
|
||||
} else if code != codeInterface.(string) {
|
||||
dataJSON.Key = "code"
|
||||
dataJSON.Msg = "验证码不正确!"
|
||||
} else if userInfo.Status == "unactive" {
|
||||
dataJSON.Key = "unactive"
|
||||
dataJSON.Msg = "用户已被冻结!"
|
||||
} else if userInfo.Status == "del" {
|
||||
dataJSON.Key = "del"
|
||||
dataJSON.Msg = "用户已被删除!"
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
userInfo.Ip = c.Ctx.Input.IP()
|
||||
models.UpdateUserInfoIP(userInfo)
|
||||
}()
|
||||
|
||||
if dataJSON.Key == "" {
|
||||
c.SetSession("userID", userID)
|
||||
c.DelSession("verifyCode")
|
||||
}
|
||||
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 退出登录,删除session中的数据,避免数据量过大,内存吃紧
|
||||
*/
|
||||
|
||||
func (c *LoginController) Logout() {
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
c.DelSession("userID")
|
||||
dataJSON.Code = 200
|
||||
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 验证码获取,如果获取成功,并将验证码存到session中
|
||||
*/
|
||||
func (c *LoginController) GetVerifyImg() {
|
||||
Image, verifyCode := utils.GenerateVerifyCodeImg()
|
||||
if Image == nil || len(verifyCode) != common.VERIFY_CODE_LEN {
|
||||
logs.Error("获取验证码图片失败!")
|
||||
} else {
|
||||
c.SetSession("verifyCode", verifyCode)
|
||||
}
|
||||
logs.Info("验证码:", verifyCode)
|
||||
Image.WriteTo(c.Ctx.ResponseWriter)
|
||||
}
|
||||
136
boss/controllers/pageController.go
Normal file
136
boss/controllers/pageController.go
Normal file
@@ -0,0 +1,136 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/10/23 15:20
|
||||
** @Author : yuebin
|
||||
** @File : page_controller
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/23 15:20
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type PageController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *PageController) Index() {
|
||||
fmt.Println("dlfjldkjfldjfljljljlj")
|
||||
c.TplName = "index.html"
|
||||
}
|
||||
|
||||
func (c *PageController) LoginPage() {
|
||||
c.TplName = "login.html"
|
||||
}
|
||||
|
||||
func (c *PageController) AccountPage() {
|
||||
c.TplName = "account.html"
|
||||
}
|
||||
|
||||
func (c *PageController) AccountHistoryPage() {
|
||||
c.TplName = "account_history.html"
|
||||
}
|
||||
|
||||
func (c *PageController) BankCardPage() {
|
||||
c.TplName = "bank_card.html"
|
||||
}
|
||||
|
||||
func (c *PageController) CreateAgentPage() {
|
||||
c.TplName = "create_agent.html"
|
||||
}
|
||||
|
||||
func (c *PageController) EditRolePage() {
|
||||
c.TplName = "edit_role.html"
|
||||
}
|
||||
|
||||
func (c *PageController) FirstMenuPage() {
|
||||
c.TplName = "first_menu.html"
|
||||
}
|
||||
|
||||
func (c *PageController) MainPage() {
|
||||
c.TplName = "main.html"
|
||||
}
|
||||
|
||||
func (c *PageController) MenuPage() {
|
||||
c.TplName = "menu.html"
|
||||
}
|
||||
|
||||
func (c *PageController) MerchantPage() {
|
||||
c.TplName = "merchant.html"
|
||||
}
|
||||
|
||||
func (c *PageController) OperatorPage() {
|
||||
c.TplName = "operator.html"
|
||||
}
|
||||
|
||||
func (c *PageController) PowerPage() {
|
||||
c.TplName = "power.html"
|
||||
}
|
||||
|
||||
func (c *PageController) RoadPage() {
|
||||
c.TplName = "road.html"
|
||||
}
|
||||
|
||||
func (c *PageController) RoadPoolPage() {
|
||||
c.TplName = "road_pool.html"
|
||||
}
|
||||
|
||||
func (c *PageController) RoadProfitPage() {
|
||||
c.TplName = "road_profit.html"
|
||||
}
|
||||
|
||||
func (c *PageController) RolePage() {
|
||||
c.TplName = "role.html"
|
||||
}
|
||||
|
||||
func (c *PageController) SecondMenuPage() {
|
||||
c.TplName = "second_menu.html"
|
||||
}
|
||||
|
||||
func (c *PageController) OrderInfoPage() {
|
||||
c.TplName = "order_info.html"
|
||||
}
|
||||
|
||||
func (c *PageController) OrderProfitPage() {
|
||||
c.TplName = "order_profit.html"
|
||||
}
|
||||
|
||||
func (c *PageController) MerchantPayforPage() {
|
||||
c.TplName = "merchant_payfor.html"
|
||||
}
|
||||
|
||||
func (c *PageController) SelfPayforPage() {
|
||||
c.TplName = "self_payfor.html"
|
||||
}
|
||||
|
||||
func (c *PageController) PayforRecordPage() {
|
||||
c.TplName = "payfor_record.html"
|
||||
}
|
||||
|
||||
func (c *PageController) ConfirmPage() {
|
||||
c.TplName = "confirm.html"
|
||||
}
|
||||
|
||||
func (c *PageController) SelfNotifyPage() {
|
||||
c.TplName = "self_notify.html"
|
||||
}
|
||||
|
||||
func (c *PageController) SelfPlusSubPage() {
|
||||
c.TplName = "self_plus_sub.html"
|
||||
}
|
||||
|
||||
func (c *PageController) AgentToMerchantPage() {
|
||||
c.TplName = "agent_to_merchant.html"
|
||||
}
|
||||
|
||||
func (c *PageController) PlatFormProfitPage() {
|
||||
c.TplName = "platform_profit.html"
|
||||
}
|
||||
|
||||
func (c *PageController) AgentProfitPage() {
|
||||
c.TplName = "agent_profit.html"
|
||||
}
|
||||
102
boss/controllers/queryController.go
Normal file
102
boss/controllers/queryController.go
Normal file
@@ -0,0 +1,102 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/6 14:03
|
||||
** @Author : yuebin
|
||||
** @File : query.go
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/6 14:03
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
controller "boss/supplier"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SupplierQuery struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func OrderQuery(bankOrderId string) string {
|
||||
|
||||
orderInfo := models.GetOrderByBankOrderId(bankOrderId)
|
||||
|
||||
if orderInfo.BankOrderId == "" || len(orderInfo.BankOrderId) == 0 {
|
||||
logs.Error("不存在这样的订单,订单查询结束")
|
||||
return "不存在这样的订单"
|
||||
}
|
||||
|
||||
if orderInfo.Status != "" && orderInfo.Status != "wait" {
|
||||
logs.Error(fmt.Sprintf("该订单=%s,已经处理完毕,", bankOrderId))
|
||||
return "该订单已经处理完毕"
|
||||
}
|
||||
|
||||
supplierCode := orderInfo.PayProductCode
|
||||
supplier := controller.GetPaySupplierByCode(supplierCode)
|
||||
|
||||
flag := supplier.PayQuery(orderInfo)
|
||||
if flag {
|
||||
return "查询完毕,返回正确结果"
|
||||
} else {
|
||||
return "订单还在处理中"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (c *SupplierQuery) SupplierOrderQuery() {
|
||||
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
exist := models.BankOrderIdIsEixst(bankOrderId)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if !exist {
|
||||
keyDataJSON.Msg = "该订单不存在"
|
||||
}
|
||||
|
||||
msg := OrderQuery(bankOrderId)
|
||||
|
||||
keyDataJSON.Msg = msg
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 向上游查询代付结果
|
||||
*/
|
||||
func (c *SupplierQuery) SupplierPayForQuery() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if bankOrderId == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "不存在这样的代付订单"
|
||||
} else {
|
||||
payFor := models.GetPayForByBankOrderId(bankOrderId)
|
||||
if payFor.RoadUid == "" {
|
||||
keyDataJSON.Msg = "该代付订单没有对应的通道uid"
|
||||
} else {
|
||||
roadInfo := models.GetRoadInfoByRoadUid(payFor.RoadUid)
|
||||
supplier := controller.GetPaySupplierByCode(roadInfo.ProductUid)
|
||||
result, msg := supplier.PayForQuery(payFor)
|
||||
keyDataJSON.Msg = msg
|
||||
if result == common.PAYFOR_SUCCESS {
|
||||
controller.PayForSuccess(payFor)
|
||||
} else if result == common.PAYFOR_FAIL {
|
||||
controller.PayForFail(payFor)
|
||||
} else {
|
||||
logs.Info("银行处理中")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
75
boss/controllers/sendNotifyMerchant.go
Normal file
75
boss/controllers/sendNotifyMerchant.go
Normal file
@@ -0,0 +1,75 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/12/8 22:15
|
||||
** @Author : yuebin
|
||||
** @File : send_notify_merchant
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/12/8 22:15
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/httplib"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SendNotify struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *SendNotify) SendNotifyToMerchant() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
orderInfo := models.GetOrderByBankOrderId(bankOrderId)
|
||||
if orderInfo.Status == common.WAIT {
|
||||
keyDataJSON.Msg = "该订单不是成功状态,不能回调"
|
||||
} else {
|
||||
notifyInfo := models.GetNotifyInfoByBankOrderId(bankOrderId)
|
||||
notifyUrl := notifyInfo.Url
|
||||
logs.Info(fmt.Sprintf("boss管理后台手动触发订单回调,url=%s", notifyUrl))
|
||||
req := httplib.Post(notifyUrl)
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
logs.Error("回调发送失败,fail:", err)
|
||||
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送失败,订单回调,fail:%s", err)
|
||||
} else {
|
||||
if !strings.Contains(strings.ToLower(response), "success") {
|
||||
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送成功,但是未返回success字段, 商户返回内容=%s", response)
|
||||
} else {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送成功")
|
||||
}
|
||||
}
|
||||
}
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *SendNotify) SelfSendNotify() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
notifyInfo := models.GetNotifyInfoByBankOrderId(bankOrderId)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
req := httplib.Post(notifyInfo.Url)
|
||||
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
keyDataJSON.Msg = fmt.Sprintf("订单 bankOrderId=%s,已经发送回调出错:%s", bankOrderId, err)
|
||||
} else {
|
||||
keyDataJSON.Msg = fmt.Sprintf("订单 bankOrderId=%s,已经发送回调,商户返回内容:%s", bankOrderId, response)
|
||||
}
|
||||
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
592
boss/controllers/updateController.go
Normal file
592
boss/controllers/updateController.go
Normal file
@@ -0,0 +1,592 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/8/16 9:49
|
||||
** @Author : yuebin
|
||||
** @File : update
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/16 9:49
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
controller "boss/supplier"
|
||||
"boss/utils"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/adapter/validation"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type UpdateController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
/*
|
||||
*更新密码
|
||||
*/
|
||||
func (c *UpdateController) UpdatePassword() {
|
||||
oldPassword := c.GetString("oldPassword")
|
||||
newPassword := c.GetString("newPassword")
|
||||
twicePassword := c.GetString("twicePassword")
|
||||
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
|
||||
dataJSON := new(KeyDataJSON)
|
||||
dataJSON.Code = -1
|
||||
if !ok || userID == "" {
|
||||
dataJSON.Code = 404
|
||||
dataJSON.Msg = "请重新登录!"
|
||||
} else {
|
||||
userInfo := models.GetUserInfoByUserID(userID)
|
||||
valid := validation.Validation{}
|
||||
if userInfo.Passwd != utils.GetMD5Upper(oldPassword) {
|
||||
dataJSON.Key = ".old-error"
|
||||
dataJSON.Msg = "输入密码不正确"
|
||||
} else if v := valid.Min(len(newPassword), 8, ".new-error"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "新密码长度必须大于等于8个字符!"
|
||||
} else if v := valid.Max(len(newPassword), 16, ".new-error"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "新密码长度不能大于16个字符!"
|
||||
} else if v := valid.AlphaNumeric(newPassword, ".new-error"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "新密码必须有数字和字母组成!"
|
||||
} else if newPassword != twicePassword {
|
||||
dataJSON.Key = ".twice-error"
|
||||
dataJSON.Msg = "两次密码不一致!"
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "密码修改成功!"
|
||||
//删除原先的session状态
|
||||
c.DelSession("userID")
|
||||
//更新数据库的密码
|
||||
userInfo.Passwd = utils.GetMD5Upper(newPassword)
|
||||
models.UpdateUserInfoPassword(userInfo)
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新菜单的排列顺序
|
||||
*/
|
||||
func (c *UpdateController) UpMenu() {
|
||||
menuUid := c.GetString("menuUid")
|
||||
menuInfo := models.GetMenuInfoByMenuUid(menuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if menuInfo.MenuUid == "" {
|
||||
dataJSON.Msg = "更改排列顺序失败"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
exist := models.MenuOrderIsExists(menuInfo.MenuOrder - 1)
|
||||
if !exist {
|
||||
dataJSON.Msg = "已经是最高的顺序"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
//如果他前面有菜单,那么交换他们的menuOrder
|
||||
preMenuInfo := models.GetMenuInfoByMenuOrder(menuInfo.MenuOrder - 1)
|
||||
menuInfo.MenuOrder = menuInfo.MenuOrder - 1
|
||||
preMenuInfo.MenuOrder = preMenuInfo.MenuOrder + 1
|
||||
preMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
menuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
//更新菜单表
|
||||
models.UpdateMenuInfo(preMenuInfo)
|
||||
models.UpdateMenuInfo(menuInfo)
|
||||
//更新二级菜单表
|
||||
SortSecondMenuOrder(preMenuInfo)
|
||||
SortSecondMenuOrder(menuInfo)
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
func (c *UpdateController) DownMenu() {
|
||||
menuUid := c.GetString("menuUid")
|
||||
menuInfo := models.GetMenuInfoByMenuUid(menuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if menuInfo.MenuUid == "" {
|
||||
dataJSON.Msg = "更改排列顺序失败"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
exist := models.MenuOrderIsExists(menuInfo.MenuOrder + 1)
|
||||
if !exist {
|
||||
dataJSON.Msg = "已经是最高的顺序"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
//如果他前面有菜单,那么交换他们的menuOrder
|
||||
lastMenuInfo := models.GetMenuInfoByMenuOrder(menuInfo.MenuOrder + 1)
|
||||
menuInfo.MenuOrder = menuInfo.MenuOrder + 1
|
||||
lastMenuInfo.MenuOrder = lastMenuInfo.MenuOrder - 1
|
||||
lastMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
menuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
//更新菜单表
|
||||
models.UpdateMenuInfo(lastMenuInfo)
|
||||
models.UpdateMenuInfo(menuInfo)
|
||||
//更新二级菜单表
|
||||
SortSecondMenuOrder(lastMenuInfo)
|
||||
SortSecondMenuOrder(menuInfo)
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 提升二级菜单的顺序号
|
||||
*/
|
||||
func (c *UpdateController) UpSecondMenu() {
|
||||
secondMenuUid := c.GetString("secondMenuUid")
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if secondMenuInfo.MenuOrder == 1 {
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
preSecondMenuInfo := models.GetSecondMenuInfoByMenuOrder(secondMenuInfo.MenuOrder-1, secondMenuInfo.FirstMenuUid)
|
||||
preSecondMenuInfo.MenuOrder = preSecondMenuInfo.MenuOrder + 1
|
||||
preSecondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
secondMenuInfo.MenuOrder = secondMenuInfo.MenuOrder - 1
|
||||
secondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
//更新二级菜单项
|
||||
models.UpdateSecondMenu(preSecondMenuInfo)
|
||||
models.UpdateSecondMenu(secondMenuInfo)
|
||||
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 降低二级菜单的顺序号
|
||||
*/
|
||||
func (c *UpdateController) DownSecondMenu() {
|
||||
secondMenuUid := c.GetString("secondMenuUid")
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
l := models.GetSecondMenuLenByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||
if l == secondMenuInfo.MenuOrder {
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
lastSecondMenu := models.GetSecondMenuInfoByMenuOrder(secondMenuInfo.MenuOrder+1, secondMenuInfo.FirstMenuUid)
|
||||
lastSecondMenu.MenuOrder = lastSecondMenu.MenuOrder - 1
|
||||
lastSecondMenu.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
secondMenuInfo.MenuOrder = secondMenuInfo.MenuOrder + 1
|
||||
secondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
models.UpdateSecondMenu(lastSecondMenu)
|
||||
models.UpdateSecondMenu(secondMenuInfo)
|
||||
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) FreezeOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("operatorName"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.UpdateStauts("unactive", userId) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "冻结成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "冻结失败"
|
||||
}
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) UnfreezeOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("operatorName"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.UpdateStauts("active", userId) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "解冻成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "解冻失败"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) EditOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("userId"))
|
||||
password := strings.TrimSpace(c.GetString("password"))
|
||||
changePassword := strings.TrimSpace(c.GetString("changePassword"))
|
||||
role := strings.TrimSpace(c.GetString("role"))
|
||||
nick := strings.TrimSpace(c.GetString("nick"))
|
||||
remark := strings.TrimSpace(c.GetString("remark"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
|
||||
if (len(password) > 0 || len(changePassword) > 0) && password != changePassword {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".veritfy-operator-password-error"
|
||||
keyDataJSON.Msg = "*2次密码输入不一致"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
if role == "" || role == "none" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".change-operator-role-error"
|
||||
keyDataJSON.Msg = "*角色不能为空"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
userInfo := models.GetUserInfoByUserID(userId)
|
||||
if userInfo.UserId == "" {
|
||||
keyDataJSON.Code = -2
|
||||
keyDataJSON.Msg = "该用户不存在"
|
||||
} else {
|
||||
userInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
userInfo.Remark = remark
|
||||
roleInfo := models.GetRoleByRoleUid(role)
|
||||
userInfo.RoleName = roleInfo.RoleName
|
||||
userInfo.Role = role
|
||||
if len(password) > 0 && len(changePassword) > 0 && password == changePassword {
|
||||
userInfo.Passwd = utils.GetMD5Upper(password)
|
||||
}
|
||||
userInfo.Nick = nick
|
||||
models.UpdateUserInfo(userInfo)
|
||||
keyDataJSON.Code = 200
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新通道的状态
|
||||
*/
|
||||
func (c *UpdateController) UpdateRoadStatus() {
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = 200
|
||||
|
||||
roadInfo := models.GetRoadInfoByRoadUid(roadUid)
|
||||
if roadInfo.Status == "active" {
|
||||
roadInfo.Status = "unactive"
|
||||
} else {
|
||||
roadInfo.Status = "active"
|
||||
}
|
||||
if models.UpdateRoadInfo(roadInfo) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 冻结商户
|
||||
*/
|
||||
func (c *UpdateController) UpdateMerchantStatus() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if merchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
|
||||
if merchantInfo.MerchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if merchantInfo.Status == "active" {
|
||||
merchantInfo.Status = "unactive"
|
||||
} else {
|
||||
merchantInfo.Status = "active"
|
||||
}
|
||||
merchantInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
if models.UpdateMerchant(merchantInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新账户的状态
|
||||
*/
|
||||
func (c *UpdateController) UpdateAccountStatus() {
|
||||
accountUid := strings.TrimSpace(c.GetString("accountUid"))
|
||||
|
||||
accountInfo := models.GetAccountByUid(accountUid)
|
||||
if accountInfo.Status == "active" {
|
||||
accountInfo.Status = "unactive"
|
||||
} else {
|
||||
accountInfo.Status = "active"
|
||||
}
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if models.UpdateAccount(accountInfo) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "更新账户状态成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "更新账户状态失败"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
func (c *UpdateController) OperatorAccount() {
|
||||
accountUid := strings.TrimSpace(c.GetString("accountUid"))
|
||||
accountOperator := strings.TrimSpace(c.GetString("accountOperator"))
|
||||
amount := strings.TrimSpace(c.GetString("amount"))
|
||||
|
||||
accountDataJSON := new(AccountDataJSON)
|
||||
switch accountOperator {
|
||||
case common.PLUS_AMOUNT:
|
||||
case common.SUB_AMOUNT:
|
||||
case common.FREEZE_AMOUNT:
|
||||
case common.UNFREEZE_AMOUNT:
|
||||
default:
|
||||
accountDataJSON.Code = -1
|
||||
}
|
||||
a, err := strconv.ParseFloat(amount, 64)
|
||||
if err != nil {
|
||||
accountDataJSON.Msg = "处理金额输入有误"
|
||||
}
|
||||
if accountDataJSON.Code == -1 {
|
||||
c.GenerateJSON(accountDataJSON)
|
||||
return
|
||||
}
|
||||
msg, flag := models.OperatorAccount(accountUid, accountOperator, a)
|
||||
if flag {
|
||||
accountDataJSON.Code = 200
|
||||
accountDataJSON.Msg = "处理成功,请检查对应账户信息"
|
||||
accountDataJSON.AccountList = append(accountDataJSON.AccountList, models.GetAccountByUid(accountUid))
|
||||
} else {
|
||||
accountDataJSON.Code = -1
|
||||
accountDataJSON.Msg = msg
|
||||
}
|
||||
|
||||
c.GenerateJSON(accountDataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) UpdateAgentStatus() {
|
||||
agentUid := strings.TrimSpace(c.GetString("agentUid"))
|
||||
agentInfo := models.GetAgentInfoByAgentUid(agentUid)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
|
||||
if agentInfo.AgentUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
if agentInfo.Status == "active" {
|
||||
agentInfo.Status = "unactive"
|
||||
} else {
|
||||
agentInfo.Status = "active"
|
||||
}
|
||||
agentInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if models.UpdateAgentInfo(agentInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) ResetAgentPassword() {
|
||||
agentUid := strings.TrimSpace(c.GetString("agentUid"))
|
||||
newPassword := strings.TrimSpace(c.GetString("newPassword"))
|
||||
newVertifyPassword := strings.TrimSpace(c.GetString("newVertifyPassword"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
if agentUid == "" {
|
||||
keyDataJSON.Code = -2
|
||||
} else if newPassword == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-login-password-error-reset"
|
||||
keyDataJSON.Msg = " *新密码不能为空"
|
||||
} else if newVertifyPassword != newPassword {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-vertify-password-error-reset"
|
||||
keyDataJSON.Msg = " *两次密码输入不一致"
|
||||
}
|
||||
|
||||
if keyDataJSON.Code != 200 {
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
agentInfo := models.GetAgentInfoByAgentUid(agentUid)
|
||||
agentInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
agentInfo.AgentPassword = utils.GetMD5Upper(newPassword)
|
||||
if !models.UpdateAgentInfo(agentInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 手动选择了打款通道
|
||||
*/
|
||||
func (c *UpdateController) ChoosePayForRoad() {
|
||||
roadName := strings.TrimSpace(c.GetString("roadName"))
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
remark := strings.TrimSpace(c.GetString("remark"))
|
||||
confirmType := strings.TrimSpace(c.GetString("confirmType"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if confirmType == common.PAYFOR_ROAD && roadName == "" {
|
||||
keyDataJSON.Msg = "打款通道不能为空"
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
payForInfo := models.GetPayForByBankOrderId(bankOrderId)
|
||||
roadInfo := models.GetRoadInfoByName(roadName)
|
||||
|
||||
if payForInfo.Status != common.PAYFOR_COMFRIM {
|
||||
keyDataJSON.Msg = "结算状态错误,请刷新后确认"
|
||||
} else {
|
||||
payForInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
payForInfo.GiveType = confirmType
|
||||
if confirmType == common.PAYFOR_REFUSE {
|
||||
//拒绝打款
|
||||
payForInfo.Status = common.PAYFOR_FAIL
|
||||
} else {
|
||||
payForInfo.Status = common.PAYFOR_SOLVING
|
||||
}
|
||||
payForInfo.RoadUid = roadInfo.RoadUid
|
||||
payForInfo.RoadName = roadInfo.RoadName
|
||||
payForInfo.Remark = remark
|
||||
|
||||
if !models.ForUpdatePayFor(payForInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "更新代付记录失败"
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 处理打款结果的处理
|
||||
*/
|
||||
func (c *UpdateController) ResultPayFor() {
|
||||
resultType := strings.TrimSpace(c.GetString("resultType"))
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if resultType == "" || bankOrderId == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "提交的数据有误"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
payFor := models.GetPayForByBankOrderId(bankOrderId)
|
||||
|
||||
if payFor.Type == common.SELF_HELP {
|
||||
//如果是管理员在后台提现,不用做任何的商户减款,只需要更新代付订单状态
|
||||
payFor.UpdateTime = utils.GetBasicDateTime()
|
||||
payFor.Status = resultType
|
||||
|
||||
if !models.ForUpdatePayFor(payFor) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "系统处理失败"
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if payFor.Status == common.PAYFOR_FAIL || payFor.Status == common.PAYFOR_SUCCESS {
|
||||
logs.Error(fmt.Sprintf("该代付订单=%s,状态有误....", bankOrderId))
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "订单状态有误,请刷新重新判断"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if resultType == common.PAYFOR_FAIL {
|
||||
//处理代付失败的逻辑,减去相应的代付冻结金额
|
||||
if !controller.PayForFail(payFor) {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,处理代付失败逻辑出错", payFor.MerchantUid))
|
||||
keyDataJSON.Msg = "代付失败逻辑,处理失败"
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
} else if resultType == common.PAYFOR_SUCCESS {
|
||||
//代付成功,减去相应的代付冻结金额,并且余额减掉,可用金额减掉
|
||||
if !controller.PayForSuccess(payFor) {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,处理代付成功逻辑出错", payFor.MerchantUid))
|
||||
keyDataJSON.Msg = "代付成功逻辑,处理失败"
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
}
|
||||
|
||||
if keyDataJSON.Code == 200 {
|
||||
keyDataJSON.Msg = "处理成功"
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) UpdateOrderStatus() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
solveType := strings.TrimSpace(c.GetString("solveType"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
orderInfo := models.GetOrderByBankOrderId(bankOrderId)
|
||||
if orderInfo.BankOrderId == "" {
|
||||
logs.Error("该订单不存在,bankOrderId=", bankOrderId)
|
||||
keyDataJSON.Code = -1
|
||||
} else {
|
||||
paySolve := new(controller.PaySolveController)
|
||||
flag := false
|
||||
switch solveType {
|
||||
case common.SUCCESS:
|
||||
flag = paySolve.SolvePaySuccess(bankOrderId, orderInfo.FactAmount, common.SUCCESS)
|
||||
case common.FAIL:
|
||||
flag = paySolve.SolvePayFail(orderInfo, common.FAIL)
|
||||
case common.FREEZE_AMOUNT:
|
||||
//将这笔订单进行冻结
|
||||
flag = paySolve.SolveOrderFreeze(bankOrderId)
|
||||
case common.UNFREEZE_AMOUNT:
|
||||
//将这笔订单金额解冻
|
||||
flag = paySolve.SolveOrderUnfreeze(bankOrderId)
|
||||
case common.REFUND:
|
||||
if orderInfo.Status == common.SUCCESS {
|
||||
flag = paySolve.SolveRefund(bankOrderId)
|
||||
}
|
||||
case common.ORDERROLL:
|
||||
if orderInfo.Status == common.SUCCESS {
|
||||
flag = paySolve.SolveOrderRoll(bankOrderId)
|
||||
}
|
||||
default:
|
||||
logs.Error("不存在这样的处理类型")
|
||||
}
|
||||
if flag {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
12
boss/go.mod
Normal file
12
boss/go.mod
Normal file
@@ -0,0 +1,12 @@
|
||||
module boss
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/astaxie/beego v1.12.3
|
||||
github.com/beego/beego/v2 v2.0.1
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/go-stomp/stomp v2.1.4+incompatible
|
||||
github.com/rs/xid v1.2.1
|
||||
github.com/smartystreets/goconvey v1.6.4
|
||||
)
|
||||
273
boss/go.sum
Normal file
273
boss/go.sum
Normal file
@@ -0,0 +1,273 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
||||
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
|
||||
github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
|
||||
github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
|
||||
github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE=
|
||||
github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI=
|
||||
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
|
||||
github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||
github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
|
||||
github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
|
||||
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
|
||||
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
|
||||
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-stomp/stomp v2.1.4+incompatible h1:D3SheUVDOz9RsjVWkoh/1iCOwD0qWjyeTZMUZ0EXg2Y=
|
||||
github.com/go-stomp/stomp v2.1.4+incompatible/go.mod h1:VqCtqNZv1226A1/79yh+rMiFUcfY3R109np+7ke4n0c=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
|
||||
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
|
||||
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rs/xid v1.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
|
||||
github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
|
||||
github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
|
||||
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
|
||||
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
|
||||
go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58 h1:1Bs6RVeBFtLZ8Yi1Hk07DiOqzvwLD/4hln4iahvFlag=
|
||||
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
224
boss/gojson/gojson.go
Normal file
224
boss/gojson/gojson.go
Normal file
@@ -0,0 +1,224 @@
|
||||
package gojson
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Js struct {
|
||||
data interface{}
|
||||
}
|
||||
|
||||
//Initialize the json configruation
|
||||
func Json(data string) *Js {
|
||||
j := new(Js)
|
||||
var f interface{}
|
||||
err := json.Unmarshal([]byte(data), &f)
|
||||
if err != nil {
|
||||
return j
|
||||
}
|
||||
j.data = f
|
||||
return j
|
||||
}
|
||||
|
||||
//According to the key of the returned data information,return js.data
|
||||
func (j *Js) Get(key string) *Js {
|
||||
m := j.Getdata()
|
||||
if v, ok := m[key]; ok {
|
||||
j.data = v
|
||||
return j
|
||||
}
|
||||
j.data = nil
|
||||
return j
|
||||
}
|
||||
|
||||
//判断是否有郊
|
||||
func (j *Js) IsValid() bool {
|
||||
if nil == j.data {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
//return json data
|
||||
func (j *Js) Getdata() map[string]interface{} {
|
||||
if m, ok := (j.data).(map[string]interface{}); ok {
|
||||
return m
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (j *Js) Getindex(i int) *Js {
|
||||
|
||||
num := i - 1
|
||||
if m, ok := (j.data).([]interface{}); ok {
|
||||
//防止越界
|
||||
if num < len((j.data).([]interface{})) {
|
||||
v := m[num]
|
||||
j.data = v
|
||||
} else {
|
||||
j.data = nil
|
||||
}
|
||||
return j
|
||||
}
|
||||
|
||||
if m, ok := (j.data).(map[string]interface{}); ok {
|
||||
var n = 0
|
||||
var data = make(map[string]interface{})
|
||||
for i, v := range m {
|
||||
if n == num {
|
||||
switch vv := v.(type) {
|
||||
case float64:
|
||||
data[i] = strconv.FormatFloat(vv, 'f', -1, 64)
|
||||
j.data = data
|
||||
return j
|
||||
case string:
|
||||
data[i] = vv
|
||||
j.data = data
|
||||
return j
|
||||
case []interface{}:
|
||||
j.data = vv
|
||||
return j
|
||||
}
|
||||
|
||||
}
|
||||
n++
|
||||
}
|
||||
|
||||
}
|
||||
j.data = nil
|
||||
return j
|
||||
}
|
||||
|
||||
// When the data {"result":["username","password"]} can use arrayindex(1) get the username
|
||||
func (j *Js) Arrayindex(i int) string {
|
||||
num := i - 1
|
||||
if i > len((j.data).([]interface{})) {
|
||||
data := errors.New("index out of range list").Error()
|
||||
return data
|
||||
}
|
||||
if m, ok := (j.data).([]interface{}); ok {
|
||||
v := m[num]
|
||||
switch vv := v.(type) {
|
||||
case float64:
|
||||
return strconv.FormatFloat(vv, 'f', -1, 64)
|
||||
case string:
|
||||
return vv
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if _, ok := (j.data).(map[string]interface{}); ok {
|
||||
return "error"
|
||||
}
|
||||
return "error"
|
||||
|
||||
}
|
||||
|
||||
//The data must be []interface{} ,According to your custom number to return your key and array data
|
||||
func (j *Js) Getkey(key string, i int) *Js {
|
||||
num := i - 1
|
||||
if i > len((j.data).([]interface{})) {
|
||||
j.data = errors.New("index out of range list").Error()
|
||||
return j
|
||||
}
|
||||
if m, ok := (j.data).([]interface{}); ok {
|
||||
v := m[num].(map[string]interface{})
|
||||
if h, ok := v[key]; ok {
|
||||
j.data = h
|
||||
return j
|
||||
}
|
||||
|
||||
}
|
||||
j.data = nil
|
||||
return j
|
||||
}
|
||||
|
||||
//According to the custom of the PATH to find the PATH
|
||||
func (j *Js) Getpath(args ...string) *Js {
|
||||
d := j
|
||||
for i := range args {
|
||||
m := d.Getdata()
|
||||
|
||||
if val, ok := m[args[i]]; ok {
|
||||
d.data = val
|
||||
} else {
|
||||
d.data = nil
|
||||
return d
|
||||
}
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func (j *Js) Tostring() string {
|
||||
if m, ok := j.data.(string); ok {
|
||||
return m
|
||||
}
|
||||
if m, ok := j.data.(float64); ok {
|
||||
return strconv.FormatFloat(m, 'f', -1, 64)
|
||||
}
|
||||
if m, ok := j.data.(bool); ok {
|
||||
return strconv.FormatBool(m)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (j *Js) ToArray() (k, d []string) {
|
||||
var key, data []string
|
||||
if m, ok := (j.data).([]interface{}); ok {
|
||||
for _, value := range m {
|
||||
for index, v := range value.(map[string]interface{}) {
|
||||
switch vv := v.(type) {
|
||||
case float64:
|
||||
data = append(data, strconv.FormatFloat(vv, 'f', -1, 64))
|
||||
key = append(key, index)
|
||||
case string:
|
||||
data = append(data, vv)
|
||||
key = append(key, index)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return key, data
|
||||
}
|
||||
|
||||
if m, ok := (j.data).(map[string]interface{}); ok {
|
||||
for index, v := range m {
|
||||
switch vv := v.(type) {
|
||||
case float64:
|
||||
data = append(data, strconv.FormatFloat(vv, 'f', -1, 64))
|
||||
key = append(key, index)
|
||||
case string:
|
||||
data = append(data, vv)
|
||||
key = append(key, index)
|
||||
}
|
||||
}
|
||||
return key, data
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (j *Js) StringtoArray() []string {
|
||||
var data []string
|
||||
for _, v := range j.data.([]interface{}) {
|
||||
switch vv := v.(type) {
|
||||
case string:
|
||||
data = append(data, vv)
|
||||
case float64:
|
||||
data = append(data, strconv.FormatFloat(vv, 'f', -1, 64))
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (j *Js) Type() {
|
||||
fmt.Println(reflect.TypeOf(j.data))
|
||||
}
|
||||
37
boss/main.go
Normal file
37
boss/main.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "boss/models"
|
||||
_ "boss/routers"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
RegisterLogs()
|
||||
web.Run()
|
||||
}
|
||||
|
||||
/**
|
||||
** 注册日志信息
|
||||
*/
|
||||
func RegisterLogs() {
|
||||
logs.SetLogger(logs.AdapterFile,
|
||||
`{
|
||||
"filename":"../logs/legend.log",
|
||||
"level":4,
|
||||
"maxlines":0,
|
||||
"maxsize":0,
|
||||
"daily":true,
|
||||
"maxdays":10,
|
||||
"color":true
|
||||
}`)
|
||||
|
||||
f := &logs.PatternLogFormatter{
|
||||
Pattern: "%F:%n|%w%t>> %m",
|
||||
WhenFormat: "2006-01-02",
|
||||
}
|
||||
|
||||
logs.RegisterFormatter("pattern", f)
|
||||
_ = logs.SetGlobalFormatter("pattern")
|
||||
}
|
||||
45
boss/message_queue/active_mq.go
Normal file
45
boss/message_queue/active_mq.go
Normal file
@@ -0,0 +1,45 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/6 11:43
|
||||
** @Author : yuebin
|
||||
** @File : active_mq
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/6 11:43
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package message_queue
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/go-stomp/stomp"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
//解决第一个问题的代码
|
||||
var activeConn *stomp.Conn
|
||||
|
||||
var options = []func(*stomp.Conn) error{
|
||||
//设置读写超时,超时时间为1个小时
|
||||
stomp.ConnOpt.HeartBeat(7200*time.Second, 7200*time.Second),
|
||||
stomp.ConnOpt.HeartBeatError(360 * time.Second),
|
||||
}
|
||||
|
||||
func init() {
|
||||
address := common.GetMQAddress()
|
||||
|
||||
conn, err := stomp.Dial("tcp", address, options...)
|
||||
if err != nil {
|
||||
logs.Error("链接active mq 失败:", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
activeConn = conn
|
||||
}
|
||||
|
||||
func GetActiveMQConn() *stomp.Conn {
|
||||
return activeConn
|
||||
}
|
||||
|
||||
|
||||
33
boss/message_queue/send_message.go
Normal file
33
boss/message_queue/send_message.go
Normal file
@@ -0,0 +1,33 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/21 15:53
|
||||
** @Author : yuebin
|
||||
** @File : send_message
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/21 15:53
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package message_queue
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"os"
|
||||
)
|
||||
|
||||
func SendMessage(topic, message string) {
|
||||
|
||||
conn := GetActiveMQConn()
|
||||
|
||||
if conn == nil {
|
||||
logs.Error("send message get Active mq fail")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err := conn.Send(topic, "text/plain", []byte(message))
|
||||
|
||||
if err != nil {
|
||||
logs.Error("发送消息给activeMQ失败, message=", message)
|
||||
} else {
|
||||
logs.Info("发送消息给activeMQ成功,message=", message)
|
||||
}
|
||||
}
|
||||
119
boss/models/account.go
Normal file
119
boss/models/account.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
69
boss/models/account_history_info.go
Normal file
69
boss/models/account_history_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
162
boss/models/agent_info.go
Normal file
162
boss/models/agent_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
13
boss/models/agent_profit.go
Normal file
13
boss/models/agent_profit.go
Normal file
@@ -0,0 +1,13 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/12/17 17:50
|
||||
** @Author : yuebin
|
||||
** @File : agent_profit
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/12/17 17:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
type AgentProfit struct {
|
||||
}
|
||||
106
boss/models/bank_card_info.go
Normal file
106
boss/models/bank_card_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
39
boss/models/init.go
Normal file
39
boss/models/init.go
Normal file
@@ -0,0 +1,39 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/9 13:48
|
||||
** @Author : yuebin
|
||||
** @File : init
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/9 13:48
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"boss/conf"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
)
|
||||
|
||||
func init() {
|
||||
dbHost := conf.DB_HOST
|
||||
dbUser := conf.DB_USER
|
||||
dbPassword := conf.DB_PASSWORD
|
||||
dbBase := conf.DB_BASE
|
||||
dbPort := conf.DB_PORT
|
||||
|
||||
link := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", dbUser, dbPassword, dbHost, dbPort, dbBase)
|
||||
|
||||
logs.Info("mysql init.....", link)
|
||||
|
||||
orm.RegisterDriver("mysql", orm.DRMySQL)
|
||||
orm.RegisterDataBase("default", "mysql", link)
|
||||
orm.RegisterModel(new(UserInfo), new(MenuInfo), new(SecondMenuInfo),
|
||||
new(PowerInfo), new(RoleInfo), new(BankCardInfo), new(RoadInfo),
|
||||
new(RoadPoolInfo), new(AgentInfo), new(MerchantInfo), new(MerchantDeployInfo),
|
||||
new(AccountInfo), new(AccountHistoryInfo), new(OrderInfo), new(OrderProfitInfo),
|
||||
new(OrderSettleInfo), new(NotifyInfo), new(MerchantLoadInfo),
|
||||
new(PayforInfo))
|
||||
}
|
||||
179
boss/models/menu_info.go
Normal file
179
boss/models/menu_info.go
Normal file
@@ -0,0 +1,179 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/21 9:33
|
||||
** @Author : yuebin
|
||||
** @File : menu_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/21 9:33
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type MenuInfo struct {
|
||||
Id int
|
||||
MenuOrder int
|
||||
MenuUid string
|
||||
FirstMenu string
|
||||
SecondMenu string
|
||||
Creater string
|
||||
Status string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
//实现排序的三个接口函数
|
||||
type MenuInfoSlice []MenuInfo
|
||||
|
||||
func (m MenuInfoSlice) Len() int {
|
||||
return len(m)
|
||||
}
|
||||
|
||||
func (m MenuInfoSlice) Swap(i, j int) {
|
||||
m[i], m[j] = m[j], m[i]
|
||||
}
|
||||
|
||||
func (m MenuInfoSlice) Less(i, j int) bool {
|
||||
return m[i].MenuOrder < m[j].MenuOrder //从小到大排序
|
||||
}
|
||||
|
||||
const MENUINFO = "menu_info"
|
||||
|
||||
func InsertMenu(menuInfo MenuInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert new menu info fail:", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func FirstMenuIsExists(firstMenu string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("first_menu", firstMenu).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func FirstMenuUidIsExists(firstMenUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("menu_uid", firstMenUid).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func MenuOrderIsExists(menuOrder int) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("menu_order", menuOrder).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetMenuLen() int {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.QueryTable(MENUINFO).Count()
|
||||
if err != nil {
|
||||
logs.Error("get menu info len length fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMenuInfoByMenuUid(menuUid string) MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfo MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Filter("menu_uid", menuUid).Limit(1).All(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("get menu info by menuUid fail: ", err)
|
||||
}
|
||||
return menuInfo
|
||||
}
|
||||
|
||||
func GetMenuInfosByMenuUids(menuUids []string) []MenuInfo {
|
||||
menuInfoList := make([]MenuInfo, 0)
|
||||
for _, v := range menuUids {
|
||||
m := GetMenuInfoByMenuUid(v)
|
||||
menuInfoList = append(menuInfoList, m)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuInfoByMenuOrder(menuOrder int) MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfo MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Filter("menu_order", menuOrder).Limit(1).All(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("get menu info by menu order fail: ", err)
|
||||
}
|
||||
return menuInfo
|
||||
}
|
||||
|
||||
func GetMenuAll() []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).OrderBy("-update_time").All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get all menu list fail:", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuOffset(displayCount, offset int) []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Limit(displayCount, offset).All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get menu offset fail: ", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuOffsetByMap(params map[string]string, displayCount, offset int) []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
qs := o.QueryTable(MENUINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get menu offset by map fail: ", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MENUINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Count()
|
||||
if err != nil {
|
||||
logs.Error("get menu len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func UpdateMenuInfo(menuInfo MenuInfo) {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.Update(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("update menu info fail: ", err)
|
||||
}
|
||||
logs.Info("update menu info success, num: ", cnt)
|
||||
}
|
||||
|
||||
func DeleteMenuInfo(menuUid string) {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.QueryTable(MENUINFO).Filter("menu_uid", menuUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete menu info fail: ", err)
|
||||
}
|
||||
logs.Info("delete menu info num: ", cnt)
|
||||
}
|
||||
135
boss/models/merchant_deploy_info.go
Normal file
135
boss/models/merchant_deploy_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
205
boss/models/merchant_info.go
Normal file
205
boss/models/merchant_info.go
Normal file
@@ -0,0 +1,205 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/9/28 16:47
|
||||
** @Author : yuebin
|
||||
** @File : merchant_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/9/28 16:47
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type MerchantInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
BelongAgentUid string
|
||||
BelongAgentName string
|
||||
MerchantName string
|
||||
MerchantUid string
|
||||
MerchantKey string
|
||||
MerchantSecret string
|
||||
LoginPassword string
|
||||
LoginAccount string
|
||||
AutoSettle string
|
||||
AutoPayFor string
|
||||
WhiteIps string
|
||||
Remark string
|
||||
SinglePayForRoadUid string
|
||||
SinglePayForRoadName string
|
||||
RollPayForRoadCode string
|
||||
RollPayForRoadName string
|
||||
PayforFee float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const MERCHANT_INFO = "merchant_info"
|
||||
|
||||
func IsExistByMerchantName(merchantName string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("merchant_name", merchantName).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistByMerchantUid(uid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", uid).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistMerchantByAgentUid(uid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("belong_agent_uid", uid).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistByMerchantPhone(phone string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("LoginAccount", phone).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetMerchantByPhone(phone string) (m MerchantInfo) {
|
||||
o := orm.NewOrm()
|
||||
_, e := o.QueryTable(MERCHANT_INFO).Filter("LoginAccount", phone).Limit(1).All(&m)
|
||||
if e != nil {
|
||||
logs.Error("GetMerchantByPhone merchant fail: ", e)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func InsertMerchantInfo(merchantInfo MerchantInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetMerchantLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_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 len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMerchantListByMap(params map[string]string, displayCount, offset int) []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
var merchantList []MerchantInfo
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&merchantList)
|
||||
if err != nil {
|
||||
logs.Error("get merchant list by map fail: ", err)
|
||||
}
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetAllMerchant() []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantList []MerchantInfo
|
||||
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Limit(-1).All(&merchantList)
|
||||
if err != nil {
|
||||
logs.Error("get all merchant fail:", err)
|
||||
}
|
||||
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetMerchantByParams(params map[string]string, displayCount, offset int) []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantList []MerchantInfo
|
||||
qs := o.QueryTable(MERCHANT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
qs.Limit(displayCount, offset).All(&merchantList)
|
||||
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetMerchantLenByParams(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_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 merchant len by params fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMerchantByUid(merchantUid string) MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantInfo MerchantInfo
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", merchantUid).Limit(1).All(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("get merchant info fail: ", err)
|
||||
}
|
||||
return merchantInfo
|
||||
}
|
||||
|
||||
func GetMerchantByPaykey(payKey string) MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantInfo MerchantInfo
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_key", payKey).Limit(1).All(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("get merchant by merchantKey fail: ", err)
|
||||
}
|
||||
return merchantInfo
|
||||
}
|
||||
|
||||
func UpdateMerchant(merchantInfo MerchantInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&merchantInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteMerchantByUid(merchantUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", merchantUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
56
boss/models/merchant_load_info.go
Normal file
56
boss/models/merchant_load_info.go
Normal file
@@ -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 models
|
||||
|
||||
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()
|
||||
}
|
||||
103
boss/models/notify_info.go
Normal file
103
boss/models/notify_info.go
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/20 13:13
|
||||
** @Author : yuebin
|
||||
** @File : notify_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/20 13:13
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type NotifyInfo struct {
|
||||
Id int
|
||||
Type string //订单-order,代付-payfor
|
||||
BankOrderId string
|
||||
MerchantOrderId string
|
||||
Status string
|
||||
Times int
|
||||
Url string
|
||||
Response string
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const NOTIFYINFO = "notify_info"
|
||||
|
||||
func InsertNotifyInfo(notifyInfo NotifyInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert notify fail:", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func NotifyInfoExistByBankOrderId(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(NOTIFYINFO).Filter("bank_order_id", bankOrderId).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetNotifyInfoByBankOrderId(bankOrderId string) NotifyInfo {
|
||||
o := orm.NewOrm()
|
||||
var notifyInfo NotifyInfo
|
||||
_, err := o.QueryTable(NOTIFYINFO).Filter("bank_order_id", bankOrderId).All(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("get notify info by bankOrderId fail: ", err)
|
||||
}
|
||||
|
||||
return notifyInfo
|
||||
}
|
||||
|
||||
func GetNotifyInfosNotSuccess(params map[string]interface{}) []NotifyInfo {
|
||||
o := orm.NewOrm()
|
||||
var notifyInfoList []NotifyInfo
|
||||
qs := o.QueryTable(NOTIFYINFO)
|
||||
for k, v := range params {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
qs = qs.Exclude("status", "success")
|
||||
_, err := qs.Limit(-1).All(¬ifyInfoList)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get notifyinfos fail: ", err)
|
||||
}
|
||||
|
||||
return notifyInfoList
|
||||
}
|
||||
|
||||
func GetNotifyBankOrderIdListByParams(params map[string]string) []string {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(NOTIFYINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
var notifyList []NotifyInfo
|
||||
qs.Limit(-1).All(¬ifyList)
|
||||
var list []string
|
||||
for _, n := range notifyList {
|
||||
list = append(list, n.BankOrderId)
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
func UpdateNotifyInfo(notifyInfo NotifyInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("update notify info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
222
boss/models/order_info.go
Normal file
222
boss/models/order_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
119
boss/models/order_profit_info.go
Normal file
119
boss/models/order_profit_info.go
Normal file
@@ -0,0 +1,119 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/30 11:44
|
||||
** @Author : yuebin
|
||||
** @File : order_profit_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/30 11:44
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type OrderProfitInfo struct {
|
||||
Id int
|
||||
MerchantName string
|
||||
MerchantUid string
|
||||
AgentName string
|
||||
AgentUid string
|
||||
PayProductCode string
|
||||
PayProductName string
|
||||
PayTypeCode string
|
||||
PayTypeName string
|
||||
Status string
|
||||
MerchantOrderId string
|
||||
BankOrderId string
|
||||
BankTransId string
|
||||
OrderAmount float64
|
||||
ShowAmount float64
|
||||
FactAmount float64
|
||||
UserInAmount float64
|
||||
SupplierRate float64
|
||||
PlatformRate float64
|
||||
AgentRate float64
|
||||
AllProfit float64
|
||||
SupplierProfit float64
|
||||
PlatformProfit float64
|
||||
AgentProfit float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ORDER_PROFIT_INFO = "order_profit_info"
|
||||
|
||||
func GetOrderProfitByBankOrderId(bankOrderId string) OrderProfitInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderProfit OrderProfitInfo
|
||||
_, err := o.QueryTable(ORDER_PROFIT_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderProfit)
|
||||
if err != nil {
|
||||
logs.Error("GetOrderProfitByBankOrderId fail:", err)
|
||||
}
|
||||
return orderProfit
|
||||
}
|
||||
|
||||
func GetOrderProfitLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ORDER_PROFIT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, _ := qs.Limit(-1).Count()
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetOrderProfitByMap(params map[string]string, display, offset int) []OrderProfitInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderProfitInfoList []OrderProfitInfo
|
||||
qs := o.QueryTable(ORDER_PROFIT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&orderProfitInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get order by map fail: ", err)
|
||||
}
|
||||
return orderProfitInfoList
|
||||
}
|
||||
|
||||
func GetPlatformProfitByMap(params map[string]string) []PlatformProfit {
|
||||
|
||||
o := orm.NewOrm()
|
||||
|
||||
cond := "select merchant_name, agent_name, pay_product_name as supplier_name, pay_type_name, sum(fact_amount) as order_amount, count(1) as order_count, " +
|
||||
"sum(platform_profit) as platform_profit, sum(agent_profit) as agent_profit from " + ORDER_PROFIT_INFO + " where status='success' "
|
||||
flag := false
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
if flag {
|
||||
cond += " and"
|
||||
}
|
||||
if strings.Contains(k, "create_time__gte") {
|
||||
cond = cond + " create_time>='" + v + "'"
|
||||
} else if strings.Contains(k, "create_time__lte") {
|
||||
cond = cond + " create_time<='" + v + "'"
|
||||
} else {
|
||||
cond = cond + " " + k + "='" + v + "'"
|
||||
}
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
|
||||
cond += " group by merchant_uid, agent_uid, pay_product_code, pay_type_code"
|
||||
|
||||
var platformProfitList []PlatformProfit
|
||||
_, err := o.Raw(cond).QueryRows(&platformProfitList)
|
||||
if err != nil {
|
||||
logs.Error("get platform profit by map fail:", err)
|
||||
}
|
||||
|
||||
return platformProfitList
|
||||
}
|
||||
51
boss/models/order_settle_info.go
Normal file
51
boss/models/order_settle_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
228
boss/models/payfor_info.go
Normal file
228
boss/models/payfor_info.go
Normal file
@@ -0,0 +1,228 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/25 14:32
|
||||
** @Author : yuebin
|
||||
** @File : payfor_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/25 14:32
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type PayforInfo struct {
|
||||
Id int
|
||||
PayforUid string
|
||||
MerchantUid string
|
||||
MerchantName string
|
||||
MerchantOrderId string
|
||||
BankOrderId string
|
||||
BankTransId string
|
||||
RoadUid string
|
||||
RoadName string
|
||||
RollPoolCode string
|
||||
RollPoolName string
|
||||
PayforFee float64
|
||||
PayforAmount float64
|
||||
PayforTotalAmount float64
|
||||
BankCode string
|
||||
BankName string
|
||||
BankAccountName string
|
||||
BankAccountNo string
|
||||
BankAccountType string
|
||||
Country string
|
||||
City string
|
||||
Ares string
|
||||
BankAccountAddress string
|
||||
PhoneNo string
|
||||
GiveType string
|
||||
Type string
|
||||
NotifyUrl string
|
||||
Status string
|
||||
IsSend string
|
||||
RequestTime string
|
||||
ResponseTime string
|
||||
ResponseContext string
|
||||
Remark string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
const PAYFORINFO = "payfor_info"
|
||||
|
||||
func InsertPayfor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&payFor)
|
||||
if err != nil {
|
||||
logs.Error("insert payfor fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func IsExistPayForByBankOrderId(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(PAYFORINFO).Filter("bank_order_id", bankOrderId).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistPayForByMerchantOrderId(merchantOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(PAYFORINFO).Filter("merchant_order_id", merchantOrderId).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetPayForLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
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 pay for len by map fail: ", err)
|
||||
}
|
||||
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetPayForByMap(params map[string]string, displayCount, offset int) []PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payForList []PayforInfo
|
||||
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-create_time").All(&payForList)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get agentInfo by map fail: ", err)
|
||||
}
|
||||
|
||||
return payForList
|
||||
}
|
||||
|
||||
func GetPayForListByParams(params map[string]string) []PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payForList []PayforInfo
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(-1).All(&payForList)
|
||||
if err != nil {
|
||||
logs.Error("GetPayForListByParams fail:", err)
|
||||
}
|
||||
return payForList
|
||||
}
|
||||
|
||||
func GetPayForByBankOrderId(bankOrderId string) PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payFor PayforInfo
|
||||
_, err := o.QueryTable(PAYFORINFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get pay for by bank_order_id fail: ", err)
|
||||
}
|
||||
|
||||
return payFor
|
||||
}
|
||||
|
||||
func GetPayForByMerchantOrderId(merchantOrderId string) PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payFor PayforInfo
|
||||
|
||||
_, err := o.QueryTable(PAYFORINFO).Filter("merchant_order_id", merchantOrderId).Limit(1).All(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("fail: ", err)
|
||||
}
|
||||
|
||||
return payFor
|
||||
}
|
||||
|
||||
func ForUpdatePayFor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
var tmp PayforInfo
|
||||
if err := txOrm.Raw("select * from payfor_info where bank_order_id = ? for update", payFor.BankOrderId).QueryRow(&tmp); err != nil || tmp.PayforUid == "" {
|
||||
logs.Error("for update payfor select fail:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if tmp.Status == common.PAYFOR_FAIL || tmp.Status == common.PAYFOR_SUCCESS {
|
||||
return errors.New("订单已经处理")
|
||||
}
|
||||
|
||||
//如果是手动打款,并且是需要处理商户金额
|
||||
if payFor.Status == common.PAYFOR_SOLVING && tmp.Status == common.PAYFOR_COMFRIM &&
|
||||
payFor.GiveType == common.PAYFOR_HAND && payFor.Type != common.SELF_HELP {
|
||||
|
||||
var account AccountInfo
|
||||
if err := txOrm.Raw("select * from account_info where account_uid = ? for update", payFor.MerchantUid).QueryRow(&account); err != nil || account.AccountUid == "" {
|
||||
logs.Error("for update payfor select account info,fail:", err)
|
||||
return err
|
||||
}
|
||||
//计算该用户的可用金额
|
||||
ableAmount := account.SettleAmount - account.FreezeAmount - account.PayforAmount - account.LoanAmount
|
||||
if ableAmount >= payFor.PayforAmount+payFor.PayforFee {
|
||||
account.PayforAmount += payFor.PayforFee + payFor.PayforAmount
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&account); err != nil {
|
||||
logs.Error("for update payfor update account fail:", err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,可用金额不够", payFor.MerchantUid))
|
||||
payFor.ResponseContext = "商户可用余额不足"
|
||||
payFor.Status = common.PAYFOR_FAIL
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := txOrm.Update(&payFor); err != nil {
|
||||
logs.Error("for update payfor fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdatePayFor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update pay for fail:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
21
boss/models/platform_profit.go
Normal file
21
boss/models/platform_profit.go
Normal file
@@ -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 models
|
||||
|
||||
type PlatformProfit struct {
|
||||
MerchantName string
|
||||
AgentName string
|
||||
SupplierName string
|
||||
PayTypeName string
|
||||
OrderAmount float64
|
||||
OrderCount int
|
||||
PlatformProfit float64
|
||||
AgentProfit float64
|
||||
}
|
||||
143
boss/models/power_info.go
Normal file
143
boss/models/power_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
162
boss/models/road_info.go
Normal file
162
boss/models/road_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
127
boss/models/road_pool_info.go
Normal file
127
boss/models/road_pool_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
123
boss/models/role_info.go
Normal file
123
boss/models/role_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
216
boss/models/second_menu_info.go
Normal file
216
boss/models/second_menu_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
82
boss/models/transaction.go
Normal file
82
boss/models/transaction.go
Normal file
@@ -0,0 +1,82 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/19 14:17
|
||||
** @Author : yuebin
|
||||
** @File : transaction
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/19 14:17
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
func OperatorAccount(accountUid, operatorType string, amount float64) (string, bool) {
|
||||
o := orm.NewOrm()
|
||||
|
||||
msg := ""
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
//处理事务
|
||||
accountInfo := new(AccountInfo)
|
||||
if err := txOrm.Raw("select * from account_info where account_uid = ? for update", accountUid).QueryRow(accountInfo); err != nil || accountInfo.AccountUid == "" {
|
||||
logs.Error("operator account get account info for update fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
flag := true
|
||||
|
||||
switch operatorType {
|
||||
case common.PLUS_AMOUNT: //处理加款操作
|
||||
accountInfo.Balance = accountInfo.Balance + amount
|
||||
accountInfo.SettleAmount = accountInfo.SettleAmount + amount
|
||||
case common.SUB_AMOUNT: //处理减款
|
||||
if accountInfo.Balance >= amount && accountInfo.SettleAmount >= amount {
|
||||
accountInfo.Balance = accountInfo.Balance - amount
|
||||
accountInfo.SettleAmount = accountInfo.SettleAmount - amount
|
||||
} else {
|
||||
msg = "账户余额不够减"
|
||||
flag = false
|
||||
}
|
||||
case common.FREEZE_AMOUNT: //处理冻结款
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount + amount
|
||||
case common.UNFREEZE_AMOUNT: //处理解冻款
|
||||
if accountInfo.FreezeAmount >= amount {
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount - amount
|
||||
} else {
|
||||
msg = "账户冻结金额不够解冻款"
|
||||
flag = false
|
||||
}
|
||||
}
|
||||
if !flag {
|
||||
return errors.New("处理失败")
|
||||
}
|
||||
|
||||
if _, err := txOrm.Update(accountInfo); err != nil {
|
||||
logs.Error("operator account update account fail: ", err)
|
||||
return err
|
||||
}
|
||||
//往account_history表中插入一条动账记录
|
||||
accountHistory := AccountHistoryInfo{AccountUid: accountUid, AccountName: accountInfo.AccountName, Type: operatorType,
|
||||
Amount: amount, Balance: accountInfo.Balance, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if _, err := txOrm.Insert(&accountHistory); err != nil {
|
||||
logs.Error("operator account insert account history fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return msg, false
|
||||
}
|
||||
|
||||
return msg, true
|
||||
}
|
||||
146
boss/models/user_info.go
Normal file
146
boss/models/user_info.go
Normal file
@@ -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 models
|
||||
|
||||
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
|
||||
}
|
||||
105
boss/routers/router.go
Normal file
105
boss/routers/router.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package routers
|
||||
|
||||
import (
|
||||
"boss/controllers"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
//beego.Router("/", &controllers.PageController{}, "*:Index")
|
||||
//添加过滤函数
|
||||
beego.Router("/filter.html", &controllers.FilterController{}, "*:Filter")
|
||||
//登录验证接口
|
||||
beego.Router("/login", &controllers.LoginController{}, "*:Login")
|
||||
beego.Router("/logout", &controllers.LoginController{}, "*:Logout")
|
||||
beego.Router("/getVerifyImg", &controllers.LoginController{}, "*:GetVerifyImg")
|
||||
beego.Router("/update/password", &controllers.UpdateController{}, "*:UpdatePassword")
|
||||
beego.Router("/freeze/operator", &controllers.UpdateController{}, "*:FreezeOperator")
|
||||
beego.Router("/freeze/merchant", &controllers.UpdateController{}, "*:UpdateMerchantStatus")
|
||||
beego.Router("/unfreeze/operator", &controllers.UpdateController{}, "*:UnfreezeOperator")
|
||||
beego.Router("/unfreeze/merchant", &controllers.UpdateController{}, "*:UpdateMerchantStatus")
|
||||
beego.Router("/edit/operator", &controllers.UpdateController{}, "*:EditOperator")
|
||||
beego.Router("/add/menu", &controllers.AddController{}, "*:AddMenu")
|
||||
beego.Router("/add/secondMenu", &controllers.AddController{}, "*:AddSecondMenu")
|
||||
beego.Router("/add/power", &controllers.AddController{}, "*:AddPower")
|
||||
beego.Router("/add/role", &controllers.AddController{}, "*:AddRole")
|
||||
beego.Router("/add/operator", &controllers.AddController{}, "*:AddOperator")
|
||||
beego.Router("/add/bankCard", &controllers.AddController{}, "*:AddBankCard")
|
||||
beego.Router("/add/road", &controllers.AddController{}, "*:AddRoad")
|
||||
beego.Router("/add/roadPool", &controllers.AddController{}, "*:AddRoadPool")
|
||||
beego.Router("/add/merchant", &controllers.AddController{}, "*:AddMerchant")
|
||||
beego.Router("/add/agent", &controllers.AddController{}, "*:AddAgent")
|
||||
beego.Router("/add/merchant/deploy", &controllers.AddController{}, "*:AddMerchantDeploy")
|
||||
beego.Router("/add/merchant/payType", &controllers.AddController{}, "*:AddMerchantPayType")
|
||||
beego.Router("/add/payfor", &controllers.AddController{}, "*:AddPayFor")
|
||||
beego.Router("/add/self/payfor", &controllers.AddController{}, "*:AddSelfPayFor")
|
||||
beego.Router("/get/menu", &controllers.GetController{}, "*:GetMenu")
|
||||
beego.Router("/get/secondMenu", &controllers.GetController{}, "*:GetSecondMenu")
|
||||
beego.Router("/get/secondMenus", &controllers.GetController{}, "*:GetSecondMenus")
|
||||
beego.Router("/get/oneMenu", &controllers.GetController{}, "*:GetOneMenu")
|
||||
beego.Router("/get/firstMenu", &controllers.GetController{}, "*:GetFirstMenu")
|
||||
beego.Router("/get/powerItem", &controllers.GetController{}, "*:GetPowerItem")
|
||||
beego.Router("/get/role", &controllers.GetController{}, "*:GetRole")
|
||||
beego.Router("/get/allRole", &controllers.GetController{}, "*:GetAllRole")
|
||||
beego.Router("/get/deployTree", &controllers.GetController{}, "*:GetDeployTree")
|
||||
beego.Router("/get/operator", &controllers.GetController{}, "*:GetOperator")
|
||||
beego.Router("/get/oneOperator", &controllers.GetController{}, "*:GetOneOperator")
|
||||
beego.Router("/get/editOperator", &controllers.GetController{}, "*:GetEditOperator")
|
||||
beego.Router("/get/bankCard", &controllers.GetController{}, "*:GetBankCard")
|
||||
beego.Router("/get/oneBankCard", &controllers.GetController{}, "*:GetOneBankCard")
|
||||
beego.Router("/get/road", &controllers.GetController{}, "*:GetRoad")
|
||||
beego.Router("/get/oneRoad", &controllers.GetController{}, "*:GetOneRoad")
|
||||
beego.Router("/get/all/road", &controllers.GetController{}, "*:GetAllRoad")
|
||||
beego.Router("/get/roadPool", &controllers.GetController{}, "*:GetRoadPool")
|
||||
beego.Router("/get/all/roll/pool", &controllers.GetController{}, "*:GetAllRollPool")
|
||||
beego.Router("/get/merchant", &controllers.GetController{}, "*:GetMerchant")
|
||||
beego.Router("/get/all/merchant", &controllers.GetController{}, "*:GetAllMerchant")
|
||||
beego.Router("/get/one/merchant", &controllers.GetController{}, "*:GetOneMerchant")
|
||||
beego.Router("/get/one/merchant/deploy", &controllers.GetController{}, "*:GetOneMerchantDeploy")
|
||||
beego.Router("/get/all/account", &controllers.GetController{}, "*:GetAllAccount")
|
||||
beego.Router("/get/account", &controllers.GetController{}, "*:GetAccount")
|
||||
beego.Router("/get/one/account", &controllers.GetController{}, "*:GetOneAccount")
|
||||
beego.Router("/get/account/history", &controllers.GetController{}, "*:GetAccountHistory")
|
||||
beego.Router("/get/agent", &controllers.GetController{}, "*:GetAgent")
|
||||
beego.Router("/get/all/agent", &controllers.GetController{}, "*:GetAllAgent")
|
||||
beego.Router("/get/product", &controllers.GetController{}, "*:GetProduct")
|
||||
beego.Router("/get/order", &controllers.GetController{}, "*:GetOrder")
|
||||
beego.Router("/get/one/order", &controllers.GetController{}, "*:GetOneOrder")
|
||||
beego.Router("/get/orderProfit", &controllers.GetController{}, "*:GetOrderProfit")
|
||||
beego.Router("/get/payfor", &controllers.GetController{}, "*:GetPayFor")
|
||||
beego.Router("/get/one/payfor", &controllers.GetController{}, "*:GetOnePayFor")
|
||||
beego.Router("/get/balance", &controllers.GetController{}, "*:GetBalance")
|
||||
beego.Router("/get/notify/bankOrderId/list", &controllers.GetController{}, "*:GetNotifyBankOrderIdList")
|
||||
beego.Router("/get/agent/to/merchant", &controllers.GetController{}, "*:GetAgentToMerchant")
|
||||
beego.Router("/get/profit", &controllers.GetController{}, "*:GetProfit")
|
||||
beego.Router("/save/power", &controllers.AddController{}, "*:SavePower")
|
||||
beego.Router("/save/roadUid", &controllers.AddController{}, "*:SaveRoadUid")
|
||||
beego.Router("/up/menu", &controllers.UpdateController{}, "*:UpMenu")
|
||||
beego.Router("/down/menu", &controllers.UpdateController{}, "*:DownMenu")
|
||||
beego.Router("/up/secondMenu", &controllers.UpdateController{}, "*:UpSecondMenu")
|
||||
beego.Router("/down/secondMenu", &controllers.UpdateController{}, "*:DownSecondMenu")
|
||||
beego.Router("/update/roadStatus", &controllers.UpdateController{}, "*:UpdateRoadStatus")
|
||||
beego.Router("/update/account/status", &controllers.UpdateController{}, "*:UpdateAccountStatus")
|
||||
beego.Router("/update/agent/status", &controllers.UpdateController{}, "*:UpdateAgentStatus")
|
||||
beego.Router("/update/order/status", &controllers.UpdateController{}, "*:UpdateOrderStatus")
|
||||
beego.Router("/account/operator", &controllers.UpdateController{}, "*:OperatorAccount")
|
||||
beego.Router("/delete/menu", &controllers.Deletecontroller{}, "*:DeleteMenu")
|
||||
beego.Router("/delete/secondMenu", &controllers.Deletecontroller{}, "*:DeleteSecondMenu")
|
||||
beego.Router("/delete/powerItem", &controllers.Deletecontroller{}, "*:DeletePowerItem")
|
||||
beego.Router("/delete/role", &controllers.Deletecontroller{}, "*:DeleteRole")
|
||||
beego.Router("/delete/operator", &controllers.Deletecontroller{}, "*:DeleteOperator")
|
||||
beego.Router("/delete/bankCardRecord", &controllers.Deletecontroller{}, "*:DeleteBankCardRecord")
|
||||
beego.Router("/delete/road", &controllers.Deletecontroller{}, "*:DeleteRoad")
|
||||
beego.Router("/delete/roadPool", &controllers.Deletecontroller{}, "*:DeleteRoadPool")
|
||||
beego.Router("/delete/merchant", &controllers.Deletecontroller{}, "*:DeleteMerchant")
|
||||
beego.Router("/delete/account", &controllers.Deletecontroller{}, "*:DeleteAccount")
|
||||
beego.Router("/delete/agent", &controllers.Deletecontroller{}, "*:DeleteAgent")
|
||||
beego.Router("/delete/agent/merchant/relation", &controllers.Deletecontroller{}, "*:DeleteAgentRelation")
|
||||
beego.Router("/reset/agent/password", &controllers.UpdateController{}, "*:ResetAgentPassword")
|
||||
beego.Router("/supplier/order/query", &controllers.SupplierQuery{}, "*:SupplierOrderQuery")
|
||||
beego.Router("/supplier/payfor/query", &controllers.SupplierQuery{}, "*:SupplierPayForQuery")
|
||||
beego.Router("/choose/payfor/road", &controllers.UpdateController{}, "*:ChoosePayForRoad")
|
||||
beego.Router("/result/payfor", &controllers.UpdateController{}, "*:ResultPayFor")
|
||||
beego.Router("/send/notify", &controllers.SendNotify{}, "*:SendNotifyToMerchant")
|
||||
beego.Router("/self/send/notify", &controllers.SendNotify{}, "*:SelfSendNotify")
|
||||
}
|
||||
48
boss/routers/router_pages.go
Normal file
48
boss/routers/router_pages.go
Normal file
@@ -0,0 +1,48 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/23 15:17
|
||||
** @Author : yuebin
|
||||
** @File : router_pages
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/23 15:17
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package routers
|
||||
|
||||
import (
|
||||
"boss/controllers"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
beego.Router("/", &controllers.PageController{}, "*:Index")
|
||||
beego.Router("/index.html", &controllers.PageController{}, "*:Index")
|
||||
beego.Router("/login.html", &controllers.PageController{}, "*:LoginPage")
|
||||
beego.Router("/account.html", &controllers.PageController{}, "*:AccountPage")
|
||||
beego.Router("/account_history.html", &controllers.PageController{}, "*:AccountHistoryPage")
|
||||
beego.Router("/bank_card.html", &controllers.PageController{}, "*:BankCardPage")
|
||||
beego.Router("/create_agent.html", &controllers.PageController{}, "*:CreateAgentPage")
|
||||
beego.Router("/edit_role.html", &controllers.PageController{}, "*:EditRolePage")
|
||||
beego.Router("/first_menu.html", &controllers.PageController{}, "*:FirstMenuPage")
|
||||
beego.Router("/main.html", &controllers.PageController{}, "*:MainPage")
|
||||
beego.Router("/menu.html", &controllers.PageController{}, "*:MenuPage")
|
||||
beego.Router("/merchant.html", &controllers.PageController{}, "*:MerchantPage")
|
||||
beego.Router("/operator.html", &controllers.PageController{}, "*:OperatorPage")
|
||||
beego.Router("/power.html", &controllers.PageController{}, "*:PowerPage")
|
||||
beego.Router("/road.html", &controllers.PageController{}, "*:RoadPage")
|
||||
beego.Router("/road_pool.html", &controllers.PageController{}, "*:RoadPoolPage")
|
||||
beego.Router("/road_profit.html", &controllers.PageController{}, "*:RoadProfitPage")
|
||||
beego.Router("/role.html", &controllers.PageController{}, "*:RolePage")
|
||||
beego.Router("/second_menu.html", &controllers.PageController{}, "*:SecondMenuPage")
|
||||
beego.Router("/order_info.html", &controllers.PageController{}, "*:OrderInfoPage")
|
||||
beego.Router("/order_profit.html", &controllers.PageController{}, "*:OrderProfitPage")
|
||||
beego.Router("/merchant_payfor.html", &controllers.PageController{}, "*:MerchantPayforPage")
|
||||
beego.Router("/self_payfor.html", &controllers.PageController{}, "*:SelfPayforPage")
|
||||
beego.Router("/payfor_record.html", &controllers.PageController{}, "*:PayforRecordPage")
|
||||
beego.Router("/confirm.html", &controllers.PageController{}, "*:ConfirmPage")
|
||||
beego.Router("/self_notify.html", &controllers.PageController{}, "*:SelfNotifyPage")
|
||||
beego.Router("/self_plus_sub.html", &controllers.PageController{}, "*:SelfPlusSubPage")
|
||||
beego.Router("/agent_to_merchant.html", &controllers.PageController{}, "*:AgentToMerchantPage")
|
||||
beego.Router("/platform_profit.html", &controllers.PageController{}, "*:PlatFormProfitPage")
|
||||
beego.Router("/agent_profit.html", &controllers.PageController{}, "*:AgentProfitPage")
|
||||
}
|
||||
50
boss/service/common/consts.go
Normal file
50
boss/service/common/consts.go
Normal file
@@ -0,0 +1,50 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/25 14:14
|
||||
** @Author : yuebin
|
||||
** @File : consts.go
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/25 14:14
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package common
|
||||
|
||||
const (
|
||||
ACTIVE = "active"
|
||||
UNACTIVE = "unactive"
|
||||
DELETE = "delete"
|
||||
REFUND = "refund"
|
||||
ORDERROLL = "order_roll"
|
||||
WAIT = "wait"
|
||||
SUCCESS = "success"
|
||||
FAIL = "fail"
|
||||
YES = "yes"
|
||||
NO = "no"
|
||||
ZERO = 0.0 //0元手续费
|
||||
VERIFY_CODE_LEN = 4 //验证码的长度
|
||||
PAYFOR_FEE = 2.00 //代付手续费
|
||||
PAYFOR_INTERVAL = 5 //每过5分钟执行一次代付
|
||||
|
||||
PLUS_AMOUNT = "plus_amount" //加款操作
|
||||
SUB_AMOUNT = "sub_amount" //减款操作
|
||||
FREEZE_AMOUNT = "freeze_amount" //冻结操作
|
||||
UNFREEZE_AMOUNT = "unfreeze_amount" //解冻操作
|
||||
|
||||
PAYFOR_COMFRIM = "payfor_confirm" //下发带审核
|
||||
PAYFOR_SOLVING = "payfor_solving" //发下处理中
|
||||
PAYFOR_HANDING = "payfor_handing" //手动打款中
|
||||
PAYFOR_BANKING = "payfor_banking" //银行处理中
|
||||
PAYFOR_FAIL = "payfor_fail" //代付失败
|
||||
PAYFOR_SUCCESS = "payfor_success" //代付成功
|
||||
|
||||
PAYFOR_ROAD = "payfor_road" //通道打款
|
||||
PAYFOR_HAND = "payfor_hand" //手动打款
|
||||
PAYFOR_REFUSE = "payfor_refuse" // 拒绝打款
|
||||
|
||||
SELF_API = "self_api" //自助api系统下发
|
||||
SELF_MERCHANT = "self_merchant" //管理手动处理商户下发
|
||||
SELF_HELP = "self_help" //管理自己提现
|
||||
|
||||
PUBLIC = "public" //对公卡
|
||||
PRIVATE = "private" //对私卡
|
||||
)
|
||||
25
boss/service/common/mq_config.go
Normal file
25
boss/service/common/mq_config.go
Normal file
@@ -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 common
|
||||
|
||||
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)
|
||||
}
|
||||
99
boss/service/common/pay_way_code.go
Normal file
99
boss/service/common/pay_way_code.go
Normal file
@@ -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 common
|
||||
|
||||
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 "未知"
|
||||
}
|
||||
}
|
||||
47
boss/service/common/supplier.go
Normal file
47
boss/service/common/supplier.go
Normal file
@@ -0,0 +1,47 @@
|
||||
/***************************************************
|
||||
** @Desc : 上有支付公司的编号
|
||||
** @Time : 2019/10/28 10:47
|
||||
** @Author : yuebin
|
||||
** @File : supplier
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/28 10:47
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package common
|
||||
|
||||
//添加新的上游通道时,需要添加这里
|
||||
var supplierCode2Name = map[string]string{
|
||||
"KF": "快付支付",
|
||||
"WEIXIN": "官方微信",
|
||||
"ALIPAY": "官方支付宝",
|
||||
}
|
||||
|
||||
func GetSupplierMap() map[string]string {
|
||||
return supplierCode2Name
|
||||
}
|
||||
|
||||
func GetSupplierCodes() []string {
|
||||
var supplierCodes []string
|
||||
for k := range supplierCode2Name {
|
||||
supplierCodes = append(supplierCodes, k)
|
||||
}
|
||||
|
||||
return supplierCodes
|
||||
}
|
||||
|
||||
func GetSupplierNames() []string {
|
||||
var supplierNames []string
|
||||
for _, v := range supplierCode2Name {
|
||||
supplierNames = append(supplierNames, v)
|
||||
}
|
||||
return supplierNames
|
||||
}
|
||||
|
||||
func CheckSupplierByCode(code string) string {
|
||||
for k, v := range supplierCode2Name {
|
||||
if k == code {
|
||||
return v + ",注册完毕"
|
||||
}
|
||||
}
|
||||
return "未找到上游名称,注册有问题。"
|
||||
}
|
||||
3
boss/service/conf/app.conf
Normal file
3
boss/service/conf/app.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
appname = service
|
||||
httpport = 8080
|
||||
runmode = dev
|
||||
18
boss/service/conf/config.go
Normal file
18
boss/service/conf/config.go
Normal file
@@ -0,0 +1,18 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/26 15:30
|
||||
** @Author : yuebin
|
||||
** @File : conf_pro
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/26 15:30
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package conf
|
||||
|
||||
const (
|
||||
DB_HOST = "localhost"
|
||||
DB_PORT = "3306"
|
||||
DB_USER = "root"
|
||||
DB_PASSWORD = "Kyb^15273031604"
|
||||
DB_BASE = "juhe_pay"
|
||||
)
|
||||
70
boss/service/controller/alipay.go
Normal file
70
boss/service/controller/alipay.go
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/28 16:38
|
||||
** @Author : yuebin
|
||||
** @File : alipay
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/28 16:38
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
import (
|
||||
"dongfeng/service/models"
|
||||
)
|
||||
|
||||
type AlipayImpl struct {
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) Scan(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) H5(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) Syt(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) Fast(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) bool {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) Web(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) bool {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) PayNotify() {
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) PayQuery(orderInfo models.OrderInfo) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) PayFor(info models.PayforInfo) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) PayForNotify() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) PayForQuery(payFor models.PayforInfo) (string, string) {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
func (c *AlipayImpl) BalanceQuery(roadInfo models.RoadInfo) float64 {
|
||||
return 0.00
|
||||
}
|
||||
14
boss/service/controller/consts.go
Normal file
14
boss/service/controller/consts.go
Normal file
@@ -0,0 +1,14 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/19 18:12
|
||||
** @Author : yuebin
|
||||
** @File : consts.go
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/19 18:12
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
const (
|
||||
PayNotify = ""
|
||||
)
|
||||
48
boss/service/controller/gateway_solve.go
Normal file
48
boss/service/controller/gateway_solve.go
Normal file
@@ -0,0 +1,48 @@
|
||||
/***************************************************
|
||||
** @Desc : 处理网关模块的一些需要操作数据库的功能
|
||||
** @Time : 2019/12/7 16:40
|
||||
** @Author : yuebin
|
||||
** @File : gateway_solve
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/12/7 16:40
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"dongfeng/service/models"
|
||||
)
|
||||
|
||||
/*
|
||||
* 插入支付订单记录和订单利润记录,保证一致性
|
||||
*/
|
||||
func InsertOrderAndOrderProfit(orderInfo models.OrderInfo, orderProfitInfo models.OrderProfitInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
o.Rollback()
|
||||
}
|
||||
}(o)
|
||||
|
||||
if _, err := o.Insert(&orderInfo); err != nil {
|
||||
logs.Error("insert orderInfo fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
if _, err := o.Insert(&orderProfitInfo); err != nil {
|
||||
logs.Error("insert orderProfit fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("insert order and orderProfit fail:", err)
|
||||
} else {
|
||||
logs.Info("插入order和orderProfit记录成功")
|
||||
}
|
||||
return true
|
||||
}
|
||||
32
boss/service/controller/init.go
Normal file
32
boss/service/controller/init.go
Normal file
@@ -0,0 +1,32 @@
|
||||
/***************************************************
|
||||
** @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 controller
|
||||
|
||||
import (
|
||||
"dongfeng/service/common"
|
||||
"github.com/astaxie/beego/logs"
|
||||
)
|
||||
|
||||
var registerSupplier = make(map[string]PayInterface)
|
||||
|
||||
//注册各种上游的支付接口
|
||||
|
||||
func Init() {
|
||||
registerSupplier["KF"] = new(KuaiFuImpl)
|
||||
logs.Notice(common.CheckSupplierByCode("KF"))
|
||||
registerSupplier["WEIXIN"] = new(WeiXinImpl)
|
||||
logs.Notice(common.CheckSupplierByCode("WEIXIN"))
|
||||
registerSupplier["ALIPAY"] = new(AlipayImpl)
|
||||
logs.Notice(common.CheckSupplierByCode("ALIPAY"))
|
||||
}
|
||||
|
||||
func GetPaySupplierByCode(code string) PayInterface {
|
||||
return registerSupplier[code]
|
||||
}
|
||||
381
boss/service/controller/kuaifu.go
Normal file
381
boss/service/controller/kuaifu.go
Normal file
@@ -0,0 +1,381 @@
|
||||
/***************************************************
|
||||
** @Desc : 快付支付的实现逻辑
|
||||
** @Time : 2019/10/28 14:12
|
||||
** @Author : yuebin
|
||||
** @File : kuaifu
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/28 14:12
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/httplib"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/rs/xid"
|
||||
"github.com/widuu/gojson"
|
||||
"dongfeng/service/common"
|
||||
"dongfeng/service/models"
|
||||
"dongfeng/service/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type KuaiFuImpl struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
const (
|
||||
HOST = "localhost"
|
||||
KF_SCAN_HOST = "http://" + HOST + "/gateway/scanPay/payService"
|
||||
KF_PAYFOR_HOST = "http://" + HOST + "/gateway/remittance/pay"
|
||||
KF_BALANCE_QUERY = "http://" + HOST + "/gateway/remittance/getBalance"
|
||||
KF_ORDER_QUERY = "http://" + HOST + "/gateway/scanPay/orderQuery"
|
||||
KF_PAYFOR_QUERY = "http://" + HOST + "/gateway/remittance/query"
|
||||
KF_PAY_KEY = "xxxxxxx"
|
||||
KF_PAY_SECRET = "xxxxxx"
|
||||
)
|
||||
|
||||
func (c *KuaiFuImpl) Scan(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
payWayCode := ""
|
||||
switch orderInfo.PayTypeCode {
|
||||
case "ALI_SCAN":
|
||||
payWayCode = "SCAN_ALIPAY"
|
||||
case "WEIXIN_SCAN":
|
||||
payWayCode = "SCAN_WEIXIN"
|
||||
case "QQ_SCAN":
|
||||
payWayCode = "SCAN_QQ"
|
||||
case "UNION_SCAN":
|
||||
payWayCode = "SCAN_YL"
|
||||
case "BAIDU_SCAN":
|
||||
case "JD_SCAN":
|
||||
}
|
||||
//将金额转为带有2位小数点的float
|
||||
order := fmt.Sprintf("%0.2f", orderInfo.OrderAmount)
|
||||
params := make(map[string]string)
|
||||
params["orderNo"] = orderInfo.BankOrderId
|
||||
params["productName"] = orderInfo.ShopName
|
||||
params["orderPeriod"] = orderInfo.OrderPeriod
|
||||
params["orderPrice"] = order
|
||||
params["payWayCode"] = payWayCode
|
||||
params["osType"] = orderInfo.OsType
|
||||
params["notifyUrl"] = PayNotify + "KF"
|
||||
params["payKey"] = KF_PAY_KEY
|
||||
//params["field1"] = "field1"
|
||||
|
||||
keys := utils.SortMap(params)
|
||||
sign := utils.GetMD5Sign(params, keys, KF_PAY_SECRET)
|
||||
params["sign"] = sign
|
||||
|
||||
req := httplib.Post(KF_SCAN_HOST)
|
||||
for k, v := range params {
|
||||
req.Param(k, v)
|
||||
}
|
||||
var scanData ScanData
|
||||
scanData.Supplier = orderInfo.PayProductCode
|
||||
scanData.PayType = orderInfo.PayTypeCode
|
||||
scanData.OrderNo = orderInfo.MerchantOrderId
|
||||
scanData.BankNo = orderInfo.BankOrderId
|
||||
scanData.OrderPrice = params["orderPrice"]
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
logs.Error("KF 请求失败:", err)
|
||||
scanData.Status = "01"
|
||||
scanData.Msg = gojson.Json(response).Get("statusMsg").Tostring()
|
||||
return scanData
|
||||
}
|
||||
statusCode := gojson.Json(response).Get("statusCode").Tostring()
|
||||
if statusCode != "00" {
|
||||
logs.Error("KF生成扫码地址失败")
|
||||
scanData.Status = "01"
|
||||
scanData.Msg = "生成扫码地址失败"
|
||||
return scanData
|
||||
}
|
||||
payUrl := gojson.Json(response).Get("payURL").Tostring()
|
||||
scanData.Status = "00"
|
||||
scanData.PayUrl = payUrl
|
||||
scanData.Msg = "请求成功"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) H5(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) Syt(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) Fast(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) bool {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) Web(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) bool {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return true
|
||||
}
|
||||
|
||||
//支付回调
|
||||
func (c *KuaiFuImpl) PayNotify() {
|
||||
params := make(map[string]string)
|
||||
orderNo := strings.TrimSpace(c.GetString("orderNo"))
|
||||
orderInfo := models.GetOrderByBankOrderId(orderNo)
|
||||
if orderInfo.BankOrderId == "" || len(orderInfo.BankOrderId) == 0 {
|
||||
logs.Error("快付回调的订单号不存在,订单号=", orderNo)
|
||||
c.StopRun()
|
||||
}
|
||||
roadInfo := models.GetRoadInfoByRoadUid(orderInfo.RoadUid)
|
||||
if roadInfo.RoadUid == "" || len(roadInfo.RoadUid) == 0 {
|
||||
logs.Error("支付通道已经关系或者删除,不进行回调")
|
||||
c.StopRun()
|
||||
}
|
||||
merchantUid := orderInfo.MerchantUid
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
if merchantInfo.MerchantUid == "" || len(merchantInfo.MerchantUid) == 0 {
|
||||
logs.Error("快付回调失败,该商户不存在或者已经删除,商户uid=", merchantUid)
|
||||
c.StopRun()
|
||||
}
|
||||
paySecret := merchantInfo.MerchantSecret
|
||||
params["orderNo"] = orderNo
|
||||
params["orderPrice"] = strings.TrimSpace(c.GetString("orderPrice"))
|
||||
params["orderTime"] = strings.TrimSpace(c.GetString("orderTime"))
|
||||
params["trxNo"] = strings.TrimSpace(c.GetString("trxNo"))
|
||||
params["statusCode"] = strings.TrimSpace(c.GetString("statusCode"))
|
||||
params["tradeStatus"] = strings.TrimSpace(c.GetString("tradeStatus"))
|
||||
params["field1"] = strings.TrimSpace(c.GetString("field1"))
|
||||
params["payKey"] = strings.TrimSpace(c.GetString("payKey"))
|
||||
//对参数进行验签
|
||||
keys := utils.SortMap(params)
|
||||
tmpSign := utils.GetMD5Sign(params, keys, paySecret)
|
||||
sign := strings.TrimSpace(c.GetString("sign"))
|
||||
if tmpSign != sign {
|
||||
logs.Error("快付回调签名异常,回调失败")
|
||||
c.StopRun()
|
||||
}
|
||||
//实际支付金额
|
||||
factAmount, err := strconv.ParseFloat(params["orderPrice"], 64)
|
||||
if err != nil {
|
||||
logs.Error("快付回调实际金额有误, factAmount=", params["orderPrice"])
|
||||
c.StopRun()
|
||||
}
|
||||
orderInfo.FactAmount = factAmount
|
||||
orderInfo.BankTransId = params["trxNo"]
|
||||
tradeStatus := params["tradeStatus"]
|
||||
paySolveController := new(PaySolveController)
|
||||
if tradeStatus == "FAILED" {
|
||||
if !paySolveController.SolvePayFail(orderInfo, "fail") {
|
||||
logs.Error("solve order fail fail")
|
||||
}
|
||||
} else if tradeStatus == "CANCELED" {
|
||||
if !paySolveController.SolvePayFail(orderInfo, "cancel") {
|
||||
logs.Error("solve order cancel fail")
|
||||
}
|
||||
} else if tradeStatus == "WAITING_PAYMENT" {
|
||||
logs.Notice("快付回调,该订单还处于等待支付,订单id=", orderNo)
|
||||
} else if tradeStatus == "SUCCESS" {
|
||||
//订单支付成功,需要搞很多事情 TODO
|
||||
paySolveController.SolvePaySuccess(orderInfo.BankOrderId, orderInfo.FactAmount, c.GetString("trxNo"))
|
||||
}
|
||||
c.Ctx.WriteString("success")
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) PayQuery(orderInfo models.OrderInfo) bool {
|
||||
if orderInfo.Status != "wait" && orderInfo.Status != "" {
|
||||
logs.Error("订单已经被处理,不需要查询,bankOrderId:", orderInfo.BankOrderId)
|
||||
return false
|
||||
}
|
||||
params := make(map[string]string)
|
||||
params["orderNo"] = orderInfo.BankOrderId
|
||||
params["payKey"] = KF_PAY_KEY
|
||||
paySecret := KF_PAY_SECRET
|
||||
keys := utils.SortMap(params)
|
||||
params["sign"] = utils.GetMD5Sign(params, keys, paySecret)
|
||||
req := httplib.Get(KF_ORDER_QUERY)
|
||||
for k, v := range params {
|
||||
req.Param(k, v)
|
||||
}
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
logs.Error("快付订单查询失败,bankOrderId: ", orderInfo.BankOrderId)
|
||||
logs.Error("err: ", err)
|
||||
return false
|
||||
}
|
||||
statusCode := gojson.Json(response).Get("statusCode").Tostring()
|
||||
if statusCode != "00" {
|
||||
logs.Error("快付订单查询返回失败,bankOrderId:", orderInfo.BankOrderId)
|
||||
logs.Error("err: ", response)
|
||||
return false
|
||||
}
|
||||
//获取用户的实际支付金额
|
||||
orderPrice := gojson.Json(response).Get("orderPrice").Tostring()
|
||||
factAmount, err := strconv.ParseFloat(orderPrice, 64)
|
||||
if err != nil {
|
||||
logs.Error("快速查询得到的实际金额错误, orderPrice=", orderPrice)
|
||||
}
|
||||
|
||||
//orderInfo.FactAmount = orderInfo.OrderAmount
|
||||
tradeStatus := gojson.Json(response).Get("tradeStatus").Tostring()
|
||||
paySolveController := new(PaySolveController)
|
||||
trxNo := gojson.Json(response).Get("trxNo").Tostring()
|
||||
if tradeStatus == "SUCCESS" {
|
||||
//调用支付成功的接口,做加款更新操作,需要把实际支付金额传入
|
||||
if !paySolveController.SolvePaySuccess(orderInfo.BankOrderId, factAmount, trxNo) {
|
||||
return false
|
||||
}
|
||||
} else if tradeStatus == "FAILED" {
|
||||
if !paySolveController.SolvePayFail(orderInfo, "fail") {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
logs.Info("订单状态处于:" + tradeStatus + ";bankOrderId:" + orderInfo.BankOrderId)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) PayFor(payFor models.PayforInfo) string {
|
||||
params := make(map[string]string)
|
||||
params["merchantKey"] = KF_PAY_KEY
|
||||
params["realname"] = payFor.BankAccountName
|
||||
params["cardNo"] = payFor.BankAccountNo
|
||||
params["bankCode"] = payFor.BankCode
|
||||
if payFor.BankAccountType == common.PRIVATE {
|
||||
params["accType"] = "01"
|
||||
} else {
|
||||
params["accType"] = "02"
|
||||
}
|
||||
params["province"] = payFor.BankAccountAddress
|
||||
params["city"] = payFor.BankAccountAddress
|
||||
params["bankAccountAddress"] = payFor.BankAccountAddress
|
||||
//将float64转为字符串
|
||||
params["amount"] = strconv.FormatFloat(payFor.PayforAmount, 'f', 2, 64)
|
||||
params["moblieNo"] = payFor.PhoneNo
|
||||
params["merchantOrderId"] = payFor.BankOrderId
|
||||
keys := utils.SortMap(params)
|
||||
sign := utils.GetMD5Sign(params, keys, KF_PAY_SECRET)
|
||||
params["sign"] = sign
|
||||
req := httplib.Post(KF_PAYFOR_HOST)
|
||||
for k, v := range params {
|
||||
req.Param(k, v)
|
||||
}
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
logs.Error("快付代付返回错误结果: ", response)
|
||||
} else {
|
||||
json := gojson.Json(response)
|
||||
resultCode := json.Get("resultCode").Tostring()
|
||||
resultMsg := json.Get("resultMsg").Tostring()
|
||||
if resultCode != "00" {
|
||||
logs.Error("快付代付返回错误信息:", resultMsg)
|
||||
return "fail"
|
||||
}
|
||||
settStatus := json.Get("settStatus").Tostring()
|
||||
if settStatus == "00" {
|
||||
logs.Info(fmt.Sprintf("代付uid=%s,已经成功发送给了上游处理", payFor.PayforUid))
|
||||
} else if settStatus == "01" {
|
||||
logs.Info(fmt.Sprintf("代付uid=%s,发送失败", payFor.PayforUid))
|
||||
}
|
||||
}
|
||||
return "success"
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) PayForNotify() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) PayForQuery(payFor models.PayforInfo) (string, string) {
|
||||
params := make(map[string]string)
|
||||
params["merchantKey"] = KF_PAY_KEY
|
||||
params["timestamp"] = utils.GetNowTimesTamp()
|
||||
params["merchantOrderId"] = payFor.BankOrderId
|
||||
keys := utils.SortMap(params)
|
||||
sign := utils.GetMD5Sign(params, keys, KF_PAY_SECRET)
|
||||
params["sign"] = sign
|
||||
req := httplib.Get(KF_PAYFOR_QUERY)
|
||||
for k, v := range params {
|
||||
req.Param(k, v)
|
||||
}
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
logs.Error("快付代付查询失败:", err)
|
||||
return common.PAYFOR_SOLVING, "查询失败"
|
||||
}
|
||||
|
||||
payFor.ResponseContext = response
|
||||
payFor.ResponseTime = utils.GetBasicDateTime()
|
||||
payFor.UpdateTime = utils.GetBasicDateTime()
|
||||
if !models.UpdatePayFor(payFor) {
|
||||
logs.Error("更新快付代付订单状态失败")
|
||||
}
|
||||
|
||||
resultCode := gojson.Json(response).Get("resultCode").Tostring()
|
||||
resultMsg := gojson.Json(response).Get("resultMsg").Tostring()
|
||||
|
||||
if resultCode != "00" {
|
||||
logs.Error("快付代付查询返回错误:", resultMsg)
|
||||
return common.PAYFOR_SOLVING, resultMsg
|
||||
}
|
||||
|
||||
logs.Info("快付代付查询返回结果:", resultMsg)
|
||||
|
||||
merchantOrderId := gojson.Json(response).Get("merchantOrderId").Tostring()
|
||||
if merchantOrderId != payFor.BankOrderId {
|
||||
logs.Error("快付代付返回结果,订单id不一致: ", merchantOrderId)
|
||||
return common.PAYFOR_SOLVING, "快付代付返回结果,订单id不一致"
|
||||
}
|
||||
|
||||
settStatus := gojson.Json(response).Get("settStatus").Tostring()
|
||||
|
||||
if settStatus == "00" {
|
||||
return common.PAYFOR_SUCCESS, "代付成功"
|
||||
} else if settStatus == "01" {
|
||||
return common.PAYFOR_FAIL, "代付失败"
|
||||
} else {
|
||||
return common.PAYFOR_BANKING, "银行处理中"
|
||||
}
|
||||
}
|
||||
|
||||
func (c *KuaiFuImpl) BalanceQuery(roadInfo models.RoadInfo) float64 {
|
||||
params := make(map[string]string)
|
||||
params["merchantKey"] = KF_PAY_KEY
|
||||
params["timestamp"] = utils.GetNowTimesTamp()
|
||||
params["merchantOrderId"] = xid.New().String()
|
||||
keys := utils.SortMap(params)
|
||||
sign := utils.GetMD5Sign(params, keys, KF_PAY_SECRET)
|
||||
params["sign"] = sign
|
||||
req := httplib.Get(KF_BALANCE_QUERY)
|
||||
for k, v := range params {
|
||||
req.Param(k, v)
|
||||
}
|
||||
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
logs.Error("快付余额查询失败,err: ", err)
|
||||
return 0.00
|
||||
}
|
||||
logs.Debug("快付余额查询返回:", response)
|
||||
|
||||
resultCode := gojson.Json(response).Get("resultCode").Tostring()
|
||||
resultMsg := gojson.Json(response).Get("resultMsg").Tostring()
|
||||
logs.Notice("快付返回信息:", resultMsg)
|
||||
|
||||
if resultCode != "00" {
|
||||
return 0.00
|
||||
}
|
||||
|
||||
balance := gojson.Json(response).Get("balance").Tostring()
|
||||
availableAmount := gojson.Json(response).Get("availableAmount").Tostring()
|
||||
|
||||
logs.Info(fmt.Sprintf("快付余额=%s,可用金额=%s", balance, availableAmount))
|
||||
|
||||
f, err := strconv.ParseFloat(availableAmount, 64)
|
||||
return f
|
||||
}
|
||||
203
boss/service/controller/order_settle.go
Normal file
203
boss/service/controller/order_settle.go
Normal file
@@ -0,0 +1,203 @@
|
||||
/***************************************************
|
||||
** @Desc : 订单结算,将订单上面的钱加入到账户余额中
|
||||
** @Time : 2019/11/22 11:34
|
||||
** @Author : yuebin
|
||||
** @File : order_settle
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/22 11:34
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"dongfeng/service/common"
|
||||
"dongfeng/service/models"
|
||||
"dongfeng/service/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
//订单结算,将那些支付成功的订单金额加入到商户账户的结算金额中
|
||||
func OrderSettle() {
|
||||
|
||||
params := make(map[string]string)
|
||||
params["is_allow_settle"] = common.YES
|
||||
params["is_complete_settle"] = common.NO
|
||||
orderSettleList := models.GetOrderSettleListByParams(params)
|
||||
for _, orderSettle := range orderSettleList {
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(orderSettle.BankOrderId)
|
||||
if !settle(orderSettle, orderProfitInfo) {
|
||||
logs.Error(fmt.Sprintf("结算订单bankOrderId=%s, 执行失败", orderSettle.BankOrderId))
|
||||
} else {
|
||||
logs.Info(fmt.Sprintf("结算订单bankOrderId=%s,执行成功", orderSettle.BankOrderId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func settle(orderSettle models.OrderSettleInfo, orderProfit models.OrderProfitInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
logs.Error(fmt.Sprintf("结算信息出了panic,错误信息:%s", err))
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
}(o)
|
||||
|
||||
tmpSettle := new(models.OrderSettleInfo)
|
||||
if err := o.Raw("select * from order_settle_info where bank_order_id=? for update", orderSettle.BankOrderId).QueryRow(tmpSettle); err != nil || tmpSettle == nil {
|
||||
logs.Error("获取tmpSettle失败,bankOrderId=%s", orderSettle.BankOrderId)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
tmpSettle.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpSettle.IsCompleteSettle = common.YES
|
||||
if _, err := o.Update(tmpSettle); err != nil {
|
||||
logs.Error("更新tmpSettle失败,错误:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
accountInfo := new(models.AccountInfo)
|
||||
if err := o.Raw("select * from account_info where account_uid=? for update", orderSettle.MerchantUid).QueryRow(accountInfo); err != nil || accountInfo == nil {
|
||||
logs.Error("结算select account info失败,错误信息:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
accountInfo.SettleAmount += orderProfit.FactAmount
|
||||
if _, err := o.Update(accountInfo); err != nil {
|
||||
logs.Error("结算update account 失败,错误信息:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
merchantDeployInfo := models.GetMerchantDeployByUidAndPayType(accountInfo.AccountUid, orderSettle.PayTypeCode)
|
||||
if merchantDeployInfo.IsLoan == common.YES {
|
||||
loadAmount := merchantDeployInfo.LoanRate * 0.01 * orderProfit.FactAmount
|
||||
date := utils.GetDate()
|
||||
params := make(map[string]string)
|
||||
params["merchant_uid"] = tmpSettle.MerchantUid
|
||||
params["road_uid"] = tmpSettle.RoadUid
|
||||
params["load_date"] = date
|
||||
if !models.IsExistMerchantLoadByParams(params) {
|
||||
tmp := models.MerchantLoadInfo{Status: common.NO, MerchantUid: orderSettle.MerchantUid, RoadUid: orderSettle.RoadUid,
|
||||
LoadDate: date, LoadAmount: loadAmount, UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
if _, err := o.Insert(tmp); err != nil {
|
||||
logs.Error("結算插入merchantLoad失敗,失败信息:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
} else {
|
||||
logs.Info("结算插入新的merchantLoad信息成功")
|
||||
}
|
||||
} else {
|
||||
merchantLoad := new(models.MerchantLoadInfo)
|
||||
if err := o.Raw("select * from merchant_load_info where merchant_uid=? and road_uid=? and load_date=? for update").
|
||||
QueryRow(merchantLoad); err != nil || merchantLoad == nil {
|
||||
logs.Error(fmt.Sprintf("结算过程,select merchant load info失败,错误信息:%s", err))
|
||||
o.Rollback()
|
||||
return false
|
||||
} else {
|
||||
merchantLoad.UpdateTime = utils.GetBasicDateTime()
|
||||
merchantLoad.LoadAmount += loadAmount
|
||||
if _, err := o.Update(merchantLoad); err != nil {
|
||||
logs.Error(fmt.Sprintf("结算过程,update merchant load info失败,失败信息:%s", err))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logs.Info(fmt.Sprintf("结算过程中,该商户不需要押款,全款结算"))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/*
|
||||
* 商户的押款释放处理,根据商户的押款时间进行处理
|
||||
*/
|
||||
func MerchantLoadSolve() {
|
||||
hour := time.Now().Hour()
|
||||
merchantDeployList := models.GetMerchantDeployByHour(hour)
|
||||
for _, merchantDeploy := range merchantDeployList {
|
||||
logs.Info(fmt.Sprintf("开始执行商户uid=%s,进行解款操作", merchantDeploy.MerchantUid))
|
||||
|
||||
loadDate := utils.GetDateBeforeDays(merchantDeploy.LoanDays)
|
||||
params := make(map[string]string)
|
||||
params["status"] = common.NO
|
||||
params["merchant_uid"] = merchantDeploy.MerchantUid
|
||||
params["load_date"] = loadDate
|
||||
|
||||
merchantLoadList := models.GetMerchantLoadInfoByMap(params)
|
||||
for _, merchantLoad := range merchantLoadList {
|
||||
if MerchantAbleAmount(merchantLoad) {
|
||||
logs.Info(fmt.Sprintf("商户uid=%s,押款金额=%f,押款通道=%s, 解款成功", merchantLoad.MerchantUid, merchantLoad.LoadAmount, merchantLoad.RoadUid))
|
||||
} else {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,押款金额=%f,押款通道=%s, 解款失败", merchantLoad.MerchantUid, merchantLoad.LoadAmount, merchantLoad.RoadUid))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 对应的商户的账户可用金额进行调整操作
|
||||
*/
|
||||
func MerchantAbleAmount(merchantLoad models.MerchantLoadInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
logs.Error(fmt.Sprintf("解款操作出现了painc,错误信息:%s", err))
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
}(o)
|
||||
|
||||
tmpLoad := new(models.MerchantLoadInfo)
|
||||
if err := o.Raw("select * from merchant_load_info where merchant_uid=? and road_uid=? and load_date=? for update",
|
||||
merchantLoad.MerchantUid, merchantLoad.RoadUid, merchantLoad.LoadDate).QueryRow(tmpLoad); err != nil || tmpLoad == nil {
|
||||
logs.Error(fmt.Sprintf("解款操作获取商户押款信息失败,fail: %s", err))
|
||||
o.Rollback()
|
||||
return false
|
||||
|
||||
}
|
||||
if tmpLoad.Status != common.NO {
|
||||
logs.Error(fmt.Sprintf("押款信息merchantuid=%s,通道uid=%s, 押款日期=%s,已经解款过,不需要再进行处理了", tmpLoad.MerchantUid, tmpLoad.RoadUid, tmpLoad.LoadDate))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
tmpLoad.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpLoad.Status = common.YES
|
||||
if _, err := o.Update(tmpLoad); err != nil {
|
||||
logs.Error(fmt.Sprintf("解款操作更新merchant load info 失败:%s", err))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
accountInfo := new(models.AccountInfo)
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if accountInfo.LoanAmount >= tmpLoad.LoadAmount {
|
||||
accountInfo.LoanAmount -= tmpLoad.LoadAmount
|
||||
} else {
|
||||
accountInfo.LoanAmount = common.ZERO
|
||||
}
|
||||
|
||||
if _, err := o.Update(accountInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("解款操作更新account info 失败:%s,账户uid=%s", err, accountInfo.AccountUid))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error(fmt.Sprintf("解款操作commint事务失败,账号uid=%s,错误信息=%s", accountInfo.AccountUid, err))
|
||||
} else {
|
||||
logs.Info(fmt.Sprintf("账户uid=%s,通道uid=%s,押款日期=%s,解款操作成功", accountInfo.AccountUid, tmpLoad.RoadUid, tmpLoad.LoadDate))
|
||||
}
|
||||
return true
|
||||
}
|
||||
539
boss/service/controller/pay_solve.go
Normal file
539
boss/service/controller/pay_solve.go
Normal file
@@ -0,0 +1,539 @@
|
||||
/***************************************************
|
||||
** @Desc : 处理订单状态,用户加款等核心业务
|
||||
** @Time : 2019/10/31 11:44
|
||||
** @Author : yuebin
|
||||
** @File : pay_solve
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/31 11:44
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"dongfeng/service/common"
|
||||
"dongfeng/service/message_queue"
|
||||
"dongfeng/service/models"
|
||||
"dongfeng/service/utils"
|
||||
url2 "net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type PaySolveController struct {
|
||||
}
|
||||
|
||||
//处理支付成功的加款等各项操作
|
||||
func (c *PaySolveController) SolvePaySuccess(bankOrderId string, factAmount float64, trxNo string) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if r := recover(); r != nil {
|
||||
o.Rollback()
|
||||
logs.Error("SolvePaySuccess fail, call rollback")
|
||||
}
|
||||
}(o)
|
||||
|
||||
var orderInfo models.OrderInfo
|
||||
if err := o.Raw("select * from order_info where bank_order_id = ? for update", bankOrderId).QueryRow(&orderInfo); err != nil || orderInfo.BankOrderId == "" {
|
||||
o.Rollback()
|
||||
logs.Error("不存在该订单,或者select for update出错")
|
||||
return false
|
||||
}
|
||||
|
||||
if orderInfo.Status != "wait" {
|
||||
o.Rollback()
|
||||
logs.Error("该订单已经处理,订单号=", bankOrderId)
|
||||
return false
|
||||
}
|
||||
|
||||
if factAmount <= common.ZERO {
|
||||
factAmount = orderInfo.OrderAmount
|
||||
}
|
||||
|
||||
var orderProfitInfo models.OrderProfitInfo
|
||||
if err := o.Raw("select * from order_profit_info where bank_order_id = ? for update", bankOrderId).QueryRow(&orderProfitInfo); err != nil || orderProfitInfo.BankOrderId == "" {
|
||||
logs.Error("select order_profit_info for update fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if orderProfitInfo.BankOrderId == "" {
|
||||
logs.Error("solve pay success, get orderProfit fail, bankOrderId = ", bankOrderId)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
comp := c.CompareOrderAndFactAmount(factAmount, orderInfo)
|
||||
//如果实际支付金额比订单金额大或者小,那么重新按照实际金额金额利润计算
|
||||
if comp != 0 {
|
||||
orderProfitInfo.FactAmount = factAmount
|
||||
orderProfitInfo.SupplierProfit = orderInfo.FactAmount * orderProfitInfo.SupplierRate
|
||||
orderProfitInfo.PlatformProfit = orderInfo.FactAmount * orderProfitInfo.PlatformRate
|
||||
orderProfitInfo.AgentProfit = orderInfo.FactAmount * orderProfitInfo.AgentRate
|
||||
orderProfitInfo.AllProfit = orderProfitInfo.SupplierProfit + orderProfitInfo.PlatformProfit + orderProfitInfo.AgentProfit
|
||||
orderProfitInfo.UserInAmount = orderProfitInfo.FactAmount - orderProfitInfo.AllProfit
|
||||
orderProfitInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
orderInfo.FactAmount = factAmount
|
||||
//如果实际支付金额跟订单金额有出入,那么需要重新更新利润记录
|
||||
if _, err := o.Update(orderProfitInfo); err != nil {
|
||||
logs.Info("solve pay success fail:", err)
|
||||
}
|
||||
}
|
||||
|
||||
orderInfo.Status = common.SUCCESS
|
||||
orderInfo.BankTransId = trxNo
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := o.Update(&orderInfo); err != nil || orderInfo.BankOrderId == "" {
|
||||
logs.Error(fmt.Sprintf("solve pay success, update order info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//插入一条待结算记录
|
||||
settAmount := orderProfitInfo.FactAmount - orderProfitInfo.SupplierProfit - orderProfitInfo.PlatformProfit - orderProfitInfo.AgentProfit
|
||||
if settAmount <= 0.00 {
|
||||
logs.Error(fmt.Sprintf("订单id=%s,计算利润存在异常", bankOrderId))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
orderSettleInfo := models.OrderSettleInfo{PayTypeCode: orderInfo.PayTypeCode, PayProductCode: orderInfo.PayProductCode, RoadUid: orderInfo.RoadUid,
|
||||
PayProductName: orderInfo.PayProductName, PayTypeName: orderInfo.PayTypeName, MerchantUid: orderInfo.MerchantUid, MerchantOrderId: orderInfo.MerchantOrderId,
|
||||
MerchantName: orderInfo.MerchantName, BankOrderId: bankOrderId, SettleAmount: settAmount, IsAllowSettle: common.YES,
|
||||
IsCompleteSettle: common.NO, UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if _, err := o.Insert(&orderSettleInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success,insert order settle info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//做账户的加款操作,最重要的一部
|
||||
var accountInfo models.AccountInfo
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", orderInfo.MerchantUid).QueryRow(&accountInfo); err != nil || accountInfo.AccountUid == "" {
|
||||
logs.Error(fmt.Sprintf("solve pay success, raw account info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
if _, err := o.QueryTable(models.ACCOUNT_INFO).Filter("account_uid", orderInfo.MerchantUid).
|
||||
Update(orm.Params{"balance": accountInfo.Balance + settAmount, "wait_amount": accountInfo.WaitAmount + settAmount}); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success, update account info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//添加一条动账记录
|
||||
accountHistory := models.AccountHistoryInfo{AccountUid: orderInfo.MerchantUid, AccountName: orderInfo.MerchantName,
|
||||
Type: common.PLUS_AMOUNT, Amount: settAmount, Balance: accountInfo.Balance + settAmount,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
if _, err := o.Insert(&accountHistory); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success,insert account history fail:%s, bankOrderId = %s", err, bankOrderId))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//更新通道信息
|
||||
roadInfo := models.GetRoadInfoByRoadUid(orderInfo.RoadUid)
|
||||
roadInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
roadInfo.RequestSuccess += 1
|
||||
roadInfo.TotalIncome += orderInfo.FactAmount
|
||||
roadInfo.TodayIncome += orderInfo.FactAmount
|
||||
roadInfo.TodayProfit += orderProfitInfo.PlatformProfit + orderProfitInfo.AgentProfit
|
||||
roadInfo.TotalProfit += orderProfitInfo.PlatformProfit + orderProfitInfo.AgentProfit
|
||||
roadInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := o.Update(&roadInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success, update road info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//更新订单利润表
|
||||
orderProfitInfo.Status = common.SUCCESS
|
||||
orderProfitInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := o.Update(&orderProfitInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success, update order profit info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error(fmt.Sprintf("订单bankOrderId = %s,加款失败!", bankOrderId))
|
||||
logs.Error("失败原因:", err)
|
||||
return false
|
||||
} else {
|
||||
logs.Info("账户加款成功,并记录了账户历史!")
|
||||
//如果处理成功,发送到消息队列,进行商户的回调操作
|
||||
go c.CreateOrderNotifyInfo(orderInfo, common.SUCCESS)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
//处理支付失败
|
||||
func (c *PaySolveController) SolvePayFail(orderInfo models.OrderInfo, str string) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if r := recover(); r != nil {
|
||||
o.Rollback()
|
||||
logs.Error("SolvePaySuccess fail, call rollback")
|
||||
}
|
||||
}(o)
|
||||
|
||||
var orderTmp models.OrderInfo
|
||||
bankOrderId := orderInfo.BankOrderId
|
||||
if err := o.Raw("select * from order_info where bank_order_id = ?", bankOrderId).QueryRow(&orderTmp); err != nil || orderTmp.BankOrderId == "" {
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if orderTmp.Status != "wait" {
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
_, err1 := o.QueryTable(models.ORDER_INFO).Filter("bank_order_id", bankOrderId).Update(orm.Params{"status": str, "bank_trans_id": orderInfo.BankTransId})
|
||||
_, err2 := o.QueryTable(models.ORDER_PROFIT_INFO).Filter("bank_order_id", bankOrderId).Update(orm.Params{"status": str, "bank_trans_id": orderInfo.BankTransId})
|
||||
if err1 != nil || err2 != nil {
|
||||
logs.Error("SolvePayFail fail: ", err1, err2)
|
||||
o.Rollback()
|
||||
return false
|
||||
} else {
|
||||
o.Commit()
|
||||
go c.CreateOrderNotifyInfo(orderInfo, common.FAIL)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
//处理订单冻结
|
||||
func (c *PaySolveController) SolveOrderFreeze(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
}(o)
|
||||
|
||||
var orderInfo models.OrderInfo
|
||||
if err := o.Raw("select * from order_info where bank_order_id = ? for update", bankOrderId).QueryRow(&orderInfo); err != nil || orderInfo.BankOrderId == "" {
|
||||
logs.Error("solve order freeze 不存在这样的订单记录,bankOrderId = ", bankOrderId)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if orderInfo.Status != common.SUCCESS {
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
orderInfo.Freeze = common.YES
|
||||
orderInfo.FreezeTime = utils.GetBasicDateTime()
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := o.Update(&orderInfo); err != nil {
|
||||
logs.Error("solve order freeze fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//账户的冻结金额里面加入相应的金额
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
var accountInfo models.AccountInfo
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", orderInfo.MerchantUid).QueryRow(&accountInfo); err != nil || accountInfo.AccountUid == "" {
|
||||
logs.Error(fmt.Sprintf("solve pay fail select acount fail:%s", err))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount + orderProfitInfo.UserInAmount
|
||||
if _, err := o.Update(&accountInfo); err != nil {
|
||||
logs.Error("solve order freeze fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
//插入一条动账记录
|
||||
accountHistoryInfo := models.AccountHistoryInfo{AccountName: accountInfo.AccountName, AccountUid: accountInfo.AccountUid,
|
||||
Type: common.FREEZE_AMOUNT, Amount: orderProfitInfo.UserInAmount, Balance: accountInfo.Balance, UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
if _, err := o.Insert(&accountHistoryInfo); err != nil {
|
||||
logs.Error("solve order freeze fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("SolveOrderFreeze fail")
|
||||
} else {
|
||||
logs.Info("冻结处理成功")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
//订单解冻
|
||||
func (c *PaySolveController) SolveOrderUnfreeze(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
}(o)
|
||||
|
||||
orderInfo := new(models.OrderInfo)
|
||||
if err := o.Raw("select * from order_info where bank_order_id = ? for update", bankOrderId).QueryRow(orderInfo); err != nil || orderInfo.BankOrderId == "" {
|
||||
logs.Error("solve order unfreeze 不存在这样的订单记录,bankOrderId = ", bankOrderId)
|
||||
return false
|
||||
}
|
||||
|
||||
orderInfo.Freeze = ""
|
||||
orderInfo.Unfreeze = common.YES
|
||||
orderInfo.UnfreezeTime = utils.GetBasicDateTime()
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := o.Update(orderInfo); err != nil {
|
||||
logs.Error("solve order unfreeze fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
|
||||
accountInfo := new(models.AccountInfo)
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", orderInfo.MerchantUid).QueryRow(accountInfo); err != nil || accountInfo.AccountUid == "" {
|
||||
logs.Error(fmt.Sprintf("unfreeze select account fail: %s", err))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount - orderProfitInfo.UserInAmount
|
||||
|
||||
if _, err := o.Update(accountInfo); err != nil {
|
||||
logs.Error("solve order unfreeze fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
accountHistoryInfo := models.AccountHistoryInfo{AccountUid: accountInfo.AccountUid, AccountName: accountInfo.AccountName, Type: common.UNFREEZE_AMOUNT,
|
||||
Amount: orderProfitInfo.UserInAmount, Balance: accountInfo.Balance, UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if _, err := o.Insert(&accountHistoryInfo); err != nil {
|
||||
logs.Error("solve order unfreeze fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error(fmt.Sprintf("unfreeze commit fail: %s", err))
|
||||
return false
|
||||
} else {
|
||||
logs.Info("解冻成功")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *PaySolveController) SolveRefund(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
}(o)
|
||||
|
||||
orderInfo := new(models.OrderInfo)
|
||||
if err := o.Raw("select * from order_info where bank_order_id = ? for update", bankOrderId).QueryRow(orderInfo); err != nil || orderInfo.BankOrderId == "" {
|
||||
logs.Error("solve refund 不存在这样的订单,bankOrderId = " + bankOrderId)
|
||||
return false
|
||||
}
|
||||
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
orderInfo.Refund = common.YES
|
||||
orderInfo.RefundTime = utils.GetBasicDateTime()
|
||||
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
account := new(models.AccountInfo)
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", orderInfo.MerchantUid).QueryRow(account); err != nil || account.AccountUid == "" {
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
account.SettleAmount = account.SettleAmount - orderProfitInfo.UserInAmount
|
||||
account.Balance = account.Balance - orderProfitInfo.UserInAmount
|
||||
|
||||
if orderInfo.Freeze == common.YES {
|
||||
account.FreezeAmount = account.FreezeAmount - orderProfitInfo.UserInAmount
|
||||
if account.FreezeAmount < 0 {
|
||||
account.FreezeAmount = common.ZERO
|
||||
}
|
||||
orderInfo.Freeze = ""
|
||||
}
|
||||
|
||||
if _, err := o.Update(orderInfo); err != nil {
|
||||
logs.Error("solve order refund update order info fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
if _, err := o.Update(account); err != nil {
|
||||
logs.Error("solve order refund update account fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
accountHistoryInfo := models.AccountHistoryInfo{AccountName: account.AccountName, AccountUid: account.AccountUid,
|
||||
Type: common.REFUND, Amount: orderProfitInfo.UserInAmount, Balance: account.Balance,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if _, err := o.Insert(&accountHistoryInfo); err != nil {
|
||||
logs.Error("solve order refund insert account history fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("退款处理失败,fail: ", err)
|
||||
} else {
|
||||
logs.Info("退款处理成功")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *PaySolveController) SolveOrderRoll(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
}(o)
|
||||
|
||||
orderInfo := new(models.OrderInfo)
|
||||
|
||||
if err := o.Raw("select * from order_info where bank_order_id = ? for update", bankOrderId).QueryRow(orderInfo); err != nil {
|
||||
logs.Error("solve order roll fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if orderInfo.Status != common.SUCCESS {
|
||||
logs.Error("solve order roll 订单不存在或者订单状态不是success, bankOrderId=", bankOrderId)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
|
||||
account := new(models.AccountInfo)
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", orderInfo.MerchantUid).QueryRow(account); err != nil || account.AccountUid == "" {
|
||||
logs.Error("solve order roll get account is nil, accountUid = ", orderInfo.MerchantUid)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if orderInfo.Refund == common.YES {
|
||||
account.Balance = account.Balance + orderProfitInfo.UserInAmount
|
||||
account.SettleAmount = account.SettleAmount + orderProfitInfo.UserInAmount
|
||||
orderInfo.Refund = common.NO
|
||||
}
|
||||
|
||||
if _, err := o.Update(orderInfo); err != nil {
|
||||
logs.Error("solve order roll fail update order info fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
if _, err := o.Update(account); err != nil {
|
||||
logs.Error("solve order roll update account fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
accountHistoryInfo := models.AccountHistoryInfo{AccountUid: account.AccountUid, AccountName: account.AccountName,
|
||||
Type: common.PLUS_AMOUNT, Amount: orderProfitInfo.UserInAmount, Balance: account.Balance,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
if _, err := o.Insert(&accountHistoryInfo); err != nil {
|
||||
logs.Error("solve order roll insert account history fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("处理订单回滚失败,fail: ", err)
|
||||
} else {
|
||||
logs.Info("处理订单回滚成功")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
//比较订单金额和实际支付金额的大小
|
||||
func (c *PaySolveController) CompareOrderAndFactAmount(factAmount float64, orderInfo models.OrderInfo) int {
|
||||
orderAmount := orderInfo.OrderAmount
|
||||
//将金额放大1000倍
|
||||
oa := int64(orderAmount * 1000)
|
||||
fa := int64(factAmount * 1000)
|
||||
if oa > fa {
|
||||
//如果实际金额大,返回1
|
||||
return 1
|
||||
} else if oa == fa {
|
||||
return 0
|
||||
} else {
|
||||
return 2
|
||||
}
|
||||
}
|
||||
|
||||
//支付完成后,处理给商户的回调信息
|
||||
func (c *PaySolveController) CreateOrderNotifyInfo(orderInfo models.OrderInfo, tradeStatus string) {
|
||||
|
||||
notifyInfo := new(models.NotifyInfo)
|
||||
notifyInfo.Type = "order"
|
||||
notifyInfo.BankOrderId = orderInfo.BankOrderId
|
||||
notifyInfo.MerchantOrderId = orderInfo.MerchantOrderId
|
||||
notifyInfo.Status = "wait"
|
||||
notifyInfo.Times = 0
|
||||
notifyInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
notifyInfo.CreateTime = utils.GetBasicDateTime()
|
||||
|
||||
merchantInfo := models.GetMerchantByUid(orderInfo.MerchantUid)
|
||||
|
||||
params := make(map[string]string)
|
||||
params["orderNo"] = orderInfo.MerchantOrderId
|
||||
params["orderPrice"] = strconv.FormatFloat(orderInfo.OrderAmount, 'f', 2, 64)
|
||||
params["factPrice"] = strconv.FormatFloat(orderInfo.FactAmount, 'f', 2, 64)
|
||||
params["orderTime"] = utils.GetDateTimeNot()
|
||||
|
||||
if orderInfo.BankTransId != "" {
|
||||
params["trxNo"] = orderInfo.BankTransId
|
||||
} else {
|
||||
params["trxNo"] = orderInfo.BankOrderId
|
||||
}
|
||||
params["statusCode"] = "00"
|
||||
params["tradeStatus"] = tradeStatus
|
||||
params["payKey"] = merchantInfo.MerchantKey
|
||||
|
||||
params["sign"] = utils.GetMD5Sign(params, utils.SortMap(params), merchantInfo.MerchantSecret)
|
||||
|
||||
url := url2.Values{}
|
||||
for k, v := range params {
|
||||
url.Add(k, v)
|
||||
}
|
||||
|
||||
notifyInfo.Url = orderInfo.NotifyUrl + "?" + url.Encode()
|
||||
|
||||
if models.InsertNotifyInfo(*notifyInfo) {
|
||||
logs.Info(fmt.Sprintf("订单bankOrderId=%s,已经将回调地址插入数据库", orderInfo.BankOrderId))
|
||||
} else {
|
||||
logs.Error(fmt.Sprintf("订单bankOrderId=%s,插入回调数据库失败", orderInfo.BankOrderId))
|
||||
}
|
||||
//将订单发送到消息队列,给下面的商户进行回调
|
||||
message_queue.SendMessage(common.MqOrderNotify, orderInfo.BankOrderId)
|
||||
}
|
||||
393
boss/service/controller/payfor_solve.go
Normal file
393
boss/service/controller/payfor_solve.go
Normal file
@@ -0,0 +1,393 @@
|
||||
/***************************************************
|
||||
** @Desc : 代付处理
|
||||
** @Time : 2019/11/28 18:52
|
||||
** @Author : yuebin
|
||||
** @File : payfor_solve
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/28 18:52
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"dongfeng/service/common"
|
||||
"dongfeng/service/message_queue"
|
||||
"dongfeng/service/models"
|
||||
"dongfeng/service/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func PayForFail(payFor models.PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
logs.Error("pay for fail,rollback....")
|
||||
o.Rollback()
|
||||
}
|
||||
return
|
||||
}(o)
|
||||
|
||||
var tmpForPay models.PayforInfo
|
||||
if err := o.Raw("select * from payfor_info where bank_order_id = ? for update", payFor.BankOrderId).QueryRow(&tmpForPay); err != nil || tmpForPay.PayforUid == "" {
|
||||
logs.Error("solve pay fail select fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if tmpForPay.Status == common.PAYFOR_FAIL || tmpForPay.Status == common.PAYFOR_SUCCESS {
|
||||
logs.Error(fmt.Sprintf("该代付订单uid=%s,状态已经是最终结果", payFor.PayforUid))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
//更新payfor记录的状态
|
||||
tmpForPay.Status = common.PAYFOR_FAIL
|
||||
tmpForPay.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := o.Update(&tmpForPay); err != nil {
|
||||
logs.Error("PayForFail update payfor_info fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
var account models.AccountInfo
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", payFor.MerchantUid).QueryRow(&account); err != nil || account.AccountUid == "" {
|
||||
logs.Error("payfor select account fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if account.PayforAmount < (payFor.PayforAmount + payFor.PayforFee) {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,账户中待代付金额小于代付记录的金额", payFor.MerchantUid))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
//将正在打款中的金额减去
|
||||
account.PayforAmount = account.PayforAmount - payFor.PayforAmount - payFor.PayforFee
|
||||
|
||||
if _, err := o.Update(&account); err != nil {
|
||||
logs.Error("PayForFail update account fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("代付失败处理出错,fail:", err)
|
||||
} else {
|
||||
logs.Info("代付处理成功")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func PayForSuccess(payFor models.PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
logs.Error("pay for success,rollback....")
|
||||
o.Rollback()
|
||||
}
|
||||
return
|
||||
}(o)
|
||||
|
||||
var tmpPayFor models.PayforInfo
|
||||
if err := o.Raw("select * from payfor_info where bank_order_id = ? for update", payFor.BankOrderId).QueryRow(&tmpPayFor); err != nil || tmpPayFor.PayforUid == "" {
|
||||
logs.Error("payfor success select payfor fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
if tmpPayFor.Status == common.PAYFOR_FAIL || tmpPayFor.Status == common.PAYFOR_SUCCESS {
|
||||
logs.Error(fmt.Sprintf("该代付订单uid=%s,已经是最终结果,不需要处理", payFor.PayforUid))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpPayFor.Status = common.PAYFOR_SUCCESS
|
||||
_, err := o.Update(&tmpPayFor)
|
||||
if err != nil {
|
||||
logs.Error("PayForSuccess update payfor fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
var account models.AccountInfo
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", payFor.MerchantUid).QueryRow(&account); err != nil || account.AccountUid == "" {
|
||||
logs.Error("payfor success select account fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if account.PayforAmount < (payFor.PayforAmount + payFor.PayforFee) {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,账户中待代付金额小于代付记录的金额", payFor.MerchantUid))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//代付打款中的金额减去
|
||||
account.PayforAmount = account.PayforAmount - payFor.PayforAmount - payFor.PayforFee
|
||||
//减去余额,减去可用金额
|
||||
account.Balance = account.Balance - payFor.PayforAmount - payFor.PayforFee
|
||||
//已结算金额减去
|
||||
account.SettleAmount = account.SettleAmount - payFor.PayforAmount - payFor.PayforFee
|
||||
|
||||
if _, err := o.Update(&account); err != nil {
|
||||
logs.Error("PayForSuccess udpate account fail:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
//添加一条动账记录
|
||||
accountHistory := models.AccountHistoryInfo{AccountUid: payFor.MerchantUid, AccountName: payFor.MerchantName,
|
||||
Type: common.SUB_AMOUNT, Amount: payFor.PayforAmount + payFor.PayforFee, Balance: account.Balance,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
if _, err := o.Insert(&accountHistory); err != nil {
|
||||
logs.Error("PayForSuccess insert account history fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("代付成功处理失败,fail:", err)
|
||||
} else {
|
||||
logs.Info("代付处理成功")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/*
|
||||
* 自动审核代付订单
|
||||
*/
|
||||
func SolvePayForConfirm() {
|
||||
params := make(map[string]string)
|
||||
beforeOneDay := utils.GetDateTimeBeforeDays(1)
|
||||
nowDate := utils.GetBasicDateTime()
|
||||
params["create_time__lte"] = beforeOneDay
|
||||
params["create_time__gte"] = nowDate
|
||||
params["status"] = common.PAYFOR_COMFRIM
|
||||
payForList := models.GetPayForListByParams(params)
|
||||
for _, p := range payForList {
|
||||
if p.Type == common.SELF_HELP || p.Type == common.SELF_MERCHANT {
|
||||
//系统后台提交的,人工审核
|
||||
continue
|
||||
}
|
||||
//判断商户是否开通了自动代付功能
|
||||
merchant := models.GetMerchantByUid(p.MerchantUid)
|
||||
//判断商户是否开通了自动代付
|
||||
if merchant.AutoPayFor == common.NO || merchant.AutoPayFor == "" {
|
||||
logs.Notice(fmt.Sprintf("该商户uid=%s, 没有开通自动代付功能", p.MerchantUid))
|
||||
continue
|
||||
}
|
||||
//找自动代付通道
|
||||
findPayForRoad(p, merchant)
|
||||
}
|
||||
}
|
||||
|
||||
func findPayForRoad(payFor models.PayforInfo, merchant models.MerchantInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
|
||||
//检查是否单独填写了每笔代付的手续费
|
||||
if merchant.PayforFee > common.ZERO {
|
||||
logs.Info(fmt.Sprintf("商户uid=%s,有单独的代付手续费。", merchant.MerchantUid))
|
||||
payFor.PayforFee = merchant.PayforFee
|
||||
payFor.PayforTotalAmount = payFor.PayforFee + payFor.PayforAmount
|
||||
}
|
||||
|
||||
if merchant.SinglePayForRoadUid != "" {
|
||||
payFor.RoadUid = merchant.SinglePayForRoadUid
|
||||
payFor.RoadName = merchant.SinglePayForRoadName
|
||||
} else {
|
||||
//到轮询里面寻找代付通道
|
||||
if merchant.RollPayForRoadCode == "" {
|
||||
logs.Notice(fmt.Sprintf("该商户没有配置代付通道"))
|
||||
return false
|
||||
}
|
||||
roadPoolInfo := models.GetRoadPoolByRoadPoolCode(merchant.RollPayForRoadCode)
|
||||
roadUids := strings.Split(roadPoolInfo.RoadUidPool, "||")
|
||||
roadInfoList := models.GetRoadInfosByRoadUids(roadUids)
|
||||
if len(roadUids) == 0 || len(roadInfoList) == 0 {
|
||||
logs.Error(fmt.Sprintf("通道轮询池=%s, 没有配置通道", merchant.RollPayForRoadCode))
|
||||
return false
|
||||
}
|
||||
payFor.RoadUid = roadInfoList[0].RoadUid
|
||||
payFor.RoadName = roadInfoList[0].RoadName
|
||||
}
|
||||
|
||||
o.Begin()
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
}(o)
|
||||
|
||||
var tmpPayFor models.PayforInfo
|
||||
if err := o.Raw("select * from payfor_info where payfor_uid = ? for update", payFor.PayforUid).QueryRow(&tmpPayFor); err != nil || tmpPayFor.PayforUid == "" {
|
||||
logs.Error("find payfor road select payfor fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
if tmpPayFor.Status != common.PAYFOR_COMFRIM {
|
||||
logs.Notice(fmt.Sprintf("该代付记录uid=%s,已经被审核", payFor.PayforUid))
|
||||
return false
|
||||
}
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpPayFor.Status = common.PAYFOR_SOLVING
|
||||
tmpPayFor.GiveType = common.PAYFOR_ROAD
|
||||
if _, err := o.Update(&tmpPayFor); err != nil {
|
||||
logs.Error(fmt.Sprintf("该代付记录uid=%s,从审核更新为正在处理出错: %s", payFor.PayforUid, err))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("挑选代付通道失败,fail:", err)
|
||||
} else {
|
||||
logs.Info("挑选代付通道成功")
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/*
|
||||
* 执行逻辑
|
||||
*/
|
||||
func SolvePayFor() {
|
||||
//取出一天之内的没有做处理并且不是手动打款的代付记录
|
||||
params := make(map[string]string)
|
||||
beforeOneDay := utils.GetDateTimeBeforeDays(1)
|
||||
nowDate := utils.GetBasicDateTime()
|
||||
params["create_time__lte"] = nowDate
|
||||
params["create_time__gte"] = beforeOneDay
|
||||
params["is_send"] = "no"
|
||||
params["status"] = common.PAYFOR_SOLVING
|
||||
params["give_type"] = common.PAYFOR_ROAD
|
||||
|
||||
payForList := models.GetPayForListByParams(params)
|
||||
for _, p := range payForList {
|
||||
if p.Type == common.SELF_HELP {
|
||||
//如果后台管理人员,通过任意下发,不涉及到商户减款操作,直接发送代付请求
|
||||
solveSelf(p)
|
||||
} else {
|
||||
SendPayFor(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func solveSelf(payFor models.PayforInfo) {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
o.Rollback()
|
||||
}
|
||||
}(o)
|
||||
|
||||
var tmpPayFor models.PayforInfo
|
||||
if err := o.Raw("select * from payfor_info where payfor_uid = ? for update", payFor.PayforUid).QueryRow(&tmpPayFor); err != nil || tmpPayFor.PayforUid == "" {
|
||||
logs.Error("solve self payfor fail:", err)
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
if tmpPayFor.IsSend == common.YES {
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
if payFor.RoadUid == "" {
|
||||
tmpPayFor.Status = common.PAYFOR_FAIL
|
||||
} else {
|
||||
tmpPayFor.Status = common.PAYFOR_BANKING
|
||||
tmpPayFor.RequestTime = utils.GetBasicDateTime()
|
||||
tmpPayFor.IsSend = common.YES
|
||||
}
|
||||
_, err := o.Update(&tmpPayFor)
|
||||
if err != nil {
|
||||
o.Rollback()
|
||||
} else {
|
||||
o.Commit()
|
||||
RequestPayFor(payFor)
|
||||
}
|
||||
}
|
||||
|
||||
func SendPayFor(payFor models.PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
o.Rollback()
|
||||
return
|
||||
}
|
||||
}(o)
|
||||
|
||||
var tmpPayFor models.PayforInfo
|
||||
if err := o.Raw("select * from payfor_info where payfor_uid = ? for update", payFor.PayforUid).QueryRow(&tmpPayFor); err != nil || tmpPayFor.PayforUid == "" {
|
||||
logs.Error("send payfor select payfor fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
var account models.AccountInfo
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", payFor.MerchantUid).QueryRow(&account); err != nil || account.AccountUid == "" {
|
||||
logs.Error("send payfor select account fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//支付金额不足,将直接判定为失败,不往下面邹逻辑了
|
||||
if account.SettleAmount-account.PayforAmount < tmpPayFor.PayforAmount+tmpPayFor.PayforFee {
|
||||
tmpPayFor.Status = common.PAYFOR_FAIL
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
o.Update(&tmpPayFor)
|
||||
o.Commit()
|
||||
return false
|
||||
}
|
||||
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
account.PayforAmount = account.PayforAmount + payFor.PayforAmount + payFor.PayforFee
|
||||
|
||||
_, err := o.Update(&account)
|
||||
if err != nil {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,在发送代付给上游的处理中,更新账户表出错, err: %s", payFor.MerchantUid, err))
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
tmpPayFor.IsSend = common.YES
|
||||
tmpPayFor.Status = common.PAYFOR_BANKING //变为银行处理中
|
||||
tmpPayFor.RequestTime = utils.GetBasicDateTime()
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
_, err = o.Update(&tmpPayFor)
|
||||
if err != nil {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,在发送代付给上游的处理中,更代付列表出错, err:%s", payFor.MerchantUid, err))
|
||||
o.Rollback()
|
||||
return false
|
||||
} else {
|
||||
o.Commit()
|
||||
RequestPayFor(payFor)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func RequestPayFor(payFor models.PayforInfo) {
|
||||
if payFor.RoadUid == "" {
|
||||
return
|
||||
}
|
||||
roadInfo := models.GetRoadInfoByRoadUid(payFor.RoadUid)
|
||||
supplierCode := roadInfo.ProductUid
|
||||
supplier := GetPaySupplierByCode(supplierCode)
|
||||
res := supplier.PayFor(payFor)
|
||||
logs.Info(fmt.Sprintf("代付uid=%s,上游处理结果为:%s", payFor.PayforUid, res))
|
||||
//将代付订单号发送到消息队列
|
||||
message_queue.SendMessage(common.MQ_PAYFOR_QUERY, payFor.BankOrderId)
|
||||
}
|
||||
41
boss/service/controller/supplier_interface.go
Normal file
41
boss/service/controller/supplier_interface.go
Normal file
@@ -0,0 +1,41 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/28 9:39
|
||||
** @Author : yuebin
|
||||
** @File : supplier_interface
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/28 9:39
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
import (
|
||||
"dongfeng/service/models"
|
||||
)
|
||||
|
||||
//定义扫码支付的返回值
|
||||
type ScanData struct {
|
||||
Supplier string //上游的通道供应商
|
||||
PayType string //支付类型
|
||||
OrderNo string //下游商户请求订单号
|
||||
BankNo string //本系统的请求订单号
|
||||
OrderPrice string //订单金额
|
||||
FactPrice string //实际的展示在客户面前的金额
|
||||
Status string //状态码 '00' 成功
|
||||
PayUrl string //支付二维码链接地址
|
||||
Msg string //附加的信息
|
||||
}
|
||||
|
||||
type PayInterface interface {
|
||||
Scan(models.OrderInfo, models.RoadInfo, models.MerchantInfo) ScanData
|
||||
H5(models.OrderInfo, models.RoadInfo, models.MerchantInfo) ScanData
|
||||
Fast(models.OrderInfo, models.RoadInfo, models.MerchantInfo) bool
|
||||
Syt(models.OrderInfo, models.RoadInfo, models.MerchantInfo) ScanData
|
||||
Web(models.OrderInfo, models.RoadInfo, models.MerchantInfo) bool
|
||||
PayNotify()
|
||||
PayQuery(models.OrderInfo) bool
|
||||
PayFor(models.PayforInfo) string
|
||||
PayForNotify() string
|
||||
PayForQuery(models.PayforInfo) (string, string)
|
||||
BalanceQuery(models.RoadInfo) float64
|
||||
}
|
||||
70
boss/service/controller/weixin.go
Normal file
70
boss/service/controller/weixin.go
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/28 16:38
|
||||
** @Author : yuebin
|
||||
** @File : weixin
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/28 16:38
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controller
|
||||
|
||||
import (
|
||||
"dongfeng/service/models"
|
||||
)
|
||||
|
||||
type WeiXinImpl struct {
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) Scan(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) H5(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) Syt(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) ScanData {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return scanData
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) Fast(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) bool {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) Web(orderInfo models.OrderInfo, roadInfo models.RoadInfo, merchantInfo models.MerchantInfo) bool {
|
||||
var scanData ScanData
|
||||
scanData.Status = "01"
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) PayNotify() {
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) PayQuery(orderInfo models.OrderInfo) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) PayFor(payFor models.PayforInfo) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) PayForNotify() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) PayForQuery(payFor models.PayforInfo) (string, string) {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
func (c *WeiXinImpl) BalanceQuery(roadInfo models.RoadInfo) float64 {
|
||||
return 0.00
|
||||
}
|
||||
15
boss/service/controllers/default.go
Normal file
15
boss/service/controllers/default.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type MainController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *MainController) Get() {
|
||||
c.Data["Website"] = "beego.me"
|
||||
c.Data["Email"] = "astaxie@gmail.com"
|
||||
c.TplName = "index.tpl"
|
||||
}
|
||||
10
boss/service/go.mod
Normal file
10
boss/service/go.mod
Normal file
@@ -0,0 +1,10 @@
|
||||
module service
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/beego/beego/v2 v2.0.1
|
||||
|
||||
require (
|
||||
github.com/astaxie/beego v1.12.3
|
||||
github.com/smartystreets/goconvey v1.6.4
|
||||
)
|
||||
262
boss/service/go.sum
Normal file
262
boss/service/go.sum
Normal file
@@ -0,0 +1,262 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
|
||||
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
|
||||
github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ=
|
||||
github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA=
|
||||
github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI=
|
||||
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
|
||||
github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||
github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
|
||||
github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
|
||||
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
|
||||
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
|
||||
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/glendc/gopher-json v0.0.0-20170414221815-dc4743023d0c/go.mod h1:Gja1A+xZ9BoviGJNA2E9vFkPjjsl+CoJxSXiQM1UXtw=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-redis/redis/v7 v7.4.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
|
||||
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/ledisdb/ledisdb v0.0.0-20200510135210-d35789ec47e6/go.mod h1:n931TsDuKuq+uX4v1fulaMbA/7ZLLhjc85h7chZGBCQ=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
|
||||
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
|
||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
|
||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
|
||||
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
|
||||
github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
|
||||
github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
|
||||
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
|
||||
github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
|
||||
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
|
||||
go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
9
boss/service/main.go
Normal file
9
boss/service/main.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
func main() {
|
||||
beego.Run()
|
||||
}
|
||||
43
boss/service/message_queue/active_mq.go
Normal file
43
boss/service/message_queue/active_mq.go
Normal file
@@ -0,0 +1,43 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/6 11:43
|
||||
** @Author : yuebin
|
||||
** @File : active_mq
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/6 11:43
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package message_queue
|
||||
|
||||
import (
|
||||
"dongfeng/service/common"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/go-stomp/stomp"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
//解决第一个问题的代码
|
||||
var activeConn *stomp.Conn
|
||||
|
||||
var options = []func(*stomp.Conn) error{
|
||||
//设置读写超时,超时时间为1个小时
|
||||
stomp.ConnOpt.HeartBeat(7200*time.Second, 7200*time.Second),
|
||||
stomp.ConnOpt.HeartBeatError(360 * time.Second),
|
||||
}
|
||||
|
||||
func init() {
|
||||
address := common.GetMQAddress()
|
||||
|
||||
conn, err := stomp.Dial("tcp", address, options...)
|
||||
if err != nil {
|
||||
logs.Error("链接active mq 失败:", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
activeConn = conn
|
||||
}
|
||||
|
||||
func GetActiveMQConn() *stomp.Conn {
|
||||
return activeConn
|
||||
}
|
||||
33
boss/service/message_queue/send_message.go
Normal file
33
boss/service/message_queue/send_message.go
Normal file
@@ -0,0 +1,33 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/21 15:53
|
||||
** @Author : yuebin
|
||||
** @File : send_message
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/21 15:53
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package message_queue
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"os"
|
||||
)
|
||||
|
||||
func SendMessage(topic, message string) {
|
||||
|
||||
conn := GetActiveMQConn()
|
||||
|
||||
if conn == nil {
|
||||
logs.Error("send message get Active mq fail")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err := conn.Send(topic, "text/plain", []byte(message))
|
||||
|
||||
if err != nil {
|
||||
logs.Error("发送消息给activeMQ失败, message=", message)
|
||||
} else {
|
||||
logs.Info("发送消息给activeMQ成功,message=", message)
|
||||
}
|
||||
}
|
||||
119
boss/service/models/account.go
Normal file
119
boss/service/models/account.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
69
boss/service/models/account_history_info.go
Normal file
69
boss/service/models/account_history_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
162
boss/service/models/agent_info.go
Normal file
162
boss/service/models/agent_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
13
boss/service/models/agent_profit.go
Normal file
13
boss/service/models/agent_profit.go
Normal file
@@ -0,0 +1,13 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/12/17 17:50
|
||||
** @Author : yuebin
|
||||
** @File : agent_profit
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/12/17 17:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
type AgentProfit struct {
|
||||
}
|
||||
106
boss/service/models/bank_card_info.go
Normal file
106
boss/service/models/bank_card_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
39
boss/service/models/init.go
Normal file
39
boss/service/models/init.go
Normal file
@@ -0,0 +1,39 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/9 13:48
|
||||
** @Author : yuebin
|
||||
** @File : init
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/9 13:48
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/orm"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"dongfeng/service/conf"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
dbHost := conf.DB_HOST
|
||||
dbUser := conf.DB_USER
|
||||
dbPassword := conf.DB_PASSWORD
|
||||
dbBase := conf.DB_BASE
|
||||
dbPort := conf.DB_PORT
|
||||
|
||||
link := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8", dbUser, dbPassword, dbHost, dbPort, dbBase)
|
||||
|
||||
beego.Info("mysql init.....", link)
|
||||
|
||||
orm.RegisterDriver("mysql", orm.DRMySQL)
|
||||
orm.RegisterDataBase("default", "mysql", link, 30, 30)
|
||||
orm.RegisterModel(new(UserInfo), new(MenuInfo), new(SecondMenuInfo),
|
||||
new(PowerInfo), new(RoleInfo), new(BankCardInfo), new(RoadInfo),
|
||||
new(RoadPoolInfo), new(AgentInfo), new(MerchantInfo), new(MerchantDeployInfo),
|
||||
new(AccountInfo), new(AccountHistoryInfo), new(OrderInfo), new(OrderProfitInfo),
|
||||
new(OrderSettleInfo), new(NotifyInfo), new(MerchantLoadInfo),
|
||||
new(PayforInfo))
|
||||
}
|
||||
179
boss/service/models/menu_info.go
Normal file
179
boss/service/models/menu_info.go
Normal file
@@ -0,0 +1,179 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/21 9:33
|
||||
** @Author : yuebin
|
||||
** @File : menu_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/21 9:33
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
type MenuInfo struct {
|
||||
Id int
|
||||
MenuOrder int
|
||||
MenuUid string
|
||||
FirstMenu string
|
||||
SecondMenu string
|
||||
Creater string
|
||||
Status string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
//实现排序的三个接口函数
|
||||
type MenuInfoSlice []MenuInfo
|
||||
|
||||
func (m MenuInfoSlice) Len() int {
|
||||
return len(m)
|
||||
}
|
||||
|
||||
func (m MenuInfoSlice) Swap(i, j int) {
|
||||
m[i], m[j] = m[j], m[i]
|
||||
}
|
||||
|
||||
func (m MenuInfoSlice) Less(i, j int) bool {
|
||||
return m[i].MenuOrder < m[j].MenuOrder //从小到大排序
|
||||
}
|
||||
|
||||
const MENUINFO = "menu_info"
|
||||
|
||||
func InsertMenu(menuInfo MenuInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert new menu info fail:", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func FirstMenuIsExists(firstMenu string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("first_menu", firstMenu).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func FirstMenuUidIsExists(firstMenUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("menu_uid", firstMenUid).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func MenuOrderIsExists(menuOrder int) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("menu_order", menuOrder).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetMenuLen() int {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.QueryTable(MENUINFO).Count()
|
||||
if err != nil {
|
||||
logs.Error("get menu info len length fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMenuInfoByMenuUid(menuUid string) MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfo MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Filter("menu_uid", menuUid).Limit(1).All(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("get menu info by menuUid fail: ", err)
|
||||
}
|
||||
return menuInfo
|
||||
}
|
||||
|
||||
func GetMenuInfosByMenuUids(menuUids []string) []MenuInfo {
|
||||
menuInfoList := make([]MenuInfo, 0)
|
||||
for _, v := range menuUids {
|
||||
m := GetMenuInfoByMenuUid(v)
|
||||
menuInfoList = append(menuInfoList, m)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuInfoByMenuOrder(menuOrder int) MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfo MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Filter("menu_order", menuOrder).Limit(1).All(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("get menu info by menu order fail: ", err)
|
||||
}
|
||||
return menuInfo
|
||||
}
|
||||
|
||||
func GetMenuAll() []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).OrderBy("-update_time").All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get all menu list fail:", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuOffset(displayCount, offset int) []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Limit(displayCount, offset).All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get menu offset fail: ", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuOffsetByMap(params map[string]string, displayCount, offset int) []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
qs := o.QueryTable(MENUINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get menu offset by map fail: ", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MENUINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Count()
|
||||
if err != nil {
|
||||
logs.Error("get menu len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func UpdateMenuInfo(menuInfo MenuInfo) {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.Update(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("update menu info fail: ", err)
|
||||
}
|
||||
logs.Info("update menu info success, num: ", cnt)
|
||||
}
|
||||
|
||||
func DeleteMenuInfo(menuUid string) {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.QueryTable(MENUINFO).Filter("menu_uid", menuUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete menu info fail: ", err)
|
||||
}
|
||||
logs.Info("delete menu info num: ", cnt)
|
||||
}
|
||||
135
boss/service/models/merchant_deploy_info.go
Normal file
135
boss/service/models/merchant_deploy_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
205
boss/service/models/merchant_info.go
Normal file
205
boss/service/models/merchant_info.go
Normal file
@@ -0,0 +1,205 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/9/28 16:47
|
||||
** @Author : yuebin
|
||||
** @File : merchant_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/9/28 16:47
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
type MerchantInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
BelongAgentUid string
|
||||
BelongAgentName string
|
||||
MerchantName string
|
||||
MerchantUid string
|
||||
MerchantKey string
|
||||
MerchantSecret string
|
||||
LoginPassword string
|
||||
LoginAccount string
|
||||
AutoSettle string
|
||||
AutoPayFor string
|
||||
WhiteIps string
|
||||
Remark string
|
||||
SinglePayForRoadUid string
|
||||
SinglePayForRoadName string
|
||||
RollPayForRoadCode string
|
||||
RollPayForRoadName string
|
||||
PayforFee float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const MERCHANT_INFO = "merchant_info"
|
||||
|
||||
func IsExistByMerchantName(merchantName string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("merchant_name", merchantName).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistByMerchantUid(uid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", uid).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistMerchantByAgentUid(uid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("belong_agent_uid", uid).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistByMerchantPhone(phone string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("LoginAccount", phone).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetMerchantByPhone(phone string) (m MerchantInfo) {
|
||||
o := orm.NewOrm()
|
||||
_, e := o.QueryTable(MERCHANT_INFO).Filter("LoginAccount", phone).Limit(1).All(&m)
|
||||
if e != nil {
|
||||
logs.Error("GetMerchantByPhone merchant fail: ", e)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func InsertMerchantInfo(merchantInfo MerchantInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetMerchantLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_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 len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMerchantListByMap(params map[string]string, displayCount, offset int) []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
var merchantList []MerchantInfo
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&merchantList)
|
||||
if err != nil {
|
||||
logs.Error("get merchant list by map fail: ", err)
|
||||
}
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetAllMerchant() []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantList []MerchantInfo
|
||||
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Limit(-1).All(&merchantList)
|
||||
if err != nil {
|
||||
logs.Error("get all merchant fail:", err)
|
||||
}
|
||||
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetMerchantByParams(params map[string]string, displayCount, offset int) []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantList []MerchantInfo
|
||||
qs := o.QueryTable(MERCHANT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
qs.Limit(displayCount, offset).All(&merchantList)
|
||||
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetMerchantLenByParams(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_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 merchant len by params fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMerchantByUid(merchantUid string) MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantInfo MerchantInfo
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", merchantUid).Limit(1).All(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("get merchant info fail: ", err)
|
||||
}
|
||||
return merchantInfo
|
||||
}
|
||||
|
||||
func GetMerchantByPaykey(payKey string) MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantInfo MerchantInfo
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_key", payKey).Limit(1).All(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("get merchant by merchantKey fail: ", err)
|
||||
}
|
||||
return merchantInfo
|
||||
}
|
||||
|
||||
func UpdateMerchant(merchantInfo MerchantInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&merchantInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteMerchantByUid(merchantUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", merchantUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
56
boss/service/models/merchant_load_info.go
Normal file
56
boss/service/models/merchant_load_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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()
|
||||
}
|
||||
103
boss/service/models/notify_info.go
Normal file
103
boss/service/models/notify_info.go
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/20 13:13
|
||||
** @Author : yuebin
|
||||
** @File : notify_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/20 13:13
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
type NotifyInfo struct {
|
||||
Id int
|
||||
Type string //订单-order,代付-payfor
|
||||
BankOrderId string
|
||||
MerchantOrderId string
|
||||
Status string
|
||||
Times int
|
||||
Url string
|
||||
Response string
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const NOTIFYINFO = "notify_info"
|
||||
|
||||
func InsertNotifyInfo(notifyInfo NotifyInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert notify fail:", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func NotifyInfoExistByBankOrderId(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(NOTIFYINFO).Filter("bank_order_id", bankOrderId).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetNotifyInfoByBankOrderId(bankOrderId string) NotifyInfo {
|
||||
o := orm.NewOrm()
|
||||
var notifyInfo NotifyInfo
|
||||
_, err := o.QueryTable(NOTIFYINFO).Filter("bank_order_id", bankOrderId).All(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("get notify info by bankOrderId fail: ", err)
|
||||
}
|
||||
|
||||
return notifyInfo
|
||||
}
|
||||
|
||||
func GetNotifyInfosNotSuccess(params map[string]interface{}) []NotifyInfo {
|
||||
o := orm.NewOrm()
|
||||
var notifyInfoList []NotifyInfo
|
||||
qs := o.QueryTable(NOTIFYINFO)
|
||||
for k, v := range params {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
qs = qs.Exclude("status", "success")
|
||||
_, err := qs.Limit(-1).All(¬ifyInfoList)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get notifyinfos fail: ", err)
|
||||
}
|
||||
|
||||
return notifyInfoList
|
||||
}
|
||||
|
||||
func GetNotifyBankOrderIdListByParams(params map[string]string) []string {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(NOTIFYINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
var notifyList []NotifyInfo
|
||||
qs.Limit(-1).All(¬ifyList)
|
||||
var list []string
|
||||
for _, n := range notifyList {
|
||||
list = append(list, n.BankOrderId)
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
func UpdateNotifyInfo(notifyInfo NotifyInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("update notify info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
222
boss/service/models/order_info.go
Normal file
222
boss/service/models/order_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"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
|
||||
}
|
||||
119
boss/service/models/order_profit_info.go
Normal file
119
boss/service/models/order_profit_info.go
Normal file
@@ -0,0 +1,119 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/30 11:44
|
||||
** @Author : yuebin
|
||||
** @File : order_profit_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/30 11:44
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type OrderProfitInfo struct {
|
||||
Id int
|
||||
MerchantName string
|
||||
MerchantUid string
|
||||
AgentName string
|
||||
AgentUid string
|
||||
PayProductCode string
|
||||
PayProductName string
|
||||
PayTypeCode string
|
||||
PayTypeName string
|
||||
Status string
|
||||
MerchantOrderId string
|
||||
BankOrderId string
|
||||
BankTransId string
|
||||
OrderAmount float64
|
||||
ShowAmount float64
|
||||
FactAmount float64
|
||||
UserInAmount float64
|
||||
SupplierRate float64
|
||||
PlatformRate float64
|
||||
AgentRate float64
|
||||
AllProfit float64
|
||||
SupplierProfit float64
|
||||
PlatformProfit float64
|
||||
AgentProfit float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ORDER_PROFIT_INFO = "order_profit_info"
|
||||
|
||||
func GetOrderProfitByBankOrderId(bankOrderId string) OrderProfitInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderProfit OrderProfitInfo
|
||||
_, err := o.QueryTable(ORDER_PROFIT_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderProfit)
|
||||
if err != nil {
|
||||
logs.Error("GetOrderProfitByBankOrderId fail:", err)
|
||||
}
|
||||
return orderProfit
|
||||
}
|
||||
|
||||
func GetOrderProfitLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ORDER_PROFIT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, _ := qs.Limit(-1).Count()
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetOrderProfitByMap(params map[string]string, display, offset int) []OrderProfitInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderProfitInfoList []OrderProfitInfo
|
||||
qs := o.QueryTable(ORDER_PROFIT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&orderProfitInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get order by map fail: ", err)
|
||||
}
|
||||
return orderProfitInfoList
|
||||
}
|
||||
|
||||
func GetPlatformProfitByMap(params map[string]string) []PlatformProfit {
|
||||
|
||||
o := orm.NewOrm()
|
||||
|
||||
cond := "select merchant_name, agent_name, pay_product_name as supplier_name, pay_type_name, sum(fact_amount) as order_amount, count(1) as order_count, " +
|
||||
"sum(platform_profit) as platform_profit, sum(agent_profit) as agent_profit from " + ORDER_PROFIT_INFO + " where status='success' "
|
||||
flag := false
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
if flag {
|
||||
cond += " and"
|
||||
}
|
||||
if strings.Contains(k, "create_time__gte") {
|
||||
cond = cond + " create_time>='" + v + "'"
|
||||
} else if strings.Contains(k, "create_time__lte") {
|
||||
cond = cond + " create_time<='" + v + "'"
|
||||
} else {
|
||||
cond = cond + " " + k + "='" + v + "'"
|
||||
}
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
|
||||
cond += " group by merchant_uid, agent_uid, pay_product_code, pay_type_code"
|
||||
|
||||
var platformProfitList []PlatformProfit
|
||||
_, err := o.Raw(cond).QueryRows(&platformProfitList)
|
||||
if err != nil {
|
||||
logs.Error("get platform profit by map fail:", err)
|
||||
}
|
||||
|
||||
return platformProfitList
|
||||
}
|
||||
51
boss/service/models/order_settle_info.go
Normal file
51
boss/service/models/order_settle_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
239
boss/service/models/payfor_info.go
Normal file
239
boss/service/models/payfor_info.go
Normal file
@@ -0,0 +1,239 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/25 14:32
|
||||
** @Author : yuebin
|
||||
** @File : payfor_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/25 14:32
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"dongfeng/service/common"
|
||||
"dongfeng/service/utils"
|
||||
)
|
||||
|
||||
type PayforInfo struct {
|
||||
Id int
|
||||
PayforUid string
|
||||
MerchantUid string
|
||||
MerchantName string
|
||||
MerchantOrderId string
|
||||
BankOrderId string
|
||||
BankTransId string
|
||||
RoadUid string
|
||||
RoadName string
|
||||
RollPoolCode string
|
||||
RollPoolName string
|
||||
PayforFee float64
|
||||
PayforAmount float64
|
||||
PayforTotalAmount float64
|
||||
BankCode string
|
||||
BankName string
|
||||
BankAccountName string
|
||||
BankAccountNo string
|
||||
BankAccountType string
|
||||
Country string
|
||||
City string
|
||||
Ares string
|
||||
BankAccountAddress string
|
||||
PhoneNo string
|
||||
GiveType string
|
||||
Type string
|
||||
NotifyUrl string
|
||||
Status string
|
||||
IsSend string
|
||||
RequestTime string
|
||||
ResponseTime string
|
||||
ResponseContext string
|
||||
Remark string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
const PAYFORINFO = "payfor_info"
|
||||
|
||||
func InsertPayfor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&payFor)
|
||||
if err != nil {
|
||||
logs.Error("insert payfor fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func IsExistPayForByBankOrderId(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(PAYFORINFO).Filter("bank_order_id", bankOrderId).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistPayForByMerchantOrderId(merchantOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(PAYFORINFO).Filter("merchant_order_id", merchantOrderId).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetPayForLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
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 pay for len by map fail: ", err)
|
||||
}
|
||||
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetPayForByMap(params map[string]string, displayCount, offset int) []PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payForList []PayforInfo
|
||||
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-create_time").All(&payForList)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get agentInfo by map fail: ", err)
|
||||
}
|
||||
|
||||
return payForList
|
||||
}
|
||||
|
||||
func GetPayForListByParams(params map[string]string) []PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payForList []PayforInfo
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(-1).All(&payForList)
|
||||
if err != nil {
|
||||
logs.Error("GetPayForListByParams fail:", err)
|
||||
}
|
||||
return payForList
|
||||
}
|
||||
|
||||
func GetPayForByBankOrderId(bankOrderId string) PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payFor PayforInfo
|
||||
_, err := o.QueryTable(PAYFORINFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get pay for by bank_order_id fail: ", err)
|
||||
}
|
||||
|
||||
return payFor
|
||||
}
|
||||
|
||||
func GetPayForByMerchantOrderId(merchantOrderId string) PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payFor PayforInfo
|
||||
|
||||
_, err := o.QueryTable(PAYFORINFO).Filter("merchant_order_id", merchantOrderId).Limit(1).All(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("fail: ", err)
|
||||
}
|
||||
|
||||
return payFor
|
||||
}
|
||||
|
||||
func ForUpdatePayFor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if err := recover(); err != nil {
|
||||
logs.Error("for update pay for painc.....")
|
||||
o.Rollback()
|
||||
}
|
||||
}(o)
|
||||
|
||||
var tmp PayforInfo
|
||||
if err := o.Raw("select * from payfor_info where bank_order_id = ? for update", payFor.BankOrderId).QueryRow(&tmp); err != nil || tmp.PayforUid == "" {
|
||||
logs.Error("for update payfor select fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if tmp.Status == common.PAYFOR_FAIL || tmp.Status == common.PAYFOR_SUCCESS {
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
//如果是手动打款,并且是需要处理商户金额
|
||||
if payFor.Status == common.PAYFOR_SOLVING && tmp.Status == common.PAYFOR_COMFRIM &&
|
||||
payFor.GiveType == common.PAYFOR_HAND && payFor.Type != common.SELF_HELP {
|
||||
|
||||
var account AccountInfo
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", payFor.MerchantUid).QueryRow(&account); err != nil || account.AccountUid == "" {
|
||||
logs.Error("for update payfor select account info,fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
//计算该用户的可用金额
|
||||
ableAmount := account.SettleAmount - account.FreezeAmount - account.PayforAmount - account.LoanAmount
|
||||
if ableAmount >= payFor.PayforAmount+payFor.PayforFee {
|
||||
account.PayforAmount += payFor.PayforFee + payFor.PayforAmount
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := o.Update(&account); err != nil {
|
||||
logs.Error("for update payfor update account fail:", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,可用金额不够", payFor.MerchantUid))
|
||||
payFor.ResponseContext = "商户可用余额不足"
|
||||
payFor.Status = common.PAYFOR_FAIL
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := o.Update(&payFor); err != nil {
|
||||
logs.Error("for update payfor fail: ", err)
|
||||
o.Rollback()
|
||||
return false
|
||||
}
|
||||
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Info("for update payfor success")
|
||||
} else {
|
||||
logs.Error("for update payfor fail:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdatePayFor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update pay for fail:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
21
boss/service/models/platform_profit.go
Normal file
21
boss/service/models/platform_profit.go
Normal file
@@ -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 models
|
||||
|
||||
type PlatformProfit struct {
|
||||
MerchantName string
|
||||
AgentName string
|
||||
SupplierName string
|
||||
PayTypeName string
|
||||
OrderAmount float64
|
||||
OrderCount int
|
||||
PlatformProfit float64
|
||||
AgentProfit float64
|
||||
}
|
||||
143
boss/service/models/power_info.go
Normal file
143
boss/service/models/power_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
162
boss/service/models/road_info.go
Normal file
162
boss/service/models/road_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
127
boss/service/models/road_pool_info.go
Normal file
127
boss/service/models/road_pool_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
123
boss/service/models/role_info.go
Normal file
123
boss/service/models/role_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
216
boss/service/models/second_menu_info.go
Normal file
216
boss/service/models/second_menu_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
90
boss/service/models/transaction.go
Normal file
90
boss/service/models/transaction.go
Normal file
@@ -0,0 +1,90 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/19 14:17
|
||||
** @Author : yuebin
|
||||
** @File : transaction
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/19 14:17
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
"dongfeng/service/common"
|
||||
"dongfeng/service/utils"
|
||||
)
|
||||
|
||||
func OperatorAccount(accountUid, operatorType string, amount float64) (string, bool) {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if r := recover(); r != nil {
|
||||
o.Rollback()
|
||||
logs.Error("operator account fail")
|
||||
}
|
||||
}(o)
|
||||
|
||||
msg := ""
|
||||
//处理事务
|
||||
accountInfo := new(AccountInfo)
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", accountUid).QueryRow(accountInfo); err != nil || accountInfo.AccountUid == "" {
|
||||
logs.Error("operator account get account info for update fail: ", err)
|
||||
o.Rollback()
|
||||
return msg, false
|
||||
}
|
||||
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
flag := true
|
||||
|
||||
switch operatorType {
|
||||
case common.PLUS_AMOUNT: //处理加款操作
|
||||
accountInfo.Balance = accountInfo.Balance + amount
|
||||
accountInfo.SettleAmount = accountInfo.SettleAmount + amount
|
||||
case common.SUB_AMOUNT: //处理减款
|
||||
if accountInfo.Balance >= amount && accountInfo.SettleAmount >= amount {
|
||||
accountInfo.Balance = accountInfo.Balance - amount
|
||||
accountInfo.SettleAmount = accountInfo.SettleAmount - amount
|
||||
} else {
|
||||
msg = "账户余额不够减"
|
||||
flag = false
|
||||
}
|
||||
case common.FREEZE_AMOUNT: //处理冻结款
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount + amount
|
||||
case common.UNFREEZE_AMOUNT: //处理解冻款
|
||||
if accountInfo.FreezeAmount >= amount {
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount - amount
|
||||
} else {
|
||||
msg = "账户冻结金额不够解冻款"
|
||||
flag = false
|
||||
}
|
||||
}
|
||||
if !flag {
|
||||
o.Rollback()
|
||||
return msg, false
|
||||
}
|
||||
|
||||
if _, err := o.Update(accountInfo); err != nil {
|
||||
logs.Error("operator account update account fail: ", err)
|
||||
o.Rollback()
|
||||
return msg, false
|
||||
}
|
||||
//往account_history表中插入一条动账记录
|
||||
accountHistory := AccountHistoryInfo{AccountUid: accountUid, AccountName: accountInfo.AccountName, Type: operatorType,
|
||||
Amount: amount, Balance: accountInfo.Balance, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if _, err := o.Insert(&accountHistory); err != nil {
|
||||
logs.Error("operator account insert account history fail: ", err)
|
||||
o.Rollback()
|
||||
return msg, false
|
||||
}
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("operator account commit fail: ", err)
|
||||
return msg, false
|
||||
} else {
|
||||
logs.Info("操作账户成功")
|
||||
return "", true
|
||||
}
|
||||
}
|
||||
146
boss/service/models/user_info.go
Normal file
146
boss/service/models/user_info.go
Normal file
@@ -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 models
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/orm"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
7
boss/service/routers/router.go
Normal file
7
boss/service/routers/router.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package routers
|
||||
|
||||
import ()
|
||||
|
||||
func init() {
|
||||
//beego.Router("/", &controllers.MainController{})
|
||||
}
|
||||
BIN
boss/service/service
Normal file
BIN
boss/service/service
Normal file
Binary file not shown.
22
boss/service/service_init/init_all.go
Normal file
22
boss/service/service_init/init_all.go
Normal file
@@ -0,0 +1,22 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/19 17:48
|
||||
** @Author : yuebin
|
||||
** @File : init_all
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/19 17:48
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package service_init
|
||||
|
||||
import (
|
||||
"dongfeng/service/controller"
|
||||
_ "dongfeng/service/message_queue"
|
||||
"dongfeng/service/models"
|
||||
)
|
||||
|
||||
func InitAll() {
|
||||
//初始化mysql
|
||||
models.Init()
|
||||
controller.Init()
|
||||
}
|
||||
1
boss/service/static/js/reload.min.js
vendored
Normal file
1
boss/service/static/js/reload.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
function b(a){var c=new WebSocket(a);c.onclose=function(){setTimeout(function(){b(a)},2E3)};c.onmessage=function(){location.reload()}}try{if(window.WebSocket)try{b("ws://localhost:12450/reload")}catch(a){console.error(a)}else console.log("Your browser does not support WebSockets.")}catch(a){console.error("Exception during connecting to Reload:",a)};
|
||||
39
boss/service/tests/default_test.go
Normal file
39
boss/service/tests/default_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"runtime"
|
||||
"path/filepath"
|
||||
_ "service/routers"
|
||||
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func init() {
|
||||
_, file, _, _ := runtime.Caller(0)
|
||||
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
|
||||
beego.TestBeegoInit(apppath)
|
||||
}
|
||||
|
||||
|
||||
// TestBeego is a sample to run an endpoint test
|
||||
func TestBeego(t *testing.T) {
|
||||
r, _ := http.NewRequest("GET", "/", nil)
|
||||
w := httptest.NewRecorder()
|
||||
beego.BeeApp.Handlers.ServeHTTP(w, r)
|
||||
|
||||
beego.Trace("testing", "TestBeego", "Code[%d]\n%s", w.Code, w.Body.String())
|
||||
|
||||
Convey("Subject: Test Station Endpoint\n", t, func() {
|
||||
Convey("Status Code Should Be 200", func() {
|
||||
So(w.Code, ShouldEqual, 200)
|
||||
})
|
||||
Convey("The Result Should Not Be Empty", func() {
|
||||
So(w.Body.Len(), ShouldBeGreaterThan, 0)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
131
boss/service/utils/AES_ECB.go
Normal file
131
boss/service/utils/AES_ECB.go
Normal file
@@ -0,0 +1,131 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2018-8-30 13:50
|
||||
** @Author : Joker
|
||||
** @File : ACE_ECB
|
||||
** @Last Modified by : Joker
|
||||
** @Last Modified time: 2018-8-30 13:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"encoding/hex"
|
||||
"github.com/astaxie/beego/logs"
|
||||
)
|
||||
|
||||
/*
|
||||
aes解码
|
||||
crypted:要加密的字符串
|
||||
key:用来加密的密钥 密钥长度可以是128bit、192bit、256bit中的任意一个
|
||||
16位key对应128bit
|
||||
*/
|
||||
func AesDecrypt(src, key []byte) []byte {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
logs.Error("Joker: AesDecrypt failed to NewCipher")
|
||||
logs.Error(err)
|
||||
}
|
||||
blockMode := NewECBDecrypter(block)
|
||||
origData := make([]byte, len(src))
|
||||
blockMode.CryptBlocks(origData, src)
|
||||
origData = PKCS5UnPadding(origData)
|
||||
return origData
|
||||
}
|
||||
|
||||
/*aes编码*/
|
||||
func AesEncrypt(src []byte, key string) []byte {
|
||||
decodeString, err := hex.DecodeString(key)
|
||||
if err != nil {
|
||||
logs.Error("Joker: AesEncrypt failed to hex key")
|
||||
logs.Error(err)
|
||||
}
|
||||
block, err := aes.NewCipher(decodeString)
|
||||
if err != nil {
|
||||
logs.Error("Joker: AesEncrypt failed to NewCipher")
|
||||
logs.Error(err)
|
||||
}
|
||||
if len(src) < 0 {
|
||||
logs.Error("Joker: AesEncrypt`s input is null ")
|
||||
}
|
||||
ecb := NewECBEncrypter(block)
|
||||
src = PKCS5Padding(src, block.BlockSize())
|
||||
crypted := make([]byte, len(src))
|
||||
ecb.CryptBlocks(crypted, src)
|
||||
// 普通base64编码加密 区别于urlsafe base64
|
||||
//fmt.Println("base64 result:", base64.StdEncoding.EncodeToString(crypted))
|
||||
//fmt.Println("base64UrlSafe result:", Base64UrlSafeEncode(crypted))
|
||||
return crypted
|
||||
}
|
||||
|
||||
func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
|
||||
padding := blockSize - len(ciphertext)%blockSize
|
||||
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
|
||||
return append(ciphertext, padtext...)
|
||||
}
|
||||
|
||||
func PKCS5UnPadding(origData []byte) []byte {
|
||||
length := len(origData)
|
||||
// 去掉最后一个字节 unpadding 次
|
||||
unpadding := int(origData[length-1])
|
||||
return origData[:(length - unpadding)]
|
||||
}
|
||||
|
||||
type ecb struct {
|
||||
b cipher.Block
|
||||
blockSize int
|
||||
}
|
||||
|
||||
func newECB(b cipher.Block) *ecb {
|
||||
return &ecb{
|
||||
b: b,
|
||||
blockSize: b.BlockSize(),
|
||||
}
|
||||
}
|
||||
|
||||
type ecbEncrypter ecb
|
||||
|
||||
// NewECBEncrypter returns a BlockMode which encrypts in electronic code book
|
||||
// mode, using the given Block.
|
||||
func NewECBEncrypter(b cipher.Block) cipher.BlockMode {
|
||||
return (*ecbEncrypter)(newECB(b))
|
||||
}
|
||||
func (x *ecbEncrypter) BlockSize() int { return x.blockSize }
|
||||
func (x *ecbEncrypter) CryptBlocks(dst, src []byte) {
|
||||
if len(src)%x.blockSize != 0 {
|
||||
logs.Error("Joker: CryptBlocks`s input not full blocks")
|
||||
}
|
||||
if len(dst) < len(src) {
|
||||
logs.Error("Joker: CryptBlocks`s output smaller than input")
|
||||
}
|
||||
for len(src) > 0 {
|
||||
x.b.Encrypt(dst, src[:x.blockSize])
|
||||
src = src[x.blockSize:]
|
||||
dst = dst[x.blockSize:]
|
||||
}
|
||||
}
|
||||
|
||||
type ecbDecrypter ecb
|
||||
|
||||
// NewECBDecrypter returns a BlockMode which decrypts in electronic code book
|
||||
// mode, using the given Block.
|
||||
func NewECBDecrypter(b cipher.Block) cipher.BlockMode {
|
||||
return (*ecbDecrypter)(newECB(b))
|
||||
}
|
||||
func (x *ecbDecrypter) BlockSize() int { return x.blockSize }
|
||||
func (x *ecbDecrypter) CryptBlocks(dst, src []byte) {
|
||||
if len(src)%x.blockSize != 0 {
|
||||
logs.Error("Joker: CryptBlocks`s input not full blocks")
|
||||
}
|
||||
if len(dst) < len(src) {
|
||||
logs.Error("Joker: CryptBlocks`s output smaller than input")
|
||||
}
|
||||
for len(src) > 0 {
|
||||
x.b.Decrypt(dst, src[:x.blockSize])
|
||||
src = src[x.blockSize:]
|
||||
dst = dst[x.blockSize:]
|
||||
}
|
||||
}
|
||||
40
boss/service/utils/date_time.go
Normal file
40
boss/service/utils/date_time.go
Normal file
@@ -0,0 +1,40 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/21 10:21
|
||||
** @Author : yuebin
|
||||
** @File : date_time
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/21 10:21
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package utils
|
||||
|
||||
import "time"
|
||||
|
||||
func GetDateTimeNot() string {
|
||||
return time.Now().Format("2006010215:04:05")
|
||||
}
|
||||
|
||||
func GetDate() string {
|
||||
return time.Now().Format("2006-01-02")
|
||||
}
|
||||
|
||||
func GetBasicDateTime() string {
|
||||
return time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func GetNowTimesTamp() string {
|
||||
return time.Now().Format("20060102150405")
|
||||
}
|
||||
|
||||
func GetDateTimeBeforeHours(hour int) string {
|
||||
return time.Now().Add(-time.Hour * time.Duration(hour)).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func GetDateBeforeDays(days int) string {
|
||||
return time.Now().Add(-time.Hour * time.Duration(days) * 24).Format("2006-01-02")
|
||||
}
|
||||
|
||||
func GetDateTimeBeforeDays(days int) string {
|
||||
return time.Now().Add(-time.Hour * time.Duration(days) * 24).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user