companylogic.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. */
  9. namespace app\index\logic;
  10. use app\index\model\companymodel;
  11. use app\index\model\inventmodel;
  12. use app\index\model\usermodel;
  13. class companylogic extends baselogic
  14. {
  15. /**
  16. * 设置请求数据规则
  17. * 20220107
  18. * wj
  19. */
  20. protected function setrules()
  21. {
  22. $list = [
  23. 'newinfo' => [
  24. ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
  25. ],
  26. 'getinfobyid' => [
  27. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  28. ],
  29. 'updatebyid' => [
  30. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  31. ],
  32. 'getinfowitchinventbyid'=>[
  33. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  34. ['name' => 'activestate', 'title' => 'activestate', 'regex' => '/[0|1|2]{1}/'],
  35. ]
  36. ];
  37. return $list;
  38. }
  39. /**
  40. * 新建信息
  41. * wj
  42. * 20220118
  43. */
  44. public function newinfo($arr)
  45. {
  46. $result = $this->checkparam(__FUNCTION__, $arr);
  47. if (1 != $result['status']) {
  48. return $result;
  49. }
  50. $m_u = new usermodel();
  51. $m_c = new companymodel();
  52. $openid = $arr['openid'];
  53. $info = $m_u->getinfobyopenid($openid);
  54. if (empty($info)) {
  55. return backarr(0, "用户不存在");
  56. }
  57. if (empty($info['is_company'])) {
  58. return backarr(0, "非企业用户");
  59. }
  60. unset($arr['openid']);
  61. $id = $m_c->insertData($arr);
  62. $updateDate = ['company_id' => $id];
  63. $row = $m_u->updatebyid($info['id'], $updateDate);
  64. return backarr(1, "新增成功", ['id' => $id]);
  65. }
  66. /**
  67. * 根据id获取企业信息
  68. * wj
  69. * 20220118
  70. */
  71. public function getinfobyid($arr)
  72. {
  73. $result = $this->checkparam(__FUNCTION__, $arr);
  74. if (1 != $result['status']) {
  75. return $result;
  76. }
  77. $id = $arr['id'];
  78. $m_c = new companymodel();
  79. $info = $m_c->getinfobyid($id);
  80. if (empty($info)) {
  81. return backarr(0, "无数据");
  82. }
  83. return backarr(1, "获取成功", $info);
  84. }
  85. /**
  86. * 根据id获取企业信息包括岗位
  87. * wj
  88. * 20220119
  89. */
  90. public function getinfowitchinventbyid($arr)
  91. {
  92. $result = $this->checkparam(__FUNCTION__, $arr);
  93. if (1 != $result['status']) {
  94. return $result;
  95. }
  96. $id = $arr['id'];
  97. $m_c = new companymodel();
  98. $info = $m_c->getinfobyid($id);
  99. if (empty($info)) {
  100. return backarr(0, "无数据");
  101. }
  102. $m_i = new inventmodel();
  103. $where = ['company_id' => $info['id']];
  104. if(isset($arr['activestate'])){
  105. $where['active_state'] = $arr['activestate'];
  106. }
  107. $ilist = $m_i->getlist($where, "*", 1, 0);
  108. $info['invent_list'] = $ilist;
  109. return backarr(1, "获取成功", $info);
  110. }
  111. /**
  112. * 根据id修改企业信息
  113. * wj
  114. * 20220118
  115. */
  116. public function updatebyid($arr)
  117. {
  118. $result = $this->checkparam(__FUNCTION__, $arr);
  119. if (1 != $result['status']) {
  120. return $result;
  121. }
  122. $id = $arr['id'];
  123. unset($arr['id']);
  124. $m_c = new companymodel();
  125. $row = $m_c->updatebyid($id, $arr);
  126. if (empty($row)) {
  127. return backarr(0, "修改失败");
  128. }
  129. return backarr(1, "获取成功", ['id' => $id]);
  130. }
  131. }