Compare commits
No commits in common. "6e6e01a823838f47ecbf8d56c4e0691c0463866e" and "a056e2b26a8568333600fdfcf2b0e1978a965bb9" have entirely different histories.
6e6e01a823
...
a056e2b26a
|
@ -19,19 +19,11 @@ const (
|
|||
//系统错误
|
||||
SystemError = 500
|
||||
|
||||
//请求超时
|
||||
RequestTimeOut = 600
|
||||
|
||||
//未登录
|
||||
NotLogin = 1000
|
||||
|
||||
// 商户
|
||||
MerchantNotFound = 1100
|
||||
|
||||
// app
|
||||
AppNotFound = 1200
|
||||
AppDisabled = 1201
|
||||
AppIpNotAllow = 1202
|
||||
)
|
||||
|
||||
var MsgEN = map[int]string{
|
||||
|
@ -49,11 +41,8 @@ var MsgZH = map[int]string{
|
|||
NotFound: "数据不存在",
|
||||
NotAuth: "未经授权",
|
||||
NotLogin: "未登录",
|
||||
RequestTimeOut: "请求超时",
|
||||
|
||||
MerchantNotFound: "商户不存在",
|
||||
AppNotFound: "app_id未找到",
|
||||
AppDisabled: "app通道关闭",
|
||||
AppIpNotAllow: "ip不在白名单内",
|
||||
}
|
||||
var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH}
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package pojo
|
||||
|
||||
const (
|
||||
Rsa int32 = iota + 1
|
||||
Sm2
|
||||
Sm4
|
||||
)
|
|
@ -1,6 +0,0 @@
|
|||
package pojo
|
||||
|
||||
const (
|
||||
STATUS_ENABLE int32 = 1
|
||||
STATUS_DISABLED int32 = 2
|
||||
)
|
|
@ -3,7 +3,6 @@ package data
|
|||
import (
|
||||
"PaymentCenter/app/http/entities"
|
||||
"PaymentCenter/app/models/appmodel"
|
||||
"database/sql"
|
||||
"xorm.io/builder"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
@ -38,12 +37,3 @@ func (m *AppRepo) AppDelete(app *appmodel.App, conn builder.Cond) (int64, error)
|
|||
func (m *AppRepo) AppUpdate(app *appmodel.App, conn builder.Cond, columns ...string) (int64, error) {
|
||||
return m.repo.Where(conn).MustCols(columns...).Update(app)
|
||||
}
|
||||
|
||||
func (m *AppRepo) AppFindOne(app *appmodel.App, conn builder.Cond, columns ...string) (*appmodel.App, error) {
|
||||
has, err := m.repo.Where(conn).Get(app)
|
||||
if !has {
|
||||
return nil, sql.ErrNoRows
|
||||
}
|
||||
return app, err
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func NewOrderLogRepo(repo xorm.Interface) *OrderLogRepo {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *OrderLogRepo) OrderLogList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]orderlogmodel.OrderLog) (int64, error) {
|
||||
func (m *OrderLogRepo) MerchantList(conn builder.Cond, pageFilter entities.PageRequest, orderLogList *[]orderlogmodel.OrderLogModel) (int64, error) {
|
||||
repo := m.repo.Where(conn)
|
||||
if pageFilter.Page > 0 {
|
||||
repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1))
|
||||
|
@ -25,15 +25,15 @@ func (m *OrderLogRepo) OrderLogList(conn builder.Cond, pageFilter entities.PageR
|
|||
return repo.Desc("create_time").FindAndCount(orderLogList)
|
||||
}
|
||||
|
||||
func (m *OrderLogRepo) OrderLogInsertOne(orderLog *orderlogmodel.OrderLog) (int64, error) {
|
||||
func (m *OrderLogRepo) MerchantInsertOne(orderLog *orderlogmodel.OrderLogModel) (int64, error) {
|
||||
return m.repo.InsertOne(orderLog)
|
||||
}
|
||||
|
||||
func (m *OrderLogRepo) OrderLogDelete(orderLog *orderlogmodel.OrderLog, conn builder.Cond) (int64, error) {
|
||||
func (m *OrderLogRepo) MerchantDelete(orderLog *orderlogmodel.OrderLogModel, conn builder.Cond) (int64, error) {
|
||||
return m.repo.Where(conn).Delete(orderLog)
|
||||
}
|
||||
|
||||
// columns 参数为要更新的字段
|
||||
func (m *OrderLogRepo) OrderLogUpdate(orderLog *orderlogmodel.OrderLog, conn builder.Cond, columns ...string) (int64, error) {
|
||||
func (m *OrderLogRepo) MerchantUpdate(orderLog *orderlogmodel.OrderLogModel, conn builder.Cond, columns ...string) (int64, error) {
|
||||
return m.repo.Where(conn).MustCols(columns...).Update(orderLog)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func NewOrderRepo(repo xorm.Interface) *OrderRepo {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *OrderRepo) OrderList(conn builder.Cond, pageFilter entities.PageRequest, orderList *[]ordersmodel.Orders) (int64, error) {
|
||||
func (m *OrderRepo) MerchantList(conn builder.Cond, pageFilter entities.PageRequest, orderList *[]ordersmodel.Orders) (int64, error) {
|
||||
repo := m.repo.Where(conn)
|
||||
if pageFilter.Page > 0 {
|
||||
repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1))
|
||||
|
@ -25,27 +25,15 @@ func (m *OrderRepo) OrderList(conn builder.Cond, pageFilter entities.PageRequest
|
|||
return repo.Desc("create_time").FindAndCount(orderList)
|
||||
}
|
||||
|
||||
func (m *OrderRepo) OrderInsertOne(order *ordersmodel.Orders) (int64, error) {
|
||||
func (m *OrderRepo) MerchantInsertOne(order *ordersmodel.Orders) (int64, error) {
|
||||
return m.repo.InsertOne(order)
|
||||
}
|
||||
|
||||
func (m *OrderRepo) OrderDelete(order *ordersmodel.Orders, conn builder.Cond) (int64, error) {
|
||||
func (m *OrderRepo) MerchantDelete(order *ordersmodel.Orders, conn builder.Cond) (int64, error) {
|
||||
return m.repo.Where(conn).Delete(order)
|
||||
}
|
||||
|
||||
// columns 参数为要更新的字段
|
||||
func (m *OrderRepo) OrderUpdate(order *ordersmodel.Orders, conn builder.Cond, columns ...string) (int64, error) {
|
||||
func (m *OrderRepo) MerchantUpdate(order *ordersmodel.Orders, conn builder.Cond, columns ...string) (int64, error) {
|
||||
return m.repo.Where(conn).MustCols(columns...).Update(order)
|
||||
}
|
||||
|
||||
func (m *OrderRepo) OrdersBackendList(conn builder.Cond, pageFilter entities.PageRequest, orderList *[]ordersmodel.OrdersBackendList) (int64, error) {
|
||||
repo := m.repo.Select(`orders.*, merchant.name as merchant_name, app.app_name, pay_channel.pay_name`).
|
||||
Where(conn)
|
||||
if pageFilter.Page > 0 {
|
||||
repo = repo.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1))
|
||||
}
|
||||
repo = repo.Join("left", "app", "app.id = orders.app_id").
|
||||
Join("left", "merchant", "merchant.id = orders.merchant_id").
|
||||
Join("left", "pay_channel", "pay_channel.id = orders.pay_id")
|
||||
return repo.Desc("create_time").FindAndCount(orderList)
|
||||
}
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
package backend
|
||||
|
||||
import (
|
||||
"PaymentCenter/app/constants/errorcode"
|
||||
"PaymentCenter/app/http/controllers"
|
||||
"PaymentCenter/app/http/entities"
|
||||
"PaymentCenter/app/http/entities/backend"
|
||||
"PaymentCenter/app/models/orderlogmodel"
|
||||
"PaymentCenter/app/models/ordersmodel"
|
||||
"PaymentCenter/app/services"
|
||||
"github.com/ahmetb/go-linq/v3"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func OrderList(c *gin.Context) {
|
||||
req, _ := controllers.GetRequest(c).(*backend.OrderListRequest)
|
||||
filter, err := req.ValidateRequest()
|
||||
if err != nil {
|
||||
controllers.Error(c, errorcode.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
orderList, total, code := services.OrderList(filter)
|
||||
|
||||
result := make([]backend.OrdersResponse, 0, len(orderList))
|
||||
linq.From(orderList).SelectT(func(in ordersmodel.OrdersBackendList) (out backend.OrdersResponse) {
|
||||
out.ResponseFromDb(in)
|
||||
return
|
||||
}).ToSlice(&result)
|
||||
data := entities.PageRsp{
|
||||
Total: total,
|
||||
Data: result,
|
||||
}
|
||||
controllers.HandCodeRes(c, data, code)
|
||||
}
|
||||
|
||||
func OrderLogsList(c *gin.Context) {
|
||||
req, _ := controllers.GetRequest(c).(*backend.OrderLogsListRequest)
|
||||
req.SetDefault()
|
||||
orderLogList, total, code := services.OrderLogsList(*req)
|
||||
|
||||
result := make([]backend.OrderLogResponse, 0, len(orderLogList))
|
||||
linq.From(orderLogList).SelectT(func(in orderlogmodel.OrderLog) (out backend.OrderLogResponse) {
|
||||
out.ResponseFromDb(in)
|
||||
return
|
||||
}).ToSlice(&result)
|
||||
data := entities.PageRsp{
|
||||
Total: total,
|
||||
Data: result,
|
||||
}
|
||||
controllers.HandCodeRes(c, data, code)
|
||||
}
|
|
@ -207,7 +207,3 @@ func phoneValidation(fl validator.FieldLevel) bool {
|
|||
reg := regexp.MustCompile(phoneRegex)
|
||||
return reg.MatchString(phone)
|
||||
}
|
||||
|
||||
func ErrWithCode(c *gin.Context, code int) {
|
||||
Error(c, code, errorcode.GetMsg(code, c.GetHeader("local")))
|
||||
}
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
package backend
|
||||
|
||||
import (
|
||||
"PaymentCenter/app/http/entities"
|
||||
"PaymentCenter/app/models/orderlogmodel"
|
||||
"PaymentCenter/app/models/ordersmodel"
|
||||
"PaymentCenter/app/utils"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"time"
|
||||
)
|
||||
|
||||
type OrderListRequest struct {
|
||||
Id int64 `json:"id" form:"id"`
|
||||
MerchantId int64 `json:"merchant_id" form:"merchant_id"`
|
||||
PayId int64 `json:"pay_id" form:"pay_id"`
|
||||
AppId int64 `json:"app_id" form:"app_id"`
|
||||
MerchantOrderId string `json:"merchant_order_id" form:"merchant_order_id"`
|
||||
Status int `json:"status" form:"status"`
|
||||
OrderType int `json:"order_type" form:"order_type"`
|
||||
StartTime string `json:"start_time" form:"start_time"`
|
||||
EndTime string `json:"end_time" form:"end_time"`
|
||||
entities.PageRequest
|
||||
}
|
||||
type OrderList struct {
|
||||
Id int64 `json:"id"`
|
||||
MerchantId int64 `json:"merchant_id"`
|
||||
PayId int64 `json:"pay_id"`
|
||||
AppId int64 `json:"app_id"`
|
||||
MerchantOrderId string `json:"merchant_order_id"`
|
||||
Status int `json:"status"`
|
||||
OrderType int `json:"order_type"`
|
||||
StartTime time.Time `json:"start_time"`
|
||||
EndTime time.Time `json:"end_time"`
|
||||
entities.PageRequest
|
||||
}
|
||||
|
||||
func (o *OrderListRequest) ValidateRequest() (r OrderList, err error) {
|
||||
if o.StartTime != "" {
|
||||
r.StartTime, err = utils.StrToTimeShanghai(o.StartTime)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "时间格式错误")
|
||||
return
|
||||
}
|
||||
}
|
||||
if o.EndTime != "" {
|
||||
r.EndTime, err = utils.StrToTimeShanghai(o.EndTime)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "时间格式错误")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
r.Id = o.Id
|
||||
r.MerchantId = o.MerchantId
|
||||
r.PayId = o.PayId
|
||||
r.AppId = o.AppId
|
||||
r.MerchantOrderId = o.MerchantOrderId
|
||||
r.Status = o.Status
|
||||
r.OrderType = o.OrderType
|
||||
r.PageRequest = o.PageRequest
|
||||
r.SetDefault()
|
||||
return
|
||||
}
|
||||
|
||||
type OrdersResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
MerchantId int64 `json:"merchant_id"`
|
||||
PayId int64 `json:"pay_id"`
|
||||
AppId int64 `json:"app_id"`
|
||||
MerchantOrderId string `json:"merchant_order_id"`
|
||||
Status int `json:"status"`
|
||||
OrderType int `json:"order_type"`
|
||||
Amount int `json:"amount"`
|
||||
IpAddress string `json:"ip_address"`
|
||||
MerchantRequest string `json:"merchant_request"`
|
||||
MerchantResponse string `json:"merchant_response"`
|
||||
OrderResponse string `json:"order_response"`
|
||||
ExtJson string `json:"ext_json"`
|
||||
CreateTime string `json:"create_time"`
|
||||
UpdateTime string `json:"update_time"`
|
||||
MerchantName string `json:"merchant_name"`
|
||||
PayName string `json:"pay_name"`
|
||||
AppName string `json:"app_name"`
|
||||
}
|
||||
|
||||
func (o *OrdersResponse) ResponseFromDb(db ordersmodel.OrdersBackendList) {
|
||||
o.Id = db.Id
|
||||
o.MerchantId = db.MerchantId
|
||||
o.PayId = db.PayId
|
||||
o.AppId = db.AppId
|
||||
o.MerchantOrderId = db.MerchantOrderId
|
||||
o.Status = db.Status
|
||||
o.OrderType = db.OrderType
|
||||
o.Amount = db.Amount
|
||||
o.IpAddress = db.IpAddress
|
||||
o.MerchantRequest = db.MerchantRequest
|
||||
o.MerchantResponse = db.MerchantResponse
|
||||
o.OrderResponse = db.OrderResponse
|
||||
o.ExtJson = db.ExtJson
|
||||
o.CreateTime = db.CreateTime.Format("2006-01-02 15:04:05")
|
||||
o.UpdateTime = db.UpdateTime.Format("2006-01-02 15:04:05")
|
||||
o.MerchantName = db.MerchantName
|
||||
o.PayName = db.PayName
|
||||
o.AppName = db.AppName
|
||||
}
|
||||
|
||||
type OrderLogsListRequest struct {
|
||||
OrderId int64 `json:"order_id" form:"order_id"`
|
||||
entities.PageRequest
|
||||
}
|
||||
|
||||
type OrderLogResponse struct {
|
||||
Id int64 `json:"id"`
|
||||
OrderId int64 `json:"order_id"`
|
||||
PayCallback string `json:"pay_callback"`
|
||||
Status int `json:"status"`
|
||||
MerchantParam string `json:"merchant_param"`
|
||||
MerchantCallback string `json:"merchant_callback"`
|
||||
CreateTime string `json:"create_time"`
|
||||
}
|
||||
|
||||
func (o *OrderLogResponse) ResponseFromDb(db orderlogmodel.OrderLog) {
|
||||
o.Id = db.Id
|
||||
o.OrderId = db.OrderId
|
||||
o.PayCallback = db.PayCallback
|
||||
o.Status = db.Status
|
||||
o.MerchantParam = db.MerchantParam
|
||||
o.MerchantCallback = db.MerchantCallback
|
||||
o.CreateTime = db.CreateTime.Format("2006-01-02 15:04:05")
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package front
|
||||
|
||||
type PayCommonBody struct {
|
||||
AppId int64 `json:"app_id" validate:"required"`
|
||||
AppId string `json:"app_id" validate:"required"`
|
||||
Timestamp int64 `json:"timestamp" validate:"required"`
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,8 @@ import (
|
|||
"PaymentCenter/app/constants/common"
|
||||
"PaymentCenter/app/constants/errorcode"
|
||||
"PaymentCenter/app/http/controllers"
|
||||
"PaymentCenter/app/http/entities"
|
||||
"PaymentCenter/app/http/entities/front"
|
||||
"PaymentCenter/app/http/requestmapping"
|
||||
"PaymentCenter/app/services"
|
||||
"PaymentCenter/app/utils"
|
||||
"context"
|
||||
"errors"
|
||||
|
@ -111,32 +109,9 @@ func ValidatePayRequest() gin.HandlerFunc {
|
|||
return func(c *gin.Context) {
|
||||
com, err := utils.SonicApiDataToStruct(controllers.GetRequest(c), &front.PayCommonBody{})
|
||||
if err != nil {
|
||||
controllers.ErrWithCode(c, errorcode.ParamError)
|
||||
}
|
||||
comStruct := com.(*front.PayCommonBody)
|
||||
//判断时间
|
||||
//now := time.Now().UnixNano() / 1000000
|
||||
//if comStruct.Timestamp > now || (config.GetConf().TimeOut != 0 && (now-comStruct.Timestamp) > config.GetConf().TimeOut) {
|
||||
// controllers.ErrWithCode(c, errorcode.RequestTimeOut)
|
||||
// return
|
||||
//}
|
||||
//获取app信息
|
||||
app, errCode := services.AppFindOne(entities.IdRequest{Id: comStruct.AppId})
|
||||
if errCode != errorcode.Success {
|
||||
controllers.ErrWithCode(c, errCode)
|
||||
return
|
||||
}
|
||||
//检查app可用性
|
||||
appCheck := services.NewAppCheck(app).Check()
|
||||
if appCheck.GetCode() != errorcode.Success {
|
||||
controllers.ErrWithCode(c, appCheck.GetCode())
|
||||
return
|
||||
}
|
||||
//检查白名单
|
||||
if !appCheck.IpCheck(c.ClientIP()) {
|
||||
controllers.ErrWithCode(c, appCheck.GetCode())
|
||||
return
|
||||
controllers.Error(c, errorcode.ParamError, err.Error())
|
||||
}
|
||||
com = com.(*front.PayCommonBody)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
|
|
|
@ -24,7 +24,4 @@ var BackendRequestMap = map[string]func() interface{}{
|
|||
common.ADMIN_V1 + "/app/list": func() interface{} { return new(backend.AppListRequest) },
|
||||
common.ADMIN_V1 + "/app/delete": func() interface{} { return new(entities.IdRequest) },
|
||||
common.ADMIN_V1 + "/app/decrypt": func() interface{} { return new(backend.GenerateDecryptKeyRequest) },
|
||||
// 订单
|
||||
common.ADMIN_V1 + "/order/list": func() interface{} { return new(backend.OrderListRequest) },
|
||||
common.ADMIN_V1 + "/order/log/list": func() interface{} { return new(backend.OrderLogsListRequest) },
|
||||
}
|
||||
|
|
|
@ -46,11 +46,6 @@ func RegisterAdminRoute(router *gin.Engine) {
|
|||
app.DELETE("/delete", backend.AppDelete) // 应用删除
|
||||
app.GET("/decrypt", backend.GenerateDecrypt) // 生成密钥对
|
||||
|
||||
// 订单
|
||||
order := v1.Group("/order")
|
||||
order.GET("/list", backend.OrderList) // 订单列表
|
||||
order.GET("/log/list", backend.OrderLogsList) // 订单日志列表
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ var (
|
|||
type App struct {
|
||||
Id int64
|
||||
MerchantId int64 `xorm:"'merchant_id' bigint(20)"`
|
||||
AppName string `xorm:"'app_name' varchar(20)"`
|
||||
AppRemark string `xorm:"'app_remark' varchar(200)"`
|
||||
Status int32 `xorm:"'status' tinyint(2)"`
|
||||
KeyType int32 `xorm:"'key_type' tinyint(2)"`
|
||||
AppName string `xorm:"'app_name' varchar(128)"`
|
||||
AppRemark string `xorm:"'app_remark' varchar(255)"`
|
||||
Status int `xorm:"'status' int(11)"`
|
||||
KeyType int `xorm:"'key_type' int(11)"`
|
||||
PublicKey string `xorm:"'public_key' varchar(1024)"`
|
||||
PrivateKey string `xorm:"'private_key' varchar(1024)"`
|
||||
MerchantPublicKey string `xorm:"'merchant_public_key' varchar(1024)"`
|
||||
|
|
|
@ -17,7 +17,7 @@ type Orders struct {
|
|||
MerchantId int64 `xorm:"'merchant_id' bigint(20)"`
|
||||
PayId int64 `xorm:"'pay_id' bigint(20)"`
|
||||
AppId int64 `xorm:"'app_id' bigint(20)"`
|
||||
MerchantOrderId string `xorm:"'merchant_order_id' varchar(32)"`
|
||||
MerchantOrderId string `xorm:"'merchant_order_id' varchar(128)"`
|
||||
Status int `xorm:"'status' int(11)"`
|
||||
OrderType int `xorm:"'order_type' int(11)"`
|
||||
Amount int `xorm:"'amount' int(11)"`
|
||||
|
@ -30,12 +30,6 @@ type Orders struct {
|
|||
UpdateTime time.Time `xorm:"'update_time' timestamp updated"`
|
||||
DeleteTime time.Time `xorm:"'delete_time' timestamp deleted"`
|
||||
}
|
||||
type OrdersBackendList struct {
|
||||
Orders `xorm:"extends"`
|
||||
MerchantName string `xorm:"'merchant_name' varchar(128)"`
|
||||
PayName string `xorm:"'pay_name' varchar(128)"`
|
||||
AppName string `xorm:"'app_name' varchar(128)"`
|
||||
}
|
||||
|
||||
// 表名
|
||||
func (m *Orders) TableName() string {
|
||||
|
|
|
@ -17,6 +17,7 @@ type PayChannel struct {
|
|||
PayName string `xorm:"'pay_name' varchar(128)"`
|
||||
MerchantId int64 `xorm:"'merchant_id' bigint(20)"`
|
||||
ChannelType int `xorm:"'channel_type' int(11)"`
|
||||
|
||||
AppId string `xorm:"'app_id' varchar(255)"`
|
||||
ExtJson string `xorm:"'ext_json' JSON"`
|
||||
ExpireTime time.Time `xorm:"'expire_time' datetime"`
|
||||
|
|
|
@ -1,47 +1,5 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"PaymentCenter/app/constants/errorcode"
|
||||
"PaymentCenter/app/constants/pojo"
|
||||
"PaymentCenter/app/models/appmodel"
|
||||
"PaymentCenter/app/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type AppCheck struct {
|
||||
App *appmodel.App
|
||||
Code int
|
||||
}
|
||||
|
||||
func NewAppCheck(app *appmodel.App) *AppCheck {
|
||||
return &AppCheck{
|
||||
App: app,
|
||||
Code: errorcode.Success,
|
||||
}
|
||||
}
|
||||
|
||||
func (a *AppCheck) IpCheck(ip string) bool {
|
||||
if a.App.WhiteIp == "" {
|
||||
func validIp(ip string) bool {
|
||||
return true
|
||||
}
|
||||
if !utils.ContainsString(strings.Split(a.App.WhiteIp, ","), ip) {
|
||||
a.Code = errorcode.AppIpNotAllow
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *AppCheck) Check() *AppCheck {
|
||||
|
||||
if a.App.Status == pojo.STATUS_DISABLED {
|
||||
a.Code = errorcode.AppDisabled
|
||||
}
|
||||
if a.App.DeleteTime.Location() == nil {
|
||||
a.Code = errorcode.AppNotFound
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *AppCheck) GetCode() int {
|
||||
return a.Code
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package apicrypt
|
||||
|
||||
import "PaymentCenter/app/models/appmodel"
|
||||
|
||||
func NewRsa(app *appmodel.App) ApiDecrypt {
|
||||
return &Rsa{
|
||||
App: app,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Rsa) Encrypt(decryptData interface{}) (encryptData string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (r *Rsa) Decrypt(encryptData string) (decryptData map[string]interface{}, err error) {
|
||||
return
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package apicrypt
|
||||
|
||||
func (r *SM2) Encrypt(decryptData interface{}) (encryptData string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (r *SM2) Decrypt(encryptData string) (decryptData map[string]interface{}, err error) {
|
||||
return
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package apicrypt
|
||||
|
||||
func (r *SM4) Encrypt(decryptData interface{}) (encryptData string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (r *SM4) Decrypt(encryptData string) (decryptData map[string]interface{}, err error) {
|
||||
return
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package apicrypt
|
||||
|
||||
import "PaymentCenter/app/models/appmodel"
|
||||
|
||||
type (
|
||||
ApiDecrypt interface {
|
||||
Encrypt(decryptData interface{}) (encryptData string, err error)
|
||||
Decrypt(encryptData string) (decryptData map[string]interface{}, err error)
|
||||
}
|
||||
|
||||
Rsa struct {
|
||||
App *appmodel.App
|
||||
}
|
||||
|
||||
SM2 struct {
|
||||
App *appmodel.App
|
||||
}
|
||||
|
||||
SM4 struct {
|
||||
App *appmodel.App
|
||||
}
|
||||
)
|
|
@ -8,7 +8,6 @@ import (
|
|||
"PaymentCenter/app/models/appmodel"
|
||||
"PaymentCenter/app/models/merchantmodel"
|
||||
"PaymentCenter/app/models/paychannelmodel"
|
||||
"database/sql"
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
|
@ -85,20 +84,3 @@ func AppDelete(req entities.IdRequest) (code int) {
|
|||
code = handErr(err)
|
||||
return
|
||||
}
|
||||
|
||||
func AppFindOne(req entities.IdRequest, col ...string) (row *appmodel.App, code int) {
|
||||
repo := data.NewAppRepo(paychannelmodel.GetInstance().GetDb())
|
||||
|
||||
// 拼接查询条件
|
||||
conn := builder.NewCond()
|
||||
conn = conn.And(builder.Eq{"Id": req.Id})
|
||||
m := appmodel.App{Id: req.Id}
|
||||
row, err := repo.AppFindOne(&m, conn, col...)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, errorcode.AppNotFound
|
||||
}
|
||||
return row, errorcode.SystemError
|
||||
}
|
||||
return row, errorcode.Success
|
||||
}
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"PaymentCenter/app/data"
|
||||
"PaymentCenter/app/http/entities/backend"
|
||||
"PaymentCenter/app/models/orderlogmodel"
|
||||
"PaymentCenter/app/models/ordersmodel"
|
||||
"PaymentCenter/app/models/paychannelmodel"
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
// 订单列表,后台查询
|
||||
func OrderList(req backend.OrderList) (result []ordersmodel.OrdersBackendList, total int64, code int) {
|
||||
repo := data.NewOrderRepo(paychannelmodel.GetInstance().GetDb())
|
||||
// 拼接查询条件
|
||||
conn := builder.NewCond()
|
||||
if req.Id > 0 {
|
||||
conn = conn.And(builder.Eq{"id": req.Id})
|
||||
}
|
||||
if req.MerchantId > 0 {
|
||||
conn = conn.And(builder.Eq{"merchant_id": req.MerchantId})
|
||||
}
|
||||
if req.PayId > 0 {
|
||||
conn = conn.And(builder.Eq{"pay_id": req.PayId})
|
||||
}
|
||||
if req.AppId > 0 {
|
||||
conn = conn.And(builder.Eq{"app_id": req.AppId})
|
||||
}
|
||||
if req.MerchantOrderId != "" {
|
||||
conn = conn.And(builder.Like{"merchant_order_id", req.MerchantOrderId})
|
||||
}
|
||||
if req.Status > 0 {
|
||||
conn = conn.And(builder.Eq{"status": req.Status})
|
||||
}
|
||||
if req.OrderType > 0 {
|
||||
conn = conn.And(builder.Eq{"order_type": req.OrderType})
|
||||
}
|
||||
if !req.StartTime.IsZero() {
|
||||
conn = conn.And(builder.Gte{"start_time": req.StartTime})
|
||||
}
|
||||
if !req.EndTime.IsZero() {
|
||||
conn = conn.And(builder.Lte{"end_time": req.EndTime})
|
||||
}
|
||||
|
||||
// 调用repo
|
||||
orderList := make([]ordersmodel.OrdersBackendList, 0)
|
||||
count, err := repo.OrdersBackendList(conn, req.PageRequest, &orderList)
|
||||
code = handErr(err)
|
||||
return orderList, count, code
|
||||
}
|
||||
|
||||
func OrderLogsList(req backend.OrderLogsListRequest) (result []orderlogmodel.OrderLog, total int64, code int) {
|
||||
repo := data.NewOrderLogRepo(paychannelmodel.GetInstance().GetDb())
|
||||
conn := builder.NewCond()
|
||||
if req.OrderId > 0 {
|
||||
conn = conn.And(builder.Eq{"order_id": req.OrderId})
|
||||
}
|
||||
// 调用repo
|
||||
orderLogList := make([]orderlogmodel.OrderLog, 0)
|
||||
count, err := repo.OrderLogList(conn, req.PageRequest, &orderLogList)
|
||||
code = handErr(err)
|
||||
|
||||
return orderLogList, count, code
|
||||
}
|
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/base64"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -14,8 +13,7 @@ const (
|
|||
)
|
||||
|
||||
func TestRsaEncrypt(t *testing.T) {
|
||||
fmt.Println(time.Now().UnixNano() / (1000000))
|
||||
//fmt.Printf("%s\n", encrypt())
|
||||
fmt.Printf("%s\n", encrypt())
|
||||
}
|
||||
|
||||
func TestRsaDecrypt(t *testing.T) {
|
||||
|
|
|
@ -431,12 +431,3 @@ func SonicApiDataToStruct(data interface{}, structInterFace interface{}) (dataSt
|
|||
err = sonic.Unmarshal(bytes, &structInterFace)
|
||||
return structInterFace, err
|
||||
}
|
||||
|
||||
func ContainsString(slice []string, s string) bool {
|
||||
for _, item := range slice {
|
||||
if item == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ type Config struct {
|
|||
Debug bool `toml:"Debug"`
|
||||
PrometheusCollectEnable bool `toml:"PrometheusCollectEnable"`
|
||||
SkyWalkingOapServer string `toml:"SkyWalkingOapServer"`
|
||||
TimeOut int64 `toml:"TimeOut"`
|
||||
Log config.LogConfig `toml:"Log"`
|
||||
Redis config.RedisConfig `toml:"Redis"`
|
||||
Mns config.MnsConfig `toml:"AliMns"`
|
||||
|
|
Loading…
Reference in New Issue