| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- namespace app\controller\admin\points;
- use crmeb\jobs\BatchDeliveryJob;
- use crmeb\services\ExcelService;
- use think\App;
- use crmeb\basic\BaseController;
- use app\common\repositories\store\order\StoreOrderRepository;
- use think\facade\Queue;
- /**
- * 订单
- */
- class Order extends BaseController
- {
- /**
- * @var StoreOrderRepository
- */
- protected $repository;
- /**
- * StoreProduct constructor.
- * @param App $app
- * @param StoreOrderRepository $repository
- */
- public function __construct(App $app, StoreOrderRepository $repository)
- {
- parent::__construct($app);
- $this->repository = $repository;
- }
- /**
- * 列表
- * @Author:Qinii
- * @Date: 2020/5/18
- * @return mixed
- */
- public function lst()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['keyword', 'date', 'status', 'order_sn', 'product_id', 'nickname', 'phone', 'uid', 'store_name']);
- $where['activity_type'] = 20;
- if ($where['status'] == -10) {
- unset($where['status']);
- $where['is_del'] = 1;
- }
- return app('json')->success($this->repository->pointsOrderAdminList($where, $page, $limit));
- }
- /**
- * 详情
- * @param $id
- * @return mixed
- * @author Qinii
- * @day 2020-06-11
- */
- public function detail($id)
- {
- $data = $this->repository->getOne($id, 0);
- if (!$data) return app('json')->fail('数据不存在');
- return app('json')->success($data);
- }
- /**
- * 订单状态
- * @param $id
- * @return \think\response\Json
- * @author Qinii
- */
- public function getStatus($id)
- {
- [$page, $limit] = $this->getPage();
- $where['user_type'] = $this->request->param('user_type');
- $where['date'] = $this->request->param('date');
- $where['id'] = $id;
- $data = $this->repository->getOrderStatus($where, $page, $limit);
- if (!$data) return app('json')->fail('数据不存在');
- return app('json')->success($data);
- }
- /**
- * 发货
- * @param $id
- * @return mixed
- * @author Qinii
- */
- public function delivery($id)
- {
- $split = $this->request->params(['is_split', ['split', []]]);
- if (!$this->repository->merDeliveryExists($id, $this->request->merId(), 1))
- return app('json')->fail('订单信息或状态错误');
- $data = $this->request->params([
- 'delivery_type',
- 'delivery_name',
- 'delivery_id',
- 'remark',
- ]);
- if (!$data['delivery_type'] || $data['delivery_type'] != 3 && (!$data['delivery_name'] || !$data['delivery_id']))
- return app('json')->fail('填写配送信息');
- $this->repository->runDelivery($id, $this->request->merId(), $data, $split, 'delivery');
- return app('json')->success('发货成功');
- }
- /**
- * 批量发货
- * @return \think\response\Json
- * @author Qinii
- * @day 7/26/21
- */
- public function batchDelivery()
- {
- $params = $this->request->params([
- 'order_id',
- 'delivery_id',
- 'delivery_type',
- 'delivery_name',
- 'remark',
- ]);
- if (!in_array($params['delivery_type'], [1, 2, 3]))
- return app('json')->fail('发货类型错误');
- if (!$params['order_id'])
- return app('json')->fail('需要订单ID');
- $data = ['mer_id' => $this->request->merId(), 'data' => $params];
- Queue::push(BatchDeliveryJob::class, $data);
- return app('json')->success('开始批量发货');
- }
- /**
- * 导出文件
- * @author Qinii
- * @day 2020-07-30
- */
- public function excel()
- {
- [$page, $limit] = $this->getPage();
- $where = $this->request->params(['keyword', 'date', 'status', 'order_sn', 'product_id']);
- $data = app()->make(ExcelService::class)->pointsOrder($where, $page, $limit);
- return app('json')->success($data);
- }
- /**
- * 删除
- * @Author:Qinii
- * @Date: 2020/5/18
- * @param $id
- * @return mixed
- */
- public function delete($id)
- {
- if (!$this->repository->userDelExists($id, $this->request->merId()))
- return app('json')->fail('订单信息或状态错误');
- $this->repository->update($id, ['is_system_del' => 1]);
- return app('json')->success('删除成功');
- }
- /**
- * 订单备注
- * @param $id
- * @return mixed
- * @author Qinii
- * @day 2020-06-11
- */
- public function remarkForm($id)
- {
- return app('json')->success(formToData($this->repository->pointsMarkForm($id)));
- }
- /**
- * 订单备注
- * @param $id
- * @return mixed
- * @author Qinii
- * @day 2020-06-11
- */
- public function remark($id)
- {
- if (!$this->repository->getOne($id, $this->request->merId()))
- return app('json')->fail('数据不存在');
- $data = $this->request->params(['remark']);
- $this->repository->update($id, $data);
- return app('json')->success('备注成功');
- }
- /**
- * 订单备注
- * @param $id
- * @return \think\response\Json
- * @author Qinii
- */
- public function express($id)
- {
- if (!$this->repository->getWhereCount(['order_id' => $id]))
- return app('json')->fail('订单信息或状态错误');
- return app('json')->success($this->repository->express($id, null));
- }
- }
|