Order.php 9.9 KB

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