Serve.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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\merchant\system\serve;
  12. use app\common\repositories\system\serve\ServeMealRepository;
  13. use app\common\repositories\system\serve\ServeOrderRepository;
  14. use crmeb\basic\BaseController;
  15. use think\App;
  16. use think\facade\Cache;
  17. class Serve extends BaseController
  18. {
  19. /**
  20. * @var ServeOrderRepository
  21. */
  22. protected $repository;
  23. /**
  24. * Merchant constructor.
  25. * @param App $app
  26. * @param ServeOrderRepository $repository
  27. */
  28. public function __construct(App $app, ServeOrderRepository $repository)
  29. {
  30. parent::__construct($app);
  31. $this->repository = $repository;
  32. }
  33. /**
  34. * 获取二维码
  35. *
  36. * @return \think\response\Json
  37. */
  38. public function getQrCode()
  39. {
  40. // 获取服务账号信息
  41. $sms_info = systemConfigNoCache('serve_account');
  42. if (!$sms_info) {
  43. return app('json')->fail('平台未登录一号通');
  44. }
  45. // 获取请求参数
  46. $data = $this->request->params(['meal_id', 'pay_type']);
  47. // 调用仓库方法生成二维码
  48. $ret = $this->repository->QrCode($this->request->merId(), 'meal', $data);
  49. // 返回结果
  50. return app('json')->success($ret);
  51. }
  52. /**
  53. * 获取菜品列表
  54. *
  55. * @return \think\response\Json
  56. */
  57. public function meal()
  58. {
  59. // 获取服务账号信息
  60. $sms_info = systemConfigNoCache('serve_account');
  61. if (!$sms_info) {
  62. return app('json')->fail('平台未登录一号通');
  63. }
  64. // 获取分页参数和查询条件
  65. [$page, $limit] = $this->getPage();
  66. $type = $this->request->param('type', 'copy');
  67. // 判断类型是否合法
  68. if ($type == 'copy' && !systemConfig('copy_product_status')) {
  69. return app('json')->fail('平台未开启一号通商品复制');
  70. }
  71. if ($type == 'dump' && systemConfig('crmeb_serve_dump') != 1) {
  72. return app('json')->fail('平台未开启一号通电子面单');
  73. }
  74. // 构建查询条件
  75. $where['type'] = $type == 'copy' ? 1 : 2;
  76. $where['status'] = 1;
  77. // 调用仓库方法获取菜品列表
  78. $data = app()->make(ServeMealRepository::class)->getList($where, $page, $limit);
  79. return app('json')->success($data);
  80. }
  81. /**
  82. * 获取列表
  83. *
  84. * @return \think\response\Json
  85. */
  86. public function lst()
  87. {
  88. // 获取分页参数和查询条件
  89. [$page, $limit] = $this->getPage();
  90. $where = $this->request->params(['status', 'type']);
  91. $where['mer_id'] = $this->request->merId();
  92. // 调用仓库方法获取列表
  93. $data = $this->repository->getList($where, $page, $limit);
  94. return app('json')->success($data);
  95. }
  96. }