ContractRecord.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model\api;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class ContractRecord extends Model
  9. {
  10. //合约列表
  11. public function getList($page,$where = [],$pageCount = 20,$filed = '*',$desc = ''){
  12. $data = $this
  13. // ->field("p.*,ap.cate_name,ap.json")
  14. // ->alias("p")
  15. // ->join("adver_page ap",'ap.id=p.page_id')
  16. ->when(!empty($where),function ($query) use($where){
  17. if(!empty($where['uid'])) {
  18. $query->where('uid',$where['uid']);
  19. }
  20. if(!empty($where['title'])) {
  21. $query->wherelike('p.title','%' . $where['title'] . '%');
  22. }
  23. if(isset($where['sassid'])) {
  24. $query->where('p.sassid',$where['sassid']);
  25. }
  26. })
  27. ->order($desc)
  28. ->paginate(['list_rows'=>$pageCount,'page'=>$page])
  29. ->toArray();
  30. foreach ($data['data'] as $k=>$v) {
  31. $data['data'][$k]['time'] = date('Y-m-d',$v['time']);
  32. $data['data'][$k]['jsonAr'] = json_decode($v['data'],true);
  33. }
  34. //echo $this->getLastSql();
  35. return [$data['total'],$data['data']];
  36. }
  37. }