Tx.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model\system;
  4. use Closure;
  5. use library\basic\BaseModel;
  6. use think\Model;
  7. /**
  8. * @mixin \think\Model
  9. */
  10. class Tx extends BaseModel
  11. {
  12. /**
  13. * 获取列表数据
  14. * @param $page
  15. * @param $where
  16. * @param $pageCount
  17. * @param $desc
  18. */
  19. public function getList($page,$where = [],$pageCount = 20,$filed = '*',$desc = ''){
  20. $data = $this
  21. ->field(
  22. "t.*,(SELECT mobile FROM table_member where uid = t.uid) as member_mobile,"
  23. . "(SELECT name from table_site where sassid = t.sassid) as site_name,".
  24. "(SELECT name from table_warehouse where id = t.warehouse_id) as warehouse_name"
  25. )
  26. ->alias("t")
  27. ->when(!empty($where),function ($query) use($where){
  28. if($where['orderType'] == 2) {
  29. $query->where('t.is_type',1);
  30. }
  31. if($where['orderType'] == 1) {
  32. $query->where('t.is_type',0);
  33. }
  34. if(!empty($where['mobile'])){
  35. $query->where('t.code',"%".$where['mobile']."%");
  36. }
  37. if(!empty($where['uid'])){
  38. $query->where('t.uid',$where['uid']);
  39. }
  40. if(!empty($where['type'])){
  41. $query->where('t.type',$where['type']);
  42. }
  43. if(!empty($where['sassids'])){
  44. $query->whereIn('t.sassid',join(',',$where['sassids']));
  45. }
  46. })
  47. ->order($desc)
  48. ->paginate(['list_rows'=>$pageCount,'page'=>$page])
  49. ->toArray();
  50. // echo $this->getLastSql();
  51. return [$data['total'],$data['data']];
  52. }
  53. }