SmsPay.php 2.1 KB

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