TalentBankChange.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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["newBank"];
  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["newBank"];
  87. $updAllowance["bankNumber"] = $info["newBankNumber"];
  88. $updAllowance["bankNetPoint"] = $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["newBank"];
  96. $updHousepurchase["bankNumber"] = $info["newBankNumber"];
  97. $updHousepurchase["bankNetPoint"] = $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_quit")->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. private function setTalentBank($data) {
  127. $where = [];
  128. if (\StrUtil::isNotEmpAndNull($data["talentName"])) {
  129. $where[] = ["talentName", "=", $data["talentName"]];
  130. }
  131. if (\StrUtil::isNotEmpAndNull($data["idCard"])) {
  132. $where[] = ["idCard", "=", $data["IdCard"]];
  133. }
  134. if (\StrUtil::isNotEmpAndNull($data["oldBankName"])) {
  135. $where[] = ["oldBankName", "=", $data["oldBankName"]];
  136. }
  137. if (\StrUtil::isNotEmpAndNull($data["newBankName"])) {
  138. $where[] = ["newBankName", "=", $data["newBankName"]];
  139. }
  140. if (\StrUtil::isNotEmpAndNull($data["oldBankAccount"])) {
  141. $where[] = ["oldBankAccount", "=", $data["oldBankAccount"]];
  142. }
  143. if (\StrUtil::isNotEmpAndNull($data["newBankAccount"])) {
  144. $where[] = ["newBankAccount", "=", $data["newBankAccount"]];
  145. }
  146. if ($data["checkState"] != null) {
  147. $where[] = ["checkState", "=", $data["checkState"]];
  148. }
  149. return $where;
  150. }
  151. }