companylogic.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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' => 'string'],
  28. ],
  29. 'updatebyid' => [
  30. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'string'],
  31. ],
  32. ];
  33. return $list;
  34. }
  35. /**
  36. * 新建信息
  37. * wj
  38. * 20220118
  39. */
  40. public function newinfo($arr)
  41. {
  42. $result = $this->checkparam(__FUNCTION__, $arr);
  43. if (1 != $result['status']) {
  44. return $result;
  45. }
  46. $m_u = new usermodel();
  47. $m_c = new companymodel();
  48. $openid = $arr['openid'];
  49. $info = $m_u->getinfobyopenid($openid);
  50. if (empty($info)) {
  51. return backarr(0, "用户不存在");
  52. }
  53. if (empty($info['is_company'])) {
  54. return backarr(0, "非企业用户");
  55. }
  56. unset($arr['openid']);
  57. $id = $m_c->insertData($arr);
  58. $updateDate = ['company_id' => $id];
  59. $row = $m_u->updatebyid($info['id'], $updateDate);
  60. return backarr(1, "新增成功", ['id' => $id]);
  61. }
  62. /**
  63. * 根据id获取企业信息
  64. * wj
  65. * 20220118
  66. */
  67. public function getinfobyid($arr)
  68. {
  69. $result = $this->checkparam(__FUNCTION__, $arr);
  70. if (1 != $result['status']) {
  71. return $result;
  72. }
  73. $id = $arr['id'];
  74. $m_c = new companymodel();
  75. $info = $m_c->getinfobyid($id);
  76. if (empty($info)) {
  77. return backarr(0, "无数据");
  78. }
  79. return backarr(1, "获取成功", $info);
  80. }
  81. /**
  82. * 根据id获取企业信息包括岗位
  83. * wj
  84. * 20220119
  85. */
  86. public function getinfowitchinventbyid($arr)
  87. {
  88. $result = $this->checkparam(__FUNCTION__, $arr);
  89. if (1 != $result['status']) {
  90. return $result;
  91. }
  92. $id = $arr['id'];
  93. $m_c = new companymodel();
  94. $info = $m_c->getinfobyid($id);
  95. if (empty($info)) {
  96. return backarr(0, "无数据");
  97. }
  98. $m_i = new inventmodel();
  99. $ilist = $m_i->getlist(['company_id' => $info['id'], "*", 1, 0]);
  100. $info['invent_list'] = $ilist;
  101. return backarr(1, "获取成功", $info);
  102. }
  103. /**
  104. * 根据id修改企业信息
  105. * wj
  106. * 20220118
  107. */
  108. public function updatebyid($arr)
  109. {
  110. $result = $this->checkparam(__FUNCTION__, $arr);
  111. if (1 != $result['status']) {
  112. return $result;
  113. }
  114. $id = $arr['id'];
  115. unset($arr['id']);
  116. $m_c = new companymodel();
  117. $row = $m_c->updatebyid($id, $arr);
  118. if (empty($row)) {
  119. return backarr(0, "修改失败");
  120. }
  121. return backarr(1, "获取成功", ['id' => $id]);
  122. }
  123. }