DeliveryService.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\order;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\order\DeliveryServiceServices;
  14. use app\services\user\UserWechatuserServices;
  15. use think\facade\App;
  16. /**
  17. * 配送员管理
  18. * Class StoreService
  19. * @package app\admin\controller\store
  20. */
  21. class DeliveryService extends AuthController
  22. {
  23. /**
  24. * DeliveryService constructor.
  25. * @param App $app
  26. * @param DeliveryServiceServices $services
  27. */
  28. public function __construct(App $app, DeliveryServiceServices $services)
  29. {
  30. parent::__construct($app);
  31. $this->services = $services;
  32. }
  33. /**
  34. * 配送员列表
  35. * @return mixed
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\DbException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. */
  40. public function index()
  41. {
  42. return app('json')->success($this->services->getServiceList([]));
  43. }
  44. /**
  45. * 添加客服表单
  46. * @return mixed
  47. * @throws \FormBuilder\Exception\FormBuilderException
  48. */
  49. public function add()
  50. {
  51. return app('json')->success($this->services->create());
  52. }
  53. /**
  54. * 保存配送员
  55. * @return mixed
  56. */
  57. public function save()
  58. {
  59. $data = $this->request->postMore([
  60. ['image', ''],
  61. ['uid', 0],
  62. ['avatar', ''],
  63. ['phone', ''],
  64. ['nickname', ''],
  65. ['status', 1],
  66. ]);
  67. $this->services->saveDeliveryService($data);
  68. return app('json')->success(100000);
  69. }
  70. /**
  71. * 编辑表单
  72. * @param $id
  73. * @return mixed
  74. * @throws \FormBuilder\Exception\FormBuilderException
  75. */
  76. public function edit($id)
  77. {
  78. return app('json')->success($this->services->edit((int)$id));
  79. }
  80. /**
  81. * 修改配送员
  82. * @param $id
  83. * @return mixed
  84. */
  85. public function update($id)
  86. {
  87. $data = $this->request->postMore([
  88. ['avatar', ''],
  89. ['nickname', ''],
  90. ['phone', ''],
  91. ['status', 1],
  92. ]);
  93. $this->services->updateDeliveryService((int)$id, $data);
  94. return app('json')->success(100001);
  95. }
  96. /**
  97. * 删除配送员
  98. * @param $id
  99. * @return mixed
  100. */
  101. public function delete($id)
  102. {
  103. if (!$this->services->delete($id))
  104. return app('json')->fail(100008);
  105. else
  106. return app('json')->success(100002);
  107. }
  108. /**
  109. * 修改状态
  110. * @param $id
  111. * @param $status
  112. * @return mixed
  113. */
  114. public function set_status($id, $status)
  115. {
  116. if ($status == '' || $id == 0) return app('json')->fail(100100);
  117. $this->services->update($id, ['status' => $status]);
  118. return app('json')->success(100014);
  119. }
  120. /**
  121. * 获取所有配送员列表
  122. * @return mixed
  123. */
  124. public function get_delivery_list()
  125. {
  126. $data = $this->services->getDeliveryList();
  127. return app('json')->success($data);
  128. }
  129. }