@@ -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")
|
||||
}
|
||||
Reference in New Issue
Block a user