DeliveryOrder.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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\merchant\store\delivery;
  12. use app\common\repositories\delivery\DeliveryOrderRepository;
  13. use app\common\repositories\system\serve\ServeOrderRepository;
  14. use think\App;
  15. use crmeb\basic\BaseController;
  16. use think\exception\ValidateException;
  17. class DeliveryOrder extends BaseController
  18. {
  19. protected $repository;
  20. public function __construct(App $app, DeliveryOrderRepository $repository)
  21. {
  22. parent::__construct($app);
  23. $this->repository = $repository;
  24. if (systemConfig('delivery_status') != 1) throw new ValidateException('未开启同城配送');
  25. }
  26. public function lst()
  27. {
  28. [$page, $limit] = $this->getPage();
  29. $where = $this->request->params(['keyword','station_id','status','date','order_sn','station_type']);
  30. $where['mer_id'] = $this->request->merId();
  31. $data = $this->repository->merList($where, $page, $limit);
  32. return app('json')->success($data);
  33. }
  34. public function detail($id)
  35. {
  36. $data = $this->repository->detail($id,$this->request->merId());
  37. return app('json')->success($data);
  38. }
  39. public function cancelForm($id)
  40. {
  41. return app('json')->success(formToData($this->repository->cancelForm($id)));
  42. }
  43. public function cancel($id)
  44. {
  45. $reason = $this->request->params(['reason','cancel_reason']);
  46. if (empty($reason['reason']))
  47. return app('json')->fail('取消理由不能为空');
  48. $this->repository->cancel($id, $this->request->merId(), $reason);
  49. return app('json')->success('取消成功');
  50. }
  51. public function delete($id)
  52. {
  53. $this->repository->destory($id, $this->request->merId());
  54. return app('json')->success('删除成功');
  55. }
  56. public function switchWithStatus($id)
  57. {
  58. $status = $this->request->param('status') == 1 ? 1 : 0;
  59. $this->repository->update($id,['status' => $status]);
  60. return app('json')->success('修改成功');
  61. }
  62. }