附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 regels
709 B

  1. package hdl
  2. import (
  3. "applet/app/e"
  4. "applet/app/svc"
  5. "github.com/gin-gonic/gin"
  6. )
  7. func Pay(c *gin.Context) {
  8. orderType := c.Param("orderType")
  9. payMethod := c.Param("payMethod")
  10. if orderType == "" || payMethod == "" {
  11. e.OutErr(c, e.ERR_INVALID_ARGS)
  12. return
  13. }
  14. payFunc, ok := svc.PayFuncList[orderType][payMethod]
  15. if !ok || payFunc == nil {
  16. e.OutErr(c, e.ERR, e.NewErr(500, "不存在该支付方式"))
  17. return
  18. }
  19. r, err := payFunc(c)
  20. if err != nil {
  21. switch err.(type) {
  22. case e.E:
  23. err1 := err.(e.E)
  24. e.OutErr(c, err1.Code, err1.Error())
  25. return
  26. default:
  27. e.OutErr(c, e.ERR_PAY_ERR, e.NewErr(e.ERR_PAY_ERR, err.Error()))
  28. return
  29. }
  30. }
  31. e.OutSuc(c, r, nil)
  32. return
  33. return
  34. }