Order.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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\ExcelRepository;
  14. use app\common\repositories\system\merchant\MerchantRepository;
  15. use app\common\repositories\store\order\StoreOrderRepository as repository;
  16. use crmeb\services\ExcelService;
  17. use think\App;
  18. class Order extends BaseController
  19. {
  20. protected $repository;
  21. public function __construct(App $app, repository $repository)
  22. {
  23. parent::__construct($app);
  24. $this->repository = $repository;
  25. }
  26. public function lst($id)
  27. {
  28. [$page, $limit] = $this->getPage();
  29. $where = $this->request->params(['date','order_sn','order_type','keywords','username','activity_type','group_order_sn','store_name']);
  30. $where['reconciliation_type'] = $this->request->param('status', 1);
  31. $where['mer_id'] = $id;
  32. return app('json')->success($this->repository->adminMerGetList($where, $page, $limit));
  33. }
  34. public function markForm($id)
  35. {
  36. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  37. return app('json')->fail('数据不存在');
  38. return app('json')->success(formToData($this->repository->adminMarkForm($id)));
  39. }
  40. public function mark($id)
  41. {
  42. if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
  43. return app('json')->fail('数据不存在');
  44. $data = $this->request->params(['admin_mark']);
  45. $this->repository->update($id, $data);
  46. return app('json')->success('备注成功');
  47. }
  48. public function title()
  49. {
  50. $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','is_trader','activity_type']);
  51. return app('json')->success($this->repository->getStat($where, $where['status']));
  52. }
  53. /**
  54. * TODO
  55. * @return mixed
  56. * @author Qinii
  57. * @day 2020-06-25
  58. */
  59. public function getAllList()
  60. {
  61. [$page, $limit] = $this->getPage();
  62. $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','is_trader','activity_type','group_order_sn','store_name']);
  63. $data = $this->repository->adminGetList($where, $page, $limit);
  64. return app('json')->success($data);
  65. }
  66. public function takeTitle()
  67. {
  68. $where = $this->request->params(['date','order_sn','keywords','username','is_trader']);
  69. $where['take_order'] = 1;
  70. $where['status'] = '';
  71. $where['verify_date'] = $where['date'];
  72. unset($where['date']);
  73. return app('json')->success($this->repository->getStat($where, ''));
  74. }
  75. /**
  76. * TODO 自提订单列表
  77. * @return mixed
  78. * @author Qinii
  79. * @day 2020-08-17
  80. */
  81. public function getTakeList()
  82. {
  83. [$page, $limit] = $this->getPage();
  84. $where = $this->request->params(['date','order_sn','keywords','username','is_trader']);
  85. $where['take_order'] = 1;
  86. $where['status'] = '';
  87. $where['verify_date'] = $where['date'];
  88. unset($where['date']);
  89. return app('json')->success($this->repository->adminGetList($where, $page, $limit));
  90. }
  91. /**
  92. * TODO
  93. * @return mixed
  94. * @author Qinii
  95. * @day 2020-08-17
  96. */
  97. public function chart()
  98. {
  99. return app('json')->success($this->repository->OrderTitleNumber(null,null));
  100. }
  101. /**
  102. * TODO 自提订单头部统计
  103. * @return mixed
  104. * @author Qinii
  105. * @day 2020-08-17
  106. */
  107. public function takeChart()
  108. {
  109. return app('json')->success($this->repository->OrderTitleNumber(null,1));
  110. }
  111. /**
  112. * TODO 订单类型
  113. * @return mixed
  114. * @author Qinii
  115. * @day 2020-08-15
  116. */
  117. public function orderType()
  118. {
  119. return app('json')->success($this->repository->orderType([]));
  120. }
  121. public function detail($id)
  122. {
  123. $data = $this->repository->getOne($id, null);
  124. if (!$data)
  125. return app('json')->fail('数据不存在');
  126. return app('json')->success($data);
  127. }
  128. public function status($id)
  129. {
  130. [$page, $limit] = $this->getPage();
  131. return app('json')->success($this->repository->getOrderStatus($id, $page, $limit));
  132. }
  133. /**
  134. * TODO 快递查询
  135. * @param $id
  136. * @return mixed
  137. * @author Qinii
  138. * @day 2020-06-25
  139. */
  140. public function express($id)
  141. {
  142. if (!$this->repository->getWhereCount(['order_id' => $id, 'delivery_type' => 1]))
  143. return app('json')->fail('订单信息或状态错误');
  144. return app('json')->success($this->repository->express($id,null));
  145. }
  146. public function reList($id)
  147. {
  148. [$page, $limit] = $this->getPage();
  149. $where = ['reconciliation_id' => $id, 'type' => 0];
  150. return app('json')->success($this->repository->reconList($where, $page, $limit));
  151. }
  152. /**
  153. * TODO 导出文件
  154. * @author Qinii
  155. * @day 2020-07-30
  156. */
  157. public function excel()
  158. {
  159. $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','take_order']);
  160. if($where['take_order']){
  161. $where['verify_date'] = $where['date'];
  162. unset($where['date']);
  163. }
  164. [$page, $limit] = $this->getPage();
  165. $data = app()->make(ExcelService::class)->order($where, $page, $limit);
  166. return app('json')->success($data);
  167. }
  168. }