mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-09-14 14:43:50 +08:00
提交新项目
This commit is contained in:
998
jhboss/controllers/add.go
Normal file
998
jhboss/controllers/add.go
Normal file
@@ -0,0 +1,998 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/8/19 18:13
|
||||
** @Author : yuebin
|
||||
** @File : add
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/19 18:13
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/validation"
|
||||
"github.com/rs/xid"
|
||||
"juhe/service/common"
|
||||
"juhe/service/models"
|
||||
"juhe/service/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type AddController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加一级菜单
|
||||
*/
|
||||
func (c *AddController) AddMenu() {
|
||||
oneMenu := c.GetString("oneMenu")
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
menuInfo := models.MenuInfo{MenuUid: xid.New().String(), FirstMenu: oneMenu, Status: "active",
|
||||
Creater: c.GetSession("userID").(string), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
exist := models.FirstMenuIsExists(oneMenu)
|
||||
if !exist {
|
||||
menuInfo.MenuOrder = models.GetMenuLen() + 1
|
||||
flag := models.InsertMenu(menuInfo)
|
||||
if !flag {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "添加菜单失败"
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "一级菜单名已经存在"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加二级菜单
|
||||
*/
|
||||
func (c *AddController) AddSecondMenu() {
|
||||
firstMenuUid := c.GetString("preMenuUid")
|
||||
secondMenu := c.GetString("secondMenu")
|
||||
secondRouter := c.GetString("secondRouter")
|
||||
|
||||
dataJSON := new(KeyDataJSON)
|
||||
|
||||
firstMenuInfo := models.GetMenuInfoByMenuUid(firstMenuUid)
|
||||
routerExists := models.SecondRouterExists(secondRouter)
|
||||
secondMenuExists := models.SecondMenuIsExists(secondMenu)
|
||||
|
||||
if firstMenuInfo.MenuUid == "" {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Key = "pre-menu-error"
|
||||
dataJSON.Msg = "*一级菜单不存在"
|
||||
} else if routerExists {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "*该路由已存在"
|
||||
dataJSON.Key = "second-router-error"
|
||||
} else if secondMenuExists {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Key = "second-menu-error"
|
||||
dataJSON.Msg = "*该菜单名已经存在"
|
||||
} else {
|
||||
sl := models.GetSecondMenuLenByFirstMenuUid(firstMenuUid)
|
||||
secondMenuInfo := models.SecondMenuInfo{MenuOrder: sl + 1, FirstMenuUid: firstMenuInfo.MenuUid,
|
||||
FirstMenu: firstMenuInfo.FirstMenu, SecondMenuUid: xid.New().String(), Status: "active",
|
||||
SecondMenu: secondMenu, SecondRouter: secondRouter, Creater: c.GetSession("userID").(string),
|
||||
CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime(), FirstMenuOrder: firstMenuInfo.MenuOrder}
|
||||
if !models.InsertSecondMenu(secondMenuInfo) {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "添加二级菜单失败"
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "添加二级菜单成功"
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加权限项的处理函数
|
||||
*/
|
||||
func (c *AddController) AddPower() {
|
||||
firstMenuUid := strings.TrimSpace(c.GetString("firstMenuUid"))
|
||||
secondMenuUid := strings.TrimSpace(c.GetString("secondMenuUid"))
|
||||
powerItem := strings.TrimSpace(c.GetString("powerItem"))
|
||||
powerID := strings.TrimSpace(c.GetString("powerID"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
if powerItem == "" || len(powerItem) == 0 {
|
||||
keyDataJSON.Key = ".power-name-error"
|
||||
keyDataJSON.Msg = "*权限项名称不能为空"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
if powerID == "" || len(powerID) == 0 {
|
||||
keyDataJSON.Key = ".power-id-error"
|
||||
keyDataJSON.Msg = "*权限项ID不能为空"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
if models.PowerUidExists(powerID) {
|
||||
keyDataJSON.Key = ".power-id-error"
|
||||
keyDataJSON.Msg = "*权限项ID已经存在"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(powerID)
|
||||
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||
|
||||
powerInfo := models.PowerInfo{SecondMenuUid: secondMenuUid, SecondMenu: secondMenuInfo.SecondMenu,
|
||||
PowerId: powerID, PowerItem: powerItem, Creater: c.GetSession("userID").(string),
|
||||
Status: "active", CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime(),
|
||||
FirstMenuUid: firstMenuUid}
|
||||
|
||||
keyDataJSON.Code = 200
|
||||
if !models.InsertPowerInfo(powerInfo) {
|
||||
keyDataJSON.Key = ".power-save-success"
|
||||
keyDataJSON.Msg = "添加权限项失败"
|
||||
} else {
|
||||
keyDataJSON.Key = ".power-save-success"
|
||||
keyDataJSON.Msg = "添加权限项成功"
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加权限角色
|
||||
*/
|
||||
func (this *AddController) AddRole() {
|
||||
roleName := strings.TrimSpace(this.GetString("roleNameAdd"))
|
||||
roleRemark := strings.TrimSpace(this.GetString("roleRemark"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if len(roleName) == 0 {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".role-name-error"
|
||||
keyDataJSON.Msg = "*角色名称不能为空"
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if models.RoleNameExists(roleName) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".role-name-error"
|
||||
keyDataJSON.Msg = "*角色名称已经存在"
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
roleInfo := models.RoleInfo{RoleName: roleName, RoleUid: xid.New().String(),
|
||||
Creater: this.GetSession("userID").(string), Status: "active", Remark: roleRemark,
|
||||
CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if !models.InsertRole(roleInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".role-save-success"
|
||||
keyDataJSON.Msg = "添加角色失败"
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
keyDataJSON.Code = 200
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (this *AddController) SavePower() {
|
||||
firstMenuUids := this.GetStrings("firstMenuUid[]")
|
||||
secondMenuUids := this.GetStrings("secondMenuUid[]")
|
||||
powerIds := this.GetStrings("powerId[]")
|
||||
roleUid := strings.TrimSpace(this.GetString("roleUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
roleInfo := models.GetRoleByRoleUid(roleUid)
|
||||
if len(roleUid) == 0 || len(roleInfo.RoleUid) == 0 {
|
||||
dataJSON.Code = -1
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
roleInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
roleInfo.ShowFirstUid = strings.Join(firstMenuUids, "||")
|
||||
roleInfo.ShowSecondUid = strings.Join(secondMenuUids, "||")
|
||||
roleInfo.ShowPowerUid = strings.Join(powerIds, "||")
|
||||
|
||||
menuInfoList := models.GetMenuInfosByMenuUids(firstMenuUids)
|
||||
showFirstMenu := make([]string, 0)
|
||||
for _, m := range menuInfoList {
|
||||
showFirstMenu = append(showFirstMenu, m.FirstMenu)
|
||||
}
|
||||
roleInfo.ShowFirstMenu = strings.Join(showFirstMenu, "||")
|
||||
|
||||
secondMenuInfoList := models.GetSecondMenuInfoBySecondMenuUids(secondMenuUids)
|
||||
showSecondMenu := make([]string, 0)
|
||||
for _, m := range secondMenuInfoList {
|
||||
showSecondMenu = append(showSecondMenu, m.SecondMenu)
|
||||
}
|
||||
roleInfo.ShowSecondMenu = strings.Join(showSecondMenu, "||")
|
||||
|
||||
powerList := models.GetPowerByIds(powerIds)
|
||||
showPower := make([]string, 0)
|
||||
for _, p := range powerList {
|
||||
showPower = append(showPower, p.PowerItem)
|
||||
}
|
||||
roleInfo.ShowPower = strings.Join(showPower, "||")
|
||||
|
||||
if !models.UpdateRoleInfo(roleInfo) {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "更新roleInfo失败"
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "更新roleInfo成功"
|
||||
}
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加操作员
|
||||
*/
|
||||
func (this *AddController) AddOperator() {
|
||||
loginAccount := strings.TrimSpace(this.GetString("operatorAccount"))
|
||||
loginPassword := strings.TrimSpace(this.GetString("operatorPassword"))
|
||||
role := strings.TrimSpace(this.GetString("operatorRole"))
|
||||
status := strings.TrimSpace(this.GetString("status"))
|
||||
remark := strings.TrimSpace(this.GetString("remark"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
if len(loginAccount) == 0 {
|
||||
keyDataJSON.Key = ".operator-name-error"
|
||||
keyDataJSON.Msg = "*登录账号不能为空"
|
||||
} else if len(loginPassword) == 0 {
|
||||
keyDataJSON.Key = ".operator-password-error"
|
||||
keyDataJSON.Msg = "*初始密码不能为空"
|
||||
} else if len(role) == 0 || role == "none" {
|
||||
keyDataJSON.Key = ".operator-role-error"
|
||||
keyDataJSON.Msg = "请选择角色"
|
||||
} else if models.UserInfoExistByUserId(loginAccount) {
|
||||
keyDataJSON.Key = ".operator-name-error"
|
||||
keyDataJSON.Msg = "*账号已经存在"
|
||||
} else {
|
||||
if len(remark) == 0 {
|
||||
remark = loginAccount
|
||||
}
|
||||
roleInfo := models.GetRoleByRoleUid(role)
|
||||
userInfo := models.UserInfo{UserId: loginAccount, Passwd: utils.GetMD5Upper(loginPassword), Nick: "壮壮", Remark: remark,
|
||||
Status: status, Role: role, RoleName: roleInfo.RoleName, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
if !models.InsertUser(userInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "添加操作员失败"
|
||||
} else {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "添加操作员成功"
|
||||
}
|
||||
}
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加银行卡
|
||||
*/
|
||||
func (this *AddController) AddBankCard() {
|
||||
userName := strings.TrimSpace(this.GetString("userName"))
|
||||
bankCode := strings.TrimSpace(this.GetString("bankCode"))
|
||||
accountName := strings.TrimSpace(this.GetString("accountName"))
|
||||
certificateType := strings.TrimSpace(this.GetString("certificateType"))
|
||||
phoneNo := strings.TrimSpace(this.GetString("phoneNo"))
|
||||
bankName := strings.TrimSpace(this.GetString("bankName"))
|
||||
bankAccountType := strings.TrimSpace(this.GetString("bankAccountType"))
|
||||
bankNo := strings.TrimSpace(this.GetString("bankNo"))
|
||||
identifyCard := strings.TrimSpace(this.GetString("certificateType"))
|
||||
certificateNo := strings.TrimSpace(this.GetString("certificateNo"))
|
||||
bankAddress := strings.TrimSpace(this.GetString("bankAddress"))
|
||||
uid := strings.TrimSpace(this.GetString("uid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
dataJSON.Code = -1
|
||||
if len(userName) == 0 {
|
||||
dataJSON.Msg = "用户名不能为空"
|
||||
} else if len(bankCode) == 0 {
|
||||
dataJSON.Msg = "银行编码不能为空"
|
||||
} else if len(accountName) == 0 {
|
||||
dataJSON.Msg = "银行开户名不能为空"
|
||||
} else if len(certificateType) == 0 {
|
||||
dataJSON.Msg = "证件种类不能为空"
|
||||
} else if len(phoneNo) == 0 {
|
||||
dataJSON.Msg = "手机号不能为空"
|
||||
} else if len(bankName) == 0 {
|
||||
dataJSON.Msg = "银行名称不能为空"
|
||||
} else if len(bankAccountType) == 0 {
|
||||
dataJSON.Msg = "银行账户类型不能为空"
|
||||
} else if len(bankNo) == 0 {
|
||||
dataJSON.Msg = "银行账号不能为空"
|
||||
} else if len(certificateNo) == 0 {
|
||||
dataJSON.Msg = "身份证号不能为空"
|
||||
} else if len(bankAddress) == 0 {
|
||||
dataJSON.Msg = "银行地址不能为空"
|
||||
} else {
|
||||
|
||||
}
|
||||
if dataJSON.Msg != "" {
|
||||
logs.Error("添加银行卡校验失败")
|
||||
} else {
|
||||
if len(uid) > 0 {
|
||||
bankCardInfo := models.GetBankCardByUid(uid)
|
||||
bankCardInfo = models.BankCardInfo{
|
||||
Id: bankCardInfo.Id, UserName: userName, BankName: bankName,
|
||||
BankCode: bankCode, BankAccountType: bankAccountType,
|
||||
AccountName: accountName, BankNo: bankNo, IdentifyCard: identifyCard,
|
||||
CertificateNo: certificateNo, PhoneNo: phoneNo,
|
||||
BankAddress: bankAddress, UpdateTime: utils.GetBasicDateTime(),
|
||||
CreateTime: bankCardInfo.CreateTime, Uid: bankCardInfo.Uid,
|
||||
}
|
||||
if models.UpdateBankCard(bankCardInfo) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
} else {
|
||||
bankCardInfo := models.BankCardInfo{Uid: "3333" + xid.New().String(), UserName: userName, BankName: bankName,
|
||||
BankCode: bankCode, BankAccountType: bankAccountType, AccountName: accountName, BankNo: bankNo,
|
||||
IdentifyCard: identifyCard, CertificateNo: certificateNo, PhoneNo: phoneNo, BankAddress: bankAddress,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertBankCardInfo(bankCardInfo) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加通道
|
||||
*/
|
||||
func (this *AddController) AddRoad() {
|
||||
roadUid := strings.TrimSpace(this.GetString("roadUid"))
|
||||
roadName := strings.TrimSpace(this.GetString("roadName"))
|
||||
roadRemark := strings.TrimSpace(this.GetString("roadRemark"))
|
||||
productUid := strings.TrimSpace(this.GetString("productName"))
|
||||
payType := strings.TrimSpace(this.GetString("payType"))
|
||||
basicRate := strings.TrimSpace(this.GetString("basicRate"))
|
||||
settleFee := strings.TrimSpace(this.GetString("settleFee"))
|
||||
roadTotalLimit := strings.TrimSpace(this.GetString("roadTotalLimit"))
|
||||
roadEverydayLimit := strings.TrimSpace(this.GetString("roadEverydayLimit"))
|
||||
singleMinLimit := strings.TrimSpace(this.GetString("singleMinLimit"))
|
||||
singleMaxLimit := strings.TrimSpace(this.GetString("singleMaxLimit"))
|
||||
startHour := strings.TrimSpace(this.GetString("startHour"))
|
||||
endHour := strings.TrimSpace(this.GetString("endHour"))
|
||||
params := strings.TrimSpace(this.GetString("params"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
startHourTmp, err1 := strconv.Atoi(startHour)
|
||||
endHourTmp, err2 := strconv.Atoi(endHour)
|
||||
|
||||
if err1 != nil || err2 != nil {
|
||||
dataJSON.Msg = "开始时间或者结束时间设置有误"
|
||||
this.GenerateJSON(dataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
valid := validation.Validation{}
|
||||
if v := valid.Required(roadName, "roadName"); !v.Ok {
|
||||
dataJSON.Msg = "通道名称不能为空"
|
||||
} else if v := valid.Required(productUid, "productUid"); !v.Ok {
|
||||
dataJSON.Msg = "产品名称不能为空"
|
||||
} else if v := valid.Required(payType, "payType"); !v.Ok {
|
||||
dataJSON.Msg = "支付类型不能为空"
|
||||
} else if v := valid.Required(basicRate, ""); !v.Ok {
|
||||
dataJSON.Msg = "成本费率不能为空"
|
||||
} else if v := valid.Range(startHourTmp, 0, 23, ""); !v.Ok {
|
||||
dataJSON.Msg = "开始时间设置有误"
|
||||
} else if v := valid.Range(endHourTmp, 0, 23, ""); !v.Ok {
|
||||
dataJSON.Msg = "结束时间设置有误"
|
||||
} else {
|
||||
basicFee, err := strconv.ParseFloat(basicRate, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "成本汇率设置不符合规范"
|
||||
}
|
||||
settleFeeTmp, err := strconv.ParseFloat(settleFee, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "代付手续费设置不符合规范"
|
||||
}
|
||||
totalLimit, err := strconv.ParseFloat(roadTotalLimit, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "通道总额度设置不符合规范"
|
||||
}
|
||||
todayLimit, err := strconv.ParseFloat(roadEverydayLimit, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "每天额度设置不符合规范"
|
||||
}
|
||||
singleMinLimitTmp, err := strconv.ParseFloat(singleMinLimit, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "单笔最小金额设置不符合规范"
|
||||
}
|
||||
singleMaxLimitTmp, err := strconv.ParseFloat(singleMaxLimit, 64)
|
||||
if err != nil {
|
||||
dataJSON.Msg = "单笔最大金额设置不符合规范"
|
||||
}
|
||||
if len(dataJSON.Msg) > 0 {
|
||||
this.GenerateJSON(dataJSON)
|
||||
return
|
||||
}
|
||||
productName := ""
|
||||
supplierMap := common.GetSupplierMap()
|
||||
for k, v := range supplierMap {
|
||||
if k == productUid {
|
||||
productName = v
|
||||
}
|
||||
}
|
||||
|
||||
if len(roadUid) > 0 {
|
||||
//更新通道
|
||||
roadInfo := models.GetRoadInfoByRoadUid(roadUid)
|
||||
roadInfo.RoadName = roadName
|
||||
roadInfo.Remark = roadRemark
|
||||
roadInfo.ProductUid = productUid
|
||||
roadInfo.ProductName = productName
|
||||
roadInfo.PayType = payType
|
||||
roadInfo.BasicFee = basicFee
|
||||
roadInfo.SettleFee = settleFeeTmp
|
||||
roadInfo.TotalLimit = totalLimit
|
||||
roadInfo.TodayLimit = todayLimit
|
||||
roadInfo.SingleMaxLimit = singleMaxLimitTmp
|
||||
roadInfo.SingleMinLimit = singleMinLimitTmp
|
||||
roadInfo.StarHour = startHourTmp
|
||||
roadInfo.EndHour = endHourTmp
|
||||
roadInfo.Params = params
|
||||
|
||||
if models.UpdateRoadInfo(roadInfo) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Msg = "通道更新失败"
|
||||
}
|
||||
} else {
|
||||
//添加新的通道
|
||||
roadUid = "4444" + xid.New().String()
|
||||
roadInfo := models.RoadInfo{RoadName: roadName, RoadUid: roadUid, Remark: roadRemark,
|
||||
ProductUid: productUid, ProductName: productName, PayType: payType, BasicFee: basicFee, SettleFee: settleFeeTmp,
|
||||
TotalLimit: totalLimit, TodayLimit: todayLimit, SingleMinLimit: singleMinLimitTmp, Balance: common.ZERO,
|
||||
SingleMaxLimit: singleMaxLimitTmp, StarHour: startHourTmp, EndHour: endHourTmp, Status: "active",
|
||||
Params: params, UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime(),
|
||||
}
|
||||
|
||||
if models.InsertRoadInfo(roadInfo) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Msg = "添加新通道失败"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (this *AddController) AddRoadPool() {
|
||||
roadPoolName := strings.TrimSpace(this.GetString("roadPoolName"))
|
||||
roadPoolCode := strings.TrimSpace(this.GetString("roadPoolCode"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
|
||||
if len(roadPoolName) == 0 {
|
||||
keyDataJSON.Msg = "*通道池名称不能为空"
|
||||
} else if len(roadPoolCode) == 0 {
|
||||
keyDataJSON.Msg = "*通道池编号不能为空"
|
||||
}
|
||||
|
||||
roadPoolInfo := models.RoadPoolInfo{Status: "active", RoadPoolName: roadPoolName, RoadPoolCode: roadPoolCode,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertRoadPool(roadPoolInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "添加通道池成功"
|
||||
} else {
|
||||
keyDataJSON.Msg = "添加通道池失败"
|
||||
}
|
||||
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加或者更新通道池中的通道
|
||||
*/
|
||||
func (this *AddController) SaveRoadUid() {
|
||||
roadUids := this.GetStrings("roadUid[]")
|
||||
roadPoolCode := strings.TrimSpace(this.GetString("roadPoolCode"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
roadPoolInfo := models.GetRoadPoolByRoadPoolCode(roadPoolCode)
|
||||
if roadPoolInfo.RoadPoolCode == "" {
|
||||
this.GenerateJSON(dataJSON)
|
||||
return
|
||||
}
|
||||
var uids []string
|
||||
for _, uid := range roadUids {
|
||||
//去掉空格
|
||||
if len(uid) > 0 && models.RoadInfoExistByRoadUid(uid) {
|
||||
uids = append(uids, uid)
|
||||
}
|
||||
}
|
||||
if len(uids) > 0 {
|
||||
roadUid := strings.Join(uids, "||")
|
||||
roadPoolInfo.RoadUidPool = roadUid
|
||||
}
|
||||
roadPoolInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if models.UpdateRoadPool(roadPoolInfo) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
this.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加代理信息
|
||||
*/
|
||||
func (this *AddController) AddAgent() {
|
||||
agentName := strings.TrimSpace(this.GetString("agentName"))
|
||||
agentPhone := strings.TrimSpace(this.GetString("agentPhone"))
|
||||
agentLoginPassword := strings.TrimSpace(this.GetString("agentLoginPassword"))
|
||||
agentVertifyPassword := strings.TrimSpace(this.GetString("agentVertifyPassword"))
|
||||
agentRemark := strings.TrimSpace(this.GetString("agentRemark"))
|
||||
status := strings.TrimSpace(this.GetString("status"))
|
||||
agentUid := strings.TrimSpace(this.GetString("agentUid"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if agentName == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-name-error"
|
||||
keyDataJSON.Msg = "代理名不能为空"
|
||||
} else if models.IsEixstByAgentName(agentName) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-name-error"
|
||||
keyDataJSON.Msg = "已存在该代理名称"
|
||||
} else if agentPhone == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-phone-error"
|
||||
keyDataJSON.Msg = "代理注册手机号不能为空"
|
||||
} else if models.IsEixstByAgentPhone(agentPhone) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-phone-error"
|
||||
keyDataJSON.Msg = "代理商手机号已被注册"
|
||||
} else if agentLoginPassword == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-login-password-error"
|
||||
keyDataJSON.Msg = "密码不能为空"
|
||||
} else if agentLoginPassword != agentVertifyPassword {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-vertify-password-error"
|
||||
keyDataJSON.Msg = "二次密码输入不一致"
|
||||
}
|
||||
|
||||
if keyDataJSON.Code == -1 {
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if status == "" {
|
||||
status = "active"
|
||||
}
|
||||
|
||||
if agentUid == "" {
|
||||
|
||||
agentUid = "9999" + xid.New().String()
|
||||
|
||||
agentInfo := models.AgentInfo{Status: status, AgentName: agentName, AgentPhone: agentPhone,
|
||||
AgentPassword: utils.GetMD5Upper(agentLoginPassword), AgentUid: agentUid, UpdateTime: utils.GetBasicDateTime(),
|
||||
CreateTime: utils.GetBasicDateTime(), AgentRemark: agentRemark}
|
||||
|
||||
if !models.InsertAgentInfo(agentInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "添加代理商失败"
|
||||
}
|
||||
}
|
||||
|
||||
//创建新的账户
|
||||
account := models.GetAccountByUid(agentUid)
|
||||
if account.AccountUid == "" {
|
||||
account.Status = "active"
|
||||
account.AccountUid = agentUid
|
||||
account.AccountName = agentName
|
||||
account.Balance = 0.0
|
||||
account.LoanAmount = 0.0
|
||||
account.FreezeAmount = 0.0
|
||||
account.PayforAmount = 0.0
|
||||
account.SettleAmount = 0.0
|
||||
account.WaitAmount = 0.0
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
account.CreateTime = utils.GetBasicDateTime()
|
||||
if models.InsetAcount(account) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "插入成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "掺入失败"
|
||||
}
|
||||
}
|
||||
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (this *AddController) AddMerchant() {
|
||||
merchantName := strings.TrimSpace(this.GetString("merchantName"))
|
||||
phone := strings.TrimSpace(this.GetString("phone"))
|
||||
loginPassword := strings.TrimSpace(this.GetString("loginPassword"))
|
||||
verifyPassword := strings.TrimSpace(this.GetString("verifyPassword"))
|
||||
merchantStatus := strings.TrimSpace(this.GetString("merchantStatus"))
|
||||
remark := strings.TrimSpace(this.GetString("remark"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
if merchantName == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-name-error"
|
||||
keyDataJSON.Msg = "商户名称为空"
|
||||
} else if models.IsExistByMerchantName(merchantName) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-name-error"
|
||||
keyDataJSON.Msg = "商户名已经存在"
|
||||
} else if phone == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-phone-error"
|
||||
keyDataJSON.Msg = "手机号为空"
|
||||
} else if models.IsExistByMerchantPhone(phone) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-phone-error"
|
||||
keyDataJSON.Msg = "该手机号已经注册"
|
||||
} else if loginPassword == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-login-password-error"
|
||||
keyDataJSON.Msg = "登录密码为空"
|
||||
} else if verifyPassword == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#merchant-verify-password-error"
|
||||
keyDataJSON.Msg = "密码确认为空"
|
||||
} else if loginPassword != verifyPassword {
|
||||
keyDataJSON.Key = "#merchant-verify-password-error"
|
||||
keyDataJSON.Msg = "两次密码输入不正确"
|
||||
} else if merchantStatus == "" {
|
||||
merchantStatus = "active"
|
||||
}
|
||||
if keyDataJSON.Code == -1 {
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
merchantUid := "8888" + xid.New().String()
|
||||
merchantKey := "kkkk" + xid.New().String() //商户key
|
||||
merchantSecret := "ssss" + xid.New().String() //商户密钥
|
||||
merchantInfo := models.MerchantInfo{MerchantName: merchantName, MerchantUid: merchantUid,
|
||||
LoginAccount: phone, MerchantKey: merchantKey, MerchantSecret: merchantSecret,
|
||||
LoginPassword: utils.GetMD5Upper(loginPassword), Status: merchantStatus, Remark: remark,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertMerchantInfo(merchantInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "插入失败"
|
||||
}
|
||||
//创建新的账户
|
||||
account := models.GetAccountByUid(merchantUid)
|
||||
if account.AccountUid == "" {
|
||||
account.Status = "active"
|
||||
account.AccountUid = merchantUid
|
||||
account.AccountName = merchantName
|
||||
account.Balance = 0.0
|
||||
account.LoanAmount = 0.0
|
||||
account.FreezeAmount = 0.0
|
||||
account.PayforAmount = 0.0
|
||||
account.SettleAmount = 0.0
|
||||
account.WaitAmount = 0.0
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
account.CreateTime = utils.GetBasicDateTime()
|
||||
if models.InsetAcount(account) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "插入成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "掺入失败"
|
||||
}
|
||||
}
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加商戶支付配置參數
|
||||
*/
|
||||
func (this *AddController) AddMerchantDeploy() {
|
||||
//merchantName := strings.TrimSpace(this.GetString("merchantName"))
|
||||
merchantUid := strings.TrimSpace(this.GetString("merchantNo"))
|
||||
isAutoSettle := strings.TrimSpace(this.GetString("isAutoSettle"))
|
||||
isAutoPayfor := strings.TrimSpace(this.GetString("isAutoPayfor"))
|
||||
ipWhite := strings.TrimSpace(this.GetString("ipWhite"))
|
||||
payforRoadChoose := strings.TrimSpace(this.GetString("payforRoadChoose"))
|
||||
rollPayforRoadChoose := strings.TrimSpace(this.GetString("rollPayforRoadChoose"))
|
||||
payforFee := strings.TrimSpace(this.GetString("payforFee"))
|
||||
belongAgentName := strings.TrimSpace(this.GetString("belongAgentName"))
|
||||
belongAgentUid := strings.TrimSpace(this.GetString("belongAgentUid"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
merchantInfo.AutoSettle = isAutoSettle
|
||||
merchantInfo.AutoPayFor = isAutoPayfor
|
||||
merchantInfo.WhiteIps = ipWhite
|
||||
merchantInfo.BelongAgentName = belongAgentName
|
||||
merchantInfo.BelongAgentUid = belongAgentUid
|
||||
|
||||
if payforRoadChoose != "" {
|
||||
roadInfo := models.GetRoadInfoByName(payforRoadChoose)
|
||||
merchantInfo.SinglePayForRoadName = payforRoadChoose
|
||||
merchantInfo.SinglePayForRoadUid = roadInfo.RoadUid
|
||||
}
|
||||
if rollPayforRoadChoose != "" {
|
||||
rollPoolInfo := models.GetRoadPoolByName(rollPayforRoadChoose)
|
||||
merchantInfo.RollPayForRoadName = rollPayforRoadChoose
|
||||
merchantInfo.RollPayForRoadCode = rollPoolInfo.RoadPoolCode
|
||||
}
|
||||
tmp, err := strconv.ParseFloat(payforFee, 64)
|
||||
if err != nil {
|
||||
logs.Error("手续费由字符串转为float64失败")
|
||||
tmp = common.PAYFOR_FEE
|
||||
}
|
||||
merchantInfo.PayforFee = tmp
|
||||
if models.UpdateMerchant(merchantInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (this *AddController) AddMerchantPayType() {
|
||||
merchantNo := strings.TrimSpace(this.GetString("merchantNo"))
|
||||
payType := strings.TrimSpace(this.GetString("payType"))
|
||||
singleRoad := strings.TrimSpace(this.GetString("singleRoad"))
|
||||
singleRoadPlatformFee := strings.TrimSpace(this.GetString("singleRoadPlatformFee"))
|
||||
singleRoadAgentFee := strings.TrimSpace(this.GetString("singleRoadAgentFee"))
|
||||
rollPoolRoad := strings.TrimSpace(this.GetString("rollPoolRoad"))
|
||||
rollRoadPlatformFee := strings.TrimSpace(this.GetString("rollRoadPlatformFee"))
|
||||
rollRoadAgentFee := strings.TrimSpace(this.GetString("rollRoadAgentFee"))
|
||||
isLoan := strings.TrimSpace(this.GetString("isLoan"))
|
||||
loanRate := strings.TrimSpace(this.GetString("loanRate"))
|
||||
loanDays := strings.TrimSpace(this.GetString("loanDays"))
|
||||
unfreezeTimeHour := strings.TrimSpace(this.GetString("unfreezeTimeHour"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if payType == "" || payType == "none" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "操作失败,请选择支付类型"
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
if singleRoad == "" && (singleRoadPlatformFee != "" || singleRoadAgentFee != "") {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "单通道选项不能为空"
|
||||
} else if rollPoolRoad == "" && (rollRoadPlatformFee != "" || rollRoadAgentFee != "") {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "轮询通道选项不能为空"
|
||||
}
|
||||
|
||||
if keyDataJSON.Code == -1 {
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
//将字符串转变为float64或者int类型
|
||||
a, err := strconv.ParseFloat(singleRoadPlatformFee, 64)
|
||||
if err != nil {
|
||||
a = 0.0
|
||||
}
|
||||
b, err := strconv.ParseFloat(singleRoadAgentFee, 64)
|
||||
if err != nil {
|
||||
b = 0.0
|
||||
}
|
||||
c, err := strconv.ParseFloat(rollRoadPlatformFee, 64)
|
||||
if err != nil {
|
||||
c = 0.0
|
||||
}
|
||||
d, err := strconv.ParseFloat(rollRoadAgentFee, 64)
|
||||
if err != nil {
|
||||
d = 0.0
|
||||
}
|
||||
e, err := strconv.ParseFloat(loanRate, 64)
|
||||
if err != nil {
|
||||
e = 0.0
|
||||
}
|
||||
i, err := strconv.Atoi(loanDays)
|
||||
if err != nil {
|
||||
i = 0
|
||||
}
|
||||
j, err := strconv.Atoi(unfreezeTimeHour)
|
||||
if err != nil {
|
||||
j = 0
|
||||
}
|
||||
|
||||
var merchantDeployInfo models.MerchantDeployInfo
|
||||
merchantDeployInfo.MerchantUid = merchantNo
|
||||
merchantDeployInfo.PayType = payType
|
||||
merchantDeployInfo.SingleRoadName = singleRoad
|
||||
merchantDeployInfo.SingleRoadPlatformRate = a
|
||||
merchantDeployInfo.SingleRoadAgentRate = b
|
||||
merchantDeployInfo.RollRoadPlatformRate = c
|
||||
merchantDeployInfo.RollRoadAgentRate = d
|
||||
merchantDeployInfo.IsLoan = isLoan
|
||||
merchantDeployInfo.LoanRate = e
|
||||
merchantDeployInfo.LoanDays = i
|
||||
merchantDeployInfo.UnfreezeHour = j
|
||||
merchantDeployInfo.RollRoadName = rollPoolRoad
|
||||
roadInfo := models.GetRoadInfoByName(singleRoad)
|
||||
rollPoolInfo := models.GetRoadPoolByName(rollPoolRoad)
|
||||
merchantDeployInfo.SingleRoadUid = roadInfo.RoadUid
|
||||
merchantDeployInfo.RollRoadCode = rollPoolInfo.RoadPoolCode
|
||||
|
||||
//如果该用户的改支付类型已经存在,那么进行更新,否则进行添加
|
||||
if models.IsExistByUidAndPayType(merchantNo, payType) {
|
||||
if singleRoad == "" && rollPoolRoad == "" {
|
||||
//表示需要删除该支付类型的通道
|
||||
if models.DeleteMerchantDeployByUidAndPayType(merchantNo, payType) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "删除该支付类型通道成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "删除该支付类型通道失败"
|
||||
}
|
||||
} else {
|
||||
tmpInfo := models.GetMerchantDeployByUidAndPayType(merchantNo, payType)
|
||||
merchantDeployInfo.Id = tmpInfo.Id
|
||||
merchantDeployInfo.Status = tmpInfo.Status
|
||||
merchantDeployInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if models.UpdateMerchantDeploy(merchantDeployInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "更新成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "更新失败"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if singleRoad == "" && rollPoolRoad == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "参数不能为空"
|
||||
} else {
|
||||
merchantDeployInfo.CreateTime = utils.GetBasicDateTime()
|
||||
merchantDeployInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
merchantDeployInfo.Status = common.ACTIVE
|
||||
if models.InsertMerchantDeployInfo(merchantDeployInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = "添加支付类型成功"
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "添加支付类型失败"
|
||||
}
|
||||
}
|
||||
}
|
||||
this.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
*后台提交的下发记录
|
||||
*/
|
||||
func (c *AddController) AddPayFor() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
merchantName := strings.TrimSpace(c.GetString("merchantName"))
|
||||
bankName := strings.TrimSpace(c.GetString("bankName"))
|
||||
accountName := strings.TrimSpace(c.GetString("accountName"))
|
||||
bankUid := strings.TrimSpace(c.GetString("bankUid"))
|
||||
bankNo := strings.TrimSpace(c.GetString("bankNo"))
|
||||
//cardType := strings.TrimSpace(c.GetString("cardType"))
|
||||
bankAddress := strings.TrimSpace(c.GetString("bankAddress"))
|
||||
phone := strings.TrimSpace(c.GetString("phone"))
|
||||
payForAmount := strings.TrimSpace(c.GetString("payForAmount"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
|
||||
if merchantUid == "" {
|
||||
keyDataJSON.Msg = "请选择需要下发的商户"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if bankUid == "" {
|
||||
keyDataJSON.Msg = "请选择发下银行卡"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
money, err := strconv.ParseFloat(payForAmount, 64)
|
||||
if err != nil {
|
||||
logs.Error("add pay for fail: ", err)
|
||||
keyDataJSON.Msg = "下发金额输入不正确"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
accountInfo := models.GetAccountByUid(merchantUid)
|
||||
if accountInfo.SettleAmount < money+common.PAYFOR_FEE {
|
||||
keyDataJSON.Msg = "用户可用金额不够"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
bankInfo := models.GetBankCardByUid(bankUid)
|
||||
|
||||
if bankInfo.BankNo != bankNo || bankInfo.AccountName != accountName || bankInfo.PhoneNo != phone {
|
||||
keyDataJSON.Msg = "银行卡信息有误,请连接管理员"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
payFor := models.PayforInfo{PayforUid: "pppp" + xid.New().String(), MerchantUid: merchantUid, MerchantName: merchantName, PhoneNo: phone,
|
||||
MerchantOrderId: xid.New().String(), BankOrderId: "4444" + xid.New().String(), PayforFee: common.PAYFOR_FEE, Type: common.SELF_MERCHANT,
|
||||
PayforAmount: money, PayforTotalAmount: money + common.PAYFOR_FEE, BankCode: bankInfo.BankCode, BankName: bankName, IsSend: common.NO,
|
||||
BankAccountName: bankInfo.AccountName, BankAccountNo: bankInfo.BankNo, BankAccountType: bankInfo.BankAccountType, BankAccountAddress: bankAddress,
|
||||
Status: common.PAYFOR_COMFRIM, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertPayfor(payFor) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "代付下发提交失败"
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *AddController) AddSelfPayFor() {
|
||||
bankUid := strings.TrimSpace(c.GetString("bankUid"))
|
||||
bankName := strings.TrimSpace(c.GetString("bankName"))
|
||||
accountName := strings.TrimSpace(c.GetString("accountName"))
|
||||
bankNo := strings.TrimSpace(c.GetString("bankNo"))
|
||||
//cardType := strings.TrimSpace(c.GetString("cardType"))
|
||||
bankAddress := strings.TrimSpace(c.GetString("bankAddress"))
|
||||
phone := strings.TrimSpace(c.GetString("phone"))
|
||||
payForAmount := strings.TrimSpace(c.GetString("payForAmount"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
|
||||
if bankUid == "" {
|
||||
keyDataJSON.Msg = "银行卡uid不能为空,请联系技术人员"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
money, err := strconv.ParseFloat(payForAmount, 64)
|
||||
if err != nil {
|
||||
logs.Error("self payfor money fail: ", err)
|
||||
keyDataJSON.Msg = "输入金额有误,请仔细检查"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
bankInfo := models.GetBankCardByUid(bankUid)
|
||||
|
||||
//需要对前端传入的数据做校验,不能完全相信前端的数据
|
||||
if bankInfo.AccountName != accountName || bankInfo.BankNo != bankNo || bankInfo.PhoneNo != phone {
|
||||
keyDataJSON.Msg = "前端页面数据有篡改,请注意资金安全"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
selfPayFor := models.PayforInfo{PayforUid: "pppp" + xid.New().String(), BankOrderId: "4444" + xid.New().String(), PayforFee: common.ZERO, Type: common.SELF_HELP,
|
||||
PayforAmount: money, PayforTotalAmount: money + common.ZERO, BankCode: bankInfo.BankCode, BankName: bankName, IsSend: common.NO,
|
||||
BankAccountName: bankInfo.AccountName, BankAccountNo: bankInfo.BankNo, BankAccountType: bankInfo.BankAccountType, BankAccountAddress: bankAddress,
|
||||
Status: common.PAYFOR_COMFRIM, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if models.InsertPayfor(selfPayFor) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Msg = "数据处理失败,请重新提交"
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
36
jhboss/controllers/base_controller.go
Normal file
36
jhboss/controllers/base_controller.go
Normal file
@@ -0,0 +1,36 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/8/13 18:09
|
||||
** @Author : yuebin
|
||||
** @File : base_controller
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/13 18:09
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import "github.com/astaxie/beego"
|
||||
|
||||
type BaseController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *BaseController) GenerateJSON(dataJSON interface{}) {
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *BaseController) Prepare() {
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
if !ok || userID == "" {
|
||||
//用户没有登录,或者登录到期了,则跳转登录主页面
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = 404
|
||||
dataJSON.Msg = "登录已经过期!"
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
} else {
|
||||
//重新赋值给session
|
||||
c.SetSession("userID", userID)
|
||||
}
|
||||
}
|
235
jhboss/controllers/datas.go
Normal file
235
jhboss/controllers/datas.go
Normal file
@@ -0,0 +1,235 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/8/16 10:03
|
||||
** @Author : yuebin
|
||||
** @File : datas
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/16 10:03
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"juhe/service/models"
|
||||
)
|
||||
|
||||
type BaseDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
}
|
||||
|
||||
type KeyDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
Key string
|
||||
}
|
||||
|
||||
type MenuDataJSON struct {
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
MenuList []models.MenuInfo
|
||||
}
|
||||
|
||||
type SecondMenuDataJSON struct {
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
SecondMenuList []models.SecondMenuInfo
|
||||
}
|
||||
|
||||
type PowerItemDataJSON struct {
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
PowerItemList []models.PowerInfo
|
||||
}
|
||||
|
||||
type RoleInfoDataJSON struct {
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
Code int
|
||||
Msg string
|
||||
RoleInfoList []models.RoleInfo
|
||||
}
|
||||
|
||||
type DeployTreeJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
Key string
|
||||
AllFirstMenu []models.MenuInfo
|
||||
ShowFirstMenuUid map[string]bool
|
||||
AllSecondMenu []models.SecondMenuInfo
|
||||
ShowSecondMenuUid map[string]bool
|
||||
AllPower []models.PowerInfo
|
||||
ShowPowerUid map[string]bool
|
||||
}
|
||||
|
||||
type OperatorDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
OperatorList []models.UserInfo
|
||||
}
|
||||
|
||||
type EditOperatorDataJSON struct {
|
||||
Code int
|
||||
Msg string
|
||||
OperatorList []models.UserInfo
|
||||
RoleList []models.RoleInfo
|
||||
}
|
||||
|
||||
type BankCardDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
BankCardInfoList []models.BankCardInfo
|
||||
}
|
||||
|
||||
type RoadDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
RoadInfoList []models.RoadInfo
|
||||
RoadPool models.RoadPoolInfo
|
||||
}
|
||||
|
||||
type RoadPoolDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
RoadPoolInfoList []models.RoadPoolInfo
|
||||
}
|
||||
|
||||
type MerchantDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
MerchantList []models.MerchantInfo
|
||||
}
|
||||
|
||||
type MerchantDeployDataJSON struct {
|
||||
Code int
|
||||
Msg string
|
||||
MerchantDeploy models.MerchantDeployInfo
|
||||
}
|
||||
|
||||
type AccountDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AccountList []models.AccountInfo
|
||||
}
|
||||
|
||||
type AccountHistoryDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AccountHistoryList []models.AccountHistoryInfo
|
||||
}
|
||||
|
||||
type AgentDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
AgentList []models.AgentInfo
|
||||
}
|
||||
|
||||
type ProductDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
ProductMap map[string]string
|
||||
}
|
||||
|
||||
type OrderDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
OrderList []models.OrderInfo
|
||||
AllAmount float64
|
||||
SuccessRate string
|
||||
NotifyUrl string
|
||||
}
|
||||
|
||||
type ListDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
List []models.OrderProfitInfo
|
||||
AllAmount float64
|
||||
SupplierProfit float64
|
||||
AgentProfit float64
|
||||
PlatformProfit float64
|
||||
}
|
||||
|
||||
type PayForDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
StartIndex int
|
||||
DisplayCount int
|
||||
CurrentPage int
|
||||
TotalPage int
|
||||
PayForList []models.PayforInfo
|
||||
}
|
||||
|
||||
type BalanceDataJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
Balance float64
|
||||
}
|
||||
|
||||
type NotifyBankOrderIdListJSON struct {
|
||||
Msg string
|
||||
Code int
|
||||
NotifyIdList []string
|
||||
}
|
||||
|
||||
type ProfitListJSON struct {
|
||||
TotalAmount float64
|
||||
PlatformTotalProfit float64
|
||||
AgentTotalProfit float64
|
||||
Msg string
|
||||
Code int
|
||||
ProfitList []models.PlatformProfit
|
||||
}
|
340
jhboss/controllers/delete.go
Normal file
340
jhboss/controllers/delete.go
Normal file
@@ -0,0 +1,340 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/8/21 16:51
|
||||
** @Author : yuebin
|
||||
** @File : delete
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/21 16:51
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"juhe/service/models"
|
||||
"juhe/service/utils"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Deletecontroller struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) Finish() {
|
||||
remainderFirstMenuUid := make([]string, 0)
|
||||
remainderFirstMenu := make([]string, 0)
|
||||
remainderSecondMenuUid := make([]string, 0)
|
||||
remainderSecondMenu := make([]string, 0)
|
||||
remainderPowerId := make([]string, 0)
|
||||
remainderPower := make([]string, 0)
|
||||
allRoleInfo := models.GetRole()
|
||||
//如果有删除任何的东西,需要重新赋值权限
|
||||
for _, r := range allRoleInfo {
|
||||
for _, showFirstUid := range strings.Split(r.ShowFirstUid, "||") {
|
||||
if models.FirstMenuUidIsExists(showFirstUid) {
|
||||
remainderFirstMenuUid = append(remainderFirstMenuUid, showFirstUid)
|
||||
menuInfo := models.GetMenuInfoByMenuUid(showFirstUid)
|
||||
remainderFirstMenu = append(remainderFirstMenu, menuInfo.FirstMenu)
|
||||
}
|
||||
}
|
||||
for _, showSecondUid := range strings.Split(r.ShowSecondUid, "||") {
|
||||
if models.SecondMenuUidIsExists(showSecondUid) {
|
||||
remainderSecondMenuUid = append(remainderSecondMenuUid, showSecondUid)
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(showSecondUid)
|
||||
remainderSecondMenu = append(remainderSecondMenu, secondMenuInfo.SecondMenu)
|
||||
}
|
||||
}
|
||||
for _, showPowerId := range strings.Split(r.ShowPowerUid, "||") {
|
||||
if models.PowerUidExists(showPowerId) {
|
||||
remainderPowerId = append(remainderPowerId, showPowerId)
|
||||
powerInfo := models.GetPowerById(showPowerId)
|
||||
remainderPower = append(remainderPower, powerInfo.PowerItem)
|
||||
}
|
||||
}
|
||||
r.ShowFirstUid = strings.Join(remainderFirstMenuUid, "||")
|
||||
r.ShowFirstMenu = strings.Join(remainderFirstMenu, "||")
|
||||
r.ShowSecondUid = strings.Join(remainderSecondMenuUid, "||")
|
||||
r.ShowSecondMenu = strings.Join(remainderSecondMenu, "||")
|
||||
r.ShowPowerUid = strings.Join(remainderPowerId, "||")
|
||||
r.ShowPower = strings.Join(remainderPower, "||")
|
||||
r.UpdateTime = utils.GetBasicDateTime()
|
||||
models.UpdateRoleInfo(r)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteMenu() {
|
||||
menuUid := c.GetString("menuUid")
|
||||
menuInfo := models.GetMenuInfoByMenuUid(menuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if menuInfo.MenuUid == "" {
|
||||
dataJSON.Msg = "不存在该菜单"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
logs.Info(c.GetSession("userID").(string) + ",执行了删除一级菜单操作")
|
||||
models.DeleteMenuInfo(menuUid)
|
||||
//删除该一级目下下的所有二级目录
|
||||
models.DeleteSecondMenuByFirstMenuUid(menuUid)
|
||||
SortFirstMenuOrder()
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSONP()
|
||||
}
|
||||
|
||||
/*
|
||||
* 对一级菜单重新进行排序
|
||||
*/
|
||||
func SortFirstMenuOrder() {
|
||||
menuInfoList := models.GetMenuAll()
|
||||
sort.Sort(models.MenuInfoSlice(menuInfoList))
|
||||
|
||||
for i := 0; i < len(menuInfoList); i++ {
|
||||
m := menuInfoList[i]
|
||||
m.UpdateTime = utils.GetBasicDateTime()
|
||||
m.MenuOrder = i + 1
|
||||
models.UpdateMenuInfo(m)
|
||||
//对应的二级菜单也应该重新分配顺序号
|
||||
SortSecondMenuOrder(m)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 对二级菜单分配顺序号
|
||||
*/
|
||||
func SortSecondMenuOrder(firstMenuInfo models.MenuInfo) {
|
||||
secondMenuInfoList := models.GetSecondMenuListByFirstMenuUid(firstMenuInfo.MenuUid)
|
||||
for _, sm := range secondMenuInfoList {
|
||||
sm.FirstMenuOrder = firstMenuInfo.MenuOrder
|
||||
sm.UpdateTime = utils.GetBasicDateTime()
|
||||
models.UpdateSecondMenu(sm)
|
||||
//删除下下一级的所有权限项
|
||||
models.DeletePowerBySecondUid(sm.SecondMenuUid)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteSecondMenu() {
|
||||
secondMenuUid := strings.TrimSpace(c.GetString("secondMenuUid"))
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if secondMenuUid == "" || secondMenuInfo.SecondMenuUid == "" {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "该二级菜单不存在"
|
||||
} else {
|
||||
if models.DeleteSecondMenuBySecondMenuUid(secondMenuUid) {
|
||||
dataJSON.Code = 200
|
||||
ml := models.GetSecondMenuLenByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||
//删除该二级页面下的所有权限项
|
||||
models.DeletePowerBySecondUid(secondMenuUid)
|
||||
if ml == 0 {
|
||||
//如果该二级类目已经被全部删除,那么对应的一级类目也应当删除
|
||||
models.DeleteMenuInfo(secondMenuInfo.FirstMenuUid)
|
||||
SortFirstMenuOrder()
|
||||
} else {
|
||||
secondMenuInfoList := models.GetSecondMenuListByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||
sort.Sort(models.SecondMenuSlice(secondMenuInfoList))
|
||||
for i := 0; i < len(secondMenuInfoList); i++ {
|
||||
m := secondMenuInfoList[i]
|
||||
models.UpdateSecondMenuOrderBySecondUid(m.SecondMenuUid, i+1)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "删除失败"
|
||||
}
|
||||
}
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除权限项
|
||||
*/
|
||||
func (c *Deletecontroller) DeletePowerItem() {
|
||||
powerID := strings.TrimSpace(c.GetString("powerID"))
|
||||
models.DeletePowerItemByPowerID(powerID)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = 200
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除角色
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteRole() {
|
||||
roleUid := strings.TrimSpace(c.GetString("roleUid"))
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.DeleteRoleByRoleUid(roleUid) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除操作员
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("userId"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.DeleteUserByUserId(userId) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
}
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteBankCardRecord() {
|
||||
uid := strings.TrimSpace(c.GetString("uid"))
|
||||
|
||||
dataJSON := new(BankCardDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
if models.DeleteBankCardByUid(uid) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除通道操作
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteRoad() {
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
if models.DeleteRoadByRoadUid(roadUid) {
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
params := make(map[string]string)
|
||||
roadPoolInfoList := models.GetAllRollPool(params)
|
||||
//将轮询池中的对应的通道删除
|
||||
for _, roadPoolInfo := range roadPoolInfoList {
|
||||
var uids []string
|
||||
roadInfoList := strings.Split(roadPoolInfo.RoadUidPool, "||")
|
||||
for _, uid := range roadInfoList {
|
||||
if uid != roadUid {
|
||||
uids = append(uids, uid)
|
||||
}
|
||||
}
|
||||
roadPoolInfo.RoadUidPool = strings.Join(uids, "||")
|
||||
roadPoolInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
models.UpdateRoadPool(roadPoolInfo)
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除通道池
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteRoadPool() {
|
||||
roadPoolCode := strings.TrimSpace(c.GetString("roadPoolCode"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = -1
|
||||
|
||||
if models.DeleteRoadPoolByCode(roadPoolCode) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Msg = "删除通道池失败"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除商户
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteMerchant() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if merchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if models.DeleteMerchantByUid(merchantUid) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除账户
|
||||
*/
|
||||
func (c *Deletecontroller) DeleteAccount() {
|
||||
accountUid := strings.TrimSpace(c.GetString("accountUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
models.IsExistByMerchantUid(accountUid)
|
||||
if models.IsExistByMerchantUid(accountUid) || models.IsExistByAgentUid(accountUid) {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "用户还存在,不能删除"
|
||||
} else {
|
||||
if models.DeleteAccountByUid(accountUid) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "删除账户成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "删除账户失败"
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteAgent() {
|
||||
agentUid := strings.TrimSpace(c.GetString("agentUid"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
//判断是否有商户还绑定了该代理
|
||||
if models.IsExistMerchantByAgentUid(agentUid) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "已有商户绑定改代理,不能删除"
|
||||
} else {
|
||||
if models.DeleteAgentByAgentUid(agentUid) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "删除失败"
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *Deletecontroller) DeleteAgentRelation() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if merchantInfo.MerchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "不存在这样的商户"
|
||||
} else {
|
||||
merchantInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
merchantInfo.BelongAgentUid = ""
|
||||
merchantInfo.BelongAgentName = ""
|
||||
|
||||
if !models.UpdateMerchant(merchantInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "更新商户失败"
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(merchantInfo)
|
||||
}
|
56
jhboss/controllers/filter.go
Normal file
56
jhboss/controllers/filter.go
Normal file
@@ -0,0 +1,56 @@
|
||||
/***************************************************
|
||||
** @Desc : 过滤功能
|
||||
** @Time : 2019/8/8 16:10
|
||||
** @Author : yuebin
|
||||
** @File : filter
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/8 16:10
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FilterController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
var FilterLogin = func(ctx *context.Context) {
|
||||
userID, ok := ctx.Input.Session("userID").(string)
|
||||
if !ok || userID == "" {
|
||||
if !strings.Contains(ctx.Request.RequestURI, "/login.html") &&
|
||||
!strings.Contains(ctx.Request.RequestURI, "/getVerifyImg") &&
|
||||
!strings.Contains(ctx.Request.RequestURI, "/favicon.ico") &&
|
||||
!ctx.Input.IsAjax() {
|
||||
ctx.Redirect(302, "/login.html")
|
||||
}
|
||||
} else {
|
||||
if strings.Contains(ctx.Request.RequestURI, "/login.html") {
|
||||
ctx.Redirect(302, "/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//jsonp请求过来的函数
|
||||
func (c *FilterController) Filter() {
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
|
||||
dataJSON := new(struct {
|
||||
Code int
|
||||
})
|
||||
|
||||
if !ok || userID == "" {
|
||||
dataJSON.Code = 404
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
c.SetSession("userID", userID)
|
||||
}
|
||||
fmt.Println(dataJSON)
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
1006
jhboss/controllers/get.go
Normal file
1006
jhboss/controllers/get.go
Normal file
File diff suppressed because it is too large
Load Diff
106
jhboss/controllers/login.go
Normal file
106
jhboss/controllers/login.go
Normal file
@@ -0,0 +1,106 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/validation"
|
||||
"juhe/service/common"
|
||||
"juhe/service/models"
|
||||
"juhe/service/utils"
|
||||
)
|
||||
|
||||
type LoginController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *LoginController) Prepare() {
|
||||
|
||||
}
|
||||
|
||||
func (c *LoginController) Login() {
|
||||
|
||||
userID := c.GetString("userID")
|
||||
passWD := c.GetString("passwd")
|
||||
code := c.GetString("Code")
|
||||
|
||||
dataJSON := new(KeyDataJSON)
|
||||
|
||||
valid := validation.Validation{}
|
||||
|
||||
if v := valid.Required(userID, "userID"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "手机号不能为空!"
|
||||
} else if v := valid.Required(passWD, "passWD"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "登录密码不能为空!"
|
||||
} else if v := valid.Length(code, common.VERIFY_CODE_LEN, "code"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "验证码不正确!"
|
||||
}
|
||||
|
||||
userInfo := models.GetUserInfoByUserID(userID)
|
||||
|
||||
if userInfo.UserId == "" {
|
||||
dataJSON.Key = "userID"
|
||||
dataJSON.Msg = "用户不存在,请求联系管理员!"
|
||||
} else {
|
||||
codeInterface := c.GetSession("verifyCode")
|
||||
if userInfo.Passwd != utils.GetMD5Upper(passWD) {
|
||||
dataJSON.Key = "passWD"
|
||||
dataJSON.Msg = "密码不正确!"
|
||||
} else if codeInterface == nil {
|
||||
dataJSON.Key = "code"
|
||||
dataJSON.Msg = "验证码失效!"
|
||||
} else if code != codeInterface.(string) {
|
||||
dataJSON.Key = "code"
|
||||
dataJSON.Msg = "验证码不正确!"
|
||||
} else if userInfo.Status == "unactive" {
|
||||
dataJSON.Key = "unactive"
|
||||
dataJSON.Msg = "用户已被冻结!"
|
||||
} else if userInfo.Status == "del" {
|
||||
dataJSON.Key = "del"
|
||||
dataJSON.Msg = "用户已被删除!"
|
||||
}
|
||||
}
|
||||
|
||||
go func() {
|
||||
userInfo.Ip = c.Ctx.Input.IP()
|
||||
models.UpdateUserInfoIP(userInfo)
|
||||
}()
|
||||
|
||||
if dataJSON.Key == "" {
|
||||
c.SetSession("userID", userID)
|
||||
c.DelSession("verifyCode")
|
||||
}
|
||||
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 退出登录,删除session中的数据,避免数据量过大,内存吃紧
|
||||
*/
|
||||
|
||||
func (c *LoginController) Logout() {
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
c.DelSession("userID")
|
||||
dataJSON.Code = 200
|
||||
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 验证码获取,如果获取成功,并将验证码存到session中
|
||||
*/
|
||||
func (c *LoginController) GetVerifyImg() {
|
||||
Image, verifyCode := utils.GenerateVerifyCodeImg()
|
||||
if Image == nil || len(verifyCode) != common.VERIFY_CODE_LEN {
|
||||
logs.Error("获取验证码图片失败!")
|
||||
} else {
|
||||
c.SetSession("verifyCode", verifyCode)
|
||||
}
|
||||
logs.Info("验证码:", verifyCode)
|
||||
Image.WriteTo(c.Ctx.ResponseWriter)
|
||||
}
|
132
jhboss/controllers/page_controller.go
Normal file
132
jhboss/controllers/page_controller.go
Normal file
@@ -0,0 +1,132 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/10/23 15:20
|
||||
** @Author : yuebin
|
||||
** @File : page_controller
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/23 15:20
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import "github.com/astaxie/beego"
|
||||
|
||||
type PageController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *PageController) Index() {
|
||||
c.TplName = "index.html"
|
||||
}
|
||||
|
||||
func (c *PageController) LoginPage() {
|
||||
c.TplName = "login.html"
|
||||
}
|
||||
|
||||
func (c *PageController) AccountPage() {
|
||||
c.TplName = "account.html"
|
||||
}
|
||||
|
||||
func (c *PageController) AccountHistoryPage() {
|
||||
c.TplName = "account_history.html"
|
||||
}
|
||||
|
||||
func (c *PageController) BankCardPage() {
|
||||
c.TplName = "bank_card.html"
|
||||
}
|
||||
|
||||
func (c *PageController) CreateAgentPage() {
|
||||
c.TplName = "create_agent.html"
|
||||
}
|
||||
|
||||
func (c *PageController) EditRolePage() {
|
||||
c.TplName = "edit_role.html"
|
||||
}
|
||||
|
||||
func (c *PageController) FirstMenuPage() {
|
||||
c.TplName = "first_menu.html"
|
||||
}
|
||||
|
||||
func (c *PageController) MainPage() {
|
||||
c.TplName = "main.html"
|
||||
}
|
||||
|
||||
func (c *PageController) MenuPage() {
|
||||
c.TplName = "menu.html"
|
||||
}
|
||||
|
||||
func (c *PageController) MerchantPage() {
|
||||
c.TplName = "merchant.html"
|
||||
}
|
||||
|
||||
func (c *PageController) OperatorPage() {
|
||||
c.TplName = "operator.html"
|
||||
}
|
||||
|
||||
func (c *PageController) PowerPage() {
|
||||
c.TplName = "power.html"
|
||||
}
|
||||
|
||||
func (c *PageController) RoadPage() {
|
||||
c.TplName = "road.html"
|
||||
}
|
||||
|
||||
func (c *PageController) RoadPoolPage() {
|
||||
c.TplName = "road_pool.html"
|
||||
}
|
||||
|
||||
func (c *PageController) RoadProfitPage() {
|
||||
c.TplName = "road_profit.html"
|
||||
}
|
||||
|
||||
func (c *PageController) RolePage() {
|
||||
c.TplName = "role.html"
|
||||
}
|
||||
|
||||
func (c *PageController) SecondMenuPage() {
|
||||
c.TplName = "second_menu.html"
|
||||
}
|
||||
|
||||
func (c *PageController) OrderInfoPage() {
|
||||
c.TplName = "order_info.html"
|
||||
}
|
||||
|
||||
func (c *PageController) OrderProfitPage() {
|
||||
c.TplName = "order_profit.html"
|
||||
}
|
||||
|
||||
func (c *PageController) MerchantPayforPage() {
|
||||
c.TplName = "merchant_payfor.html"
|
||||
}
|
||||
|
||||
func (c *PageController) SelfPayforPage() {
|
||||
c.TplName = "self_payfor.html"
|
||||
}
|
||||
|
||||
func (c *PageController) PayforRecordPage() {
|
||||
c.TplName = "payfor_record.html"
|
||||
}
|
||||
|
||||
func (c *PageController) ConfirmPage() {
|
||||
c.TplName = "confirm.html"
|
||||
}
|
||||
|
||||
func (c *PageController) SelfNotifyPage() {
|
||||
c.TplName = "self_notify.html"
|
||||
}
|
||||
|
||||
func (c *PageController) SelfPlusSubPage() {
|
||||
c.TplName = "self_plus_sub.html"
|
||||
}
|
||||
|
||||
func (c *PageController) AgentToMerchantPage() {
|
||||
c.TplName = "agent_to_merchant.html"
|
||||
}
|
||||
|
||||
func (c *PageController) PlatFormProfitPage() {
|
||||
c.TplName = "platform_profit.html"
|
||||
}
|
||||
|
||||
func (c *PageController) AgentProfitPage() {
|
||||
c.TplName = "agent_profit.html"
|
||||
}
|
102
jhboss/controllers/query.go
Normal file
102
jhboss/controllers/query.go
Normal file
@@ -0,0 +1,102 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/6 14:03
|
||||
** @Author : yuebin
|
||||
** @File : query.go
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/6 14:03
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"juhe/service/common"
|
||||
"juhe/service/controller"
|
||||
"juhe/service/models"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SupplierQuery struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func OrderQuery(bankOrderId string) string {
|
||||
|
||||
orderInfo := models.GetOrderByBankOrderId(bankOrderId)
|
||||
|
||||
if orderInfo.BankOrderId == "" || len(orderInfo.BankOrderId) == 0 {
|
||||
logs.Error("不存在这样的订单,订单查询结束")
|
||||
return "不存在这样的订单"
|
||||
}
|
||||
|
||||
if orderInfo.Status != "" && orderInfo.Status != "wait" {
|
||||
logs.Error(fmt.Sprintf("该订单=%s,已经处理完毕,", bankOrderId))
|
||||
return "该订单已经处理完毕"
|
||||
}
|
||||
|
||||
supplierCode := orderInfo.PayProductCode
|
||||
supplier := controller.GetPaySupplierByCode(supplierCode)
|
||||
|
||||
flag := supplier.PayQuery(orderInfo)
|
||||
if flag {
|
||||
return "查询完毕,返回正确结果"
|
||||
} else {
|
||||
return "订单还在处理中"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (c *SupplierQuery) SupplierOrderQuery() {
|
||||
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
exist := models.BankOrderIdIsEixst(bankOrderId)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if !exist {
|
||||
keyDataJSON.Msg = "该订单不存在"
|
||||
}
|
||||
|
||||
msg := OrderQuery(bankOrderId)
|
||||
|
||||
keyDataJSON.Msg = msg
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
/*
|
||||
* 向上游查询代付结果
|
||||
*/
|
||||
func (c *SupplierQuery) SupplierPayForQuery() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if bankOrderId == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "不存在这样的代付订单"
|
||||
} else {
|
||||
payFor := models.GetPayForByBankOrderId(bankOrderId)
|
||||
if payFor.RoadUid == "" {
|
||||
keyDataJSON.Msg = "该代付订单没有对应的通道uid"
|
||||
} else {
|
||||
roadInfo := models.GetRoadInfoByRoadUid(payFor.RoadUid)
|
||||
supplier := controller.GetPaySupplierByCode(roadInfo.ProductUid)
|
||||
result, msg := supplier.PayForQuery(payFor)
|
||||
keyDataJSON.Msg = msg
|
||||
if result == common.PAYFOR_SUCCESS {
|
||||
controller.PayForSuccess(payFor)
|
||||
} else if result == common.PAYFOR_FAIL {
|
||||
controller.PayForFail(payFor)
|
||||
} else {
|
||||
logs.Info("银行处理中")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
}
|
75
jhboss/controllers/send_notify_merchant.go
Normal file
75
jhboss/controllers/send_notify_merchant.go
Normal file
@@ -0,0 +1,75 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/12/8 22:15
|
||||
** @Author : yuebin
|
||||
** @File : send_notify_merchant
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/12/8 22:15
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/httplib"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"juhe/service/common"
|
||||
"juhe/service/models"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SendNotify struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (c *SendNotify) SendNotifyToMerchant() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = -1
|
||||
orderInfo := models.GetOrderByBankOrderId(bankOrderId)
|
||||
if orderInfo.Status == common.WAIT {
|
||||
keyDataJSON.Msg = "该订单不是成功状态,不能回调"
|
||||
} else {
|
||||
notifyInfo := models.GetNotifyInfoByBankOrderId(bankOrderId)
|
||||
notifyUrl := notifyInfo.Url
|
||||
logs.Info(fmt.Sprintf("boss管理后台手动触发订单回调,url=%s", notifyUrl))
|
||||
req := httplib.Post(notifyUrl)
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
logs.Error("回调发送失败,fail:", err)
|
||||
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送失败,订单回调,fail:%s", err)
|
||||
} else {
|
||||
if !strings.Contains(strings.ToLower(response), "success") {
|
||||
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送成功,但是未返回success字段, 商户返回内容=%s", response)
|
||||
} else {
|
||||
keyDataJSON.Code = 200
|
||||
keyDataJSON.Msg = fmt.Sprintf("该订单回调发送成功")
|
||||
}
|
||||
}
|
||||
}
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *SendNotify) SelfSendNotify() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
notifyInfo := models.GetNotifyInfoByBankOrderId(bankOrderId)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
req := httplib.Post(notifyInfo.Url)
|
||||
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
keyDataJSON.Msg = fmt.Sprintf("订单 bankOrderId=%s,已经发送回调出错:%s", bankOrderId, err)
|
||||
} else {
|
||||
keyDataJSON.Msg = fmt.Sprintf("订单 bankOrderId=%s,已经发送回调,商户返回内容:%s", bankOrderId, response)
|
||||
}
|
||||
|
||||
c.Data["json"] = keyDataJSON
|
||||
c.ServeJSON()
|
||||
}
|
51
jhboss/controllers/test.go
Normal file
51
jhboss/controllers/test.go
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/9/20 14:38
|
||||
** @Author : yuebin
|
||||
** @File : test
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/9/20 14:38
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/httplib"
|
||||
)
|
||||
|
||||
const HOST = "https://gw.open.icbc.com.cn/ui/b2c/pay/transfer/V2"
|
||||
|
||||
func (c *BaseController) Test() {
|
||||
//sign := c.GetString("sign")
|
||||
msg_id := c.GetString("msg_id")
|
||||
app_id := c.GetString("app_id")
|
||||
sign_type := c.GetString("sign_type")
|
||||
timestamp := c.GetString("timestamp")
|
||||
//host := HOST + "&sign=" + sign + "&msg_id=" + msg_id + "&app_id=" + app_id + "&sign_type=" + sign_type + "×tamp=" + timestamp
|
||||
biz_content := c.GetString("biz_content")
|
||||
clientType := c.GetString("clientType")
|
||||
interfaceVersion := c.GetString("interfaceVersion")
|
||||
interfaceName := c.GetString("interfaceName")
|
||||
notify_url := c.GetString("notify_url")
|
||||
ca := c.GetString("ca")
|
||||
req := httplib.Post(HOST)
|
||||
//req.Header("Content‐Type", "application/x‐www‐form‐urlencoded")
|
||||
req.Header("charset", "GBK")
|
||||
req.Param("charset", "UTF-8")
|
||||
req.Param("format", "json")
|
||||
req.Param("sign", "ERERERERERERERE")
|
||||
req.Param("msg_id", msg_id)
|
||||
req.Param("app_id", app_id)
|
||||
req.Param("sign_type", sign_type)
|
||||
req.Param("timestamp", timestamp)
|
||||
req.Param("biz_content", biz_content)
|
||||
req.Param("clientType", clientType)
|
||||
req.Param("interfaceVersion", interfaceVersion)
|
||||
req.Param("interfaceName", interfaceName)
|
||||
req.Param("notify_url", notify_url)
|
||||
req.Param("ca", ca)
|
||||
|
||||
res, _ := req.String()
|
||||
c.Ctx.WriteString(res)
|
||||
c.ServeJSON()
|
||||
}
|
592
jhboss/controllers/update.go
Normal file
592
jhboss/controllers/update.go
Normal file
@@ -0,0 +1,592 @@
|
||||
/***************************************************
|
||||
** @Desc : c file for ...
|
||||
** @Time : 2019/8/16 9:49
|
||||
** @Author : yuebin
|
||||
** @File : update
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/16 9:49
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/astaxie/beego/validation"
|
||||
"juhe/service/common"
|
||||
"juhe/service/controller"
|
||||
"juhe/service/models"
|
||||
"juhe/service/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type UpdateController struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
/*
|
||||
*更新密码
|
||||
*/
|
||||
func (c *UpdateController) UpdatePassword() {
|
||||
oldPassword := c.GetString("oldPassword")
|
||||
newPassword := c.GetString("newPassword")
|
||||
twicePassword := c.GetString("twicePassword")
|
||||
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
|
||||
dataJSON := new(KeyDataJSON)
|
||||
dataJSON.Code = -1
|
||||
if !ok || userID == "" {
|
||||
dataJSON.Code = 404
|
||||
dataJSON.Msg = "请重新登录!"
|
||||
} else {
|
||||
userInfo := models.GetUserInfoByUserID(userID)
|
||||
valid := validation.Validation{}
|
||||
if userInfo.Passwd != utils.GetMD5Upper(oldPassword) {
|
||||
dataJSON.Key = ".old-error"
|
||||
dataJSON.Msg = "输入密码不正确"
|
||||
} else if v := valid.Min(len(newPassword), 8, ".new-error"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "新密码长度必须大于等于8个字符!"
|
||||
} else if v := valid.Max(len(newPassword), 16, ".new-error"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "新密码长度不能大于16个字符!"
|
||||
} else if v := valid.AlphaNumeric(newPassword, ".new-error"); !v.Ok {
|
||||
dataJSON.Key = v.Error.Key
|
||||
dataJSON.Msg = "新密码必须有数字和字母组成!"
|
||||
} else if newPassword != twicePassword {
|
||||
dataJSON.Key = ".twice-error"
|
||||
dataJSON.Msg = "两次密码不一致!"
|
||||
} else {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "密码修改成功!"
|
||||
//删除原先的session状态
|
||||
c.DelSession("userID")
|
||||
//更新数据库的密码
|
||||
userInfo.Passwd = utils.GetMD5Upper(newPassword)
|
||||
models.UpdateUserInfoPassword(userInfo)
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新菜单的排列顺序
|
||||
*/
|
||||
func (c *UpdateController) UpMenu() {
|
||||
menuUid := c.GetString("menuUid")
|
||||
menuInfo := models.GetMenuInfoByMenuUid(menuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if menuInfo.MenuUid == "" {
|
||||
dataJSON.Msg = "更改排列顺序失败"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
exist := models.MenuOrderIsExists(menuInfo.MenuOrder - 1)
|
||||
if !exist {
|
||||
dataJSON.Msg = "已经是最高的顺序"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
//如果他前面有菜单,那么交换他们的menuOrder
|
||||
preMenuInfo := models.GetMenuInfoByMenuOrder(menuInfo.MenuOrder - 1)
|
||||
menuInfo.MenuOrder = menuInfo.MenuOrder - 1
|
||||
preMenuInfo.MenuOrder = preMenuInfo.MenuOrder + 1
|
||||
preMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
menuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
//更新菜单表
|
||||
models.UpdateMenuInfo(preMenuInfo)
|
||||
models.UpdateMenuInfo(menuInfo)
|
||||
//更新二级菜单表
|
||||
SortSecondMenuOrder(preMenuInfo)
|
||||
SortSecondMenuOrder(menuInfo)
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
func (c *UpdateController) DownMenu() {
|
||||
menuUid := c.GetString("menuUid")
|
||||
menuInfo := models.GetMenuInfoByMenuUid(menuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if menuInfo.MenuUid == "" {
|
||||
dataJSON.Msg = "更改排列顺序失败"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
exist := models.MenuOrderIsExists(menuInfo.MenuOrder + 1)
|
||||
if !exist {
|
||||
dataJSON.Msg = "已经是最高的顺序"
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
//如果他前面有菜单,那么交换他们的menuOrder
|
||||
lastMenuInfo := models.GetMenuInfoByMenuOrder(menuInfo.MenuOrder + 1)
|
||||
menuInfo.MenuOrder = menuInfo.MenuOrder + 1
|
||||
lastMenuInfo.MenuOrder = lastMenuInfo.MenuOrder - 1
|
||||
lastMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
menuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
//更新菜单表
|
||||
models.UpdateMenuInfo(lastMenuInfo)
|
||||
models.UpdateMenuInfo(menuInfo)
|
||||
//更新二级菜单表
|
||||
SortSecondMenuOrder(lastMenuInfo)
|
||||
SortSecondMenuOrder(menuInfo)
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 提升二级菜单的顺序号
|
||||
*/
|
||||
func (c *UpdateController) UpSecondMenu() {
|
||||
secondMenuUid := c.GetString("secondMenuUid")
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if secondMenuInfo.MenuOrder == 1 {
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
preSecondMenuInfo := models.GetSecondMenuInfoByMenuOrder(secondMenuInfo.MenuOrder-1, secondMenuInfo.FirstMenuUid)
|
||||
preSecondMenuInfo.MenuOrder = preSecondMenuInfo.MenuOrder + 1
|
||||
preSecondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
secondMenuInfo.MenuOrder = secondMenuInfo.MenuOrder - 1
|
||||
secondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
//更新二级菜单项
|
||||
models.UpdateSecondMenu(preSecondMenuInfo)
|
||||
models.UpdateSecondMenu(secondMenuInfo)
|
||||
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 降低二级菜单的顺序号
|
||||
*/
|
||||
func (c *UpdateController) DownSecondMenu() {
|
||||
secondMenuUid := c.GetString("secondMenuUid")
|
||||
secondMenuInfo := models.GetSecondMenuInfoBySecondMenuUid(secondMenuUid)
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
l := models.GetSecondMenuLenByFirstMenuUid(secondMenuInfo.FirstMenuUid)
|
||||
if l == secondMenuInfo.MenuOrder {
|
||||
dataJSON.Code = -1
|
||||
} else {
|
||||
lastSecondMenu := models.GetSecondMenuInfoByMenuOrder(secondMenuInfo.MenuOrder+1, secondMenuInfo.FirstMenuUid)
|
||||
lastSecondMenu.MenuOrder = lastSecondMenu.MenuOrder - 1
|
||||
lastSecondMenu.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
secondMenuInfo.MenuOrder = secondMenuInfo.MenuOrder + 1
|
||||
secondMenuInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
models.UpdateSecondMenu(lastSecondMenu)
|
||||
models.UpdateSecondMenu(secondMenuInfo)
|
||||
|
||||
dataJSON.Code = 200
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) FreezeOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("operatorName"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.UpdateStauts("unactive", userId) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "冻结成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "冻结失败"
|
||||
}
|
||||
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) UnfreezeOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("operatorName"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
|
||||
if models.UpdateStauts("active", userId) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "解冻成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "解冻失败"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) EditOperator() {
|
||||
userId := strings.TrimSpace(c.GetString("userId"))
|
||||
password := strings.TrimSpace(c.GetString("password"))
|
||||
changePassword := strings.TrimSpace(c.GetString("changePassword"))
|
||||
role := strings.TrimSpace(c.GetString("role"))
|
||||
nick := strings.TrimSpace(c.GetString("nick"))
|
||||
remark := strings.TrimSpace(c.GetString("remark"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
|
||||
if (len(password) > 0 || len(changePassword) > 0) && password != changePassword {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".veritfy-operator-password-error"
|
||||
keyDataJSON.Msg = "*2次密码输入不一致"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
if role == "" || role == "none" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = ".change-operator-role-error"
|
||||
keyDataJSON.Msg = "*角色不能为空"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
userInfo := models.GetUserInfoByUserID(userId)
|
||||
if userInfo.UserId == "" {
|
||||
keyDataJSON.Code = -2
|
||||
keyDataJSON.Msg = "该用户不存在"
|
||||
} else {
|
||||
userInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
userInfo.Remark = remark
|
||||
roleInfo := models.GetRoleByRoleUid(role)
|
||||
userInfo.RoleName = roleInfo.RoleName
|
||||
userInfo.Role = role
|
||||
if len(password) > 0 && len(changePassword) > 0 && password == changePassword {
|
||||
userInfo.Passwd = utils.GetMD5Upper(password)
|
||||
}
|
||||
userInfo.Nick = nick
|
||||
models.UpdateUserInfo(userInfo)
|
||||
keyDataJSON.Code = 200
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新通道的状态
|
||||
*/
|
||||
func (c *UpdateController) UpdateRoadStatus() {
|
||||
roadUid := strings.TrimSpace(c.GetString("roadUid"))
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON.Code = 200
|
||||
|
||||
roadInfo := models.GetRoadInfoByRoadUid(roadUid)
|
||||
if roadInfo.Status == "active" {
|
||||
roadInfo.Status = "unactive"
|
||||
} else {
|
||||
roadInfo.Status = "active"
|
||||
}
|
||||
if models.UpdateRoadInfo(roadInfo) {
|
||||
dataJSON.Code = 200
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 冻结商户
|
||||
*/
|
||||
func (c *UpdateController) UpdateMerchantStatus() {
|
||||
merchantUid := strings.TrimSpace(c.GetString("merchantUid"))
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
if merchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
merchantInfo := models.GetMerchantByUid(merchantUid)
|
||||
|
||||
if merchantInfo.MerchantUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if merchantInfo.Status == "active" {
|
||||
merchantInfo.Status = "unactive"
|
||||
} else {
|
||||
merchantInfo.Status = "active"
|
||||
}
|
||||
merchantInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
if models.UpdateMerchant(merchantInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新账户的状态
|
||||
*/
|
||||
func (c *UpdateController) UpdateAccountStatus() {
|
||||
accountUid := strings.TrimSpace(c.GetString("accountUid"))
|
||||
|
||||
accountInfo := models.GetAccountByUid(accountUid)
|
||||
if accountInfo.Status == "active" {
|
||||
accountInfo.Status = "unactive"
|
||||
} else {
|
||||
accountInfo.Status = "active"
|
||||
}
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
dataJSON := new(BaseDataJSON)
|
||||
if models.UpdateAccount(accountInfo) {
|
||||
dataJSON.Code = 200
|
||||
dataJSON.Msg = "更新账户状态成功"
|
||||
} else {
|
||||
dataJSON.Code = -1
|
||||
dataJSON.Msg = "更新账户状态失败"
|
||||
}
|
||||
c.GenerateJSON(dataJSON)
|
||||
}
|
||||
func (c *UpdateController) OperatorAccount() {
|
||||
accountUid := strings.TrimSpace(c.GetString("accountUid"))
|
||||
accountOperator := strings.TrimSpace(c.GetString("accountOperator"))
|
||||
amount := strings.TrimSpace(c.GetString("amount"))
|
||||
|
||||
accountDataJSON := new(AccountDataJSON)
|
||||
switch accountOperator {
|
||||
case common.PLUS_AMOUNT:
|
||||
case common.SUB_AMOUNT:
|
||||
case common.FREEZE_AMOUNT:
|
||||
case common.UNFREEZE_AMOUNT:
|
||||
default:
|
||||
accountDataJSON.Code = -1
|
||||
}
|
||||
a, err := strconv.ParseFloat(amount, 64)
|
||||
if err != nil {
|
||||
accountDataJSON.Msg = "处理金额输入有误"
|
||||
}
|
||||
if accountDataJSON.Code == -1 {
|
||||
c.GenerateJSON(accountDataJSON)
|
||||
return
|
||||
}
|
||||
msg, flag := models.OperatorAccount(accountUid, accountOperator, a)
|
||||
if flag {
|
||||
accountDataJSON.Code = 200
|
||||
accountDataJSON.Msg = "处理成功,请检查对应账户信息"
|
||||
accountDataJSON.AccountList = append(accountDataJSON.AccountList, models.GetAccountByUid(accountUid))
|
||||
} else {
|
||||
accountDataJSON.Code = -1
|
||||
accountDataJSON.Msg = msg
|
||||
}
|
||||
|
||||
c.GenerateJSON(accountDataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) UpdateAgentStatus() {
|
||||
agentUid := strings.TrimSpace(c.GetString("agentUid"))
|
||||
agentInfo := models.GetAgentInfoByAgentUid(agentUid)
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
|
||||
if agentInfo.AgentUid == "" {
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
if agentInfo.Status == "active" {
|
||||
agentInfo.Status = "unactive"
|
||||
} else {
|
||||
agentInfo.Status = "active"
|
||||
}
|
||||
agentInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if models.UpdateAgentInfo(agentInfo) {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) ResetAgentPassword() {
|
||||
agentUid := strings.TrimSpace(c.GetString("agentUid"))
|
||||
newPassword := strings.TrimSpace(c.GetString("newPassword"))
|
||||
newVertifyPassword := strings.TrimSpace(c.GetString("newVertifyPassword"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
if agentUid == "" {
|
||||
keyDataJSON.Code = -2
|
||||
} else if newPassword == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-login-password-error-reset"
|
||||
keyDataJSON.Msg = " *新密码不能为空"
|
||||
} else if newVertifyPassword != newPassword {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Key = "#agent-vertify-password-error-reset"
|
||||
keyDataJSON.Msg = " *两次密码输入不一致"
|
||||
}
|
||||
|
||||
if keyDataJSON.Code != 200 {
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
agentInfo := models.GetAgentInfoByAgentUid(agentUid)
|
||||
agentInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
agentInfo.AgentPassword = utils.GetMD5Upper(newPassword)
|
||||
if !models.UpdateAgentInfo(agentInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 手动选择了打款通道
|
||||
*/
|
||||
func (c *UpdateController) ChoosePayForRoad() {
|
||||
roadName := strings.TrimSpace(c.GetString("roadName"))
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
remark := strings.TrimSpace(c.GetString("remark"))
|
||||
confirmType := strings.TrimSpace(c.GetString("confirmType"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if confirmType == common.PAYFOR_ROAD && roadName == "" {
|
||||
keyDataJSON.Msg = "打款通道不能为空"
|
||||
keyDataJSON.Code = -1
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
payForInfo := models.GetPayForByBankOrderId(bankOrderId)
|
||||
roadInfo := models.GetRoadInfoByName(roadName)
|
||||
|
||||
if payForInfo.Status != common.PAYFOR_COMFRIM {
|
||||
keyDataJSON.Msg = "结算状态错误,请刷新后确认"
|
||||
} else {
|
||||
payForInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
payForInfo.GiveType = confirmType
|
||||
if confirmType == common.PAYFOR_REFUSE {
|
||||
//拒绝打款
|
||||
payForInfo.Status = common.PAYFOR_FAIL
|
||||
} else {
|
||||
payForInfo.Status = common.PAYFOR_SOLVING
|
||||
}
|
||||
payForInfo.RoadUid = roadInfo.RoadUid
|
||||
payForInfo.RoadName = roadInfo.RoadName
|
||||
payForInfo.Remark = remark
|
||||
|
||||
if !models.ForUpdatePayFor(payForInfo) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "更新代付记录失败"
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
/*
|
||||
* 处理打款结果的处理
|
||||
*/
|
||||
func (c *UpdateController) ResultPayFor() {
|
||||
resultType := strings.TrimSpace(c.GetString("resultType"))
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
keyDataJSON.Code = 200
|
||||
|
||||
if resultType == "" || bankOrderId == "" {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "提交的数据有误"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
payFor := models.GetPayForByBankOrderId(bankOrderId)
|
||||
|
||||
if payFor.Type == common.SELF_HELP {
|
||||
//如果是管理员在后台提现,不用做任何的商户减款,只需要更新代付订单状态
|
||||
payFor.UpdateTime = utils.GetBasicDateTime()
|
||||
payFor.Status = resultType
|
||||
|
||||
if !models.ForUpdatePayFor(payFor) {
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "系统处理失败"
|
||||
}
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if payFor.Status == common.PAYFOR_FAIL || payFor.Status == common.PAYFOR_SUCCESS {
|
||||
logs.Error(fmt.Sprintf("该代付订单=%s,状态有误....", bankOrderId))
|
||||
keyDataJSON.Code = -1
|
||||
keyDataJSON.Msg = "订单状态有误,请刷新重新判断"
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
return
|
||||
}
|
||||
|
||||
if resultType == common.PAYFOR_FAIL {
|
||||
//处理代付失败的逻辑,减去相应的代付冻结金额
|
||||
if !controller.PayForFail(payFor) {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,处理代付失败逻辑出错", payFor.MerchantUid))
|
||||
keyDataJSON.Msg = "代付失败逻辑,处理失败"
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
} else if resultType == common.PAYFOR_SUCCESS {
|
||||
//代付成功,减去相应的代付冻结金额,并且余额减掉,可用金额减掉
|
||||
if !controller.PayForSuccess(payFor) {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,处理代付成功逻辑出错", payFor.MerchantUid))
|
||||
keyDataJSON.Msg = "代付成功逻辑,处理失败"
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
}
|
||||
|
||||
if keyDataJSON.Code == 200 {
|
||||
keyDataJSON.Msg = "处理成功"
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
||||
|
||||
func (c *UpdateController) UpdateOrderStatus() {
|
||||
bankOrderId := strings.TrimSpace(c.GetString("bankOrderId"))
|
||||
solveType := strings.TrimSpace(c.GetString("solveType"))
|
||||
|
||||
keyDataJSON := new(KeyDataJSON)
|
||||
orderInfo := models.GetOrderByBankOrderId(bankOrderId)
|
||||
if orderInfo.BankOrderId == "" {
|
||||
logs.Error("该订单不存在,bankOrderId=", bankOrderId)
|
||||
keyDataJSON.Code = -1
|
||||
} else {
|
||||
paySolve := new(controller.PaySolveController)
|
||||
flag := false
|
||||
switch solveType {
|
||||
case common.SUCCESS:
|
||||
flag = paySolve.SolvePaySuccess(bankOrderId, orderInfo.FactAmount, common.SUCCESS)
|
||||
case common.FAIL:
|
||||
flag = paySolve.SolvePayFail(orderInfo, common.FAIL)
|
||||
case common.FREEZE_AMOUNT:
|
||||
//将这笔订单进行冻结
|
||||
flag = paySolve.SolveOrderFreeze(bankOrderId)
|
||||
case common.UNFREEZE_AMOUNT:
|
||||
//将这笔订单金额解冻
|
||||
flag = paySolve.SolveOrderUnfreeze(bankOrderId)
|
||||
case common.REFUND:
|
||||
if orderInfo.Status == common.SUCCESS {
|
||||
flag = paySolve.SolveRefund(bankOrderId)
|
||||
}
|
||||
case common.ORDERROLL:
|
||||
if orderInfo.Status == common.SUCCESS {
|
||||
flag = paySolve.SolveOrderRoll(bankOrderId)
|
||||
}
|
||||
default:
|
||||
logs.Error("不存在这样的处理类型")
|
||||
}
|
||||
if flag {
|
||||
keyDataJSON.Code = 200
|
||||
} else {
|
||||
keyDataJSON.Code = -1
|
||||
}
|
||||
}
|
||||
|
||||
c.GenerateJSON(keyDataJSON)
|
||||
}
|
Reference in New Issue
Block a user