TalentBankChange.php 10 KB

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