inventlogic.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 16:07:27
  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 inventlogic extends baselogic
  14. {
  15. /**
  16. * 设置请求数据规则
  17. * 20220107
  18. * wj
  19. */
  20. protected function setrules()
  21. {
  22. $list = [
  23. 'newinfo' => [
  24. ['name' => 'companyid', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
  25. ['name' => 'openid', 'title' => 'openid', 'type' => 'string'],
  26. ],
  27. 'getlistbywhere' => [
  28. ['name' => 'companyid', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
  29. ['name' => 'passstate', 'title' => 'passstate', 'type' => 'numeric', 'regex' => '/[0|1|2]{1}/'],
  30. ['name' => 'activestate', 'title' => 'activestate', 'type' => 'numeric', 'regex' => '/[0|1]{1}/'],
  31. ['name' => 'title', 'title' => 'title', 'type' => 'string', 'regex' => '/.{2,}/'],
  32. ['name' => 'page', 'title' => 'page', 'type' => 'numeric'],
  33. ['name' => 'size', 'title' => 'size', 'type' => 'numeric'],
  34. ],
  35. 'updatebyid' => [
  36. ['name' => 'id', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
  37. ],
  38. 'getinfobyid' => [
  39. ['name' => 'id', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
  40. ],
  41. 'getcountbyparty' => [
  42. ['name' => 'partyid', 'title' => 'partyid', 'require' => true, 'type' => 'numeric'],
  43. ],
  44. ];
  45. return $list;
  46. }
  47. /**
  48. * 新建数据
  49. * 20220119
  50. * wj
  51. */
  52. public function newinfo($arr)
  53. {
  54. $result = $this->checkparam(__FUNCTION__, $arr);
  55. if (1 != $result['status']) {
  56. return $result;
  57. }
  58. $companyid = $arr['companyid'];
  59. $m_c = new companymodel();
  60. $cinfo = $m_c->getinfobyid($companyid);
  61. if (empty($cinfo)) {
  62. return backarr(0, "企业信息不存在");
  63. }
  64. $openid = $arr['openid'];
  65. $m_u = new usermodel();
  66. $uinfo = $m_u->getinfobyopenid($openid);
  67. if (empty($uinfo)) {
  68. return backarr(0, "用户信息不存在");
  69. }
  70. $m_i = new inventmodel();
  71. $arr['company_id'] = $companyid;
  72. $arr['create_user_id'] = $uinfo['id'];
  73. $id = $m_i->insertData($arr);
  74. if (empty($id)) {
  75. return backarr(0, "新增失败");
  76. }
  77. return backarr(1, "新增成功", ['id' => $id]);
  78. }
  79. /**
  80. * 获取列表数据 根据条件
  81. * 20220119
  82. * wj
  83. */
  84. public function getlistbywhere($arr)
  85. {
  86. $result = $this->checkparam(__FUNCTION__, $arr);
  87. if (1 != $result['status']) {
  88. return $result;
  89. }
  90. $companyid = $arr['companyid'];
  91. $m_c = new companymodel();
  92. $cinfo = $m_c->getinfobyid($companyid);
  93. if (empty($cinfo)) {
  94. return backarr(0, "企业信息不存在");
  95. }
  96. $m_i = new inventmodel();
  97. $where = [['company_id', '=', $companyid]];
  98. if (isset($arr['title'])) {
  99. $where[] = ['title', 'like', '%' . $arr['title'] . '%'];
  100. }
  101. if (isset($arr['activestate'])) {
  102. $where[] = ['active_state', '=', $arr['activestate']];
  103. }
  104. if (isset($arr['passstate'])) {
  105. $where[] = ['pass_state', '=', $arr['passstate']];
  106. }
  107. $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
  108. $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
  109. $count = $m_i->getList($where, 'count');
  110. if ($count <= 0) {
  111. return backarr(0, "无数据");
  112. }
  113. $list = $m_i->getList($where, '*', $page, $size);
  114. return backarr(1, "查询成功", $list);
  115. }
  116. /**
  117. * 修改数据根据id
  118. * 20220119
  119. * wj
  120. */
  121. public function updatebyid($arr)
  122. {
  123. $result = $this->checkparam(__FUNCTION__, $arr);
  124. if (1 != $result['status']) {
  125. return $result;
  126. }
  127. $id = $arr['id'];
  128. $m_i = new inventmodel();
  129. $row = $m_i->updatebyid($id, $arr);
  130. if (empty($row)) {
  131. return backarr(0, "修改失败");
  132. }
  133. return backarr(1, "获取成功", ['id' => $id]);
  134. }
  135. /**
  136. * 获取数据根据id
  137. * 20220119
  138. * wj
  139. */
  140. public function getinfobyid($arr)
  141. {
  142. $result = $this->checkparam(__FUNCTION__, $arr);
  143. if (1 != $result['status']) {
  144. return $result;
  145. }
  146. $id = $arr['id'];
  147. $m_i = new inventmodel();
  148. $iinfo = $m_i->getinfobyid($id);
  149. if (empty($iinfo)) {
  150. return backarr(0, "数据不存在");
  151. }
  152. return backarr(1, "获取成功", $iinfo);
  153. }
  154. /**
  155. * 获取本次活动全部职位总数
  156. * 20220122
  157. * wj
  158. */
  159. public function getcountbyparty($arr)
  160. {
  161. $result = $this->checkparam(__FUNCTION__, $arr);
  162. if (1 != $result['status']) {
  163. return $result;
  164. }
  165. $partyid = $arr['partyid'];
  166. $m_i = new inventmodel();
  167. $count = $m_i->getcountbyparty($partyid);
  168. return backarr(1, "获取成功", $count);
  169. }
  170. }