StoreDeliveryOrder.php 3.2 KB

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