companymodel.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2021-10-29 16:06:41
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2021-10-29 16:15:16
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class companymodel extends Model
  11. {
  12. protected $table = 't_company';
  13. public function insertData($data)
  14. {
  15. $id = $this->insertGetId($data);
  16. return empty($id) ? false : $id;
  17. }
  18. public function getInfo($where, $field = "*", $row = true)
  19. {
  20. $info = $this->field($field)->where($where);
  21. if ($row) {
  22. $info = $info->find();
  23. } else {
  24. $info = $info->select();
  25. }
  26. return empty($info) ? false : $info;
  27. }
  28. public function updateinfo($where, $updateData)
  29. {
  30. $row = $this->where($where)->update($updateData);
  31. return empty($row) ? false : $row;
  32. }
  33. public function deleteinfo($where)
  34. {
  35. $row = $this->where($where)->delete();
  36. return empty($row) ? false : $row;
  37. }
  38. public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
  39. {
  40. $whereUse = [];
  41. if (isset($where['company']) && !empty($where['company'])) {
  42. $whereUse['company'] = ['like', "%" . $where['company'] . "%"];
  43. }
  44. if (isset($where['wname']) && !empty($where['wname'])) {
  45. $whereUse['wname'] = ['like', "%" . $where['wname'] . "%"];
  46. }
  47. if (isset($where['telno']) && !empty($where['telno'])) {
  48. $whereUse['telno'] = ['like', "%" . $where['telno'] . "%"];
  49. }
  50. if (isset($where['isactive']) && in_array($where['isactive'], [0, 1])) {
  51. $whereUse['isactive'] = $where['isactive'];
  52. }
  53. if (isset($where['ispass']) && in_array($where['ispass'], [0, 1, 2])) {
  54. $whereUse['ispass'] = $where['ispass'];
  55. }
  56. if (isset($where['createtime']) && is_array($where['createtime'])) {
  57. $whereUse['createtime'] = ['between', $where['createtime']];
  58. }
  59. $sqlObj = $this->where($whereUse);
  60. if ("count" != $field) {
  61. $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
  62. if ($row) {
  63. $data = $sqlObj->find();
  64. } else {
  65. $data = $sqlObj->select();
  66. }
  67. } else {
  68. $data = $sqlObj = $sqlObj->count();
  69. }
  70. return $data;
  71. }
  72. /**
  73. * 获取企业总量
  74. * 20211228
  75. * wj
  76. */
  77. public function getcount()
  78. {
  79. $count = $this->where([])->count();
  80. return $count;
  81. }
  82. /**
  83. * 获取分析数据
  84. * 20211228
  85. * wj
  86. */
  87. public function statistics()
  88. {
  89. $sql = "select isactive,ispass,count(*) as count from " . $this->table . " group by isactive,ispass";
  90. $list = $this->query("select * from (" . $sql . ") as t");
  91. return $list;
  92. }
  93. }