This commit is contained in:
liwei 2023-06-16 16:06:39 +08:00
commit 46ccbd1e81

View File

@ -5,8 +5,10 @@ import (
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/gin/engine" "go_dreamfactory/lego/sys/gin/engine"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/utils/crypto/md5" "go_dreamfactory/lego/utils/crypto/md5"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/utils"
"net/http" "net/http"
"time" "time"
) )
@ -18,15 +20,19 @@ type PayDeliveryResults struct {
//充值发货 //充值发货
func (this *Api_Comp) PayDelivery(c *engine.Context) { func (this *Api_Comp) PayDelivery(c *engine.Context) {
req := make([]interface{}, 0) uid := c.Query("uid")
err := c.BindJSON(&req) pid := c.Query("productid")
this.module.Debugf("PayDelivery:%+v err:%v", req, err) oid := c.Query("orderid")
price := utils.ToInt32(c.Query("price"))
sign := c.Query("sign")
// req := make([]interface{}, 0)
// err := c.BindJSON(&req)
var ( var (
payreq *pb.PayDeliveryReq = &pb.PayDeliveryReq{ payreq *pb.PayDeliveryReq = &pb.PayDeliveryReq{
Uid: req[0].(string), Uid: uid,
Productid: req[1].(string), Productid: pid,
Orderid: req[2].(string), Orderid: oid,
Price: int32(req[3].(float64)), Price: price,
Amount: 1, Amount: 1,
} }
payresp *pb.PayDeliveryResp = &pb.PayDeliveryResp{ payresp *pb.PayDeliveryResp = &pb.PayDeliveryResp{
@ -35,6 +41,7 @@ func (this *Api_Comp) PayDelivery(c *engine.Context) {
Data: "", Data: "",
} }
) )
this.module.Debugf("PayDelivery:%+v", payreq)
defer func() { defer func() {
if payresp.Code != 0 { if payresp.Code != 0 {
if payresp.Code != pb.ErrorCode_PayOrderCompleted { if payresp.Code != pb.ErrorCode_PayOrderCompleted {
@ -48,14 +55,16 @@ func (this *Api_Comp) PayDelivery(c *engine.Context) {
} }
}() }()
sginStr := fmt.Sprintf("%s%s%s%d%s", req[0], req[1], req[2], req[3], this.options.Key) sginStr := fmt.Sprintf("%s%s%s%d%s", payreq.Uid, payreq.Productid, payreq.Orderid, payreq.Price, this.options.Key)
sign := md5.MD5(sginStr) _sign := md5.MD5(sginStr)
if sign != req[4].(string) { if _sign != sign {
payresp.Code = pb.ErrorCode_SignError payresp.Code = pb.ErrorCode_SignError
payresp.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_SignError) payresp.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_SignError)
log.Errorf("签名错误 sign:%s _sign:%s", sign, _sign)
return
} }
ctx, _ := context.WithTimeout(context.TODO(), time.Second*5) ctx, _ := context.WithTimeout(context.TODO(), time.Second*5)
if err = this.module.service.RpcCall( if err := this.module.service.RpcCall(
ctx, ctx,
comm.Service_Worker, comm.Service_Worker,
string(comm.Rpc_ModulePayDelivery), string(comm.Rpc_ModulePayDelivery),