123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\store\controller;
- use app\api\controller\Alipay;
- use EasyWeChat\Factory;
- use library\Controller;
- use think\Db;
- use app\api\controller\Area;
- use app\api\controller\Crontab;
- use function GuzzleHttp\Psr7\_caseless_remove;
- /**
- * 订单记录管理
- * Class Order
- * @package app\store\controller
- */
- class Order extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'store_order';
- /**
- * 订单记录管理
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function index()
- {
- $this->root = $this->request->root(true);
- $this->title = '订单记录管理';
- $array = $this->statistical_order_info();
- $this->assign('a', $array);
- $this->byWhere(1)->field('a.*,b.name,b.headimg')->order('a.id desc')->page();
- }
- protected function statistical_order_info()
- {
- $array = array();
- $array['all_order'] = $this->byWhere(2)->where('a.status', '>',0)->count();
- $array['all_price'] = $this->byWhere(2)->where('a.status', '>',0)->sum('a.price_total');
- $array['weixin_all_price'] = $this->byWhere(2)->where('a.status', '>',0)->where('a.pay_type', '1')->sum('a.price_total');
- $array['zfb_all_price'] = $this->byWhere(2)->where('a.status', '>',0)->where('a.pay_type', '2')->sum('a.price_total');
- return $array;
- }
- /**
- * 搜索条件
- * @return \library\helper\QueryHelper
- */
- protected function byWhere($type)
- {
- if ($type == 1) {
- $query = $this->_query($this->table);
- } elseif ($type == 2) {
- $query = Db::name($this->table);
- }
- $query = $query->alias('a')->join('store_member b', 'a.user_id=b.id');
- $query->where('a.status','>',0);
- if (isset($_GET['order_no']) && $_GET['order_no']) {
- $query->where('a.order_no', 'like','%'.$_GET['order_no'].'%');
- }
- if (isset($_GET['status']) && $_GET['status'] != '') {
- $query->where('a.status', $_GET['status']);
- }
- if (isset($_GET['pay_status']) && $_GET['pay_status'] != '') {
- $query->where('a.pay_status', $_GET['pay_status']);
- }
- if (isset($_GET['pay_type']) && $_GET['pay_type']) {
- $query->where('a.pay_type', $_GET['pay_type']);
- }
- if (isset($_GET['create_at']) && $_GET['create_at']) {
- $time = explode(' - ', $_GET['create_at']);
- $start_date_time = $time[0] . ' 00:00:00';
- $end_date_time = $time[1] . ' 23:59:59';
- $query->whereBetweenTime('a.create_at', $start_date_time, $end_date_time);
- }
- if (isset($_GET['pay_at']) && $_GET['pay_at']) {
- $time = explode(' - ', $_GET['pay_at']);
- $start_date_time = $time[0] . ' 00:00:00';
- $end_date_time = $time[1] . ' 23:59:59';
- $query->whereBetweenTime('a.pay_at', $start_date_time, $end_date_time);
- }
- if (isset($_GET['user_info']) && $_GET['user_info']) {
- $query->where('b.name|b.phone', '=', $_GET['user_info'] );
- }
- if (isset($_GET['worker_info']) && $_GET['worker_info']) {
- $worker_id = Db::name('store_engineer')->where('name|phone', '=', $_GET['worker_info'] )->value('id');
- $query->where('worker_id',$worker_id);
- }
- return $query;
- }
- /**
- * 订单列表处理
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _index_page_filter(array &$data)
- {
- $mids = array_unique(array_merge(array_column($data, 'user_id'), array_column($data, 'user_id')));
- $memberList = Db::name('StoreMember')->whereIn('id', $mids)->select();
- $wids = array_unique(array_merge(array_column($data, 'worker_id'), array_column($data, 'worker_id')));
- $workerList = Db::name('store_engineer')->whereIn('id', $wids)->select();
- foreach ($data as &$vo) {
- list($vo['member'], $vo['worker']) = [[],[]];
- foreach ($memberList as $member) if ($member['id'] === $vo['user_id']) {
- $vo['member'] = $member;
- }
- foreach ($workerList as $worker) if ($worker['id'] === $vo['worker_id']) {
- $vo['worker'] = $worker;
- }
- $vo['serve_title'] = Db::name('store_goods')->where('id',$vo['goods_id'])->value('title');
- }
- }
- /**
- * 表单数据处理
- * @param array $data
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- protected function _form_filter(array &$data)
- {
- if ($this->request->isGet()) {
- //接单人员信息
- if($data['worker_id']){
- $data['worker_info'] = Db::name('store_engineer')->field('name,phone')->where('id',$data['worker_id'])->find();
- }
- $this->data = $data;
- }
- }
- /**
- * 订单详情
- * @auth true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function order_detail()
- {
- $this->_form($this->table);
- }
- }
|