Order.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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\admin\order;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\store\order\StoreOrderRepository as repository;
  14. use crmeb\services\ExcelService;
  15. use think\App;
  16. /**
  17. * 订单
  18. */
  19. class Order extends BaseController
  20. {
  21. protected $repository;
  22. public function __construct(App $app, repository $repository)
  23. {
  24. parent::__construct($app);
  25. $this->repository = $repository;
  26. }
  27. /**
  28. * 每个商户的订单列表
  29. * @param $id
  30. * @return \think\response\Json
  31. * @author Qinii
  32. * @day 2024/5/10
  33. */
  34. public function lst($id)
  35. {
  36. [$page, $limit] = $this->getPage();
  37. $where = $this->request->params(['date', 'order_sn', 'order_type', 'keywords', 'username', 'activity_type', 'group_order_sn', 'store_name', 'filter_delivery', 'filter_product', 'delivery_id','nickname','uid','phone','real_name']);
  38. $where['mer_id'] = $id;
  39. $where['is_spread'] = $this->request->param('is_spread', '');
  40. return app('json')->success($this->repository->adminMerGetList($where, $page, $limit));
  41. }
  42. /**
  43. * 平台对订单备注
  44. * @param $id
  45. * @return \think\response\Json
  46. * @author Qinii
  47. */
  48. public function markForm($id)
  49. {
  50. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  51. return app('json')->fail('数据不存在');
  52. return app('json')->success(formToData($this->repository->adminMarkForm($id)));
  53. }
  54. /**
  55. * 平台对订单备注
  56. * @param $id
  57. * @return \think\response\Json
  58. * @author Qinii
  59. */
  60. public function mark($id)
  61. {
  62. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  63. return app('json')->fail('数据不存在');
  64. $data = $this->request->params(['admin_mark']);
  65. $this->repository->update($id, $data);
  66. return app('json')->success('备注成功');
  67. }
  68. /**
  69. * 订单统计
  70. * @return \think\response\Json
  71. * @author Qinii
  72. */
  73. public function title()
  74. {
  75. $where = $this->request->params(['type', 'date', 'mer_id', 'keywords', 'status', 'username', 'order_sn', 'is_trader', 'activity_type', 'filter_delivery', 'filter_product','nickname','uid','phone','real_name']);
  76. $where['is_spread'] = $this->request->param('is_spread', 0);
  77. return app('json')->success($this->repository->getStat($where, $where['status']));
  78. }
  79. /**
  80. * 订单列表
  81. * @return mixed
  82. * @author Qinii
  83. * @day 2020-06-25
  84. */
  85. public function getAllList()
  86. {
  87. [$page, $limit] = $this->getPage();
  88. $where = $this->request->params(['type', 'date', 'mer_id', 'keywords', 'status', 'username', 'order_sn', 'is_trader', 'activity_type', 'group_order_sn', 'store_name', 'spread_name', 'top_spread_name', 'filter_delivery', 'filter_product','nickname','uid','phone','real_name','delivery_name','delivery_phone']);
  89. $pay_type = $this->request->param('pay_type', '');
  90. if ($pay_type != '') $where['pay_type'] = $this->repository::PAY_TYPE_FILTEER[$pay_type];
  91. $where['is_spread'] = $this->request->param('is_spread', 0);
  92. $data = $this->repository->adminGetList($where, $page, $limit);
  93. return app('json')->success($data);
  94. }
  95. /**
  96. * 自提订单统计
  97. * @return \think\response\Json
  98. * @author Qinii
  99. */
  100. public function takeTitle()
  101. {
  102. $where = $this->request->params(['date', 'order_sn', 'keywords', 'username', 'is_trader']);
  103. $where['take_order'] = 1;
  104. $where['status'] = '';
  105. $where['verify_date'] = $where['date'];
  106. unset($where['date']);
  107. $pay_type = $this->request->param('pay_type','');
  108. if ($pay_type != '') $where['pay_type'] = $this->repository::PAY_TYPE_FILTEER[$pay_type];
  109. return app('json')->success($this->repository->getStat($where, ''));
  110. }
  111. /**
  112. * 自提订单列表
  113. * @return mixed
  114. * @author Qinii
  115. * @day 2020-08-17
  116. */
  117. public function getTakeList()
  118. {
  119. [$page, $limit] = $this->getPage();
  120. $where = $this->request->params(['date', 'order_sn', 'keywords', 'username', 'is_trader']);
  121. $where['take_order'] = 1;
  122. $where['status'] = '';
  123. $where['verify_date'] = $where['date'];
  124. unset($where['date']);
  125. $pay_type = $this->request->param('pay_type','');
  126. if ($pay_type != '') $where['pay_type'] = $this->repository::PAY_TYPE_FILTEER[$pay_type];
  127. return app('json')->success($this->repository->adminGetList($where, $page, $limit));
  128. }
  129. /**
  130. *
  131. * @return mixed
  132. * @author Qinii
  133. * @day 2020-08-17
  134. */
  135. public function chart()
  136. {
  137. return app('json')->success($this->repository->OrderTitleNumber(null, null));
  138. }
  139. /**
  140. * 分销订单头部统计
  141. * @return \think\response\Json
  142. * @author Qinii
  143. * @day 2023/7/7
  144. */
  145. public function spreadChart()
  146. {
  147. return app('json')->success($this->repository->OrderTitleNumber(null, 2));
  148. }
  149. /**
  150. * 自提订单头部统计
  151. * @return mixed
  152. * @author Qinii
  153. * @day 2020-08-17
  154. */
  155. public function takeChart()
  156. {
  157. return app('json')->success($this->repository->OrderTitleNumber(null, 1));
  158. }
  159. /**
  160. * 订单类型
  161. * @return mixed
  162. * @author Qinii
  163. * @day 2020-08-15
  164. */
  165. public function orderType()
  166. {
  167. return app('json')->success($this->repository->orderType([]));
  168. }
  169. /**
  170. * 订单详情
  171. * @param $id
  172. * @return \think\response\Json
  173. * @author Qinii
  174. */
  175. public function detail($id)
  176. {
  177. $data = $this->repository->getOne($id, null);
  178. if (!$data)
  179. return app('json')->fail('数据不存在');
  180. return app('json')->success($data);
  181. }
  182. /**
  183. * 订单操作记录
  184. * @param $id
  185. * @return \think\response\Json
  186. * @author Qinii
  187. */
  188. public function status($id)
  189. {
  190. [$page, $limit] = $this->getPage();
  191. $where = $this->request->params(['date', 'user_type']);
  192. $where['id'] = $id;
  193. return app('json')->success($this->repository->getOrderStatus($where, $page, $limit));
  194. }
  195. /**
  196. * 快递查询
  197. * @param $id
  198. * @return mixed
  199. * @author Qinii
  200. * @day 2020-06-25
  201. */
  202. public function express($id)
  203. {
  204. if (!$this->repository->getWhereCount(['order_id' => $id]))
  205. return app('json')->fail('订单信息或状态错误');
  206. return app('json')->success($this->repository->express($id, null));
  207. }
  208. public function reList($id)
  209. {
  210. [$page, $limit] = $this->getPage();
  211. $where = ['reconciliation_id' => $id, 'type' => 0];
  212. return app('json')->success($this->repository->reconList($where, $page, $limit));
  213. }
  214. /**
  215. * 导出文件
  216. * @author Qinii
  217. * @day 2020-07-30
  218. */
  219. public function excel()
  220. {
  221. $where = $this->request->params(['type', 'date', 'mer_id', 'keywords', 'status', 'username', 'order_sn', 'take_order', 'is_trader', 'activity_type', 'group_order_sn', 'store_name', 'filter_delivery', 'filter_product', 'pay_type','uid','phone','real_name','delivery_name','delivery_phone']);
  222. if ($where['pay_type'] != '') $where['pay_type'] = $this->repository::PAY_TYPE_FILTEER[$where['pay_type']];
  223. if ($where['take_order']) {
  224. $where['verify_date'] = $where['date'];
  225. unset($where['date']);
  226. }
  227. [$page, $limit] = $this->getPage();
  228. $data = app()->make(ExcelService::class)->order($where, $page, $limit);
  229. return app('json')->success($data);
  230. }
  231. /**
  232. * 拆分后自订单
  233. * @param $id
  234. * @return \think\response\Json
  235. * @author Qinii
  236. * @day 2023/2/22
  237. */
  238. public function childrenList($id)
  239. {
  240. $data = $this->repository->childrenList($id, 0);
  241. return app('json')->success($data);
  242. }
  243. }