12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace app\order\controller;
- use library\Controller;
- use think\Db;
- /**
- * 订单管理
- * Class MagicOrder
- * @package app\order\controller
- */
- class MagicOrder extends Controller
- {
- protected $table = 'MagicOrder';
- /**
- * 订单列表
- * @auth true
- * @menu true
- */
- public function index()
- {
- $this->title = '订单管理';
- $this->order_status = ['待支付','已支付/待发货','已发货/待收货','已收货'];
- $query = $this->_query($this->table);
- $where = [];
- $where[] = ['o.is_deleted','=',0];
- $where[] = ['o.cancel_state','=',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')];
- $where[] = ['o.cancel_state','=',0];
- $query->alias('o')
- ->field('o.* , u.name as user_name ,u.phone')
- ->join('store_member u',' o.uid = u.id ','LEFT');
- if(!empty($where)) $query->where($where);
- $query ->order('o.id desc')->page();
- }
- /**
- * 订单详情
- * @auth true
- * @menu true
- */
- public function detail()
- {
- $this->title = '订单详情';
- $order_id = input('id');
- $detail = Db::table('magic_order o')
- ->field('o.* , u.name as user_name ,u.phone')
- ->join('store_member u',' o.uid = u.id ','LEFT')
- ->where('o.id',$order_id)
- ->find();
- $address_info = Db::table('delivery_address')->field('id,mer_name,detail,phone,name')->find($detail['address_id']);
- $this->assign('address_info',$address_info);
- $this->assign('detail',$detail);
- $this->fetch('detail');
- }
- /**
- * 订单发货
- * @auth true
- * @menu true
- */
- public function deliver()
- {
- $this->title = '发货';
- $this->express_company = Db::table('store_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->isPost() && $this->request->action() == 'deliver') {
- $express_company = Db::table('store_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;
- $data['status'] = 2;
- }
- if ($this->request->isGet() && $this->request->action() == 'deliver') {
- if (isset($data['address_id'])){
- $this->address_info = Db::table('delivery_address')->field('id,mer_name,detail,phone,name')->find($data['address_id']);
- }
- }
- }
- }
|