MagicOrder.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace app\order\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 订单管理
  7. * Class MagicOrder
  8. * @package app\order\controller
  9. */
  10. class MagicOrder extends Controller
  11. {
  12. protected $table = 'MagicOrder';
  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. $where[] = ['o.is_deleted','=',0];
  25. $where[] = ['o.cancel_state','=',0];
  26. if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%'];
  27. if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%'];
  28. if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%'];
  29. if($this->request->request('order_status') > -1) $where[]= ['o.status','=',$this->request->request('order_status')];
  30. $where[] = ['o.cancel_state','=',0];
  31. $query->alias('o')
  32. ->field('o.* , u.name as user_name ,u.phone')
  33. ->join('store_member u',' o.uid = u.id ','LEFT');
  34. if(!empty($where)) $query->where($where);
  35. $query ->order('o.id desc')->page();
  36. }
  37. /**
  38. * 订单详情
  39. * @auth true
  40. * @menu true
  41. */
  42. public function detail()
  43. {
  44. $this->title = '订单详情';
  45. $order_id = input('id');
  46. $detail = Db::table('magic_order o')
  47. ->field('o.* , u.name as user_name ,u.phone')
  48. ->join('store_member u',' o.uid = u.id ','LEFT')
  49. ->where('o.id',$order_id)
  50. ->find();
  51. $address_info = Db::table('delivery_address')->field('id,mer_name,detail,phone,name')->find($detail['address_id']);
  52. $this->assign('address_info',$address_info);
  53. $this->assign('detail',$detail);
  54. $this->fetch('detail');
  55. }
  56. /**
  57. * 订单发货
  58. * @auth true
  59. * @menu true
  60. */
  61. public function deliver()
  62. {
  63. $this->title = '发货';
  64. $this->express_company = Db::table('store_express_company')->field('id,express_title')->select();
  65. $this->_form($this->table,'deliver');
  66. }
  67. /**
  68. * 表单数据处理
  69. * @auth true
  70. * @menu true
  71. * @param array $data
  72. */
  73. protected function _form_filter(&$data)
  74. {
  75. if ($this->request->isPost() && $this->request->action() == 'deliver') {
  76. $express_company = Db::table('store_express_company')->field('id,express_title')->find($data['express_company_id']);
  77. $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
  78. $data['express_send_at'] = date("Y-m-d H:i:s");
  79. $data['express_state'] = 1;
  80. $data['status'] = 2;
  81. }
  82. if ($this->request->isGet() && $this->request->action() == 'deliver') {
  83. if (isset($data['address_id'])){
  84. $this->address_info = Db::table('delivery_address')->field('id,mer_name,detail,phone,name')->find($data['address_id']);
  85. }
  86. }
  87. }
  88. }