上传支付接口调整

This commit is contained in:
liwei1dao 2022-12-20 14:30:29 +08:00
parent 1932877a11
commit b22ff23c4d
2 changed files with 40 additions and 6 deletions

View File

@ -94,3 +94,29 @@
"data":"", "data":"",
} }
``` ```
### 支付发货API
- 接口名:paydelivery
- 接口说明:web 服务器给玩家发送邮件
- 请求地址:{IP}:{port}/paydelivery
- 请求参数:orderid(订单号|签名),productid(商品id|签名),price(总金额|签名),amount(购买数量|签名),uid(用户id|签名),sign(签名)
- 请求样例
```
{
"orderid":"orderid0001",
"productid":"productid_1",
"price":35.5,
"amount": 1,
"uid":"df01_123dasqwe123",
"sign":"asjioqiowjeioqjweijqwejoi"
}
```
- 返回参数 code(0:成功 -1 失败),msg(结果描述),data(返回的额外数据)
- 返回样例
```
{
"code":0,
"msg":"成功",
"data":"",
}
```

View File

@ -13,6 +13,8 @@ type PayDelivery struct {
pb.DBSystemNotify pb.DBSystemNotify
Order string `json:"orderid"` Order string `json:"orderid"`
ProductID string `json:"productid"` ProductID string `json:"productid"`
Price float32 `json:"price"`
Amount int32 `json:"amount"`
Uid string `json:"uid"` Uid string `json:"uid"`
Sign string `json:"sign"` Sign string `json:"sign"`
} }
@ -23,11 +25,17 @@ func (this *Api_Comp) PayDelivery(c *engine.Context) {
err := c.BindJSON(&req) err := c.BindJSON(&req)
this.module.Debugf("PayDelivery:%+v err:%v", req, err) this.module.Debugf("PayDelivery:%+v err:%v", req, err)
var ( var (
payreq *pb.PayDeliveryReq = &pb.PayDeliveryReq{} 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{} payresp *pb.PayDeliveryResp = &pb.PayDeliveryResp{}
) )
defer c.JSON(http.StatusOK, &Respond{Code: payresp.Code, Message: payresp.Msg, Data: nil}) 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, "uid": req.Uid}); sign != req.Sign { 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) this.module.Errorf("PayDelivery SignError sgin:%s", sign)
payresp.Code = pb.ErrorCode_SignError payresp.Code = pb.ErrorCode_SignError
return return