Order.php 5.1 KB

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