EducationSchool.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\model\TalentLog;
  6. use app\common\state\ProjectState;
  7. use app\common\api\DictApi;
  8. use think\facade\Db;
  9. use app\common\api\EducationApi;
  10. use app\common\state\MainState;
  11. /**
  12. * Description of EducationSchool
  13. *
  14. * @author sgq
  15. */
  16. class EducationSchool extends AdminController {
  17. public function index() {
  18. $type = $this->user["type"];
  19. return view("", ["type" => $type]);
  20. }
  21. public function list() {
  22. $res = EducationApi::getList($this->request);
  23. return json($res);
  24. }
  25. public function detail() {
  26. $id = $this->request->param("id");
  27. $info = EducationApi::getInfoById($id);
  28. return view("", ["row" => $info]);
  29. }
  30. /**
  31. * 校验是否在审核范围内
  32. * @param type $id
  33. * @param type $process
  34. * @return type
  35. */
  36. public function validateIsCheck($id) {
  37. $responseObj = new \stdClass();
  38. $responseObj->code = 500;
  39. $oldInfo = EducationApi::getInfoById($id);
  40. if ($oldInfo["checkState"] != 1 && $oldInfo["checkState"] != 9) {
  41. $responseObj->msg = "不在审核范围内";
  42. return json($responseObj);
  43. }
  44. $where = [];
  45. $where[] = ["mainId", "=", $id];
  46. $where[] = ["active", "=", 2];
  47. $where[] = ["step", "=", 11];
  48. $log = TalentLog::where($where)->order("createTime desc")->find();
  49. if ($log) {
  50. $oldInfo["checkState"] = $log["state"];
  51. $oldInfo["checkMsg"] = $log["description"];
  52. } else {
  53. $oldInfo["checkState"] = null;
  54. $oldInfo["checkMsg"] = "";
  55. }
  56. $responseObj->code = 200;
  57. $responseObj->obj = $oldInfo;
  58. return json($responseObj);
  59. }
  60. /**
  61. * 审核
  62. * @return type
  63. */
  64. public function check() {
  65. $responseObj = new \stdClass();
  66. $responseObj->code = 500;
  67. $obj = $this->request->param();
  68. if (!$obj) {
  69. $responseObj->msg = "系统错误,请联系管理员";
  70. return json($responseObj);
  71. }
  72. if (!$obj["checkState"]) {
  73. $responseObj->msg = "请选择审核状态";
  74. return json($responseObj);
  75. }
  76. Db::startTrans();
  77. try {
  78. //加入日志
  79. $newLog["id"] = getStringId();
  80. $newLog["type"] = ProjectState::EDUCATION;
  81. $newLog["mainId"] = $obj["id"];
  82. $newLog["active"] = 2;
  83. $newLog["state"] = $obj["checkState"];
  84. $newLog["step"] = 11;
  85. $newLog["stateChange"] = "保存未提交";
  86. $newLog["description"] = $obj["checkMsg"];
  87. $newLog["createTime"] = date("Y-m-d H:i:s");
  88. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  89. Db::table("new_talent_checklog")->insert($newLog);
  90. $responseObj->code = 200;
  91. $responseObj->msg = "审核成功";
  92. Db::commit();
  93. return json($responseObj);
  94. } catch (\Exception $e) {
  95. Db::rollback();
  96. $responseObj->msg = $e->getMessage();
  97. return json($responseObj);
  98. }
  99. }
  100. public function submitCheck() {
  101. $id = $this->request->param("id");
  102. $checkState = $this->request->param("id");
  103. $responseObj = new \stdClass();
  104. $responseObj->code = 500;
  105. if (!$id) {
  106. $responseObj->msg = "系统错误,请联系管理员!";
  107. return json($responseObj);
  108. }
  109. $oldInfo = EducationApi::getInfoById($id);
  110. if ($oldInfo["checkState"] != 1 && $oldInfo["checkState"] != 9) {
  111. $responseObj->msg = "不在审核范围内";
  112. return json($responseObj);
  113. }
  114. $where = [];
  115. $where[] = ["mainId", "=", $id];
  116. $where[] = ["active", "=", 2];
  117. $where[] = ["step", "=", 11];
  118. $oldLog = TalentLog::where($where)->order("createTime desc")->find();
  119. if (!$oldLog) {
  120. $responseObj->msg = "请先审核后再提交";
  121. return json($responseObj);
  122. }
  123. $updData = [];
  124. $updData["id"] = $id;
  125. $updData["checkState"] = $oldLog["state"];
  126. $updData["checkMsg"] = $oldLog["description"];
  127. if ($updData["checkState"] == 3) {
  128. $updData["passTime"] = date("Y-m-d H:i:s");
  129. if ($oldInfo["project"] == 2) {
  130. if ($oldInfo["talentArrange"] == 1) {
  131. $updData["score"] = 15;
  132. } else if ($oldInfo["talentArrange"] == 2) {
  133. $updData["score"] = 10;
  134. } else if ($oldInfo["talentArrange"] == 3) {
  135. $updData["score"] = 5;
  136. }
  137. }
  138. }
  139. $newLog["id"] = getStringId();
  140. $newLog["type"] = ProjectState::EDUCATION;
  141. $newLog["mainId"] = $id;
  142. $newLog["active"] = 1;
  143. $newLog["state"] = $oldLog["state"];
  144. $newLog["step"] = 11;
  145. $newLog["stateChange"] = MainState::getStateName($oldInfo["checkState"]) . "->" . MainState::getStateName($updData["checkState"]);
  146. $newLog["description"] = $oldLog["description"];
  147. $newLog["createTime"] = date("Y-m-d H:i:s");
  148. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  149. Db::startTrans();
  150. try {
  151. $where = [];
  152. $where[] = ["mainId", "=", $id];
  153. $where[] = ["type", "=", ProjectState::EDUCATION];
  154. $where[] = ["active", "=", 2];
  155. Db::table("new_talent_checklog")->where($where)->delete();
  156. Db::table("new_talent_checklog")->insert($newLog);
  157. Db::table("un_education_school")->save($updData);
  158. Db::commit();
  159. $responseObj->code = 200;
  160. $responseObj->msg = "提交审核成功";
  161. return json($responseObj);
  162. } catch (\think\db\exception\DbException $e) {
  163. Db::rollback();
  164. $responseObj->msg = $e->getMessage();
  165. return json($responseObj);
  166. }
  167. }
  168. /**
  169. * 通用导出
  170. * @return type
  171. */
  172. public function export() {
  173. $response = new \stdClass();
  174. $response->code = 500;
  175. $request = $this->request;
  176. $user = $this->user;
  177. if (!in_array($user["type"], [1, 2, 5, 6])) {
  178. $response->msg = "当前账号类型没有操作权限";
  179. return \StrUtil::back($response, "TalentInfo.callBack");
  180. }
  181. $names = \StrUtil::getRequestDecodeParam($request, "names");
  182. $values = \StrUtil::getRequestDecodeParam($request, "values");
  183. $title = array_filter(explode(",", $names)); //exce标题
  184. $keys = array_filter(explode(",", $values)); //标题对应的字段
  185. $where = [];
  186. //$where[] = ["type", "=", $user["type"]];
  187. if ($_where = EducationApi::getWhereByParams($request->param())) {
  188. $where = array_merge($where, $_where);
  189. }
  190. $list = \app\common\model\EducationSchool::where($where)->select()->toArray();
  191. if (in_array("talentArrangeName", $keys)) {
  192. $levelMap = DictApi::selectByParentCode("talent_arrange");
  193. }
  194. if (in_array("companyStreetName", $keys) || in_array("houseStreetName", $keys)) {
  195. $streetMap = DictApi::selectByParentCode("street");
  196. }
  197. if (in_array("cRelationName", $keys)) {
  198. $relationMap = DictApi::selectByParentCode("education_relation");
  199. }
  200. if (in_array("nowGradeName", $keys)) {
  201. $gradeMap = DictApi::selectByParentCode("education_grade");
  202. }
  203. if (in_array("applySchoolName", $keys)) {
  204. $schoolMap = DictApi::selectByParentCode("education_school_pool");
  205. }
  206. if (in_array("projectName", $keys)) {
  207. $educationProjectMap = DictApi::selectByParentCode("education_project");
  208. }
  209. $rows = [];
  210. foreach ($list as $item) {
  211. $row = [];
  212. foreach ($keys as $k) {
  213. $val = $item[$k];
  214. switch ($k) {
  215. case "talentArrangeName":
  216. $val = $levelMap[$item["talentArrange"]];
  217. break;
  218. case "companyStreetName":
  219. $val = $streetMap[$item["companyStreet"]];
  220. break;
  221. case "houseStreetName":
  222. $val = $streetMap[$item["houseStreet"]];
  223. break;
  224. case "cRelationName":
  225. $val = $relationMap[$item["cRelation"]];
  226. break;
  227. case "nowGradeName":
  228. $val = $gradeMap[$item["nowGrade"]];
  229. break;
  230. case "applySchoolName":
  231. $val = $schoolMap[$item["applySchool"]];
  232. break;
  233. case "projectName":
  234. $val = $educationProjectMap[$item["project"]];
  235. break;
  236. case "pSexName":
  237. $val = $item["pSex"] == 1 ? "男" : "女";
  238. break;
  239. case "cSexName":
  240. $val = $item["cSex"] == 1 ? "男" : "女";
  241. break;
  242. case "checkStateName":
  243. if ($item["checkState"] == -2) {
  244. $val = "保存未提交";
  245. }if ($item["checkState"] == -1) {
  246. $val = "审核不通过";
  247. }if ($item["checkState"] == 1) {
  248. $val = "待审核";
  249. }if ($item["checkState"] == 2) {
  250. $val = "审核驳回";
  251. }if ($item["checkState"] == 3) {
  252. $val = "审核通过";
  253. }if ($item["checkState"] == 9) {
  254. $val = "重新提交";
  255. }
  256. break;
  257. }
  258. $row[] = $val;
  259. }
  260. $rows[] = $row;
  261. }
  262. if (!$rows) {
  263. $response->msg = "没有可导出的内容";
  264. return \StrUtil::back($response, "TalentInfo.callBack");
  265. }
  266. $fileName = "子女择校导出";
  267. export($title, $rows, $fileName);
  268. }
  269. }