Serve.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\controller\merchant\system\serve;
  3. use app\common\repositories\system\serve\ServeMealRepository;
  4. use app\common\repositories\system\serve\ServeOrderRepository;
  5. use ln\basic\BaseController;
  6. use think\App;
  7. use think\facade\Cache;
  8. class Serve extends BaseController
  9. {
  10. /**
  11. * @var ServeOrderRepository
  12. */
  13. protected $repository;
  14. /**
  15. * Merchant constructor.
  16. * @param App $app
  17. * @param ServeOrderRepository $repository
  18. */
  19. public function __construct(App $app, ServeOrderRepository $repository)
  20. {
  21. parent::__construct($app);
  22. $this->repository = $repository;
  23. }
  24. public function getQrCode()
  25. {
  26. $sms_info = Cache::get('serve_account');
  27. if (!$sms_info) {
  28. return app('json')->fail('平台未登录一号通');
  29. }
  30. $data = $this->request->params(['meal_id','pay_type']);
  31. $merId = $this->request->merId();
  32. $ret = $this->repository->QrCode($merId,$data);
  33. return app('json')->success($ret);
  34. }
  35. public function meal()
  36. {
  37. $sms_info = Cache::get('serve_account');
  38. if (!$sms_info) {
  39. return app('json')->fail('平台未登录一号通');
  40. }
  41. [$page, $limit] = $this->getPage();
  42. $type = $this->request->param( 'type','copy');
  43. if ($type == 'copy' && systemConfig('copy_product_status') != 2) {
  44. return app('json')->fail('平台未开启一号通商品复制');
  45. }
  46. if ($type == 'dump' && systemConfig('crmeb_serve_dump') != 1) {
  47. return app('json')->fail('平台未开启一号通电子面单');
  48. }
  49. $where['type'] = $type == 'copy' ? 1 : 2;
  50. $where['status'] = 1;
  51. $data = app()->make(ServeMealRepository::class)->getList($where, $page, $limit);
  52. return app('json')->success($data);
  53. }
  54. public function lst()
  55. {
  56. [$page, $limit] = $this->getPage();
  57. $where = $this->request->params(['status', 'type']);
  58. $where['mer_id'] = $this->request->merId();
  59. $data = $this->repository->getList($where, $page, $limit);
  60. return app('json')->success($data);
  61. }
  62. }