CrystalOrder.php 2.5 KB

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