LivingAllowanceApi.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. namespace app\common\api;
  3. use app\common\model\LivingAllowance as LaModel;
  4. use app\common\state\LivingAllowanceState as LaState;
  5. use think\facade\Db;
  6. /**
  7. * Description of LivingAllowanceApi
  8. *
  9. * @author sgq
  10. */
  11. class LivingAllowanceApi {
  12. public static function getList($params) {
  13. $order = trim($params["order"]) ?: "desc";
  14. $offset = trim($params["offset"]) ?: 0;
  15. $limit = trim($params["limit"]) ?: 10;
  16. $where = [];
  17. if ($_where = self::setLivingAllowanceCheckStateCondition($params)) {
  18. $where = array_merge($where, $_where);
  19. }
  20. if ($_where = self::getWhereByParams($params)) {
  21. $where = array_merge($where, $_where);
  22. }
  23. $type = session("user")["type"];
  24. $where[] = ["type", "=", $type];
  25. $count = laModel::where($where)->count();
  26. $list = laModel::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
  27. $masterTypes = DictApi::selectByParentCode("un_master_education"); //申报对象类型
  28. $degrees = DictApi::selectByParentCode("highest_degree"); //最高学历
  29. foreach ($list as $key => $item) {
  30. $list[$key]["declareTypeName"] = $masterTypes[$item["declareType"]];
  31. $list[$key]["highEducation"] = $degrees[$item["highEducation"]];
  32. }
  33. return ["total" => $count, "rows" => $list];
  34. }
  35. public static function setLivingAllowanceCheckStateCondition($params) {
  36. $where = [];
  37. $checkState = $params["checkState"];
  38. $process = $params["process"];
  39. if ($checkState) {
  40. switch ($process) {
  41. case -1:
  42. if ($checkState == 7) {
  43. $where[] = ["checkState", ">=", $checkState];
  44. } else {
  45. $where[] = ["checkState", "=", $checkState];
  46. }
  47. break;
  48. case 1:
  49. if ($checkState == LaState::LA_NEED_DEP_CHECK) {
  50. $where[] = ["checkState", "in", [15, 25, 30, 35]];
  51. } else if ($checkState == 5) {
  52. $where[] = ["checkState", "=", LaState::LA_NEED_FIRST_CHECK];
  53. $where[] = ["highProcess", ">=", 1];
  54. } else if ($checkState == LaState::LA_NEED_FIRST_CHECK) {
  55. $where[] = ["checkState", "=", LaState::LA_NEED_FIRST_CHECK];
  56. $where[] = ["highProcess", "<", 1];
  57. } else {
  58. $where[] = ["checkState", "=", $checkState];
  59. }
  60. break;
  61. case 2:
  62. if ($checkState == LaState::LA_BEFORE_REJECT) {
  63. $where[] = ["checkState", "=", 15];
  64. $where[] = ["highProcess", ">=", 2];
  65. } else if ($checkState == LaState::LA_NEED_FIRST_CHECK) {
  66. $where[] = ["checkState", "=", 15];
  67. $where[] = ["highProcess", "<", 2];
  68. } else if ($checkState == LaState::LA_FIRST_REJECT) { //待复核
  69. $where[] = ["checkState", "in", [1, 3, 5, 7, 10, 20]];
  70. } else if ($checkState == LaState::LA_NEED_DEP_CHECK) {
  71. $where[] = ["checkState", ">=", 25];
  72. } else {
  73. $where[] = ["checkState", "=", $checkState];
  74. }
  75. break;
  76. case 3:
  77. if ($checkState == LaState::LA_THIRD_REJECT) {
  78. $where [] = ["checkState", "in", [7, 10, 15, 20, 30]];
  79. } else if ($checkState == LaState::LA_BEFORE_REJECT) { //重新提交
  80. $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
  81. $where[] = ["highProcess", ">=", 3];
  82. } else if ($checkState == LaState::LA_NEED_THIRD) { //待复核
  83. $where[] = ["checkState", "=", $checkState];
  84. $where[] = ["highProcess", "<", 3];
  85. } else {
  86. $where[] = ["checkState", "=", $checkState];
  87. }
  88. break;
  89. case 4:
  90. $where[] = ["checkState", "=", $checkState];
  91. break;
  92. case 5:
  93. break;
  94. }
  95. }
  96. return $where;
  97. }
  98. public static function getWhereByParams($params) {
  99. foreach ($params as &$param) {
  100. $param = trim($param);
  101. }unset($param);
  102. $where = [];
  103. if ($params["name"]) {
  104. $where[] = ["name", "like", "%" . $params["name"] . "%"];
  105. }
  106. if ($params["idCard"]) {
  107. $where[] = ["idCard", "like", "%" . $params["idCard"] . "%"];
  108. }
  109. if ($params["introductionMethod"]) {
  110. $where[] = ["introductionMethod", "=", $params["introductionMethod"]];
  111. }
  112. if ($params["sex"]) {
  113. $where[] = ["sex", "=", $params["sex"]];
  114. }
  115. if ($params["declareType"]) {
  116. $where[] = ["declareType", "=", $params["declareType"]];
  117. }
  118. if ($params["nation"]) {
  119. $where[] = ["nation", "=", $params["nation"]];
  120. }
  121. if ($params["nationality"]) {
  122. $where[] = ["nationality", "=", $params["nationality"]];
  123. }
  124. if ($params["provinceCode"]) {
  125. $where[] = ["provinceCode", "=", $params["provinceCode"]];
  126. }
  127. if ($params["politics"]) {
  128. $where[] = ["politics", "=", $params["politics"]];
  129. }
  130. if (session("user")["usertype"] == 2) {
  131. $where[] = ["enterpriseId", "=", session("user")["uid"]];
  132. } else {
  133. if ($params["enterpriseId"]) {
  134. $where[] = ["enterpriseId", "=", $params["enterpriseId"]];
  135. }
  136. }
  137. if ($params["industryFieldNew"]) {
  138. $where[] = ["industryFieldNew", "=", $params["industryFieldNew"]];
  139. }
  140. if ($params["industryField"]) {
  141. $where[] = ["industryField", "=", $params["industryField"]];
  142. }
  143. if ($params["introductionMode"]) {
  144. $where[] = ["introductionMode", "=", $params["introductionMode"]];
  145. }
  146. if ($params["highEducation"]) {
  147. $where[] = ["highEducation", "=", $params["highEducation"]];
  148. }
  149. if ($params["major"]) {
  150. $where[] = ["major", "like", "%" . $params["major"] . "%"];
  151. }
  152. if ($params["title"]) {
  153. $where[] = ["title", "like", "%" . $params["title"] . "%"];
  154. }
  155. if ($params["studyAbroad"]) {
  156. $where[] = ["studyAbroad", "=", $params["studyAbroad"]];
  157. }
  158. if ($params["phone"]) {
  159. $where[] = ["phone", "like", "%" . $params["phone"] . "%"];
  160. }
  161. if ($params["email"]) {
  162. $where[] = ["email", "like", "%" . $params["email"] . "%"];
  163. }
  164. if ($params["address"]) {
  165. $where[] = ["address", "=", $params["address"]];
  166. }
  167. if ($params["isPublic"]) {
  168. $where[] = ["isPublic", "=", $params["isPublic"]];
  169. }
  170. if ($params["year"]) {
  171. $where[] = ["year", "=", $params["year"]];
  172. }
  173. switch ($params["process"]) {
  174. case 1:
  175. $where[] = ["checkState", "not in", [3, 5]];
  176. break;
  177. case 2:
  178. $where[] = ["firstPassTime", "EXP", Db::raw("is not null")];
  179. break;
  180. case 3:
  181. $where[] = ["firstDepPassTime", "EXP", Db::raw("is not null")];
  182. break;
  183. case 4:
  184. $where[] = ["checkState", "in", [-1, 35]];
  185. break;
  186. }
  187. return $where;
  188. }
  189. public static function getInfoById($id) {
  190. return LaModel::findOrEmpty($id)->toArray();
  191. }
  192. public static function getApplyCountByIdCard($idCard) {
  193. $where = [];
  194. $where[] = ["idCard", "=", $idCard];
  195. $where[] = ["checkState", "<>", LaState::LA_NOTPASS];
  196. $list = LaModel::where($where)->distinct(true)->field("substr(year,1,4)")->select();
  197. return count($list);
  198. }
  199. }