mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2024-11-14 06:29:19 +08:00
重构了boss系统,添加了逻辑
This commit is contained in:
parent
4967a137ec
commit
7cd2e963ad
@ -1,25 +0,0 @@
|
||||
/***************************************************
|
||||
** @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)
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 "未知"
|
||||
}
|
||||
}
|
@ -14,34 +14,9 @@ var supplierCode2Name = map[string]string{
|
||||
"KF": "快付支付",
|
||||
"WEIXIN": "官方微信",
|
||||
"ALIPAY": "官方支付宝",
|
||||
"DAILI": "代丽支付",
|
||||
}
|
||||
|
||||
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 "未找到上游名称,注册有问题。"
|
||||
}
|
||||
|
@ -8,5 +8,11 @@ sessionon = true
|
||||
dbhost = localhost
|
||||
dbport = 3306
|
||||
dbuser = root
|
||||
dbpasswd =
|
||||
dbbase = juhe_pay
|
||||
dbpasswd = Kyb^15273031604
|
||||
dbbase = juhe_pay
|
||||
|
||||
[gateway]
|
||||
host = http://localhost:12309/
|
||||
#orderUrl = http://localhost:12309/gateway/supplier/order/query
|
||||
#updateOrderUrl = http://localhost:12309/gateway/update/order
|
||||
#payforUrl = http://localhost:12309/gateway/update/order
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,9 @@
|
||||
package controllers
|
||||
|
||||
import beego "github.com/beego/beego/v2/server/web"
|
||||
import (
|
||||
"boss/datas"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type BaseController struct {
|
||||
beego.Controller
|
||||
@ -8,20 +11,20 @@ type BaseController struct {
|
||||
|
||||
func (c *BaseController) GenerateJSON(dataJSON interface{}) {
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *BaseController) Prepare() {
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
if !ok || userID == "" {
|
||||
//用户没有登录,或者登录到期了,则跳转登录主页面
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON := new(datas.BaseDataJSON)
|
||||
dataJSON.Code = 404
|
||||
dataJSON.Msg = "登录已经过期!"
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
} else {
|
||||
//重新赋值给session
|
||||
c.SetSession("userID", userID)
|
||||
_ = c.SetSession("userID", userID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,195 +10,73 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"boss/models"
|
||||
"boss/utils"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"sort"
|
||||
"boss/service"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Deletecontroller struct {
|
||||
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) Finish() {
|
||||
se := new(service.DeleteService)
|
||||
se.Finish()
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteMenu() {
|
||||
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
|
||||
}
|
||||
se := new(service.DeleteService)
|
||||
dataJSON := se.DeleteMenu(menuUid, c.GetSession("userID").(string))
|
||||
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSONP()
|
||||
_ = 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() {
|
||||
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 = "删除失败"
|
||||
}
|
||||
}
|
||||
se := new(service.DeleteService)
|
||||
dataJSON := se.DeleteSecondMenu(secondMenuUid)
|
||||
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除权限项
|
||||
*/
|
||||
func (c *Deletecontroller) DeletePowerItem() {
|
||||
func (c *DeleteController) DeletePowerItem() {
|
||||
powerID := strings.TrimSpace(c.GetString("powerID"))
|
||||
models.DeletePowerItemByPowerID(powerID)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = 200
|
||||
se := new(service.DeleteService)
|
||||
dataJSON := se.DeletePowerItem(powerID)
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除角色
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteRole() {
|
||||
func (c *DeleteController) DeleteRole() {
|
||||
roleUid := strings.TrimSpace(c.GetString("roleUid"))
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.DeleteRoleByRoleUid(roleUid) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
}
|
||||
se := new(service.DeleteService)
|
||||
dataJSON := se.DeleteRole(roleUid)
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除操作员
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteOperator() {
|
||||
func (c *DeleteController) DeleteOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("userId"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.DeleteUserByUserId(userId) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
}
|
||||
se := new(service.DeleteService)
|
||||
dataJSON := se.DeleteOperator(userId)
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteBankCardRecord() {
|
||||
func (c *DeleteController) DeleteBankCardRecord() {
|
||||
uid := strings.TrimSpace(c.GetString("uid"))
|
||||
se := new(service.DeleteService)
|
||||
|
||||
dataJSON := new(BankCardDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
if models.DeleteBankCardByUid(uid) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
dataJSON := se.DeleteBankCardRecord(uid)
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
@ -206,135 +84,65 @@ func (c *Deletecontroller) DeleteBankCardRecord() {
|
||||
/*
|
||||
* 删除通道操作
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteRoad() {
|
||||
func (c *DeleteController) DeleteRoad() {
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
se := new(service.DeleteService)
|
||||
dataJSON := se.DeleteRoad(roadUid)
|
||||
|
||||
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() {
|
||||
func (c *DeleteController) DeleteRoadPool() {
|
||||
roadPoolCode := strings.TrimSpace(c.GetString("roadPoolCode"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
se := new(service.DeleteService)
|
||||
dataJSON := se.DeleteRoadPool(roadPoolCode)
|
||||
|
||||
if models.DeleteRoadPoolByCode(roadPoolCode) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Msg = "删除通道池失败"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除商户
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteMerchant() {
|
||||
func (c *DeleteController) DeleteMerchant() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if merchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
se := new(service.DeleteService)
|
||||
keyDataJSON := se.DeleteMerchant(merchantUid)
|
||||
|
||||
if models.DeleteMerchantByUid(merchantUid) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除账户
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteAccount() {
|
||||
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 = "删除账户失败"
|
||||
}
|
||||
}
|
||||
se := new(service.DeleteService)
|
||||
dataJSON := se.DeleteAccount(accountUid)
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteAgent() {
|
||||
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 = "删除失败"
|
||||
}
|
||||
}
|
||||
se := new(service.DeleteService)
|
||||
keyDataJSON := se.DeleteAgent(agentUid)
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteAgentRelation() {
|
||||
func (c *DeleteController) DeleteAgentRelation() {
|
||||
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
se := new(service.DeleteService)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON := se.DeleteAgentRelation(merchantUid)
|
||||
|
||||
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)
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
@ -11,29 +11,11 @@ package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
"strings"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
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, "/")
|
||||
}
|
||||
}
|
||||
web.Controller
|
||||
}
|
||||
|
||||
//jsonp请求过来的函数
|
||||
@ -48,9 +30,9 @@ func (c *FilterController) Filter() {
|
||||
dataJSON.Code = 404
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
c.SetSession("userID", userID)
|
||||
_ = c.SetSession("userID", userID)
|
||||
}
|
||||
fmt.Println(dataJSON)
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
@ -11,8 +11,16 @@ package controllers
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
controller "boss/supplier"
|
||||
"boss/datas"
|
||||
"boss/models/accounts"
|
||||
"boss/models/agent"
|
||||
"boss/models/merchant"
|
||||
"boss/models/notify"
|
||||
"boss/models/order"
|
||||
"boss/models/payfor"
|
||||
"boss/models/road"
|
||||
"boss/models/system"
|
||||
"boss/models/user"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
@ -70,24 +78,24 @@ func (c *GetController) GetMenu() {
|
||||
|
||||
params := make(map[string]string)
|
||||
params["first_menu__icontains"] = firstMenuSearch
|
||||
c.GetCutPage(models.GetMenuLenByMap(params))
|
||||
c.GetCutPage(system.GetMenuLenByMap(params))
|
||||
|
||||
menuDataJSON := new(MenuDataJSON)
|
||||
menuDataJSON := new(datas.MenuDataJSON)
|
||||
menuDataJSON.DisplayCount = c.DisplayCount
|
||||
menuDataJSON.CurrentPage = c.CurrentPage
|
||||
menuDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
menuDataJSON.Code = -1
|
||||
menuDataJSON.MenuList = make([]models.MenuInfo, 0)
|
||||
menuDataJSON.MenuList = make([]system.MenuInfo, 0)
|
||||
c.GenerateJSON(menuDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
menuInfoList := models.GetMenuOffsetByMap(params, c.DisplayCount, c.Offset)
|
||||
sort.Sort(models.MenuInfoSlice(menuInfoList))
|
||||
menuInfoList := system.GetMenuOffsetByMap(params, c.DisplayCount, c.Offset)
|
||||
sort.Sort(system.MenuInfoSlice(menuInfoList))
|
||||
for i, m := range menuInfoList {
|
||||
secondMenuInfoList := models.GetSecondMenuListByFirstMenuUid(m.MenuUid)
|
||||
secondMenuInfoList := system.GetSecondMenuListByFirstMenuUid(m.MenuUid)
|
||||
smenus := ""
|
||||
for j := 0; j < len(secondMenuInfoList); j++ {
|
||||
smenus += secondMenuInfoList[j].SecondMenu
|
||||
@ -110,15 +118,15 @@ func (c *GetController) GetMenu() {
|
||||
}
|
||||
|
||||
func (c *GetController) GetFirstMenu() {
|
||||
menuDataJSON := new(MenuDataJSON)
|
||||
menuList := models.GetMenuAll()
|
||||
menuDataJSON := new(datas.MenuDataJSON)
|
||||
menuList := system.GetMenuAll()
|
||||
|
||||
if len(menuList) == 0 {
|
||||
menuDataJSON.Code = -1
|
||||
} else {
|
||||
menuDataJSON.Code = 200
|
||||
}
|
||||
sort.Sort(models.MenuInfoSlice(menuList))
|
||||
sort.Sort(system.MenuInfoSlice(menuList))
|
||||
menuDataJSON.MenuList = menuList
|
||||
c.GenerateJSON(menuDataJSON)
|
||||
}
|
||||
@ -134,11 +142,11 @@ func (c *GetController) GetSecondMenu() {
|
||||
params := make(map[string]string)
|
||||
params["first_menu__icontains"] = firstMenuSearch
|
||||
params["second_menu__icontains"] = secondMenuSearch
|
||||
l := models.GetSecondMenuLenByMap(params)
|
||||
l := system.GetSecondMenuLenByMap(params)
|
||||
|
||||
c.GetCutPage(l)
|
||||
|
||||
secondMenuDataJSON := new(SecondMenuDataJSON)
|
||||
secondMenuDataJSON := new(datas.SecondMenuDataJSON)
|
||||
secondMenuDataJSON.DisplayCount = c.DisplayCount
|
||||
|
||||
secondMenuDataJSON.Code = 200
|
||||
@ -146,13 +154,13 @@ func (c *GetController) GetSecondMenu() {
|
||||
secondMenuDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
secondMenuDataJSON.SecondMenuList = make([]models.SecondMenuInfo, 0)
|
||||
secondMenuDataJSON.SecondMenuList = make([]system.SecondMenuInfo, 0)
|
||||
c.GenerateJSON(secondMenuDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
secondMenuList := models.GetSecondMenuByMap(params, c.DisplayCount, c.Offset)
|
||||
sort.Sort(models.SecondMenuSlice(secondMenuList))
|
||||
secondMenuList := system.GetSecondMenuByMap(params, c.DisplayCount, c.Offset)
|
||||
sort.Sort(system.SecondMenuSlice(secondMenuList))
|
||||
secondMenuDataJSON.SecondMenuList = secondMenuList
|
||||
secondMenuDataJSON.StartIndex = c.Offset
|
||||
|
||||
@ -166,9 +174,9 @@ func (c *GetController) GetSecondMenu() {
|
||||
func (c *GetController) GetSecondMenus() {
|
||||
firstMenuUid := strings.TrimSpace(c.GetString("firMenuUid"))
|
||||
|
||||
secondMenuDataJSON := new(SecondMenuDataJSON)
|
||||
secondMenuDataJSON := new(datas.SecondMenuDataJSON)
|
||||
|
||||
secondMenuList := models.GetSecondMenuListByFirstMenuUid(firstMenuUid)
|
||||
secondMenuList := system.GetSecondMenuListByFirstMenuUid(firstMenuUid)
|
||||
|
||||
secondMenuDataJSON.Code = 200
|
||||
secondMenuDataJSON.SecondMenuList = secondMenuList
|
||||
@ -178,18 +186,18 @@ func (c *GetController) GetSecondMenus() {
|
||||
func (c *GetController) GetOneMenu() {
|
||||
menuUid := c.GetString("menuUid")
|
||||
|
||||
dataJSON := new(MenuDataJSON)
|
||||
menuInfo := models.GetMenuInfoByMenuUid(menuUid)
|
||||
dataJSON := new(datas.MenuDataJSON)
|
||||
menuInfo := system.GetMenuInfoByMenuUid(menuUid)
|
||||
if menuInfo.MenuUid == "" {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "该菜单项不存在"
|
||||
} else {
|
||||
dataJSON.MenuList = make([]models.MenuInfo, 0)
|
||||
dataJSON.MenuList = make([]system.MenuInfo, 0)
|
||||
dataJSON.MenuList = append(dataJSON.MenuList, menuInfo)
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSONP()
|
||||
_ = c.ServeJSONP()
|
||||
}
|
||||
|
||||
func (c *GetController) GetPowerItem() {
|
||||
@ -200,25 +208,25 @@ func (c *GetController) GetPowerItem() {
|
||||
params["power_uid__icontains"] = powerID
|
||||
params["power_item_icontains"] = powerItem
|
||||
|
||||
l := models.GetPowerItemLenByMap(params)
|
||||
l := system.GetPowerItemLenByMap(params)
|
||||
|
||||
c.GetCutPage(l)
|
||||
|
||||
powerItemDataJSON := new(PowerItemDataJSON)
|
||||
powerItemDataJSON := new(datas.PowerItemDataJSON)
|
||||
powerItemDataJSON.DisplayCount = c.DisplayCount
|
||||
powerItemDataJSON.Code = 200
|
||||
powerItemDataJSON.CurrentPage = c.CurrentPage
|
||||
powerItemDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
powerItemDataJSON.PowerItemList = make([]models.PowerInfo, 0)
|
||||
powerItemDataJSON.PowerItemList = make([]system.PowerInfo, 0)
|
||||
c.GenerateJSON(powerItemDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
powerItemDataJSON.StartIndex = c.Offset
|
||||
powerItemList := models.GetPowerItemByMap(params, c.DisplayCount, c.Offset)
|
||||
sort.Sort(models.PowerInfoSlice(powerItemList))
|
||||
powerItemList := system.GetPowerItemByMap(params, c.DisplayCount, c.Offset)
|
||||
sort.Sort(system.PowerInfoSlice(powerItemList))
|
||||
powerItemDataJSON.PowerItemList = powerItemList
|
||||
|
||||
c.GenerateJSON(powerItemDataJSON)
|
||||
@ -230,29 +238,29 @@ func (c *GetController) GetRole() {
|
||||
params := make(map[string]string)
|
||||
params["role_name__icontains"] = roleName
|
||||
|
||||
l := models.GetRoleLenByMap(params)
|
||||
l := system.GetRoleLenByMap(params)
|
||||
|
||||
c.GetCutPage(l)
|
||||
|
||||
roleInfoDataJSON := new(RoleInfoDataJSON)
|
||||
roleInfoDataJSON := new(datas.RoleInfoDataJSON)
|
||||
roleInfoDataJSON.DisplayCount = c.DisplayCount
|
||||
roleInfoDataJSON.Code = 200
|
||||
roleInfoDataJSON.CurrentPage = c.CurrentPage
|
||||
roleInfoDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
roleInfoDataJSON.RoleInfoList = make([]models.RoleInfo, 0)
|
||||
roleInfoDataJSON.RoleInfoList = make([]system.RoleInfo, 0)
|
||||
c.GenerateJSON(roleInfoDataJSON)
|
||||
return
|
||||
}
|
||||
roleInfoDataJSON.StartIndex = c.Offset
|
||||
roleInfoDataJSON.RoleInfoList = models.GetRoleByMap(params, c.DisplayCount, c.Offset)
|
||||
roleInfoDataJSON.RoleInfoList = system.GetRoleByMap(params, c.DisplayCount, c.Offset)
|
||||
c.GenerateJSON(roleInfoDataJSON)
|
||||
}
|
||||
|
||||
func (c *GetController) GetAllRole() {
|
||||
roleInfoDataJSON := new(RoleInfoDataJSON)
|
||||
roleInfoList := models.GetRole()
|
||||
roleInfoDataJSON := new(datas.RoleInfoDataJSON)
|
||||
roleInfoList := system.GetRole()
|
||||
fmt.Println(roleInfoList)
|
||||
if len(roleInfoList) == 0 {
|
||||
roleInfoDataJSON.Code = -1
|
||||
@ -265,15 +273,15 @@ func (c *GetController) GetAllRole() {
|
||||
|
||||
func (c *GetController) GetDeployTree() {
|
||||
roleUid := strings.TrimSpace(c.GetString("roleUid"))
|
||||
roleInfo := models.GetRoleByRoleUid(roleUid)
|
||||
roleInfo := system.GetRoleByRoleUid(roleUid)
|
||||
|
||||
allFirstMenu := models.GetMenuAll()
|
||||
sort.Sort(models.MenuInfoSlice(allFirstMenu))
|
||||
allSecondMenu := models.GetSecondMenuList()
|
||||
sort.Sort(models.SecondMenuSlice(allSecondMenu))
|
||||
allPower := models.GetPower()
|
||||
allFirstMenu := system.GetMenuAll()
|
||||
sort.Sort(system.MenuInfoSlice(allFirstMenu))
|
||||
allSecondMenu := system.GetSecondMenuList()
|
||||
sort.Sort(system.SecondMenuSlice(allSecondMenu))
|
||||
allPower := system.GetPower()
|
||||
|
||||
deployTreeJSON := new(DeployTreeJSON)
|
||||
deployTreeJSON := new(datas.DeployTreeJSON)
|
||||
deployTreeJSON.Code = 200
|
||||
deployTreeJSON.AllFirstMenu = allFirstMenu
|
||||
deployTreeJSON.AllSecondMenu = allSecondMenu
|
||||
@ -303,32 +311,32 @@ func (c *GetController) GetOperator() {
|
||||
params := make(map[string]string)
|
||||
params["user_id__icontains"] = operatorName
|
||||
|
||||
l := models.GetOperatorLenByMap(params)
|
||||
l := user.GetOperatorLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
operatorDataJSON := new(OperatorDataJSON)
|
||||
operatorDataJSON := new(datas.OperatorDataJSON)
|
||||
operatorDataJSON.DisplayCount = c.DisplayCount
|
||||
operatorDataJSON.Code = 200
|
||||
operatorDataJSON.CurrentPage = c.CurrentPage
|
||||
operatorDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
operatorDataJSON.OperatorList = make([]models.UserInfo, 0)
|
||||
operatorDataJSON.OperatorList = make([]user.UserInfo, 0)
|
||||
c.GenerateJSON(operatorDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
operatorDataJSON.StartIndex = c.Offset
|
||||
operatorDataJSON.OperatorList = models.GetOperatorByMap(params, c.DisplayCount, c.Offset)
|
||||
operatorDataJSON.OperatorList = user.GetOperatorByMap(params, c.DisplayCount, c.Offset)
|
||||
c.GenerateJSON(operatorDataJSON)
|
||||
}
|
||||
|
||||
func (c *GetController) GetOneOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("userId"))
|
||||
|
||||
userInfo := models.GetUserInfoByUserID(userId)
|
||||
userInfo := user.GetUserInfoByUserID(userId)
|
||||
|
||||
operatorDataJSON := new(OperatorDataJSON)
|
||||
operatorDataJSON.OperatorList = make([]models.UserInfo, 0)
|
||||
operatorDataJSON := new(datas.OperatorDataJSON)
|
||||
operatorDataJSON.OperatorList = make([]user.UserInfo, 0)
|
||||
operatorDataJSON.OperatorList = append(operatorDataJSON.OperatorList, userInfo)
|
||||
|
||||
operatorDataJSON.Code = 200
|
||||
@ -339,11 +347,11 @@ func (c *GetController) GetOneOperator() {
|
||||
func (c *GetController) GetEditOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("userId"))
|
||||
|
||||
editOperatorDataJSON := new(EditOperatorDataJSON)
|
||||
userInfo := models.GetUserInfoByUserID(userId)
|
||||
editOperatorDataJSON := new(datas.EditOperatorDataJSON)
|
||||
userInfo := user.GetUserInfoByUserID(userId)
|
||||
fmt.Println(userInfo)
|
||||
editOperatorDataJSON.OperatorList = append(editOperatorDataJSON.OperatorList, userInfo)
|
||||
editOperatorDataJSON.RoleList = models.GetRole()
|
||||
editOperatorDataJSON.RoleList = system.GetRole()
|
||||
editOperatorDataJSON.Code = 200
|
||||
|
||||
c.GenerateJSON(editOperatorDataJSON)
|
||||
@ -354,31 +362,31 @@ func (c *GetController) GetBankCard() {
|
||||
params := make(map[string]string)
|
||||
params["account_name__icontains"] = accountNameSearch
|
||||
|
||||
l := models.GetBankCardLenByMap(params)
|
||||
l := system.GetBankCardLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
bankCardDataJSON := new(BankCardDataJSON)
|
||||
bankCardDataJSON := new(datas.BankCardDataJSON)
|
||||
bankCardDataJSON.DisplayCount = c.DisplayCount
|
||||
bankCardDataJSON.Code = 200
|
||||
bankCardDataJSON.CurrentPage = c.CurrentPage
|
||||
bankCardDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
bankCardDataJSON.BankCardInfoList = make([]models.BankCardInfo, 0)
|
||||
bankCardDataJSON.BankCardInfoList = make([]system.BankCardInfo, 0)
|
||||
c.GenerateJSON(bankCardDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
bankCardDataJSON.StartIndex = c.Offset
|
||||
bankCardDataJSON.BankCardInfoList = models.GetBankCardByMap(params, c.DisplayCount, c.Offset)
|
||||
bankCardDataJSON.BankCardInfoList = system.GetBankCardByMap(params, c.DisplayCount, c.Offset)
|
||||
c.GenerateJSON(bankCardDataJSON)
|
||||
}
|
||||
|
||||
func (c *GetController) GetOneBankCard() {
|
||||
uid := strings.TrimSpace(c.GetString("uid"))
|
||||
bankCardInfo := models.GetBankCardByUid(uid)
|
||||
bankCardInfo := system.GetBankCardByUid(uid)
|
||||
|
||||
bankCardDataJSON := new(BankCardDataJSON)
|
||||
bankCardDataJSON := new(datas.BankCardDataJSON)
|
||||
bankCardDataJSON.Code = -1
|
||||
|
||||
if bankCardInfo.Uid != "" {
|
||||
@ -405,24 +413,24 @@ func (c *GetController) GetRoad() {
|
||||
params["road_uid"] = roadUid
|
||||
params["pay_type"] = payType
|
||||
|
||||
l := models.GetRoadLenByMap(params)
|
||||
l := road.GetRoadLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
roadDataJSON := new(RoadDataJSON)
|
||||
roadDataJSON := new(datas.RoadDataJSON)
|
||||
roadDataJSON.DisplayCount = c.DisplayCount
|
||||
roadDataJSON.Code = 200
|
||||
roadDataJSON.CurrentPage = c.CurrentPage
|
||||
roadDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
roadDataJSON.RoadInfoList = make([]models.RoadInfo, 0)
|
||||
roadDataJSON.RoadInfoList = make([]road.RoadInfo, 0)
|
||||
c.GenerateJSON(roadDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
roadDataJSON.StartIndex = c.Offset
|
||||
roadDataJSON.RoadInfoList = models.GetRoadInfoByMap(params, c.DisplayCount, c.Offset)
|
||||
roadDataJSON.RoadPool = models.GetRoadPoolByRoadPoolCode(roadPoolCode)
|
||||
roadDataJSON.RoadInfoList = road.GetRoadInfoByMap(params, c.DisplayCount, c.Offset)
|
||||
roadDataJSON.RoadPool = road.GetRoadPoolByRoadPoolCode(roadPoolCode)
|
||||
c.GenerateJSON(roadDataJSON)
|
||||
}
|
||||
|
||||
@ -431,8 +439,8 @@ func (c *GetController) GetAllRoad() {
|
||||
params := make(map[string]string)
|
||||
params["road_name__icontains"] = roadName
|
||||
|
||||
roadDataJSON := new(RoadDataJSON)
|
||||
roadInfoList := models.GetAllRoad(params)
|
||||
roadDataJSON := new(datas.RoadDataJSON)
|
||||
roadInfoList := road.GetAllRoad(params)
|
||||
|
||||
roadDataJSON.Code = 200
|
||||
roadDataJSON.RoadInfoList = roadInfoList
|
||||
@ -445,15 +453,15 @@ func (c *GetController) GetAllRoad() {
|
||||
func (c *GetController) GetOneRoad() {
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))
|
||||
|
||||
roadInfo := models.GetRoadInfoByRoadUid(roadUid)
|
||||
roadDataJSON := new(RoadDataJSON)
|
||||
roadInfo := road.GetRoadInfoByRoadUid(roadUid)
|
||||
roadDataJSON := new(datas.RoadDataJSON)
|
||||
roadDataJSON.Code = -1
|
||||
|
||||
if roadInfo.RoadUid != "" {
|
||||
roadDataJSON.RoadInfoList = append(roadDataJSON.RoadInfoList, roadInfo)
|
||||
roadDataJSON.Code = 200
|
||||
} else {
|
||||
roadDataJSON.RoadInfoList = make([]models.RoadInfo, 0)
|
||||
roadDataJSON.RoadInfoList = make([]road.RoadInfo, 0)
|
||||
}
|
||||
|
||||
c.GenerateJSON(roadDataJSON)
|
||||
@ -467,23 +475,23 @@ func (c *GetController) GetRoadPool() {
|
||||
params["road_pool_name__icontains"] = roadPoolName
|
||||
params["road_pool_code__icontains"] = roadPoolCode
|
||||
|
||||
l := models.GetRoadPoolLenByMap(params)
|
||||
l := road.GetRoadPoolLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
roadPoolDataJSON := new(RoadPoolDataJSON)
|
||||
roadPoolDataJSON := new(datas.RoadPoolDataJSON)
|
||||
roadPoolDataJSON.DisplayCount = c.DisplayCount
|
||||
roadPoolDataJSON.Code = 200
|
||||
roadPoolDataJSON.CurrentPage = c.CurrentPage
|
||||
roadPoolDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
roadPoolDataJSON.RoadPoolInfoList = make([]models.RoadPoolInfo, 0)
|
||||
roadPoolDataJSON.RoadPoolInfoList = make([]road.RoadPoolInfo, 0)
|
||||
c.GenerateJSON(roadPoolDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
roadPoolDataJSON.StartIndex = c.Offset
|
||||
roadPoolDataJSON.RoadPoolInfoList = models.GetRoadPoolByMap(params, c.DisplayCount, c.Offset)
|
||||
roadPoolDataJSON.RoadPoolInfoList = road.GetRoadPoolByMap(params, c.DisplayCount, c.Offset)
|
||||
c.GenerateJSON(roadPoolDataJSON)
|
||||
}
|
||||
|
||||
@ -492,9 +500,9 @@ func (c *GetController) GetAllRollPool() {
|
||||
params := make(map[string]string)
|
||||
params["road_pool_name__icontains"] = rollPoolName
|
||||
|
||||
roadPoolDataJSON := new(RoadPoolDataJSON)
|
||||
roadPoolDataJSON := new(datas.RoadPoolDataJSON)
|
||||
roadPoolDataJSON.Code = 200
|
||||
roadPoolDataJSON.RoadPoolInfoList = models.GetAllRollPool(params)
|
||||
roadPoolDataJSON.RoadPoolInfoList = road.GetAllRollPool(params)
|
||||
c.GenerateJSON(roadPoolDataJSON)
|
||||
}
|
||||
|
||||
@ -506,36 +514,36 @@ func (c *GetController) GetMerchant() {
|
||||
params["merchant_name__icontains"] = merchantName
|
||||
params["merchant_uid__icontains"] = merchantNo
|
||||
|
||||
l := models.GetMerchantLenByMap(params)
|
||||
l := merchant.GetMerchantLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
merchantDataJSON := new(MerchantDataJSON)
|
||||
merchantDataJSON := new(datas.MerchantDataJSON)
|
||||
merchantDataJSON.DisplayCount = c.DisplayCount
|
||||
merchantDataJSON.Code = 200
|
||||
merchantDataJSON.CurrentPage = c.CurrentPage
|
||||
merchantDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
merchantDataJSON.MerchantList = make([]models.MerchantInfo, 0)
|
||||
merchantDataJSON.MerchantList = make([]merchant.MerchantInfo, 0)
|
||||
c.GenerateJSON(merchantDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
merchantDataJSON.StartIndex = c.Offset
|
||||
merchantDataJSON.MerchantList = models.GetMerchantListByMap(params, c.DisplayCount, c.Offset)
|
||||
merchantDataJSON.MerchantList = merchant.GetMerchantListByMap(params, c.DisplayCount, c.Offset)
|
||||
c.GenerateJSON(merchantDataJSON)
|
||||
}
|
||||
|
||||
func (c *GetController) GetAllMerchant() {
|
||||
merchantDataJSON := new(MerchantDataJSON)
|
||||
merchantDataJSON := new(datas.MerchantDataJSON)
|
||||
merchantDataJSON.Code = 200
|
||||
merchantDataJSON.MerchantList = models.GetAllMerchant()
|
||||
merchantDataJSON.MerchantList = merchant.GetAllMerchant()
|
||||
c.GenerateJSON(merchantDataJSON)
|
||||
}
|
||||
|
||||
func (c *GetController) GetOneMerchant() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
merchantDataJSON := new(MerchantDataJSON)
|
||||
merchantDataJSON := new(datas.MerchantDataJSON)
|
||||
|
||||
if merchantUid == "" {
|
||||
merchantDataJSON.Code = -1
|
||||
@ -543,7 +551,7 @@ func (c *GetController) GetOneMerchant() {
|
||||
return
|
||||
}
|
||||
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
merchantInfo := merchant.GetMerchantByUid(merchantUid)
|
||||
|
||||
merchantDataJSON.Code = 200
|
||||
merchantDataJSON.MerchantList = append(merchantDataJSON.MerchantList, merchantInfo)
|
||||
@ -554,9 +562,9 @@ func (c *GetController) GetOneMerchantDeploy() {
|
||||
merchantNo := strings.TrimSpace(c.GetString("merchantNo"))
|
||||
payType := strings.TrimSpace(c.GetString("payType"))
|
||||
|
||||
merchantDeployDataJSON := new(MerchantDeployDataJSON)
|
||||
merchantDeployDataJSON := new(datas.MerchantDeployDataJSON)
|
||||
|
||||
merchantDeployInfo := models.GetMerchantDeployByUidAndPayType(merchantNo, payType)
|
||||
merchantDeployInfo := merchant.GetMerchantDeployByUidAndPayType(merchantNo, payType)
|
||||
|
||||
if merchantDeployInfo.Status == "active" {
|
||||
merchantDeployDataJSON.Code = 200
|
||||
@ -570,10 +578,10 @@ func (c *GetController) GetOneMerchantDeploy() {
|
||||
}
|
||||
|
||||
func (c *GetController) GetAllAccount() {
|
||||
accountDataJSON := new(AccountDataJSON)
|
||||
accountDataJSON := new(datas.AccountDataJSON)
|
||||
accountDataJSON.Code = 200
|
||||
|
||||
accountDataJSON.AccountList = models.GetAllAccount()
|
||||
accountDataJSON.AccountList = accounts.GetAllAccount()
|
||||
|
||||
c.GenerateJSON(accountDataJSON)
|
||||
}
|
||||
@ -586,23 +594,23 @@ func (c *GetController) GetAccount() {
|
||||
params["account_name__icontains"] = accountName
|
||||
params["account_uid_icontains"] = accountUid
|
||||
|
||||
l := models.GetAccountLenByMap(params)
|
||||
l := accounts.GetAccountLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
accountDataJSON := new(AccountDataJSON)
|
||||
accountDataJSON := new(datas.AccountDataJSON)
|
||||
accountDataJSON.DisplayCount = c.DisplayCount
|
||||
accountDataJSON.Code = 200
|
||||
accountDataJSON.CurrentPage = c.CurrentPage
|
||||
accountDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
accountDataJSON.AccountList = make([]models.AccountInfo, 0)
|
||||
accountDataJSON.AccountList = make([]accounts.AccountInfo, 0)
|
||||
c.GenerateJSON(accountDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
accountDataJSON.StartIndex = c.Offset
|
||||
accountDataJSON.AccountList = models.GetAccountByMap(params, c.DisplayCount, c.Offset)
|
||||
accountDataJSON.AccountList = accounts.GetAccountByMap(params, c.DisplayCount, c.Offset)
|
||||
c.GenerateJSON(accountDataJSON)
|
||||
}
|
||||
|
||||
@ -610,9 +618,9 @@ func (c *GetController) GetOneAccount() {
|
||||
//从http的body中获取accountUid字段,并且这个字段是string类型
|
||||
accountUid := strings.TrimSpace(c.GetString("accountUid"))
|
||||
//new一个accountDataJSON结构体对象,用来做jsonp返回
|
||||
accountDataJSON := new(AccountDataJSON)
|
||||
accountDataJSON := new(datas.AccountDataJSON)
|
||||
//用accountuid作为过滤字段,从数据库中读取一条信息
|
||||
accountInfo := models.GetAccountByUid(accountUid)
|
||||
accountInfo := accounts.GetAccountByUid(accountUid)
|
||||
//code初始值为200
|
||||
accountDataJSON.Code = 200
|
||||
//将从数据库读出来的数据插入到accountList数组中
|
||||
@ -645,23 +653,23 @@ func (c *GetController) GetAccountHistory() {
|
||||
params["create_time__gte"] = startTime
|
||||
params["create_time__lte"] = endTime
|
||||
|
||||
l := models.GetAccountHistoryLenByMap(params)
|
||||
l := accounts.GetAccountHistoryLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
accountHistoryDataJSON := new(AccountHistoryDataJSON)
|
||||
accountHistoryDataJSON := new(datas.AccountHistoryDataJSON)
|
||||
accountHistoryDataJSON.DisplayCount = c.DisplayCount
|
||||
accountHistoryDataJSON.Code = 200
|
||||
accountHistoryDataJSON.CurrentPage = c.CurrentPage
|
||||
accountHistoryDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
accountHistoryDataJSON.AccountHistoryList = make([]models.AccountHistoryInfo, 0)
|
||||
accountHistoryDataJSON.AccountHistoryList = make([]accounts.AccountHistoryInfo, 0)
|
||||
c.GenerateJSON(accountHistoryDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
accountHistoryDataJSON.StartIndex = c.Offset
|
||||
accountHistoryDataJSON.AccountHistoryList = models.GetAccountHistoryByMap(params, c.DisplayCount, c.Offset)
|
||||
accountHistoryDataJSON.AccountHistoryList = accounts.GetAccountHistoryByMap(params, c.DisplayCount, c.Offset)
|
||||
c.GenerateJSON(accountHistoryDataJSON)
|
||||
}
|
||||
|
||||
@ -670,23 +678,23 @@ func (c *GetController) GetAgent() {
|
||||
params := make(map[string]string)
|
||||
params["agnet_name__icontains"] = agentName
|
||||
|
||||
l := models.GetAgentInfoLenByMap(params)
|
||||
l := agent.GetAgentInfoLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
agentDataJSON := new(AgentDataJSON)
|
||||
agentDataJSON := new(datas.AgentDataJSON)
|
||||
agentDataJSON.DisplayCount = c.DisplayCount
|
||||
agentDataJSON.Code = 200
|
||||
agentDataJSON.CurrentPage = c.CurrentPage
|
||||
agentDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
agentDataJSON.AgentList = make([]models.AgentInfo, 0)
|
||||
agentDataJSON.AgentList = make([]agent.AgentInfo, 0)
|
||||
c.GenerateJSON(agentDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
agentDataJSON.StartIndex = c.Offset
|
||||
agentDataJSON.AgentList = models.GetAgentInfoByMap(params, c.DisplayCount, c.Offset)
|
||||
agentDataJSON.AgentList = agent.GetAgentInfoByMap(params, c.DisplayCount, c.Offset)
|
||||
c.GenerateJSON(agentDataJSON)
|
||||
}
|
||||
|
||||
@ -695,16 +703,16 @@ func (c *GetController) GetAllAgent() {
|
||||
params := make(map[string]string)
|
||||
params["agent_name__icontains"] = agentName
|
||||
|
||||
agentDataJSON := new(AgentDataJSON)
|
||||
agentDataJSON := new(datas.AgentDataJSON)
|
||||
agentDataJSON.Code = 200
|
||||
agentDataJSON.AgentList = models.GetAllAgentByMap(params)
|
||||
agentDataJSON.AgentList = agent.GetAllAgentByMap(params)
|
||||
|
||||
c.GenerateJSON(agentDataJSON)
|
||||
}
|
||||
|
||||
func (c *GetController) GetProduct() {
|
||||
supplierCode2Name := common.GetSupplierMap()
|
||||
productDataJSON := new(ProductDataJSON)
|
||||
productDataJSON := new(datas.ProductDataJSON)
|
||||
productDataJSON.Code = 200
|
||||
productDataJSON.ProductMap = supplierCode2Name
|
||||
c.GenerateJSON(productDataJSON)
|
||||
@ -718,19 +726,19 @@ func (c *GetController) GetAgentToMerchant() {
|
||||
params["belong_agent_uid"] = agentUid
|
||||
params["merchant_uid"] = merchantUid
|
||||
|
||||
l := models.GetMerchantLenByParams(params)
|
||||
l := merchant.GetMerchantLenByParams(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
merchantDataJSON := new(MerchantDataJSON)
|
||||
merchantDataJSON := new(datas.MerchantDataJSON)
|
||||
merchantDataJSON.DisplayCount = c.DisplayCount
|
||||
merchantDataJSON.Code = 200
|
||||
merchantDataJSON.CurrentPage = c.CurrentPage
|
||||
merchantDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
merchantDataJSON.MerchantList = make([]models.MerchantInfo, 0)
|
||||
merchantDataJSON.MerchantList = make([]merchant.MerchantInfo, 0)
|
||||
} else {
|
||||
merchantDataJSON.MerchantList = models.GetMerchantByParams(params, c.DisplayCount, c.Offset)
|
||||
merchantDataJSON.MerchantList = merchant.GetMerchantByParams(params, c.DisplayCount, c.Offset)
|
||||
}
|
||||
|
||||
c.GenerateJSON(merchantDataJSON)
|
||||
@ -768,36 +776,37 @@ func (c *GetController) GetOrder() {
|
||||
params["refund"] = "yes"
|
||||
}
|
||||
|
||||
l := models.GetOrderLenByMap(params)
|
||||
l := order.GetOrderLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
orderDataJSON := new(OrderDataJSON)
|
||||
orderDataJSON := new(datas.OrderDataJSON)
|
||||
orderDataJSON.DisplayCount = c.DisplayCount
|
||||
orderDataJSON.Code = 200
|
||||
orderDataJSON.CurrentPage = c.CurrentPage
|
||||
orderDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
orderDataJSON.OrderList = make([]models.OrderInfo, 0)
|
||||
orderDataJSON.OrderList = make([]order.OrderInfo, 0)
|
||||
c.GenerateJSON(orderDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
orderDataJSON.StartIndex = c.Offset
|
||||
orderDataJSON.OrderList = models.GetOrderByMap(params, c.DisplayCount, c.Offset)
|
||||
orderDataJSON.SuccessRate = models.GetSuccessRateByMap(params)
|
||||
orderDataJSON.AllAmount = models.GetAllAmountByMap(params)
|
||||
orderDataJSON.OrderList = order.GetOrderByMap(params, c.DisplayCount, c.Offset)
|
||||
orderDataJSON.SuccessRate = order.GetSuccessRateByMap(params)
|
||||
params["status"] = common.SUCCESS
|
||||
orderDataJSON.AllAmount = order.GetAllAmountByMap(params)
|
||||
c.GenerateJSON(orderDataJSON)
|
||||
}
|
||||
|
||||
func (c *GetController) GetOneOrder() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
orderDataJSON := new(OrderDataJSON)
|
||||
orderInfo := models.GetOneOrder(bankOrderId)
|
||||
orderDataJSON := new(datas.OrderDataJSON)
|
||||
orderInfo := order.GetOneOrder(bankOrderId)
|
||||
|
||||
orderDataJSON.Code = 200
|
||||
orderDataJSON.OrderList = append(orderDataJSON.OrderList, orderInfo)
|
||||
notifyInfo := models.GetNotifyInfoByBankOrderId(bankOrderId)
|
||||
notifyInfo := notify.GetNotifyInfoByBankOrderId(bankOrderId)
|
||||
if notifyInfo.Url == "" || len(notifyInfo.Url) == 0 {
|
||||
orderDataJSON.NotifyUrl = orderInfo.NotifyUrl
|
||||
} else {
|
||||
@ -826,23 +835,23 @@ func (c *GetController) GetOrderProfit() {
|
||||
params["pay_product_code"] = supplierUid
|
||||
params["pay_type_code"] = payWayCode
|
||||
|
||||
l := models.GetOrderProfitLenByMap(params)
|
||||
l := order.GetOrderProfitLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
listDataJSON := new(ListDataJSON)
|
||||
listDataJSON := new(datas.ListDataJSON)
|
||||
listDataJSON.DisplayCount = c.DisplayCount
|
||||
listDataJSON.Code = 200
|
||||
listDataJSON.CurrentPage = c.CurrentPage
|
||||
listDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
listDataJSON.List = make([]models.OrderProfitInfo, 0)
|
||||
listDataJSON.List = make([]order.OrderProfitInfo, 0)
|
||||
c.GenerateJSON(listDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
listDataJSON.StartIndex = c.Offset
|
||||
listDataJSON.List = models.GetOrderProfitByMap(params, c.DisplayCount, c.Offset)
|
||||
listDataJSON.List = order.GetOrderProfitByMap(params, c.DisplayCount, c.Offset)
|
||||
supplierAll := 0.0
|
||||
platformAll := 0.0
|
||||
agentAll := 0.0
|
||||
@ -878,23 +887,23 @@ func (c *GetController) GetPayFor() {
|
||||
params["bank_order_id"] = bankOrderId
|
||||
params["status"] = status
|
||||
|
||||
l := models.GetPayForLenByMap(params)
|
||||
l := payfor.GetPayForLenByMap(params)
|
||||
c.GetCutPage(l)
|
||||
|
||||
listDataJSON := new(PayForDataJSON)
|
||||
listDataJSON := new(datas.PayForDataJSON)
|
||||
listDataJSON.DisplayCount = c.DisplayCount
|
||||
listDataJSON.Code = 200
|
||||
listDataJSON.CurrentPage = c.CurrentPage
|
||||
listDataJSON.TotalPage = c.TotalPage
|
||||
|
||||
if c.Offset < 0 {
|
||||
listDataJSON.PayForList = make([]models.PayforInfo, 0)
|
||||
listDataJSON.PayForList = make([]payfor.PayforInfo, 0)
|
||||
c.GenerateJSON(listDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
listDataJSON.StartIndex = c.Offset
|
||||
listDataJSON.PayForList = models.GetPayForByMap(params, c.DisplayCount, c.Offset)
|
||||
listDataJSON.PayForList = payfor.GetPayForByMap(params, c.DisplayCount, c.Offset)
|
||||
for index, p := range listDataJSON.PayForList {
|
||||
if p.MerchantName == "" {
|
||||
listDataJSON.PayForList[index].MerchantName = "任意下发"
|
||||
@ -912,9 +921,9 @@ func (c *GetController) GetPayFor() {
|
||||
func (c *GetController) GetOnePayFor() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
payForInfo := models.GetPayForByBankOrderId(bankOrderId)
|
||||
payForInfo := payfor.GetPayForByBankOrderId(bankOrderId)
|
||||
|
||||
listDataJSON := new(PayForDataJSON)
|
||||
listDataJSON := new(datas.PayForDataJSON)
|
||||
listDataJSON.Code = 200
|
||||
listDataJSON.PayForList = append(listDataJSON.PayForList, payForInfo)
|
||||
|
||||
@ -922,27 +931,29 @@ func (c *GetController) GetOnePayFor() {
|
||||
}
|
||||
|
||||
func (c *GetController) GetBalance() {
|
||||
roadName := strings.TrimSpace(c.GetString("roadName"))
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))
|
||||
/*roadName := strings.TrimSpace(c.GetString("roadName"))
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))*/
|
||||
|
||||
var roadInfo models.RoadInfo
|
||||
/*var roadInfo road.RoadInfo
|
||||
if roadUid != "" {
|
||||
roadInfo = models.GetRoadInfoByRoadUid(roadUid)
|
||||
roadInfo = road.GetRoadInfoByRoadUid(roadUid)
|
||||
} else {
|
||||
roadInfo = models.GetRoadInfoByName(roadName)
|
||||
}
|
||||
roadInfo = road.GetRoadInfoByName(roadName)
|
||||
}*/
|
||||
|
||||
balanceDataJSON := new(BalanceDataJSON)
|
||||
balanceDataJSON := new(datas.BalanceDataJSON)
|
||||
balanceDataJSON.Code = 200
|
||||
|
||||
supplier := controller.GetPaySupplierByCode(roadInfo.ProductUid)
|
||||
/*supplier := controller.GetPaySupplierByCode(roadInfo.ProductUid)
|
||||
if supplier == nil {
|
||||
balanceDataJSON.Code = -1
|
||||
balanceDataJSON.Balance = -1.00
|
||||
} else {
|
||||
balance := supplier.BalanceQuery(roadInfo)
|
||||
balanceDataJSON.Balance = balance
|
||||
}
|
||||
}*/
|
||||
// TODO 从gateway获取账户余额
|
||||
balanceDataJSON.Balance = 1
|
||||
|
||||
c.GenerateJSON(balanceDataJSON)
|
||||
}
|
||||
@ -959,9 +970,9 @@ func (c *GetController) GetNotifyBankOrderIdList() {
|
||||
params["merchant_uid"] = merchantUid
|
||||
params["type"] = notifyType
|
||||
|
||||
bankOrderIdListJSON := new(NotifyBankOrderIdListJSON)
|
||||
bankOrderIdListJSON := new(datas.NotifyBankOrderIdListJSON)
|
||||
bankOrderIdListJSON.Code = 200
|
||||
bankOrderIdListJSON.NotifyIdList = models.GetNotifyBankOrderIdListByParams(params)
|
||||
bankOrderIdListJSON.NotifyIdList = notify.GetNotifyBankOrderIdListByParams(params)
|
||||
c.GenerateJSON(bankOrderIdListJSON)
|
||||
}
|
||||
|
||||
@ -984,9 +995,9 @@ func (c *GetController) GetProfit() {
|
||||
params["create_time__gte"] = startTime
|
||||
params["create_time__lte"] = endTime
|
||||
|
||||
profitListJSON := new(ProfitListJSON)
|
||||
profitListJSON := new(datas.ProfitListJSON)
|
||||
profitListJSON.Code = 200
|
||||
profitListJSON.ProfitList = models.GetPlatformProfitByMap(params)
|
||||
profitListJSON.ProfitList = order.GetPlatformProfitByMap(params)
|
||||
|
||||
profitListJSON.TotalAmount = 0.00
|
||||
profitListJSON.PlatformTotalProfit = 0.00
|
||||
|
@ -2,7 +2,8 @@ package controllers
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
"boss/datas"
|
||||
"boss/models/user"
|
||||
"boss/utils"
|
||||
"github.com/beego/beego/v2/adapter/validation"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
@ -23,7 +24,7 @@ func (c *LoginController) Login() {
|
||||
passWD := c.GetString("passwd")
|
||||
code := c.GetString("Code")
|
||||
|
||||
dataJSON := new(KeyDataJSON)
|
||||
dataJSON := new(datas.KeyDataJSON)
|
||||
|
||||
valid := validation.Validation{}
|
||||
|
||||
@ -38,7 +39,7 @@ func (c *LoginController) Login() {
|
||||
dataJSON.Msg = "验证码不正确!"
|
||||
}
|
||||
|
||||
userInfo := models.GetUserInfoByUserID(userID)
|
||||
userInfo := user.GetUserInfoByUserID(userID)
|
||||
|
||||
if userInfo.UserId == "" {
|
||||
dataJSON.Key = "userID"
|
||||
@ -54,8 +55,8 @@ func (c *LoginController) Login() {
|
||||
} else if code != codeInterface.(string) {
|
||||
dataJSON.Key = "code"
|
||||
dataJSON.Msg = "验证码不正确!"
|
||||
} else if userInfo.Status == "unactive" {
|
||||
dataJSON.Key = "unactive"
|
||||
} else if userInfo.Status == common.UNACTIVE {
|
||||
dataJSON.Key = common.UNACTIVE
|
||||
dataJSON.Msg = "用户已被冻结!"
|
||||
} else if userInfo.Status == "del" {
|
||||
dataJSON.Key = "del"
|
||||
@ -65,16 +66,16 @@ func (c *LoginController) Login() {
|
||||
|
||||
go func() {
|
||||
userInfo.Ip = c.Ctx.Input.IP()
|
||||
models.UpdateUserInfoIP(userInfo)
|
||||
user.UpdateUserInfoIP(userInfo)
|
||||
}()
|
||||
|
||||
if dataJSON.Key == "" {
|
||||
c.SetSession("userID", userID)
|
||||
c.DelSession("verifyCode")
|
||||
_ = c.SetSession("userID", userID)
|
||||
_ = c.DelSession("verifyCode")
|
||||
}
|
||||
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
@ -82,13 +83,13 @@ func (c *LoginController) Login() {
|
||||
*/
|
||||
|
||||
func (c *LoginController) Logout() {
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON := new(datas.BaseDataJSON)
|
||||
|
||||
c.DelSession("userID")
|
||||
_ = c.DelSession("userID")
|
||||
dataJSON.Code = 200
|
||||
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
@ -99,8 +100,12 @@ func (c *LoginController) GetVerifyImg() {
|
||||
if Image == nil || len(verifyCode) != common.VERIFY_CODE_LEN {
|
||||
logs.Error("获取验证码图片失败!")
|
||||
} else {
|
||||
c.SetSession("verifyCode", verifyCode)
|
||||
_ = c.SetSession("verifyCode", verifyCode)
|
||||
}
|
||||
logs.Info("验证码:", verifyCode)
|
||||
Image.WriteTo(c.Ctx.ResponseWriter)
|
||||
if Image == nil {
|
||||
logs.Error("生成验证码失败!")
|
||||
} else {
|
||||
_, _ = Image.WriteTo(c.Ctx.ResponseWriter)
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
@ -19,7 +18,6 @@ type PageController struct {
|
||||
}
|
||||
|
||||
func (c *PageController) Index() {
|
||||
fmt.Println("dlfjldkjfldjfljljljlj")
|
||||
c.TplName = "index.html"
|
||||
}
|
||||
|
||||
|
@ -10,60 +10,24 @@
|
||||
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"
|
||||
"boss/service"
|
||||
"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 "订单还在处理中"
|
||||
}
|
||||
|
||||
web.Controller
|
||||
}
|
||||
|
||||
func (c *SupplierQuery) SupplierOrderQuery() {
|
||||
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
exist := models.BankOrderIdIsEixst(bankOrderId)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if !exist {
|
||||
keyDataJSON.Msg = "该订单不存在"
|
||||
}
|
||||
se := new(service.QueryService)
|
||||
keyDataJSON := se.SupplierOrderQuery(bankOrderId)
|
||||
|
||||
msg := OrderQuery(bankOrderId)
|
||||
|
||||
keyDataJSON.Msg = msg
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
@ -72,31 +36,9 @@ func (c *SupplierQuery) SupplierOrderQuery() {
|
||||
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("银行处理中")
|
||||
}
|
||||
}
|
||||
}
|
||||
se := new(service.QueryService)
|
||||
keyDataJSON := se.SupplierPayForQuery(bankOrderId)
|
||||
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
/***************************************************
|
||||
** @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()
|
||||
}
|
38
boss/controllers/sendNotifyMerchantController.go
Normal file
38
boss/controllers/sendNotifyMerchantController.go
Normal file
@ -0,0 +1,38 @@
|
||||
/***************************************************
|
||||
** @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/service"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SendNotify struct {
|
||||
web.Controller
|
||||
}
|
||||
|
||||
func (c *SendNotify) SendNotifyToMerchant() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
se := new(service.SendNotifyMerchantService)
|
||||
keyDataJSON := se.SendNotifyToMerchant(bankOrderId)
|
||||
|
||||
c.Data["json"] = keyDataJSON
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *SendNotify) SelfSendNotify() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
se := new(service.SendNotifyMerchantService)
|
||||
keyDataJSON := se.SelfSendNotify(bankOrderId)
|
||||
c.Data["json"] = keyDataJSON
|
||||
_ = c.ServeJSON()
|
||||
}
|
@ -10,14 +10,11 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
controller "boss/supplier"
|
||||
"boss/datas"
|
||||
"boss/models/user"
|
||||
"boss/service"
|
||||
"boss/utils"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/adapter/validation"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -35,13 +32,13 @@ func (c *UpdateController) UpdatePassword() {
|
||||
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
|
||||
dataJSON := new(KeyDataJSON)
|
||||
dataJSON := new(datas.KeyDataJSON)
|
||||
dataJSON.Code = -1
|
||||
if !ok || userID == "" {
|
||||
dataJSON.Code = 404
|
||||
dataJSON.Msg = "请重新登录!"
|
||||
} else {
|
||||
userInfo := models.GetUserInfoByUserID(userID)
|
||||
userInfo := user.GetUserInfoByUserID(userID)
|
||||
valid := validation.Validation{}
|
||||
if userInfo.Passwd != utils.GetMD5Upper(oldPassword) {
|
||||
dataJSON.Key = ".old-error"
|
||||
@ -62,10 +59,10 @@ func (c *UpdateController) UpdatePassword() {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "密码修改成功!"
|
||||
//删除原先的session状态
|
||||
c.DelSession("userID")
|
||||
_ = c.DelSession("userID")
|
||||
//更新数据库的密码
|
||||
userInfo.Passwd = utils.GetMD5Upper(newPassword)
|
||||
models.UpdateUserInfoPassword(userInfo)
|
||||
user.UpdateUserInfoPassword(userInfo)
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
@ -76,62 +73,16 @@ func (c *UpdateController) UpdatePassword() {
|
||||
*/
|
||||
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
|
||||
}
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
dataJSON := se.UpMenu(menuUid)
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
dataJSON := se.DownMenu(menuUid)
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
@ -140,22 +91,9 @@ func (c *UpdateController) DownMenu() {
|
||||
*/
|
||||
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)
|
||||
se := new(service.UpdateService)
|
||||
dataJSON := se.UpSecondMenu(secondMenuUid)
|
||||
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
@ -164,41 +102,15 @@ func (c *UpdateController) UpSecondMenu() {
|
||||
*/
|
||||
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
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
dataJSON := se.DownSecondMenu(secondMenuUid)
|
||||
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 = "冻结失败"
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
dataJSON := se.FreezeOperator(userId)
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
@ -206,15 +118,9 @@ func (c *UpdateController) FreezeOperator() {
|
||||
func (c *UpdateController) UnfreezeOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("operatorName"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
se := new(service.UpdateService)
|
||||
dataJSON := se.UnfreezeOperator(userId)
|
||||
|
||||
if models.UpdateStauts("active", userId) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "解冻成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "解冻失败"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
@ -226,39 +132,8 @@ func (c *UpdateController) EditOperator() {
|
||||
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
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
keyDataJSON := se.EditOperator(password, changePassword, role, userId, nick, remark)
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
@ -269,20 +144,9 @@ func (c *UpdateController) EditOperator() {
|
||||
func (c *UpdateController) UpdateRoadStatus() {
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = 200
|
||||
se := new(service.UpdateService)
|
||||
dataJSON := se.UpdateRoadStatus(roadUid)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@ -291,33 +155,9 @@ func (c *UpdateController) UpdateRoadStatus() {
|
||||
*/
|
||||
func (c *UpdateController) UpdateMerchantStatus() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if merchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
keyDataJSON := se.UpdateMerchantStatus(merchantUid)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@ -327,22 +167,9 @@ func (c *UpdateController) UpdateMerchantStatus() {
|
||||
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()
|
||||
se := new(service.UpdateService)
|
||||
dataJSON := se.UpdateAccountStatus(accountUid)
|
||||
|
||||
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() {
|
||||
@ -350,59 +177,16 @@ func (c *UpdateController) OperatorAccount() {
|
||||
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
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
accountDataJSON := se.OperatorAccount(accountOperator, amount, accountUid)
|
||||
|
||||
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)
|
||||
se := new(service.UpdateService)
|
||||
c.GenerateJSON(se.UpdateAgentStatus(agentUid))
|
||||
}
|
||||
|
||||
func (c *UpdateController) ResetAgentPassword() {
|
||||
@ -410,32 +194,9 @@ func (c *UpdateController) ResetAgentPassword() {
|
||||
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 = " *两次密码输入不一致"
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
|
||||
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)
|
||||
c.GenerateJSON(se.ResetAgentPassword(agentUid, newPassword, newVertifyPassword))
|
||||
}
|
||||
|
||||
/*
|
||||
@ -447,41 +208,9 @@ func (c *UpdateController) ChoosePayForRoad() {
|
||||
remark := strings.TrimSpace(c.GetString("remark"))
|
||||
confirmType := strings.TrimSpace(c.GetString("confirmType"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
se := new(service.UpdateService)
|
||||
|
||||
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)
|
||||
c.GenerateJSON(se.ChoosePayForRoad(confirmType, roadName, bankOrderId, remark))
|
||||
}
|
||||
|
||||
/*
|
||||
@ -491,102 +220,16 @@ func (c *UpdateController) ResultPayFor() {
|
||||
resultType := strings.TrimSpace(c.GetString("resultType"))
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
se := new(service.UpdateService)
|
||||
|
||||
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)
|
||||
c.GenerateJSON(se.ResultPayFor(resultType, bankOrderId))
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
se := new(service.UpdateService)
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
c.GenerateJSON(se.UpdateOrderStatus(bankOrderId, solveType))
|
||||
}
|
||||
|
@ -1,6 +1,15 @@
|
||||
package controllers
|
||||
package datas
|
||||
|
||||
import "boss/models"
|
||||
import (
|
||||
"boss/models/accounts"
|
||||
"boss/models/agent"
|
||||
"boss/models/merchant"
|
||||
"boss/models/order"
|
||||
"boss/models/payfor"
|
||||
"boss/models/road"
|
||||
"boss/models/system"
|
||||
"boss/models/user"
|
||||
)
|
||||
|
||||
type BaseDataJSON struct {
|
||||
Msg string
|
||||
@ -20,7 +29,7 @@ type MenuDataJSON struct {
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
MenuList []models.MenuInfo
|
||||
MenuList []system.MenuInfo
|
||||
}
|
||||
|
||||
type SecondMenuDataJSON struct {
|
||||
@ -30,7 +39,7 @@ type SecondMenuDataJSON struct {
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
SecondMenuList []models.SecondMenuInfo
|
||||
SecondMenuList []system.SecondMenuInfo
|
||||
}
|
||||
|
||||
type PowerItemDataJSON struct {
|
||||
@ -40,7 +49,7 @@ type PowerItemDataJSON struct {
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
PowerItemList []models.PowerInfo
|
||||
PowerItemList []system.PowerInfo
|
||||
}
|
||||
|
||||
type RoleInfoDataJSON struct {
|
||||
@ -50,18 +59,18 @@ type RoleInfoDataJSON struct {
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
RoleInfoList []models.RoleInfo
|
||||
RoleInfoList []system.RoleInfo
|
||||
}
|
||||
|
||||
type DeployTreeJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
Key string
|
||||
AllFirstMenu []models.MenuInfo
|
||||
AllFirstMenu []system.MenuInfo
|
||||
ShowFirstMenuUid map[string]bool
|
||||
AllSecondMenu []models.SecondMenuInfo
|
||||
AllSecondMenu []system.SecondMenuInfo
|
||||
ShowSecondMenuUid map[string]bool
|
||||
AllPower []models.PowerInfo
|
||||
AllPower []system.PowerInfo
|
||||
ShowPowerUid map[string]bool
|
||||
}
|
||||
|
||||
@ -72,14 +81,14 @@ type OperatorDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
OperatorList []models.UserInfo
|
||||
OperatorList []user.UserInfo
|
||||
}
|
||||
|
||||
type EditOperatorDataJSON struct {
|
||||
Code int
|
||||
Msg string
|
||||
OperatorList []models.UserInfo
|
||||
RoleList []models.RoleInfo
|
||||
OperatorList []user.UserInfo
|
||||
RoleList []system.RoleInfo
|
||||
}
|
||||
|
||||
type BankCardDataJSON struct {
|
||||
@ -89,7 +98,7 @@ type BankCardDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
BankCardInfoList []models.BankCardInfo
|
||||
BankCardInfoList []system.BankCardInfo
|
||||
}
|
||||
|
||||
type RoadDataJSON struct {
|
||||
@ -99,8 +108,8 @@ type RoadDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
RoadInfoList []models.RoadInfo
|
||||
RoadPool models.RoadPoolInfo
|
||||
RoadInfoList []road.RoadInfo
|
||||
RoadPool road.RoadPoolInfo
|
||||
}
|
||||
|
||||
type RoadPoolDataJSON struct {
|
||||
@ -110,7 +119,7 @@ type RoadPoolDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
RoadPoolInfoList []models.RoadPoolInfo
|
||||
RoadPoolInfoList []road.RoadPoolInfo
|
||||
}
|
||||
|
||||
type MerchantDataJSON struct {
|
||||
@ -120,13 +129,13 @@ type MerchantDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
MerchantList []models.MerchantInfo
|
||||
MerchantList []merchant.MerchantInfo
|
||||
}
|
||||
|
||||
type MerchantDeployDataJSON struct {
|
||||
Code int
|
||||
Msg string
|
||||
MerchantDeploy models.MerchantDeployInfo
|
||||
MerchantDeploy merchant.MerchantDeployInfo
|
||||
}
|
||||
|
||||
type AccountDataJSON struct {
|
||||
@ -136,7 +145,7 @@ type AccountDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AccountList []models.AccountInfo
|
||||
AccountList []accounts.AccountInfo
|
||||
}
|
||||
|
||||
type AccountHistoryDataJSON struct {
|
||||
@ -146,7 +155,7 @@ type AccountHistoryDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AccountHistoryList []models.AccountHistoryInfo
|
||||
AccountHistoryList []accounts.AccountHistoryInfo
|
||||
}
|
||||
|
||||
type AgentDataJSON struct {
|
||||
@ -156,7 +165,7 @@ type AgentDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AgentList []models.AgentInfo
|
||||
AgentList []agent.AgentInfo
|
||||
}
|
||||
|
||||
type ProductDataJSON struct {
|
||||
@ -172,7 +181,7 @@ type OrderDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
OrderList []models.OrderInfo
|
||||
OrderList []order.OrderInfo
|
||||
AllAmount float64
|
||||
SuccessRate string
|
||||
NotifyUrl string
|
||||
@ -185,7 +194,7 @@ type ListDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
List []models.OrderProfitInfo
|
||||
List []order.OrderProfitInfo
|
||||
AllAmount float64
|
||||
SupplierProfit float64
|
||||
AgentProfit float64
|
||||
@ -199,7 +208,7 @@ type PayForDataJSON struct {
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
PayForList []models.PayforInfo
|
||||
PayForList []payfor.PayforInfo
|
||||
}
|
||||
|
||||
type BalanceDataJSON struct {
|
||||
@ -220,5 +229,5 @@ type ProfitListJSON struct {
|
||||
AgentTotalProfit float64
|
||||
Msg string
|
||||
Code int
|
||||
ProfitList []models.PlatformProfit
|
||||
ProfitList []order.PlatformProfit
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/***************************************************
|
||||
** @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
|
||||
}
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
/***************************************************
|
||||
** @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)
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/16 11:11
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/19 14:56
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@ -27,16 +27,6 @@ type AccountHistoryInfo struct {
|
||||
|
||||
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)
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/19 14:41
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package agent
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@ -72,18 +72,6 @@ func GetAgentInfoByAgentUid(agentUid string) AgentInfo {
|
||||
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)
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/12/17 17:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package agent
|
||||
|
||||
type AgentProfit struct {
|
||||
}
|
@ -11,6 +11,15 @@ package models
|
||||
|
||||
import (
|
||||
"boss/conf"
|
||||
"boss/models/accounts"
|
||||
"boss/models/agent"
|
||||
"boss/models/merchant"
|
||||
"boss/models/notify"
|
||||
"boss/models/order"
|
||||
"boss/models/payfor"
|
||||
"boss/models/road"
|
||||
"boss/models/system"
|
||||
"boss/models/user"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
@ -30,10 +39,10 @@ func init() {
|
||||
|
||||
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))
|
||||
orm.RegisterModel(new(user.UserInfo), new(system.MenuInfo), new(system.SecondMenuInfo),
|
||||
new(system.PowerInfo), new(system.RoleInfo), new(system.BankCardInfo), new(road.RoadInfo),
|
||||
new(road.RoadPoolInfo), new(agent.AgentInfo), new(merchant.MerchantInfo), new(merchant.MerchantDeployInfo),
|
||||
new(accounts.AccountInfo), new(accounts.AccountHistoryInfo), new(order.OrderInfo), new(order.OrderProfitInfo),
|
||||
new(order.OrderSettleInfo), new(notify.NotifyInfo), new(merchant.MerchantLoadInfo),
|
||||
new(payfor.PayforInfo))
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/7 11:52
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@ -65,25 +65,6 @@ func GetMerchantDeployByUidAndPayType(uid, payType string) MerchantDeployInfo {
|
||||
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()
|
||||
@ -103,33 +84,3 @@ func UpdateMerchantDeploy(merchantDeploy MerchantDeployInfo) bool {
|
||||
}
|
||||
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
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/28 16:47
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@ -68,15 +68,6 @@ func IsExistByMerchantPhone(phone string) bool {
|
||||
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)
|
||||
@ -172,16 +163,6 @@ func GetMerchantByUid(merchantUid string) MerchantInfo {
|
||||
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)
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/11/22 13:07
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/11/20 13:13
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package notify
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@ -39,12 +39,6 @@ func InsertNotifyInfo(notifyInfo NotifyInfo) bool {
|
||||
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
|
||||
@ -56,23 +50,6 @@ func GetNotifyInfoByBankOrderId(bankOrderId string) NotifyInfo {
|
||||
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)
|
||||
@ -91,13 +68,3 @@ func GetNotifyBankOrderIdListByParams(params map[string]string) []string {
|
||||
|
||||
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
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/28 10:15
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package order
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -54,22 +54,6 @@ type OrderInfo struct {
|
||||
|
||||
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()
|
||||
@ -97,7 +81,7 @@ func GetOrderByMap(params map[string]string, display, offset int) []OrderInfo {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&orderInfoList)
|
||||
_, err := qs.Limit(display, offset).OrderBy("-create_time").All(&orderInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get order by map fail: ", err)
|
||||
}
|
||||
@ -200,16 +184,6 @@ func GetOrderByBankOrderId(bankOrderId string) OrderInfo {
|
||||
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
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/30 11:44
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package order
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/30 11:41
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package order
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/12/17 17:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package order
|
||||
|
||||
type PlatformProfit struct {
|
||||
MerchantName string
|
@ -7,10 +7,11 @@
|
||||
** @Last Modified time: 2019/11/25 14:32
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package payfor
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models/accounts"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
@ -51,7 +52,7 @@ type PayforInfo struct {
|
||||
IsSend string
|
||||
RequestTime string
|
||||
ResponseTime string
|
||||
ResponseContext string
|
||||
ResponseContent string
|
||||
Remark string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
@ -69,20 +70,6 @@ func InsertPayfor(payFor PayforInfo) bool {
|
||||
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)
|
||||
@ -149,19 +136,6 @@ func GetPayForByBankOrderId(bankOrderId string) PayforInfo {
|
||||
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()
|
||||
|
||||
@ -181,7 +155,7 @@ func ForUpdatePayFor(payFor PayforInfo) bool {
|
||||
if payFor.Status == common.PAYFOR_SOLVING && tmp.Status == common.PAYFOR_COMFRIM &&
|
||||
payFor.GiveType == common.PAYFOR_HAND && payFor.Type != common.SELF_HELP {
|
||||
|
||||
var account AccountInfo
|
||||
var account accounts.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
|
||||
@ -197,7 +171,7 @@ func ForUpdatePayFor(payFor PayforInfo) bool {
|
||||
}
|
||||
} else {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,可用金额不够", payFor.MerchantUid))
|
||||
payFor.ResponseContext = "商户可用余额不足"
|
||||
payFor.ResponseContent = "商户可用余额不足"
|
||||
payFor.Status = common.PAYFOR_FAIL
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/8 12:09
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package road
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/9 16:35
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package road
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/6 10:19
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/21 9:33
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@ -119,16 +119,6 @@ func GetMenuAll() []MenuInfo {
|
||||
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
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/28 17:59
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/29 14:43
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/26 9:33
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@ -48,15 +48,6 @@ func (sm SecondMenuSlice) Less(i, j int) bool {
|
||||
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
|
||||
@ -208,9 +199,3 @@ func UpdateSecondMenu(secondMenu SecondMenuInfo) {
|
||||
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
|
||||
}
|
@ -11,6 +11,7 @@ package models
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models/accounts"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
@ -25,7 +26,7 @@ func OperatorAccount(accountUid, operatorType string, amount float64) (string, b
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
//处理事务
|
||||
accountInfo := new(AccountInfo)
|
||||
accountInfo := new(accounts.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
|
||||
@ -65,7 +66,7 @@ func OperatorAccount(accountUid, operatorType string, amount float64) (string, b
|
||||
return err
|
||||
}
|
||||
//往account_history表中插入一条动账记录
|
||||
accountHistory := AccountHistoryInfo{AccountUid: accountUid, AccountName: accountInfo.AccountName, Type: operatorType,
|
||||
accountHistory := accounts.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 {
|
||||
|
@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/9 14:02
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package user
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@ -1,70 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/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
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 = ""
|
||||
)
|
@ -1,48 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/models"
|
||||
"github.com/beego/beego/v2/adapter/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
/*
|
||||
* 插入支付订单记录和订单利润记录,保证一致性
|
||||
*/
|
||||
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
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/common"
|
||||
"github.com/beego/beego/v2/core/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]
|
||||
}
|
@ -1,381 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/common"
|
||||
"boss/gojson"
|
||||
"boss/models"
|
||||
"boss/utils"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/adapter/httplib"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/rs/xid"
|
||||
"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
|
||||
}
|
@ -1,192 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/common"
|
||||
"boss/models"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"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()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
tmpSettle := new(models.OrderSettleInfo)
|
||||
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
|
||||
tmpSettle.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpSettle.IsCompleteSettle = common.YES
|
||||
|
||||
if _, err := txOrm.Update(tmpSettle); err != nil {
|
||||
logs.Error("更新tmpSettle失败,错误:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
accountInfo := new(models.AccountInfo)
|
||||
|
||||
if err := txOrm.Raw("select * from account_info where account_uid=? for update", orderSettle.MerchantUid).QueryRow(accountInfo); err != nil || accountInfo == nil {
|
||||
logs.Error("结算select account info失败,错误信息:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
accountInfo.SettleAmount += orderProfit.FactAmount
|
||||
|
||||
if _, err := txOrm.Update(accountInfo); err != nil {
|
||||
logs.Error("结算update account 失败,错误信息:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
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 := txOrm.Insert(tmp); err != nil {
|
||||
logs.Error("結算插入merchantLoad失敗,失败信息:", err)
|
||||
return err
|
||||
} else {
|
||||
logs.Info("结算插入新的merchantLoad信息成功")
|
||||
}
|
||||
} else {
|
||||
merchantLoad := new(models.MerchantLoadInfo)
|
||||
if err := txOrm.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))
|
||||
return err
|
||||
} else {
|
||||
merchantLoad.UpdateTime = utils.GetBasicDateTime()
|
||||
merchantLoad.LoadAmount = merchantLoad.LoadAmount + loadAmount
|
||||
if _, err := txOrm.Update(merchantLoad); err != nil {
|
||||
logs.Error(fmt.Sprintf("结算过程,update merchant load info失败,失败信息:%s", err))
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logs.Info(fmt.Sprintf("结算过程中,该商户不需要押款,全款结算"))
|
||||
}
|
||||
return nil
|
||||
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
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()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
tmpLoad := new(models.MerchantLoadInfo)
|
||||
|
||||
if err := txOrm.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))
|
||||
return err
|
||||
|
||||
}
|
||||
if tmpLoad.Status != common.NO {
|
||||
logs.Error(fmt.Sprintf("押款信息merchantuid=%s,通道uid=%s, 押款日期=%s,已经解款过,不需要再进行处理了", tmpLoad.MerchantUid, tmpLoad.RoadUid, tmpLoad.LoadDate))
|
||||
return errors.New("已经解款过,不需要再进行处理了")
|
||||
}
|
||||
|
||||
tmpLoad.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpLoad.Status = common.YES
|
||||
|
||||
if _, err := txOrm.Update(tmpLoad); err != nil {
|
||||
logs.Error(fmt.Sprintf("解款操作更新merchant load info 失败:%s", err))
|
||||
return err
|
||||
}
|
||||
|
||||
accountInfo := new(models.AccountInfo)
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if accountInfo.LoanAmount >= tmpLoad.LoadAmount {
|
||||
accountInfo.LoanAmount -= tmpLoad.LoadAmount
|
||||
} else {
|
||||
accountInfo.LoanAmount = common.ZERO
|
||||
}
|
||||
|
||||
if _, err := txOrm.Update(accountInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("解款操作更新account info 失败:%s,账户uid=%s", err, accountInfo.AccountUid))
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@ -1,489 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/common"
|
||||
"boss/message_queue"
|
||||
"boss/models"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
url2 "net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type PaySolveController struct {
|
||||
}
|
||||
|
||||
//处理支付成功的加款等各项操作
|
||||
func (c *PaySolveController) SolvePaySuccess(bankOrderId string, factAmount float64, trxNo string) bool {
|
||||
|
||||
o := orm.NewOrm()
|
||||
|
||||
err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
var orderInfo models.OrderInfo
|
||||
if err := txOrm.Raw("select * from order_info where bank_order_id = ? for update", bankOrderId).QueryRow(&orderInfo); err != nil || orderInfo.BankOrderId == "" {
|
||||
logs.Error("不存在该订单,或者select for update出错")
|
||||
return err
|
||||
}
|
||||
|
||||
if orderInfo.Status != "wait" {
|
||||
logs.Error("该订单已经处理,订单号=", bankOrderId)
|
||||
return errors.New(fmt.Sprintf("该订单已经处理,订单号= %s", bankOrderId))
|
||||
}
|
||||
|
||||
if factAmount <= common.ZERO {
|
||||
factAmount = orderInfo.OrderAmount
|
||||
}
|
||||
|
||||
var orderProfitInfo models.OrderProfitInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
|
||||
if orderProfitInfo.BankOrderId == "" {
|
||||
logs.Error("solve pay success, get orderProfit fail, bankOrderId = ", bankOrderId)
|
||||
return errors.New(fmt.Sprintf("solve pay success, get orderProfit fail, bankOrderId = %s", bankOrderId))
|
||||
}
|
||||
|
||||
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 := txOrm.Update(orderProfitInfo); err != nil {
|
||||
logs.Info("solve pay success fail:", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
orderInfo.Status = common.SUCCESS
|
||||
orderInfo.BankTransId = trxNo
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&orderInfo); err != nil || orderInfo.BankOrderId == "" {
|
||||
logs.Error(fmt.Sprintf("solve pay success, update order info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
return err
|
||||
}
|
||||
|
||||
//插入一条待结算记录
|
||||
settAmount := orderProfitInfo.FactAmount - orderProfitInfo.SupplierProfit - orderProfitInfo.PlatformProfit - orderProfitInfo.AgentProfit
|
||||
if settAmount <= 0.00 {
|
||||
logs.Error(fmt.Sprintf("订单id=%s,计算利润存在异常", bankOrderId))
|
||||
return errors.New(fmt.Sprintf("订单id=%s,计算利润存在异常", bankOrderId))
|
||||
}
|
||||
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 := txOrm.Insert(&orderSettleInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success,insert order settle info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
return err
|
||||
}
|
||||
|
||||
//做账户的加款操作,最重要的一部
|
||||
var accountInfo models.AccountInfo
|
||||
if err := txOrm.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))
|
||||
return err
|
||||
}
|
||||
if _, err := txOrm.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))
|
||||
return err
|
||||
}
|
||||
|
||||
//添加一条动账记录
|
||||
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 := txOrm.Insert(&accountHistory); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success,insert account history fail:%s, bankOrderId = %s", err, bankOrderId))
|
||||
return err
|
||||
}
|
||||
|
||||
//更新通道信息
|
||||
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 := txOrm.Update(&roadInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success, update road info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
return err
|
||||
}
|
||||
|
||||
//更新订单利润表
|
||||
orderProfitInfo.Status = common.SUCCESS
|
||||
orderProfitInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&orderProfitInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success, update order profit info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
return err
|
||||
}
|
||||
|
||||
// 给下游发送回调通知
|
||||
go c.CreateOrderNotifyInfo(orderInfo, common.SUCCESS)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
logs.Error("SolvePaySuccess失败:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
logs.Info("SolvePaySuccess处理成功")
|
||||
return true
|
||||
}
|
||||
|
||||
//处理支付失败
|
||||
func (c *PaySolveController) SolvePayFail(orderInfo models.OrderInfo, str string) bool {
|
||||
o := orm.NewOrm()
|
||||
err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
var orderTmp models.OrderInfo
|
||||
bankOrderId := orderInfo.BankOrderId
|
||||
if err := txOrm.Raw("select * from order_info where bank_order_id = ?", bankOrderId).QueryRow(&orderTmp); err != nil || orderTmp.BankOrderId == "" {
|
||||
return err
|
||||
}
|
||||
|
||||
if orderTmp.Status != "wait" {
|
||||
return errors.New("订单已经处理,不要重复加款")
|
||||
}
|
||||
if _, err := txOrm.QueryTable(models.ORDER_INFO).Filter("bank_order_id", bankOrderId).Update(orm.Params{"status": str, "bank_trans_id": orderInfo.BankTransId}); err != nil {
|
||||
logs.Error("更改订单状态失败:", err)
|
||||
return err
|
||||
}
|
||||
if _, err := txOrm.QueryTable(models.ORDER_PROFIT_INFO).Filter("bank_order_id", bankOrderId).Update(orm.Params{"status": str, "bank_trans_id": orderInfo.BankTransId}); err != nil {
|
||||
logs.Error("更改订单状态失败:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
go c.CreateOrderNotifyInfo(orderInfo, common.FAIL)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
logs.Error("SolvePayFail:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
logs.Info("SolvePayFail成功")
|
||||
return true
|
||||
}
|
||||
|
||||
//处理订单冻结
|
||||
func (c *PaySolveController) SolveOrderFreeze(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
|
||||
err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
var orderInfo models.OrderInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
|
||||
if orderInfo.Status != common.SUCCESS {
|
||||
logs.Error("非成功订单不能进行冻结")
|
||||
return errors.New("非成功订单不能进行冻结")
|
||||
}
|
||||
|
||||
orderInfo.Freeze = common.YES
|
||||
orderInfo.FreezeTime = utils.GetBasicDateTime()
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&orderInfo); err != nil {
|
||||
logs.Error("solve order freeze fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
//账户的冻结金额里面加入相应的金额
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
var accountInfo models.AccountInfo
|
||||
if err := txOrm.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))
|
||||
return err
|
||||
}
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount + orderProfitInfo.UserInAmount
|
||||
if _, err := txOrm.Update(&accountInfo); err != nil {
|
||||
logs.Error("solve order freeze fail: ", err)
|
||||
return err
|
||||
}
|
||||
//插入一条动账记录
|
||||
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 := txOrm.Insert(&accountHistoryInfo); err != nil {
|
||||
logs.Error("solve order freeze fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
logs.Error("SolveOrderFreeze:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
logs.Info("SolveOrderFreeze")
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
//订单解冻
|
||||
func (c *PaySolveController) SolveOrderUnfreeze(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
orderInfo := new(models.OrderInfo)
|
||||
if err := txOrm.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 err
|
||||
}
|
||||
|
||||
orderInfo.Freeze = ""
|
||||
orderInfo.Unfreeze = common.YES
|
||||
orderInfo.UnfreezeTime = utils.GetBasicDateTime()
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(orderInfo); err != nil {
|
||||
logs.Error("solve order unfreeze fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
|
||||
accountInfo := new(models.AccountInfo)
|
||||
if err := txOrm.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))
|
||||
return err
|
||||
}
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount - orderProfitInfo.UserInAmount
|
||||
|
||||
if _, err := txOrm.Update(accountInfo); err != nil {
|
||||
logs.Error("solve order unfreeze fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
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 := txOrm.Insert(&accountHistoryInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
logs.Error("SolveOrderUnfreeze失败:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *PaySolveController) SolveRefund(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
orderInfo := new(models.OrderInfo)
|
||||
if err := txOrm.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 err
|
||||
}
|
||||
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
orderInfo.Refund = common.YES
|
||||
orderInfo.RefundTime = utils.GetBasicDateTime()
|
||||
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
account := new(models.AccountInfo)
|
||||
if err := txOrm.Raw("select * from account_info where account_uid = ? for update", orderInfo.MerchantUid).QueryRow(account); err != nil || account.AccountUid == "" {
|
||||
return err
|
||||
}
|
||||
|
||||
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 := txOrm.Update(orderInfo); err != nil {
|
||||
logs.Error("solve order refund update order info fail: ", err)
|
||||
return err
|
||||
}
|
||||
if _, err := txOrm.Update(account); err != nil {
|
||||
logs.Error("solve order refund update account fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
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 := txOrm.Insert(&accountHistoryInfo); err != nil {
|
||||
logs.Error("solve order refund insert account history fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
logs.Error("SolveRefund 成功:", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *PaySolveController) SolveOrderRoll(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
orderInfo := new(models.OrderInfo)
|
||||
|
||||
if err := txOrm.Raw("select * from order_info where bank_order_id = ? for update", bankOrderId).QueryRow(orderInfo); err != nil {
|
||||
logs.Error("solve order roll fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if orderInfo.Status != common.SUCCESS {
|
||||
logs.Error("solve order roll 订单不存在或者订单状态不是success, bankOrderId=", bankOrderId)
|
||||
return errors.New("solve order roll failed")
|
||||
}
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
orderProfitInfo := models.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
|
||||
account := new(models.AccountInfo)
|
||||
if err := txOrm.Raw("select * from account_info where account_uid = ? for update", orderInfo.MerchantUid).QueryRow(account); err != nil || account.AccountUid == "" {
|
||||
return err
|
||||
}
|
||||
|
||||
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 := txOrm.Update(orderInfo); err != nil {
|
||||
logs.Error("solve order roll fail update order info fail: ", err)
|
||||
return err
|
||||
}
|
||||
if _, err := txOrm.Update(account); err != nil {
|
||||
logs.Error("solve order roll update account fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
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 := txOrm.Insert(&accountHistoryInfo); err != nil {
|
||||
logs.Error("solve order roll insert account history fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}); err != nil {
|
||||
logs.Error("SolveOrderRoll处理失败:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
@ -1,350 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/common"
|
||||
"boss/message_queue"
|
||||
"boss/models"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func PayForFail(payFor models.PayforInfo) bool {
|
||||
|
||||
o := orm.NewOrm()
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
var tmpForPay models.PayforInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
|
||||
if tmpForPay.Status == common.PAYFOR_FAIL || tmpForPay.Status == common.PAYFOR_SUCCESS {
|
||||
logs.Error(fmt.Sprintf("该代付订单uid=%s,状态已经是最终结果", payFor.PayforUid))
|
||||
return errors.New("状态已经是最终结果")
|
||||
}
|
||||
//更新payfor记录的状态
|
||||
tmpForPay.Status = common.PAYFOR_FAIL
|
||||
tmpForPay.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&tmpForPay); err != nil {
|
||||
logs.Error("PayForFail update payfor_info fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
var account models.AccountInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if account.PayforAmount < (payFor.PayforAmount + payFor.PayforFee) {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,账户中待代付金额小于代付记录的金额", payFor.MerchantUid))
|
||||
return errors.New("账户中待代付金额小于代付记录的金额")
|
||||
}
|
||||
//将正在打款中的金额减去
|
||||
account.PayforAmount = account.PayforAmount - payFor.PayforAmount - payFor.PayforFee
|
||||
|
||||
if _, err := txOrm.Update(&account); err != nil {
|
||||
logs.Error("PayForFail update account fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func PayForSuccess(payFor models.PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
var tmpPayFor models.PayforInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
if tmpPayFor.Status == common.PAYFOR_FAIL || tmpPayFor.Status == common.PAYFOR_SUCCESS {
|
||||
logs.Error(fmt.Sprintf("该代付订单uid=%s,已经是最终结果,不需要处理", payFor.PayforUid))
|
||||
return errors.New("已经是最终结果,不需要处理")
|
||||
}
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpPayFor.Status = common.PAYFOR_SUCCESS
|
||||
_, err := txOrm.Update(&tmpPayFor)
|
||||
if err != nil {
|
||||
logs.Error("PayForSuccess update payfor fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
var account models.AccountInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if account.PayforAmount < (payFor.PayforAmount + payFor.PayforFee) {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,账户中待代付金额小于代付记录的金额", payFor.MerchantUid))
|
||||
return errors.New("账户中待代付金额小于代付记录的金额")
|
||||
}
|
||||
|
||||
//代付打款中的金额减去
|
||||
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 := txOrm.Update(&account); err != nil {
|
||||
logs.Error("PayForSuccess udpate account fail:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
//添加一条动账记录
|
||||
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 := txOrm.Insert(&accountHistory); err != nil {
|
||||
logs.Error("PayForSuccess insert account history fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
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 {
|
||||
//检查是否单独填写了每笔代付的手续费
|
||||
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 := orm.NewOrm()
|
||||
// 开启事务
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
var tmpPayFor models.PayforInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
|
||||
if tmpPayFor.Status != common.PAYFOR_COMFRIM {
|
||||
logs.Notice(fmt.Sprintf("该代付记录uid=%s,已经被审核", payFor.PayforUid))
|
||||
return errors.New("已经被审核")
|
||||
}
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpPayFor.Status = common.PAYFOR_SOLVING
|
||||
tmpPayFor.GiveType = common.PAYFOR_ROAD
|
||||
|
||||
if _, err := txOrm.Update(&tmpPayFor); err != nil {
|
||||
logs.Error(fmt.Sprintf("该代付记录uid=%s,从审核更新为正在处理出错: %s", payFor.PayforUid, err))
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
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) bool {
|
||||
o := orm.NewOrm()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
var tmpPayFor models.PayforInfo
|
||||
if err := txOrm.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)
|
||||
return errors.New("solve self payfor fail")
|
||||
}
|
||||
|
||||
if tmpPayFor.IsSend == common.YES {
|
||||
return errors.New("代付已经发送")
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
if _, err := txOrm.Update(&tmpPayFor); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
RequestPayFor(payFor)
|
||||
|
||||
return nil
|
||||
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func SendPayFor(payFor models.PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
var tmpPayFor models.PayforInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
|
||||
var account models.AccountInfo
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
}
|
||||
|
||||
//支付金额不足,将直接判定为失败,不往下面邹逻辑了
|
||||
if account.SettleAmount-account.PayforAmount < tmpPayFor.PayforAmount+tmpPayFor.PayforFee {
|
||||
tmpPayFor.Status = common.PAYFOR_FAIL
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
if _, err := txOrm.Update(&tmpPayFor); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
account.PayforAmount = account.PayforAmount + payFor.PayforAmount + payFor.PayforFee
|
||||
|
||||
if _, err := txOrm.Update(&account); err != nil {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,在发送代付给上游的处理中,更新账户表出错, err: %s", payFor.MerchantUid, err))
|
||||
return err
|
||||
}
|
||||
|
||||
tmpPayFor.IsSend = common.YES
|
||||
tmpPayFor.Status = common.PAYFOR_BANKING //变为银行处理中
|
||||
tmpPayFor.RequestTime = utils.GetBasicDateTime()
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
if _, err := txOrm.Update(&tmpPayFor); err != nil {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,在发送代付给上游的处理中,更代付列表出错, err:%s", payFor.MerchantUid, err))
|
||||
return err
|
||||
}
|
||||
|
||||
RequestPayFor(payFor)
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
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)
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/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
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/***************************************************
|
||||
** @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 (
|
||||
"boss/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
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package gojson
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
@ -1,6 +1,6 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html xmlns="http://www.w3.org/1999/html">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>管理后台</title>
|
||||
@ -36,8 +36,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<span class="explain">账户余额:用户充值成功后立马相加,提款成功后相减的结果。结算金额:用户充值成功过一段时间后相加,出款成功后相减的结果。</span>
|
||||
<span class="explain">可用金额 = (结算金额 - 冻结金额 - 押款金额 - 正在出款金额)</span>
|
||||
<span class="explain" style="color: red;">账户余额:用户充值成功后立马相加,提款成功后相减的结果。</span>
|
||||
<span class="explain" style="color: red;">待结算金额:用户充值后,还没有加到可结算金中。</span>
|
||||
<span class="explain" style="color: red;">结算金额: 可以提现的金额 = (账户余额 - 待结算金额 - 押款金额 - 冻结金额 - 正在出款金额)</span>
|
||||
|
||||
</div>
|
||||
<div class="menu-table">
|
||||
<table>
|
||||
@ -52,7 +54,7 @@
|
||||
<th>押款金额</th>
|
||||
<th>冻结金额</th>
|
||||
<th>正在出款的金额</th>
|
||||
<th>可用金额</th>
|
||||
{{/* <th>可用金额</th>*/}}
|
||||
<th>账户状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@ -121,13 +123,15 @@
|
||||
let tmp = "<tr>" + "<th>" + (res.StartIndex+i+1) + "</th>" +
|
||||
"<th>" + v.AccountUid + "</th>" + "<th>" + v.AccountName + "</th>" + "<th>" + v.Balance + "</th>" +
|
||||
"<th>" + v.SettleAmount + "</th>" + "<th>" + v.WaitAmount + "</th>" + "<th>" + v.LoanAmount + "</th>" +
|
||||
"<th>" + v.FreezeAmount + "</th>" +"<th>" + v.PayforAmount + "</th>" +
|
||||
"<th>" + (v.SettleAmount-v.FreezeAmount-v.PayforAmount-v.LoanAmount) + "</th>" + "<th>" + v.Status + "</th>";
|
||||
"<th>" + v.FreezeAmount + "</th>" +"<th>" + v.PayforAmount + "</th>" + "<th>" + v.Status + "</th>";
|
||||
tmp = tmp.replace("unactive", "冻结").replace("active", "激活");
|
||||
tmp = tmp + "<th>" + '<div class="btn-group" role="group" aria-label="...">' +
|
||||
'<button type="button" value="' + v.AccountUid +'" class="btn btn-default" onclick="updateAccountStatus(this.value);">'+ "激活|冻结" +'</button>' +
|
||||
'<button type="button" value="' + v.AccountUid +'" class="btn btn-default" onclick="deleteAccount(this.value);"><span class="glyphicon glyphicon-trash"></span></button>' +
|
||||
'</div>' + "</th>" + "</tr>";
|
||||
if (v.Status === "unactive") {
|
||||
tmp = tmp.replace("<tr>", "<tr style='color: red;'>");
|
||||
}
|
||||
str = str + tmp;
|
||||
}
|
||||
|
||||
|
@ -308,6 +308,7 @@
|
||||
alert("处理失败");
|
||||
} else {
|
||||
ajaxAgentList(getAgentCutPageValues());
|
||||
alert("操作成功")
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -174,7 +174,7 @@
|
||||
<div class="self-nav">
|
||||
|
||||
</div>
|
||||
<nav class="navbar-inverse navbar-fixed-top" id="navbar-inverse">
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top" id="navbar-inverse">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="#">聚合支付管理系统</a>
|
||||
@ -183,7 +183,8 @@
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span>你好!管理员 <span class="caret"></span></a>
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="glyphicon glyphicon-user"></span>你好!管理员 <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="#" style="text-align: center;" data-toggle="modal" data-target="#logoutModal"> <i class="glyphicon glyphicon-cog change-password"></i> 更改密码</a>
|
||||
|
@ -243,15 +243,15 @@
|
||||
<span>支付类型:</span>
|
||||
<select id="pay-type" style="top: 31px;">
|
||||
<option value="none">请选择</option>
|
||||
<option value="WEIXIN-SCAN">微信扫码</option>
|
||||
<option value="WEIXIN-H5">微信H5</option>
|
||||
<option value="WEIXIN-SYT">微信收银台</option>
|
||||
<option value="ALI-SCAN">支付宝扫码</option>
|
||||
<option value="ALI-H5">支付宝H5</option>
|
||||
<option value="ALI-SYT">支付宝收银台</option>
|
||||
<option value="QQ-SCAN">QQ扫码</option>
|
||||
<option value="QQ-H5">QQ-H5</option>
|
||||
<option value="QQ-SYT">QQ收银台</option>
|
||||
<option value="WEIXIN_SCAN">微信扫码</option>
|
||||
<option value="WEIXIN_H5">微信H5</option>
|
||||
<option value="WEIXIN_SYT">微信收银台</option>
|
||||
<option value="ALI_SCAN">支付宝扫码</option>
|
||||
<option value="ALI_H5">支付宝H5</option>
|
||||
<option value="ALI_SYT">支付宝收银台</option>
|
||||
<option value="QQ_SCAN">QQ扫码</option>
|
||||
<option value="QQ_H5">QQ-H5</option>
|
||||
<option value="QQ_SYT">QQ收银台</option>
|
||||
<option value="UNION_SCAN">银联扫码</option>
|
||||
<option value="UNION_H5">银联H5</option>
|
||||
<option value="UNION_PC_WAP">银联pc-web</option>
|
||||
@ -645,7 +645,13 @@
|
||||
let str = "";
|
||||
for (let i = 0; i < res.MerchantList.length; i ++) {
|
||||
let v = res.MerchantList[i];
|
||||
let tmp = "<tr>" + "<th>" + (res.StartIndex+i+1) + "</th>" +
|
||||
let t = "";
|
||||
if (v.Status === "unactive") {
|
||||
t = "<tr style=\"color: red;\">";
|
||||
} else {
|
||||
t = "<tr>";
|
||||
}
|
||||
let tmp = t + "<th>" + (res.StartIndex+i+1) + "</th>" +
|
||||
"<th>" + v.MerchantUid + "</th>" + "<th>" + v.MerchantName + "</th>" + "<th>" + v.MerchantKey + "</th>" +
|
||||
"<th>" + v.MerchantSecret + "</th>" + "<th>" + v.LoginAccount + "</th>" + "<th>" + v.Status + "</th>";
|
||||
|
||||
@ -693,6 +699,7 @@
|
||||
alert("更新失败")
|
||||
} else {
|
||||
showMerchantAjax(getMerchantCutPageValues());
|
||||
alert("操作成功")
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -302,12 +302,19 @@
|
||||
let str = "";
|
||||
for (let i = 0; i < res.OperatorList.length; i ++) {
|
||||
let v = res.OperatorList[i];
|
||||
let tmp = "<tr>" + "<th>" + (res.StartIndex+i+1) + "</th>" +
|
||||
let t = "";
|
||||
let h = "";
|
||||
if (v.Status === "unactive") {
|
||||
t = "<tr style=\"color: red;\">";
|
||||
} else {
|
||||
t = "<tr>";
|
||||
}
|
||||
let tmp = t + "<th>" + (res.StartIndex+i+1) + "</th>" +
|
||||
"<th>" + v.UserId + "</th>" + "<th>" + v.RoleName + "</th>" + "<th>" + v.Nick + "</th>" +
|
||||
"<th>" + v.Remark + "</th>" + "<th>" + v.Status + "</th>" +
|
||||
"<th>" + v.CreateTime + "</th>";
|
||||
|
||||
tmp = tmp + "<th>" + '<div class="btn-group" role="group" aria-label="...">' +
|
||||
tmp = tmp + "<th>" + '<div class="btn-group" role="group" aria-label="...">' +
|
||||
'<button type="button" value="' + v.UserId +'" class="btn btn-default" onclick="editOperator(this.value);"><span class="glyphicon glyphicon-pencil"></span></button>' +
|
||||
'<button type="button" value="' + v.UserId +'" class="btn btn-default" onclick="freezeOperator(this.value);"><span>冻结</span></button>' +
|
||||
'<button type="button" value="' + v.UserId +'" class="btn btn-default" onclick="unfreezeOperator(this.value);"><span>解冻</span></button>' +
|
||||
|
@ -364,13 +364,13 @@
|
||||
"solveType":"freeze_amount"
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.Code == 404) {
|
||||
if (res.Code === 404) {
|
||||
window.parent.location = "/login.html";
|
||||
return
|
||||
} else if (res.Code == 200) {
|
||||
alert("冻结成功");
|
||||
} else if (res.Msg === "success") {
|
||||
alert("处理成功");
|
||||
} else {
|
||||
alert("冻结失败")
|
||||
alert("可能订单未完成支付,不能进行此项操作!")
|
||||
}
|
||||
AjaxOrderList(getOrderSearchValues());
|
||||
},
|
||||
@ -507,10 +507,14 @@
|
||||
"bankOrderId":bankOrderid
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.Code == 404) {
|
||||
if (res.Code === 404) {
|
||||
window.parent.location = "/login.html";
|
||||
} else {
|
||||
alert(res.Msg);
|
||||
if (res.Msg === "success") {
|
||||
alert("处理成功!")
|
||||
} else {
|
||||
alert("处理失败!")
|
||||
}
|
||||
AjaxOrderList(getOrderSearchValues());
|
||||
}
|
||||
},
|
||||
|
@ -209,7 +209,7 @@
|
||||
"bankOrderId":bankOrderId
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.Code == 404) {
|
||||
if (res.Code === 404) {
|
||||
window.parent.location = "/login.html";
|
||||
} else {
|
||||
alert(res.Msg);
|
||||
@ -228,7 +228,7 @@
|
||||
"bankOrderId":bankOrderId
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.Code == 404) {
|
||||
if (res.Code === 404) {
|
||||
window.parent.location = "/login.html";
|
||||
} else {
|
||||
alert(res.Msg);
|
||||
@ -310,9 +310,9 @@
|
||||
"resultType":resultType
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.Code == 404) {
|
||||
if (res.Code === 404) {
|
||||
window.parent.location = "/login.html";
|
||||
} else if (res.Code == -1){
|
||||
} else if (res.Code === -1){
|
||||
alert(res.Msg);
|
||||
} else {
|
||||
$("#result-cannel").trigger('click');
|
||||
|
@ -329,7 +329,13 @@
|
||||
let str = "";
|
||||
for (let i = 0; i < res.RoadInfoList.length; i ++) {
|
||||
let v = res.RoadInfoList[i];
|
||||
let tmp = "<tr>" + "<th>" + (res.StartIndex+i+1) + "</th>" +
|
||||
let t = "";
|
||||
if (v.Status === "unactive") {
|
||||
t = "<tr style=\"color: red;\">"
|
||||
} else {
|
||||
t = "<tr>";
|
||||
}
|
||||
let tmp = t + "<th>" + (res.StartIndex+i+1) + "</th>" +
|
||||
"<th>" + v.RoadName + "</th>" + "<th>" + v.ProductName + "</th>" + "<th>" + v.PayType + "</th>" +
|
||||
"<th>" + v.BasicFee + "</th>" + "<th>" + v.Status + "</th>" + "<th>" + v.TotalLimit + "</th>" +
|
||||
"<th>" + v.TodayLimit + "</th>" + "<th>" + v.SingleMinLimit + "-" + v.SingleMaxLimit + "</th>" +
|
||||
|
@ -243,7 +243,7 @@
|
||||
"<th>" + v.RoleName + "</th>" + "<th>" + v.RoleUid + "</th>" +
|
||||
"<th>" + v.Remark + "</th>" + "<th>" + v.CreateTime + "</th>";
|
||||
tmp = tmp + "<th>" + '<div class="btn-group" role="group" aria-label="...">' +
|
||||
'<button type="button" value="' + v.RoleUid +'" class="btn btn-default" onclick="editRole(this.value);"><span class="glyphicon glyphicon-pencil"></span></button>' +
|
||||
// '<button type="button" value="' + v.RoleUid +'" class="btn btn-default" onclick="editRole(this.value);"><span class="glyphicon glyphicon-pencil"></span></button>' +
|
||||
'<button type="button" value="' + v.RoleUid +'" class="btn btn-default" onclick="deleteRole(this.value);"><span class="glyphicon glyphicon-trash"></span></button>' +
|
||||
'</div>' + "</th>" + "</tr>";
|
||||
str = str + tmp;
|
||||
|
@ -131,7 +131,26 @@
|
||||
$("#operate-result").html(res.Msg);
|
||||
} else {
|
||||
randResult(res);
|
||||
alert("操作成功,请仔细检查商户的资金状态");
|
||||
alert("当前用户的信息如下......");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
alert("系统异常,请稍后再试")
|
||||
}
|
||||
});
|
||||
}
|
||||
function getAccount() {
|
||||
let dataJSON = getValues();
|
||||
$.ajax({
|
||||
url:"/get/one/account",
|
||||
data: dataJSON,
|
||||
success: function (res) {
|
||||
if (res.Code == 404) {
|
||||
window.parent.location = "/login.html";
|
||||
} else if (res.Code == -1) {
|
||||
$("#operate-result").html(res.Msg);
|
||||
} else {
|
||||
randResult(res);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
@ -141,9 +160,14 @@
|
||||
}
|
||||
$("#select-self-name").change(function () {
|
||||
clearResult();
|
||||
let accountUid = $("#select-self-name").val();
|
||||
if (accountUid === "" || accountUid.length <= 0) {
|
||||
return false;
|
||||
}
|
||||
getAccount();
|
||||
});
|
||||
$("#select-self-type").click(function () {
|
||||
clearResult();
|
||||
// clearResult();
|
||||
});
|
||||
function setAccount() {
|
||||
$.ajax({
|
||||
|
Loading…
Reference in New Issue
Block a user