Order.php 6.3 KB

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