companylogic.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. ['name' => 'organization_code', 'title' => 'organization_code', 'type' => 'string'],
  26. ['name' => 'companyname', 'title' => 'companyname', 'type' => 'string'],
  27. ],
  28. 'getinfobyid' => [
  29. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  30. ],
  31. 'updatebyid' => [
  32. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  33. ],
  34. 'getinfowitchinventbyid' => [
  35. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  36. ['name' => 'activestate', 'title' => 'activestate', 'regex' => '/[0|1|2]{1}/'],
  37. ],
  38. ];
  39. return $list;
  40. }
  41. /**
  42. * 新建信息
  43. * wj
  44. * 20220118
  45. */
  46. public function newinfo($arr)
  47. {
  48. $result = $this->checkparam(__FUNCTION__, $arr);
  49. if (1 != $result['status']) {
  50. return $result;
  51. }
  52. $m_u = new usermodel();
  53. $m_c = new companymodel();
  54. $openid = $arr['openid'];
  55. $info = $m_u->getinfobyopenid($openid);
  56. if (empty($info)) {
  57. return backarr(0, "用户不存在");
  58. }
  59. if (empty($info['is_company'])) {
  60. return backarr(0, "非企业用户");
  61. }
  62. unset($arr['openid']);
  63. $where = [];
  64. $cinfo = [];
  65. if (isset($arr['organization_code'])) {
  66. $where['organization_code'] = $arr['organization_code'];
  67. }
  68. if (isset($arr['companyname'])) {
  69. $where['companyname'] = $arr['companyname'];
  70. }
  71. if (empty(!$where)) {
  72. $cinfo = $m_c->getinfo($where, ['id']);
  73. }
  74. if (empty($cinfo)) {
  75. $id = $m_c->insertData($arr);
  76. } else {
  77. $id = $cinfo['id'];
  78. }
  79. $updateDate = ['company_id' => $id];
  80. $row = $m_u->updatebyid($info['id'], $updateDate);
  81. return backarr(1, "新增成功", ['id' => $id]);
  82. }
  83. /**
  84. * 根据id获取企业信息
  85. * wj
  86. * 20220118
  87. */
  88. public function getinfobyid($arr)
  89. {
  90. $result = $this->checkparam(__FUNCTION__, $arr);
  91. if (1 != $result['status']) {
  92. return $result;
  93. }
  94. $id = $arr['id'];
  95. $m_c = new companymodel();
  96. $info = $m_c->getinfobyid($id);
  97. if (empty($info)) {
  98. return backarr(0, "无数据");
  99. }
  100. return backarr(1, "获取成功", $info);
  101. }
  102. /**
  103. * 根据id获取企业信息包括岗位
  104. * wj
  105. * 20220119
  106. */
  107. public function getinfowitchinventbyid($arr)
  108. {
  109. $result = $this->checkparam(__FUNCTION__, $arr);
  110. if (1 != $result['status']) {
  111. return $result;
  112. }
  113. $id = $arr['id'];
  114. $m_c = new companymodel();
  115. $info = $m_c->getinfobyid($id);
  116. if (empty($info)) {
  117. return backarr(0, "无数据");
  118. }
  119. $m_i = new inventmodel();
  120. $where = ['company_id' => $info['id']];
  121. if (isset($arr['activestate'])) {
  122. $where['active_state'] = $arr['activestate'];
  123. }
  124. $ilist = $m_i->getlist($where, "*", 1, 0);
  125. $info['invent_list'] = $ilist;
  126. return backarr(1, "获取成功", $info);
  127. }
  128. /**
  129. * 根据id修改企业信息
  130. * wj
  131. * 20220118
  132. */
  133. public function updatebyid($arr)
  134. {
  135. $result = $this->checkparam(__FUNCTION__, $arr);
  136. if (1 != $result['status']) {
  137. return $result;
  138. }
  139. $id = $arr['id'];
  140. unset($arr['id']);
  141. $m_c = new companymodel();
  142. $row = $m_c->updatebyid($id, $arr);
  143. if (empty($row)) {
  144. return backarr(0, "修改失败");
  145. }
  146. return backarr(1, "获取成功", ['id' => $id]);
  147. }
  148. /**
  149. * 获取本次活动全部公司总数
  150. * 20220122
  151. * wj
  152. */
  153. public function getcountbyparty($arr)
  154. {
  155. $result = $this->checkparam(__FUNCTION__, $arr);
  156. if (1 != $result['status']) {
  157. return $result;
  158. }
  159. $partyid = $arr['partyid'];
  160. $m_c = new companymodel();
  161. $count = $m_c->getcountbyparty($partyid);
  162. return backarr(1, "获取成功", $count);
  163. }
  164. }