Order.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\order\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 订单管理
  7. * Class Order
  8. * @package app\order\controller
  9. */
  10. class Order extends Controller
  11. {
  12. protected $table = 'StoreOrder';
  13. /**
  14. * 订单列表
  15. * @auth true
  16. * @menu true
  17. */
  18. public function index()
  19. {
  20. $this->title = '线上商城订单管理';
  21. $this->order_status = ['待支付','已支付/待发货','已发货/待收货','已收货','已评论','','','','','已取消'];
  22. $query = $this->_query($this->table);
  23. $where = [];
  24. if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%'];
  25. if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%'];
  26. if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%'];
  27. if($this->request->request('order_status') > -1) $where[]= ['o.status','=',$this->request->request('order_status')];
  28. $where[] =['source','=',0] ;
  29. $query->alias('o')
  30. ->field('o.* , u.name as user_name ,u.phone')
  31. ->join('store_member u',' o.uid = u.id ','LEFT');
  32. if(!empty($where)) $query->where($where);
  33. $query ->order('o.id desc')->page();
  34. }
  35. /**
  36. * 订单详情
  37. * @auth true
  38. * @menu true
  39. */
  40. public function detail()
  41. {
  42. $this->title = '订单详情';
  43. $order_id = input('id');
  44. $detail = Db::table('store_order o')
  45. ->field('o.* , u.name as user_name ,u.phone')
  46. ->join('store_member u',' o.uid = u.id ','LEFT')
  47. ->where('o.id',$order_id)
  48. ->find();
  49. $this->assign('detail',$detail);
  50. $this->fetch('detail');
  51. }
  52. /**
  53. * 订单发货
  54. * @auth true
  55. * @menu true
  56. */
  57. public function deliver()
  58. {
  59. $this->title = '发货';
  60. $this->express_company = Db::table('store_express_company')->field('id,express_title')->select();
  61. $this->_form($this->table,'deliver');
  62. }
  63. /**
  64. * 表单数据处理
  65. * @auth true
  66. * @menu true
  67. * @param array $data
  68. */
  69. protected function _form_filter(&$data)
  70. {
  71. if ($this->request->isPost() && $this->request->action() == 'deliver') {
  72. $express_company = Db::table('store_express_company')->field('id,express_title')->find($data['express_company_id']);
  73. $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
  74. $data['express_send_at'] = date("Y-m-d H:i:s");
  75. $data['express_state'] = 1;
  76. }
  77. }
  78. }