面包店
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.
 
 
 
 
 

37 regels
730 B

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