|
- package hdl
-
- import (
- "applet/app/e"
- "applet/app/pay/svc"
- "github.com/gin-gonic/gin"
- )
-
- // Pay 整合所有支付
- func Pay(c *gin.Context) {
- orderType := c.Param("orderType")
- payMethod := c.Param("payMethod")
- if orderType == "" || payMethod == "" {
- e.OutErr(c, e.ERR_INVALID_ARGS)
- return
- }
- payFunc, ok := svc.PayFuncList[orderType][payMethod]
- if !ok || payFunc == nil {
- e.OutErr(c, e.ERR, e.NewErr(500, "不存在该支付方式"))
- return
- }
- r, err := payFunc(c)
- if err != nil {
- switch err.(type) {
- case e.E:
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- default:
- e.OutErr(c, e.ERR_PAY_ERR, e.NewErr(e.ERR_PAY_ERR, err.Error()))
- return
- }
- }
- e.OutSuc(c, r, nil)
- return
- }
|