Order.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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\v1\store;
  12. use app\controller\admin\AuthController;
  13. use app\services\order\OtherOrderServices;
  14. use app\services\order\StoreOrderServices;
  15. use app\services\user\UserRechargeServices;
  16. use think\facade\App;
  17. use \app\common\controller\Order as CommonOrder;
  18. /**
  19. * Class Order
  20. * @package app\controller\admin\v1\order
  21. */
  22. class Order extends AuthController
  23. {
  24. use CommonOrder;
  25. /**
  26. * @var StoreOrderServices
  27. */
  28. protected $services;
  29. /**
  30. * Order constructor.
  31. * @param App $app
  32. * @param StoreOrderServices $services
  33. */
  34. public function __construct(App $app, StoreOrderServices $services)
  35. {
  36. parent::__construct($app);
  37. $this->services = $services;
  38. }
  39. /**
  40. * 订单列表
  41. * @return mixed
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. */
  46. public function index()
  47. {
  48. $where = $this->request->getMore([
  49. ['order_type', ''],
  50. ['type', ''],
  51. ['status', ''],
  52. ['time', ''],
  53. ['real_name', ''],
  54. ['store_id', -1]
  55. ]);
  56. if (!$where['store_id']) $where['store_id'] = -1;
  57. $where['is_system_del'] = 0;
  58. if (!$where['real_name'] && !in_array($where['status'], [-1, -2, -3])) {
  59. $where['pid'] = 0;
  60. }
  61. return $this->success($this->services->getOrderList($where, ['*'], ['split' => function ($query) {
  62. $query->field('id,pid');
  63. }, 'pink', 'invoice', 'storeStaff']));
  64. }
  65. /**
  66. * 获取订单类型数量
  67. * @return mixed
  68. */
  69. public function chart()
  70. {
  71. $where = $this->request->getMore([
  72. ['data', '', '', 'time'],
  73. ['order_type', ''],
  74. [['type', 'd'], 0],
  75. ['store_id', -1]
  76. ]);
  77. $where['store_id'] = $where['store_id'] ?: -1;
  78. $data = $this->services->orderStoreCount($where);
  79. return $this->success($data);
  80. }
  81. /**
  82. * 获取头部统计数据
  83. * @param UserRechargeServices $services
  84. * @param OtherOrderServices $orderServices
  85. * @return mixed
  86. */
  87. public function header(UserRechargeServices $services, OtherOrderServices $orderServices)
  88. {
  89. [$store_id] = $this->request->getMore([
  90. ['store_id', -1]
  91. ], true);
  92. $store_id = $store_id ?: -1;
  93. $store_id = (int)$store_id;
  94. $data = $this->services->getStoreOrderHeader($store_id);
  95. $data['recharg'] = $services->getRechargeCount($store_id);
  96. $data['vip'] = $orderServices->getvipOrderCount($store_id);
  97. return $this->success($data);
  98. }
  99. /**
  100. * 获取配置信息
  101. * @return mixed
  102. */
  103. public function getDeliveryInfo()
  104. {
  105. return $this->success([
  106. 'express_temp_id' => store_config($this->storeId, 'config_export_temp_id'),
  107. 'id' => store_config($this->storeId, 'config_export_id'),
  108. 'to_name' => store_config($this->storeId, 'config_export_to_name'),
  109. 'to_tel' => store_config($this->storeId, 'config_export_to_tel'),
  110. 'to_add' => store_config($this->storeId, 'config_export_to_address'),
  111. 'export_open' => (bool)store_config($this->storeId, 'config_export_open')
  112. ]);
  113. }
  114. /**
  115. * 订单分配
  116. * @return mixed
  117. * @throws \think\db\exception\DataNotFoundException
  118. * @throws \think\db\exception\DbException
  119. * @throws \think\db\exception\ModelNotFoundException
  120. */
  121. public function shareOrder()
  122. {
  123. [$oid, $store_id] = $this->request->getMore([
  124. ['oid', 0],
  125. ['store_id', 0]
  126. ], true);
  127. if (!$oid || !$store_id) {
  128. return $this->fail('缺少参数');
  129. }
  130. $this->services->shareOrder((int)$oid, (int)$store_id);
  131. return $this->success('分配成功');
  132. }
  133. }