companylogic.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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' => 'createdate', 'title' => 'createdate', 'type' => 'array'],
  29. ['name' => 'page', 'title' => 'page', 'type' => 'numeric'],
  30. ['name' => 'size', 'title' => 'size', 'type' => 'numeric'],
  31. ],
  32. ];
  33. return $list;
  34. }
  35. /**
  36. * 审核公司
  37. * 20220208
  38. * wj
  39. */
  40. public function auditcompany($arr)
  41. {
  42. $result = $this->checkparam(__FUNCTION__, $arr);
  43. if (1 != $result['status']) {
  44. return $result;
  45. }
  46. $ids = $arr['ids'];
  47. if (is_string($ids)) {
  48. $ids = [$ids];
  49. }
  50. $ispass = $arr['ispass'];
  51. $m_c = new companymodel();
  52. $successIds = [];
  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. $successIds[] = $value;
  62. $update = ['ispass' => $ispass];
  63. $m_c->updateinfo($where, $update);
  64. }
  65. }
  66. $data = [
  67. 'successIds' => $successIds,
  68. ];
  69. return backarr(1, "操作成功", $data);
  70. }
  71. /**
  72. * 获取公司列表
  73. * 20220208
  74. * wj
  75. */
  76. public function getlistbywhere($arr)
  77. {
  78. $result = $this->checkparam(__FUNCTION__, $arr);
  79. if (1 != $result['status']) {
  80. return $result;
  81. }
  82. $where = [];
  83. if (isset($arr['ispass'])) {
  84. $where[] = ['ispass', '=', $arr['ispass']];
  85. }
  86. if (isset($arr['companyname'])) {
  87. $where[] = ['companyname', 'like', '%' . $arr['companyname'] . '%'];
  88. }
  89. if (isset($arr['createdate'])) {
  90. $createdate = $arr['createdate'];
  91. $where[] = ['create_time', '>=', $createdate[0]];
  92. $where[] = ['create_time', '<=', $createdate[1]];
  93. }
  94. $m_c = new companymodel();
  95. $count = $m_c->getList($where, 'count');
  96. if ($count <= 0) {
  97. return backarr(0, "无数据");
  98. }
  99. $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
  100. $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
  101. $list = $m_c->getList($where, '*', $page, $size);
  102. return backarr(1, "查询成功", $list);
  103. }
  104. }