Order.php 5.1 KB

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