companylogic.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2022-01-18 11:12:23
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2022-01-19 15:51:59
  7. */
  8. namespace app\admin\logic;
  9. use app\admin\model\companymodel;
  10. use think\facade\Log;
  11. class companylogic extends baselogic
  12. {
  13. /**
  14. * 设置请求数据规则
  15. * 20220107
  16. * wj
  17. */
  18. protected function setrules()
  19. {
  20. $list = [
  21. 'auditcompany' => [
  22. ['name' => 'ids', 'title' => 'id', 'require' => true, 'type' => 'array'],
  23. ['name' => 'ispass', 'title' => 'ispass', 'require' => true, 'type' => 'numeric', 'regex' => '/[1|2]{1}/'],
  24. ],
  25. 'getlistbywhere' => [
  26. ['name' => 'ispass', 'title' => 'ispass', 'type' => 'numeric', 'regex' => '/[0|1|2]{1}/'],
  27. ['name' => 'companyname', 'title' => 'companyname', 'type' => 'string'],
  28. ['name' => 'starttime', 'title' => 'starttime', 'type' => 'datetime'],
  29. ['name' => 'endtime', 'title' => 'starttime', 'type' => 'datetime'],
  30. ['name' => 'page', 'title' => 'page', 'type' => 'numeric'],
  31. ['name' => 'size', 'title' => 'size', 'type' => 'numeric'],
  32. ],
  33. ];
  34. return $list;
  35. }
  36. /**
  37. * 审核公司
  38. * 20220208
  39. * wj
  40. */
  41. public function auditcompany($arr)
  42. {
  43. $result = $this->checkparam(__FUNCTION__, $arr);
  44. if (1 != $result['status']) {
  45. return $result;
  46. }
  47. $ids = $arr['ids'];
  48. if (is_string($ids)) {
  49. $ids = [$ids];
  50. }
  51. $ispass = $arr['ispass'];
  52. $m_c = new companymodel();
  53. foreach ($ids as $key => $value) {
  54. $where = ['id' => $value];
  55. $info = $m_c->getInfo($where);
  56. if (empty($info)) {
  57. log::error("company_id " . $value . " 无对应企业");
  58. continue;
  59. }
  60. if ($ispass != $info['ispass']) {
  61. $update = ['ispass' => $ispass];
  62. $m_c->updateinfo($where, $update);
  63. }
  64. }
  65. return backarr(1, "操作成功");
  66. }
  67. /**
  68. * 获取公司列表
  69. * 20220208
  70. * wj
  71. */
  72. public function getlistbywhere($arr)
  73. {
  74. $result = $this->checkparam(__FUNCTION__, $arr);
  75. if (1 != $result['status']) {
  76. return $result;
  77. }
  78. $where = [];
  79. if (isset($arr['ispass'])) {
  80. $where[] = ['ispass', '=', $arr['ispass']];
  81. }
  82. if (isset($arr['companyname'])) {
  83. $where[] = ['companyname', 'like', '%' . $arr['companyname'] . '%'];
  84. }
  85. if (isset($arr['starttime']) && isset($arr['endtime'])) {
  86. $where[] = ['create_time', '>=', $arr['starttime']];
  87. $where[] = ['create_time', '<=', $arr['endtime']];
  88. }
  89. $m_c = new companymodel();
  90. $count = $m_c->getList($where, 'count');
  91. if ($count <= 0) {
  92. return backarr(0, "无数据");
  93. }
  94. $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
  95. $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
  96. $list = $m_c->getList($where, '*', $page, $size);
  97. return backarr(1, "查询成功", $list);
  98. }
  99. }