From 1359da0f1638d245a8ae159e049daf7c09f1baf8 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 16 Jun 2023 11:12:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8F=91=E8=B4=A7api?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/api_paydelivery.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/web/api_paydelivery.go b/modules/web/api_paydelivery.go index dd69dfa62..8f6f6adb6 100644 --- a/modules/web/api_paydelivery.go +++ b/modules/web/api_paydelivery.go @@ -53,6 +53,8 @@ func (this *Api_Comp) PayDelivery(c *engine.Context) { if sign != req[4].(string) { payresp.Code = pb.ErrorCode_SignError payresp.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_SignError) + this.module.Errorf("PayDelivery 签名错误! sginStr:%s sign:%s", sginStr, sign) + return } ctx, _ := context.WithTimeout(context.TODO(), time.Second*5) if err = this.module.service.RpcCall( From 8753572ebc142a533c17e46b89da6d8b39831933 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 16 Jun 2023 16:05:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=AD=BE=E5=90=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/web/api_paydelivery.go | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/web/api_paydelivery.go b/modules/web/api_paydelivery.go index 8f6f6adb6..64c27e481 100644 --- a/modules/web/api_paydelivery.go +++ b/modules/web/api_paydelivery.go @@ -5,8 +5,10 @@ import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/sys/gin/engine" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/utils/crypto/md5" "go_dreamfactory/pb" + "go_dreamfactory/utils" "net/http" "time" ) @@ -18,15 +20,19 @@ type PayDeliveryResults struct { //充值发货 func (this *Api_Comp) PayDelivery(c *engine.Context) { - req := make([]interface{}, 0) - err := c.BindJSON(&req) - this.module.Debugf("PayDelivery:%+v err:%v", req, err) + uid := c.Query("uid") + pid := c.Query("productid") + oid := c.Query("orderid") + price := utils.ToInt32(c.Query("price")) + sign := c.Query("sign") + // req := make([]interface{}, 0) + // err := c.BindJSON(&req) var ( payreq *pb.PayDeliveryReq = &pb.PayDeliveryReq{ - Uid: req[0].(string), - Productid: req[1].(string), - Orderid: req[2].(string), - Price: int32(req[3].(float64)), + Uid: uid, + Productid: pid, + Orderid: oid, + Price: price, Amount: 1, } payresp *pb.PayDeliveryResp = &pb.PayDeliveryResp{ @@ -35,6 +41,7 @@ func (this *Api_Comp) PayDelivery(c *engine.Context) { Data: "", } ) + this.module.Debugf("PayDelivery:%+v", payreq) defer func() { if payresp.Code != 0 { if payresp.Code != pb.ErrorCode_PayOrderCompleted { @@ -48,16 +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) - sign := md5.MD5(sginStr) - if sign != req[4].(string) { + sginStr := fmt.Sprintf("%s%s%s%d%s", payreq.Uid, payreq.Productid, payreq.Orderid, payreq.Price, this.options.Key) + _sign := md5.MD5(sginStr) + if _sign != sign { payresp.Code = pb.ErrorCode_SignError payresp.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_SignError) - this.module.Errorf("PayDelivery 签名错误! sginStr:%s sign:%s", sginStr, sign) + log.Errorf("签名错误 sign:%s _sign:%s", sign, _sign) return } ctx, _ := context.WithTimeout(context.TODO(), time.Second*5) - if err = this.module.service.RpcCall( + if err := this.module.service.RpcCall( ctx, comm.Service_Worker, string(comm.Rpc_ModulePayDelivery),