ExchangeOrder.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace app\order\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 兑换订单管理
  7. * Class IntegralOrder
  8. * @package app\order\controller
  9. */
  10. class ExchangeOrder extends Controller
  11. {
  12. protected $table = 'ExchangeOrder';
  13. /**
  14. * 订单列表
  15. * @auth true
  16. * @menu true
  17. * @throws \think\Exception
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * @throws \think\exception\DbException
  21. * @throws \think\exception\PDOExceptio
  22. */
  23. public function index()
  24. {
  25. $this->title = '兑换订单管理';
  26. $this->order_status = ['待支付','已支付/待发货','已发货/待收货','已收货'];
  27. $query = $this->_query($this->table);
  28. $where = [];
  29. $where[] = ['o.is_deleted','=',0];
  30. $where[] = ['o.cancel_state','=',0];
  31. if($this->request->request('tel'))$where[]= ['u.phone','like','%'.$this->request->request('tel').'%'];
  32. if($this->request->request('user_name'))$where[]= ['u.name','like','%'.$this->request->request('user_name').'%'];
  33. if($this->request->request('order_no')) $where[]= ['o.order_no','like','%'.$this->request->request('order_no').'%'];
  34. if($this->request->request('order_status') > -1) $where[]= ['o.status','=',$this->request->request('order_status')];
  35. $query->alias('o')
  36. ->field('o.* , u.name as u_name ,u.phone as u_phone')
  37. ->join('store_member u',' o.user_id = u.id ','LEFT');
  38. if(!empty($where)) $query->where($where);
  39. $query ->order('o.id desc')->page();
  40. }
  41. /**
  42. * 订单详情
  43. * @auth true
  44. * @menu true
  45. * @throws \think\Exception
  46. * @throws \think\db\exception\DataNotFoundException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. * @throws \think\exception\DbException
  49. * @throws \think\exception\PDOExceptio
  50. */
  51. public function detail()
  52. {
  53. $this->title = '兑换订单详情';
  54. $order_id = input('id');
  55. $detail = Db::name('exchange_order o')
  56. ->field('o.* , u.name as user_name ,u.phone')
  57. ->join('store_member u',' o.user_id = u.id ','LEFT')
  58. ->where('o.id',$order_id)
  59. ->find();
  60. $this->assign('detail',$detail);
  61. $this->fetch('detail');
  62. }
  63. /**
  64. * 订单发货
  65. * @auth true
  66. * @menu true
  67. * @throws \think\Exception
  68. * @throws \think\db\exception\DataNotFoundException
  69. * @throws \think\db\exception\ModelNotFoundException
  70. * @throws \think\exception\DbException
  71. * @throws \think\exception\PDOExceptio
  72. */
  73. public function deliver()
  74. {
  75. $this->title = '发货';
  76. $this->express_company = Db::name('express_company')->field('id,express_title,express_code')->select();
  77. $this->_form($this->table,'deliver');
  78. }
  79. /**
  80. * 表单数据处理
  81. * @auth true
  82. * @menu true
  83. * @param array $data
  84. */
  85. protected function _form_filter(&$data)
  86. {
  87. if ($this->request->isPost() && $this->request->action() == 'deliver') {
  88. $express_company = Db::name('express_company')->field('id,express_title')->find($data['express_company_id']);
  89. $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
  90. $data['express_send_at'] = date("Y-m-d H:i:s");
  91. $data['express_state'] = 1;
  92. $data['status'] = 2;
  93. }
  94. }
  95. }