60 lines
1.6 KiB
Go
60 lines
1.6 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{
|
|
Code: 0,
|
|
Msg: "成功",
|
|
Data: "",
|
|
}
|
|
)
|
|
defer func() {
|
|
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 {
|
|
this.module.Errorf("PayDelivery SignError sgin:%s", sign)
|
|
payresp.Code = pb.ErrorCode_SignError
|
|
payresp.Msg = pb.GetErrorCodeMsg(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
|
|
}
|
|
}
|