Order.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. class Order extends Base
  5. {
  6. public function __construct()
  7. {
  8. parent::__construct();
  9. }
  10. public function index()
  11. {
  12. $param = input();
  13. $param['page'] = intval($param['page']) <1 ? 1 : $param['page'];
  14. $param['limit'] = intval($param['limit']) <1 ? $this->_pagesize : $param['limit'];
  15. $where=[];
  16. if($param['status']!=''){
  17. $where['order_status'] = ['eq',$param['status']];
  18. }
  19. if(!empty($param['uid'])){
  20. $where['o.user_id'] = ['eq',$param['uid'] ];
  21. }
  22. if(!empty($param['wd'])){
  23. $param['wd'] = htmlspecialchars(urldecode($param['wd']));
  24. $where['order_code'] = ['like','%'.$param['wd'].'%'];
  25. }
  26. $order='order_id desc';
  27. $res = model('Order')->listData($where,$order,$param['page'],$param['limit']);
  28. $this->assign('list',$res['list']);
  29. $this->assign('total',$res['total']);
  30. $this->assign('page',$res['page']);
  31. $this->assign('limit',$res['limit']);
  32. $param['page'] = '{page}';
  33. $param['limit'] = '{limit}';
  34. $this->assign('param',$param);
  35. $this->assign('title',lang('admin/order/title'));
  36. return $this->fetch('admin@order/index');
  37. }
  38. public function del()
  39. {
  40. $param = input();
  41. $ids = $param['ids'];
  42. $all = $param['all'];
  43. if(!empty($ids)){
  44. $where=[];
  45. $where['order_id'] = ['in',$ids];
  46. if($all==1){
  47. $where['order_id'] = ['gt',0];
  48. }
  49. $res = model('Order')->delData($where);
  50. if($res['code']>1){
  51. return $this->error($res['msg']);
  52. }
  53. return $this->success($res['msg']);
  54. }
  55. return $this->error(lang('param_err'));
  56. }
  57. }