SmsPay.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\system\sms;
  12. use crmeb\basic\BaseController;
  13. use crmeb\services\YunxinSmsService;
  14. use think\App;
  15. /**
  16. * Class SmsPay
  17. * @package app\controller\admin\system\sms
  18. * @author xaboy
  19. * @day 2020-05-18
  20. */
  21. class SmsPay extends BaseController
  22. {
  23. /**
  24. * @var YunxinSmsService
  25. */
  26. protected $service;
  27. /**
  28. * Sms constructor.
  29. * @param App $app
  30. */
  31. public function __construct(App $app)
  32. {
  33. parent::__construct($app);
  34. $this->service = YunxinSmsService::create();
  35. }
  36. /**
  37. * @return mixed
  38. * @author xaboy
  39. * @day 2020-05-18
  40. */
  41. public function number()
  42. {
  43. $countInfo = $this->service->count();
  44. if ($countInfo['status'] == 400) return app('json')->fail($countInfo['msg']);
  45. $info['account'] = $this->service->account();
  46. $info['number'] = $countInfo['data']['number'];
  47. $info['send_total'] = $countInfo['data']['send_total'];
  48. return app('json')->success($info);
  49. }
  50. /**
  51. * @return mixed
  52. * @author xaboy
  53. * @day 2020-05-18
  54. */
  55. public function price()
  56. {
  57. [$page, $limit] = $this->getPage();
  58. $mealInfo = $this->service->meal($page, $limit);
  59. if ($mealInfo['status'] == 400) return app('json')->fail($mealInfo['msg']);
  60. return app('json')->success($mealInfo['data']);
  61. }
  62. /**
  63. * @return mixed
  64. * @author xaboy
  65. * @day 2020-05-18
  66. */
  67. public function pay()
  68. {
  69. list($payType, $mealId, $price) = $this->request->params([
  70. ['payType', 'weixin'],
  71. ['mealId', 0],
  72. ['price', 0],
  73. ], true);
  74. $payInfo = $this->service->pay($payType, $mealId, $price, $this->request->adminId());
  75. if ($payInfo['status'] == 400) return app('json')->fail($payInfo['msg']);
  76. return app('json')->success($payInfo['data']);
  77. }
  78. /**
  79. * @author xaboy
  80. * @day 2020-05-18
  81. */
  82. public function notice()
  83. {
  84. //TODO 短信支付成功回调
  85. }
  86. }