Sdzxlist.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Sdzxlist extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_sdzxlist','sdzxlist');
  7. }
  8. //定义方法的调用规则 获取URI第二段值
  9. public function _remap($arg,$arg_array)
  10. {
  11. if($arg == 'index'){
  12. $this->_index();
  13. }else{
  14. exit('No direct script access allowed');
  15. }
  16. }
  17. private function _index(){
  18. if($this->input->method() == 'post'){
  19. $page = $this->input->post('page',true);
  20. $perpage = $this->input->post('perpage',true);
  21. $sqr = $this->input->post('sqr',true);
  22. $sqr = trim($sqr);
  23. $shop_id = $this->input->post('shop_id',true);
  24. $plat_id = $this->input->post('plat_id',true);
  25. $shop_ids = $this->input->post('shop_ids',true);
  26. $ktime = $this->input->post('ktime',true);
  27. $jtime = $this->input->post('jtime',true);
  28. $ktime = strtotime($ktime);
  29. $jtime = strtotime($jtime);
  30. $where = "add_time >= ".$ktime." and add_time < ".$jtime." ";
  31. if(!empty($sqr)){
  32. $where .= " and sqr = ".$sqr." ";
  33. }
  34. if(!empty($shop_id)){
  35. $where .= " and shop_id = ".$shop_id." ";
  36. }else{
  37. $where .= " and shop_id in (".$shop_ids.") ";
  38. }
  39. if(!empty($plat_id)){
  40. $where .= " and plat_id = ".$plat_id." ";
  41. }
  42. //数据排序
  43. $order_str = "id desc";
  44. if(empty($page))
  45. {
  46. $start = 0;
  47. $perpage = 1;
  48. }
  49. else
  50. {
  51. $start = ($page - 1)*$perpage;
  52. }
  53. //$list = $this->bhsq->find_all($where,"id,shop_id,plat_id,title,sku,sqr,sq_num,sq_status,add_time,update_time",$order_str,$start,$perpage);
  54. $list = [];
  55. if(empty($list)){
  56. $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
  57. echo json_encode($rows);exit;
  58. }
  59. $shop_list = $this->shop->find_all("1=1","id,shopname");
  60. $shop_list = array_column($shop_list,'shopname','id');
  61. $plat_list = $this->typeclass->find_all("classid = 32","id,title");
  62. $plat_list = array_column($plat_list,'title','id');
  63. $status_list = $this->bhsq->getSqStatus();
  64. foreach($list as $k=>$v){
  65. $list[$k]['update_time'] = "";
  66. }
  67. $total = $this->bhsq->find_count($where);
  68. $pagenum = ceil($total/$perpage);
  69. $over = $total-($start+$perpage);
  70. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  71. echo json_encode($rows);exit;
  72. }else{
  73. $this->_Template('sdzxlist_index',$this->data);
  74. }
  75. }
  76. }