go_dreamfactory/modules/web/api_paydelivery.go
2022-12-20 14:30:29 +08:00

53 lines
1.4 KiB
Go

package web
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/gin"
"go_dreamfactory/lego/sys/gin/engine"
"go_dreamfactory/pb"
"net/http"
)
type PayDelivery struct {
pb.DBSystemNotify
Order string `json:"orderid"`
ProductID string `json:"productid"`
Price float32 `json:"price"`
Amount int32 `json:"amount"`
Uid string `json:"uid"`
Sign string `json:"sign"`
}
//充值发货
func (this *Api_Comp) PayDelivery(c *engine.Context) {
req := &PayDelivery{}
err := c.BindJSON(&req)
this.module.Debugf("PayDelivery:%+v err:%v", req, err)
var (
payreq *pb.PayDeliveryReq = &pb.PayDeliveryReq{
Uid: req.Uid,
Orderid: req.Order,
Productid: req.ProductID,
Price: req.Price,
Amount: req.Amount,
}
payresp *pb.PayDeliveryResp = &pb.PayDeliveryResp{}
)
defer c.JSON(http.StatusOK, &Respond{Code: payresp.Code, Message: payresp.Msg, Data: nil})
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 {
this.module.Errorf("PayDelivery SignError sgin:%s", sign)
payresp.Code = pb.ErrorCode_SignError
return
}
if err = this.module.service.RpcCall(
context.Background(),
comm.Service_Worker,
string(comm.Rpc_ModulePayDelivery),
payreq,
payresp); err != nil {
this.module.Errorln(err)
payresp.Code = pb.ErrorCode_RpcFuncExecutionError
}
}