TalentBankChange.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\model\TalentBankChange as TbcModel;
  5. use app\common\api\DictApi;
  6. use app\common\state\MainState;
  7. use app\common\model\TalentLog;
  8. use app\common\state\ProjectState;
  9. use think\facade\Db;
  10. /**
  11. * Description of TalentBankChange
  12. *
  13. * @author sgq
  14. */
  15. class TalentBankChange extends AdminController {
  16. public function index() {
  17. return view("", ["type" => $this->user["type"]]);
  18. }
  19. public function list() {
  20. $params = $this->request->param();
  21. $offset = $params["offset"] ?: 0;
  22. $order = $params["order"] ?: "desc";
  23. $limit = $params["limit"] ?: 10;
  24. $where = $this->setTalentBank($params);
  25. $where[] = ["type", "=", $this->user["type"]];
  26. $where[] = ["delete", "=", 0];
  27. //获取字典表人才层次
  28. $levelMap = DictApi::selectByParentCode("talent_arrange");
  29. $count = TbcModel::where($where)->count();
  30. $list = TbcModel::where($where)->limit($offset, $limit)->order("createTime {$order}")->select()->toArray();
  31. foreach ($list as $key => $item) {
  32. $list[$key]["talentArrangeName"] = $levelMap[$item["talentArrange"]];
  33. }
  34. return json(["rows" => $list, "total" => $count]);
  35. }
  36. public function check() {
  37. $id = $this->request["id"];
  38. $info = TbcModel::where("id", $id)->find();
  39. $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talentArrange"]];
  40. if (\StrUtil::isNotEmpAndNull($info["talentType"])) {
  41. $info["talentTypeName"] = DictApi::selectByParentCode("enterprise_tag")[$info["talentType"]];
  42. }
  43. //查看是否有上传旧附件
  44. $_where = [["mainId", "=", $id]];
  45. $old_list = Db::table("un_talent_common_file")->where($_where)->find();
  46. $showOldFile = 0;
  47. if ($old_list) {
  48. $showOldFile = 1;
  49. }
  50. return view("check", ["type" => $this->user["type"], "row" => $info, "showOldFile" => $showOldFile]);
  51. }
  52. public function submitToCheck() {
  53. $responseObj = new \stdClass();
  54. $responseObj->code = 500;
  55. $id = $this->request["id"];
  56. $checkState = $this->request["checkState"];
  57. $checkMsg = $this->request["checkMsg"];
  58. $info = TbcModel::where("id", $id)->find();
  59. if (!$info) {
  60. $responseObj->msg = "系统错误,请联系管理员";
  61. return $responseObj;
  62. }
  63. if (strlen($info["talentId"]) == 19) {
  64. //旧系统申请兼容处理
  65. unset($where);
  66. $where[] = ["enterprise_id", "=", $info["enterpriseId"]];
  67. $where[] = ["card_number", "=", $info["idCard"]];
  68. $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
  69. $where[] = ["active", "=", 1];
  70. $where[] = ["delete", "=", 0];
  71. $ti = \app\enterprise\model\Talent::where($where)->order("createTime desc")->find();
  72. if (!$ti) {
  73. $responseObj->msg = "未匹配到人才数据";
  74. return $responseObj;
  75. }
  76. $info["talentId"] = $ti["id"];
  77. }
  78. if (!$checkState) {
  79. $responseObj->msg = "请选择审核状态";
  80. return $responseObj;
  81. }
  82. Db::startTrans();
  83. try {
  84. //添加日志
  85. $user = $this->user;
  86. $log["id"] = getStringId();
  87. $log["active"] = 1;
  88. $log["state"] = $checkState;
  89. $log["step"] = 11;
  90. $log["stateChange"] = MainState::getStateName($info["checkState"]) . "->" . MainState::getStateName($checkState);
  91. $log["type"] = ProjectState::BANKCHANGE;
  92. $log["mainId"] = $id;
  93. $log["description"] = $checkMsg;
  94. $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  95. $log["createTime"] = date("Y-m-d H:i:s");
  96. $updTalentBank["id"] = $id;
  97. $updTalentBank["checkState"] = $checkState;
  98. $updTalentBank["checkMsg"] = $checkMsg;
  99. if ($checkState == 3) {
  100. //修改人才库信息
  101. $upd["id"] = $info["talentId"];
  102. $upd["bank"] = $info["newBankName"];
  103. $upd["bank_number"] = $info["newBankNumber"];
  104. $upd["bank_branch_name"] = $info["newBankNerPoint"];
  105. $upd["bank_account"] = $info["newBankAccount"];
  106. Db::table("new_talent_info")->save($upd);
  107. //修改津补贴
  108. $updAllowance["bank"] = $info["newBankName"];
  109. $updAllowance["bankNumber"] = $info["newBankNumber"];
  110. $updAllowance["bankNetwork"] = $info["newBankNerPoint"];
  111. $updAllowance["bankAccount"] = $info["newBankAccount"];
  112. $where = [];
  113. $where[] = ["talentId", "=", $info["talentId"]];
  114. $where[] = ["publicState", "<=", 3];
  115. Db::table("un_talent_allowance_info")->where($where)->save($updAllowance);
  116. //修改购房补贴
  117. $updHousepurchase["bank"] = $info["newBankName"];
  118. $updHousepurchase["bankNumber"] = $info["newBankNumber"];
  119. $updHousepurchase["bankNetwork"] = $info["newBankNerPoint"];
  120. $updHousepurchase["bankAccount"] = $info["newBankAccount"];
  121. $where = [];
  122. $where[] = ["talentId", "=", $info["talentId"]];
  123. $where[] = ["publicState", "<=", 2];
  124. Db::table("un_housepurchase")->where($where)->save($updHousepurchase);
  125. $talentLog["id"] = getStringId();
  126. $talentLog["active"] = 1;
  127. $talentLog["step"] = 23;
  128. $talentLog["type"] = ProjectState::TALENT;
  129. $talentLog["mainId"] = $info["talentId"];
  130. $talentLog["description"] = "银行账号变更通过,同步到人才库";
  131. $talentLog["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
  132. $talentLog["createTime"] = date("Y-m-d H:i:s");
  133. Db::table("new_talent_checklog")->insert($talentLog);
  134. $updTalentBank["passTime"] = date("Y-m-d H:i:s");
  135. }
  136. Db::table("new_talent_checklog")->insert($log);
  137. Db::table("un_talent_bank_change")->save($updTalentBank);
  138. $responseObj->code = 200;
  139. $responseObj->msg = "审核成功";
  140. Db::commit();
  141. return $responseObj;
  142. } catch (\think\db\exception\DbException $e) {
  143. $responseObj->msg = $e->getMessage();
  144. Db::rollback();
  145. return $responseObj;
  146. }
  147. }
  148. public function export() {
  149. $request = $this->request;
  150. $data["talentName"] = \StrUtil::getRequestDecodeParam($request, "talentName");
  151. $data["idCard"] = \StrUtil::getRequestDecodeParam($request, "idCard");
  152. $data["oldBankName"] = \StrUtil::getRequestDecodeParam($request, "oldBankName");
  153. $data["oldBankAccount"] = \StrUtil::getRequestDecodeParam($request, "oldBankAccount");
  154. $data["newBankName"] = \StrUtil::getRequestDecodeParam($request, "newBankName");
  155. $data["newBankAccount"] = \StrUtil::getRequestDecodeParam($request, "newBankAccount");
  156. $data["checkState"] = \StrUtil::getRequestDecodeParam($request, "checkState");
  157. $where = $this->setTalentBank($data);
  158. $where[] = ["type", "=", $this->user["type"]];
  159. $where[] = ["delete", "=", 0];
  160. $list = TbcModel::where($where)->select()->toArray();
  161. $levelMap = DictApi::selectByParentCode("talent_arrange");
  162. $title = ["姓名", "证件号码", "工作单位", "人才层次", "原开户银行", "原开户银行网点", "原银行账号", "原银行行号",
  163. "现开户银行", "现开户银行网点", "现银行账号", "现银行行号", "审核状态", "审核意见", "审核通过时间"];
  164. $keys = ["talentName", "idCard", "enterpriseName", "talentArrangeName", "oldBankName", "oldBankNerPoint", "oldBankAccount", "oldBankNumber",
  165. "newBankName", "newBankNerPoint", "newBankAccount", "newBankNumber", "checkStateName", "checkMsg", "passTime"];
  166. $rows = [];
  167. foreach ($list as &$item) {
  168. $item["talentArrangeName"] = $levelMap[$item["talentArrange"]];
  169. switch ($item["checkState"]) {
  170. case -1:
  171. $item["checkStateName"] = "待提交";
  172. break;
  173. case 1:
  174. $item["checkStateName"] = "待审核";
  175. break;
  176. case 2:
  177. $item["checkStateName"] = "审核驳回";
  178. break;
  179. case 3:
  180. $item["checkStateName"] = "已通过";
  181. break;
  182. case 9:
  183. $item["checkStateName"] = "重新提交";
  184. break;
  185. }
  186. $row = [];
  187. for ($i = 0; $i < count($keys); $i++) {
  188. $row[] = $item[$keys[$i]];
  189. }
  190. $rows[] = $row;
  191. }unset($item);
  192. if (!$rows) {
  193. return json(["msg" => "没有可导出的内容"]);
  194. }
  195. $fileName = "银行卡变更列表";
  196. export($title, $rows, $fileName);
  197. }
  198. private function setTalentBank($data) {
  199. $where = [];
  200. if (\StrUtil::isNotEmpAndNull($data["talentName"])) {
  201. $where[] = ["talentName", "=", $data["talentName"]];
  202. }
  203. if (\StrUtil::isNotEmpAndNull($data["idCard"])) {
  204. $where[] = ["idCard", "=", $data["IdCard"]];
  205. }
  206. if (\StrUtil::isNotEmpAndNull($data["oldBankName"])) {
  207. $where[] = ["oldBankName", "=", $data["oldBankName"]];
  208. }
  209. if (\StrUtil::isNotEmpAndNull($data["newBankName"])) {
  210. $where[] = ["newBankName", "=", $data["newBankName"]];
  211. }
  212. if (\StrUtil::isNotEmpAndNull($data["oldBankAccount"])) {
  213. $where[] = ["oldBankAccount", "=", $data["oldBankAccount"]];
  214. }
  215. if (\StrUtil::isNotEmpAndNull($data["newBankAccount"])) {
  216. $where[] = ["newBankAccount", "=", $data["newBankAccount"]];
  217. }
  218. if ($data["checkState"] != null) {
  219. $where[] = ["checkState", "=", $data["checkState"]];
  220. }
  221. return $where;
  222. }
  223. }