TalentBankChange.php 9.6 KB

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