feat: 继续添加充值卡充值回调
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
/.idea/
|
/.idea/
|
||||||
/.vscode/
|
/.vscode/
|
||||||
/main.exe
|
/main.exe
|
||||||
|
/logs/
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
appname = jhgateway
|
appname = jhgateway
|
||||||
HTTPAddr = localhost
|
|
||||||
httpport = 12309
|
httpport = 12309
|
||||||
RemoteAddr = localhost
|
RemoteAddr = 0.0.0.0
|
||||||
RemotePort = 12309
|
RemotePort = 12309
|
||||||
runmode = dev
|
runmode = prod
|
||||||
HTTPAddr = localhost
|
HTTPAddr = 0.0.0.0
|
||||||
sessionon = true
|
sessionon = true
|
||||||
copyrequestbody = true
|
copyrequestbody = true
|
||||||
|
|
||||||
@@ -22,14 +21,14 @@ separate="["emergency","alert","critical","error","warning","notice","info","deb
|
|||||||
maxdays=10
|
maxdays=10
|
||||||
|
|
||||||
[mysql]
|
[mysql]
|
||||||
dbhost = localhost
|
dbhost = mysql
|
||||||
dbport = 3306
|
dbport = 3306
|
||||||
dbuser = root
|
dbuser = root
|
||||||
dbpasswd = 123456
|
dbpasswd = 123456
|
||||||
dbbase = juhe_pay
|
dbbase = kami
|
||||||
|
|
||||||
[mq]
|
[mq]
|
||||||
host = 127.0.0.1
|
host = rabbitmq
|
||||||
port = 61613
|
port = 61613
|
||||||
|
|
||||||
[mf]
|
[mf]
|
||||||
@@ -42,6 +41,13 @@ query_card_url = http://test.shop.center.mf178.cn/userapi/card/order_info
|
|||||||
key = BjI@3@N5XeU7kLP5$MppMobz$3ljek7d
|
key = BjI@3@N5XeU7kLP5$MppMobz$3ljek7d
|
||||||
|
|
||||||
[appleCard]
|
[appleCard]
|
||||||
submit_card_url=http://test.shop.center.mf178.cn/userapi/card/submit_card
|
; 提交卡密接口
|
||||||
|
submit_card_url = http://kami_backend:12401/api/cardInfo/appleCard/submit
|
||||||
|
; url = https://shop.task.mf178.cn/userapi/card/submit_card
|
||||||
|
query_card_url = http://kami_backend:12401/api/cardInfo/appleCard/query
|
||||||
|
notify_url = http://kami_gateway:12309/appleCard/notify
|
||||||
|
|
||||||
|
[tMallGame]
|
||||||
|
submit_card_url=http://test.shop.center.mf178.cn/recharge/tMallGame/order/submit
|
||||||
notify_url=http://test.shop.center.mf178.cn/appleCard/notify
|
notify_url=http://test.shop.center.mf178.cn/appleCard/notify
|
||||||
query_card_url=http://test.shop.center.mf178.cn/userapi/card/order_info
|
query_card_url=http://test.shop.center.mf178.cn/userapi/card/order_info
|
||||||
@@ -4,7 +4,7 @@ ENV GO111MODULE=on GOPROXY=https://goproxy.cn,direct CGO_ENABLED=0 GOOS=linux GO
|
|||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
COPY ./ /build/
|
COPY .. /build/
|
||||||
|
|
||||||
RUN go mod tidy && go build main.go
|
RUN go mod tidy && go build main.go
|
||||||
|
|
||||||
@@ -22,10 +22,9 @@ RUN echo "https://mirrors.aliyun.com/alpine/v3.18/main/" > /etc/apk/repositories
|
|||||||
|
|
||||||
COPY --from=builder /build/main /app/
|
COPY --from=builder /build/main /app/
|
||||||
COPY --from=builder /build/conf/ /app/conf/
|
COPY --from=builder /build/conf/ /app/conf/
|
||||||
COPY --from=builder /build/views/ /app/views/
|
COPY --from=builder /build/deploy/wait-for-it.sh /app/
|
||||||
COPY --from=builder /build/static/ /app/static/
|
|
||||||
|
|
||||||
# 启动服务
|
# 启动服务
|
||||||
CMD ["./main"]
|
CMD ["sh", "wait-for-it.sh", "-p", "mysql:3306", "-p", "rabbitmq:61613", "./main"]
|
||||||
|
|
||||||
EXPOSE 12309
|
EXPOSE 12309
|
||||||
17
deploy/docker-compose-local.yaml
Normal file
17
deploy/docker-compose-local.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
services:
|
||||||
|
gateway_kami:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: ./deploy/Dockerfile
|
||||||
|
container_name: kami_gateway
|
||||||
|
image: kami_gateway:latest
|
||||||
|
ports:
|
||||||
|
- "12309:12309"
|
||||||
|
networks:
|
||||||
|
- 1panel-network
|
||||||
|
labels:
|
||||||
|
createdBy: Developer
|
||||||
|
|
||||||
|
networks:
|
||||||
|
1panel-network:
|
||||||
|
external: true
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
kami_gateway:
|
kami_gateway:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: ./deploy/Dockerfile
|
||||||
container_name: kami_gateway
|
container_name: kami_gateway
|
||||||
image: kami_gateway:$VERSION
|
image: kami_gateway:$VERSION
|
||||||
restart:
|
restart:
|
||||||
52
deploy/wait-for-it.sh
Normal file
52
deploy/wait-for-it.sh
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# 初始化变量
|
||||||
|
hosts=""
|
||||||
|
|
||||||
|
# 解析命令行参数
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
-p)
|
||||||
|
shift
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "No host:port provided after -p"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
hosts="$hosts $1"
|
||||||
|
;;
|
||||||
|
-*|--*)
|
||||||
|
echo "Unknown option $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# 检查是否提供了主机
|
||||||
|
if [ -z "$hosts" ]; then
|
||||||
|
echo "No hosts provided. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 等待所有服务变得可用
|
||||||
|
for host in $hosts; do
|
||||||
|
addr=$(echo $host | cut -d':' -f1)
|
||||||
|
port=$(echo $host | cut -d':' -f2)
|
||||||
|
while ! nc -z "$addr" "$port"; do
|
||||||
|
echo "Waiting for $addr:$port..." >&2
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo "$addr:$port is available!"
|
||||||
|
done
|
||||||
|
|
||||||
|
# 执行最终命令
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "No command provided to execute. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
version: '3.8'
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
container_name: kami_gateway_test
|
|
||||||
image: kami_gateway_test:0.11
|
|
||||||
restart:
|
|
||||||
always
|
|
||||||
ports:
|
|
||||||
- "22309:12309"
|
|
||||||
volumes:
|
|
||||||
- /data/kami/gateway/conf/:/app/conf/
|
|
||||||
- /data/kami/gateway/logs/:/app/logs/
|
|
||||||
networks:
|
|
||||||
- 1panel-network
|
|
||||||
labels:
|
|
||||||
createdBy: Developer
|
|
||||||
|
|
||||||
networks:
|
|
||||||
1panel-network:
|
|
||||||
external: true
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package gateway
|
package gateway
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gateway/internal/response"
|
"gateway/internal/schema/response"
|
||||||
"gateway/internal/service"
|
"gateway/internal/service"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"gateway/internal/models/merchant"
|
"gateway/internal/models/merchant"
|
||||||
"gateway/internal/models/order"
|
"gateway/internal/models/order"
|
||||||
"gateway/internal/models/response"
|
"gateway/internal/models/response"
|
||||||
"gateway/internal/query"
|
"gateway/internal/schema/query"
|
||||||
"gateway/internal/service"
|
"gateway/internal/service"
|
||||||
"gateway/internal/utils"
|
"gateway/internal/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"gateway/internal/models/order"
|
"gateway/internal/models/order"
|
||||||
"gateway/internal/models/payfor"
|
"gateway/internal/models/payfor"
|
||||||
"gateway/internal/models/road"
|
"gateway/internal/models/road"
|
||||||
"gateway/internal/pay_for"
|
"gateway/internal/schema/response"
|
||||||
"gateway/internal/response"
|
pay_for2 "gateway/internal/service/pay_for"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
@@ -41,7 +41,7 @@ func (c *PayForGateway) PayFor() {
|
|||||||
payForResponse.ResultCode = "01"
|
payForResponse.ResultCode = "01"
|
||||||
payForResponse.ResultMsg = msg
|
payForResponse.ResultMsg = msg
|
||||||
} else {
|
} else {
|
||||||
payForResponse = pay_for.AutoPayFor(params, config.SELF_API)
|
payForResponse = pay_for2.AutoPayFor(params, config.SELF_API)
|
||||||
}
|
}
|
||||||
c.Data["json"] = payForResponse
|
c.Data["json"] = payForResponse
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
@@ -55,7 +55,7 @@ func (c *PayForGateway) PayForQuery() {
|
|||||||
params["merchantOrderId"] = strings.TrimSpace(c.GetString("merchantOrderId"))
|
params["merchantOrderId"] = strings.TrimSpace(c.GetString("merchantOrderId"))
|
||||||
params["sign"] = strings.TrimSpace(c.GetString("sign"))
|
params["sign"] = strings.TrimSpace(c.GetString("sign"))
|
||||||
|
|
||||||
c.Data["json"] = pay_for.PayForResultQuery(params)
|
c.Data["json"] = pay_for2.PayForResultQuery(params)
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,9 +95,9 @@ func (c *PayForGateway) SolvePayForResult() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resultType == config.PAYFOR_FAIL {
|
if resultType == config.PAYFOR_FAIL {
|
||||||
pay_for.PayForFail(p)
|
pay_for2.PayForFail(p)
|
||||||
} else if resultType == config.PAYFOR_SUCCESS {
|
} else if resultType == config.PAYFOR_SUCCESS {
|
||||||
pay_for.PayForSuccess(p)
|
pay_for2.PayForSuccess(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Ctx.WriteString(config.SUCCESS)
|
c.Ctx.WriteString(config.SUCCESS)
|
||||||
@@ -117,7 +117,7 @@ func (c *PayForGateway) Balance() {
|
|||||||
balanceResponse.ResultMsg = msg
|
balanceResponse.ResultMsg = msg
|
||||||
c.Data["json"] = balanceResponse
|
c.Data["json"] = balanceResponse
|
||||||
} else {
|
} else {
|
||||||
c.Data["json"] = pay_for.BalanceQuery(params)
|
c.Data["json"] = pay_for2.BalanceQuery(params)
|
||||||
}
|
}
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
"gateway/internal/models/merchant_deploy"
|
"gateway/internal/models/merchant_deploy"
|
||||||
"gateway/internal/models/order"
|
"gateway/internal/models/order"
|
||||||
"gateway/internal/models/road"
|
"gateway/internal/models/road"
|
||||||
"gateway/internal/request"
|
request2 "gateway/internal/schema/request"
|
||||||
"gateway/internal/response"
|
response2 "gateway/internal/schema/response"
|
||||||
"gateway/internal/service"
|
"gateway/internal/service"
|
||||||
"gateway/internal/utils"
|
"gateway/internal/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -82,7 +82,6 @@ func (c *ScanController) Scan() {
|
|||||||
// 生成订单记录
|
// 生成订单记录
|
||||||
orderInfo, _, err := service.GenerateRecord(p)
|
orderInfo, _, err := service.GenerateRecord(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Code = -1
|
|
||||||
p.Msg = fmt.Sprintf("生成订单失败:%v", err.Error())
|
p.Msg = fmt.Sprintf("生成订单失败:%v", err.Error())
|
||||||
c.SolveFailJSON(p)
|
c.SolveFailJSON(p)
|
||||||
return
|
return
|
||||||
@@ -99,7 +98,7 @@ func (c *ScanController) Scan() {
|
|||||||
params["statusCode"] = "00"
|
params["statusCode"] = "00"
|
||||||
sign := utils.GetMD5SignMF(params, p.MerchantInfo.MerchantSecret)
|
sign := utils.GetMD5SignMF(params, p.MerchantInfo.MerchantSecret)
|
||||||
|
|
||||||
c.Data["json"] = response.ScanSuccessData{
|
c.Data["json"] = response2.ScanSuccessData{
|
||||||
OrderNo: orderInfo.BankOrderId,
|
OrderNo: orderInfo.BankOrderId,
|
||||||
OrderPrice: strconv.FormatFloat(orderInfo.OrderAmount, 'f', 2, 64),
|
OrderPrice: strconv.FormatFloat(orderInfo.OrderAmount, 'f', 2, 64),
|
||||||
StatusCode: "00",
|
StatusCode: "00",
|
||||||
@@ -118,7 +117,7 @@ func (c *ScanController) Scan() {
|
|||||||
service.SolvePayFail(orderInfo.BankOrderId, "")
|
service.SolvePayFail(orderInfo.BankOrderId, "")
|
||||||
logs.Error("获取上游渠道失败,请联系客服", supplierCode)
|
logs.Error("获取上游渠道失败,请联系客服", supplierCode)
|
||||||
err = errors.New("获取上游渠道失败,请联系客服")
|
err = errors.New("获取上游渠道失败,请联系客服")
|
||||||
c.Data["json"] = response.CommonErr(-1, err.Error())
|
c.Data["json"] = response2.CommonErr(-1, err.Error())
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
c.StopRun()
|
c.StopRun()
|
||||||
return
|
return
|
||||||
@@ -141,8 +140,8 @@ func (c *ScanController) Scan() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SolveFailJSON 处理错误的返回
|
// SolveFailJSON 处理错误的返回
|
||||||
func (c *ScanController) SolveFailJSON(p *response.PayBaseResp) {
|
func (c *ScanController) SolveFailJSON(p *response2.PayBaseResp) {
|
||||||
scanFailJSON := new(response.ScanFailData)
|
scanFailJSON := new(response2.ScanFailData)
|
||||||
scanFailJSON.StatusCode = "01"
|
scanFailJSON.StatusCode = "01"
|
||||||
scanFailJSON.PayKey = p.Params["payKey"]
|
scanFailJSON.PayKey = p.Params["payKey"]
|
||||||
scanFailJSON.Msg = p.Msg
|
scanFailJSON.Msg = p.Msg
|
||||||
@@ -157,32 +156,32 @@ func (c *ScanController) GetAllowedMM() {
|
|||||||
showMMValue, err := c.GetFloat("showMMValue")
|
showMMValue, err := c.GetFloat("showMMValue")
|
||||||
productCode := strings.TrimSpace(c.GetString("productCode"))
|
productCode := strings.TrimSpace(c.GetString("productCode"))
|
||||||
if payKey == "" || showMMValue == 0 || productCode == "" {
|
if payKey == "" || showMMValue == 0 || productCode == "" {
|
||||||
res := response.CommonErr(-1, "获取面额失败,参数缺失")
|
res := response2.CommonErr(-1, "获取面额失败,参数缺失")
|
||||||
c.Data["json"] = res
|
c.Data["json"] = res
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Data["json"] = response.CommonErr(-1, err.Error())
|
c.Data["json"] = response2.CommonErr(-1, err.Error())
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
c.StopRun()
|
c.StopRun()
|
||||||
}
|
}
|
||||||
merchantInfo, err := service.GetMerchantInfoByPayKey(payKey)
|
merchantInfo, err := service.GetMerchantInfoByPayKey(payKey)
|
||||||
if err != nil || merchantInfo.Id == 0 {
|
if err != nil || merchantInfo.Id == 0 {
|
||||||
c.Data["json"] = response.CommonErr(-1, "获取面额失败,获取商户信息出错")
|
c.Data["json"] = response2.CommonErr(-1, "获取面额失败,获取商户信息出错")
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
c.StopRun()
|
c.StopRun()
|
||||||
}
|
}
|
||||||
merchantDeployInfo := service.GerMerchantDeployInfoByUidAndProductCode(merchantInfo.MerchantUid, productCode)
|
merchantDeployInfo := service.GerMerchantDeployInfoByUidAndProductCode(merchantInfo.MerchantUid, productCode)
|
||||||
if merchantDeployInfo.Id == 0 {
|
if merchantDeployInfo.Id == 0 {
|
||||||
res := response.CommonErr(-1, "获取面额失败,当前通道不存在")
|
res := response2.CommonErr(-1, "获取面额失败,当前通道不存在")
|
||||||
c.Data["json"] = res
|
c.Data["json"] = res
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
profitMarginList, err := merchantDeployInfo.GetFactMMValue(showMMValue)
|
profitMarginList, err := merchantDeployInfo.GetFactMMValue(showMMValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Data["json"] = response.CommonErr(-1, err.Error())
|
c.Data["json"] = response2.CommonErr(-1, err.Error())
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
c.StopRun()
|
c.StopRun()
|
||||||
}
|
}
|
||||||
@@ -209,27 +208,27 @@ func (c *ScanController) GetAllowedMM() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
logs.Info("转换后的面额数据:%+v", resData)
|
logs.Info("转换后的面额数据:%+v", resData)
|
||||||
c.Data["json"] = response.Ok(resData)
|
c.Data["json"] = response2.Ok(resData)
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOrder 创建订单
|
// CreateOrder 创建订单
|
||||||
func (c *ScanController) CreateOrder() {
|
func (c *ScanController) CreateOrder() {
|
||||||
createdOrder := request.CreatedOrder{}
|
createdOrder := request2.CreatedOrder{}
|
||||||
_ = c.BindJSON(&createdOrder)
|
_ = c.BindJSON(&createdOrder)
|
||||||
|
|
||||||
valid := validation.Validation{}
|
valid := validation.Validation{}
|
||||||
b, err := valid.Valid(&createdOrder)
|
b, err := valid.Valid(&createdOrder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("创建订单错误:", err)
|
logs.Error("创建订单错误:", err)
|
||||||
res := response.CommonErr(-1, "创建订单错误,参数错误")
|
res := response2.CommonErr(-1, "创建订单错误,参数错误")
|
||||||
c.Data["json"] = res
|
c.Data["json"] = res
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !b {
|
if !b {
|
||||||
logs.Error("创建订单错误:", valid.Errors)
|
logs.Error("创建订单错误:", valid.Errors)
|
||||||
res := response.CommonErr(-1, "创建订单错误,参数验证错误")
|
res := response2.CommonErr(-1, "创建订单错误,参数验证错误")
|
||||||
c.Data["json"] = res
|
c.Data["json"] = res
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
return
|
return
|
||||||
@@ -237,13 +236,13 @@ func (c *ScanController) CreateOrder() {
|
|||||||
merchantInfo := merchant.GetMerchantByPasskey(createdOrder.PayKey)
|
merchantInfo := merchant.GetMerchantByPasskey(createdOrder.PayKey)
|
||||||
if merchantInfo.Id == 0 {
|
if merchantInfo.Id == 0 {
|
||||||
logs.Error("创建订单错误:", err)
|
logs.Error("创建订单错误:", err)
|
||||||
res := response.CommonErr(-1, "创建订单错误")
|
res := response2.CommonErr(-1, "创建订单错误")
|
||||||
c.Data["json"] = res
|
c.Data["json"] = res
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !utils.Md5MFVerify(createdOrder.ToMap(), merchantInfo.MerchantSecret) {
|
if !utils.Md5MFVerify(createdOrder.ToMap(), merchantInfo.MerchantSecret) {
|
||||||
res := response.CommonErr(-1, "sign验证错误")
|
res := response2.CommonErr(-1, "sign验证错误")
|
||||||
logs.Error("sign验证错误")
|
logs.Error("sign验证错误")
|
||||||
c.Data["json"] = res
|
c.Data["json"] = res
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
@@ -252,12 +251,14 @@ func (c *ScanController) CreateOrder() {
|
|||||||
orderInfo := order.GetOrderByMerchantOrderId(createdOrder.OrderNo)
|
orderInfo := order.GetOrderByMerchantOrderId(createdOrder.OrderNo)
|
||||||
roadInfo := road.GetRoadInfoByProductCode(createdOrder.ProductCode)
|
roadInfo := road.GetRoadInfoByProductCode(createdOrder.ProductCode)
|
||||||
if orderInfo.Id != 0 {
|
if orderInfo.Id != 0 {
|
||||||
res := response.Ok(struct {
|
res := response2.Ok(struct {
|
||||||
ProductCode string `json:"productCode"`
|
ProductCode string `json:"productCode"`
|
||||||
PaymentName string `json:"paymentName"`
|
PaymentName string `json:"paymentName"`
|
||||||
|
TransactionType string `json:"TransactionType"`
|
||||||
}{
|
}{
|
||||||
ProductCode: createdOrder.ProductCode,
|
ProductCode: createdOrder.ProductCode,
|
||||||
PaymentName: roadInfo.PaymentHtml,
|
PaymentName: roadInfo.PaymentHtml,
|
||||||
|
TransactionType: roadInfo.TransactionType,
|
||||||
})
|
})
|
||||||
c.Data["json"] = res
|
c.Data["json"] = res
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
@@ -265,13 +266,13 @@ func (c *ScanController) CreateOrder() {
|
|||||||
}
|
}
|
||||||
roadInfo, err = service.CreateOrderInfoAndOrderProfitInfo(createdOrder, merchantInfo)
|
roadInfo, err = service.CreateOrderInfoAndOrderProfitInfo(createdOrder, merchantInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res := response.CommonErr(-1, err.Error())
|
res := response2.CommonErr(-1, err.Error())
|
||||||
logs.Info("创建订单错误:", err)
|
logs.Info("创建订单错误:", err)
|
||||||
c.Data["json"] = res
|
c.Data["json"] = res
|
||||||
_ = c.ServeJSON()
|
_ = c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res := response.Ok(struct {
|
res := response2.Ok(struct {
|
||||||
ProductCode string `json:"productCode"`
|
ProductCode string `json:"productCode"`
|
||||||
PaymentName string `json:"paymentName"`
|
PaymentName string `json:"paymentName"`
|
||||||
TransactionType string `json:"TransactionType"`
|
TransactionType string `json:"TransactionType"`
|
||||||
@@ -285,11 +286,11 @@ func (c *ScanController) CreateOrder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ScanController) QueryAccountInfo() {
|
func (c *ScanController) QueryAccountInfo() {
|
||||||
accountInfo := request.ThirdPartyAccountInfo{}
|
accountInfo := request2.ThirdPartyAccountInfo{}
|
||||||
channelName := c.Ctx.Input.Param("channel")
|
channelName := c.Ctx.Input.Param("channel")
|
||||||
if channelName == "TMallGame" {
|
if channelName == "TMallGame" {
|
||||||
_ = c.BindJSON(&accountInfo)
|
_ = c.BindJSON(&accountInfo)
|
||||||
err := t_mall_game.QueryTMallGameAccountInfo(context.Background())
|
err := t_mall_game.QueryTMallGameAccountInfo(context.Background(), request2.ThirdPartyAccountInfo{})
|
||||||
_ = err
|
_ = err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"gateway/internal/config"
|
"gateway/internal/config"
|
||||||
"gateway/internal/request"
|
"gateway/internal/schema/request"
|
||||||
"github.com/beego/beego/v2/client/httplib"
|
"github.com/beego/beego/v2/client/httplib"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
20
internal/entities/supplier/third_party/init.go
vendored
20
internal/entities/supplier/third_party/init.go
vendored
@@ -7,27 +7,25 @@ import (
|
|||||||
|
|
||||||
// 添加新的上游通道时,需要添加这里
|
// 添加新的上游通道时,需要添加这里
|
||||||
var supplierCode2Name = map[string]string{
|
var supplierCode2Name = map[string]string{
|
||||||
"KF": "快付支付",
|
"MF178": "178卡密",
|
||||||
"WEIXIN": "官方微信",
|
"APPLE": "苹果itunes充值",
|
||||||
"ALIPAY": "官方支付宝",
|
"TMALLGAME": "天猫店铺充值",
|
||||||
"DAILI": "代丽支付",
|
|
||||||
"MF178": "178卡密",
|
|
||||||
"APPLE": "苹果itunes充值",
|
|
||||||
"T_MALL_GAME": "天猫店铺充值",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var registerSupplier = make(map[string]supplier.PayInterface)
|
var registerSupplier = make(map[string]supplier.PayInterface)
|
||||||
|
|
||||||
// 注册各种上游的支付接口
|
// 注册各种上游的支付接口
|
||||||
func init() {
|
func init() {
|
||||||
registerSupplier["KF"] = new(KuaiFuImpl)
|
//registerSupplier["KF"] = new(KuaiFuImpl)
|
||||||
logs.Notice(CheckSupplierByCode("KF"))
|
//logs.Notice(CheckSupplierByCode("KF"))
|
||||||
registerSupplier["DAILI"] = new(DaiLiImpl)
|
//registerSupplier["DAILI"] = new(DaiLiImpl)
|
||||||
logs.Notice(CheckSupplierByCode("DAILI"))
|
//logs.Notice(CheckSupplierByCode("DAILI"))
|
||||||
registerSupplier["APPLE"] = new(AppleCardImpl)
|
registerSupplier["APPLE"] = new(AppleCardImpl)
|
||||||
logs.Notice(CheckSupplierByCode("APPLE"))
|
logs.Notice(CheckSupplierByCode("APPLE"))
|
||||||
registerSupplier["MF178"] = new(MFCardV2Impl)
|
registerSupplier["MF178"] = new(MFCardV2Impl)
|
||||||
logs.Notice(CheckSupplierByCode("MF178"))
|
logs.Notice(CheckSupplierByCode("MF178"))
|
||||||
|
registerSupplier["TMALLGAME"] = new(TMAllGameImpl)
|
||||||
|
logs.Notice(CheckSupplierByCode("TMALLGAME"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPaySupplierByCode(code string) supplier.PayInterface {
|
func GetPaySupplierByCode(code string) supplier.PayInterface {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func (c *TMAllGameImpl) SendCard(jsonStr string, cardInfo supplier.CardInfo, ord
|
|||||||
req.Header("tokenFrom", "iframe")
|
req.Header("tokenFrom", "iframe")
|
||||||
response, err := req.String()
|
response, err := req.String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("Apple GetToken 请求失败:", err)
|
logs.Error("天猫店铺请求失败:", err)
|
||||||
return false, ""
|
return false, ""
|
||||||
}
|
}
|
||||||
logs.Info("远端请求返回数据:" + response)
|
logs.Info("远端请求返回数据:" + response)
|
||||||
@@ -109,7 +109,7 @@ func (c *TMAllGameImpl) SendCard(jsonStr string, cardInfo supplier.CardInfo, ord
|
|||||||
return false, response
|
return false, response
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *TMAllGameImpl) Scan(orderInfo order.OrderInfo, roadInfo road.RoadInfo) supplier.ScanData {
|
func (c *TMAllGameImpl) Scan(orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) supplier.ScanData {
|
||||||
var cdata supplier.CardInfo
|
var cdata supplier.CardInfo
|
||||||
if roadInfo.TransactionType == string(consts.TransactionTypeRedeem) {
|
if roadInfo.TransactionType == string(consts.TransactionTypeRedeem) {
|
||||||
cdata = &supplier.RedeemCardInfo{}
|
cdata = &supplier.RedeemCardInfo{}
|
||||||
|
|||||||
@@ -1,13 +1,3 @@
|
|||||||
package agent
|
package agent
|
||||||
|
|
||||||
/***************************************************
|
|
||||||
** @Desc : This file for ...
|
|
||||||
** @Time : 2019/12/17 17:50
|
|
||||||
** @Author : yuebin
|
|
||||||
** @File : agent_profit
|
|
||||||
** @Last Modified by : yuebin
|
|
||||||
** @Last Modified time: 2019/12/17 17:50
|
|
||||||
** @Software: GoLand
|
|
||||||
****************************************************/
|
|
||||||
|
|
||||||
type AgentProfit struct{}
|
type AgentProfit struct{}
|
||||||
|
|||||||
@@ -4,17 +4,16 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"gateway/internal/models/accounts"
|
"gateway/internal/models/accounts"
|
||||||
"gateway/internal/models/agent"
|
"gateway/internal/models/agent"
|
||||||
merchant2 "gateway/internal/models/merchant"
|
"gateway/internal/models/merchant"
|
||||||
"gateway/internal/models/merchant_deploy"
|
"gateway/internal/models/merchant_deploy"
|
||||||
"gateway/internal/models/notify"
|
"gateway/internal/models/notify"
|
||||||
"gateway/internal/models/order"
|
"gateway/internal/models/order"
|
||||||
"gateway/internal/models/payfor"
|
"gateway/internal/models/payfor"
|
||||||
"gateway/internal/models/road"
|
"gateway/internal/models/road"
|
||||||
system2 "gateway/internal/models/system"
|
"gateway/internal/models/system"
|
||||||
"gateway/internal/models/user"
|
"gateway/internal/models/user"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/client/orm"
|
"github.com/beego/beego/v2/client/orm"
|
||||||
"github.com/beego/beego/v2/core/logs"
|
|
||||||
"github.com/beego/beego/v2/server/web"
|
"github.com/beego/beego/v2/server/web"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
@@ -28,19 +27,18 @@ func init() {
|
|||||||
|
|
||||||
link := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&loc=Local&parseTime=true", dbUser, dbPassword, dbHost, dbPort, dbBase)
|
link := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&loc=Local&parseTime=true", dbUser, dbPassword, dbHost, dbPort, dbBase)
|
||||||
|
|
||||||
logs.Info("mysql init.....", link)
|
|
||||||
_ = orm.RegisterDriver("mysql", orm.DRMySQL)
|
_ = orm.RegisterDriver("mysql", orm.DRMySQL)
|
||||||
_ = orm.RegisterDataBase("default", "mysql", link)
|
_ = orm.RegisterDataBase("default", "mysql", link)
|
||||||
orm.RegisterModel(new(user.UserInfo),
|
orm.RegisterModel(new(user.UserInfo),
|
||||||
new(system2.MenuInfo),
|
new(system.MenuInfo),
|
||||||
new(system2.SecondMenuInfo),
|
new(system.SecondMenuInfo),
|
||||||
new(system2.PowerInfo),
|
new(system.PowerInfo),
|
||||||
new(system2.RoleInfo),
|
new(system.RoleInfo),
|
||||||
new(system2.BankCardInfo),
|
new(system.BankCardInfo),
|
||||||
new(road.RoadInfo),
|
new(road.RoadInfo),
|
||||||
new(road.RoadPoolInfo),
|
new(road.RoadPoolInfo),
|
||||||
new(agent.AgentInfo),
|
new(agent.AgentInfo),
|
||||||
new(merchant2.MerchantInfo),
|
new(merchant.MerchantInfo),
|
||||||
new(merchant_deploy.MerchantDeployInfo),
|
new(merchant_deploy.MerchantDeployInfo),
|
||||||
new(accounts.AccountInfo),
|
new(accounts.AccountInfo),
|
||||||
new(accounts.AccountHistoryInfoModel),
|
new(accounts.AccountHistoryInfoModel),
|
||||||
@@ -48,7 +46,7 @@ func init() {
|
|||||||
new(order.OrderProfitInfo),
|
new(order.OrderProfitInfo),
|
||||||
new(order.OrderSettleInfo),
|
new(order.OrderSettleInfo),
|
||||||
new(notify.NotifyInfo),
|
new(notify.NotifyInfo),
|
||||||
new(merchant2.MerchantLoadInfo),
|
new(merchant.MerchantLoadInfo),
|
||||||
new(payfor.PayforInfo),
|
new(payfor.PayforInfo),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"gateway/internal/entities/supplier/third_party"
|
"gateway/internal/entities/supplier/third_party"
|
||||||
"gateway/internal/models/payfor"
|
"gateway/internal/models/payfor"
|
||||||
"gateway/internal/models/road"
|
"gateway/internal/models/road"
|
||||||
"gateway/internal/pay_for"
|
"gateway/internal/service/pay_for"
|
||||||
"gateway/internal/utils"
|
"gateway/internal/utils"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"gateway/internal/config"
|
"gateway/internal/config"
|
||||||
"gateway/internal/entities/supplier"
|
"gateway/internal/entities/supplier"
|
||||||
"gateway/internal/models/merchant"
|
"gateway/internal/models/merchant"
|
||||||
"gateway/internal/response"
|
"gateway/internal/schema/response"
|
||||||
"github.com/beego/beego/v2/core/logs"
|
"github.com/beego/beego/v2/core/logs"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"gateway/internal/models/merchant_deploy"
|
"gateway/internal/models/merchant_deploy"
|
||||||
"gateway/internal/models/payfor"
|
"gateway/internal/models/payfor"
|
||||||
"gateway/internal/models/road"
|
"gateway/internal/models/road"
|
||||||
"gateway/internal/response"
|
"gateway/internal/schema/response"
|
||||||
"gateway/internal/utils"
|
"gateway/internal/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
"gateway/internal/models/merchant_deploy"
|
"gateway/internal/models/merchant_deploy"
|
||||||
"gateway/internal/models/order"
|
"gateway/internal/models/order"
|
||||||
"gateway/internal/models/road"
|
"gateway/internal/models/road"
|
||||||
"gateway/internal/request"
|
"gateway/internal/schema/request"
|
||||||
"gateway/internal/response"
|
"gateway/internal/schema/response"
|
||||||
"gateway/internal/utils"
|
"gateway/internal/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@@ -314,22 +314,18 @@ func GenerateRecord(c *response.PayBaseResp) (order.OrderInfo, order.OrderProfit
|
|||||||
logs.Info("插入支付订单记录和支付利润记录成功")
|
logs.Info("插入支付订单记录和支付利润记录成功")
|
||||||
return orderInfo, orderProfit, nil
|
return orderInfo, orderProfit, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if orderInfo.Status != config.Created {
|
if orderInfo.Status != config.Created {
|
||||||
err := errors.New("当前订单已存在,请等待处理结果或手动查询")
|
err := errors.New("当前订单已存在,请等待处理结果或手动查询")
|
||||||
return orderInfo, orderProfitInfo, err
|
return orderInfo, orderProfitInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !order.InsertOrderExValue(c.Params["orderNo"], c.Params["exValue"]) {
|
if !order.InsertOrderExValue(c.Params["orderNo"], c.Params["exValue"]) {
|
||||||
err := errors.New("订单数据插入失败")
|
err := errors.New("订单数据插入失败")
|
||||||
return orderInfo, orderProfitInfo, err
|
return orderInfo, orderProfitInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !order.InsertPayTime(c.Params["orderNo"]) {
|
if !order.InsertPayTime(c.Params["orderNo"]) {
|
||||||
err := errors.New("订单数据插入失败")
|
err := errors.New("订单数据插入失败")
|
||||||
return orderInfo, orderProfitInfo, err
|
return orderInfo, orderProfitInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !order.SwitchOrderAndOrderProfitStatus(c.Params["orderNo"], config.WAIT) {
|
if !order.SwitchOrderAndOrderProfitStatus(c.Params["orderNo"], config.WAIT) {
|
||||||
err := errors.New("订单状态转换失败")
|
err := errors.New("订单状态转换失败")
|
||||||
return orderInfo, orderProfitInfo, err
|
return orderInfo, orderProfitInfo, err
|
||||||
|
|||||||
6
main.go
6
main.go
@@ -5,8 +5,8 @@ import (
|
|||||||
"gateway/internal/entities/notify"
|
"gateway/internal/entities/notify"
|
||||||
_ "gateway/internal/entities/supplier/third_party"
|
_ "gateway/internal/entities/supplier/third_party"
|
||||||
_ "gateway/internal/models"
|
_ "gateway/internal/models"
|
||||||
"gateway/internal/query"
|
|
||||||
_ "gateway/internal/routers"
|
_ "gateway/internal/routers"
|
||||||
|
query2 "gateway/internal/schema/query"
|
||||||
"gateway/internal/service"
|
"gateway/internal/service"
|
||||||
"github.com/beego/beego/v2/core/logs"
|
"github.com/beego/beego/v2/core/logs"
|
||||||
"github.com/beego/beego/v2/server/web"
|
"github.com/beego/beego/v2/server/web"
|
||||||
@@ -19,9 +19,9 @@ func main() {
|
|||||||
web.BConfig.WebConfig.Session.SessionOn = true
|
web.BConfig.WebConfig.Session.SessionOn = true
|
||||||
go notify.CreateOrderNotifyConsumer()
|
go notify.CreateOrderNotifyConsumer()
|
||||||
// go pay_for.PayForInit()
|
// go pay_for.PayForInit()
|
||||||
go query.CreatePayForQueryConsumer()
|
go query2.CreatePayForQueryConsumer()
|
||||||
go service.OrderSettleInit()
|
go service.OrderSettleInit()
|
||||||
go query.CreateSupplierOrderQueryCuConsumer()
|
go query2.CreateSupplierOrderQueryCuConsumer()
|
||||||
web.Run()
|
web.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user