123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- <?php
- namespace app\admin\controller;
- use app\admin\common\AdminController;
- use app\common\api\ChuanglanSmsApi;
- use app\common\api\EnterpriseApi;
- use app\common\api\LivingAllowanceApi;
- use app\common\state\LivingAllowanceState as LaState;
- use app\common\state\CommonConst;
- use app\common\model\TalentLog;
- use app\common\state\ProjectState;
- use app\common\model\LivingAllowance as LaModel;
- use app\common\api\DictApi;
- use think\facade\Db;
- /**
- * Description of LivingAllowance
- *
- * @author sgq
- */
- class LivingAllowance extends AdminController {
- public function index() {
- $enterpriseList = EnterpriseApi::getSimpleList();
- $provinceList = \app\common\api\LocationApi::findProvinceSelect();
- $process = $this->request->param("process");
- $message = [];
- if ($this->user["type"] == 1) {
- $message["typeName"] = "晋江市硕博人才生活补贴申报";
- $message["address"] = "聚才网/人才晋江微信公众号";
- $message["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
- $message["phone"] = "0595-85633128";
- $message["email"] = "jjrc85661234@163.com";
- } else if ($this->user["type"] == 2) {
- $message["typeName"] = "晋江市硕博人才生活补贴申报";
- $message["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
- $message["dep"] = "集成电路产业园区";
- $message["phone"] = "0595-82250007、0595-82250001";
- $message["email"] = "jjjcdr@163.com";
- }
- return view("", ["enterpriseList" => $enterpriseList, "provinceList" => $provinceList, "process" => $process, "message" => $message]);
- }
- public function list() {
- $res = LivingAllowanceApi::getList($this->request->param());
- return json($res);
- }
- public function detail() {
- $id = $this->request->param("id");
- $process = $this->request->param("process");
- $info = LivingAllowanceApi::getInfoById($id);
- $info = $this->translateToChinese($info);
- return view("", ["row" => $info, "process" => $process]);
- }
- private function translateToChinese($obj) {
- if ($obj["industryFieldNew"]) {
- $obj["industryFieldNewName"] = DictApi::findByParentCodeAndCode("industry_field", $obj["industryFieldNew"])["name"];
- }
- if ($obj["industryField"]) {
- $industry_field_type = $obj["industryFieldNew"] ? $obj["industryFieldNew"] . "_field" : "un_industryField";
- $obj["industryFieldName"] = DictApi::findByParentCodeAndCode($industry_field_type, $obj["industryField"])["name"];
- }
- if ($obj["address"]) {
- $obj["streetName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
- }
- if ($obj["nationality"]) {
- $obj["nationalityName"] = DictApi::findByParentCodeAndCode("nationality", $obj["nationality"])["name"];
- }
- if ($obj["nation"]) {
- $obj["nationName"] = DictApi::findByParentCodeAndCode("nation", $obj["nation"])["name"];
- }
- if ($obj["politics"]) {
- $obj["politicsName"] = DictApi::findByParentCodeAndCode("politics", $obj["politics"])["name"];
- }
- if ($obj["highEducation"]) {
- $obj["educationName"] = DictApi::findByParentCodeAndCode("highest_degree", $obj["highEducation"])["name"];
- }
- if ($obj["introductionMode"]) {
- $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("un_introduction_mode", $obj["introductionMode"])["name"];
- }
- if ($obj["declareType"]) {
- $obj["declareTypeName"] = DictApi::findByParentCodeAndCode("un_master_education", $obj["declareType"])["name"];
- }
- if ($obj["cardType"] == 1) {
- $obj["cardTypeName"] = "身份证";
- } else if ($obj["cardType"] == 2) {
- $obj["cardTypeName"] = "通行证";
- } else if ($obj["cardType"] == 3) {
- $obj["cardTypeName"] = "护照";
- } else {
- $obj["cardTypeName"] = "未知";
- }
- return $obj;
- }
- /**
- * 校验是否在审核范围内
- * @param type $id
- * @param type $process
- * @return type
- */
- public function validateIsCheck($id, $process) {
- $oldInfo = \app\common\api\LivingAllowanceApi::getInfoById($id);
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- switch ($process) {
- case 1:
- if ($oldInfo["checkState"] != LaState::LA_NEED_FIRST_CHECK && $oldInfo["checkState"] != LaState::LA_DEP_REJECT) {
- $responseObj->msg = "该申报不在审核范围内,无法审核";
- } else {
- $responseObj->code = 200;
- $responseObj->msg = "";
- }
- break;
- case 2:
- $company = getCacheById("Company", $this->user["companyId"]);
- if ($oldInfo["checkState"] != LaState::LA_NEED_DEP_CHECK && $oldInfo["checkState"] != LaState::LA_THIRD_REJECT) {
- $responseObj->msg = "该申报不在审核范围内,无法审核";
- } else if ($company["code"] != CommonConst::JYJ) {
- $responseObj->msg = "部门审核仅教育局能够审核!";
- } else {
- $responseObj->code = 200;
- $responseObj->msg = "";
- }
- break;
- case 3:
- if ($oldInfo["checkState"] != LaState::LA_NEED_THIRD) {
- $responseObj->msg = "该申报不在审核范围内,无法审核";
- } else if ($oldInfo["reditStatus"] == 1) {
- $responseObj->msg = "当前申报数据未导入核查数据,无法审核";
- } else {
- $responseObj->code = 200;
- $responseObj->msg = "";
- }
- break;
- case 4:
- break;
- }
- if ($responseObj->code == 500) {
- return json($responseObj);
- }
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["active", "=", 2];
- $where[] = ["step", "=", $process];
- $log = TalentLog::where($where)->order("createTime desc")->find();
- if ($log) {
- $oldInfo["checkState"] = $log["state"];
- $oldInfo["checkMsg"] = $log["description"];
- } else {
- $oldInfo["checkState"] = null;
- $oldInfo["checkMsg"] = "";
- }
- $res = [];
- $res["obj"] = $oldInfo;
- if ($responseObj->code == 200) {
- $where = [];
- $where[] = ["project", "=", ProjectState::LIVINGALLOWANCE];
- $where[] = ["active", "=", 1];
- $where[] = ["type", "=", $oldInfo["type"]];
- $fileTypeList = \app\common\model\FileType::where($where)->order("sn")->select()->toArray();
- $res["fileList"] = $fileTypeList;
- }
- $responseObj->obj = $res;
- return json($responseObj);
- }
- /**
- * 审核
- * @return type
- */
- public function check() {
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- $obj = $this->request->param();
- if (!$obj) {
- $responseObj->msg = "系统错误,请联系管理员";
- return json($responseObj);
- }
- if (!$obj["checkState"]) {
- $responseObj->msg = "请选择审核状态";
- return json($responseObj);
- }
- Db::startTrans();
- try {
- //保存驳回字段
- $updData["id"] = $obj["id"];
- $updData["fields"] = $obj["fields"];
- $updData["files"] = $obj["files"];
- Db::table("md_living_allowance_info")->save($updData);
- //加入日志
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $obj["id"];
- $newLog["active"] = 2;
- $newLog["state"] = $obj["checkState"];
- $newLog["step"] = $obj["process"];
- $newLog["stateChange"] = "保存未提交";
- $newLog["description"] = $obj["checkMsg"];
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- Db::table("new_talent_checklog")->insert($newLog);
- $responseObj->code = 200;
- $responseObj->msg = "审核成功";
- Db::commit();
- return json($responseObj);
- } catch (\Exception $e) {
- Db::rollback();
- $responseObj->msg = $e->getMessage();
- return json($responseObj);
- }
- }
- /**
- * 审核不通过
- * @return type
- */
- public function setNotPass() {
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- $ids = trim($this->request->param("ids"));
- $msg = trim($this->request->param("msg"));
- $ids = array_filter(explode(",", $ids));
- if (!$ids) {
- $responseObj->msg = "请选择需要设置审核不通过的数据";
- return json($responseObj);
- }
- if (!$msg) {
- $responseObj->msg = "请填写审核不通过的原因";
- return json($responseObj);
- }
- $where = [];
- $where[] = ["id", "in", $ids];
- $list = LaModel::where($where)->select()->toArray();
- $updates = [];
- $newLogs = [];
- $sb = [];
- Db::startTrans();
- try {
- foreach ($list as $obj) {
- if ($obj["checkState"] != LaState::LA_SAVE && $obj["checkState"] != LaState::LA_FIRST_REJECT) {
- $sb[] = $obj["name"];
- }
- $oldState = $obj["checkState"];
- $newState = LaState::LA_NOTPASS;
- $updates[] = [
- "id" => $obj["id"],
- "checkState" => $newState,
- "checkMsg" => $msg
- ];
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $obj["id"];
- $newLog["active"] = 2;
- $newLog["state"] = $newState;
- $newLog["step"] = 70; //审核不通过
- $newLog["stateChange"] = LaState::getStateDesc($oldState) . "->" . LaState::getStateDesc($newState);
- $newLog["description"] = $msg;
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- $newLogs[] = $newLog;
- }
- if ($sb) {
- $responseObj->msg = implode(",", $sb) . "的审核状态既不是待提交,也不是初审驳回";
- return json($responseObj);
- }
- if (!$updates || !$newLogs) {
- $responseObj->msg = "没有待审核项";
- return json($responseObj);
- }
- Db::table("md_living_allowance_info")->saveAll($updates);
- Db::table("new_talent_checklog")->insertAll($newLogs);
- Db::commit();
- $responseObj->code = 200;
- $responseObj->msg = "设置审核不通过成功";
- return json($responseObj);
- } catch (\Exception $e) {
- Db::rollback();
- return json(["msg" => "设置审核不通过失败:" . $e->getMessage()]);
- }
- }
- public function submitCheck() {
- $id = $this->request->param("id");
- $process = $this->request->param("process");
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- if (!$id) {
- $responseObj->msg = "系统错误,请联系管理员!";
- return json($responseObj);
- }
- $oldInfo = \app\common\api\LivingAllowanceApi::getInfoById($id);
- $oldState = $oldInfo["checkState"];
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["active", "=", 2];
- $where[] = ["step", "=", $process];
- $oldLog = TalentLog::where($where)->order("createTime desc")->find();
- if (!$oldLog) {
- $responseObj->msg = "请先审核后再提交";
- return json($responseObj);
- }
- $company = getCacheById("Company", $this->user["companyId"]);
- if ($process == 2 && $company["code"] != CommonConst::JYJ) {
- $responseObj->msg = "部门审核仅教育局能够审核!";
- return $responseObj;
- }
- $updData = [];
- $updData["id"] = $id;
- if (!$oldInfo["highProcess"]) {
- $updData["highProcess"] = $process;
- } else {
- $updData["highProcess"] = $oldInfo["process"] < $process ? $process : $oldInfo["highProcess"];
- }
- switch ($process) {
- case 1:
- if ($oldLog["state"] == -1) {
- $updData["checkState"] = LaState::LA_NOTPASS;
- $updData["recommendAmount"] = 0;
- $updData["isPay"] = -1;
- $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
- $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
- }
- if ($oldLog["state"] == 2) {
- $updData["checkState"] = LaState::LA_FIRST_REJECT;
- //MessageRecord record = new MessageRecord(old.getId(), 2, 2, old.getName(), old.getPhone(), null, SmsProperties.MASTER_ALLOWANCE_REJECT);
- //Sms253Util.sendMessage(record);
- }
- //审核通过
- if ($oldLog["state"] == 3) {
- $updData["checkState"] = LaState::LA_NEED_DEP_CHECK;
- $updData["firstPassTime"] = date("Y-m-d H:i:s");
- }
- break;
- case 2:
- if ($oldLog["state"] == -1) {
- $updData["checkState"] = LaState::LA_NOTPASS;
- $updData["recommendAmount"] = 0;
- $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
- $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
- $updData["recommendIsPay"] = -1;
- }
- if ($oldLog["state"] == 2) {
- $updData["checkState"] = LaState::LA_DEP_REJECT;
- $updData["creditStatus"] = 1;
- $updData["recommendAmount"] = null;
- $updData["recommendAmountDesc"] = "";
- $updData["recommendJudgmentDetails"] = "";
- $updData["recommendIsPay"] = 0;
- }
- if ($oldLog["state"] == 3) {
- $updData["checkState"] = LaState::LA_NEED_THIRD;
- $updData["firstDepPassTime"] = date("Y-m-d H:i:s");
- $_updData = $this->calculateAmount($oldInfo);
- $updData = array_merge($updData, $_updData);
- }
- break;
- case 3:
- if ($oldLog["state"] == -1) {
- $updData["checkState"] = LaState::LA_NOTPASS;
- $updData["recommendAmount"] = 0;
- $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
- $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
- $updData["recommendIsPay"] = -1;
- }
- if ($oldLog["state"] == 2) {
- $updData["checkState"] = LaState::LA_DEP_REJECT;
- $updData["creditStatus"] = 1;
- $updData["recommendAmount"] = null;
- $updData["recommendAmountDesc"] = "";
- $updData["recommendJudgmentDetails"] = "";
- $updData["recommendIsPay"] = 0;
- }
- if ($oldLog["state"] == 3) {
- $updData["checkState"] = LaState::LA_PASS;
- $updData["isPublic"] = 2;
- }
- break;
- }
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $id;
- $newLog["active"] = 1;
- $newLog["state"] = $oldLog["state"];
- $newLog["step"] = $process;
- $newLog["stateChange"] = LaState::getStateDesc($oldState) . "->" . LaState::getStateDesc($updData["checkState"]);
- $newLog["description"] = $oldLog["description"];
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- Db::startTrans();
- try {
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
- $where[] = ["active", "=", 2];
- Db::table("new_talent_checklog")->where($where)->delete();
- Db::table("new_talent_checklog")->insert($newLog);
- Db::table("md_living_allowance_info")->save($updData);
- Db::commit();
- $responseObj->code = 200;
- $responseObj->msg = "提交审核成功";
- return json($responseObj);
- } catch (\think\db\exception\DbException $e) {
- Db::rollback();
- $responseObj->msg = $e->getMessage();
- return json($responseObj);
- }
- }
- /**
- * 计算兑现额度
- * @param type $oldInfo
- * @return string
- */
- private function calculateAmount($oldInfo) {
- $return = [];
- /* * 硕士研究生补贴 */
- if ($oldInfo["declareType"] == 1) {
- //硕士 master_living_allowance_ss_money
- $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_ss_money", $oldInfo["applyCount"]);
- } else {
- //博士 master_living_allowance_bs_money
- $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_bs_money", $oldInfo["applyCount"]);
- }
- $moneyStanard = $moneyInfo ? $moneyInfo["name"] : 0;
- $return["recommendAmount"] = $moneyStanard;
- $where = [];
- $where[] = ["cardType", "=", $oldInfo["cardType"]];
- $where[] = ["idCard", "=", $oldInfo["idCard"]];
- $where[] = ["year", "=", substr($oldInfo["year"], 0, 4)];
- $where[] = ["checkState", "=", 30];
- $where[] = ["publicState", ">=", 4];
- $talentAllowanceInfo = \app\common\model\TalentAllowance::where($where)->findOrEmpty();
- if ($talentAllowanceInfo) {
- $balanceMoney = $oldInfo["amount"] - $talentAllowanceInfo["money"];
- if (round($balanceMoney, 2) == round(0, 2)) {
- $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",根据就高原则生活补贴享受额度为0元,因此不予兑现;\n";
- $return["recommendAmount"] = 0;
- $return["recommendIsPay"] = -1;
- } else {
- $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",需要补充生活补贴额度为:" . round($balanceMoney, 2) . "元,予以兑现;\n";
- $return["recommendAmount"] = $balanceMoney;
- }
- } else {
- $return["recommendAmountDesc"] = "当年度无享受津补贴的记录,可全额享受,予以兑现;\n";
- }
- return $return;
- }
- }
|