IntegralOrder.php 3.2 KB

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