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

View File

@ -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,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)
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)
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),