WxpayController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * WxpayController.php UTF-8
  4. *
  5. *
  6. * @date : 2018/6/6 20:33
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\cfloat\controller;
  13. use api\common\controller\CFloatBaseController;
  14. use huo\controller\pay\Notify;
  15. use huolib\pay\Pay;
  16. use think\Config;
  17. class WxpayController extends CFloatBaseController {
  18. function _initialize() {
  19. parent::_initialize();
  20. Config::set('default_return_type', 'html');
  21. }
  22. /**
  23. * 微信支付回调地址
  24. * wxpay/notify
  25. */
  26. public function notifyUrl() {
  27. $_class = new Notify();
  28. $_class->notifyUrl('wxpay');
  29. }
  30. /**
  31. * 微信支付通知地址
  32. * wxpay/return
  33. *
  34. * @return mixed
  35. * @throws \think\Exception
  36. */
  37. public function returnUrl() {
  38. $_pay_class = Pay::ins()->get('wxpay');
  39. $_pay_rs = $_pay_class->returnUrl();
  40. $this->assign('info', $_pay_rs);
  41. $_msg = "支付成功!";
  42. if ("3" == $_pay_rs['status']) {
  43. $_msg = "支付失败!";
  44. $this->assign('msg', $_msg);
  45. return $this->fetch('order/failed');
  46. }
  47. $this->assign('msg', $_msg);
  48. return $this->fetch('order/success');
  49. }
  50. /**
  51. * 微信支付显示地址
  52. * wxpay/show
  53. *
  54. * @return mixed
  55. * @throws \think\Exception
  56. */
  57. public function showUrl() {
  58. $_order_id = $this->request->param('order_id');
  59. if (empty($_order_id)) {
  60. $_msg = '未支付';
  61. $this->assign('msg', $_msg);
  62. return $this->fetch('order/failed');
  63. }
  64. $_msg = '玩家取消支付,请重新下单';
  65. $this->assign('msg', $_msg);
  66. return $this->fetch('order/failed');
  67. }
  68. }