dongfeng-pay/boss/controllers/getController.go

1018 lines
30 KiB
Go
Raw Normal View History

2021-04-27 15:33:49 +08:00
/***************************************************
** @Desc : c file for ...
** @Time : 2019/8/21 11:18
** @Author : yuebin
** @File : get
** @Last Modified by : yuebin
** @Last Modified time: 2019/8/21 11:18
** @Software: GoLand
****************************************************/
package controllers
import (
"boss/common"
2021-11-11 10:30:43 +08:00
"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"
2021-04-27 15:33:49 +08:00
"fmt"
"sort"
"strconv"
"strings"
)
type GetController struct {
BaseController
DisplayCount int
CurrentPage int
TotalPage int
JumpPage int
Offset int
}
/*
* 处理分页的函数
*/
func (c *GetController) GetCutPage(l int) {
c.DisplayCount, _ = c.GetInt("displayCount")
c.CurrentPage, _ = c.GetInt("currentPage")
c.TotalPage, _ = c.GetInt("totalPage")
c.JumpPage, _ = c.GetInt("jumpPage")
if c.CurrentPage == 0 {
c.CurrentPage = 1
}
if c.DisplayCount == 0 {
c.DisplayCount = 20
}
if c.JumpPage > 0 {
c.CurrentPage = c.JumpPage
}
if l > 0 {
c.TotalPage = l / c.DisplayCount
if l%c.DisplayCount > 0 {
c.TotalPage += 1
}
} else {
c.TotalPage = 0
c.CurrentPage = 0
}
//假如当前页超过了总页数
if c.CurrentPage > c.TotalPage {
c.CurrentPage = c.TotalPage
}
//计算出偏移量
c.Offset = (c.CurrentPage - 1) * c.DisplayCount
}
func (c *GetController) GetMenu() {
firstMenuSearch := strings.TrimSpace(c.GetString("firstMenuSearch"))
params := make(map[string]string)
params["first_menu__icontains"] = firstMenuSearch
2021-11-11 10:30:43 +08:00
c.GetCutPage(system.GetMenuLenByMap(params))
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
menuDataJSON := new(datas.MenuDataJSON)
2021-04-27 15:33:49 +08:00
menuDataJSON.DisplayCount = c.DisplayCount
menuDataJSON.CurrentPage = c.CurrentPage
menuDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
menuDataJSON.Code = -1
2021-11-11 10:30:43 +08:00
menuDataJSON.MenuList = make([]system.MenuInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(menuDataJSON)
return
}
2021-11-11 10:30:43 +08:00
menuInfoList := system.GetMenuOffsetByMap(params, c.DisplayCount, c.Offset)
sort.Sort(system.MenuInfoSlice(menuInfoList))
2021-04-27 15:33:49 +08:00
for i, m := range menuInfoList {
2021-11-11 10:30:43 +08:00
secondMenuInfoList := system.GetSecondMenuListByFirstMenuUid(m.MenuUid)
2021-04-27 15:33:49 +08:00
smenus := ""
for j := 0; j < len(secondMenuInfoList); j++ {
smenus += secondMenuInfoList[j].SecondMenu
if j != (len(secondMenuInfoList) - 1) {
smenus += "||"
}
}
m.SecondMenu = smenus
menuInfoList[i] = m
}
menuDataJSON.Code = 200
menuDataJSON.MenuList = menuInfoList
menuDataJSON.StartIndex = c.Offset
if len(menuInfoList) == 0 {
menuDataJSON.Msg = "获取菜单列表失败"
}
c.GenerateJSON(menuDataJSON)
}
func (c *GetController) GetFirstMenu() {
2021-11-11 10:30:43 +08:00
menuDataJSON := new(datas.MenuDataJSON)
menuList := system.GetMenuAll()
2021-04-27 15:33:49 +08:00
if len(menuList) == 0 {
menuDataJSON.Code = -1
} else {
menuDataJSON.Code = 200
}
2021-11-11 10:30:43 +08:00
sort.Sort(system.MenuInfoSlice(menuList))
2021-04-27 15:33:49 +08:00
menuDataJSON.MenuList = menuList
c.GenerateJSON(menuDataJSON)
}
/*
*获取所有的二级菜单
*/
func (c *GetController) GetSecondMenu() {
firstMenuSearch := strings.TrimSpace(c.GetString("firstMenuSerach"))
secondMenuSearch := strings.TrimSpace(c.GetString("secondMenuSerach"))
params := make(map[string]string)
params["first_menu__icontains"] = firstMenuSearch
params["second_menu__icontains"] = secondMenuSearch
2021-11-11 10:30:43 +08:00
l := system.GetSecondMenuLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
secondMenuDataJSON := new(datas.SecondMenuDataJSON)
2021-04-27 15:33:49 +08:00
secondMenuDataJSON.DisplayCount = c.DisplayCount
secondMenuDataJSON.Code = 200
secondMenuDataJSON.CurrentPage = c.CurrentPage
secondMenuDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
secondMenuDataJSON.SecondMenuList = make([]system.SecondMenuInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(secondMenuDataJSON)
return
}
2021-11-11 10:30:43 +08:00
secondMenuList := system.GetSecondMenuByMap(params, c.DisplayCount, c.Offset)
sort.Sort(system.SecondMenuSlice(secondMenuList))
2021-04-27 15:33:49 +08:00
secondMenuDataJSON.SecondMenuList = secondMenuList
secondMenuDataJSON.StartIndex = c.Offset
if len(secondMenuList) == 0 {
secondMenuDataJSON.Msg = "获取二级菜单失败"
}
c.GenerateJSON(secondMenuDataJSON)
}
func (c *GetController) GetSecondMenus() {
firstMenuUid := strings.TrimSpace(c.GetString("firMenuUid"))
2021-11-11 10:30:43 +08:00
secondMenuDataJSON := new(datas.SecondMenuDataJSON)
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
secondMenuList := system.GetSecondMenuListByFirstMenuUid(firstMenuUid)
2021-04-27 15:33:49 +08:00
secondMenuDataJSON.Code = 200
secondMenuDataJSON.SecondMenuList = secondMenuList
c.GenerateJSON(secondMenuDataJSON)
}
func (c *GetController) GetOneMenu() {
menuUid := c.GetString("menuUid")
2021-11-11 10:30:43 +08:00
dataJSON := new(datas.MenuDataJSON)
menuInfo := system.GetMenuInfoByMenuUid(menuUid)
2021-04-27 15:33:49 +08:00
if menuInfo.MenuUid == "" {
dataJSON.Code = -1
dataJSON.Msg = "该菜单项不存在"
} else {
2021-11-11 10:30:43 +08:00
dataJSON.MenuList = make([]system.MenuInfo, 0)
2021-04-27 15:33:49 +08:00
dataJSON.MenuList = append(dataJSON.MenuList, menuInfo)
dataJSON.Code = 200
}
c.Data["json"] = dataJSON
2021-11-11 10:30:43 +08:00
_ = c.ServeJSONP()
2021-04-27 15:33:49 +08:00
}
func (c *GetController) GetPowerItem() {
powerID := c.GetString("powerID")
powerItem := c.GetString("powerItem")
params := make(map[string]string)
params["power_uid__icontains"] = powerID
params["power_item_icontains"] = powerItem
2021-11-11 10:30:43 +08:00
l := system.GetPowerItemLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
powerItemDataJSON := new(datas.PowerItemDataJSON)
2021-04-27 15:33:49 +08:00
powerItemDataJSON.DisplayCount = c.DisplayCount
powerItemDataJSON.Code = 200
powerItemDataJSON.CurrentPage = c.CurrentPage
powerItemDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
powerItemDataJSON.PowerItemList = make([]system.PowerInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(powerItemDataJSON)
return
}
powerItemDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
powerItemList := system.GetPowerItemByMap(params, c.DisplayCount, c.Offset)
sort.Sort(system.PowerInfoSlice(powerItemList))
2021-04-27 15:33:49 +08:00
powerItemDataJSON.PowerItemList = powerItemList
c.GenerateJSON(powerItemDataJSON)
}
func (c *GetController) GetRole() {
roleName := strings.TrimSpace(c.GetString("roleName"))
params := make(map[string]string)
params["role_name__icontains"] = roleName
2021-11-11 10:30:43 +08:00
l := system.GetRoleLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
roleInfoDataJSON := new(datas.RoleInfoDataJSON)
2021-04-27 15:33:49 +08:00
roleInfoDataJSON.DisplayCount = c.DisplayCount
roleInfoDataJSON.Code = 200
roleInfoDataJSON.CurrentPage = c.CurrentPage
roleInfoDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
roleInfoDataJSON.RoleInfoList = make([]system.RoleInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(roleInfoDataJSON)
return
}
roleInfoDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
roleInfoDataJSON.RoleInfoList = system.GetRoleByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(roleInfoDataJSON)
}
func (c *GetController) GetAllRole() {
2021-11-11 10:30:43 +08:00
roleInfoDataJSON := new(datas.RoleInfoDataJSON)
roleInfoList := system.GetRole()
2021-04-27 15:33:49 +08:00
fmt.Println(roleInfoList)
if len(roleInfoList) == 0 {
roleInfoDataJSON.Code = -1
} else {
roleInfoDataJSON.Code = 200
roleInfoDataJSON.RoleInfoList = roleInfoList
}
c.GenerateJSON(roleInfoDataJSON)
}
func (c *GetController) GetDeployTree() {
roleUid := strings.TrimSpace(c.GetString("roleUid"))
2021-11-11 10:30:43 +08:00
roleInfo := system.GetRoleByRoleUid(roleUid)
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
allFirstMenu := system.GetMenuAll()
sort.Sort(system.MenuInfoSlice(allFirstMenu))
allSecondMenu := system.GetSecondMenuList()
sort.Sort(system.SecondMenuSlice(allSecondMenu))
allPower := system.GetPower()
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
deployTreeJSON := new(datas.DeployTreeJSON)
2021-04-27 15:33:49 +08:00
deployTreeJSON.Code = 200
deployTreeJSON.AllFirstMenu = allFirstMenu
deployTreeJSON.AllSecondMenu = allSecondMenu
deployTreeJSON.AllPower = allPower
deployTreeJSON.ShowFirstMenuUid = make(map[string]bool)
for _, v := range strings.Split(roleInfo.ShowFirstUid, "||") {
deployTreeJSON.ShowFirstMenuUid[v] = true
}
deployTreeJSON.ShowSecondMenuUid = make(map[string]bool)
for _, v := range strings.Split(roleInfo.ShowSecondUid, "||") {
deployTreeJSON.ShowSecondMenuUid[v] = true
}
deployTreeJSON.ShowPowerUid = make(map[string]bool)
for _, v := range strings.Split(roleInfo.ShowPowerUid, "||") {
deployTreeJSON.ShowPowerUid[v] = true
}
c.GenerateJSON(deployTreeJSON)
}
/*
* 获取操作员列表
*/
func (c *GetController) GetOperator() {
operatorName := strings.TrimSpace(c.GetString("operatorName"))
params := make(map[string]string)
params["user_id__icontains"] = operatorName
2021-11-11 10:30:43 +08:00
l := user.GetOperatorLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
operatorDataJSON := new(datas.OperatorDataJSON)
2021-04-27 15:33:49 +08:00
operatorDataJSON.DisplayCount = c.DisplayCount
operatorDataJSON.Code = 200
operatorDataJSON.CurrentPage = c.CurrentPage
operatorDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
operatorDataJSON.OperatorList = make([]user.UserInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(operatorDataJSON)
return
}
operatorDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
operatorDataJSON.OperatorList = user.GetOperatorByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(operatorDataJSON)
}
func (c *GetController) GetOneOperator() {
userId := strings.TrimSpace(c.GetString("userId"))
2021-11-11 10:30:43 +08:00
userInfo := user.GetUserInfoByUserID(userId)
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
operatorDataJSON := new(datas.OperatorDataJSON)
operatorDataJSON.OperatorList = make([]user.UserInfo, 0)
2021-04-27 15:33:49 +08:00
operatorDataJSON.OperatorList = append(operatorDataJSON.OperatorList, userInfo)
operatorDataJSON.Code = 200
c.GenerateJSON(operatorDataJSON)
}
func (c *GetController) GetEditOperator() {
userId := strings.TrimSpace(c.GetString("userId"))
2021-11-11 10:30:43 +08:00
editOperatorDataJSON := new(datas.EditOperatorDataJSON)
userInfo := user.GetUserInfoByUserID(userId)
2021-04-27 15:33:49 +08:00
fmt.Println(userInfo)
editOperatorDataJSON.OperatorList = append(editOperatorDataJSON.OperatorList, userInfo)
2021-11-11 10:30:43 +08:00
editOperatorDataJSON.RoleList = system.GetRole()
2021-04-27 15:33:49 +08:00
editOperatorDataJSON.Code = 200
c.GenerateJSON(editOperatorDataJSON)
}
func (c *GetController) GetBankCard() {
accountNameSearch := strings.TrimSpace(c.GetString("accountNameSearch"))
params := make(map[string]string)
params["account_name__icontains"] = accountNameSearch
2021-11-11 10:30:43 +08:00
l := system.GetBankCardLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
bankCardDataJSON := new(datas.BankCardDataJSON)
2021-04-27 15:33:49 +08:00
bankCardDataJSON.DisplayCount = c.DisplayCount
bankCardDataJSON.Code = 200
bankCardDataJSON.CurrentPage = c.CurrentPage
bankCardDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
bankCardDataJSON.BankCardInfoList = make([]system.BankCardInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(bankCardDataJSON)
return
}
bankCardDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
bankCardDataJSON.BankCardInfoList = system.GetBankCardByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(bankCardDataJSON)
}
func (c *GetController) GetOneBankCard() {
uid := strings.TrimSpace(c.GetString("uid"))
2021-11-11 10:30:43 +08:00
bankCardInfo := system.GetBankCardByUid(uid)
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
bankCardDataJSON := new(datas.BankCardDataJSON)
2021-04-27 15:33:49 +08:00
bankCardDataJSON.Code = -1
if bankCardInfo.Uid != "" {
bankCardDataJSON.BankCardInfoList = append(bankCardDataJSON.BankCardInfoList, bankCardInfo)
bankCardDataJSON.Code = 200
}
c.GenerateJSON(bankCardDataJSON)
}
/*
* 获取通道
*/
func (c *GetController) GetRoad() {
roadName := strings.TrimSpace(c.GetString("roadName"))
productName := strings.TrimSpace(c.GetString("productName"))
roadUid := strings.TrimSpace(c.GetString("roadUid"))
payType := strings.TrimSpace(c.GetString("payType"))
roadPoolCode := strings.TrimSpace(c.GetString("roadPoolCode"))
params := make(map[string]string)
params["road_name__icontains"] = roadName
params["product_name__icontains"] = productName
params["road_uid"] = roadUid
params["pay_type"] = payType
2021-11-11 10:30:43 +08:00
l := road.GetRoadLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
roadDataJSON := new(datas.RoadDataJSON)
2021-04-27 15:33:49 +08:00
roadDataJSON.DisplayCount = c.DisplayCount
roadDataJSON.Code = 200
roadDataJSON.CurrentPage = c.CurrentPage
roadDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
roadDataJSON.RoadInfoList = make([]road.RoadInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(roadDataJSON)
return
}
roadDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
roadDataJSON.RoadInfoList = road.GetRoadInfoByMap(params, c.DisplayCount, c.Offset)
roadDataJSON.RoadPool = road.GetRoadPoolByRoadPoolCode(roadPoolCode)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(roadDataJSON)
}
func (c *GetController) GetAllRoad() {
roadName := strings.TrimSpace(c.GetString("roadName"))
params := make(map[string]string)
params["road_name__icontains"] = roadName
2021-11-11 10:30:43 +08:00
roadDataJSON := new(datas.RoadDataJSON)
roadInfoList := road.GetAllRoad(params)
2021-04-27 15:33:49 +08:00
roadDataJSON.Code = 200
roadDataJSON.RoadInfoList = roadInfoList
c.GenerateJSON(roadDataJSON)
}
/*
* 获取单个通道
*/
func (c *GetController) GetOneRoad() {
roadUid := strings.TrimSpace(c.GetString("roadUid"))
2021-11-11 10:30:43 +08:00
roadInfo := road.GetRoadInfoByRoadUid(roadUid)
roadDataJSON := new(datas.RoadDataJSON)
2021-04-27 15:33:49 +08:00
roadDataJSON.Code = -1
if roadInfo.RoadUid != "" {
roadDataJSON.RoadInfoList = append(roadDataJSON.RoadInfoList, roadInfo)
roadDataJSON.Code = 200
} else {
2021-11-11 10:30:43 +08:00
roadDataJSON.RoadInfoList = make([]road.RoadInfo, 0)
2021-04-27 15:33:49 +08:00
}
c.GenerateJSON(roadDataJSON)
}
func (c *GetController) GetRoadPool() {
roadPoolName := strings.TrimSpace(c.GetString("roadPoolName"))
roadPoolCode := strings.TrimSpace(c.GetString("roadPoolCode"))
params := make(map[string]string)
params["road_pool_name__icontains"] = roadPoolName
params["road_pool_code__icontains"] = roadPoolCode
2021-11-11 10:30:43 +08:00
l := road.GetRoadPoolLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
roadPoolDataJSON := new(datas.RoadPoolDataJSON)
2021-04-27 15:33:49 +08:00
roadPoolDataJSON.DisplayCount = c.DisplayCount
roadPoolDataJSON.Code = 200
roadPoolDataJSON.CurrentPage = c.CurrentPage
roadPoolDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
roadPoolDataJSON.RoadPoolInfoList = make([]road.RoadPoolInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(roadPoolDataJSON)
return
}
roadPoolDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
roadPoolDataJSON.RoadPoolInfoList = road.GetRoadPoolByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(roadPoolDataJSON)
}
func (c *GetController) GetAllRollPool() {
rollPoolName := strings.TrimSpace(c.GetString("rollPoolName"))
params := make(map[string]string)
params["road_pool_name__icontains"] = rollPoolName
2021-11-11 10:30:43 +08:00
roadPoolDataJSON := new(datas.RoadPoolDataJSON)
2021-04-27 15:33:49 +08:00
roadPoolDataJSON.Code = 200
2021-11-11 10:30:43 +08:00
roadPoolDataJSON.RoadPoolInfoList = road.GetAllRollPool(params)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(roadPoolDataJSON)
}
func (c *GetController) GetMerchant() {
merchantName := strings.TrimSpace(c.GetString("merchantName"))
merchantNo := strings.TrimSpace(c.GetString("merchantNo"))
params := make(map[string]string)
params["merchant_name__icontains"] = merchantName
params["merchant_uid__icontains"] = merchantNo
2021-11-11 10:30:43 +08:00
l := merchant.GetMerchantLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
merchantDataJSON := new(datas.MerchantDataJSON)
2021-04-27 15:33:49 +08:00
merchantDataJSON.DisplayCount = c.DisplayCount
merchantDataJSON.Code = 200
merchantDataJSON.CurrentPage = c.CurrentPage
merchantDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
merchantDataJSON.MerchantList = make([]merchant.MerchantInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(merchantDataJSON)
return
}
merchantDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
merchantDataJSON.MerchantList = merchant.GetMerchantListByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(merchantDataJSON)
}
func (c *GetController) GetAllMerchant() {
2021-11-11 10:30:43 +08:00
merchantDataJSON := new(datas.MerchantDataJSON)
2021-04-27 15:33:49 +08:00
merchantDataJSON.Code = 200
2021-11-11 10:30:43 +08:00
merchantDataJSON.MerchantList = merchant.GetAllMerchant()
2021-04-27 15:33:49 +08:00
c.GenerateJSON(merchantDataJSON)
}
func (c *GetController) GetOneMerchant() {
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
2021-11-11 10:30:43 +08:00
merchantDataJSON := new(datas.MerchantDataJSON)
2021-04-27 15:33:49 +08:00
if merchantUid == "" {
merchantDataJSON.Code = -1
c.GenerateJSON(merchantDataJSON)
return
}
2021-11-11 10:30:43 +08:00
merchantInfo := merchant.GetMerchantByUid(merchantUid)
2021-04-27 15:33:49 +08:00
merchantDataJSON.Code = 200
merchantDataJSON.MerchantList = append(merchantDataJSON.MerchantList, merchantInfo)
c.GenerateJSON(merchantDataJSON)
}
func (c *GetController) GetOneMerchantDeploy() {
merchantNo := strings.TrimSpace(c.GetString("merchantNo"))
payType := strings.TrimSpace(c.GetString("payType"))
2021-11-11 10:30:43 +08:00
merchantDeployDataJSON := new(datas.MerchantDeployDataJSON)
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
merchantDeployInfo := merchant.GetMerchantDeployByUidAndPayType(merchantNo, payType)
2021-04-27 15:33:49 +08:00
if merchantDeployInfo.Status == "active" {
merchantDeployDataJSON.Code = 200
merchantDeployDataJSON.MerchantDeploy = merchantDeployInfo
} else {
merchantDeployDataJSON.Code = -1
merchantDeployDataJSON.MerchantDeploy = merchantDeployInfo
}
c.GenerateJSON(merchantDeployDataJSON)
}
func (c *GetController) GetAllAccount() {
2021-11-11 10:30:43 +08:00
accountDataJSON := new(datas.AccountDataJSON)
2021-04-27 15:33:49 +08:00
accountDataJSON.Code = 200
2021-11-11 10:30:43 +08:00
accountDataJSON.AccountList = accounts.GetAllAccount()
2021-04-27 15:33:49 +08:00
c.GenerateJSON(accountDataJSON)
}
func (c *GetController) GetAccount() {
accountName := strings.TrimSpace(c.GetString("accountName"))
accountUid := strings.TrimSpace(c.GetString("accountNo"))
params := make(map[string]string)
params["account_name__icontains"] = accountName
params["account_uid_icontains"] = accountUid
2021-11-11 10:30:43 +08:00
l := accounts.GetAccountLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
accountDataJSON := new(datas.AccountDataJSON)
2021-04-27 15:33:49 +08:00
accountDataJSON.DisplayCount = c.DisplayCount
accountDataJSON.Code = 200
accountDataJSON.CurrentPage = c.CurrentPage
accountDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
accountDataJSON.AccountList = make([]accounts.AccountInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(accountDataJSON)
return
}
accountDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
accountDataJSON.AccountList = accounts.GetAccountByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(accountDataJSON)
}
func (c *GetController) GetOneAccount() {
//从http的body中获取accountUid字段并且这个字段是string类型
accountUid := strings.TrimSpace(c.GetString("accountUid"))
//new一个accountDataJSON结构体对象用来做jsonp返回
2021-11-11 10:30:43 +08:00
accountDataJSON := new(datas.AccountDataJSON)
2021-04-27 15:33:49 +08:00
//用accountuid作为过滤字段从数据库中读取一条信息
2021-11-11 10:30:43 +08:00
accountInfo := accounts.GetAccountByUid(accountUid)
2021-04-27 15:33:49 +08:00
//code初始值为200
accountDataJSON.Code = 200
//将从数据库读出来的数据插入到accountList数组中
accountDataJSON.AccountList = append(accountDataJSON.AccountList, accountInfo)
//返回jsonp格式的数据给前端
c.GenerateJSON(accountDataJSON)
}
func (c *GetController) GetAccountHistory() {
accountName := strings.TrimSpace(c.GetString("accountHistoryName"))
accountUid := strings.TrimSpace(c.GetString("accountHistoryNo"))
operatorType := strings.TrimSpace(c.GetString("operatorType"))
startTime := c.GetString("startTime")
endTime := c.GetString("endTime")
switch operatorType {
case "plus-amount":
operatorType = common.PLUS_AMOUNT
case "sub-amount":
operatorType = common.SUB_AMOUNT
case "freeze-amount":
operatorType = common.FREEZE_AMOUNT
case "unfreeze-amount":
operatorType = common.UNFREEZE_AMOUNT
}
params := make(map[string]string)
params["account_name__icontains"] = accountName
params["account_uid__icontains"] = accountUid
params["type"] = operatorType
params["create_time__gte"] = startTime
params["create_time__lte"] = endTime
2021-11-11 10:30:43 +08:00
l := accounts.GetAccountHistoryLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
accountHistoryDataJSON := new(datas.AccountHistoryDataJSON)
2021-04-27 15:33:49 +08:00
accountHistoryDataJSON.DisplayCount = c.DisplayCount
accountHistoryDataJSON.Code = 200
accountHistoryDataJSON.CurrentPage = c.CurrentPage
accountHistoryDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
accountHistoryDataJSON.AccountHistoryList = make([]accounts.AccountHistoryInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(accountHistoryDataJSON)
return
}
accountHistoryDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
accountHistoryDataJSON.AccountHistoryList = accounts.GetAccountHistoryByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(accountHistoryDataJSON)
}
func (c *GetController) GetAgent() {
agentName := strings.TrimSpace(c.GetString("agentName"))
params := make(map[string]string)
params["agnet_name__icontains"] = agentName
2021-11-11 10:30:43 +08:00
l := agent.GetAgentInfoLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
agentDataJSON := new(datas.AgentDataJSON)
2021-04-27 15:33:49 +08:00
agentDataJSON.DisplayCount = c.DisplayCount
agentDataJSON.Code = 200
agentDataJSON.CurrentPage = c.CurrentPage
agentDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
agentDataJSON.AgentList = make([]agent.AgentInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(agentDataJSON)
return
}
agentDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
agentDataJSON.AgentList = agent.GetAgentInfoByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(agentDataJSON)
}
func (c *GetController) GetAllAgent() {
agentName := strings.TrimSpace(c.GetString("agentName"))
params := make(map[string]string)
params["agent_name__icontains"] = agentName
2021-11-11 10:30:43 +08:00
agentDataJSON := new(datas.AgentDataJSON)
2021-04-27 15:33:49 +08:00
agentDataJSON.Code = 200
2021-11-11 10:30:43 +08:00
agentDataJSON.AgentList = agent.GetAllAgentByMap(params)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(agentDataJSON)
}
func (c *GetController) GetProduct() {
supplierCode2Name := common.GetSupplierMap()
2021-11-11 10:30:43 +08:00
productDataJSON := new(datas.ProductDataJSON)
2021-04-27 15:33:49 +08:00
productDataJSON.Code = 200
productDataJSON.ProductMap = supplierCode2Name
c.GenerateJSON(productDataJSON)
}
func (c *GetController) GetAgentToMerchant() {
agentUid := strings.TrimSpace(c.GetString("agentUid"))
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
params := make(map[string]string)
params["belong_agent_uid"] = agentUid
params["merchant_uid"] = merchantUid
2021-11-11 10:30:43 +08:00
l := merchant.GetMerchantLenByParams(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
merchantDataJSON := new(datas.MerchantDataJSON)
2021-04-27 15:33:49 +08:00
merchantDataJSON.DisplayCount = c.DisplayCount
merchantDataJSON.Code = 200
merchantDataJSON.CurrentPage = c.CurrentPage
merchantDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
merchantDataJSON.MerchantList = make([]merchant.MerchantInfo, 0)
2021-04-27 15:33:49 +08:00
} else {
2021-11-11 10:30:43 +08:00
merchantDataJSON.MerchantList = merchant.GetMerchantByParams(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
}
c.GenerateJSON(merchantDataJSON)
}
/*
* 获取订单数据
*/
func (c *GetController) GetOrder() {
startTime := strings.TrimSpace(c.GetString("startTime"))
endTime := strings.TrimSpace(c.GetString("endTime"))
merchantName := strings.TrimSpace(c.GetString("merchantName"))
orderNo := strings.TrimSpace(c.GetString("merchantOrderId"))
//bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
status := strings.TrimSpace(c.GetString("orderStatus"))
supplierUid := strings.TrimSpace(c.GetString("supplierUid"))
payWayCode := strings.TrimSpace(c.GetString("payWayCode"))
freeStatus := strings.TrimSpace(c.GetString("freeStatus"))
params := make(map[string]string)
params["create_time__gte"] = startTime
params["create_time__lte"] = endTime
params["merchant_name__icontains"] = merchantName
params["merchant_order_id"] = orderNo
//params["bank_order_id"] = bankOrderId
params["status"] = status
params["pay_product_code"] = supplierUid
params["pay_type_code"] = payWayCode
switch freeStatus {
case "free":
params["free"] = "yes"
case "unfree":
params["unfree"] = "yes"
case "refund":
params["refund"] = "yes"
}
2021-11-11 10:30:43 +08:00
l := order.GetOrderLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
orderDataJSON := new(datas.OrderDataJSON)
2021-04-27 15:33:49 +08:00
orderDataJSON.DisplayCount = c.DisplayCount
orderDataJSON.Code = 200
orderDataJSON.CurrentPage = c.CurrentPage
orderDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
orderDataJSON.OrderList = make([]order.OrderInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(orderDataJSON)
return
}
orderDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
orderDataJSON.OrderList = order.GetOrderByMap(params, c.DisplayCount, c.Offset)
orderDataJSON.SuccessRate = order.GetSuccessRateByMap(params)
params["status"] = common.SUCCESS
orderDataJSON.AllAmount = order.GetAllAmountByMap(params)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(orderDataJSON)
}
func (c *GetController) GetOneOrder() {
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
2021-11-11 10:30:43 +08:00
orderDataJSON := new(datas.OrderDataJSON)
orderInfo := order.GetOneOrder(bankOrderId)
2021-04-27 15:33:49 +08:00
orderDataJSON.Code = 200
orderDataJSON.OrderList = append(orderDataJSON.OrderList, orderInfo)
2021-11-11 10:30:43 +08:00
notifyInfo := notify.GetNotifyInfoByBankOrderId(bankOrderId)
2021-04-27 15:33:49 +08:00
if notifyInfo.Url == "" || len(notifyInfo.Url) == 0 {
orderDataJSON.NotifyUrl = orderInfo.NotifyUrl
} else {
orderDataJSON.NotifyUrl = notifyInfo.Url
}
c.GenerateJSON(orderDataJSON)
}
func (c *GetController) GetOrderProfit() {
startTime := strings.TrimSpace(c.GetString("startTime"))
endTime := strings.TrimSpace(c.GetString("endTime"))
merchantName := strings.TrimSpace(c.GetString("merchantName"))
agentName := strings.TrimSpace(c.GetString("agentName"))
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
status := strings.TrimSpace(c.GetString("orderStatus"))
supplierUid := strings.TrimSpace(c.GetString("supplierUid"))
payWayCode := strings.TrimSpace(c.GetString("payWayCode"))
params := make(map[string]string)
params["create_time__gte"] = startTime
params["create_time__lte"] = endTime
params["merchant_name__icontains"] = merchantName
params["agent_name__icontains"] = agentName
params["bank_order_id"] = bankOrderId
params["status"] = status
params["pay_product_code"] = supplierUid
params["pay_type_code"] = payWayCode
2021-11-11 10:30:43 +08:00
l := order.GetOrderProfitLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
listDataJSON := new(datas.ListDataJSON)
2021-04-27 15:33:49 +08:00
listDataJSON.DisplayCount = c.DisplayCount
listDataJSON.Code = 200
listDataJSON.CurrentPage = c.CurrentPage
listDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
listDataJSON.List = make([]order.OrderProfitInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(listDataJSON)
return
}
listDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
listDataJSON.List = order.GetOrderProfitByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
supplierAll := 0.0
platformAll := 0.0
agentAll := 0.0
allAmount := 0.0
for _, v := range listDataJSON.List {
if v.Status != "success" {
continue
}
allAmount += v.FactAmount
supplierAll += v.SupplierProfit
platformAll += v.PlatformProfit
agentAll += v.AgentProfit
}
listDataJSON.SupplierProfit, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", supplierAll), 3)
listDataJSON.PlatformProfit, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", platformAll), 3)
listDataJSON.AgentProfit, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", agentAll), 3)
listDataJSON.AllAmount, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", allAmount), 3)
c.GenerateJSON(listDataJSON)
}
func (c *GetController) GetPayFor() {
startTime := strings.TrimSpace(c.GetString("startTime"))
endTime := strings.TrimSpace(c.GetString("endTime"))
merchantOrderId := strings.TrimSpace(c.GetString("merchantOrderId"))
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
status := strings.TrimSpace(c.GetString("status"))
params := make(map[string]string)
params["create_time__lte"] = endTime
params["create_time__gte"] = startTime
params["merchant_order_id"] = merchantOrderId
params["bank_order_id"] = bankOrderId
params["status"] = status
2021-11-11 10:30:43 +08:00
l := payfor.GetPayForLenByMap(params)
2021-04-27 15:33:49 +08:00
c.GetCutPage(l)
2021-11-11 10:30:43 +08:00
listDataJSON := new(datas.PayForDataJSON)
2021-04-27 15:33:49 +08:00
listDataJSON.DisplayCount = c.DisplayCount
listDataJSON.Code = 200
listDataJSON.CurrentPage = c.CurrentPage
listDataJSON.TotalPage = c.TotalPage
if c.Offset < 0 {
2021-11-11 10:30:43 +08:00
listDataJSON.PayForList = make([]payfor.PayforInfo, 0)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(listDataJSON)
return
}
listDataJSON.StartIndex = c.Offset
2021-11-11 10:30:43 +08:00
listDataJSON.PayForList = payfor.GetPayForByMap(params, c.DisplayCount, c.Offset)
2021-04-27 15:33:49 +08:00
for index, p := range listDataJSON.PayForList {
if p.MerchantName == "" {
listDataJSON.PayForList[index].MerchantName = "任意下发"
}
if p.MerchantOrderId == "" {
listDataJSON.PayForList[index].MerchantOrderId = "任意发下"
}
if p.RoadName == "" {
listDataJSON.PayForList[index].RoadName = "无"
}
}
c.GenerateJSON(listDataJSON)
}
func (c *GetController) GetOnePayFor() {
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
2021-11-11 10:30:43 +08:00
payForInfo := payfor.GetPayForByBankOrderId(bankOrderId)
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
listDataJSON := new(datas.PayForDataJSON)
2021-04-27 15:33:49 +08:00
listDataJSON.Code = 200
listDataJSON.PayForList = append(listDataJSON.PayForList, payForInfo)
c.GenerateJSON(listDataJSON)
}
func (c *GetController) GetBalance() {
2021-11-11 10:30:43 +08:00
/*roadName := strings.TrimSpace(c.GetString("roadName"))
roadUid := strings.TrimSpace(c.GetString("roadUid"))*/
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
/*var roadInfo road.RoadInfo
2021-04-27 15:33:49 +08:00
if roadUid != "" {
2021-11-11 10:30:43 +08:00
roadInfo = road.GetRoadInfoByRoadUid(roadUid)
2021-04-27 15:33:49 +08:00
} else {
2021-11-11 10:30:43 +08:00
roadInfo = road.GetRoadInfoByName(roadName)
}*/
2021-04-27 15:33:49 +08:00
2021-11-11 10:30:43 +08:00
balanceDataJSON := new(datas.BalanceDataJSON)
2021-04-27 15:33:49 +08:00
balanceDataJSON.Code = 200
2021-11-11 10:30:43 +08:00
/*supplier := controller.GetPaySupplierByCode(roadInfo.ProductUid)
2021-04-27 15:33:49 +08:00
if supplier == nil {
balanceDataJSON.Code = -1
balanceDataJSON.Balance = -1.00
} else {
balance := supplier.BalanceQuery(roadInfo)
balanceDataJSON.Balance = balance
2021-11-11 10:30:43 +08:00
}*/
// TODO 从gateway获取账户余额
balanceDataJSON.Balance = 1
2021-04-27 15:33:49 +08:00
c.GenerateJSON(balanceDataJSON)
}
func (c *GetController) GetNotifyBankOrderIdList() {
startTime := strings.TrimSpace(c.GetString("startTime"))
endTime := strings.TrimSpace(c.GetString("endTime"))
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
notifyType := strings.TrimSpace(c.GetString("notifyType"))
params := make(map[string]string)
params["create_time__gte"] = startTime
params["create_time_lte"] = endTime
params["merchant_uid"] = merchantUid
params["type"] = notifyType
2021-11-11 10:30:43 +08:00
bankOrderIdListJSON := new(datas.NotifyBankOrderIdListJSON)
2021-04-27 15:33:49 +08:00
bankOrderIdListJSON.Code = 200
2021-11-11 10:30:43 +08:00
bankOrderIdListJSON.NotifyIdList = notify.GetNotifyBankOrderIdListByParams(params)
2021-04-27 15:33:49 +08:00
c.GenerateJSON(bankOrderIdListJSON)
}
/*
* 获取利润表
*/
func (c *GetController) GetProfit() {
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
agentUid := strings.TrimSpace(c.GetString("agentUid"))
supplierUid := strings.TrimSpace(c.GetString("supplierUid"))
payType := strings.TrimSpace(c.GetString("payType"))
startTime := strings.TrimSpace(c.GetString("startTime"))
endTime := strings.TrimSpace(c.GetString("endTime"))
params := make(map[string]string)
params["merchant_uid"] = merchantUid
params["agent_uid"] = agentUid
params["pay_product_code"] = supplierUid
params["pay_type_code"] = payType
params["create_time__gte"] = startTime
params["create_time__lte"] = endTime
2021-11-11 10:30:43 +08:00
profitListJSON := new(datas.ProfitListJSON)
2021-04-27 15:33:49 +08:00
profitListJSON.Code = 200
2021-11-11 10:30:43 +08:00
profitListJSON.ProfitList = order.GetPlatformProfitByMap(params)
2021-04-27 15:33:49 +08:00
profitListJSON.TotalAmount = 0.00
profitListJSON.PlatformTotalProfit = 0.00
profitListJSON.AgentTotalProfit = 0.00
for i, p := range profitListJSON.ProfitList {
profitListJSON.TotalAmount += p.OrderAmount
profitListJSON.PlatformTotalProfit += p.PlatformProfit
profitListJSON.AgentTotalProfit += p.AgentProfit
if p.AgentName == "" {
p.AgentName = "无代理商"
}
profitListJSON.ProfitList[i] = p
}
c.GenerateJSON(profitListJSON)
}