上传支付接口调增

This commit is contained in:
liwei1dao 2022-12-20 17:12:54 +08:00
parent b84b75ce8f
commit a61b865d6d

View File

@ -2,9 +2,10 @@ package web
import ( import (
"context" "context"
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/gin"
"go_dreamfactory/lego/sys/gin/engine" "go_dreamfactory/lego/sys/gin/engine"
"go_dreamfactory/lego/utils/crypto/md5"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"net/http" "net/http"
) )
@ -21,16 +22,16 @@ type PayDelivery struct {
//充值发货 //充值发货
func (this *Api_Comp) PayDelivery(c *engine.Context) { func (this *Api_Comp) PayDelivery(c *engine.Context) {
req := &PayDelivery{} req := make([]interface{}, 0)
err := c.BindJSON(&req) err := c.BindJSON(&req)
this.module.Debugf("PayDelivery:%+v err:%v", req, err) this.module.Debugf("PayDelivery:%+v err:%v", req, err)
var ( var (
payreq *pb.PayDeliveryReq = &pb.PayDeliveryReq{ payreq *pb.PayDeliveryReq = &pb.PayDeliveryReq{
Uid: req.Uid, Uid: req[0].(string),
Orderid: req.Order, Productid: req[1].(string),
Productid: req.ProductID, Orderid: req[2].(string),
Price: req.Price, Price: req[3].(float32),
Amount: req.Amount, Amount: 1,
} }
payresp *pb.PayDeliveryResp = &pb.PayDeliveryResp{ payresp *pb.PayDeliveryResp = &pb.PayDeliveryResp{
Code: 0, Code: 0,
@ -41,11 +42,10 @@ func (this *Api_Comp) PayDelivery(c *engine.Context) {
defer func() { defer func() {
c.JSON(http.StatusOK, &Respond{Code: payresp.Code, Message: payresp.Msg, Data: ""}) c.JSON(http.StatusOK, &Respond{Code: payresp.Code, Message: payresp.Msg, Data: ""})
}() }()
if sign := gin.ParamSign(this.options.Key, map[string]interface{}{"orderid": req.Order, "productid": req.ProductID, "price": req.Price, "amount": req.Amount, "uid": req.Uid}); sign != req.Sign { sign := md5.MD5EncToLower(fmt.Sprintf("%s%s%s%d%s%s", req[0], req[1], req[2], req[3], req[4], this.options.Key))
this.module.Errorf("PayDelivery SignError sgin:%s", sign) if sign != req[4] {
payresp.Code = pb.ErrorCode_SignError payresp.Code = pb.ErrorCode_SignError
payresp.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_SignError) payresp.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_SignError)
return
} }
if err = this.module.service.RpcCall( if err = this.module.service.RpcCall(
context.Background(), context.Background(),