title = '订单管理'; $this->order_status = ['待支付','已支付']; $this->all_pay_type = all_pay_type(); $query = $this->_query($this->table); $where = []; $where[] = ['o.is_deleted','=',0]; if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%']; if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%']; if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%']; if($this->request->request('order_status') > -1) $where[]= ['o.status','>',$this->request->request('order_status')]; $query->alias('o') ->field('o.* , u.name ,u.phone as user_phone,u.headimg,g.name as goods_name,i.goods_spec,i.weight,i.sell_price') ->join('StoreMember u',' o.user_id = u.id ','LEFT') ->join('StoreGoods g',' o.goods_id = g.id ','LEFT') ->join('StoreGoodsItem i',' o.spec_id = i.id ','LEFT'); if(!empty($where)) $query->where($where); $query ->order('o.id desc')->page(); } /** * 订单列表处理 * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _index_page_filter(array &$data) { foreach ($data as &$vo) { } } /** * 订单审核 * @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 audit() { $this->title = '审核'; $this->_form($this->table); } /** * 修改快递 * @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 express() { if ($this->request->isGet()) { $where = ['is_deleted' => '0', 'status' => '1']; $this->expressList = Db::name('express_company')->where($where)->order('sort desc,id desc')->select(); } $this->_form($this->table); } /** * 快递表单处理 * @param array $vo * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _express_form_filter(&$vo) { if ($this->request->isPost()) { $order = Db::name($this->table)->where(['id' => $vo['id']])->find(); if (empty($order)) $this->error('订单查询异常,请稍候再试!'); $express = Db::name('express_company')->where(['express_code' => $vo['express_company_code']])->find(); if (empty($express)) $this->error('发货快递公司异常,请重新选择快递公司!'); $vo['express_company_title'] = $express['express_title']; $vo['express_send_at'] = empty($order['express_send_at']) ? date('Y-m-d H:i:s') : $order['express_send_at']; $vo['express_state'] = '1'; $vo['status'] = '2'; } } /** * 订单详情 * @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 detail() { $this->title = '订单详情'; $this->_form($this->table); } /** * 订单发货 * @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 deliver() { $this->title = '发货'; $this->express_company = Db::name('express_company')->field('id,express_title')->select(); $this->_form($this->table,'deliver'); } /** * 表单数据处理 * @auth true * @menu true * @param array $data */ protected function _form_filter(&$data) { if ($this->request->isGet() && $this->request->action() == 'detail'){ $this->goods_info = GiftOrder::where(['o.id'=>$data['id']]) ->alias('o') ->field('g.name,g.cover,i.sell_price,i.goods_spec') ->leftJoin('StoreGoods g','g.id=o.goods_id') ->leftJoin('StoreGoodsItem i','i.id=o.spec_id') ->find()->toArray(); $this->data = $data; } if($this->request->isGet() && $this->request->action() == 'audit'){ $this->goods_info = StoreGoods::field('id,name')->where('id',$data['goods_id'])->find()->toArray(); } if ($this->request->isPost() && $this->request->action() == 'deliver') { $express_company = Db::name('express_company')->field('id,express_title')->find($data['express_company_id']); $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : ''; $data['express_send_at'] = date("Y-m-d H:i:s"); $data['express_state'] = 1; } } }