StoreDeliveryOrder.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\store\order;
  12. use app\controller\store\AuthController;
  13. use app\services\order\StoreDeliveryOrderServices;
  14. use think\facade\App;
  15. /**
  16. * 配送订单
  17. * Class StoreDeliveryOrder
  18. * @package app\controller\store\order
  19. */
  20. class StoreDeliveryOrder extends AuthController
  21. {
  22. /**
  23. * StoreDeliveryOrder constructor.
  24. * @param App $app
  25. * @param StoreDeliveryOrderServices $services
  26. */
  27. public function __construct(App $app, StoreDeliveryOrderServices $services)
  28. {
  29. parent::__construct($app);
  30. $this->services = $services;
  31. }
  32. /**
  33. * 显示资源列表
  34. *
  35. * @return \think\Response
  36. */
  37. public function index()
  38. {
  39. $where = $this->request->getMore([
  40. ['keyword', ''],
  41. ['status', ''],
  42. ['data', '', '', 'time'],
  43. ['station_type', '']
  44. ]);
  45. $where['type'] = 1;
  46. $where['relation_id'] = $this->storeId;
  47. return $this->success($this->services->systemPage($where));
  48. }
  49. /**
  50. * 详情
  51. * @param $id
  52. * @return mixed
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. */
  57. public function detail($id)
  58. {
  59. if (!$id) {
  60. return app('json')->fail('缺少参数ID');
  61. }
  62. $data = $this->services->detail($id);
  63. return app('json')->success($data);
  64. }
  65. public function cancelForm($id)
  66. {
  67. if (!$id) {
  68. return app('json')->fail('缺少参数ID');
  69. }
  70. return app('json')->success($this->services->cancelForm($id));
  71. }
  72. /**
  73. * 取消发单
  74. * @param $id
  75. * @return mixed
  76. * @throws \think\db\exception\DataNotFoundException
  77. * @throws \think\db\exception\DbException
  78. * @throws \think\db\exception\ModelNotFoundException
  79. */
  80. public function cancel($id)
  81. {
  82. $reason = $this->request->getMore([
  83. ['reason', ''],
  84. ['cancel_reason', '']
  85. ]);
  86. if (!$id) {
  87. return app('json')->fail('缺少参数ID');
  88. }
  89. if (empty($reason['reason']))
  90. return app('json')->fail('取消理由不能为空');
  91. $this->services->cancel($id, $reason);
  92. return app('json')->success('取消成功');
  93. }
  94. /**
  95. * @param $id
  96. * @return mixed
  97. */
  98. public function delete($id)
  99. {
  100. if (!$id) {
  101. return app('json')->fail('缺少参数ID');
  102. }
  103. $this->services->delete((int)$id);
  104. return app('json')->success('删除成功');
  105. }
  106. }