@@ -0,0 +1,70 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// DaBaiShaCallBack 金鱼结构回调函数
|
||||
func DaBaiShaCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.DaBaiShaRes{}
|
||||
g := rchgutil.DaBaiSha{}
|
||||
if err := ctx.ShouldBindJSON(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
bs, _ := json.Marshal(rchg)
|
||||
log.Info(fmt.Sprintf("DaBaiSha callback parameter data:%+v:", string(bs)))
|
||||
buf := bytes.Buffer{}
|
||||
buf.WriteString(strconv.Itoa(rchg.Code))
|
||||
buf.WriteString(rchg.MercID)
|
||||
buf.WriteString(rchg.OID)
|
||||
buf.WriteString(rchg.PayMoney)
|
||||
buf.WriteString(rchg.TradeNo)
|
||||
buf.WriteString(g.GetAppSecret())
|
||||
if !rchgutil.VerifySign(rchg.Sign, buf.String()) {
|
||||
log.Error("DaBaiSha callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
g.TradeNo = rchg.TradeNo
|
||||
msg, err := g.QueryOrder()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if msg.PayTime == "" {
|
||||
return errors.New("querry order err,no payTime")
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, err := time.ParseInLocation("2006-01-02T15:04:05Z07:00", msg.PayTime, loc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, rchg.Code, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "success")
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// DXZhiFuCallBack 金鱼结构回调函数
|
||||
func DXZhiFuCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.DXZhiFuRes{}
|
||||
err := ctx.ShouldBind(&rchg)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("DXZhiFu callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
log.Info(fmt.Sprintf("DXZhiFu callback parameter data:%+v:", rchg))
|
||||
if rchg.Sign != rchg.ToSign() {
|
||||
log.Error(fmt.Sprintf("DXZhiFu callback sign verify fail error:%+v:", err))
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("DXZhiFu callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
var status int = 200
|
||||
if rchg.Code != "00" {
|
||||
return nil
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, _ := time.ParseInLocation("20060102150405", rchg.DateTime, loc)
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, status, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("DXZhiFu RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "OK")
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/rchgamegoldmod"
|
||||
"91porn-server/web/vidhelp"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// GetGameGoldList doc
|
||||
// @Summary 获取金币列表
|
||||
// @Description 获取金币列表
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/gameGold/list [get]
|
||||
func GetGameGoldList(ctx *gin.Context) {
|
||||
infos, err := rchgamegoldmod.GetGoldList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, infos)
|
||||
}
|
||||
|
||||
// GameGoldInsert doc
|
||||
// @Summary 新增
|
||||
// @Description 新增
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param reachargeDetails formData rchgamegoldmod.GoldReq true "product卡"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/gameGold/add [post]
|
||||
func GameGoldInsert(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgamegoldmod.GoldReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if req.Coins*100 != req.Price {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
gd := rchgamegoldmod.Gold{
|
||||
Name: req.Name,
|
||||
Coins: req.Coins,
|
||||
Price: req.Price,
|
||||
CouponDesc: req.CouponDesc,
|
||||
GiveVipDays: req.GiveVipDays,
|
||||
LouFengUnlockTimes: req.LouFengUnlockTimes,
|
||||
GiveGameCoin: req.GiveGameCoin,
|
||||
NotFirst: req.NotFirst,
|
||||
Active: req.Active,
|
||||
UpdatedAt: time.Now(),
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
if err := rchgamegoldmod.InsertGold(&gd); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(rchgamegoldmod.RedisKey, "GetPayChannel")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageCoin, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// GameGoldUpdate doc
|
||||
// @Summary 编辑金币配置
|
||||
// @Description 编辑金币配置
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/gameGold/update [post]
|
||||
func GameGoldUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgamegoldmod.EditGoldReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
oid, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("exchange string(%s) to objectID error.", req.ID))
|
||||
return
|
||||
}
|
||||
req.UpdatedAt = time.Now()
|
||||
m := vidhelp.Struct2Map(req.GoldReq)
|
||||
cond := bson.M{"_id": oid}
|
||||
updt := bson.M(m)
|
||||
cnt, err := rchgamegoldmod.UpdateGold(cond, updt)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(rchgamegoldmod.RedisKey, "GetPayChannel")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageCoin, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, rchgamegoldmod.OpeResp{Count: cnt})
|
||||
}
|
||||
|
||||
// GameGoldDelete doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData int true "product等级""
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/gameGold/delete [delete]
|
||||
func GameGoldDelete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgamegoldmod.DelReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
oids := make([]primitive.ObjectID, 0, len(req.IDs))
|
||||
for _, id := range req.IDs {
|
||||
oid, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("exchange string(%s) to objectID error.", id))
|
||||
continue
|
||||
}
|
||||
oids = append(oids, oid)
|
||||
}
|
||||
if oids == nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
cond := bson.M{"_id": bson.M{"$in": oids}}
|
||||
cnt, err := rchgamegoldmod.DeleteGold(cond)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(rchgamegoldmod.RedisKey, "GetPayChannel")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageCoin, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, rchgamegoldmod.OpeResp{Count: cnt})
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/constant/redisconst"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/rchgamtmod"
|
||||
"91porn-server/web/vidhelp"
|
||||
"91porn-server/web/webg"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// GetGoldList doc
|
||||
// @Summary 获取金币列表
|
||||
// @Description 获取金币列表
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/gold/list [get]
|
||||
func GetGoldList(ctx *gin.Context) {
|
||||
infos, err := rchgamtmod.GetGoldList()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, infos)
|
||||
}
|
||||
|
||||
// GoldInsert doc
|
||||
// @Summary 新增
|
||||
// @Description 新增
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param reachargeDetails formData rchgamtmod.GoldReq true "product卡"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/gold/add [post]
|
||||
func GoldInsert(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgamtmod.GoldReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
gd := rchgamtmod.Gold{
|
||||
Name: req.Name,
|
||||
Coins: req.Coins,
|
||||
Price: req.Price,
|
||||
Active: req.Active,
|
||||
UpdatedAt: time.Now(),
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
if err = rchgamtmod.InsertGold(&gd); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(rchgamtmod.RedisKey, "GetPayChannel")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageCoin, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// GoldUpdate doc
|
||||
// @Summary 编辑金币配置
|
||||
// @Description 编辑金币配置
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/gold/update [post]
|
||||
func GoldUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgamtmod.EditGoldReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
oid, err := primitive.ObjectIDFromHex(req.ID)
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("exchange string(%s) to objectID error.", req.ID))
|
||||
return
|
||||
}
|
||||
req.UpdatedAt = time.Now()
|
||||
m := vidhelp.Struct2Map(req.GoldReq)
|
||||
cond := bson.M{"_id": oid}
|
||||
updt := bson.M(m)
|
||||
cnt, err := rchgamtmod.UpdateGold(cond, updt)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(rchgamtmod.RedisKey, "GetPayChannel")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageCoin, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, rchgamtmod.OpeResp{Count: cnt})
|
||||
}
|
||||
|
||||
// GoldDelete doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData int true "product等级""
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/gold/delete [delete]
|
||||
func GoldDelete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgamtmod.DelReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
oids := make([]primitive.ObjectID, 0, len(req.IDs))
|
||||
for _, id := range req.IDs {
|
||||
oid, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
log.Warn(fmt.Sprintf("exchange string(%s) to objectID error.", id))
|
||||
continue
|
||||
}
|
||||
oids = append(oids, oid)
|
||||
}
|
||||
if oids == nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
cond := bson.M{"_id": bson.M{"$in": oids}}
|
||||
cnt, err := rchgamtmod.DeleteGold(cond)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
redisKey := redisconst.DataCachKey(rchgamtmod.RedisKey, "GetPayChannel")
|
||||
_, _ = webg.Redis.Del(redisKey)
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManageCoin, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, rchgamtmod.OpeResp{Count: cnt})
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GoldfishPlusCallBack 金鱼结构回调函数
|
||||
func GoldfishPlusCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.GoldfishPlusRes{}
|
||||
g := rchgutil.GoldfishPlus{}
|
||||
if err := ctx.ShouldBindJSON(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("GoldfishPlus callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
log.Info(fmt.Sprintf("GoldfishPlus callback parameter data:%+v:", rchg))
|
||||
buf := bytes.Buffer{}
|
||||
buf.WriteString(strconv.Itoa(rchg.Code))
|
||||
buf.WriteString(rchg.MercID)
|
||||
buf.WriteString(rchg.OID)
|
||||
buf.WriteString(rchg.PayMoney)
|
||||
buf.WriteString(rchg.TradeNo)
|
||||
buf.WriteString(g.GetAppSecret())
|
||||
if !rchgutil.VerifySign(rchg.Sign, buf.String()) {
|
||||
log.Error("GoldfishPlus callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("GoldfishPlus callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
g.TradeNo = rchg.TradeNo
|
||||
msg, err := g.QueryOrder()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if msg.PayTime == "" {
|
||||
return errors.New("querry order err,no payTime")
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, err := time.ParseInLocation("2006-01-02T15:04:05Z07:00", msg.PayTime, loc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, rchg.Code, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("GoldfishPlus RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "success")
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// IZhiFuCallBack 金鱼结构回调函数
|
||||
func IZhiFuCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.IZhiFuRes{}
|
||||
if err := ctx.ShouldBind(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("IZhiFu callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
log.Info(fmt.Sprintf("IZhiFu callback parameter data:%+v:", rchg))
|
||||
if rchg.Sign != rchg.ToSign() {
|
||||
log.Error("IZhiFu callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
var status int = 100
|
||||
if rchg.Code == rchgutil.IZhiFuSuccess {
|
||||
status = 200
|
||||
}
|
||||
paymentAt, err := rchg.QueryOrder()
|
||||
if err != nil {
|
||||
paymentAt = time.Now()
|
||||
}
|
||||
if err = rechargeser.RechargeCallBack(ctx, "", rchg.PayMoney, rchg.TradeNo, status, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("IZhiFu RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "success")
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// LeiHuoCallBack 金鱼结构回调函数
|
||||
func LeiHuoCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.DaBaiShaRes{}
|
||||
g := rchgutil.DaBaiSha{}
|
||||
if err := ctx.ShouldBindJSON(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
bs, _ := json.Marshal(rchg)
|
||||
log.Info(fmt.Sprintf("DaBaiSha callback parameter data:%+v:", string(bs)))
|
||||
buf := bytes.Buffer{}
|
||||
buf.WriteString(strconv.Itoa(rchg.Code))
|
||||
buf.WriteString(rchg.MercID)
|
||||
buf.WriteString(rchg.OID)
|
||||
buf.WriteString(rchg.PayMoney)
|
||||
buf.WriteString(rchg.TradeNo)
|
||||
buf.WriteString(g.GetAppSecret())
|
||||
if !rchgutil.VerifySign(rchg.Sign, buf.String()) {
|
||||
log.Error("DaBaiSha callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
g.TradeNo = rchg.TradeNo
|
||||
msg, err := g.QueryOrder()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if msg.PayTime == "" {
|
||||
return errors.New("querry order err,no payTime")
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, err := time.ParseInLocation("2006-01-02T15:04:05Z07:00", msg.PayTime, loc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, rchg.Code, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("DaBaiSha RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "success")
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// LuckyCallBack 金鱼结构回调函数
|
||||
func LuckyCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.LuckyRes{}
|
||||
if err := ctx.ShouldBind(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("Lucky callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
log.Info(fmt.Sprintf("Lucky callback parameter data:%+v:", rchg))
|
||||
if rchg.Sign != rchg.ToSign() {
|
||||
log.Error("Lucky callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Lucky callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
var status int = 200
|
||||
if rchg.Code != "00" {
|
||||
return nil
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, _ := time.ParseInLocation("20060102150405", rchg.DateTime, loc)
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, status, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("Lucky RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "OK")
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/rchgchanmod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GetChannel doc
|
||||
// @Summary 获取支付渠道
|
||||
// @Description 获取支付渠道
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/channel/list [get]
|
||||
func GetChannel(ctx *gin.Context) {
|
||||
infos, err := rchgchanmod.GetPayChannels()
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, infos)
|
||||
}
|
||||
|
||||
// ChannelInsert doc
|
||||
// @Summary 新增
|
||||
// @Description 新增
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param reachargeDetails formData rchgchanmod.ChannelReq ture "product卡"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/channel/add [post]
|
||||
func ChannelInsert(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgchanmod.ChannelReq{}
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
pc := rchgchanmod.PayChannel{
|
||||
ChannelName: req.ChannelName,
|
||||
CID: req.CID,
|
||||
PayType: req.PayType,
|
||||
MinMoney: req.MinMoney,
|
||||
MaxMoney: req.MaxMoney,
|
||||
Weight: req.Weight,
|
||||
Active: req.Active,
|
||||
Rate: req.Rate,
|
||||
Category: req.Category,
|
||||
ActivePeriod: req.ActivePeriod,
|
||||
AmountTypes: req.AmountTypes,
|
||||
|
||||
UpdatedAt: time.Now(),
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
if err := rchgchanmod.InsertPayChannel(&pc); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManagePayType, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
|
||||
// ChannelUpdate doc
|
||||
// @Summary 编辑充值渠道
|
||||
// @Description 编辑充值渠道
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/channel/update [post]
|
||||
func ChannelUpdate(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgchanmod.EditReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
cnt, err := rchgchanmod.UpdatePayChannel(req.ID, req.EditInfo)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbUpdateError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManagePayType, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, rchgchanmod.OpeResp{Count: cnt})
|
||||
}
|
||||
|
||||
// ChannelDelete doc
|
||||
// @Summary 删除
|
||||
// @Description 删除
|
||||
// @Tags recharge
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData int true "product等级""
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/web/recharge/channel/delete [delete]
|
||||
func ChannelDelete(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
req := rchgchanmod.DelReq{}
|
||||
if err = ctx.ShouldBind(&req); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
cnt, err := rchgchanmod.DeletePayChannel(req.IDs)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(req)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.ProductManagePayType, constant.Delete, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, rchgchanmod.OpeResp{Count: cnt})
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/rchgordmod"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
// OrderList doc
|
||||
// @Summary 充值订单
|
||||
// @Description 充值订单
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /business/order/list [get]
|
||||
func OrderList(ctx *gin.Context) {
|
||||
var arg struct {
|
||||
common.StandQuery
|
||||
rchgordmod.RchgQueryReq
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
cond, opt := common.StandQueryMap(arg.StandQuery, arg.RchgQueryReq)
|
||||
//兼容以前没有productType的订单
|
||||
if arg.ProductType != nil && *arg.ProductType == 0 {
|
||||
cond["productType"] = bson.M{"$in": bson.A{0, nil}}
|
||||
}
|
||||
if arg.DistrictCode != nil {
|
||||
cond["districtCode"] = arg.DistrictCode
|
||||
}
|
||||
total, data, err := rchgordmod.FindRechargesOrders(cond, opt)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, map[string]interface{}{
|
||||
"total": total,
|
||||
"orders": rechargeser.BaiYuan(data),
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateOrder doc
|
||||
// @Summary 充值订单
|
||||
// @Description 充值订单
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /recharge/order/update [get]
|
||||
func UpdateOrder(ctx *gin.Context) {
|
||||
manager, err := common.GetAdminAct(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var p struct {
|
||||
ID string `json:"id" form:"id" bson:"id"`
|
||||
rchgordmod.RechargeUpdateReq
|
||||
}
|
||||
if err = ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = rchgordmod.UpdateRechargeOrder(p.ID, p.RechargeUpdateReq); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err.Error())
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(p)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.TradeManageRechargeOrder, constant.Modify, string(log), ctx.Request.URL.RequestURI())
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// SharkCallBack 金鱼结构回调函数
|
||||
func SharkCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.SharkRes{}
|
||||
s := rchgutil.Shark{}
|
||||
if err := ctx.ShouldBindJSON(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("Shark callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
log.Info(fmt.Sprintf("Shark callback parameter data error:%+v:", rchg))
|
||||
buf := bytes.Buffer{}
|
||||
buf.WriteString(strconv.Itoa(rchg.Code))
|
||||
buf.WriteString(rchg.MercID)
|
||||
buf.WriteString(rchg.OID)
|
||||
buf.WriteString(rchg.PayMoney)
|
||||
buf.WriteString(rchg.TradeNo)
|
||||
buf.WriteString(s.GetAppSecret())
|
||||
if !rchgutil.VerifySign(rchg.Sign, buf.String()) {
|
||||
log.Error("Shark callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Shark callback ParseFloat fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
s.TradeNo = rchg.TradeNo
|
||||
msg, err := s.QueryOrder()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
if msg.PayTime == "" {
|
||||
return errors.New("querry order err,no payTime")
|
||||
}
|
||||
paymentAt, err := time.ParseInLocation("2006-01-02T15:04:05Z07:00", msg.PayTime, loc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, rchg.Code, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("Shark RechargeCallBack fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "success")
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// YiLianFuCallBack 亿联富
|
||||
func YiLianFuCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.YiLIanFuRes{}
|
||||
if err := ctx.ShouldBind(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("YiLianFu callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
log.Info(fmt.Sprintf("YiLianFu callback parameter data:%+v:", rchg))
|
||||
if rchg.Sign != rchg.ToSign() {
|
||||
log.Error("YiLianFu callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("YiLianFu callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
var status int = 200
|
||||
if rchg.ResCode != "SUCCESS" {
|
||||
return nil
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, _ := time.ParseInLocation("20060102150405", rchg.PayTime, loc)
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, status, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("YiLianFu RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "SUCCESS")
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package rechargectrl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/common/rchgutil"
|
||||
"91porn-server/web/service/rechargeser"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ZhongFuCallBack 金鱼结构回调函数
|
||||
func ZhongFuCallBack(ctx *gin.Context) {
|
||||
if err := func() error {
|
||||
rchg := rchgutil.ZhongFuRes{}
|
||||
if err := ctx.ShouldBind(&rchg); err != nil {
|
||||
log.Error(fmt.Sprintf("ZhongFu callback parameter bind fail error:%+v:", err))
|
||||
return err
|
||||
}
|
||||
log.Info(fmt.Sprintf("ZhongFu callback parameter data:%+v:", rchg))
|
||||
if rchg.Sign != rchg.ToSign() {
|
||||
log.Error("ZhongFu callback sign verify fail")
|
||||
return errors.New("check sign fail")
|
||||
}
|
||||
payMoneyf, err := strconv.ParseFloat(rchg.PayMoney, 64)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("ZhongFu callback ParseFloat fail error:%+v:", err))
|
||||
return fmt.Errorf("invalid payMoney %s", rchg.PayMoney)
|
||||
}
|
||||
payMoneyf = payMoneyf * 100
|
||||
payMoney := int64(payMoneyf)
|
||||
var status int = 200
|
||||
if rchg.Code != "00" {
|
||||
return nil
|
||||
}
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
paymentAt, _ := time.ParseInLocation("20060102150405", rchg.PayTime, loc)
|
||||
if err = rechargeser.RechargeCallBack(ctx, rchg.OID, payMoney, rchg.TradeNo, status, paymentAt); err != nil {
|
||||
log.Error(fmt.Sprintf("ZhongFu RechargeCallBack fail error:%+v:", err))
|
||||
}
|
||||
return err
|
||||
}(); err != nil {
|
||||
ctx.String(http.StatusBadRequest, "fail")
|
||||
return
|
||||
}
|
||||
ctx.String(http.StatusOK, "OK")
|
||||
}
|
||||
Reference in New Issue
Block a user