mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2024-11-14 22:49:21 +08:00
boss系统添加了一些逻辑
This commit is contained in:
parent
2a7be69a37
commit
5099a04124
@ -16,7 +16,7 @@ func main() {
|
|||||||
** 注册日志信息
|
** 注册日志信息
|
||||||
*/
|
*/
|
||||||
func RegisterLogs() {
|
func RegisterLogs() {
|
||||||
logs.SetLogger(logs.AdapterFile,
|
_ = logs.SetLogger(logs.AdapterFile,
|
||||||
`{
|
`{
|
||||||
"filename":"../logs/legend.log",
|
"filename":"../logs/legend.log",
|
||||||
"level":4,
|
"level":4,
|
||||||
|
@ -2,104 +2,109 @@ package routers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"boss/controllers"
|
"boss/controllers"
|
||||||
beego "github.com/beego/beego/v2/server/web"
|
"github.com/beego/beego/v2/server/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func test() {
|
||||||
|
//web.Router("/accept/notify", &controllers.TestController{}, "*:AcceptNotify")
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
test()
|
||||||
//beego.Router("/", &controllers.PageController{}, "*:Index")
|
//beego.Router("/", &controllers.PageController{}, "*:Index")
|
||||||
//添加过滤函数
|
//添加过滤函数
|
||||||
beego.Router("/filter.html", &controllers.FilterController{}, "*:Filter")
|
web.Router("/filter.html", &controllers.FilterController{}, "*:Filter")
|
||||||
//登录验证接口
|
//登录验证接口
|
||||||
beego.Router("/login", &controllers.LoginController{}, "*:Login")
|
web.Router("/login", &controllers.LoginController{}, "*:Login")
|
||||||
beego.Router("/logout", &controllers.LoginController{}, "*:Logout")
|
web.Router("/logout", &controllers.LoginController{}, "*:Logout")
|
||||||
beego.Router("/getVerifyImg", &controllers.LoginController{}, "*:GetVerifyImg")
|
web.Router("/getVerifyImg", &controllers.LoginController{}, "*:GetVerifyImg")
|
||||||
beego.Router("/update/password", &controllers.UpdateController{}, "*:UpdatePassword")
|
web.Router("/update/password", &controllers.UpdateController{}, "*:UpdatePassword")
|
||||||
beego.Router("/freeze/operator", &controllers.UpdateController{}, "*:FreezeOperator")
|
web.Router("/freeze/operator", &controllers.UpdateController{}, "*:FreezeOperator")
|
||||||
beego.Router("/freeze/merchant", &controllers.UpdateController{}, "*:UpdateMerchantStatus")
|
web.Router("/freeze/merchant", &controllers.UpdateController{}, "*:UpdateMerchantStatus")
|
||||||
beego.Router("/unfreeze/operator", &controllers.UpdateController{}, "*:UnfreezeOperator")
|
web.Router("/unfreeze/operator", &controllers.UpdateController{}, "*:UnfreezeOperator")
|
||||||
beego.Router("/unfreeze/merchant", &controllers.UpdateController{}, "*:UpdateMerchantStatus")
|
web.Router("/unfreeze/merchant", &controllers.UpdateController{}, "*:UpdateMerchantStatus")
|
||||||
beego.Router("/edit/operator", &controllers.UpdateController{}, "*:EditOperator")
|
web.Router("/edit/operator", &controllers.UpdateController{}, "*:EditOperator")
|
||||||
beego.Router("/add/menu", &controllers.AddController{}, "*:AddMenu")
|
web.Router("/add/menu", &controllers.AddController{}, "*:AddMenu")
|
||||||
beego.Router("/add/secondMenu", &controllers.AddController{}, "*:AddSecondMenu")
|
web.Router("/add/secondMenu", &controllers.AddController{}, "*:AddSecondMenu")
|
||||||
beego.Router("/add/power", &controllers.AddController{}, "*:AddPower")
|
web.Router("/add/power", &controllers.AddController{}, "*:AddPower")
|
||||||
beego.Router("/add/role", &controllers.AddController{}, "*:AddRole")
|
web.Router("/add/role", &controllers.AddController{}, "*:AddRole")
|
||||||
beego.Router("/add/operator", &controllers.AddController{}, "*:AddOperator")
|
web.Router("/add/operator", &controllers.AddController{}, "*:AddOperator")
|
||||||
beego.Router("/add/bankCard", &controllers.AddController{}, "*:AddBankCard")
|
web.Router("/add/bankCard", &controllers.AddController{}, "*:AddBankCard")
|
||||||
beego.Router("/add/road", &controllers.AddController{}, "*:AddRoad")
|
web.Router("/add/road", &controllers.AddController{}, "*:AddRoad")
|
||||||
beego.Router("/add/roadPool", &controllers.AddController{}, "*:AddRoadPool")
|
web.Router("/add/roadPool", &controllers.AddController{}, "*:AddRoadPool")
|
||||||
beego.Router("/add/merchant", &controllers.AddController{}, "*:AddMerchant")
|
web.Router("/add/merchant", &controllers.AddController{}, "*:AddMerchant")
|
||||||
beego.Router("/add/agent", &controllers.AddController{}, "*:AddAgent")
|
web.Router("/add/agent", &controllers.AddController{}, "*:AddAgent")
|
||||||
beego.Router("/add/merchant/deploy", &controllers.AddController{}, "*:AddMerchantDeploy")
|
web.Router("/add/merchant/deploy", &controllers.AddController{}, "*:AddMerchantDeploy")
|
||||||
beego.Router("/add/merchant/payType", &controllers.AddController{}, "*:AddMerchantPayType")
|
web.Router("/add/merchant/payType", &controllers.AddController{}, "*:AddMerchantPayType")
|
||||||
beego.Router("/add/payfor", &controllers.AddController{}, "*:AddPayFor")
|
web.Router("/add/payfor", &controllers.AddController{}, "*:AddPayFor")
|
||||||
beego.Router("/add/self/payfor", &controllers.AddController{}, "*:AddSelfPayFor")
|
web.Router("/add/self/payfor", &controllers.AddController{}, "*:AddSelfPayFor")
|
||||||
beego.Router("/get/menu", &controllers.GetController{}, "*:GetMenu")
|
web.Router("/get/menu", &controllers.GetController{}, "*:GetMenu")
|
||||||
beego.Router("/get/secondMenu", &controllers.GetController{}, "*:GetSecondMenu")
|
web.Router("/get/secondMenu", &controllers.GetController{}, "*:GetSecondMenu")
|
||||||
beego.Router("/get/secondMenus", &controllers.GetController{}, "*:GetSecondMenus")
|
web.Router("/get/secondMenus", &controllers.GetController{}, "*:GetSecondMenus")
|
||||||
beego.Router("/get/oneMenu", &controllers.GetController{}, "*:GetOneMenu")
|
web.Router("/get/oneMenu", &controllers.GetController{}, "*:GetOneMenu")
|
||||||
beego.Router("/get/firstMenu", &controllers.GetController{}, "*:GetFirstMenu")
|
web.Router("/get/firstMenu", &controllers.GetController{}, "*:GetFirstMenu")
|
||||||
beego.Router("/get/powerItem", &controllers.GetController{}, "*:GetPowerItem")
|
web.Router("/get/powerItem", &controllers.GetController{}, "*:GetPowerItem")
|
||||||
beego.Router("/get/role", &controllers.GetController{}, "*:GetRole")
|
web.Router("/get/role", &controllers.GetController{}, "*:GetRole")
|
||||||
beego.Router("/get/allRole", &controllers.GetController{}, "*:GetAllRole")
|
web.Router("/get/allRole", &controllers.GetController{}, "*:GetAllRole")
|
||||||
beego.Router("/get/deployTree", &controllers.GetController{}, "*:GetDeployTree")
|
web.Router("/get/deployTree", &controllers.GetController{}, "*:GetDeployTree")
|
||||||
beego.Router("/get/operator", &controllers.GetController{}, "*:GetOperator")
|
web.Router("/get/operator", &controllers.GetController{}, "*:GetOperator")
|
||||||
beego.Router("/get/oneOperator", &controllers.GetController{}, "*:GetOneOperator")
|
web.Router("/get/oneOperator", &controllers.GetController{}, "*:GetOneOperator")
|
||||||
beego.Router("/get/editOperator", &controllers.GetController{}, "*:GetEditOperator")
|
web.Router("/get/editOperator", &controllers.GetController{}, "*:GetEditOperator")
|
||||||
beego.Router("/get/bankCard", &controllers.GetController{}, "*:GetBankCard")
|
web.Router("/get/bankCard", &controllers.GetController{}, "*:GetBankCard")
|
||||||
beego.Router("/get/oneBankCard", &controllers.GetController{}, "*:GetOneBankCard")
|
web.Router("/get/oneBankCard", &controllers.GetController{}, "*:GetOneBankCard")
|
||||||
beego.Router("/get/road", &controllers.GetController{}, "*:GetRoad")
|
web.Router("/get/road", &controllers.GetController{}, "*:GetRoad")
|
||||||
beego.Router("/get/oneRoad", &controllers.GetController{}, "*:GetOneRoad")
|
web.Router("/get/oneRoad", &controllers.GetController{}, "*:GetOneRoad")
|
||||||
beego.Router("/get/all/road", &controllers.GetController{}, "*:GetAllRoad")
|
web.Router("/get/all/road", &controllers.GetController{}, "*:GetAllRoad")
|
||||||
beego.Router("/get/roadPool", &controllers.GetController{}, "*:GetRoadPool")
|
web.Router("/get/roadPool", &controllers.GetController{}, "*:GetRoadPool")
|
||||||
beego.Router("/get/all/roll/pool", &controllers.GetController{}, "*:GetAllRollPool")
|
web.Router("/get/all/roll/pool", &controllers.GetController{}, "*:GetAllRollPool")
|
||||||
beego.Router("/get/merchant", &controllers.GetController{}, "*:GetMerchant")
|
web.Router("/get/merchant", &controllers.GetController{}, "*:GetMerchant")
|
||||||
beego.Router("/get/all/merchant", &controllers.GetController{}, "*:GetAllMerchant")
|
web.Router("/get/all/merchant", &controllers.GetController{}, "*:GetAllMerchant")
|
||||||
beego.Router("/get/one/merchant", &controllers.GetController{}, "*:GetOneMerchant")
|
web.Router("/get/one/merchant", &controllers.GetController{}, "*:GetOneMerchant")
|
||||||
beego.Router("/get/one/merchant/deploy", &controllers.GetController{}, "*:GetOneMerchantDeploy")
|
web.Router("/get/one/merchant/deploy", &controllers.GetController{}, "*:GetOneMerchantDeploy")
|
||||||
beego.Router("/get/all/account", &controllers.GetController{}, "*:GetAllAccount")
|
web.Router("/get/all/account", &controllers.GetController{}, "*:GetAllAccount")
|
||||||
beego.Router("/get/account", &controllers.GetController{}, "*:GetAccount")
|
web.Router("/get/account", &controllers.GetController{}, "*:GetAccount")
|
||||||
beego.Router("/get/one/account", &controllers.GetController{}, "*:GetOneAccount")
|
web.Router("/get/one/account", &controllers.GetController{}, "*:GetOneAccount")
|
||||||
beego.Router("/get/account/history", &controllers.GetController{}, "*:GetAccountHistory")
|
web.Router("/get/account/history", &controllers.GetController{}, "*:GetAccountHistory")
|
||||||
beego.Router("/get/agent", &controllers.GetController{}, "*:GetAgent")
|
web.Router("/get/agent", &controllers.GetController{}, "*:GetAgent")
|
||||||
beego.Router("/get/all/agent", &controllers.GetController{}, "*:GetAllAgent")
|
web.Router("/get/all/agent", &controllers.GetController{}, "*:GetAllAgent")
|
||||||
beego.Router("/get/product", &controllers.GetController{}, "*:GetProduct")
|
web.Router("/get/product", &controllers.GetController{}, "*:GetProduct")
|
||||||
beego.Router("/get/order", &controllers.GetController{}, "*:GetOrder")
|
web.Router("/get/order", &controllers.GetController{}, "*:GetOrder")
|
||||||
beego.Router("/get/one/order", &controllers.GetController{}, "*:GetOneOrder")
|
web.Router("/get/one/order", &controllers.GetController{}, "*:GetOneOrder")
|
||||||
beego.Router("/get/orderProfit", &controllers.GetController{}, "*:GetOrderProfit")
|
web.Router("/get/orderProfit", &controllers.GetController{}, "*:GetOrderProfit")
|
||||||
beego.Router("/get/payfor", &controllers.GetController{}, "*:GetPayFor")
|
web.Router("/get/payfor", &controllers.GetController{}, "*:GetPayFor")
|
||||||
beego.Router("/get/one/payfor", &controllers.GetController{}, "*:GetOnePayFor")
|
web.Router("/get/one/payfor", &controllers.GetController{}, "*:GetOnePayFor")
|
||||||
beego.Router("/get/balance", &controllers.GetController{}, "*:GetBalance")
|
web.Router("/get/balance", &controllers.GetController{}, "*:GetBalance")
|
||||||
beego.Router("/get/notify/bankOrderId/list", &controllers.GetController{}, "*:GetNotifyBankOrderIdList")
|
web.Router("/get/notify/bankOrderId/list", &controllers.GetController{}, "*:GetNotifyBankOrderIdList")
|
||||||
beego.Router("/get/agent/to/merchant", &controllers.GetController{}, "*:GetAgentToMerchant")
|
web.Router("/get/agent/to/merchant", &controllers.GetController{}, "*:GetAgentToMerchant")
|
||||||
beego.Router("/get/profit", &controllers.GetController{}, "*:GetProfit")
|
web.Router("/get/profit", &controllers.GetController{}, "*:GetProfit")
|
||||||
beego.Router("/save/power", &controllers.AddController{}, "*:SavePower")
|
web.Router("/save/power", &controllers.AddController{}, "*:SavePower")
|
||||||
beego.Router("/save/roadUid", &controllers.AddController{}, "*:SaveRoadUid")
|
web.Router("/save/roadUid", &controllers.AddController{}, "*:SaveRoadUid")
|
||||||
beego.Router("/up/menu", &controllers.UpdateController{}, "*:UpMenu")
|
web.Router("/up/menu", &controllers.UpdateController{}, "*:UpMenu")
|
||||||
beego.Router("/down/menu", &controllers.UpdateController{}, "*:DownMenu")
|
web.Router("/down/menu", &controllers.UpdateController{}, "*:DownMenu")
|
||||||
beego.Router("/up/secondMenu", &controllers.UpdateController{}, "*:UpSecondMenu")
|
web.Router("/up/secondMenu", &controllers.UpdateController{}, "*:UpSecondMenu")
|
||||||
beego.Router("/down/secondMenu", &controllers.UpdateController{}, "*:DownSecondMenu")
|
web.Router("/down/secondMenu", &controllers.UpdateController{}, "*:DownSecondMenu")
|
||||||
beego.Router("/update/roadStatus", &controllers.UpdateController{}, "*:UpdateRoadStatus")
|
web.Router("/update/roadStatus", &controllers.UpdateController{}, "*:UpdateRoadStatus")
|
||||||
beego.Router("/update/account/status", &controllers.UpdateController{}, "*:UpdateAccountStatus")
|
web.Router("/update/account/status", &controllers.UpdateController{}, "*:UpdateAccountStatus")
|
||||||
beego.Router("/update/agent/status", &controllers.UpdateController{}, "*:UpdateAgentStatus")
|
web.Router("/update/agent/status", &controllers.UpdateController{}, "*:UpdateAgentStatus")
|
||||||
beego.Router("/update/order/status", &controllers.UpdateController{}, "*:UpdateOrderStatus")
|
web.Router("/update/order/status", &controllers.UpdateController{}, "*:UpdateOrderStatus")
|
||||||
beego.Router("/account/operator", &controllers.UpdateController{}, "*:OperatorAccount")
|
web.Router("/account/operator", &controllers.UpdateController{}, "*:OperatorAccount")
|
||||||
beego.Router("/delete/menu", &controllers.Deletecontroller{}, "*:DeleteMenu")
|
web.Router("/delete/menu", &controllers.DeleteController{}, "*:DeleteMenu")
|
||||||
beego.Router("/delete/secondMenu", &controllers.Deletecontroller{}, "*:DeleteSecondMenu")
|
web.Router("/delete/secondMenu", &controllers.DeleteController{}, "*:DeleteSecondMenu")
|
||||||
beego.Router("/delete/powerItem", &controllers.Deletecontroller{}, "*:DeletePowerItem")
|
web.Router("/delete/powerItem", &controllers.DeleteController{}, "*:DeletePowerItem")
|
||||||
beego.Router("/delete/role", &controllers.Deletecontroller{}, "*:DeleteRole")
|
web.Router("/delete/role", &controllers.DeleteController{}, "*:DeleteRole")
|
||||||
beego.Router("/delete/operator", &controllers.Deletecontroller{}, "*:DeleteOperator")
|
web.Router("/delete/operator", &controllers.DeleteController{}, "*:DeleteOperator")
|
||||||
beego.Router("/delete/bankCardRecord", &controllers.Deletecontroller{}, "*:DeleteBankCardRecord")
|
web.Router("/delete/bankCardRecord", &controllers.DeleteController{}, "*:DeleteBankCardRecord")
|
||||||
beego.Router("/delete/road", &controllers.Deletecontroller{}, "*:DeleteRoad")
|
web.Router("/delete/road", &controllers.DeleteController{}, "*:DeleteRoad")
|
||||||
beego.Router("/delete/roadPool", &controllers.Deletecontroller{}, "*:DeleteRoadPool")
|
web.Router("/delete/roadPool", &controllers.DeleteController{}, "*:DeleteRoadPool")
|
||||||
beego.Router("/delete/merchant", &controllers.Deletecontroller{}, "*:DeleteMerchant")
|
web.Router("/delete/merchant", &controllers.DeleteController{}, "*:DeleteMerchant")
|
||||||
beego.Router("/delete/account", &controllers.Deletecontroller{}, "*:DeleteAccount")
|
web.Router("/delete/account", &controllers.DeleteController{}, "*:DeleteAccount")
|
||||||
beego.Router("/delete/agent", &controllers.Deletecontroller{}, "*:DeleteAgent")
|
web.Router("/delete/agent", &controllers.DeleteController{}, "*:DeleteAgent")
|
||||||
beego.Router("/delete/agent/merchant/relation", &controllers.Deletecontroller{}, "*:DeleteAgentRelation")
|
web.Router("/delete/agent/merchant/relation", &controllers.DeleteController{}, "*:DeleteAgentRelation")
|
||||||
beego.Router("/reset/agent/password", &controllers.UpdateController{}, "*:ResetAgentPassword")
|
web.Router("/reset/agent/password", &controllers.UpdateController{}, "*:ResetAgentPassword")
|
||||||
beego.Router("/supplier/order/query", &controllers.SupplierQuery{}, "*:SupplierOrderQuery")
|
web.Router("/supplier/order/query", &controllers.SupplierQuery{}, "*:SupplierOrderQuery")
|
||||||
beego.Router("/supplier/payfor/query", &controllers.SupplierQuery{}, "*:SupplierPayForQuery")
|
web.Router("/supplier/payfor/query", &controllers.SupplierQuery{}, "*:SupplierPayForQuery")
|
||||||
beego.Router("/choose/payfor/road", &controllers.UpdateController{}, "*:ChoosePayForRoad")
|
web.Router("/choose/payfor/road", &controllers.UpdateController{}, "*:ChoosePayForRoad")
|
||||||
beego.Router("/result/payfor", &controllers.UpdateController{}, "*:ResultPayFor")
|
web.Router("/result/payfor", &controllers.UpdateController{}, "*:ResultPayFor")
|
||||||
beego.Router("/send/notify", &controllers.SendNotify{}, "*:SendNotifyToMerchant")
|
web.Router("/send/notify", &controllers.SendNotify{}, "*:SendNotifyToMerchant")
|
||||||
beego.Router("/self/send/notify", &controllers.SendNotify{}, "*:SelfSendNotify")
|
web.Router("/self/send/notify", &controllers.SendNotify{}, "*:SelfSendNotify")
|
||||||
}
|
}
|
||||||
|
961
boss/service/addService.go
Normal file
961
boss/service/addService.go
Normal file
@ -0,0 +1,961 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"boss/common"
|
||||||
|
"boss/datas"
|
||||||
|
"boss/models/accounts"
|
||||||
|
"boss/models/agent"
|
||||||
|
"boss/models/merchant"
|
||||||
|
"boss/models/payfor"
|
||||||
|
"boss/models/road"
|
||||||
|
"boss/models/system"
|
||||||
|
"boss/models/user"
|
||||||
|
"boss/utils"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
"github.com/beego/beego/v2/core/validation"
|
||||||
|
"github.com/rs/xid"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AddService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddMenu(oneMenu, userID string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
menuInfo := system.MenuInfo{
|
||||||
|
MenuUid: xid.New().String(),
|
||||||
|
FirstMenu: oneMenu,
|
||||||
|
Status: "active",
|
||||||
|
Creater: userID,
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
exist := system.FirstMenuIsExists(oneMenu)
|
||||||
|
if !exist {
|
||||||
|
menuInfo.MenuOrder = system.GetMenuLen() + 1
|
||||||
|
flag := system.InsertMenu(menuInfo)
|
||||||
|
if !flag {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "添加菜单失败"
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "一级菜单名已经存在"
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddSecondMenu(firstMenuUid, secondRouter, secondMenu, userID string) *datas.KeyDataJSON {
|
||||||
|
dataJSON := new(datas.KeyDataJSON)
|
||||||
|
|
||||||
|
firstMenuInfo := system.GetMenuInfoByMenuUid(firstMenuUid)
|
||||||
|
routerExists := system.SecondRouterExists(secondRouter)
|
||||||
|
secondMenuExists := system.SecondMenuIsExists(secondMenu)
|
||||||
|
|
||||||
|
if firstMenuInfo.MenuUid == "" {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Key = "pre-menu-error"
|
||||||
|
dataJSON.Msg = "*一级菜单不存在"
|
||||||
|
} else if routerExists {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "*该路由已存在"
|
||||||
|
dataJSON.Key = "second-router-error"
|
||||||
|
} else if secondMenuExists {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Key = "second-menu-error"
|
||||||
|
dataJSON.Msg = "*该菜单名已经存在"
|
||||||
|
} else {
|
||||||
|
sl := system.GetSecondMenuLenByFirstMenuUid(firstMenuUid)
|
||||||
|
secondMenuInfo := system.SecondMenuInfo{
|
||||||
|
MenuOrder: sl + 1,
|
||||||
|
FirstMenuUid: firstMenuInfo.MenuUid,
|
||||||
|
FirstMenu: firstMenuInfo.FirstMenu,
|
||||||
|
SecondMenuUid: xid.New().String(),
|
||||||
|
Status: "active",
|
||||||
|
SecondMenu: secondMenu,
|
||||||
|
SecondRouter: secondRouter,
|
||||||
|
Creater: userID,
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
FirstMenuOrder: firstMenuInfo.MenuOrder,
|
||||||
|
}
|
||||||
|
if !system.InsertSecondMenu(secondMenuInfo) {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "添加二级菜单失败"
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
dataJSON.Msg = "添加二级菜单成功"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddPower(powerItem, powerID, firstMenuUid, secondMenuUid, userID string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
|
||||||
|
if powerItem == "" || len(powerItem) == 0 {
|
||||||
|
keyDataJSON.Key = ".power-name-error"
|
||||||
|
keyDataJSON.Msg = "*权限项名称不能为空"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
if powerID == "" || len(powerID) == 0 {
|
||||||
|
keyDataJSON.Key = ".power-id-error"
|
||||||
|
keyDataJSON.Msg = "*权限项ID不能为空"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
if system.PowerUidExists(powerID) {
|
||||||
|
keyDataJSON.Key = ".power-id-error"
|
||||||
|
keyDataJSON.Msg = "*权限项ID已经存在"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
secondMenuInfo := system.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||||
|
|
||||||
|
powerInfo := system.PowerInfo{
|
||||||
|
SecondMenuUid: secondMenuUid,
|
||||||
|
SecondMenu: secondMenuInfo.SecondMenu,
|
||||||
|
PowerId: powerID, PowerItem: powerItem,
|
||||||
|
Creater: userID,
|
||||||
|
Status: "active",
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
FirstMenuUid: firstMenuUid,
|
||||||
|
}
|
||||||
|
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
if !system.InsertPowerInfo(powerInfo) {
|
||||||
|
keyDataJSON.Key = ".power-save-success"
|
||||||
|
keyDataJSON.Msg = "添加权限项失败"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Key = ".power-save-success"
|
||||||
|
keyDataJSON.Msg = "添加权限项成功"
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddRole(roleName, roleRemark, userID string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
if len(roleName) == 0 {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = ".role-name-error"
|
||||||
|
keyDataJSON.Msg = "*角色名称不能为空"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if system.RoleNameExists(roleName) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = ".role-name-error"
|
||||||
|
keyDataJSON.Msg = "*角色名称已经存在"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
roleInfo := system.RoleInfo{
|
||||||
|
RoleName: roleName,
|
||||||
|
RoleUid: xid.New().String(),
|
||||||
|
Creater: userID,
|
||||||
|
Status: "active",
|
||||||
|
Remark: roleRemark,
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if !system.InsertRole(roleInfo) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = ".role-save-success"
|
||||||
|
keyDataJSON.Msg = "添加角色失败"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) SavePower(roleUid string, firstMenuUids, secondMenuUids, powerIds []string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
roleInfo := system.GetRoleByRoleUid(roleUid)
|
||||||
|
if len(roleUid) == 0 || len(roleInfo.RoleUid) == 0 {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
roleInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
roleInfo.ShowFirstUid = strings.Join(firstMenuUids, "||")
|
||||||
|
roleInfo.ShowSecondUid = strings.Join(secondMenuUids, "||")
|
||||||
|
roleInfo.ShowPowerUid = strings.Join(powerIds, "||")
|
||||||
|
|
||||||
|
menuInfoList := system.GetMenuInfosByMenuUids(firstMenuUids)
|
||||||
|
showFirstMenu := make([]string, 0)
|
||||||
|
for _, m := range menuInfoList {
|
||||||
|
showFirstMenu = append(showFirstMenu, m.FirstMenu)
|
||||||
|
}
|
||||||
|
roleInfo.ShowFirstMenu = strings.Join(showFirstMenu, "||")
|
||||||
|
|
||||||
|
secondMenuInfoList := system.GetSecondMenuInfoBySecondMenuUids(secondMenuUids)
|
||||||
|
showSecondMenu := make([]string, 0)
|
||||||
|
for _, m := range secondMenuInfoList {
|
||||||
|
showSecondMenu = append(showSecondMenu, m.SecondMenu)
|
||||||
|
}
|
||||||
|
roleInfo.ShowSecondMenu = strings.Join(showSecondMenu, "||")
|
||||||
|
|
||||||
|
powerList := system.GetPowerByIds(powerIds)
|
||||||
|
showPower := make([]string, 0)
|
||||||
|
for _, p := range powerList {
|
||||||
|
showPower = append(showPower, p.PowerItem)
|
||||||
|
}
|
||||||
|
roleInfo.ShowPower = strings.Join(showPower, "||")
|
||||||
|
|
||||||
|
if !system.UpdateRoleInfo(roleInfo) {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "更新roleInfo失败"
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
dataJSON.Msg = "更新roleInfo成功"
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddOperator(loginAccount, loginPassword, role, status, remark string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
if len(loginAccount) == 0 {
|
||||||
|
keyDataJSON.Key = ".operator-name-error"
|
||||||
|
keyDataJSON.Msg = "*登录账号不能为空"
|
||||||
|
} else if len(loginPassword) == 0 {
|
||||||
|
keyDataJSON.Key = ".operator-password-error"
|
||||||
|
keyDataJSON.Msg = "*初始密码不能为空"
|
||||||
|
} else if len(role) == 0 || role == "none" {
|
||||||
|
keyDataJSON.Key = ".operator-role-error"
|
||||||
|
keyDataJSON.Msg = "请选择角色"
|
||||||
|
} else if user.UserInfoExistByUserId(loginAccount) {
|
||||||
|
keyDataJSON.Key = ".operator-name-error"
|
||||||
|
keyDataJSON.Msg = "*账号已经存在"
|
||||||
|
} else {
|
||||||
|
if len(remark) == 0 {
|
||||||
|
remark = loginAccount
|
||||||
|
}
|
||||||
|
roleInfo := system.GetRoleByRoleUid(role)
|
||||||
|
userInfo := user.UserInfo{
|
||||||
|
UserId: loginAccount,
|
||||||
|
Passwd: utils.GetMD5Upper(loginPassword),
|
||||||
|
Nick: "壮壮", Remark: remark,
|
||||||
|
Status: status,
|
||||||
|
Role: role,
|
||||||
|
RoleName: roleInfo.RoleName,
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
if !user.InsertUser(userInfo) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "添加操作员失败"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "添加操作员成功"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddBankCard(userName, bankCode, accountName, certificateType,
|
||||||
|
phoneNo, bankName, bankAccountType, bankNo, certificateNo, bankAddress, uid, identifyCard string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
|
||||||
|
dataJSON.Code = -1
|
||||||
|
if len(userName) == 0 {
|
||||||
|
dataJSON.Msg = "用户名不能为空"
|
||||||
|
} else if len(bankCode) == 0 {
|
||||||
|
dataJSON.Msg = "银行编码不能为空"
|
||||||
|
} else if len(accountName) == 0 {
|
||||||
|
dataJSON.Msg = "银行开户名不能为空"
|
||||||
|
} else if len(certificateType) == 0 {
|
||||||
|
dataJSON.Msg = "证件种类不能为空"
|
||||||
|
} else if len(phoneNo) == 0 {
|
||||||
|
dataJSON.Msg = "手机号不能为空"
|
||||||
|
} else if len(bankName) == 0 {
|
||||||
|
dataJSON.Msg = "银行名称不能为空"
|
||||||
|
} else if len(bankAccountType) == 0 {
|
||||||
|
dataJSON.Msg = "银行账户类型不能为空"
|
||||||
|
} else if len(bankNo) == 0 {
|
||||||
|
dataJSON.Msg = "银行账号不能为空"
|
||||||
|
} else if len(certificateNo) == 0 {
|
||||||
|
dataJSON.Msg = "身份证号不能为空"
|
||||||
|
} else if len(bankAddress) == 0 {
|
||||||
|
dataJSON.Msg = "银行地址不能为空"
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
if dataJSON.Msg != "" {
|
||||||
|
logs.Error("添加银行卡校验失败")
|
||||||
|
} else {
|
||||||
|
if len(uid) > 0 {
|
||||||
|
bankCardInfo := system.GetBankCardByUid(uid)
|
||||||
|
bankCardInfo = system.BankCardInfo{
|
||||||
|
Id: bankCardInfo.Id,
|
||||||
|
UserName: userName,
|
||||||
|
BankName: bankName,
|
||||||
|
BankCode: bankCode,
|
||||||
|
BankAccountType: bankAccountType,
|
||||||
|
AccountName: accountName,
|
||||||
|
BankNo: bankNo,
|
||||||
|
IdentifyCard: identifyCard,
|
||||||
|
CertificateNo: certificateNo,
|
||||||
|
PhoneNo: phoneNo,
|
||||||
|
BankAddress: bankAddress,
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
CreateTime: bankCardInfo.CreateTime,
|
||||||
|
Uid: bankCardInfo.Uid,
|
||||||
|
}
|
||||||
|
if system.UpdateBankCard(bankCardInfo) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bankCardInfo := system.BankCardInfo{
|
||||||
|
Uid: "3333" + xid.New().String(),
|
||||||
|
UserName: userName,
|
||||||
|
BankName: bankName,
|
||||||
|
BankCode: bankCode,
|
||||||
|
BankAccountType: bankAccountType,
|
||||||
|
AccountName: accountName,
|
||||||
|
BankNo: bankNo,
|
||||||
|
IdentifyCard: identifyCard,
|
||||||
|
CertificateNo: certificateNo,
|
||||||
|
PhoneNo: phoneNo,
|
||||||
|
BankAddress: bankAddress,
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if system.InsertBankCardInfo(bankCardInfo) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddRoad(startHour, endHour, roadName, productUid,
|
||||||
|
payType, basicRate, settleFee, roadTotalLimit, roadEverydayLimit,
|
||||||
|
singleMinLimit, singleMaxLimit, roadUid, roadRemark, params string) *datas.BaseDataJSON {
|
||||||
|
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
dataJSON.Code = -1
|
||||||
|
|
||||||
|
startHourTmp, err1 := strconv.Atoi(startHour)
|
||||||
|
endHourTmp, err2 := strconv.Atoi(endHour)
|
||||||
|
|
||||||
|
if err1 != nil || err2 != nil {
|
||||||
|
dataJSON.Msg = "开始时间或者结束时间设置有误"
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
valid := validation.Validation{}
|
||||||
|
if v := valid.Required(roadName, "roadName"); !v.Ok {
|
||||||
|
dataJSON.Msg = "通道名称不能为空"
|
||||||
|
} else if v := valid.Required(productUid, "productUid"); !v.Ok {
|
||||||
|
dataJSON.Msg = "产品名称不能为空"
|
||||||
|
} else if v := valid.Required(payType, "payType"); !v.Ok {
|
||||||
|
dataJSON.Msg = "支付类型不能为空"
|
||||||
|
} else if v := valid.Required(basicRate, ""); !v.Ok {
|
||||||
|
dataJSON.Msg = "成本费率不能为空"
|
||||||
|
} else if v := valid.Range(startHourTmp, 0, 23, ""); !v.Ok {
|
||||||
|
dataJSON.Msg = "开始时间设置有误"
|
||||||
|
} else if v := valid.Range(endHourTmp, 0, 23, ""); !v.Ok {
|
||||||
|
dataJSON.Msg = "结束时间设置有误"
|
||||||
|
} else {
|
||||||
|
basicFee, err := strconv.ParseFloat(basicRate, 64)
|
||||||
|
if err != nil {
|
||||||
|
dataJSON.Msg = "成本汇率设置不符合规范"
|
||||||
|
}
|
||||||
|
settleFeeTmp, err := strconv.ParseFloat(settleFee, 64)
|
||||||
|
if err != nil {
|
||||||
|
dataJSON.Msg = "代付手续费设置不符合规范"
|
||||||
|
}
|
||||||
|
totalLimit, err := strconv.ParseFloat(roadTotalLimit, 64)
|
||||||
|
if err != nil {
|
||||||
|
dataJSON.Msg = "通道总额度设置不符合规范"
|
||||||
|
}
|
||||||
|
todayLimit, err := strconv.ParseFloat(roadEverydayLimit, 64)
|
||||||
|
if err != nil {
|
||||||
|
dataJSON.Msg = "每天额度设置不符合规范"
|
||||||
|
}
|
||||||
|
singleMinLimitTmp, err := strconv.ParseFloat(singleMinLimit, 64)
|
||||||
|
if err != nil {
|
||||||
|
dataJSON.Msg = "单笔最小金额设置不符合规范"
|
||||||
|
}
|
||||||
|
singleMaxLimitTmp, err := strconv.ParseFloat(singleMaxLimit, 64)
|
||||||
|
if err != nil {
|
||||||
|
dataJSON.Msg = "单笔最大金额设置不符合规范"
|
||||||
|
}
|
||||||
|
if len(dataJSON.Msg) > 0 {
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
productName := ""
|
||||||
|
supplierMap := common.GetSupplierMap()
|
||||||
|
for k, v := range supplierMap {
|
||||||
|
if k == productUid {
|
||||||
|
productName = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(roadUid) > 0 {
|
||||||
|
//更新通道
|
||||||
|
roadInfo := road.GetRoadInfoByRoadUid(roadUid)
|
||||||
|
roadInfo.RoadName = roadName
|
||||||
|
roadInfo.Remark = roadRemark
|
||||||
|
roadInfo.ProductUid = productUid
|
||||||
|
roadInfo.ProductName = productName
|
||||||
|
roadInfo.PayType = payType
|
||||||
|
roadInfo.BasicFee = basicFee
|
||||||
|
roadInfo.SettleFee = settleFeeTmp
|
||||||
|
roadInfo.TotalLimit = totalLimit
|
||||||
|
roadInfo.TodayLimit = todayLimit
|
||||||
|
roadInfo.SingleMaxLimit = singleMaxLimitTmp
|
||||||
|
roadInfo.SingleMinLimit = singleMinLimitTmp
|
||||||
|
roadInfo.StarHour = startHourTmp
|
||||||
|
roadInfo.EndHour = endHourTmp
|
||||||
|
roadInfo.Params = params
|
||||||
|
|
||||||
|
if road.UpdateRoadInfo(roadInfo) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
dataJSON.Msg = "通道更新失败"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//添加新的通道
|
||||||
|
roadUid = "4444" + xid.New().String()
|
||||||
|
roadInfo := road.RoadInfo{
|
||||||
|
RoadName: roadName,
|
||||||
|
RoadUid: roadUid,
|
||||||
|
Remark: roadRemark,
|
||||||
|
ProductUid: productUid,
|
||||||
|
ProductName: productName,
|
||||||
|
PayType: payType,
|
||||||
|
BasicFee: basicFee,
|
||||||
|
SettleFee: settleFeeTmp,
|
||||||
|
TotalLimit: totalLimit,
|
||||||
|
TodayLimit: todayLimit,
|
||||||
|
SingleMinLimit: singleMinLimitTmp,
|
||||||
|
Balance: common.ZERO,
|
||||||
|
SingleMaxLimit: singleMaxLimitTmp,
|
||||||
|
StarHour: startHourTmp,
|
||||||
|
EndHour: endHourTmp,
|
||||||
|
Status: "active",
|
||||||
|
Params: params,
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if road.InsertRoadInfo(roadInfo) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
dataJSON.Msg = "添加新通道失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddRoadPool(roadPoolName, roadPoolCode string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
|
||||||
|
if len(roadPoolName) == 0 {
|
||||||
|
keyDataJSON.Msg = "*通道池名称不能为空"
|
||||||
|
} else if len(roadPoolCode) == 0 {
|
||||||
|
keyDataJSON.Msg = "*通道池编号不能为空"
|
||||||
|
}
|
||||||
|
|
||||||
|
roadPoolInfo := road.RoadPoolInfo{
|
||||||
|
Status: "active",
|
||||||
|
RoadPoolName: roadPoolName,
|
||||||
|
RoadPoolCode: roadPoolCode,
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if road.InsertRoadPool(roadPoolInfo) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "添加通道池成功"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Msg = "添加通道池失败"
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) SaveRoadUid(roadPoolCode string, roadUids []string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
dataJSON.Code = -1
|
||||||
|
roadPoolInfo := road.GetRoadPoolByRoadPoolCode(roadPoolCode)
|
||||||
|
if roadPoolInfo.RoadPoolCode == "" {
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
var uids []string
|
||||||
|
for _, uid := range roadUids {
|
||||||
|
//去掉空格
|
||||||
|
if len(uid) > 0 && road.RoadInfoExistByRoadUid(uid) {
|
||||||
|
uids = append(uids, uid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(uids) > 0 {
|
||||||
|
roadUid := strings.Join(uids, "||")
|
||||||
|
roadPoolInfo.RoadUidPool = roadUid
|
||||||
|
}
|
||||||
|
roadPoolInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
if road.UpdateRoadPool(roadPoolInfo) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddAgent(agentName, agentPhone, agentLoginPassword,
|
||||||
|
agentVertifyPassword, status, agentUid, agentRemark string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
|
||||||
|
if agentName == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#agent-name-error"
|
||||||
|
keyDataJSON.Msg = "代理名不能为空"
|
||||||
|
} else if agent.IsEixstByAgentName(agentName) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#agent-name-error"
|
||||||
|
keyDataJSON.Msg = "已存在该代理名称"
|
||||||
|
} else if agentPhone == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#agent-phone-error"
|
||||||
|
keyDataJSON.Msg = "代理注册手机号不能为空"
|
||||||
|
} else if agent.IsEixstByAgentPhone(agentPhone) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#agent-phone-error"
|
||||||
|
keyDataJSON.Msg = "代理商手机号已被注册"
|
||||||
|
} else if agentLoginPassword == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#agent-login-password-error"
|
||||||
|
keyDataJSON.Msg = "密码不能为空"
|
||||||
|
} else if agentLoginPassword != agentVertifyPassword {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#agent-vertify-password-error"
|
||||||
|
keyDataJSON.Msg = "二次密码输入不一致"
|
||||||
|
}
|
||||||
|
|
||||||
|
if keyDataJSON.Code == -1 {
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if status == "" {
|
||||||
|
status = "active"
|
||||||
|
}
|
||||||
|
|
||||||
|
if agentUid == "" {
|
||||||
|
|
||||||
|
agentUid = "9999" + xid.New().String()
|
||||||
|
|
||||||
|
agentInfo := agent.AgentInfo{
|
||||||
|
Status: status,
|
||||||
|
AgentName: agentName,
|
||||||
|
AgentPhone: agentPhone,
|
||||||
|
AgentPassword: utils.GetMD5Upper(agentLoginPassword),
|
||||||
|
AgentUid: agentUid,
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
AgentRemark: agentRemark,
|
||||||
|
}
|
||||||
|
|
||||||
|
if !agent.InsertAgentInfo(agentInfo) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "添加代理商失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//创建新的账户
|
||||||
|
account := accounts.GetAccountByUid(agentUid)
|
||||||
|
if account.AccountUid == "" {
|
||||||
|
account.Status = "active"
|
||||||
|
account.AccountUid = agentUid
|
||||||
|
account.AccountName = agentName
|
||||||
|
account.Balance = 0.0
|
||||||
|
account.LoanAmount = 0.0
|
||||||
|
account.FreezeAmount = 0.0
|
||||||
|
account.PayforAmount = 0.0
|
||||||
|
account.SettleAmount = 0.0
|
||||||
|
account.WaitAmount = 0.0
|
||||||
|
account.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
account.CreateTime = utils.GetBasicDateTime()
|
||||||
|
if accounts.InsetAcount(account) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "插入成功"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "掺入失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
func (c *AddService) AddMerchant(merchantName, phone, loginPassword,
|
||||||
|
verifyPassword, merchantStatus, remark string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
if merchantName == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#merchant-name-error"
|
||||||
|
keyDataJSON.Msg = "商户名称为空"
|
||||||
|
} else if merchant.IsExistByMerchantName(merchantName) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#merchant-name-error"
|
||||||
|
keyDataJSON.Msg = "商户名已经存在"
|
||||||
|
} else if phone == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#merchant-phone-error"
|
||||||
|
keyDataJSON.Msg = "手机号为空"
|
||||||
|
} else if merchant.IsExistByMerchantPhone(phone) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#merchant-phone-error"
|
||||||
|
keyDataJSON.Msg = "该手机号已经注册"
|
||||||
|
} else if loginPassword == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#merchant-login-password-error"
|
||||||
|
keyDataJSON.Msg = "登录密码为空"
|
||||||
|
} else if verifyPassword == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#merchant-verify-password-error"
|
||||||
|
keyDataJSON.Msg = "密码确认为空"
|
||||||
|
} else if loginPassword != verifyPassword {
|
||||||
|
keyDataJSON.Key = "#merchant-verify-password-error"
|
||||||
|
keyDataJSON.Msg = "两次密码输入不正确"
|
||||||
|
} else if merchantStatus == "" {
|
||||||
|
merchantStatus = "active"
|
||||||
|
}
|
||||||
|
if keyDataJSON.Code == -1 {
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
merchantUid := "8888" + xid.New().String()
|
||||||
|
merchantKey := "kkkk" + xid.New().String() //商户key
|
||||||
|
merchantSecret := "ssss" + xid.New().String() //商户密钥
|
||||||
|
merchantInfo := merchant.MerchantInfo{
|
||||||
|
MerchantName: merchantName,
|
||||||
|
MerchantUid: merchantUid,
|
||||||
|
LoginAccount: phone,
|
||||||
|
MerchantKey: merchantKey,
|
||||||
|
MerchantSecret: merchantSecret,
|
||||||
|
LoginPassword: utils.GetMD5Upper(loginPassword),
|
||||||
|
Status: merchantStatus,
|
||||||
|
Remark: remark,
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if merchant.InsertMerchantInfo(merchantInfo) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "插入失败"
|
||||||
|
}
|
||||||
|
//创建新的账户
|
||||||
|
account := accounts.GetAccountByUid(merchantUid)
|
||||||
|
if account.AccountUid == "" {
|
||||||
|
account.Status = "active"
|
||||||
|
account.AccountUid = merchantUid
|
||||||
|
account.AccountName = merchantName
|
||||||
|
account.Balance = 0.0
|
||||||
|
account.LoanAmount = 0.0
|
||||||
|
account.FreezeAmount = 0.0
|
||||||
|
account.PayforAmount = 0.0
|
||||||
|
account.SettleAmount = 0.0
|
||||||
|
account.WaitAmount = 0.0
|
||||||
|
account.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
account.CreateTime = utils.GetBasicDateTime()
|
||||||
|
if accounts.InsetAcount(account) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "插入成功"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "掺入失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddMerchantDeploy(merchantUid, isAutoSettle, isAutoPayfor, ipWhite, belongAgentName,
|
||||||
|
belongAgentUid, payforRoadChoose, rollPayforRoadChoose, payforFee string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
merchantInfo := merchant.GetMerchantByUid(merchantUid)
|
||||||
|
merchantInfo.AutoSettle = isAutoSettle
|
||||||
|
merchantInfo.AutoPayFor = isAutoPayfor
|
||||||
|
merchantInfo.WhiteIps = ipWhite
|
||||||
|
merchantInfo.BelongAgentName = belongAgentName
|
||||||
|
merchantInfo.BelongAgentUid = belongAgentUid
|
||||||
|
|
||||||
|
if payforRoadChoose != "" {
|
||||||
|
roadInfo := road.GetRoadInfoByName(payforRoadChoose)
|
||||||
|
merchantInfo.SinglePayForRoadName = payforRoadChoose
|
||||||
|
merchantInfo.SinglePayForRoadUid = roadInfo.RoadUid
|
||||||
|
}
|
||||||
|
if rollPayforRoadChoose != "" {
|
||||||
|
rollPoolInfo := road.GetRoadPoolByName(rollPayforRoadChoose)
|
||||||
|
merchantInfo.RollPayForRoadName = rollPayforRoadChoose
|
||||||
|
merchantInfo.RollPayForRoadCode = rollPoolInfo.RoadPoolCode
|
||||||
|
}
|
||||||
|
tmp, err := strconv.ParseFloat(payforFee, 64)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("手续费由字符串转为float64失败")
|
||||||
|
tmp = common.PAYFOR_FEE
|
||||||
|
}
|
||||||
|
merchantInfo.PayforFee = tmp
|
||||||
|
if merchant.UpdateMerchant(merchantInfo) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddMerchantPayType(payType, singleRoad, rollPoolRoad,
|
||||||
|
singleRoadPlatformFee, rollRoadPlatformFee, singleRoadAgentFee, rollRoadAgentFee,
|
||||||
|
loanRate, loanDays, unfreezeTimeHour, merchantNo, isLoan string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
if payType == "" || payType == "none" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "操作失败,请选择支付类型"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if singleRoad == "" && rollPoolRoad == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "单通道、轮询通道至少要有一个不为空!"
|
||||||
|
}
|
||||||
|
|
||||||
|
if singleRoad != "" && singleRoadPlatformFee == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "单通道平台利润率不能为0"
|
||||||
|
}
|
||||||
|
|
||||||
|
if rollPoolRoad != "" && rollRoadPlatformFee == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "轮询通道平台利润率不能为0"
|
||||||
|
}
|
||||||
|
|
||||||
|
if keyDataJSON.Code == -1 {
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
//将字符串转变为float64或者int类型
|
||||||
|
a, err := strconv.ParseFloat(singleRoadPlatformFee, 64)
|
||||||
|
if err != nil {
|
||||||
|
a = 0.0
|
||||||
|
}
|
||||||
|
b, err := strconv.ParseFloat(singleRoadAgentFee, 64)
|
||||||
|
if err != nil {
|
||||||
|
b = 0.0
|
||||||
|
}
|
||||||
|
cs, err := strconv.ParseFloat(rollRoadPlatformFee, 64)
|
||||||
|
if err != nil {
|
||||||
|
cs = 0.0
|
||||||
|
}
|
||||||
|
d, err := strconv.ParseFloat(rollRoadAgentFee, 64)
|
||||||
|
if err != nil {
|
||||||
|
d = 0.0
|
||||||
|
}
|
||||||
|
e, err := strconv.ParseFloat(loanRate, 64)
|
||||||
|
if err != nil {
|
||||||
|
e = 0.0
|
||||||
|
}
|
||||||
|
i, err := strconv.Atoi(loanDays)
|
||||||
|
if err != nil {
|
||||||
|
i = 0
|
||||||
|
}
|
||||||
|
j, err := strconv.Atoi(unfreezeTimeHour)
|
||||||
|
if err != nil {
|
||||||
|
j = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
var merchantDeployInfo merchant.MerchantDeployInfo
|
||||||
|
merchantDeployInfo.MerchantUid = merchantNo
|
||||||
|
merchantDeployInfo.PayType = payType
|
||||||
|
merchantDeployInfo.SingleRoadName = singleRoad
|
||||||
|
merchantDeployInfo.SingleRoadPlatformRate = a
|
||||||
|
merchantDeployInfo.SingleRoadAgentRate = b
|
||||||
|
merchantDeployInfo.RollRoadPlatformRate = cs
|
||||||
|
merchantDeployInfo.RollRoadAgentRate = d
|
||||||
|
merchantDeployInfo.IsLoan = isLoan
|
||||||
|
merchantDeployInfo.LoanRate = e
|
||||||
|
merchantDeployInfo.LoanDays = i
|
||||||
|
merchantDeployInfo.UnfreezeHour = j
|
||||||
|
merchantDeployInfo.RollRoadName = rollPoolRoad
|
||||||
|
roadInfo := road.GetRoadInfoByName(singleRoad)
|
||||||
|
rollPoolInfo := road.GetRoadPoolByName(rollPoolRoad)
|
||||||
|
merchantDeployInfo.SingleRoadUid = roadInfo.RoadUid
|
||||||
|
merchantDeployInfo.RollRoadCode = rollPoolInfo.RoadPoolCode
|
||||||
|
|
||||||
|
//如果该用户的改支付类型已经存在,那么进行更新,否则进行添加
|
||||||
|
if merchant.IsExistByUidAndPayType(merchantNo, payType) {
|
||||||
|
if singleRoad == "" && rollPoolRoad == "" {
|
||||||
|
//表示需要删除该支付类型的通道
|
||||||
|
if merchant.DeleteMerchantDeployByUidAndPayType(merchantNo, payType) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "删除该支付类型通道成功"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "删除该支付类型通道失败"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmpInfo := merchant.GetMerchantDeployByUidAndPayType(merchantNo, payType)
|
||||||
|
merchantDeployInfo.Id = tmpInfo.Id
|
||||||
|
merchantDeployInfo.Status = tmpInfo.Status
|
||||||
|
merchantDeployInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
merchantDeployInfo.CreateTime = tmpInfo.CreateTime
|
||||||
|
if merchant.UpdateMerchantDeploy(merchantDeployInfo) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "更新成功"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "更新失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if singleRoad == "" && rollPoolRoad == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "参数不能为空"
|
||||||
|
} else {
|
||||||
|
merchantDeployInfo.CreateTime = utils.GetBasicDateTime()
|
||||||
|
merchantDeployInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
merchantDeployInfo.Status = common.ACTIVE
|
||||||
|
if merchant.InsertMerchantDeployInfo(merchantDeployInfo) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "添加支付类型成功"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "添加支付类型失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddPayFor(merchantUid, bankUid, payForAmount, bankNo, accountName,
|
||||||
|
phone, merchantName, bankName, bankAddress string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
|
||||||
|
if merchantUid == "" {
|
||||||
|
keyDataJSON.Msg = "请选择需要下发的商户"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if bankUid == "" {
|
||||||
|
keyDataJSON.Msg = "请选择发下银行卡"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
money, err := strconv.ParseFloat(payForAmount, 64)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("add pay for fail: ", err)
|
||||||
|
keyDataJSON.Msg = "下发金额输入不正确"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
accountInfo := accounts.GetAccountByUid(merchantUid)
|
||||||
|
if accountInfo.SettleAmount < money+common.PAYFOR_FEE {
|
||||||
|
keyDataJSON.Msg = "用户可用金额不够"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
bankInfo := system.GetBankCardByUid(bankUid)
|
||||||
|
|
||||||
|
if bankInfo.BankNo != bankNo || bankInfo.AccountName != accountName || bankInfo.PhoneNo != phone {
|
||||||
|
keyDataJSON.Msg = "银行卡信息有误,请连接管理员"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
payFor := payfor.PayforInfo{
|
||||||
|
PayforUid: "pppp" + xid.New().String(),
|
||||||
|
MerchantUid: merchantUid,
|
||||||
|
MerchantName: merchantName, PhoneNo: phone,
|
||||||
|
MerchantOrderId: xid.New().String(),
|
||||||
|
BankOrderId: "4444" + xid.New().String(),
|
||||||
|
PayforFee: common.PAYFOR_FEE, Type: common.SELF_MERCHANT,
|
||||||
|
PayforAmount: money,
|
||||||
|
PayforTotalAmount: money + common.PAYFOR_FEE,
|
||||||
|
BankCode: bankInfo.BankCode,
|
||||||
|
BankName: bankName, IsSend: common.NO,
|
||||||
|
BankAccountName: bankInfo.AccountName,
|
||||||
|
BankAccountNo: bankInfo.BankNo,
|
||||||
|
BankAccountType: bankInfo.BankAccountType,
|
||||||
|
BankAccountAddress: bankAddress,
|
||||||
|
Status: common.PAYFOR_COMFRIM,
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if payfor.InsertPayfor(payFor) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "代付下发提交失败"
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *AddService) AddSelfPayFor(bankUid, payForAmount, accountName,
|
||||||
|
bankNo, phone, bankName, bankAddress string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
|
||||||
|
if bankUid == "" {
|
||||||
|
keyDataJSON.Msg = "银行卡uid不能为空,请联系技术人员"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
money, err := strconv.ParseFloat(payForAmount, 64)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("self payfor money fail: ", err)
|
||||||
|
keyDataJSON.Msg = "输入金额有误,请仔细检查"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
bankInfo := system.GetBankCardByUid(bankUid)
|
||||||
|
|
||||||
|
//需要对前端传入的数据做校验,不能完全相信前端的数据
|
||||||
|
if bankInfo.AccountName != accountName || bankInfo.BankNo != bankNo || bankInfo.PhoneNo != phone {
|
||||||
|
keyDataJSON.Msg = "前端页面数据有篡改,请注意资金安全"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
selfPayFor := payfor.PayforInfo{
|
||||||
|
PayforUid: "pppp" + xid.New().String(),
|
||||||
|
BankOrderId: "4444" + xid.New().String(),
|
||||||
|
PayforFee: common.ZERO,
|
||||||
|
Type: common.SELF_HELP,
|
||||||
|
PayforAmount: money,
|
||||||
|
PayforTotalAmount: money + common.ZERO,
|
||||||
|
BankCode: bankInfo.BankCode,
|
||||||
|
BankName: bankName,
|
||||||
|
IsSend: common.NO,
|
||||||
|
BankAccountName: bankInfo.AccountName,
|
||||||
|
BankAccountNo: bankInfo.BankNo,
|
||||||
|
BankAccountType: bankInfo.BankAccountType,
|
||||||
|
BankAccountAddress: bankAddress,
|
||||||
|
Status: common.PAYFOR_COMFRIM,
|
||||||
|
CreateTime: utils.GetBasicDateTime(),
|
||||||
|
UpdateTime: utils.GetBasicDateTime(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if payfor.InsertPayfor(selfPayFor) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Msg = "数据处理失败,请重新提交"
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
293
boss/service/deleteService.go
Normal file
293
boss/service/deleteService.go
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"boss/datas"
|
||||||
|
"boss/models/accounts"
|
||||||
|
"boss/models/agent"
|
||||||
|
"boss/models/merchant"
|
||||||
|
"boss/models/road"
|
||||||
|
"boss/models/system"
|
||||||
|
"boss/models/user"
|
||||||
|
"boss/utils"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) 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 := system.GetRole()
|
||||||
|
//如果有删除任何的东西,需要重新赋值权限
|
||||||
|
for _, r := range allRoleInfo {
|
||||||
|
for _, showFirstUid := range strings.Split(r.ShowFirstUid, "||") {
|
||||||
|
if system.FirstMenuUidIsExists(showFirstUid) {
|
||||||
|
remainderFirstMenuUid = append(remainderFirstMenuUid, showFirstUid)
|
||||||
|
menuInfo := system.GetMenuInfoByMenuUid(showFirstUid)
|
||||||
|
remainderFirstMenu = append(remainderFirstMenu, menuInfo.FirstMenu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, showSecondUid := range strings.Split(r.ShowSecondUid, "||") {
|
||||||
|
if system.SecondMenuUidIsExists(showSecondUid) {
|
||||||
|
remainderSecondMenuUid = append(remainderSecondMenuUid, showSecondUid)
|
||||||
|
secondMenuInfo := system.GetSecondMenuInfoBySecondMenuUid(showSecondUid)
|
||||||
|
remainderSecondMenu = append(remainderSecondMenu, secondMenuInfo.SecondMenu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, showPowerId := range strings.Split(r.ShowPowerUid, "||") {
|
||||||
|
if system.PowerUidExists(showPowerId) {
|
||||||
|
remainderPowerId = append(remainderPowerId, showPowerId)
|
||||||
|
powerInfo := system.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()
|
||||||
|
system.UpdateRoleInfo(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteMenu(menuUid, userID string) *datas.BaseDataJSON {
|
||||||
|
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
menuInfo := system.GetMenuInfoByMenuUid(menuUid)
|
||||||
|
if menuInfo.MenuUid == "" {
|
||||||
|
dataJSON.Msg = "不存在该菜单"
|
||||||
|
dataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
logs.Info(userID + ",执行了删除一级菜单操作")
|
||||||
|
system.DeleteMenuInfo(menuUid)
|
||||||
|
//删除该一级目下下的所有二级目录
|
||||||
|
system.DeleteSecondMenuByFirstMenuUid(menuUid)
|
||||||
|
SortFirstMenuOrder()
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
func (c *DeleteService) DeleteSecondMenu(secondMenuUid string) *datas.BaseDataJSON {
|
||||||
|
|
||||||
|
secondMenuInfo := system.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
if secondMenuUid == "" || secondMenuInfo.SecondMenuUid == "" {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "该二级菜单不存在"
|
||||||
|
} else {
|
||||||
|
if system.DeleteSecondMenuBySecondMenuUid(secondMenuUid) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
ml := system.GetSecondMenuLenByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||||
|
//删除该二级页面下的所有权限项
|
||||||
|
system.DeletePowerBySecondUid(secondMenuUid)
|
||||||
|
if ml == 0 {
|
||||||
|
//如果该二级类目已经被全部删除,那么对应的一级类目也应当删除
|
||||||
|
system.DeleteMenuInfo(secondMenuInfo.FirstMenuUid)
|
||||||
|
SortFirstMenuOrder()
|
||||||
|
} else {
|
||||||
|
secondMenuInfoList := system.GetSecondMenuListByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||||
|
sort.Sort(system.SecondMenuSlice(secondMenuInfoList))
|
||||||
|
for i := 0; i < len(secondMenuInfoList); i++ {
|
||||||
|
m := secondMenuInfoList[i]
|
||||||
|
system.UpdateSecondMenuOrderBySecondUid(m.SecondMenuUid, i+1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "删除失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeletePowerItem(powerID string) *datas.BaseDataJSON {
|
||||||
|
system.DeletePowerItemByPowerID(powerID)
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
dataJSON.Code = 200
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteRole(roleUid string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
|
||||||
|
if system.DeleteRoleByRoleUid(roleUid) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteOperator(userId string) *datas.BaseDataJSON {
|
||||||
|
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
|
||||||
|
if user.DeleteUserByUserId(userId) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteBankCardRecord(uid string) *datas.BankCardDataJSON {
|
||||||
|
|
||||||
|
dataJSON := new(datas.BankCardDataJSON)
|
||||||
|
dataJSON.Code = -1
|
||||||
|
|
||||||
|
if system.DeleteBankCardByUid(uid) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteRoad(roadUid string) *datas.BaseDataJSON {
|
||||||
|
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
dataJSON.Code = -1
|
||||||
|
|
||||||
|
if road.DeleteRoadByRoadUid(roadUid) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
params := make(map[string]string)
|
||||||
|
roadPoolInfoList := road.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()
|
||||||
|
road.UpdateRoadPool(roadPoolInfo)
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteRoadPool(roadPoolCode string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
dataJSON.Code = -1
|
||||||
|
|
||||||
|
if road.DeleteRoadPoolByCode(roadPoolCode) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
dataJSON.Msg = "删除通道池失败"
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteMerchant(merchantUid string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
if merchantUid == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if merchant.DeleteMerchantByUid(merchantUid) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteAccount(accountUid string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
merchant.IsExistByMerchantUid(accountUid)
|
||||||
|
if merchant.IsExistByMerchantUid(accountUid) || agent.IsExistByAgentUid(accountUid) {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "用户还存在,不能删除"
|
||||||
|
} else {
|
||||||
|
if accounts.DeleteAccountByUid(accountUid) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
dataJSON.Msg = "删除账户成功"
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "删除账户失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *DeleteService) DeleteAgent(agentUid string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
//判断是否有商户还绑定了该代理
|
||||||
|
if merchant.IsExistMerchantByAgentUid(agentUid) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "已有商户绑定改代理,不能删除"
|
||||||
|
} else {
|
||||||
|
if agent.DeleteAgentByAgentUid(agentUid) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "删除失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
func (c *DeleteService) DeleteAgentRelation(merchantUid string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
merchantInfo := merchant.GetMerchantByUid(merchantUid)
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
|
||||||
|
if merchantInfo.MerchantUid == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "不存在这样的商户"
|
||||||
|
} else {
|
||||||
|
merchantInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
merchantInfo.BelongAgentUid = ""
|
||||||
|
merchantInfo.BelongAgentName = ""
|
||||||
|
|
||||||
|
if !merchant.UpdateMerchant(merchantInfo) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "更新商户失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 对一级菜单重新进行排序
|
||||||
|
*/
|
||||||
|
func SortFirstMenuOrder() {
|
||||||
|
menuInfoList := system.GetMenuAll()
|
||||||
|
sort.Sort(system.MenuInfoSlice(menuInfoList))
|
||||||
|
|
||||||
|
for i := 0; i < len(menuInfoList); i++ {
|
||||||
|
m := menuInfoList[i]
|
||||||
|
m.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
m.MenuOrder = i + 1
|
||||||
|
system.UpdateMenuInfo(m)
|
||||||
|
//对应的二级菜单也应该重新分配顺序号
|
||||||
|
SortSecondMenuOrder(m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 对二级菜单分配顺序号
|
||||||
|
*/
|
||||||
|
func SortSecondMenuOrder(firstMenuInfo system.MenuInfo) {
|
||||||
|
secondMenuInfoList := system.GetSecondMenuListByFirstMenuUid(firstMenuInfo.MenuUid)
|
||||||
|
for _, sm := range secondMenuInfoList {
|
||||||
|
sm.FirstMenuOrder = firstMenuInfo.MenuOrder
|
||||||
|
sm.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
system.UpdateSecondMenu(sm)
|
||||||
|
//删除下下一级的所有权限项
|
||||||
|
system.DeletePowerBySecondUid(sm.SecondMenuUid)
|
||||||
|
}
|
||||||
|
}
|
98
boss/service/queryService.go
Normal file
98
boss/service/queryService.go
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"boss/datas"
|
||||||
|
"boss/models/order"
|
||||||
|
"boss/models/payfor"
|
||||||
|
"fmt"
|
||||||
|
"github.com/beego/beego/v2/client/httplib"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
"github.com/beego/beego/v2/server/web"
|
||||||
|
)
|
||||||
|
|
||||||
|
type QueryService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func OrderQuery(bankOrderId string) string {
|
||||||
|
|
||||||
|
orderInfo := order.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 "该订单已经处理完毕"
|
||||||
|
}
|
||||||
|
|
||||||
|
// 向gateway发送请求,请求上游的支付结果
|
||||||
|
gUrl, _ := web.AppConfig.String("gateway::host")
|
||||||
|
gUrl = gUrl + "supplier/order/query" + "?" + "bankOrderId=" + bankOrderId
|
||||||
|
res, err := httplib.Get(gUrl).String()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("获取gateway上游订单查询结果失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if res == "success" {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
return "fail"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *QueryService) SupplierOrderQuery(bankOrderId string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
exist := order.BankOrderIdIsEixst(bankOrderId)
|
||||||
|
if !exist {
|
||||||
|
keyDataJSON.Msg = "该订单不存在"
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
msg := OrderQuery(bankOrderId)
|
||||||
|
|
||||||
|
keyDataJSON.Msg = msg
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *QueryService) SupplierPayForQuery(bankOrderId string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
|
||||||
|
if bankOrderId == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "不存在这样的代付订单"
|
||||||
|
} else {
|
||||||
|
payFor := payfor.GetPayForByBankOrderId(bankOrderId)
|
||||||
|
if payFor.RoadUid == "" {
|
||||||
|
keyDataJSON.Msg = "该代付订单没有对应的通道uid"
|
||||||
|
} else {
|
||||||
|
result := querySupplierPayForResult(bankOrderId)
|
||||||
|
if result {
|
||||||
|
keyDataJSON.Msg = "处理成功!"
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Msg = "处理失败!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func querySupplierPayForResult(bankOrderId string) bool {
|
||||||
|
payforUrl, _ := web.AppConfig.String("gateway::host")
|
||||||
|
u := payforUrl + "gateway/supplier/payfor/query" + "?bankOrderId=" + bankOrderId
|
||||||
|
s, err := httplib.Get(u).String()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("处理代付查询请求gateway失败:", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if s == "fail" {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
61
boss/service/sendNotifyMerchantService.go
Normal file
61
boss/service/sendNotifyMerchantService.go
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"boss/common"
|
||||||
|
"boss/datas"
|
||||||
|
"boss/models/notify"
|
||||||
|
"boss/models/order"
|
||||||
|
"fmt"
|
||||||
|
"github.com/beego/beego/v2/client/httplib"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendNotifyMerchantService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SendNotifyMerchantService) SendNotifyToMerchant(bankOrderId string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
orderInfo := order.GetOrderByBankOrderId(bankOrderId)
|
||||||
|
if orderInfo.Status == common.WAIT {
|
||||||
|
keyDataJSON.Msg = "该订单不是成功状态,不能回调"
|
||||||
|
} else {
|
||||||
|
notifyInfo := notify.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("该订单回调发送成功")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SendNotifyMerchantService) SelfSendNotify(bankOrderId string) *datas.KeyDataJSON {
|
||||||
|
notifyInfo := notify.GetNotifyInfoByBankOrderId(bankOrderId)
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.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)
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
436
boss/service/updateService.go
Normal file
436
boss/service/updateService.go
Normal file
@ -0,0 +1,436 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"boss/common"
|
||||||
|
"boss/datas"
|
||||||
|
"boss/models"
|
||||||
|
"boss/models/accounts"
|
||||||
|
"boss/models/agent"
|
||||||
|
"boss/models/merchant"
|
||||||
|
"boss/models/payfor"
|
||||||
|
"boss/models/road"
|
||||||
|
"boss/models/system"
|
||||||
|
"boss/models/user"
|
||||||
|
"boss/utils"
|
||||||
|
"fmt"
|
||||||
|
"github.com/beego/beego/v2/client/httplib"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
|
"github.com/beego/beego/v2/server/web"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UpdateService struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) UpMenu(menuUid string) *datas.BaseDataJSON {
|
||||||
|
menuInfo := system.GetMenuInfoByMenuUid(menuUid)
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
if menuInfo.MenuUid == "" {
|
||||||
|
dataJSON.Msg = "更改排列顺序失败"
|
||||||
|
dataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
exist := system.MenuOrderIsExists(menuInfo.MenuOrder - 1)
|
||||||
|
if !exist {
|
||||||
|
dataJSON.Msg = "已经是最高的顺序"
|
||||||
|
dataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
//如果他前面有菜单,那么交换他们的menuOrder
|
||||||
|
preMenuInfo := system.GetMenuInfoByMenuOrder(menuInfo.MenuOrder - 1)
|
||||||
|
menuInfo.MenuOrder = menuInfo.MenuOrder - 1
|
||||||
|
preMenuInfo.MenuOrder = preMenuInfo.MenuOrder + 1
|
||||||
|
preMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
menuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
//更新菜单表
|
||||||
|
system.UpdateMenuInfo(preMenuInfo)
|
||||||
|
system.UpdateMenuInfo(menuInfo)
|
||||||
|
//更新二级菜单表
|
||||||
|
SortSecondMenuOrder(preMenuInfo)
|
||||||
|
SortSecondMenuOrder(menuInfo)
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) DownMenu(menuUid string) *datas.BaseDataJSON {
|
||||||
|
menuInfo := system.GetMenuInfoByMenuUid(menuUid)
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
if menuInfo.MenuUid == "" {
|
||||||
|
dataJSON.Msg = "更改排列顺序失败"
|
||||||
|
dataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
exist := system.MenuOrderIsExists(menuInfo.MenuOrder + 1)
|
||||||
|
if !exist {
|
||||||
|
dataJSON.Msg = "已经是最高的顺序"
|
||||||
|
dataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
//如果他前面有菜单,那么交换他们的menuOrder
|
||||||
|
lastMenuInfo := system.GetMenuInfoByMenuOrder(menuInfo.MenuOrder + 1)
|
||||||
|
menuInfo.MenuOrder = menuInfo.MenuOrder + 1
|
||||||
|
lastMenuInfo.MenuOrder = lastMenuInfo.MenuOrder - 1
|
||||||
|
lastMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
menuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
//更新菜单表
|
||||||
|
system.UpdateMenuInfo(lastMenuInfo)
|
||||||
|
system.UpdateMenuInfo(menuInfo)
|
||||||
|
//更新二级菜单表
|
||||||
|
SortSecondMenuOrder(lastMenuInfo)
|
||||||
|
SortSecondMenuOrder(menuInfo)
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) UpSecondMenu(secondMenuUid string) *datas.BaseDataJSON {
|
||||||
|
secondMenuInfo := system.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
if secondMenuInfo.MenuOrder == 1 {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
preSecondMenuInfo := system.GetSecondMenuInfoByMenuOrder(secondMenuInfo.MenuOrder-1, secondMenuInfo.FirstMenuUid)
|
||||||
|
preSecondMenuInfo.MenuOrder = preSecondMenuInfo.MenuOrder + 1
|
||||||
|
preSecondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
secondMenuInfo.MenuOrder = secondMenuInfo.MenuOrder - 1
|
||||||
|
secondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
//更新二级菜单项
|
||||||
|
system.UpdateSecondMenu(preSecondMenuInfo)
|
||||||
|
system.UpdateSecondMenu(secondMenuInfo)
|
||||||
|
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) DownSecondMenu(secondMenuUid string) *datas.BaseDataJSON {
|
||||||
|
secondMenuInfo := system.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||||
|
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
|
||||||
|
l := system.GetSecondMenuLenByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||||
|
if l == secondMenuInfo.MenuOrder {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
lastSecondMenu := system.GetSecondMenuInfoByMenuOrder(secondMenuInfo.MenuOrder+1, secondMenuInfo.FirstMenuUid)
|
||||||
|
lastSecondMenu.MenuOrder = lastSecondMenu.MenuOrder - 1
|
||||||
|
lastSecondMenu.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
|
||||||
|
secondMenuInfo.MenuOrder = secondMenuInfo.MenuOrder + 1
|
||||||
|
secondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
|
||||||
|
system.UpdateSecondMenu(lastSecondMenu)
|
||||||
|
system.UpdateSecondMenu(secondMenuInfo)
|
||||||
|
|
||||||
|
dataJSON.Code = 200
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) FreezeOperator(userId string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
|
||||||
|
if user.UpdateStauts(common.UNACTIVE, userId) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
dataJSON.Msg = "冻结成功"
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "冻结失败"
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) UnfreezeOperator(userId string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
|
||||||
|
if user.UpdateStauts("active", userId) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
dataJSON.Msg = "解冻成功"
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "解冻失败"
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) EditOperator(password, changePassword, role, userId, nick, remark string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
|
||||||
|
if (len(password) > 0 || len(changePassword) > 0) && password != changePassword {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = ".veritfy-operator-password-error"
|
||||||
|
keyDataJSON.Msg = "*2次密码输入不一致"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if role == "" || role == "none" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = ".change-operator-role-error"
|
||||||
|
keyDataJSON.Msg = "*角色不能为空"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
userInfo := user.GetUserInfoByUserID(userId)
|
||||||
|
if userInfo.UserId == "" {
|
||||||
|
keyDataJSON.Code = -2
|
||||||
|
keyDataJSON.Msg = "该用户不存在"
|
||||||
|
} else {
|
||||||
|
userInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
userInfo.Remark = remark
|
||||||
|
roleInfo := system.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
|
||||||
|
user.UpdateUserInfo(userInfo)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) UpdateRoadStatus(roadUid string) *datas.BaseDataJSON {
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
dataJSON.Code = 200
|
||||||
|
|
||||||
|
roadInfo := road.GetRoadInfoByRoadUid(roadUid)
|
||||||
|
if roadInfo.Status == "active" {
|
||||||
|
roadInfo.Status = common.UNACTIVE
|
||||||
|
} else {
|
||||||
|
roadInfo.Status = "active"
|
||||||
|
}
|
||||||
|
if road.UpdateRoadInfo(roadInfo) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) UpdateMerchantStatus(merchantUid string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
if merchantUid == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
merchantInfo := merchant.GetMerchantByUid(merchantUid)
|
||||||
|
|
||||||
|
if merchantInfo.MerchantUid == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if merchantInfo.Status == common.ACTIVE {
|
||||||
|
merchantInfo.Status = common.UNACTIVE
|
||||||
|
} else {
|
||||||
|
merchantInfo.Status = common.ACTIVE
|
||||||
|
}
|
||||||
|
merchantInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
|
||||||
|
if merchant.UpdateMerchant(merchantInfo) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) UpdateAccountStatus(accountUid string) *datas.BaseDataJSON {
|
||||||
|
accountInfo := accounts.GetAccountByUid(accountUid)
|
||||||
|
if accountInfo.Status == common.ACTIVE {
|
||||||
|
accountInfo.Status = common.UNACTIVE
|
||||||
|
} else {
|
||||||
|
accountInfo.Status = common.ACTIVE
|
||||||
|
}
|
||||||
|
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
|
||||||
|
dataJSON := new(datas.BaseDataJSON)
|
||||||
|
if accounts.UpdateAccount(accountInfo) {
|
||||||
|
dataJSON.Code = 200
|
||||||
|
dataJSON.Msg = "更新账户状态成功"
|
||||||
|
} else {
|
||||||
|
dataJSON.Code = -1
|
||||||
|
dataJSON.Msg = "更新账户状态失败"
|
||||||
|
}
|
||||||
|
return dataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) OperatorAccount(accountOperator, amount, accountUid string) *datas.AccountDataJSON {
|
||||||
|
accountDataJSON := new(datas.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 {
|
||||||
|
return accountDataJSON
|
||||||
|
}
|
||||||
|
msg, flag := models.OperatorAccount(accountUid, accountOperator, a)
|
||||||
|
if flag {
|
||||||
|
accountDataJSON.Code = 200
|
||||||
|
accountDataJSON.Msg = "处理成功,请检查对应账户信息"
|
||||||
|
accountDataJSON.AccountList = append(accountDataJSON.AccountList, accounts.GetAccountByUid(accountUid))
|
||||||
|
} else {
|
||||||
|
accountDataJSON.Code = -1
|
||||||
|
accountDataJSON.Msg = msg
|
||||||
|
}
|
||||||
|
return accountDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) UpdateAgentStatus(agentUid string) *datas.KeyDataJSON {
|
||||||
|
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
agentInfo := agent.GetAgentInfoByAgentUid(agentUid)
|
||||||
|
if agentInfo.AgentUid == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if agentInfo.Status == common.ACTIVE {
|
||||||
|
agentInfo.Status = common.UNACTIVE
|
||||||
|
} else {
|
||||||
|
agentInfo.Status = "active"
|
||||||
|
}
|
||||||
|
agentInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
if agent.UpdateAgentInfo(agentInfo) {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) ResetAgentPassword(agentUid, newPassword, newVertifyPassword string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
if agentUid == "" {
|
||||||
|
keyDataJSON.Code = -2
|
||||||
|
} else if newPassword == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#agent-login-password-error-reset"
|
||||||
|
keyDataJSON.Msg = " *新密码不能为空"
|
||||||
|
} else if newVertifyPassword != newPassword {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Key = "#agent-vertify-password-error-reset"
|
||||||
|
keyDataJSON.Msg = " *两次密码输入不一致"
|
||||||
|
}
|
||||||
|
|
||||||
|
if keyDataJSON.Code != 200 {
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
agentInfo := agent.GetAgentInfoByAgentUid(agentUid)
|
||||||
|
agentInfo.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
agentInfo.AgentPassword = utils.GetMD5Upper(newPassword)
|
||||||
|
if !agent.UpdateAgentInfo(agentInfo) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) ChoosePayForRoad(confirmType, roadName, bankOrderId, remark string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
|
||||||
|
if confirmType == common.PAYFOR_ROAD && roadName == "" {
|
||||||
|
keyDataJSON.Msg = "打款通道不能为空"
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
payForInfo := payfor.GetPayForByBankOrderId(bankOrderId)
|
||||||
|
roadInfo := road.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 !payfor.ForUpdatePayFor(payForInfo) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "更新代付记录失败"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) UpdateOrderStatus(bankOrderId, solveType string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
updateOrderUrl, _ := web.AppConfig.String("gateway::host")
|
||||||
|
res, err := httplib.Get(updateOrderUrl + "gateway/update/order" + "?bankOrderId=" + bankOrderId + "&solveType=" + solveType).String()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("update order status err = ", err)
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = res
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UpdateService) ResultPayFor(resultType, bankOrderId string) *datas.KeyDataJSON {
|
||||||
|
keyDataJSON := new(datas.KeyDataJSON)
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
|
||||||
|
if resultType == "" || bankOrderId == "" {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "提交的数据有误"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
payFor := payfor.GetPayForByBankOrderId(bankOrderId)
|
||||||
|
|
||||||
|
if payFor.Type == common.SELF_HELP {
|
||||||
|
//如果是管理员在后台提现,不用做任何的商户减款,只需要更新代付订单状态
|
||||||
|
payFor.UpdateTime = utils.GetBasicDateTime()
|
||||||
|
payFor.Status = resultType
|
||||||
|
|
||||||
|
if !payfor.ForUpdatePayFor(payFor) {
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "系统处理失败"
|
||||||
|
}
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
if payFor.Status == common.PAYFOR_FAIL || payFor.Status == common.PAYFOR_SUCCESS {
|
||||||
|
logs.Error(fmt.Sprintf("该代付订单=%s,状态有误....", bankOrderId))
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
keyDataJSON.Msg = "订单状态有误,请刷新重新判断"
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
u, _ := web.AppConfig.String("host")
|
||||||
|
u = u + "/solve/payfor/result?" + "resultType=" + resultType + "&bankOrderId=" + bankOrderId
|
||||||
|
s, err := httplib.Get(u).String()
|
||||||
|
if err != nil || s == common.FAIL {
|
||||||
|
logs.Error("手动处理代付结果请求gateway系统失败:", err)
|
||||||
|
keyDataJSON.Msg = "处理失败"
|
||||||
|
keyDataJSON.Code = -1
|
||||||
|
} else {
|
||||||
|
keyDataJSON.Code = 200
|
||||||
|
keyDataJSON.Msg = "处理成功"
|
||||||
|
}
|
||||||
|
|
||||||
|
return keyDataJSON
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user