SmsPay.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace app\controller\admin\system\sms;
  3. use ln\basic\BaseController;
  4. use ln\services\YunxinSmsService;
  5. use think\App;
  6. /**
  7. * Class SmsPay
  8. * @package app\controller\admin\system\sms
  9. * @author zfy
  10. * @day 2020-05-18
  11. */
  12. class SmsPay extends BaseController
  13. {
  14. /**
  15. * @var YunxinSmsService
  16. */
  17. protected $service;
  18. /**
  19. * Sms constructor.
  20. * @param App $app
  21. */
  22. public function __construct(App $app)
  23. {
  24. parent::__construct($app);
  25. $this->service = YunxinSmsService::create();
  26. }
  27. /**
  28. * @return mixed
  29. * @author zfy
  30. * @day 2020-05-18
  31. */
  32. public function number()
  33. {
  34. $countInfo = $this->service->count();
  35. if ($countInfo['status'] == 400) return app('json')->fail($countInfo['msg']);
  36. $info['account'] = $this->service->account();
  37. $info['number'] = $countInfo['data']['number'];
  38. $info['send_total'] = $countInfo['data']['send_total'];
  39. return app('json')->success($info);
  40. }
  41. /**
  42. * @return mixed
  43. * @author zfy
  44. * @day 2020-05-18
  45. */
  46. public function price()
  47. {
  48. [$page, $limit] = $this->getPage();
  49. $mealInfo = $this->service->meal($page, $limit);
  50. if ($mealInfo['status'] == 400) return app('json')->fail($mealInfo['msg']);
  51. return app('json')->success($mealInfo['data']);
  52. }
  53. /**
  54. * @return mixed
  55. * @author zfy
  56. * @day 2020-05-18
  57. */
  58. public function pay()
  59. {
  60. list($payType, $mealId, $price) = $this->request->params([
  61. ['payType', 'weixin'],
  62. ['mealId', 0],
  63. ['price', 0],
  64. ], true);
  65. $payInfo = $this->service->pay($payType, $mealId, $price, $this->request->adminId());
  66. if ($payInfo['status'] == 400) return app('json')->fail($payInfo['msg']);
  67. return app('json')->success($payInfo['data']);
  68. }
  69. /**
  70. * @author zfy
  71. * @day 2020-05-18
  72. */
  73. public function notice()
  74. {
  75. //TODO 短信支付成功回调
  76. }
  77. }