🐳修复部署相关
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
./idea
|
||||
./vscode
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
FROM golang:1.20.10 AS builder
|
||||
|
||||
ENV GO111MODULE=on GOPROXY=https://goproxy.cn,direct CGO_ENABLED=0 GOOS=linux GOARCH=amd64
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY ./ /build/
|
||||
|
||||
RUN go build main.go
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /app
|
||||
ENV TZ Asia/Shanghai
|
||||
|
||||
#设置国内镜像源,时区
|
||||
RUN echo "https://mirrors.aliyun.com/alpine/v3.18/main/" > /etc/apk/repositories && \
|
||||
echo "https://mirrors.aliyun.com/alpine/v3.18/community/" >> /etc/apk/repositories \
|
||||
&& apk update && apk upgrade && apk add --no-cache tzdata && \
|
||||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
COPY --from=builder /build/main /app/
|
||||
COPY --from=builder /build/conf/ /app/conf/
|
||||
COPY --from=builder /build/views/ /app/views/
|
||||
COPY --from=builder /build/static/ /app/static/
|
||||
|
||||
# 启动服务
|
||||
CMD ["./main"]
|
||||
|
||||
EXPOSE 12309
|
||||
@@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package config
|
||||
|
||||
import "github.com/beego/beego/v2/server/web"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package conf
|
||||
package config
|
||||
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
@@ -1,5 +1,5 @@
|
||||
// Package conf /***************************************************
|
||||
package conf
|
||||
package config
|
||||
|
||||
import "net"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/29 15:01
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package conf
|
||||
package config
|
||||
|
||||
var ScanPayWayCodes = []string{
|
||||
"WEIXIN_SCAN",
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/models/order"
|
||||
"gateway/query"
|
||||
"gateway/service"
|
||||
@@ -203,10 +203,10 @@ func (c *OrderController) OrderCreate() {
|
||||
c.Data["orderNo"] = params["orderNo"]
|
||||
c.Data["price"] = params["orderPrice"]
|
||||
c.TplName = "scan.html"
|
||||
if orderInfo.Status == conf.WAIT {
|
||||
if orderInfo.Status == config.WAIT {
|
||||
c.Data["qrCode"] = "../static/new/febs/images/public/jx.png"
|
||||
} else if orderInfo.Status == conf.SUCCESS || orderInfo.Status == conf.FAIL {
|
||||
if orderInfo.Status == conf.SUCCESS {
|
||||
} else if orderInfo.Status == config.SUCCESS || orderInfo.Status == config.FAIL {
|
||||
if orderInfo.Status == config.SUCCESS {
|
||||
c.Data["price"] = orderInfo.FactAmount
|
||||
}
|
||||
c.Data["UpdateTime"] = orderInfo.UpdateTime
|
||||
@@ -241,31 +241,31 @@ func (c *OrderController) OrderUpdate() {
|
||||
logs.Error("该订单不存在,bankOrderId=", bankOrderId)
|
||||
} else {
|
||||
switch solveType {
|
||||
case conf.SUCCESS:
|
||||
case config.SUCCESS:
|
||||
flag = service.SolvePaySuccess(bankOrderId, orderInfo.FactAmount, orderInfo.BankTransId)
|
||||
case conf.FAIL:
|
||||
case config.FAIL:
|
||||
flag = service.SolvePayFail(bankOrderId, orderInfo.BankTransId)
|
||||
case conf.FREEZE_AMOUNT:
|
||||
case config.FREEZE_AMOUNT:
|
||||
//将这笔订单进行冻结
|
||||
flag = service.SolveOrderFreeze(bankOrderId)
|
||||
case conf.UNFREEZE_AMOUNT:
|
||||
case config.UNFREEZE_AMOUNT:
|
||||
//将这笔订单金额解冻
|
||||
flag = service.SolveOrderUnfreeze(bankOrderId)
|
||||
case conf.REFUND:
|
||||
if orderInfo.Status == conf.SUCCESS {
|
||||
case config.REFUND:
|
||||
if orderInfo.Status == config.SUCCESS {
|
||||
flag = service.SolveRefund(bankOrderId)
|
||||
}
|
||||
case conf.ORDERROLL:
|
||||
if orderInfo.Status == conf.SUCCESS {
|
||||
case config.ORDERROLL:
|
||||
if orderInfo.Status == config.SUCCESS {
|
||||
flag = service.SolveOrderRoll(bankOrderId)
|
||||
}
|
||||
default:
|
||||
logs.Error("不存在这样的处理类型")
|
||||
}
|
||||
if flag {
|
||||
c.Ctx.WriteString(conf.SUCCESS)
|
||||
c.Ctx.WriteString(config.SUCCESS)
|
||||
} else {
|
||||
c.Ctx.WriteString(conf.FAIL)
|
||||
c.Ctx.WriteString(config.FAIL)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ package gateway
|
||||
****************************************************/
|
||||
import (
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/models/payfor"
|
||||
"gateway/models/road"
|
||||
"gateway/pay_for"
|
||||
@@ -49,7 +49,7 @@ func (c *PayForGateway) PayFor() {
|
||||
payForResponse.ResultMsg = msg
|
||||
} else {
|
||||
|
||||
payForResponse = pay_for.AutoPayFor(params, conf.SELF_API)
|
||||
payForResponse = pay_for.AutoPayFor(params, config.SELF_API)
|
||||
}
|
||||
|
||||
c.Data["json"] = payForResponse
|
||||
@@ -92,16 +92,16 @@ func (c *PayForGateway) SolvePayForResult() {
|
||||
|
||||
p := payfor.GetPayForByBankOrderId(bankOrderId)
|
||||
if p.BankOrderId == "" {
|
||||
c.Ctx.WriteString(conf.FAIL)
|
||||
c.Ctx.WriteString(config.FAIL)
|
||||
}
|
||||
|
||||
if resultType == conf.PAYFOR_FAIL {
|
||||
if resultType == config.PAYFOR_FAIL {
|
||||
pay_for.PayForFail(p)
|
||||
} else if resultType == conf.PAYFOR_SUCCESS {
|
||||
} else if resultType == config.PAYFOR_SUCCESS {
|
||||
pay_for.PayForSuccess(p)
|
||||
}
|
||||
|
||||
c.Ctx.WriteString(conf.SUCCESS)
|
||||
c.Ctx.WriteString(config.SUCCESS)
|
||||
}
|
||||
|
||||
// Balance 商户查找余额
|
||||
|
||||
22
docker-compose.yaml
Normal file
22
docker-compose.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
container_name: kami_gateway
|
||||
image: kami_gateway:0.11
|
||||
restart:
|
||||
always
|
||||
ports:
|
||||
- "12306:12306"
|
||||
volumes:
|
||||
- /data/kami/gateway/conf/:/app/conf/
|
||||
- /data/kami/gateway/logs/:/app/logs/
|
||||
networks:
|
||||
- 1panel-network
|
||||
labels:
|
||||
createdBy: Developer
|
||||
|
||||
networks:
|
||||
1panel-network:
|
||||
external: true
|
||||
@@ -11,7 +11,7 @@ package message
|
||||
****************************************************/
|
||||
|
||||
import (
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/go-stomp/stomp"
|
||||
"os"
|
||||
@@ -28,7 +28,7 @@ var options = []func(*stomp.Conn) error{
|
||||
}
|
||||
|
||||
func init() {
|
||||
address := conf.GetMQAddress()
|
||||
address := config.GetMQAddress()
|
||||
conn, err := stomp.Dial("tcp", address, options...)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -2,7 +2,7 @@ package notify
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/message"
|
||||
"gateway/models/notify"
|
||||
"gateway/utils"
|
||||
@@ -148,7 +148,7 @@ func CreateOrderNotifyConsumer() {
|
||||
}
|
||||
|
||||
logs.Notice("订单回调消息队列启动成功......")
|
||||
orderNotify, err := conn.Subscribe(conf.MqOrderNotify, stomp.AckClient)
|
||||
orderNotify, err := conn.Subscribe(config.MqOrderNotify, stomp.AckClient)
|
||||
if err != nil {
|
||||
logs.Error("订阅订单回调失败......")
|
||||
os.Exit(1)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/message"
|
||||
"gateway/models/accounts"
|
||||
"gateway/models/merchant"
|
||||
@@ -75,7 +75,7 @@ func AutoPayFor(params map[string]string, giveType string) *response.PayForRespo
|
||||
MerchantOrderId: params["merchantOrderId"],
|
||||
BankOrderId: "4444" + xid.New().String(),
|
||||
PayforAmount: settAmount,
|
||||
Status: conf.PAYFOR_COMFRIM,
|
||||
Status: config.PAYFOR_COMFRIM,
|
||||
BankAccountName: params["realname"],
|
||||
BankAccountNo: params["cardNo"],
|
||||
BankAccountType: params["accType"],
|
||||
@@ -125,9 +125,9 @@ func findPayForRoad(p payfor.PayforInfo) bool {
|
||||
|
||||
m := merchant.GetMerchantByUid(p.MerchantUid)
|
||||
// 检查商户是否设置了自动代付
|
||||
if m.AutoPayFor == conf.NO || m.AutoPayFor == "" {
|
||||
if m.AutoPayFor == config.NO || m.AutoPayFor == "" {
|
||||
logs.Notice(fmt.Sprintf("该商户uid=%s, 没有开通自动代付功能", p.MerchantUid))
|
||||
p.Type = conf.PAYFOR_HAND
|
||||
p.Type = config.PAYFOR_HAND
|
||||
payfor.UpdatePayFor(p)
|
||||
} else {
|
||||
|
||||
@@ -155,7 +155,7 @@ func findPayForRoad(p payfor.PayforInfo) bool {
|
||||
p.PayforFee = roadInfo.SettleFee
|
||||
p.PayforTotalAmount = p.PayforFee + p.PayforAmount
|
||||
|
||||
if m.PayforFee > conf.ZERO {
|
||||
if m.PayforFee > config.ZERO {
|
||||
logs.Info(fmt.Sprintf("商户uid=%s,有单独的代付手续费。", m.MerchantUid))
|
||||
p.PayforFee = m.PayforFee
|
||||
p.PayforTotalAmount = p.PayforFee + p.PayforAmount
|
||||
@@ -165,7 +165,7 @@ func findPayForRoad(p payfor.PayforInfo) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if p.GiveType == conf.SELF_HELP {
|
||||
if p.GiveType == config.SELF_HELP {
|
||||
if !MerchantSelf(p) {
|
||||
return false
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func findPayForRoad(p payfor.PayforInfo) bool {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p.Status = conf.PAYFOR_FAIL
|
||||
p.Status = config.PAYFOR_FAIL
|
||||
if !payfor.UpdatePayFor(p) {
|
||||
return false
|
||||
}
|
||||
@@ -195,9 +195,9 @@ func MerchantSelf(p payfor.PayforInfo) bool {
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
p.UpdateTime = utils.GetBasicDateTime()
|
||||
p.Status = conf.PAYFOR_BANKING
|
||||
p.Status = config.PAYFOR_BANKING
|
||||
p.RequestTime = utils.GetBasicDateTime()
|
||||
p.IsSend = conf.YES
|
||||
p.IsSend = config.YES
|
||||
if _, err := txOrm.Update(&p); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -225,7 +225,7 @@ func SendPayFor(p payfor.PayforInfo) bool {
|
||||
|
||||
//支付金额不足,将直接判定为失败,不往下面邹逻辑了
|
||||
if account.SettleAmount-account.PayforAmount < p.PayforAmount+p.PayforFee {
|
||||
p.Status = conf.PAYFOR_FAIL
|
||||
p.Status = config.PAYFOR_FAIL
|
||||
p.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
if _, err := txOrm.Update(&p); err != nil {
|
||||
@@ -243,9 +243,9 @@ func SendPayFor(p payfor.PayforInfo) bool {
|
||||
return err
|
||||
}
|
||||
|
||||
p.IsSend = conf.YES
|
||||
p.Status = conf.PAYFOR_BANKING //变为银行处理中
|
||||
p.GiveType = conf.PAYFOR_ROAD
|
||||
p.IsSend = config.YES
|
||||
p.Status = config.PAYFOR_BANKING //变为银行处理中
|
||||
p.GiveType = config.PAYFOR_ROAD
|
||||
p.RequestTime = utils.GetBasicDateTime()
|
||||
p.UpdateTime = utils.GetBasicDateTime()
|
||||
|
||||
@@ -267,14 +267,14 @@ func RequestPayFor(p payfor.PayforInfo) {
|
||||
if p.RoadUid == "" {
|
||||
return
|
||||
}
|
||||
p.Type = conf.PAYFOR_ROAD
|
||||
p.Type = config.PAYFOR_ROAD
|
||||
roadInfo := road.GetRoadInfoByRoadUid(p.RoadUid)
|
||||
supplierCode := roadInfo.ProductUid
|
||||
supplier := third_party.GetPaySupplierByCode(supplierCode)
|
||||
res := supplier.PayFor(p)
|
||||
logs.Info(fmt.Sprintf("代付uid=%s,上游处理结果为:%s", p.PayforUid, res))
|
||||
//将代付订单号发送到消息队列
|
||||
message.SendMessage(conf.MQ_PAYFOR_QUERY, p.BankOrderId)
|
||||
message.SendMessage(config.MQ_PAYFOR_QUERY, p.BankOrderId)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,21 +297,21 @@ func PayForResultQuery(params map[string]string) string {
|
||||
query["sign"] = utils.GetMD5Sign(params, utils.SortMap(params), merchantInfo.MerchantSecret)
|
||||
} else {
|
||||
switch payForInfo.Status {
|
||||
case conf.PAYFOR_BANKING:
|
||||
case config.PAYFOR_BANKING:
|
||||
query["resultMsg"] = "打款中"
|
||||
query["settStatus"] = "02"
|
||||
case conf.PAYFOR_SOLVING:
|
||||
case config.PAYFOR_SOLVING:
|
||||
query["resultMsg"] = "打款中"
|
||||
query["settStatus"] = "02"
|
||||
case conf.PAYFOR_COMFRIM:
|
||||
case config.PAYFOR_COMFRIM:
|
||||
query["resultMsg"] = "打款中"
|
||||
query["settStatus"] = "02"
|
||||
case conf.PAYFOR_SUCCESS:
|
||||
case config.PAYFOR_SUCCESS:
|
||||
query["resultMsg"] = "打款成功"
|
||||
query["settStatus"] = "00"
|
||||
query["settAmount"] = strconv.FormatFloat(payForInfo.PayforAmount, 'f', 2, 64)
|
||||
query["settFee"] = strconv.FormatFloat(payForInfo.PayforFee, 'f', 2, 64)
|
||||
case conf.PAYFOR_FAIL:
|
||||
case config.PAYFOR_FAIL:
|
||||
query["resultMsg"] = "打款失败"
|
||||
query["settStatus"] = "01"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/models/accounts"
|
||||
"gateway/models/payfor"
|
||||
"gateway/utils"
|
||||
@@ -24,12 +24,12 @@ func PayForFail(p payfor.PayforInfo) bool {
|
||||
return err
|
||||
}
|
||||
|
||||
if tmpForPay.Status == conf.PAYFOR_FAIL || tmpForPay.Status == conf.PAYFOR_SUCCESS {
|
||||
if tmpForPay.Status == config.PAYFOR_FAIL || tmpForPay.Status == config.PAYFOR_SUCCESS {
|
||||
logs.Error(fmt.Sprintf("该代付订单uid=%s,状态已经是最终结果", tmpForPay.PayforUid))
|
||||
return errors.New("状态已经是最终结果")
|
||||
}
|
||||
//更新payfor记录的状态
|
||||
tmpForPay.Status = conf.PAYFOR_FAIL
|
||||
tmpForPay.Status = config.PAYFOR_FAIL
|
||||
tmpForPay.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&tmpForPay); err != nil {
|
||||
logs.Error("PayForFail update payfor_info fail: ", err)
|
||||
@@ -73,13 +73,13 @@ func PayForSuccess(p payfor.PayforInfo) bool {
|
||||
logs.Error("payfor success select payfor fail:", err)
|
||||
return err
|
||||
}
|
||||
if tmpPayFor.Status == conf.PAYFOR_FAIL || tmpPayFor.Status == conf.PAYFOR_SUCCESS {
|
||||
if tmpPayFor.Status == config.PAYFOR_FAIL || tmpPayFor.Status == config.PAYFOR_SUCCESS {
|
||||
logs.Error(fmt.Sprintf("该代付订单uid=#{payFor.PayforUid},已经是最终结果,不需要处理"))
|
||||
return errors.New("已经是最终结果,不需要处理")
|
||||
}
|
||||
|
||||
tmpPayFor.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpPayFor.Status = conf.PAYFOR_SUCCESS
|
||||
tmpPayFor.Status = config.PAYFOR_SUCCESS
|
||||
_, err := txOrm.Update(&tmpPayFor)
|
||||
if err != nil {
|
||||
logs.Error("PayForSuccess update payfor fail: ", err)
|
||||
@@ -114,7 +114,7 @@ func PayForSuccess(p payfor.PayforInfo) bool {
|
||||
accountHistory := accounts.AccountHistoryInfo{
|
||||
AccountUid: tmpPayFor.MerchantUid,
|
||||
AccountName: tmpPayFor.MerchantName,
|
||||
Type: conf.SUB_AMOUNT,
|
||||
Type: config.SUB_AMOUNT,
|
||||
Amount: tmpPayFor.PayforTotalAmount,
|
||||
Balance: account.Balance,
|
||||
UpdateTime: utils.GetBasicDateTime(),
|
||||
|
||||
@@ -11,7 +11,7 @@ package query
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/message"
|
||||
"gateway/models/payfor"
|
||||
"gateway/models/road"
|
||||
@@ -63,13 +63,13 @@ func PayForSupplier(task PayForQueryTask) {
|
||||
return
|
||||
}
|
||||
res, _ := supplier.PayForQuery(payFor)
|
||||
if res == conf.PAYFOR_SUCCESS {
|
||||
if res == config.PAYFOR_SUCCESS {
|
||||
//代付成功了
|
||||
pay_for.PayForSuccess(payFor)
|
||||
} else if res == conf.PAYFOR_FAIL {
|
||||
} else if res == config.PAYFOR_FAIL {
|
||||
//代付失败
|
||||
pay_for.PayForFail(payFor)
|
||||
} else if res == conf.PAYFOR_BANKING {
|
||||
} else if res == config.PAYFOR_BANKING {
|
||||
//银行处理中,那么就继续执行查询,直到次数超过最大次数
|
||||
if task.QueryTimes <= task.LimitTimes {
|
||||
task.QueryTimes += 1
|
||||
@@ -90,7 +90,7 @@ func payForQueryConsumer(bankOrderId string) {
|
||||
|
||||
payFor := payfor.GetPayForByBankOrderId(bankOrderId)
|
||||
|
||||
if payFor.Status != conf.PAYFOR_BANKING {
|
||||
if payFor.Status != config.PAYFOR_BANKING {
|
||||
logs.Info(fmt.Sprintf("代付状态不是银行处理中,不需要去查询,bankOrderId = %s", bankOrderId))
|
||||
return
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func CreatePayForQueryConsumer() {
|
||||
|
||||
logs.Notice("代付查询消费启动成功......")
|
||||
|
||||
payForQuery, err := conn.Subscribe(conf.MQ_PAYFOR_QUERY, stomp.AckClient)
|
||||
payForQuery, err := conn.Subscribe(config.MQ_PAYFOR_QUERY, stomp.AckClient)
|
||||
if err != nil {
|
||||
logs.Error("订阅代付查询失败......")
|
||||
os.Exit(1)
|
||||
|
||||
@@ -12,7 +12,7 @@ package query
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/message"
|
||||
"gateway/models/order"
|
||||
"gateway/supplier/third_party"
|
||||
@@ -98,7 +98,7 @@ func CreateSupplierOrderQueryCuConsumer() {
|
||||
os.Exit(1)
|
||||
}
|
||||
logs.Notice("启动订单查询的消费者成功.....")
|
||||
orderQuerySub, _ := conn.Subscribe(conf.MqOrderQuery, stomp.AckClient)
|
||||
orderQuerySub, _ := conn.Subscribe(config.MqOrderQuery, stomp.AckClient)
|
||||
|
||||
for {
|
||||
select {
|
||||
|
||||
@@ -2,7 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/models/merchant"
|
||||
"gateway/models/order"
|
||||
"gateway/response"
|
||||
@@ -21,7 +21,7 @@ func GetMerchantInfoByUID(params map[string]string) *response.PayBaseResp {
|
||||
if merchantInfo.MerchantUid == "" || len(merchantInfo.MerchantUid) == 0 {
|
||||
c.Code = -1
|
||||
c.Msg = "商户不存在,或者paykey有误,请联系管理员"
|
||||
} else if merchantInfo.Status != conf.ACTIVE {
|
||||
} else if merchantInfo.Status != config.ACTIVE {
|
||||
c.Code = -1
|
||||
c.Msg = "商户状态已经被冻结或者被删除,请联系管理员!"
|
||||
} else {
|
||||
@@ -43,7 +43,7 @@ func GetMerchantInfo(params map[string]string) *response.PayBaseResp {
|
||||
if merchantInfo.MerchantUid == "" || len(merchantInfo.MerchantUid) == 0 {
|
||||
c.Code = -1
|
||||
c.Msg = "商户不存在,或者paykey有误,请联系管理员"
|
||||
} else if merchantInfo.Status != conf.ACTIVE {
|
||||
} else if merchantInfo.Status != config.ACTIVE {
|
||||
c.Code = -1
|
||||
c.Msg = "商户状态已经被冻结或者被删除,请联系管理员!"
|
||||
} else {
|
||||
@@ -137,7 +137,7 @@ func PayWayCodeIsValid(c *response.PayBaseResp) *response.PayBaseResp {
|
||||
c.Code = -1
|
||||
c.Msg = "扫码支付不支持这种支付类型"
|
||||
} else {
|
||||
scanPayWayCodes := conf.GetScanPayWayCodes()
|
||||
scanPayWayCodes := config.GetScanPayWayCodes()
|
||||
for _, v := range scanPayWayCodes {
|
||||
if c.Params["payWayCode"] == v {
|
||||
c.PayWayCode = strings.Replace(c.Params["payWayCode"], "-", "_", -1)
|
||||
|
||||
@@ -11,7 +11,7 @@ package service
|
||||
****************************************************/
|
||||
import (
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/models/merchant"
|
||||
"gateway/models/order"
|
||||
"gateway/models/road"
|
||||
@@ -120,7 +120,7 @@ func GenerateOrderInfo(c *response.PayBaseResp) order.OrderInfo {
|
||||
//6666是自己系统订单号
|
||||
bankOrderNo := "6666" + xid.New().String()
|
||||
//获取支付类型的名称,例如支付宝扫码等
|
||||
payTypeName := conf.GetNameByPayWayCode(c.Params["payWayCode"])
|
||||
payTypeName := config.GetNameByPayWayCode(c.Params["payWayCode"])
|
||||
orderInfo := order.OrderInfo{
|
||||
MerchantUid: c.MerchantInfo.MerchantUid,
|
||||
MerchantName: c.MerchantInfo.MerchantName,
|
||||
@@ -135,14 +135,14 @@ func GenerateOrderInfo(c *response.PayBaseResp) order.OrderInfo {
|
||||
RoadName: c.RoadInfo.RoadName,
|
||||
PayProductName: c.RoadInfo.ProductName,
|
||||
ShopName: c.Params["productName"],
|
||||
Freeze: conf.NO,
|
||||
Refund: conf.NO,
|
||||
Unfreeze: conf.NO,
|
||||
Freeze: config.NO,
|
||||
Refund: config.NO,
|
||||
Unfreeze: config.NO,
|
||||
PayProductCode: c.RoadInfo.ProductUid,
|
||||
PayTypeCode: c.PayWayCode,
|
||||
PayTypeName: payTypeName,
|
||||
OsType: c.Params["osType"],
|
||||
Status: conf.WAIT,
|
||||
Status: config.WAIT,
|
||||
NotifyUrl: c.Params["notifyUrl"],
|
||||
ReturnUrl: c.Params["returnUrl"],
|
||||
OrderPeriod: c.Params["orderPeriod"],
|
||||
@@ -151,7 +151,7 @@ func GenerateOrderInfo(c *response.PayBaseResp) order.OrderInfo {
|
||||
ExValue: c.Params["exValue"],
|
||||
}
|
||||
|
||||
if c.MerchantInfo.BelongAgentUid != "" || c.AgentRate > conf.ZERO {
|
||||
if c.MerchantInfo.BelongAgentUid != "" || c.AgentRate > config.ZERO {
|
||||
orderInfo.AgentUid = c.MerchantInfo.BelongAgentUid
|
||||
orderInfo.AgentName = c.MerchantInfo.BelongAgentName
|
||||
}
|
||||
@@ -161,13 +161,13 @@ func GenerateOrderInfo(c *response.PayBaseResp) order.OrderInfo {
|
||||
// 计算收益,平台利润,代理利润
|
||||
func GenerateOrderProfit(orderInfo order.OrderInfo, c *response.PayBaseResp) order.OrderProfitInfo {
|
||||
//因为所有的手续费率都是百分率,所以需要除以100
|
||||
payTypeName := conf.GetNameByPayWayCode(c.PayWayCode)
|
||||
payTypeName := config.GetNameByPayWayCode(c.PayWayCode)
|
||||
supplierProfit := c.OrderAmount / 100 * c.RoadInfo.BasicFee
|
||||
platformProfit := c.OrderAmount / 100 * c.PlatformRate //平台费率
|
||||
agentProfit := c.OrderAmount / 100 * c.AgentRate //代理费率
|
||||
//如果用户没有设置代理,那么代理利润为0.000
|
||||
if c.MerchantInfo.BelongAgentUid == "" || len(c.MerchantInfo.BelongAgentUid) == 0 {
|
||||
agentProfit = conf.ZERO
|
||||
agentProfit = config.ZERO
|
||||
}
|
||||
|
||||
allProfit := supplierProfit + platformProfit + agentProfit
|
||||
@@ -183,7 +183,7 @@ func GenerateOrderProfit(orderInfo order.OrderInfo, c *response.PayBaseResp) ord
|
||||
PayProductName: c.RoadInfo.ProductName,
|
||||
PayTypeCode: c.PayWayCode,
|
||||
PayTypeName: payTypeName,
|
||||
Status: conf.WAIT,
|
||||
Status: config.WAIT,
|
||||
MerchantOrderId: c.Params["orderNo"],
|
||||
BankOrderId: orderInfo.BankOrderId,
|
||||
OrderAmount: c.OrderAmount,
|
||||
@@ -206,7 +206,7 @@ func GenerateOrderProfit(orderInfo order.OrderInfo, c *response.PayBaseResp) ord
|
||||
}
|
||||
|
||||
//如果该条订单设置了代理利率,并且设置了代理
|
||||
if c.MerchantInfo.BelongAgentUid != "" || c.AgentRate > conf.ZERO {
|
||||
if c.MerchantInfo.BelongAgentUid != "" || c.AgentRate > config.ZERO {
|
||||
orderProfit.AgentUid = c.MerchantInfo.BelongAgentUid
|
||||
orderProfit.AgentName = c.MerchantInfo.BelongAgentName
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/message"
|
||||
"gateway/models/accounts"
|
||||
"gateway/models/merchant"
|
||||
@@ -35,7 +35,7 @@ func SolvePaySuccess(bankOrderId string, factAmount float64, trxNo string) bool
|
||||
return errors.New(fmt.Sprintf("该订单已经处理,订单号= %s", bankOrderId))
|
||||
}
|
||||
|
||||
if factAmount <= conf.ZERO {
|
||||
if factAmount <= config.ZERO {
|
||||
factAmount = orderInfo.OrderAmount
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func SolvePaySuccess(bankOrderId string, factAmount float64, trxNo string) bool
|
||||
return errors.New(fmt.Sprintf("solve pay success, get orderProfit fail, bankOrderId = %s", bankOrderId))
|
||||
}
|
||||
|
||||
orderInfo.Status = conf.SUCCESS
|
||||
orderInfo.Status = config.SUCCESS
|
||||
orderInfo.BankTransId = trxNo
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&orderInfo); err != nil || orderInfo.BankOrderId == "" {
|
||||
@@ -70,8 +70,8 @@ func SolvePaySuccess(bankOrderId string, factAmount float64, trxNo string) bool
|
||||
MerchantName: orderInfo.MerchantName,
|
||||
BankOrderId: bankOrderId,
|
||||
SettleAmount: orderProfitInfo.UserInAmount,
|
||||
IsAllowSettle: conf.YES,
|
||||
IsCompleteSettle: conf.NO,
|
||||
IsAllowSettle: config.YES,
|
||||
IsCompleteSettle: config.NO,
|
||||
UpdateTime: utils.GetBasicDateTime(),
|
||||
CreateTime: utils.GetBasicDateTime(),
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func SolvePaySuccess(bankOrderId string, factAmount float64, trxNo string) bool
|
||||
accountHistory := accounts.AccountHistoryInfo{
|
||||
AccountUid: orderInfo.MerchantUid,
|
||||
AccountName: orderInfo.MerchantName,
|
||||
Type: conf.PLUS_AMOUNT,
|
||||
Type: config.PLUS_AMOUNT,
|
||||
Amount: orderProfitInfo.UserInAmount,
|
||||
Balance: accountInfo.Balance + orderProfitInfo.UserInAmount,
|
||||
UpdateTime: utils.GetBasicDateTime(),
|
||||
@@ -125,7 +125,7 @@ func SolvePaySuccess(bankOrderId string, factAmount float64, trxNo string) bool
|
||||
}
|
||||
|
||||
//更新订单利润表
|
||||
orderProfitInfo.Status = conf.SUCCESS
|
||||
orderProfitInfo.Status = config.SUCCESS
|
||||
orderProfitInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&orderProfitInfo); err != nil {
|
||||
logs.Error(fmt.Sprintf("solve pay success, update order profit info fail: %s, bankOrderId = %s", err, bankOrderId))
|
||||
@@ -133,7 +133,7 @@ func SolvePaySuccess(bankOrderId string, factAmount float64, trxNo string) bool
|
||||
}
|
||||
|
||||
// 给下游发送回调通知
|
||||
go CreateOrderNotifyInfo(orderInfo, conf.SUCCESS)
|
||||
go CreateOrderNotifyInfo(orderInfo, config.SUCCESS)
|
||||
|
||||
return nil
|
||||
})
|
||||
@@ -160,16 +160,16 @@ func SolvePayFail(bankOrderId, transId string) bool {
|
||||
if orderTmp.Status != "wait" {
|
||||
return errors.New("订单已经处理,不要重复加款")
|
||||
}
|
||||
if _, err := txOrm.QueryTable(order.ORDER_INFO).Filter("bank_order_id", bankOrderId).Update(orm.Params{"status": conf.FAIL, "bank_trans_id": transId}); err != nil {
|
||||
if _, err := txOrm.QueryTable(order.ORDER_INFO).Filter("bank_order_id", bankOrderId).Update(orm.Params{"status": config.FAIL, "bank_trans_id": transId}); err != nil {
|
||||
logs.Error("更改订单状态失败:", err)
|
||||
return err
|
||||
}
|
||||
if _, err := txOrm.QueryTable(order.ORDER_PROFIT_INFO).Filter("bank_order_id", bankOrderId).Update(orm.Params{"status": conf.FAIL, "bank_trans_id": transId}); err != nil {
|
||||
if _, err := txOrm.QueryTable(order.ORDER_PROFIT_INFO).Filter("bank_order_id", bankOrderId).Update(orm.Params{"status": config.FAIL, "bank_trans_id": transId}); err != nil {
|
||||
logs.Error("更改订单状态失败:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
go CreateOrderNotifyInfo(orderTmp, conf.FAIL)
|
||||
go CreateOrderNotifyInfo(orderTmp, config.FAIL)
|
||||
|
||||
return nil
|
||||
})
|
||||
@@ -195,12 +195,12 @@ func SolveOrderFreeze(bankOrderId string) bool {
|
||||
return err
|
||||
}
|
||||
|
||||
if orderInfo.Status != conf.SUCCESS {
|
||||
if orderInfo.Status != config.SUCCESS {
|
||||
logs.Error("非成功订单不能进行冻结")
|
||||
return errors.New("非成功订单不能进行冻结")
|
||||
}
|
||||
|
||||
orderInfo.Freeze = conf.YES
|
||||
orderInfo.Freeze = config.YES
|
||||
orderInfo.FreezeTime = utils.GetBasicDateTime()
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&orderInfo); err != nil {
|
||||
@@ -227,7 +227,7 @@ func SolveOrderFreeze(bankOrderId string) bool {
|
||||
accountHistoryInfo := accounts.AccountHistoryInfo{
|
||||
AccountName: accountInfo.AccountName,
|
||||
AccountUid: accountInfo.AccountUid,
|
||||
Type: conf.FREEZE_AMOUNT,
|
||||
Type: config.FREEZE_AMOUNT,
|
||||
Amount: orderProfitInfo.UserInAmount,
|
||||
Balance: accountInfo.Balance,
|
||||
UpdateTime: utils.GetBasicDateTime(),
|
||||
@@ -264,7 +264,7 @@ func SolveOrderUnfreeze(bankOrderId string) bool {
|
||||
}
|
||||
|
||||
orderInfo.Freeze = ""
|
||||
orderInfo.Unfreeze = conf.YES
|
||||
orderInfo.Unfreeze = config.YES
|
||||
orderInfo.UnfreezeTime = utils.GetBasicDateTime()
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(orderInfo); err != nil {
|
||||
@@ -290,7 +290,7 @@ func SolveOrderUnfreeze(bankOrderId string) bool {
|
||||
accountHistoryInfo := accounts.AccountHistoryInfo{
|
||||
AccountUid: accountInfo.AccountUid,
|
||||
AccountName: accountInfo.AccountName,
|
||||
Type: conf.UNFREEZE_AMOUNT,
|
||||
Type: config.UNFREEZE_AMOUNT,
|
||||
Amount: orderProfitInfo.UserInAmount,
|
||||
Balance: accountInfo.Balance,
|
||||
UpdateTime: utils.GetBasicDateTime(),
|
||||
@@ -321,7 +321,7 @@ func SolveRefund(bankOrderId string) bool {
|
||||
}
|
||||
|
||||
orderInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
orderInfo.Refund = conf.YES
|
||||
orderInfo.Refund = config.YES
|
||||
orderInfo.RefundTime = utils.GetBasicDateTime()
|
||||
|
||||
orderProfitInfo := order.GetOrderProfitByBankOrderId(bankOrderId)
|
||||
@@ -334,10 +334,10 @@ func SolveRefund(bankOrderId string) bool {
|
||||
account.SettleAmount = account.SettleAmount - orderProfitInfo.UserInAmount
|
||||
account.Balance = account.Balance - orderProfitInfo.UserInAmount
|
||||
|
||||
if orderInfo.Freeze == conf.YES {
|
||||
if orderInfo.Freeze == config.YES {
|
||||
account.FreezeAmount = account.FreezeAmount - orderProfitInfo.UserInAmount
|
||||
if account.FreezeAmount < 0 {
|
||||
account.FreezeAmount = conf.ZERO
|
||||
account.FreezeAmount = config.ZERO
|
||||
}
|
||||
orderInfo.Freeze = ""
|
||||
}
|
||||
@@ -354,7 +354,7 @@ func SolveRefund(bankOrderId string) bool {
|
||||
accountHistoryInfo := accounts.AccountHistoryInfo{
|
||||
AccountName: account.AccountName,
|
||||
AccountUid: account.AccountUid,
|
||||
Type: conf.REFUND,
|
||||
Type: config.REFUND,
|
||||
Amount: orderProfitInfo.UserInAmount,
|
||||
Balance: account.Balance,
|
||||
UpdateTime: utils.GetBasicDateTime(),
|
||||
@@ -385,7 +385,7 @@ func SolveOrderRoll(bankOrderId string) bool {
|
||||
return err
|
||||
}
|
||||
|
||||
if orderInfo.Status != conf.SUCCESS {
|
||||
if orderInfo.Status != config.SUCCESS {
|
||||
logs.Error("solve order roll 订单不存在或者订单状态不是success, bankOrderId=", bankOrderId)
|
||||
return errors.New("solve order roll failed")
|
||||
}
|
||||
@@ -399,10 +399,10 @@ func SolveOrderRoll(bankOrderId string) bool {
|
||||
}
|
||||
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if orderInfo.Refund == conf.YES {
|
||||
if orderInfo.Refund == config.YES {
|
||||
account.Balance = account.Balance + orderProfitInfo.UserInAmount
|
||||
account.SettleAmount = account.SettleAmount + orderProfitInfo.UserInAmount
|
||||
orderInfo.Refund = conf.NO
|
||||
orderInfo.Refund = config.NO
|
||||
}
|
||||
|
||||
if _, err := txOrm.Update(orderInfo); err != nil {
|
||||
@@ -417,7 +417,7 @@ func SolveOrderRoll(bankOrderId string) bool {
|
||||
accountHistoryInfo := accounts.AccountHistoryInfo{
|
||||
AccountUid: account.AccountUid,
|
||||
AccountName: account.AccountName,
|
||||
Type: conf.PLUS_AMOUNT,
|
||||
Type: config.PLUS_AMOUNT,
|
||||
Amount: orderProfitInfo.UserInAmount,
|
||||
Balance: account.Balance,
|
||||
UpdateTime: utils.GetBasicDateTime(),
|
||||
@@ -506,5 +506,5 @@ func CreateOrderNotifyInfo(orderInfo order.OrderInfo, tradeStatus string) {
|
||||
logs.Error(fmt.Sprintf("订单bankOrderId=%s,插入回调数据库失败", orderInfo.BankOrderId))
|
||||
}
|
||||
//将订单发送到消息队列,给下面的商户进行回调
|
||||
go message.SendMessage(conf.MqOrderNotify, orderInfo.BankOrderId)
|
||||
go message.SendMessage(config.MqOrderNotify, orderInfo.BankOrderId)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/models/accounts"
|
||||
"gateway/models/merchant"
|
||||
"gateway/models/order"
|
||||
@@ -32,8 +32,8 @@ const (
|
||||
func OrderSettle() {
|
||||
|
||||
params := make(map[string]string)
|
||||
params["is_allow_settle"] = conf.YES
|
||||
params["is_complete_settle"] = conf.NO
|
||||
params["is_allow_settle"] = config.YES
|
||||
params["is_complete_settle"] = config.NO
|
||||
orderSettleList := order.GetOrderSettleListByParams(params)
|
||||
for _, orderSettle := range orderSettleList {
|
||||
orderProfitInfo := order.GetOrderProfitByBankOrderId(orderSettle.BankOrderId)
|
||||
@@ -56,7 +56,7 @@ func settle(orderSettle order.OrderSettleInfo, orderProfit order.OrderProfitInfo
|
||||
}
|
||||
|
||||
tmpSettle.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpSettle.IsCompleteSettle = conf.YES
|
||||
tmpSettle.IsCompleteSettle = config.YES
|
||||
if _, err := txOrm.Update(tmpSettle); err != nil {
|
||||
logs.Error("更新tmpSettle失败,错误:", err)
|
||||
return err
|
||||
@@ -73,7 +73,7 @@ func settle(orderSettle order.OrderSettleInfo, orderProfit order.OrderProfitInfo
|
||||
// 商户有押款操作
|
||||
loadAmount := 0.0
|
||||
merchantDeployInfo := merchant.GetMerchantDeployByUidAndPayType(accountInfo.AccountUid, orderSettle.PayTypeCode)
|
||||
if merchantDeployInfo.IsLoan == conf.YES {
|
||||
if merchantDeployInfo.IsLoan == config.YES {
|
||||
loadAmount = merchantDeployInfo.LoanRate * 0.01 * orderProfit.FactAmount
|
||||
date := utils.GetDate()
|
||||
params := make(map[string]string)
|
||||
@@ -82,7 +82,7 @@ func settle(orderSettle order.OrderSettleInfo, orderProfit order.OrderProfitInfo
|
||||
params["load_date"] = date
|
||||
if !merchant.IsExistMerchantLoadByParams(params) {
|
||||
|
||||
tmp := merchant.MerchantLoadInfo{Status: conf.NO, MerchantUid: orderSettle.MerchantUid, RoadUid: orderSettle.RoadUid,
|
||||
tmp := merchant.MerchantLoadInfo{Status: config.NO, MerchantUid: orderSettle.MerchantUid, RoadUid: orderSettle.RoadUid,
|
||||
LoadDate: utils.GetDateAfterDays(merchantDeployInfo.LoanDays), LoadAmount: loadAmount,
|
||||
UpdateTime: utils.GetBasicDateTime(), CreateTime: utils.GetBasicDateTime()}
|
||||
|
||||
@@ -145,7 +145,7 @@ func MerchantLoadSolve() {
|
||||
|
||||
loadDate := utils.GetDateBeforeDays(merchantDeploy.LoanDays)
|
||||
params := make(map[string]string)
|
||||
params["status"] = conf.NO
|
||||
params["status"] = config.NO
|
||||
params["merchant_uid"] = merchantDeploy.MerchantUid
|
||||
params["load_date__lte"] = loadDate
|
||||
|
||||
@@ -175,13 +175,13 @@ func MerchantAbleAmount(merchantLoad merchant.MerchantLoadInfo) bool {
|
||||
return err
|
||||
|
||||
}
|
||||
if tmpLoad.Status != conf.NO {
|
||||
if tmpLoad.Status != config.NO {
|
||||
logs.Error(fmt.Sprintf("押款信息merchantuid=%s,通道uid=%s, 押款日期=%s,已经解款过,不需要再进行处理了", tmpLoad.MerchantUid, tmpLoad.RoadUid, tmpLoad.LoadDate))
|
||||
return errors.New("已经解款过,不需要再进行处理了")
|
||||
}
|
||||
|
||||
tmpLoad.UpdateTime = utils.GetBasicDateTime()
|
||||
tmpLoad.Status = conf.YES
|
||||
tmpLoad.Status = config.YES
|
||||
if _, err := txOrm.Update(tmpLoad); err != nil {
|
||||
logs.Error(fmt.Sprintf("解款操作更新merchant load info 失败:%s", err))
|
||||
return err
|
||||
@@ -197,7 +197,7 @@ func MerchantAbleAmount(merchantLoad merchant.MerchantLoadInfo) bool {
|
||||
accountInfo.LoanAmount = accountInfo.LoanAmount - tmpLoad.LoadAmount
|
||||
accountInfo.SettleAmount = accountInfo.SettleAmount + tmpLoad.LoadAmount
|
||||
} else {
|
||||
accountInfo.LoanAmount = conf.ZERO
|
||||
accountInfo.LoanAmount = config.ZERO
|
||||
}
|
||||
|
||||
if _, err := txOrm.Update(accountInfo); err != nil {
|
||||
|
||||
16
supplier/third_party/kuaifu.go
vendored
16
supplier/third_party/kuaifu.go
vendored
@@ -11,7 +11,7 @@ package third_party
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/models/merchant"
|
||||
"gateway/models/order"
|
||||
"gateway/models/payfor"
|
||||
@@ -250,7 +250,7 @@ func (c *KuaiFuImpl) PayFor(payFor payfor.PayforInfo) string {
|
||||
params["realname"] = payFor.BankAccountName
|
||||
params["cardNo"] = payFor.BankAccountNo
|
||||
params["bankCode"] = payFor.BankCode
|
||||
if payFor.BankAccountType == conf.PRIVATE {
|
||||
if payFor.BankAccountType == config.PRIVATE {
|
||||
params["accType"] = "01"
|
||||
} else {
|
||||
params["accType"] = "02"
|
||||
@@ -309,7 +309,7 @@ func (c *KuaiFuImpl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
response, err := req.String()
|
||||
if err != nil {
|
||||
logs.Error("快付代付查询失败:", err)
|
||||
return conf.PAYFOR_SOLVING, "查询失败"
|
||||
return config.PAYFOR_SOLVING, "查询失败"
|
||||
}
|
||||
|
||||
payFor.ResponseContent = response
|
||||
@@ -324,7 +324,7 @@ func (c *KuaiFuImpl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
|
||||
if resultCode != "00" {
|
||||
logs.Error("快付代付查询返回错误:", resultMsg)
|
||||
return conf.PAYFOR_SOLVING, resultMsg
|
||||
return config.PAYFOR_SOLVING, resultMsg
|
||||
}
|
||||
|
||||
logs.Info("快付代付查询返回结果:", resultMsg)
|
||||
@@ -332,17 +332,17 @@ func (c *KuaiFuImpl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
merchantOrderId := gojson.Json(response).Get("merchantOrderId").Tostring()
|
||||
if merchantOrderId != payFor.BankOrderId {
|
||||
logs.Error("快付代付返回结果,订单id不一致: ", merchantOrderId)
|
||||
return conf.PAYFOR_SOLVING, "快付代付返回结果,订单id不一致"
|
||||
return config.PAYFOR_SOLVING, "快付代付返回结果,订单id不一致"
|
||||
}
|
||||
|
||||
settStatus := gojson.Json(response).Get("settStatus").Tostring()
|
||||
|
||||
if settStatus == "00" {
|
||||
return conf.PAYFOR_SUCCESS, "代付成功"
|
||||
return config.PAYFOR_SUCCESS, "代付成功"
|
||||
} else if settStatus == "01" {
|
||||
return conf.PAYFOR_FAIL, "代付失败"
|
||||
return config.PAYFOR_FAIL, "代付失败"
|
||||
} else {
|
||||
return conf.PAYFOR_BANKING, "银行处理中"
|
||||
return config.PAYFOR_BANKING, "银行处理中"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
22
supplier/third_party/mf178_v2.go
vendored
22
supplier/third_party/mf178_v2.go
vendored
@@ -6,7 +6,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
"gateway/models/merchant"
|
||||
"gateway/models/order"
|
||||
"gateway/models/payfor"
|
||||
@@ -304,10 +304,10 @@ func (c *MFCardV2Impl) PayFor(info payfor.PayforInfo) string {
|
||||
}
|
||||
|
||||
func (c *MFCardV2Impl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
cfg := conf.Config{}
|
||||
cfg := config.Config{}
|
||||
url, err := cfg.GetMFCardQueryUrl()
|
||||
if err != nil {
|
||||
return conf.PAYFOR_FAIL, ""
|
||||
return config.PAYFOR_FAIL, ""
|
||||
}
|
||||
|
||||
params := map[string]string{}
|
||||
@@ -319,7 +319,7 @@ func (c *MFCardV2Impl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
if err != nil {
|
||||
logs.Error("Map转化为byte数组失败,异常。", err)
|
||||
//fmt.Printf("Map转化为byte数组失败,异常:%s\n", err)
|
||||
return conf.PAYFOR_FAIL, "内部错误请稍后再试试(01)"
|
||||
return config.PAYFOR_FAIL, "内部错误请稍后再试试(01)"
|
||||
}
|
||||
logs.Info("请求参数:" + string(marshal))
|
||||
req.Header("Content-Type", "application/json")
|
||||
@@ -330,14 +330,14 @@ func (c *MFCardV2Impl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
|
||||
if err != nil {
|
||||
logs.Error("MF GetToken 请求失败:", err)
|
||||
return conf.PAYFOR_FAIL, ""
|
||||
return config.PAYFOR_FAIL, ""
|
||||
}
|
||||
|
||||
logs.Info("远端请求返回数据:" + response)
|
||||
|
||||
if gojson.Json(response).Get("code").Tostring() == "" {
|
||||
logs.Error("远程调用失败")
|
||||
return conf.PAYFOR_BANKING, ""
|
||||
return config.PAYFOR_BANKING, ""
|
||||
}
|
||||
|
||||
if gojson.Json(response).Get("code").Tostring() == "0" {
|
||||
@@ -357,24 +357,24 @@ func (c *MFCardV2Impl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
|
||||
err2 := json.Unmarshal([]byte(gojson.Json(response).Get("data").Tostring()), &d)
|
||||
if err2 != nil {
|
||||
return conf.PAYFOR_FAIL, ""
|
||||
return config.PAYFOR_FAIL, ""
|
||||
}
|
||||
|
||||
if d.Status == 9 {
|
||||
return conf.PAYFOR_SUCCESS, ""
|
||||
return config.PAYFOR_SUCCESS, ""
|
||||
}
|
||||
|
||||
if d.Status == 4 {
|
||||
return conf.PAYFOR_BANKING, ""
|
||||
return config.PAYFOR_BANKING, ""
|
||||
}
|
||||
|
||||
if d.Status == 7 || d.Status == 8 {
|
||||
return conf.PAYFOR_FAIL, ""
|
||||
return config.PAYFOR_FAIL, ""
|
||||
}
|
||||
}
|
||||
|
||||
logs.Error("远程调用失败")
|
||||
return conf.PAYFOR_BANKING, ""
|
||||
return config.PAYFOR_BANKING, ""
|
||||
}
|
||||
|
||||
func (c *MFCardV2Impl) BalanceQuery(roadInfo road.RoadInfo) float64 {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"gateway/conf"
|
||||
"gateway/config"
|
||||
_ "gateway/message"
|
||||
_ "gateway/models"
|
||||
"gateway/models/payfor"
|
||||
@@ -24,7 +24,7 @@ func TestAutoPayFor(t *testing.T) {
|
||||
params["merchantOrderId"] = xid.New().String()
|
||||
keys := utils.SortMap(params)
|
||||
params["sign"] = utils.GetMD5Sign(params, keys, paySecret)
|
||||
payFor := pay_for.AutoPayFor(params, conf.SELF_API)
|
||||
payFor := pay_for.AutoPayFor(params, config.SELF_API)
|
||||
logs.Info(payFor)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user