House.php 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use think\facade\Db;
  5. use app\common\api\Response;
  6. use app\common\api\DictApi;
  7. use app\common\api\TalentLogApi;
  8. use app\common\model\TalentChecklog;
  9. use app\common\state\ProjectState;
  10. use app\common\state\CommonConst;
  11. use app\common\state\HouseStateEnum;
  12. use app\common\model\HousePurchase as houseModel;
  13. use app\common\api\HouseApi;
  14. use app\common\model\HousePurchaseHouseInfo as houseInfoModel;
  15. /**
  16. * Description of House
  17. *
  18. * @author sgq
  19. */
  20. class House extends AdminController {
  21. public function index() {
  22. $process = $this->request["process"];
  23. $type = $this->user["type"];
  24. $assigns = ["process" => $process, "type" => $type];
  25. if ($process == 4) {
  26. if ($type == CommonConst::ENTERPRISE_NORMAL) {
  27. $msgBody["typeName"] = "晋江市现代产业体系人才津补贴申报";
  28. $msgBody["address"] = "聚才网/人才晋江微信公众号";
  29. $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  30. $msgBody["phone"] = "0595-85633128";
  31. $msgBody["email"] = "jjrc85661234@163.com";
  32. }
  33. if ($type == CommonConst::ENTERPRISE_JC) {
  34. $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
  35. $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  36. $msgBody["dep"] = "集成电路产业园区";
  37. $msgBody["phone"] = "0595-82250007、0595-82250001";
  38. $msgBody["email"] = "jjjcdr@163.com";
  39. }
  40. if ($type == CommonConst::ENTERPRISE_WJ) {
  41. $msgBody["typeName"] = "晋江市医疗卫生人才津补贴申报";
  42. $msgBody["address"] = "“健康晋江”微信公众号";
  43. $msgBody["dep"] = "晋江市卫生健康局";
  44. $msgBody["phone"] = "0595-85636159";
  45. $msgBody["email"] = "jjswjjrsk@163.com";
  46. }
  47. if ($type == CommonConst::ENTERPRISE_GJ) {
  48. $msgBody["typeName"] = "晋江市高等教育人才津补贴申报";
  49. $msgBody["address"] = "“泉州市高教发展中心”微信公众号";
  50. $msgBody["dep"] = "泉州市高教发展中心";
  51. $msgBody["phone"] = "0595-85002588";
  52. $msgBody["email"] = "jjsgjrc@126.com";
  53. }
  54. $assigns["message"] = $msgBody;
  55. }
  56. return view("", $assigns);
  57. }
  58. /**
  59. * 获取优秀人才津补贴列表
  60. */
  61. public function list($process) {
  62. $param = $this->request->param();
  63. $offset = $param["offset"] ?: 0;
  64. $limit = $param["limit"] ?: 10;
  65. $param["process"] = $process;
  66. $param["type"] = $this->user["type"];
  67. $where = [];
  68. $where[] = ["type", "=", $this->user["type"]];
  69. $where[] = ["delete", "=", 0];
  70. $order = "createTime desc";
  71. $this->setCondition($where, $param);
  72. switch ($process) {
  73. case 1:
  74. break;
  75. case 2:
  76. break;
  77. case 3:
  78. $where[] = ["depPassTime", "EXP", Db::raw("is not null")];
  79. break;
  80. case 4:
  81. $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
  82. $where[] = ["reviewPassTime", "EXP", Db::raw("is not null")];
  83. break;
  84. }
  85. if (in_array($process, [1, 3, 4])) {
  86. $count = houseModel::where($where)->count();
  87. $list = houseModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
  88. } else {
  89. $company = getCacheById("Company", $this->user["companyId"]);
  90. $result = HouseApi::selectForHousePurchase($param, $company, ProjectState::HOUSE, $offset, $limit);
  91. $count = $result["total"];
  92. $list = $result["rows"];
  93. }
  94. $list = $this->translateChinese($list, $process);
  95. return json(["rows" => $list, "total" => $count]);
  96. }
  97. /**
  98. * 审核页面
  99. * @return type
  100. */
  101. public function toCheckPage() {
  102. $id = $this->request["id"];
  103. $process = $this->request["process"];
  104. $companyId = $this->request["companyId"];
  105. $hand = $this->request["hand"];
  106. $housepurchase = HouseApi::getInfoById($id);
  107. $company = getCacheById("Company", $this->user["companyId"]);
  108. $enterprise = \app\common\api\EnterpriseApi::getOne($housepurchase["enterpriseId"]);
  109. $housepurchase["enterpriseName"] = $enterprise["name"];
  110. $housepurchase["process"] = $process;
  111. $housepurchase["companyId"] = $companyId;
  112. $housepurchase["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $housepurchase["talentArrange"])["name"];
  113. $housepurchase["marryStatusName"] = DictApi::findByParentCodeAndCode("marry_status", $housepurchase["marryStatus"])["name"];
  114. $housepurchase["cardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["cardType"])["name"];
  115. if (\StrUtil::isNotEmpAndNull($housepurchase["spouseCardType"])) {
  116. $housepurchase["spouseCardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["spouseCardType"])["name"];
  117. }
  118. if (\StrUtil::isNotEmpAndNull($housepurchase["childCardType"])) {
  119. $housepurchase["childCardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["childCardType"])["name"];
  120. }
  121. $housepurchase["streetName"] = DictApi::findByParentCodeAndCode("street", $housepurchase["street"])["name"];
  122. if ($housepurchase["type"] == 1) {
  123. $housepurchase["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $housepurchase["talentType"])["name"];
  124. }
  125. $housepurchase["identifyConditionCH"] = \app\common\api\TalentConditionApi::getOne($housepurchase["identifyCondition"])["name"];
  126. /* * 历史申报享受其他政策数据* */
  127. $historyOtherList = HouseApi::getHistoryEnjoyOtherList($id, $housepurchase["idCard"], $housepurchase["spouseIdcard"]);
  128. /* * 当前申报录入的享受其他政策数据 */
  129. $nowOtherList = HouseApi::getEnjoyOtherList($id);
  130. /* * 其他房产信息 */
  131. $zzjOtherHouseList = HouseApi::getOtherHouseList($id, 1);
  132. $zrzyOtherHouseList = HouseApi::getOtherHouseList($id, 2);
  133. /* * 未成年子女信息 */
  134. $childrenList = HouseApi::getChildren($id);
  135. /* * 配偶信息 */
  136. $spouseList = HouseApi::getSpouse($id);
  137. $dicts = DictApi::findChildDictByCode("card_type");
  138. $vars = [
  139. "dicts" => $dicts,
  140. "row" => $housepurchase,
  141. "company" => $company,
  142. "historyOtherList" => $historyOtherList,
  143. "nowOtherList" => $nowOtherList,
  144. "zzjOtherHouseList" => $zzjOtherHouseList,
  145. "zrzyOtherHouseList" => $zrzyOtherHouseList,
  146. "childrenList" => $childrenList,
  147. "spouseList" => $spouseList
  148. ];
  149. $template = $hand == 1 ? "info" : "select";
  150. return view($template, $vars);
  151. }
  152. /**
  153. * 查看详情
  154. * @return type
  155. */
  156. public function toSelectPage() {
  157. $id = $this->request["id"];
  158. $process = $this->request["process"];
  159. $obj = TalentAllowanceApi::getInfoById($id);
  160. $this->translateToChinese($obj);
  161. if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
  162. $need_choose_post_type = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_post_type");
  163. $need_choose_institution = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_institution");
  164. if ($need_choose_post_type[$obj["enterpriseId"]]) {
  165. $postTypes = DictApi::findChildDictByCode("PostType");
  166. foreach ($postTypes as $key => $pt) {
  167. if (!in_array($pt["code"], $need_choose_post_type[$obj["enterpriseId"]])) {
  168. unset($postTypes[$key]);
  169. }
  170. }
  171. }
  172. if (in_array($obj["enterpriseId"], $need_choose_institution)) {
  173. $institutions = DictApi::findChildDictByCode("Institution");
  174. }
  175. }
  176. return view("select", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
  177. }
  178. /**
  179. * 审核保存
  180. */
  181. public function check() {
  182. $id = $this->request["id"];
  183. $process = $this->request["process"];
  184. $toProcess = $this->request["toProcess"];
  185. $toDep = $this->request["toDep"];
  186. $checkState = $this->request["checkState"];
  187. $checkMsg = $this->request["checkMsg"];
  188. $cashType = $this->request["cashType"];
  189. $fields = $this->request["fields"];
  190. $files = $this->request["files"];
  191. if (!$checkState) {
  192. return new Response(Response::ERROR, "请选择审核状态");
  193. }
  194. if ($process == 1) {
  195. $old = HouseApi::getInfoById($id);
  196. $old["fields"] = $fields;
  197. $old["files"] = $files;
  198. houseModel::update($old);
  199. }
  200. if ($process == 3) {
  201. $data["id"] = $id;
  202. if ($checkState == 2) {
  203. if ($toProcess == 2) {
  204. $where = [];
  205. $where[] = ["code", "in", $toDep];
  206. $companyIds = \app\common\model\Company::where($where)->column("id");
  207. $data["toDep"] = implode(",", $companyIds);
  208. }
  209. $data["toProcess"] = $toProcess;
  210. }
  211. if ($checkState == 3) {
  212. $data["cashType"] = $cashType;
  213. }
  214. houseModel::update($data);
  215. }
  216. //添加日志
  217. TalentChecklog::create([
  218. 'id' => getStringId(),
  219. 'mainId' => $id,
  220. 'type' => intval(ProjectState::HOUSE),
  221. 'typeFileId' => null,
  222. 'active' => 2,
  223. 'state' => $checkState,
  224. 'step' => $process,
  225. 'stateChange' => "保存未提交",
  226. 'description' => $checkMsg,
  227. 'createTime' => date("Y-m-d H:i:s", time()),
  228. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  229. ]);
  230. return new Response(Response::SUCCESS, "审核成功");
  231. }
  232. /**
  233. * 提交审核
  234. * @return Response
  235. */
  236. public function submitCheck() {
  237. $id = $this->request["id"];
  238. $process = $this->request["process"];
  239. $companyId = $this->request["companyId"];
  240. if ($process != 2) {
  241. $companyId = null;
  242. }
  243. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2, $companyId);
  244. if (!$log) {
  245. return new Response(Response::ERROR, "请先审核后再提交");
  246. }
  247. $checkState = $log["state"];
  248. $housepurchase = [];
  249. $housepurchase["id"] = $id;
  250. $housepurchase["checkMsg"] = $log["description"];
  251. $old = HouseApi::getInfoById($id);
  252. //判断到达的最高流程
  253. $housepurchase["highProcess"] = $old["highProcess"] == null ? $process : ($old["highProcess"] < $process ? $process : $old["highProcess"]);
  254. switch ($process) {
  255. case 1:
  256. if ($checkState == -1) {
  257. $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
  258. $housepurchase["realEnjoyMoney"] = 0;
  259. }
  260. if ($checkState == 2) {
  261. $housepurchase["checkState"] = HouseStateEnum::FIRST_REJECT;
  262. }
  263. if ($checkState == 3) { //审核通过
  264. $depCount = Db::table("un_talent_depcheckstate")->where("mainId", $id)->count();
  265. if ($depCount > 0) {
  266. $where = [];
  267. $where[] = ["mainId", "=", $id];
  268. $where[] = ["state", "=", 2];
  269. $rejectCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  270. if ($rejectCount > 0) {
  271. $updDep["state"] = 9;
  272. $updDep["updateTime"] = date("Y-m-d H:i:s");
  273. $updDep["updateUser"] = $this->user["name"];
  274. Db::table("un_talent_depcheckstate")->where($where)->update($updDep);
  275. $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
  276. } else {
  277. $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
  278. }
  279. } else {
  280. /* * 生成各部门数据审核 */
  281. $depList = [];
  282. $depCodes = getJsonConfig("../sys_config.json", "housepurchase_dep_list")[$old["type"]];
  283. $where = [];
  284. $where[] = ["code", "in", $depCodes];
  285. $companies = \app\common\model\Company::where($where)->select()->toArray();
  286. foreach ($companies as $company) {
  287. $depList[] = [
  288. "id" => getStringId(),
  289. "type" => ProjectState::HOUSE,
  290. "mainId" => $id,
  291. "companyId" => $company["id"],
  292. "state" => 1,
  293. "createTime" => date("Y-m-d H:i:s"),
  294. "createUser" => $this->user["name"]
  295. ];
  296. }
  297. Db::table("un_talent_depcheckstate")->insertAll($depList);
  298. $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
  299. }
  300. if (\StrUtil::isEmpOrNull($old["firstPassTime"])) {
  301. $housepurchase["firstPassTime"] = date("Y-m-d H:i:s");
  302. }
  303. /* * 判断夫妻是否同时申报 */
  304. if (\StrUtil::isNotEmpAndNull($old["spouseIdcard"])) {
  305. $where = [];
  306. $where[] = ["idCard", "=", $old["spouseIdcard"]];
  307. $where[] = ["year", "=", $old["year"]];
  308. $where[] = ["delete", "=", 0];
  309. $count = houseModel::where($where)->count();
  310. $housepurchase["isConflict"] = $count > 0 ? 1 : 2;
  311. }
  312. }
  313. //添加日志
  314. TalentChecklog::create([
  315. 'id' => getStringId(),
  316. 'mainId' => $id,
  317. 'type' => intval(ProjectState::HOUSE),
  318. 'typeFileId' => null,
  319. 'active' => 1,
  320. 'state' => $checkState,
  321. 'step' => $process,
  322. 'stateChange' => sprintf("%s->%s", HouseStateEnum::getStateName($old["checkState"]), HouseStateEnum::getStateName($housepurchase["checkState"])),
  323. 'description' => $log["description"],
  324. 'createTime' => date("Y-m-d H:i:s", time()),
  325. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  326. ]);
  327. TalentChecklog::delete($log["id"]);
  328. houseModel::update($housepurchase);
  329. break;
  330. case 2:
  331. $where = [];
  332. $where[] = ["mainId", "=", $id];
  333. $where[] = ["companyId", "=", $companyId];
  334. $tds = Db::table("un_talent_depcheckstate")->where($where)->find();
  335. $tds["state"] = 3;
  336. $tds["submitTime"] = date("Y-m-d H:i:s");
  337. Db::table("un_talent_depcheckstate")->update($tds);
  338. //判断所有部门是否全部通过
  339. $where = [];
  340. $where[] = ["mainId", "=", $id];
  341. $where[] = ["state", "in", [1, 4, 9]];
  342. $needCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  343. if ($needCount == 0) {
  344. $where = [];
  345. $where[] = ["mainId", "=", $id];
  346. $where[] = ["state", "=", 2];
  347. $rejectCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  348. if ($rejectCount > 0) {
  349. $housepurchase["checkState"] = HouseStateEnum::DEP_REJECT;
  350. } else {
  351. if (\StrUtil::isEmpOrNull($old["depPassTime"])) {
  352. $housepurchase["depPassTime"] = date("Y-m-d H:i:s");
  353. }
  354. $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
  355. }
  356. houseModel::update($housepurchase);
  357. }
  358. //添加日志
  359. TalentChecklog::create([
  360. 'id' => getStringId(),
  361. 'mainId' => $id,
  362. 'type' => intval(ProjectState::HOUSE),
  363. "companyId" => $companyId,
  364. 'typeFileId' => null,
  365. 'active' => 1,
  366. 'state' => 3,
  367. 'step' => $process,
  368. 'stateChange' => sprintf("%s->%s", HouseStateEnum::getStateName($old["checkState"]), HouseStateEnum::getStateName($housepurchase["checkState"])),
  369. 'description' => $log["description"],
  370. 'createTime' => date("Y-m-d H:i:s", time()),
  371. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  372. ]);
  373. TalentChecklog::delete($log["id"]);
  374. break;
  375. case 3:
  376. if ($checkState == -1) {
  377. $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
  378. $housepurchase["cashType"] = 2;
  379. $housepurchase["realEnjoyMoney"] = 0;
  380. }
  381. if ($checkState == 2) {
  382. $where = [];
  383. $where[] = ["mainId", "=", $id];
  384. $where[] = ["companyId", "in", $old["toDep"]];
  385. if ($old["toProcess"] == -1) {
  386. $housepurchase["checkState"] = HouseStateEnum::FIRST_REJECT;
  387. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  388. $updTds["state"] = 2;
  389. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  390. }
  391. }
  392. if ($old["toProcess"] == 1) {
  393. $housepurchase["checkState"] = HouseStateEnum::REJECT_TO_FIRST;
  394. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  395. $updTds["state"] = 2;
  396. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  397. }
  398. } else if ($old["toProcess"] == 2) {
  399. $housepurchase["checkState"] = HouseStateEnum::REJECT_TO_DEP;
  400. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  401. $updTds["state"] = 4;
  402. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  403. }
  404. }
  405. }
  406. if ($checkState == 3) {
  407. /**
  408. * 通过需要判定补贴类型及享受金额
  409. * */
  410. $where = [];
  411. $where[] = ["idCard", "=", $old["idCard"]];
  412. $where[] = ["year", "=", $old["year"]];
  413. $where[] = ["delete", "=", 0];
  414. $info = \app\common\model\TalentAllowance::where($where)->find();
  415. if (!$info) {
  416. return new Response(Response::ERROR, "当前申报人暂未申报津补贴,无法审核通过");
  417. }
  418. if ($info["checkState"] != \app\common\state\AllowanceStateEnum::REVIEW_PASS || $info["publicState"] < 4) {
  419. return new Response(Response::ERROR, "当前申报人的津补贴申报暂未公示通过,无法审核通过");
  420. }
  421. $housepurchase["cashType"] = $old["cashType"];
  422. $descideDesc[] = "审核意见:" . $log["description"] . ";系统根据津补贴情况判断说明:";
  423. /* * 1.判断征信信息 */
  424. if (\StrUtil::isNotEmpAndNull($info["outMsg"]) && $info["checkState"] == \app\common\state\AllowanceStateEnum::NOTPASS) {
  425. $housepurchase["zxMsg"] = $info["outMsg"];
  426. $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
  427. $housepurchase["cashType"] = 2;
  428. $descideDesc[] = "(1)核查征信结果:" . $info["outMsg"] . ";无法享受";
  429. } else {
  430. $descideDesc[] = "(1)核查征信结果:征信通过;";
  431. $housepurchase["zxMsg"] = "";
  432. $housepurchase["checkState"] = HouseStateEnum::REVIEW_PASS;
  433. }
  434. /* * 2.获取社保/个税数据并判断是否可以享受* */
  435. if ($old["declareType"] == 1) { //购房补贴
  436. $sbSet = [];
  437. if ($old["type"] == 1) {
  438. sbSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB . getCode());
  439. } else{
  440. Set<String> pensionSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_PENSION . getCode());
  441. Set<String> unemploymentSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_UNEMPLOYMENT . getCode());
  442. Set<String> medicalSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_MEDICA . getCode());
  443. pensionSet . retainAll(unemploymentSet);
  444. pensionSet . retainAll(medicalSet);
  445. sbSet . addAll(pensionSet);
  446. }
  447. Set<String> taxSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_TAX . getCode());
  448. housepurchase . setSbPayDetail(sbSet . stream() . collect(Collectors . joining(",")));
  449. housepurchase . setTaxPayDetail(taxSet . stream() . collect(Collectors . joining(",")));
  450. housepurchase . setAllowanceType(info . getAllowanceType());
  451. /* * 获取社保个税交集 */
  452. Set<String> totalMonth = new TreeSet <> (Arrays . asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"));
  453. totalMonth . retainAll(sbSet);
  454. taxSet . retainAll(taxSet);
  455. /* * 判断是否享受人才津贴 */
  456. if (info . getAllowanceType() != 1 && housepurchase . getCashType() == 1) {
  457. housepurchase . setCashType(2);
  458. descideDesc . append("(2)上一年度未享受人才津贴,无法享受;");
  459. } else {
  460. descideDesc . append("(2)上一年度享受人才津贴;");
  461. }
  462. /* * 判断社保个税共同缴纳是否满足几个月 */
  463. if (totalMonth . size() < 9 && housepurchase . getCashType() == 1) {
  464. housepurchase . setCashType(2);
  465. descideDesc . append("(3)社保和个税上一年度共同缴纳未满足9个月,无法享受;");
  466. } else {
  467. descideDesc . append("(3)社保和个税上一年度共同缴纳满足9个月;");
  468. }
  469. housepurchase . setDecideDetail(descideDesc . toString());
  470. /* * 对需要兑现的计算享受金额 */
  471. if (housepurchase . getCashType() == 1) {
  472. ResponseObj responseObj = calculateOld(old, housepurchase, descideDesc, 1);
  473. if (responseObj . getCode() == 500) {
  474. return responseObj;
  475. }
  476. }
  477. } else if (old . getDeclareType() == 2) { //免租入住
  478. Set<String> set = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_LETTER . getCode());
  479. housepurchase . setLetterDetail(set . stream() . collect(Collectors . joining(",")));
  480. if (set . size() < 9 && housepurchase . getCashType() == 1) {
  481. housepurchase . setCashType(2);
  482. housepurchase . setDecideDetail("(2)上一年度行政介绍信未满足9个月");
  483. } else {
  484. housepurchase . setDecideDetail("(2)上一年度行政介绍信满足9个月");
  485. }
  486. }
  487. if (FengStringUtil . isEmpOrNull(old . getReviewPassTime())) {
  488. housepurchase . setReviewPassTime(DateUtil . getTime());
  489. }
  490. }
  491. TalentChecklog newLog3 = new TalentChecklog(ProjectEnum . HOUSE . getCode(), obj . getId(), null, StateConst . ACTIVE_YES, checkState,
  492. obj . getProcess(), HousePurechaseStateEnum . valueOf(old . getCheckState()) + "->" + HousePurechaseStateEnum . valueOf(housepurchase . getCheckState()), log . getDescription(), DateUtil . getTime(),
  493. ShiroKit . getUser() . getAccount() + "(" + company . getName() + ")");
  494. this.talentChecklogService.delete(new EntityWrapper<TalentChecklog>().eq("mainId", obj.getId()).eq("active", StateConst.ACTIVE_NO));
  495. this . talentChecklogService . insert(newLog3);
  496. this . housepurchaseService . updateById(housepurchase);
  497. break;
  498. }
  499. return new Response(Response::SUCCESS, "提交审核成功");
  500. }
  501. /**
  502. * 初审撤销
  503. * @return Response
  504. */
  505. public function cancleFirstCheck() {
  506. $obj = $this->request->param();
  507. $id = $obj["id"];
  508. $checkMsg = $obj["checkMsg"];
  509. if (!$id) {
  510. return new Response(Response::ERROR, "请选择需要撤销的对象");
  511. }
  512. $old = TalentAllowanceApi::getInfoById($id);
  513. if ($old["checkState"] != AllowanceStateEnum::NEED_REVIEW && $old["checkState"] != AllowanceStateEnum::NOTPASS) {
  514. return new Response(Response::ERROR, "当前对象的审核无法撤销");
  515. }
  516. $data["id"] = $id;
  517. $data["checkMsg"] = $checkMsg;
  518. $data["checkState"] = AllowanceStateEnum::NEED_CHECK;
  519. //添加日志
  520. TalentChecklog::create([
  521. 'id' => getStringId(),
  522. 'mainId' => $id,
  523. 'type' => intval(ProjectState::JBT),
  524. 'typeFileId' => null,
  525. 'active' => 1,
  526. 'state' => 11, //撤销审核
  527. 'step' => 1,
  528. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($data["checkState"]),
  529. 'description' => "撤销原因:" . $checkMsg,
  530. 'createTime' => date("Y-m-d H:i:s", time()),
  531. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  532. ]);
  533. TaModel::update($data);
  534. return new Response(Response::SUCCESS, "撤销成功");
  535. }
  536. /**
  537. * 复核撤销
  538. * @return Response|\app\admin\controller\ResponseObj
  539. */
  540. public function reviewCancleCheck() {
  541. $obj = $this->request->param();
  542. $id = $obj["id"];
  543. $checkMsg = $obj["checkMsg"];
  544. if (!$id) {
  545. return new Response(Response::ERROR, "请选择需要撤销的对象");
  546. }
  547. $old = TalentAllowanceApi::getInfoById($id);
  548. if ($old["checkState"] != AllowanceStateEnum::REVIEW_PASS || $old["publicState"] != 1) {
  549. return new Response(Response::ERROR, "当前对象的审核无法撤销");
  550. }
  551. $data["id"] = $id;
  552. $data["checkMsg"] = $checkMsg;
  553. $data["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  554. //添加日志
  555. TalentChecklog::create([
  556. 'id' => getStringId(),
  557. 'mainId' => $id,
  558. 'type' => intval(ProjectState::JBT),
  559. 'typeFileId' => null,
  560. 'active' => 1,
  561. 'state' => 11, //撤销审核
  562. 'step' => 3,
  563. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($data["checkState"]),
  564. 'description' => "撤销原因:" . $checkMsg,
  565. 'createTime' => date("Y-m-d H:i:s", time()),
  566. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  567. ]);
  568. TaModel::update($data);
  569. return new Response(Response::SUCCESS, "撤销成功");
  570. }
  571. /**
  572. * 查询需要导出的数据
  573. *
  574. */
  575. public function findTalentAllowanceByPage() {
  576. $param = $this->request->param();
  577. $where = [];
  578. $where[] = ["type", "=", $this->user["type"]];
  579. if ($param != null) {
  580. if (\StrUtil::isNotEmpAndNull($param["name"])) {
  581. $where[] = ["name", "like", "%" . $param["name"] . "%"];
  582. }
  583. if (\StrUtil::isNotEmpAndNull($param["idCard"])) {
  584. $where[] = ["idCard", "like", "%" . $param["idCard"] . "%"];
  585. }
  586. }
  587. $error = null;
  588. switch ($param["type"]) {
  589. case 1:
  590. case 2:
  591. $where[] = ["publicState", "=", 1];
  592. $where[] = ["checkState", "in", [-1, 30]];
  593. $error = "暂无可核查征信的数据";
  594. break;
  595. case 3:
  596. case 7:
  597. $where[] = ["publicState", "=", 2];
  598. $where[] = ["checkState", "in", [-1, 30]];
  599. $where[] = ["recommendAllowanceType", "=", 3];
  600. $error = "暂无可公示(不予兑现)的数据";
  601. break;
  602. case 4: //需要兑现
  603. case 8:
  604. $where[] = ["publicState", "=", 2];
  605. $where[] = ["checkState", "in", [30]];
  606. $where[] = ["recommendAllowanceType", "in", [1, 2]];
  607. $error = "暂无需要公示(兑现)的数据";
  608. break;
  609. case 5:
  610. $where[] = ["publicState", "=", 3];
  611. $where[] = ["checkState", "in", [-1, 30]];
  612. $error = "暂无可公示通过的数据";
  613. break;
  614. case 6:
  615. $where[] = ["publicState", "=", 4];
  616. $where[] = ["checkState", "in", [30]];
  617. $where[] = ["allowanceType", "in", [1, 2]];
  618. $error = "暂无可兑现的数据";
  619. break;
  620. }
  621. $list = TaModel::where($where)->select()->toArray();
  622. //查询企业信息
  623. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  624. foreach ($list as $key => $item) {
  625. $list[$key]["enterpriseName"] = $enterpriseMap[$item["enterpriseId"]];
  626. }
  627. $res = [
  628. "rows" => $list,
  629. "total" => count($list)
  630. ];
  631. return new Response(Response::SUCCESS, "", $res);
  632. }
  633. public function exportHczx() {
  634. $response = new \stdClass();
  635. $response->code = 500;
  636. $ids = $this->request->param("ids");
  637. $ids_arr = array_filter(explode(",", $ids));
  638. if (!$ids_arr) {
  639. $response->msg = "没有选择导出的名单";
  640. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  641. }
  642. $where = [];
  643. $where[] = ["id", "in", $ids_arr];
  644. $list = TaModel::field("id,cardType,idCard,name,enterpriseId,year")->where($where)->select()->toArray();
  645. if (!$list) {
  646. $response->msg = "暂无可核查征信的数据";
  647. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  648. }
  649. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  650. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  651. $cardTypeName = DictApi::selectByParentCode("card_type");
  652. $rows = [];
  653. for ($i = 0; $i < count($list); $i++) {
  654. $item = $list[$i];
  655. $row = [
  656. $i + 1, $item["name"], $cardTypeName[$item["cardType"]], $item["idCard"], $enterpriseMap[$item["enterpriseId"]], $item["description"]
  657. ];
  658. $rows[] = $row;
  659. }
  660. $filename = "津补贴待核查征信名单导出";
  661. if ($rows) {
  662. export($columns, $rows, $filename);
  663. exit();
  664. } else {
  665. $response->msg = "没有选择导出的名单";
  666. return \StrUtil::back($response, "TalentTypeChange.callBack");
  667. }
  668. }
  669. /**
  670. * 核查征信驳回
  671. */
  672. public function hczxReject() {
  673. $param = $this->request->param();
  674. if (!$param) {
  675. return new Response(Response::ERROR, "系统错误,请联系管理员");
  676. }
  677. $old = TalentAllowanceApi::getInfoById($param["id"]);
  678. if ($old["publicState"] != 1) {
  679. return new Response(Response::ERROR, "当前记录不是待核查征信状态,无法核查");
  680. }
  681. $data["id"] = $param["id"];
  682. $data["publicState"] = 2;
  683. $data["checkState"] = AllowanceStateEnum::NOTPASS;
  684. $data["recommendAllowanceType"] = 3;
  685. $data["recommendAllowanceMsg"] = "征信失信,不予兑现,失信原因:" . $param["outMsg"];
  686. $data["recommendMonths"] = "";
  687. $data["recommendMoney"] = 0.00;
  688. $data["workAllowanceMoney"] = null;
  689. $data["developAllowanceMoney"] = null;
  690. //添加日志
  691. TalentChecklog::create([
  692. 'id' => getStringId(),
  693. 'mainId' => $param["id"],
  694. 'type' => intval(ProjectState::JBT),
  695. 'typeFileId' => null,
  696. 'active' => 1,
  697. 'state' => 2,
  698. 'step' => 4,
  699. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "-><span class='label label-primary'>审核不通过</span>" . "公示状态:<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  700. 'description' => $param["outMsg"],
  701. 'createTime' => date("Y-m-d H:i:s", time()),
  702. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  703. ]);
  704. TaModel::update($data);
  705. return new Response(Response::SUCCESS, "核查征信成功");
  706. }
  707. /**
  708. * 核查征信批量通过
  709. */
  710. public function hczxPass() {
  711. $ids = $this->request["ids"];
  712. if (\StrUtil::isEmpOrNull($ids)) {
  713. return new Response(Response::ERROR, "请选择核查征信通过的数据");
  714. }
  715. $where = [];
  716. $where[] = ["id", "in", $ids];
  717. $list = TaModel::where($where)->select()->toArray();
  718. $logList = [];
  719. $upds = [];
  720. foreach ($list as $obj) {
  721. $upds[] = [
  722. "id" => $obj["id"],
  723. "publicState" => 2,
  724. ];
  725. $logList[] = [
  726. "id" => getStringId(),
  727. "type" => ProjectState::JBT,
  728. "mainId" => $obj["id"],
  729. "active" => 1,
  730. "state" => 3,
  731. "step" => 4,
  732. "stateChange" => "<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  733. "description" => "核查征信通过",
  734. "createTime" => date("Y-m-d H:i:s"),
  735. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  736. ];
  737. }
  738. $taModel = new TaModel();
  739. $taModel->saveAll($upds);
  740. Db::table("new_talent_checklog")->insertAll($logList);
  741. return new Response(Response::SUCCESS, "核查征信通过成功");
  742. }
  743. /**
  744. * 公示
  745. * */
  746. public function publicBatch() {
  747. $params = $this->request->param();
  748. $ids = $params["ids"];
  749. $ids = array_filter(explode(",", $ids));
  750. if (!$ids) {
  751. return new Response(Response::ERROR, "请至少选择一行数据");
  752. }
  753. $isMessage = $params["isMessage"] == 1 ? true : false;
  754. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  755. return new Response(Response::ERROR, "短信参数不能为空");
  756. }
  757. $where = [];
  758. $where[] = ["id", "in", $ids];
  759. $list = TaModel::where($where)->select()->toArray();
  760. Db::startTrans();
  761. try {
  762. $logList = [];
  763. $phones = [];
  764. foreach ($list as $info) {
  765. $data["id"] = $info["id"];
  766. $data["publicState"] = 3;
  767. Db::table("un_talent_allowance_info")->update($data);
  768. /* * 添加日志 */
  769. $logList[] = [
  770. "id" => getStringId(),
  771. "type" => ProjectState::JBT,
  772. "mainId" => $info["id"],
  773. "active" => 1,
  774. "state" => 3,
  775. "step" => 5,
  776. "stateChange" => "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>",
  777. "description" => "批量公示",
  778. "createTime" => date("Y-m-d H:i:s"),
  779. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  780. ];
  781. $phones[] = $info["phone"];
  782. }
  783. $effect = Db::table("new_talent_checklog")->insertAll($logList);
  784. Db::commit();
  785. if ($phones && $isMessage && $effect) {
  786. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  787. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  788. $phones = array_filter($phones);
  789. foreach ($phones as $phone) {
  790. queue("app\job\Messenger", ["type" => 6, "userId" => 0, "phone" => $phone, "template" => $tpl_content, "processName" => "津补贴-批量公示", "userType" => 3]);
  791. }
  792. }
  793. return new Response(Response::SUCCESS, "公示成功");
  794. } catch (\think\db\exception\DbException $e) {
  795. Db::rollback();
  796. return new Response(Response::SUCCESS, "公示失败:" . $e->getMessage());
  797. }
  798. }
  799. /**
  800. * 跳转到公示再审核页面
  801. * */
  802. public function toSupplePage() {
  803. $id = $this->request["id"];
  804. $process = $this->request["process"];
  805. $obj = TalentAllowanceApi::getInfoById($id);
  806. $this->translateToChinese($obj);
  807. if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
  808. $need_choose_post_type = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_post_type");
  809. $need_choose_institution = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_institution");
  810. if ($need_choose_post_type[$obj["enterpriseId"]]) {
  811. $postTypes = DictApi::findChildDictByCode("PostType");
  812. foreach ($postTypes as $key => $pt) {
  813. if (!in_array($pt["code"], $need_choose_post_type[$obj["enterpriseId"]])) {
  814. unset($postTypes[$key]);
  815. }
  816. }
  817. }
  818. if (in_array($obj["enterpriseId"], $need_choose_institution)) {
  819. $institutions = DictApi::findChildDictByCode("Institution");
  820. }
  821. }
  822. return view("public_check", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
  823. }
  824. /**
  825. * 公示再审核计算津补贴
  826. * */
  827. public function suppleCheckCalculate() {
  828. $id = $this->request["id"];
  829. try {
  830. $info = TalentAllowanceApi::getInfoById($id);
  831. $arrangeList = $this->validateAllowanceType($info);
  832. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  833. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  834. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  835. foreach ($detailList as &$detail) {
  836. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  837. if (\StrUtil::isNotEmpAndNull($detail["talentType"])) {
  838. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  839. }
  840. }
  841. $res = [
  842. "info" => $info,
  843. "detailList" => $detailList
  844. ];
  845. return new Response(Response::SUCCESS, "计算成功", $res);
  846. } catch (\think\Exception $e) {
  847. return new Response(Response::ERROR, "系统异常,请联系管理员");
  848. }
  849. }
  850. /**
  851. * 公示后审核
  852. */
  853. public function afterCheck() {
  854. $param = $this->request->param();
  855. if (!$param["id"]) {
  856. return new Response(Response::ERROR, "系统错误,请联系管理员");
  857. }
  858. $old = TalentAllowanceApi::getInfoById($param["id"]);
  859. if ($old["publicState"] != 3) {
  860. return new Response(Response::ERROR, "当前记录不是公示中状态,无法审核");
  861. }
  862. try {
  863. $arrangeList = null;
  864. $desc = "审核意见:" . $param["checkMsg"] . ";\n";
  865. $desc .= "征信:" . ($param["zxState"] == 1 ? "征信通过" : $param["zxMsg"] . ";\n");
  866. $data["id"] = $param["id"];
  867. if ($param["checkState"] == -1) {
  868. $data["checkState"] = -1;
  869. $data["checkMsg"] = $param["checkMsg"];
  870. $data["allowanceType"] = 3;
  871. $data["allowanceMsg"] = "审核不通过,原因:" . $param["checkMsg"];
  872. $data["outMsg"] = $param["zxState"] == 1 ? "" : $param["zxMsg"];
  873. } else if ($param["checkState"] == 3) {
  874. if ($param["zxState"] == 1) {
  875. $typeName = "";
  876. $old["recommendAllowanceMsg"] = "";
  877. if ($param["source"] == 1) { //遵循系统结果
  878. $arrangeList = $this->validateAllowanceType($old);
  879. $typeName = "系统判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["allowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  880. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $old["recommendAllowanceMsg"] . ";";
  881. } else if ($param["source"] == 2) {
  882. $detailIds = array_column($param["details"], "id");
  883. $where = [];
  884. $where[] = ["id", "in", $detailIds];
  885. $detailList = \app\common\model\TalentAllowancecontractDetail::where($where)->select()->toArray();
  886. $set = [];
  887. if ($params["resAllowanceType"] == 1) {
  888. $monthsMap = [];
  889. for ($i = 0; $i < count($param["details"]); $i++) {
  890. $monthsMap[$param["details"][$i]["id"]] = $param["details"][$i]["months"];
  891. }
  892. foreach ($detailList as &$detail) {
  893. $months = $monthdsMap[$detail["id"]];
  894. if (\StrUtil::isNotEmpAndNull($months)) {
  895. $detail["months"] = $months;
  896. $set = array_merge($set, explode(",", $months));
  897. }
  898. }unset($detail);
  899. }
  900. $set = array_filter($set);
  901. usort($set, function($a, $b) {
  902. return (int) $a - (int) $b;
  903. });
  904. $old["recommendAllowanceType"] = $param["resAllowanceType"];
  905. $old["recommendMonths"] = implode(",", $set);
  906. $typeName = "人工判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["recommendAllowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  907. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $obj["resAllowanceMsg"] . ";";
  908. $arrangeList = $this->calculateAllowance($old, $set, $detailList);
  909. }
  910. $desc .= "判定结果:" . $typeName;
  911. $data["checkState"] = 30;
  912. $data["outMsg"] = "";
  913. $data["allowanceType"] = $old["recommendAllowanceType"];
  914. $data["allowanceMsg"] = $old["recommendAllowanceMsg"];
  915. $data["months"] = $old["recommendMonths"];
  916. $data["money"] = $old["recommendMoney"];
  917. $data["moneyDesc"] = $old["recommendMoneyDesc"];
  918. $data["jtTalentArrange"] = $old["recommendTalentArrange"];
  919. $data["workAllowanceMoney"] = $old["workAllowanceMoney"];
  920. $data["developAllowanceMoney"] = $old["developAllowanceMoney"];
  921. } else {
  922. $data["checkState"] = -1;
  923. $data["outMsg"] = $param["zxMsg"];
  924. $data["allowanceType"] = 3;
  925. $data["allowanceMsg"] = "征信失信(不予兑现),原因:" . $param["zxMsg"];
  926. }
  927. }
  928. if ($param["allowanceType"] == 3) {
  929. $data["months"] = "";
  930. $data["money"] = 0;
  931. $data["moneyDesc"] = "";
  932. $data["jtTalentArrange"] = "";
  933. $data["workAllowanceMoney"] = null;
  934. $data["developAllowanceMoney"] = null;
  935. }
  936. $data["isPublicCheck"] = 1;
  937. $data["publicState"] = 4;
  938. //添加日志
  939. TalentChecklog::create([
  940. 'id' => getStringId(),
  941. 'mainId' => $old['id'],
  942. 'type' => intval(ProjectState::JBT),
  943. 'typeFileId' => null,
  944. 'active' => 1,
  945. 'state' => $param["checkState"] == AllowanceStateEnum::REVIEW_PASS ? 3 : $param["checkState"],
  946. 'step' => 6,
  947. 'stateChange' => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>",
  948. 'description' => $desc,
  949. 'createTime' => date("Y-m-d H:i:s", time()),
  950. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  951. ]);
  952. TaModel::update($data);
  953. if ($arrangeList != null) {
  954. $taaModel = new TalentAllowanceArrange();
  955. $taaModel->saveAll($arrangeList);
  956. }
  957. return new Response(Response::SUCCESS, "审核成功");
  958. } catch (\think\Exception $e) {
  959. return new Response(Response::ERROR, "系统异常,请联系管理员");
  960. }
  961. }
  962. /**
  963. * 批量公示通过
  964. */
  965. public function publicPass() {
  966. $ids = $this->request["ids"];
  967. $ids = explode(",", $ids);
  968. if (!$ids) {
  969. return new Response(Response::ERROR, "请至少选择一行数据");
  970. }
  971. $where = [];
  972. $where[] = ["id", "in", $ids];
  973. $list = TaModel::where($where)->select()->toArray();
  974. $logList = [];
  975. try {
  976. Db::startTrans();
  977. for ($i = 0; $i < count($list); $i++) {
  978. $obj = $list[$i];
  979. $upd["id"] = $obj["id"];
  980. $upd["publicState"] = 4;
  981. $upd["allowanceType"] = $obj["recommendAllowanceType"];
  982. $upd["allowanceMsg"] = $obj["recommendAllowanceMsg"];
  983. if ($upd["allowanceType"] == 1) {
  984. $upd["months"] = $obj["recommendMonths"];
  985. $upd["money"] = $obj["recommendMoney"];
  986. $upd["moneyDesc"] = $obj["recommendMoneyDesc"];
  987. } else if ($upd["allowanceType"] == 2) {
  988. $upd["months"] = "";
  989. $upd["jtTalentArrange"] = $obj["recommendTalentArrange"];
  990. $upd["money"] = $obj["recommendMoney"];
  991. $upd["moneyDesc"] = $obj["recommendMoneyDesc"];
  992. $upd["workAllowanceMoney"] = null;
  993. $upd["developAllowanceMoney"] = null;
  994. } else {
  995. $upd["months"] = "";
  996. $upd["money"] = 0.00;
  997. $upd["workAllowanceMoney"] = null;
  998. $upd["developAllowanceMoney"] = null;
  999. }
  1000. Db::table("un_talent_allowance_info")->update($upd);
  1001. //添加日志
  1002. $stateChange = null;
  1003. $desc = null;
  1004. if ($obj["checkState"] == AllowanceStateEnum::NOTPASS) {
  1005. $stateChange = "<span class='label label-success'>公示中</span>-><span class='label label-danger'>审核不通过</span>";
  1006. $desc = "审核不通过";
  1007. } else {
  1008. $stateChange = "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1009. $desc = "批量公示";
  1010. }
  1011. $logList[] = [
  1012. "id" => getStringId(),
  1013. "type" => ProjectState::JBT,
  1014. "mainId" => $obj["id"],
  1015. "active" => 1,
  1016. "state" => 3,
  1017. "step" => 6,
  1018. "stateChange" => $stateChange,
  1019. "description" => $desc,
  1020. "createTime" => date("Y-m-d H:i:s"),
  1021. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1022. ];
  1023. }
  1024. Db::table("new_talent_checklog")->insertAll($logList);
  1025. Db::commit();
  1026. return new Response(Response::SUCCESS, "批量公示通过成功");
  1027. } catch (\think\db\exception\DbException $e) {
  1028. Db::rollback();
  1029. return new Response(Response::ERROR, "批量公示失败:" . $e->getCode());
  1030. }
  1031. }
  1032. /**
  1033. * 兑现
  1034. */
  1035. public function cash() {
  1036. $ids = $this->request["ids"];
  1037. $ids = array_filter(explode(",", $ids));
  1038. if (!$ids) {
  1039. return new Response(Response::ERROR, "请至少选择一行数据");
  1040. }
  1041. $where = [];
  1042. $where[] = ["id", "in", $ids];
  1043. $list = TaModel::where($where)->select()->toArray();
  1044. //添加日志
  1045. $logList = [];
  1046. try {
  1047. Db::startTrans();
  1048. for ($i = 0; $i < count($list); $i++) {
  1049. $obj = $list[$i];
  1050. $upd["id"] = $obj["id"];
  1051. $upd["publicState"] = 5;
  1052. Db::table("un_talent_allowance_info")->update($upd);
  1053. $logList[] = [
  1054. "id" => getStringId(),
  1055. "type" => ProjectState::JBT,
  1056. "mainId" => $obj["id"],
  1057. "active" => 1,
  1058. "state" => 3,
  1059. "step" => 50,
  1060. "stateChange" => "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>;",
  1061. "description" => "批量兑现",
  1062. "createTime" => date("Y-m-d H:i:s"),
  1063. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1064. ];
  1065. }
  1066. Db::table("new_talent_checklog")->insertAll($logList);
  1067. Db::commit();
  1068. return new Response(Response::SUCCESS, "批量兑现成功");
  1069. } catch (\think\db\exception\DbException $e) {
  1070. Db::rollback();
  1071. return new Response(Response::ERROR, "批量兑现失败:" . $e->getCode());
  1072. }
  1073. }
  1074. /**
  1075. * 公示预览(不予兑现)
  1076. */
  1077. public function exportPublicNotCash() {
  1078. $response = new \stdClass();
  1079. $response->code = 500;
  1080. //获取字典表人才层次+
  1081. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1082. $streetMap = DictApi::selectByParentCode("street");
  1083. //查询企业信息
  1084. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1085. //查询所有
  1086. $where = [];
  1087. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  1088. $list = TaModel::where($where)->select()->toArray();
  1089. $rows = [];
  1090. for ($i = 0; $i < count($list); $i++) {
  1091. $item = $list[$i];
  1092. $rows[] = [
  1093. $i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
  1094. ];
  1095. }
  1096. $filename = CommonConst::getTypeName($this->user["type"]) . $allList[0]["year"] . "年度津补贴不予兑现对象名单";
  1097. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
  1098. if ($rows) {
  1099. export($columns, $rows, $filename);
  1100. exit();
  1101. } else {
  1102. $response->msg = "没有选择导出的名单";
  1103. return \StrUtil::back($response, "TalentTypeChange.callBack");
  1104. }
  1105. }
  1106. /**
  1107. * 导出公示名单(需要兑现)
  1108. */
  1109. public function exportPublic() {
  1110. //获取字典表人才层次+
  1111. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1112. $streetMap = DictApi::selectByParentCode("street");
  1113. //查询企业信息
  1114. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1115. /* * 查询需要公示的数据 */
  1116. $where = [];
  1117. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  1118. $list = TaModel::where($where)->select()->toArray();
  1119. /* * 查询相关的津补贴人才层次 */
  1120. $where = [];
  1121. $where[] = ["mainId", "in", explode(",", $this->request["ids"])];
  1122. $arrangeList = TalentAllowanceArrange::where($where)->select()->toArray();
  1123. foreach ($arrangeList as &$arrange) {
  1124. $arrange["talentArrangeName"] = $levelMap[$arrange["talentArrange"]];
  1125. }unset($arrange);
  1126. /* Map<String,List<TalentAllowanceArrange>> arrangeMap = arrangeList.stream().collect(Collectors.groupingBy(TalentAllowanceArrange::getMainId));
  1127. Integer sheetSize = 0;
  1128. for(TalentAllowanceInfo info:allList){
  1129. info.setEnterpriseName(enterpriseMap.get(info.getEnterpriseId()));
  1130. info.setAddressName(streetMap.get(info.getAddress()));
  1131. info.setTalentArrangeName(levelMap.get(info.getTalentArrange()));
  1132. if(info.getRecommendAllowanceType() == 1){
  1133. info.setArrangeList(arrangeMap.get(info.getId()));
  1134. sheetSize = sheetSize + info.getArrangeList().size();
  1135. }else if(info.getRecommendAllowanceType() == 1){
  1136. sheetSize++;
  1137. }
  1138. } */
  1139. $filename = CommonConst::getTypeName($this->user["type"]) . $list[0]["year"] . "年度津补贴拟发放对象名单";
  1140. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "津补贴享受月份数", "每月享受津贴标准(元)", $list[0]["year"] . "年度累计应享受津补贴金额(元)", "备注"];
  1141. }
  1142. /**
  1143. * 导出基本信息
  1144. */
  1145. public function exportBasicInfo() {
  1146. $obj["year"] = \StrUtil::getRequestDecodeParam($this->request, "year");
  1147. $obj["enterpriseName"] = \StrUtil::getRequestDecodeParam($this->request, "enterpriseName");
  1148. $obj["name"] = \StrUtil::getRequestDecodeParam($this->request, "name");
  1149. $obj["idCard"] = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  1150. $obj["talentType"] = \StrUtil::getRequestDecodeParam($this->request, "talentType");
  1151. $obj["talentArrange"] = \StrUtil::getRequestDecodeParam($this->request, "talentArrange");
  1152. $obj["address"] = \StrUtil::getRequestDecodeParam($this->request, "address");
  1153. $obj["identifyCondition"] = \StrUtil::getRequestDecodeParam($this->request, "identifyCondition");
  1154. $obj["isSupple"] = \StrUtil::getRequestDecodeParam($this->request, "isSupple");
  1155. $obj["checkState"] = \StrUtil::getRequestDecodeParam($this->request, "checkState");
  1156. $obj["publicState"] = \StrUtil::getRequestDecodeParam($this->request, "publicState");
  1157. $obj["companyName"] = \StrUtil::getRequestDecodeParam($this->request, "companyName");
  1158. $obj["allowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "allowanceType");
  1159. $obj["recommendAllowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "recommendAllowanceType");
  1160. $obj["introductionMode"] = \StrUtil::getRequestDecodeParam($this->request, "introductionMode");
  1161. $obj["firstJJStartTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJStartTime");
  1162. $obj["firstJJEndTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJEndTime");
  1163. $obj["process"] = intval(\StrUtil::getRequestDecodeParam($this->request, "process"));
  1164. $obj["type"] = $this->user["type"];
  1165. $where = [];
  1166. $where[] = ["ta.delete", "=", 0];
  1167. $where[] = ["ta.type", "=", $this->user["type"]];
  1168. $this->setTalentAllowanceInfoForExport($where, $obj, $obj["process"]);
  1169. switch ($obj["process"]) {
  1170. case 1:
  1171. $where[] = ["ta.checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  1172. break;
  1173. case 2:
  1174. $where[] = ["ta.firstPassTime", "EXP", Db::raw("is not null")];
  1175. break;
  1176. case 3:
  1177. $where[] = ["ta.visitPassTime", "EXP", Db::raw("is not null")];
  1178. break;
  1179. case 4:
  1180. if ($obj["publicState"]) {
  1181. $where[] = ["publicState", "=", $param["publicState"]];
  1182. }
  1183. $where[] = ["ta.checkState", "in", [-1, 30]];
  1184. break;
  1185. }
  1186. $projects = [
  1187. AllowanceProjectEnum::PROJECT_TAX,
  1188. AllowanceProjectEnum::PROJECT_WAGES,
  1189. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  1190. AllowanceProjectEnum::PROJECT_SB_PENSION,
  1191. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  1192. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  1193. ];
  1194. $months = [];
  1195. for ($m = 1; $m <= 12; $m++) {
  1196. $months[] = $m . "月";
  1197. }
  1198. $columns = [["年度", [1, 2]], ["所属镇街", [1, 2]], ["姓名", [1, 2]], ["性别", [1, 2]], ["证件号码", [1, 2]], ["人才层次", [1, 2]], ["认定条件", [1, 2]], ["认定条件取得时间", [1, 2]], ["认定条件名称", [1, 2]], ["公布入选月份", [1, 2]], ["拟认定津补贴类型", [1, 2]], ["拟兑现月份", [1, 2]], ["拟兑现金额", [1, 2]], ["拟兑现金额说明", [1, 2]], ["津补贴类型", [1, 2]], ["兑现月份", [1, 2]], ["兑现金额", [1, 2]], ["金额说明", [1, 2]], ["审核状态", [1, 2]], ["缴纳单位", [1, 2]]];
  1199. $infoCols = count($columns);
  1200. for ($i = 0; $i < count($projects); $i++) {
  1201. $columns[] = [AllowanceProjectEnum::getProjectName($projects[$i]), $months];
  1202. }
  1203. $list = \app\common\model\TalentAllowanceProject::alias("pro")
  1204. ->field("ta.id,ta.year,ta.enterpriseId as curEnterpriseId,ta.address,ta.name,ta.sex,ta.idCard,ta.talentArrange,ta.identifyCondition,ta.identifyGetTime,ta.identifyConditionName,ta.identifyMonth,ta.recommendAllowanceType,ta.recommendMonths,ta.recommendMoney,ta.recommendMoneyDesc,ta.allowanceType,ta.months,ta.money,ta.moneyDesc,ta.checkState,ta.publicState,pro.project,pro.months as pre_months,con.enterpriseId,con.startTime,con.endTime,con.entryTime,con.quitTime,con.isQuit")
  1205. ->leftJoin("un_talent_allowance_info ta", "ta.id=pro.mainId")
  1206. ->leftJoin("un_talent_allowancecontract_detail con", "pro.baseId=con.id")
  1207. ->where($where)
  1208. ->order("ta.year desc,ta.createTime desc,pro.project asc")
  1209. ->select()->toArray();
  1210. $tmpList = [];
  1211. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1212. $streetMap = DictApi::selectByParentCode("street");
  1213. $where = [];
  1214. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  1215. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1216. $where = [];
  1217. $where[] = ["id", "in", array_column($list, "enterpriseId")];
  1218. $enterpriseMap = \app\common\model\Enterprise::where($where)->column("name", "id");
  1219. foreach ($list as $item) {
  1220. //组装数据
  1221. if (!$tmpList[$item["id"]]) {
  1222. $tmpList[$item["id"]]["curEnterpriseId"] = $item["curEnterpriseId"];
  1223. $tmpList[$item["id"]]["info"] = [$item["year"], $streetMap[$item["address"]], $item["name"], $item["sex"] == 1 ? "男" : "女", $item["idCard"], $levelMap[$item["talentArrange"]],
  1224. $icmap[$item["identifyCondition"]], $item["identifyGetTime"], $item["identifyConditionName"], $item["identifyMonth"], AllowanceTypeEnum::getTypeName($item["recommendAllowanceType"]), $item["recommendMonths"], $item["recommendMoney"],
  1225. $item["recommendMoneyDesc"], AllowanceTypeEnum::getTypeName($item["allowanceType"]), $item["months"], $item["money"],
  1226. $item["moneyDesc"], $this->getCheckStateName($item["checkState"], $item["publicState"], $item["allowanceType"])];
  1227. }
  1228. if (!$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]) {
  1229. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]] = [
  1230. "startTime" => $item["startTime"],
  1231. "endTime" => $item["endTime"],
  1232. "entryTime" => $item["entryTime"],
  1233. "isQuit" => $item["isQuit"]
  1234. ];
  1235. }
  1236. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]["projects"][$item["project"]] = $item["pre_months"];
  1237. }
  1238. $rows = [];
  1239. $colorset = [];
  1240. foreach ($tmpList as $id => $item) {
  1241. foreach ($item["enterprise"] as $enterpriseId => $enterprise) {
  1242. $row = $item["info"];
  1243. $row[] = $this->user["uid"] == $enterpriseId ? "本单位" : $enterpriseMap[$enterpriseId];
  1244. for ($i = 0; $i < count($projects); $i++) {
  1245. if (strpos($enterprise["projects"][$projects[$i]], "=") === false) {
  1246. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1247. for ($m = 1; $m <= 12; $m++) {
  1248. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1249. if (in_array($_month, $months)) {
  1250. $row[] = "✔";
  1251. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1252. } else {
  1253. $row[] = "";
  1254. }
  1255. }
  1256. } else {
  1257. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1258. $_months = [];
  1259. foreach ($months as $month) {
  1260. $kv = explode("=", $month);
  1261. $_months[$kv[0]] = $kv[1];
  1262. }
  1263. for ($m = 1; $m <= 12; $m++) {
  1264. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1265. $days = $_months[$_month];
  1266. if ($days && $days > 0) {
  1267. $row[] = $days . "天";
  1268. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1269. } else {
  1270. $row[] = "";
  1271. }
  1272. }
  1273. }
  1274. }
  1275. $rows[] = $row;
  1276. }
  1277. }
  1278. $cols = $infoCols + count($projects) * 12 - 1;
  1279. $settings = [
  1280. "width" => [["A", 8], ["C", 12], ["D", 6], ["E", 20], ["F", 12], ["G", 70], ["H", 12], ["I", 15], ["J", 12], ["K", 12], ["P", 30]],
  1281. "height" => [18],
  1282. "freeze" => "D3",
  1283. "color" => $colorset
  1284. ];
  1285. for ($i = 0; $i < count($projects) * 12; $i++) {
  1286. $settings["width"][] = [getExcelColumnByIndex($infoCols + $i), 6]; //批设置项目的宽度
  1287. }
  1288. $settings["background-color"][] = [sprintf("%s2:%s2", getExcelColumnByIndex($infoCols), getExcelColumnByIndex($cols)), "E1F1DE"];
  1289. export($columns, $rows, "津补贴申报名单", $settings);
  1290. }
  1291. /**
  1292. * 校验是否在审核范围内
  1293. */
  1294. public function validateIsCheck() {
  1295. $id = $this->request["id"];
  1296. $process = $this->request["process"];
  1297. $compnayId = $this->request["companyId"];
  1298. $old = HouseApi::getInfoById($id);
  1299. $checkState = $old["checkState"];
  1300. $res = null;
  1301. switch ($process) {
  1302. case 1:
  1303. if ($checkState != HouseStateEnum::NEED_CHECK && $checkState != HouseStateEnum::REJECT_TO_FIRST && $checkState != HouseStateEnum::DEP_REJECT) {
  1304. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1305. } else {
  1306. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1307. if ($log) {
  1308. $old["checkState"] = $log["state"];
  1309. $old["checkMsg"] = $log["description"];
  1310. } else {
  1311. $old["checkState"] = null;
  1312. $old["checkMsg"] = "";
  1313. }
  1314. }
  1315. break;
  1316. case 2:
  1317. if ($checkState != HouseStateEnum::NEED_DEP_CHECK && $checkState != HouseStateEnum::REJECT_TO_DEP) {
  1318. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1319. } else {
  1320. $where = [];
  1321. $where[] = ["mainId", "=", $id];
  1322. $where[] = ["companyId", "=", $compnayId];
  1323. $where[] = ["type", "=", ProjectState::HOUSE];
  1324. $depcheckstate = Db::table("un_talent_depcheckstate")->where($where)->find();
  1325. if ($depcheckstate["state"] != 1 && $depcheckstate["state"] != 4 && $depcheckstate["state"] != 9) {
  1326. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1327. } else {
  1328. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2, $compnayId);
  1329. if ($log) {
  1330. $old["checkState"] = $log["state"];
  1331. $old["checkMsg"] = $log["description"];
  1332. } else {
  1333. $old["checkState"] = null;
  1334. $old["checkMsg"] = "";
  1335. }
  1336. $res["company"] = getCacheById("Company", $compnayId);
  1337. }
  1338. }
  1339. break;
  1340. case 3:
  1341. if ($checkState != HouseStateEnum::NEED_REVIEW_CHECK && $checkState != HouseStateEnum::REJECT_TO_REVIEW) {
  1342. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1343. } else {
  1344. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1345. if ($log) {
  1346. $old["checkState"] = $log["state"];
  1347. $old["checkMsg"] = $log["description"];
  1348. } else {
  1349. $old["checkState"] = null;
  1350. $old["checkMsg"] = "";
  1351. }
  1352. }
  1353. break;
  1354. case 4:
  1355. if ($checkState != HouseStateEnum::REVIEW_PASS && $checkState != HouseStateEnum::NOTPASS) {
  1356. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1357. } else if ($old["publicState"] != 2) {
  1358. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1359. } else {
  1360. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1361. if ($log) {
  1362. $old["checkState"] = $log["state"];
  1363. $old["checkMsg"] = $log["description"];
  1364. } else {
  1365. $old["checkState"] = null;
  1366. $old["checkMsg"] = "";
  1367. }
  1368. $res = $this->calculate($old, 1);
  1369. if ($res->code == 500) {
  1370. return $res;
  1371. }
  1372. $res["housepurchase"] = $res->obj;
  1373. }
  1374. break;
  1375. }
  1376. $where = [];
  1377. $where[] = ["type", "=", $old["type"]];
  1378. $where[] = ["project", "=", ProjectState::HOUSE];
  1379. $where[] = ["active", "=", 1];
  1380. $where[] = ["delete", "=", 0];
  1381. $filetypeList = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1382. /* * 查询之前是否享受过 */
  1383. $count = HouseApi::getEnjoyTimesByIdCard($old["idCard"]);
  1384. $res["number"] = $count;
  1385. $res["obj"] = $old;
  1386. $res["fileTypeList"] = $filetypeList;
  1387. return new Response(Response::SUCCESS, "", $res);
  1388. }
  1389. /**
  1390. * 初始化可修改的项目/附件/合同
  1391. * */
  1392. public function findFieldsAndFiles() {
  1393. $id = $this->request["id"];
  1394. if (\StrUtil::isEmpOrNull($id)) {
  1395. return new Response(Response::ERROR, "请选择需要修改的对象");
  1396. }
  1397. $info = HouseApi::getInfoById($id);
  1398. if (!$info) {
  1399. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1400. }
  1401. if ($info["checkState"] != HouseStateEnum::FIRST_REJECT) {
  1402. return new Response(Response::ERROR, "只能修改初审驳回的数据");
  1403. }
  1404. $res = [];
  1405. $where = [];
  1406. $where[] = ["type", "=", $info["type"]];
  1407. $where[] = ["project", "=", ProjectState::HOUSE];
  1408. $where[] = ["active", "=", 1];
  1409. $where[] = ["delete", "=", 0];
  1410. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1411. $res["files"] = $filetypes;
  1412. $res["obj"] = $info;
  1413. return new Response(Response::SUCCESS, "", $res);
  1414. }
  1415. /**
  1416. * 修改驳回项目/附件/合同
  1417. * */
  1418. public function updateFieldsAndFiles() {
  1419. $data = $this->request->param();
  1420. if (!$data["id"]) {
  1421. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1422. }
  1423. houseModel::update($data);
  1424. return new Response(Response::SUCCESS, "修改成功");
  1425. }
  1426. private function setCondition(&$where, &$query) {
  1427. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1428. $where[] = ["year", "=", $query["year"]];
  1429. }
  1430. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1431. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  1432. }
  1433. if (\StrUtil::isNotEmpAndNull($query["idCard"])) {
  1434. $where[] = ["idCard", "like", "%" . $query["idCard"] . "%"];
  1435. }
  1436. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1437. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  1438. }
  1439. if (\StrUtil::isNotEmpAndNull($query["spouseName"])) {
  1440. $where[] = ["spouseName", "like", "%" . $query["spouseName"] . "%"];
  1441. }
  1442. if (\StrUtil::isNotEmpAndNull($query["spouseIdcard"])) {
  1443. $where[] = ["spouseIdcard", "like", "%" . $query["spouseIdcard"] . "%"];
  1444. }
  1445. if (\StrUtil::isNotEmpAndNull($query["childName"])) {
  1446. $where[] = ["childName", "like", "%" . $query["childName"] . "%"];
  1447. }
  1448. if (\StrUtil::isNotEmpAndNull($query["childIdCard"])) {
  1449. $where[] = ["childIdCard", "like", "%" . $query["childIdCard"] . "%"];
  1450. }
  1451. if (\StrUtil::isNotEmpAndNull($query["marryStatus"])) {
  1452. $where[] = ["marryStatus", "=", $query["marryStatus"]];
  1453. }
  1454. if ($query["isConflict"]) {
  1455. $where[] = ["isConflict", "=", $query["isConflict"]];
  1456. }
  1457. if ($query["isRecover"]) {
  1458. $where[] = ["isRecover", "=", $query["isRecover"]];
  1459. }
  1460. if ($query["checkState"]) {
  1461. switch ($query["checkState"]) {
  1462. case -1:
  1463. $where[] = ["checkState", "=", HouseStateEnum::NOTPASS];
  1464. break;
  1465. case 1:
  1466. $where[] = ["checkState", "=", HouseStateEnum::SAVE];
  1467. break;
  1468. case 2:
  1469. switch ($query["process"]) {
  1470. case 1:
  1471. $where[] = ["checkState", "=", HouseStateEnum::NEED_CHECK];
  1472. $where[] = ["highProcess", "<", $query["process"]];
  1473. break;
  1474. case 2:
  1475. $query["state"] = 1;
  1476. break;
  1477. case 3:
  1478. $where[] = ["checkState", "=", HouseStateEnum::NEED_REVIEW_CHECK];
  1479. $where[] = ["highProcess", "<", $query["process"]];
  1480. break;
  1481. }
  1482. break;
  1483. case 3:
  1484. switch ($query["process"]) {
  1485. case 1:
  1486. $where[] = ["checkState", "=", HouseStateEnum::FIRST_REJECT];
  1487. break;
  1488. case 2:
  1489. $query["state"] = 2;
  1490. break;
  1491. case 3:
  1492. $where[] = ["checkState", "<=", HouseStateEnum::REJECT_TO_DEP];
  1493. break;
  1494. }
  1495. break;
  1496. case 4:
  1497. switch ($query["process"]) {
  1498. case 1:
  1499. $where[] = ["checkState", "in", [HouseStateEnum::NEED_DEP_CHECK, HouseStateEnum::REJECT_TO_DEP, HouseStateEnum::NEED_REVIEW_CHECK, HouseStateEnum::REVIEW_PASS]];
  1500. break;
  1501. case 2:
  1502. $query["state"] = 3;
  1503. break;
  1504. case 3:
  1505. case 4:
  1506. $where[] = ["checkState", "=", HouseStateEnum::REVIEW_PASS];
  1507. break;
  1508. }
  1509. break;
  1510. case 5:
  1511. switch ($query["process"]) {
  1512. case 1:
  1513. $where[] = ["checkState", "in", [HouseStateEnum::REJECT_TO_FIRST, HouseStateEnum::DEP_REJECT]];
  1514. break;
  1515. case 2:
  1516. $query["state"] = 4;
  1517. break;
  1518. case 3:
  1519. $where[] = ["checkState", "=", HouseStateEnum::REJECT_TO_REVIEW];
  1520. break;
  1521. }
  1522. break;
  1523. case 6:
  1524. switch ($query["process"]) {
  1525. case 1:
  1526. $where[] = ["checkState", "=", HouseStateEnum::NEED_CHECK];
  1527. $where[] = ["highProcess", ">=", $query["process"]];
  1528. break;
  1529. case 2:
  1530. $query["state"] = 9;
  1531. break;
  1532. case 3:
  1533. $where[] = ["checkState", "=", HouseStateEnum::NEED_REVIEW_CHECK];
  1534. $where[] = ["highProcess", ">=", $query["process"]];
  1535. break;
  1536. }
  1537. break;
  1538. }
  1539. }
  1540. }
  1541. private function translateToChinese(&$obj) {
  1542. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  1543. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  1544. }
  1545. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  1546. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  1547. }
  1548. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  1549. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  1550. }
  1551. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  1552. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  1553. }
  1554. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  1555. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  1556. }
  1557. }
  1558. private function translateChinese($list, $process) {
  1559. //获取字典表
  1560. $marryMap = DictApi::selectByParentCode("marry_status");
  1561. $cardTypeMap = DictApi::selectByParentCode("card_type");
  1562. $streetMap = DictApi::selectByParentCode("street");
  1563. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1564. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1565. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1566. $where = [];
  1567. $where[] = ["type", "=", $this->user["type"]];
  1568. $conditionMap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1569. $where = [];
  1570. $where[] = ["pId", "in", array_column($list, "id")];
  1571. $childrens = \app\common\model\HousePurchaseChildren::where($where)->select()->toArray();
  1572. $childMap = [];
  1573. foreach ($childrens as $child) {
  1574. $childMap[$child["pId"]][] = $child;
  1575. }
  1576. foreach ($list as &$info) {
  1577. $info["marryStatusName"] = $marryMap[$info["marryStatus"]];
  1578. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  1579. $info["spouseCardTypeName"] = $cardTypeMap[$info["spouseCardType"]];
  1580. $info["childCardTypeName"] = $cardTypeMap[$info["childCardType"]];
  1581. $info["streetName"] = $streetMap[$info["street"]];
  1582. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  1583. $info["identifyConditionCH"] = $conditionMap[$info["identifyCondition"]];
  1584. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  1585. $info["declareTypeName"] = $info["declareType"] == 1 ? "购房补贴" : "免租入住";
  1586. $info["enterpriseName"] = $enterpriseMap[$info["enterpriseId"]];
  1587. $info["isEnjoyOtherName"] = $info["isEnjoyOther"] == 1 ? "是" : "否";
  1588. $info["spouseIsLibraryName"] = $info["spouseIsLibrary"] == 1 ? "是" : "否";
  1589. $childs = $childMap[$info["id"]];
  1590. $childStr = "";
  1591. if ($childs) {
  1592. for ($i = 0; $i < count($childs); $i++) {
  1593. $childStr .= $childs[$i]["name"] . "-" . $childs[$i]["idCard"] . ";";
  1594. }
  1595. }
  1596. $info["childs"] = $childStr;
  1597. switch ($process) {
  1598. case 1:
  1599. if ($info["checkState"] == HouseStateEnum::NOTPASS) {
  1600. $info["checkStateName"] = "审核不通过";
  1601. }
  1602. if ($info["checkState"] == HouseStateEnum::SAVE) {
  1603. $info["checkStateName"] = "待提交";
  1604. }
  1605. if ($info["checkState"] == HouseStateEnum::NEED_CHECK) {
  1606. $info["checkStateName"] = $info["highProcess"] != null && $info["highProcess"] >= $process ? "重新提交" : "待审核";
  1607. }
  1608. if ($info["checkState"] == HouseStateEnum::FIRST_REJECT) {
  1609. $info["checkStateName"] = "已驳回";
  1610. }
  1611. if ($info["checkState"] == HouseStateEnum::REJECT_TO_FIRST || $info["checkState"] == HouseStateEnum::DEP_REJECT) {
  1612. $info["checkStateName"] = "上级驳回";
  1613. }
  1614. if ($info["checkState"] == HouseStateEnum::NEED_DEP_CHECK || $info["checkState"] >= HouseStateEnum::REJECT_TO_DEP) {
  1615. $info["checkStateName"] = "已通过";
  1616. }
  1617. break;
  1618. case 2:
  1619. if ($info["state"] == 1) {
  1620. $info["checkStateName"] = "待审核";
  1621. }
  1622. if ($info["state"] == 2) {
  1623. $info["checkStateName"] = "已驳回";
  1624. }
  1625. if ($info["state"] == 3) {
  1626. $info["checkStateName"] = "已通过";
  1627. }
  1628. if ($info["state"] == 4) {
  1629. $info["checkStateName"] = "上级驳回";
  1630. }
  1631. if ($info["state"] == 9) {
  1632. $info["checkStateName"] = "重新提交";
  1633. }
  1634. break;
  1635. case 3:
  1636. if ($info["checkState"] <= HouseStateEnum::REJECT_TO_DEP) {
  1637. $info["checkStateName"] = "已驳回";
  1638. } else if ($info["checkState"] == HouseStateEnum::NEED_REVIEW_CHECK) {
  1639. $info["checkStateName"] = $info["highProcess"] != null && $info["highProcess"] >= $process ? "重新提交" : "待审核";
  1640. } else if ($info["checkState"] == HouseStateEnum::REVIEW_PASS) {
  1641. $info["checkStateName"] = "已通过";
  1642. }
  1643. break;
  1644. case 4:
  1645. if ($info["checkState"] == HouseStateEnum::NOTPASS) {
  1646. $info["checkStateName"] = "审核不通过";
  1647. } else if ($info["checkState"] == HouseStateEnum::REVIEW_PASS) {
  1648. $info["checkStateName"] = "已通过";
  1649. }
  1650. break;
  1651. }
  1652. }unset($info);
  1653. return $list;
  1654. }
  1655. private function getCheckStateName($checkState, $publicState, $allowanceType) {
  1656. switch ($checkState) {
  1657. case 1:
  1658. return "待提交";
  1659. case 5:
  1660. case 13:
  1661. case 15:
  1662. case 20:
  1663. case 25:
  1664. case 35:
  1665. return "审核中";
  1666. case 10:
  1667. return "已驳回";
  1668. case - 1:
  1669. if ($publicState >= 3) {
  1670. return "审核不通过";
  1671. } else {
  1672. return "审核中";
  1673. }
  1674. break;
  1675. case 30:
  1676. if ($publicState == 1) {
  1677. return "待核查征信";
  1678. } else if ($publicState == 2) {
  1679. return "待公示";
  1680. } else if ($publicState == 3) {
  1681. return "公示中";
  1682. } else if ($publicState == 4) {
  1683. return $allowanceType != 3 ? "待兑现" : "不予兑现";
  1684. } else if ($publicState == 5) {
  1685. return "已兑现";
  1686. }
  1687. default:
  1688. return "未知状态";
  1689. }
  1690. }
  1691. /**
  1692. * @param old
  1693. * @param type 1-复核阶段,不生成享受人的剩余享受金额记录,2-公示再审核阶段,生成享受记录
  1694. * @description 计算购房补贴金额
  1695. * */
  1696. private function calculate($old, $type) {
  1697. $housepurchase = [];
  1698. $descideDesc = [];
  1699. $count = $old["type"] == 1 ? 5 : 3; //最大申报数
  1700. /* * 1、查询申报人和配偶的房产信息 */
  1701. $houseInfo = HouseApi::getHouseInfo($old["idCard"]);
  1702. $spouseHouseInfo = HouseApi::getHouseInfo($old["spouseIdCard"]);
  1703. if (!$houseInfo) {
  1704. $houseInfo = [
  1705. "idCard" => $old["idCard"],
  1706. "spouseIdCard" => null,
  1707. "houseAddress" => $old["houseAddress"],
  1708. "houseArea" => $old["houseArea"],
  1709. "houseMoney" => $old["houseMoney"],
  1710. "recordTime" => $old["recordTime"],
  1711. "realEstateNo" => $old["realEstateNo"],
  1712. "recordNo" => $old["recordNo"],
  1713. "balanceMoney" => $old["houseMoney"],
  1714. "count" => 0,
  1715. "lastYearArrears" => 0
  1716. ];
  1717. }
  1718. //判断是否超过五次申报
  1719. if ($houseInfo["count"] >= $count) {
  1720. return new Response(Response::ERROR, "申报人已享受五次购房补贴,无法再次享受");
  1721. }
  1722. if ($houseInfo["balanceMoney"] <= 0) {
  1723. return new Response(Response::ERROR, "申报房产可享受余额不足,无法享受");
  1724. }
  1725. /* * 2.查询购房补贴费用标准,根据人才层次计算可享受金额 */
  1726. $amountStandard = \app\common\api\AmountStandardApi::getStandard($this->user["type"], 3, $old["talentArrange"]);
  1727. if (!$amountStandard)
  1728. return new Response(Response::ERROR, "系统暂未设置该人才层次的购房补贴享受金额,请设置后再提交");
  1729. if ($old["type"] == 1) {
  1730. $housepurchase["talentArrangeMoney"] = round(0.2 * $amountStandard["money"], 2);
  1731. } else {
  1732. $code = "housepurchase_percentage_";
  1733. switch ($old["type"]) {
  1734. case CommonConst::ENTERPRISE_JC:
  1735. $code .= "ic";
  1736. break;
  1737. case CommonConst::ENTERPRISE_WJ:
  1738. $code .= "wj";
  1739. break;
  1740. case CommonConst::ENTERPRISE_GJ:
  1741. $code .= "gj";
  1742. break;
  1743. }
  1744. $dic = DictApi::findByParentCodeAndCode($code, $houseInfo["count"] + 1);
  1745. if (!$dic)
  1746. return new Response(Response::ERROR, "系统字典中暂未设置购房补贴年度比例,请设置后再提交。字典代码以[集成电路:housepurchase_percentage_ic][卫健:housepurchase_percentage_wj][高教:housepurchase_percentage_gj]为准");
  1747. if (!is_numeric($dic["name"]) || $dic["name"] > 1 || $dic["name"] < 0)
  1748. return new Response(Response::ERROR, "系统字典中设置的购房补贴年度比例应该是介于0~1之间的数字");
  1749. $housepurchase["talentArrangeMoney"] = round($dic["name"] * $amountStandard["money"], 2);
  1750. }
  1751. /* * 3.计算当年度录入享受其他政策的金额 */
  1752. $otherList = HouseApi::getEnjoyOtherList($old["id"]);
  1753. $housepurchase["nowOtherMoney"] = 0;
  1754. foreach ($otherList as $other) {
  1755. $housepurchase["nowOtherMoney"] += $other["money"];
  1756. }
  1757. $lastOtherMoney = $spouseHouseInfo ? $houseInfo["lastYearArrears"] + $spouseHouseInfo["lastYearArrears"] : $houseInfo["lastYearArrears"];
  1758. $housepurchase["lastOtherMoney"] = round($lastOtherMoney, 2);
  1759. $totalOtherMoney = round($housepurchase["nowOtherMoney"] + $housepurchase["lastOtherMoney"], 2);
  1760. /* * 计算当前人才层次可享受金额 */
  1761. $balanceMoney = round($amountStandard["money"] - ($houseInfo["houseMoney"] - $houseInfo["balanceMoney"]), 2);
  1762. /* * 判断余额 */
  1763. $balanceMoney = $balanceMoney >= $houseInfo["balanceMoney"] ? $houseInfo["balanceMoney"] : $balanceMoney;
  1764. if ($balanceMoney <= 0) {
  1765. $descideDesc[] = "可享受余额为:" . $balanceMoney . "元;";
  1766. /* * 判断享受其他政策是否大于0 */
  1767. if ($totalOtherMoney > 0) {
  1768. $housepurchase["isRecover"] = 1;
  1769. $descideDesc[] = "需要追讨金额为:" . $totalOtherMoney . "元;";
  1770. }
  1771. $housepurchase["shouldEnjoyMoney"] = 0;
  1772. $housepurchase["realEnjoyMoney"] = 0;
  1773. $housepurchase["nowSubOtherMoney"] = 0;
  1774. $housepurchase["nowNotSubOtherMoney"] = $totalOtherMoney;
  1775. } else {
  1776. /* * 比较余额和人才层次金额的20% */
  1777. $housepurchase["shouldEnjoyMoney"] = $balanceMoney >= $housepurchase["talentArrangeMoney"] ? $housepurchase["talentArrangeMoney"] : $balanceMoney;
  1778. /* * 计算可享受金额 */
  1779. $realEnjoyMoney = $housepurchase["shouldEnjoyMoney"] - $totalOtherMoney;
  1780. if ($realEnjoyMoney == 0) {
  1781. $housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
  1782. $housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
  1783. $housepurchase["nowNotSubOtherMoney"] = $realEnjoyMoney;
  1784. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
  1785. } else if ($realEnjoyMoney > 0) {
  1786. $housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
  1787. $housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
  1788. $housepurchase["nowNotSubOtherMoney"] = 0;
  1789. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
  1790. } else if ($realEnjoyMoney < 0) {
  1791. $housepurchase["isRecover"] = 1;
  1792. $descideDesc[] = "需要追讨金额为:" . abs($realEnjoyMoney) . "元;";
  1793. $housepurchase["realEnjoyMoney"] = 0;
  1794. $housepurchase["nowSubOtherMoney"] = $housepurchase["shouldEnjoyMoney"];
  1795. $housepurchase["nowNotSubOtherMoney"] = abs($realEnjoyMoney);
  1796. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录并生成新的未扣除记录 */
  1797. }
  1798. if ($type == 2) {
  1799. $houseInfo["count"] = $houseInfo["count"] + 1;
  1800. $houseInfo["balanceMoney"] = round($houseInfo["balanceMoney"] - $housepurchase["shouldEnjoyMoney"], 2);
  1801. $houseInfo["lastYearArrears"] = $housepurchase["nowSubOtherMoney"];
  1802. if (\StrUtil::isNotEmpAndNull($housepurchase["spouseIdcard"])) {
  1803. if (!$spouseHouseInfo) {
  1804. $spouseHouseInfo = [
  1805. "idCard" => $old["spouseIdcard"],
  1806. "spouseIdCard" => null,
  1807. "houseAddress" => $old["houseAddress"],
  1808. "houseArea" => $old["houseArea"],
  1809. "houseMoney" => $old["houseMoney"],
  1810. "recordTime" => $old["recordTime"],
  1811. "realEstateNo" => $old["realEstateNo"],
  1812. "recordNo" => $old["recordNo"],
  1813. "balanceMoney" => $houseInfo["balanceMoney"],
  1814. "count" => $houseInfo["count"],
  1815. "lastYearArrears" => $houseInfo["lastYearArrears"]
  1816. ];
  1817. } else {
  1818. $spouseHouseInfo["count"] = $spouseHouseInfo["count"] + 1;
  1819. $spouseHouseInfo["lastYearArrears"] = $houseInfo["lastYearArrears"];
  1820. $spouseHouseInfo["balanceMoney"] = $spouseHouseInfo["balanceMoney"] - $housepurchase["shouldEnjoyMoney"];
  1821. }
  1822. if ($spouseHouseInfo["id"]) {
  1823. $spouseHouseInfo["updateTime"] = date("Y-m-d H:i:s");
  1824. $spouseHouseInfo["updateUser"] = $this->user["uid"];
  1825. houseInfoModel::update($spouseHouseInfo);
  1826. } else {
  1827. $spouseHouseInfo["id"] = getStringId();
  1828. $spouseHouseInfo["createTime"] = date("Y-m-d H:i:s");
  1829. $spouseHouseInfo["createUser"] = $this->user["uid"];
  1830. houseInfoModel::insert($spouseHouseInfo);
  1831. }
  1832. }
  1833. if ($houseInfo["id"]) {
  1834. $houseInfo["updateTime"] = date("Y-m-d H:i:s");
  1835. $houseInfo["updateUser"] = $this->user["uid"];
  1836. houseInfoModel::update($houseInfo);
  1837. } else {
  1838. $houseInfo["id"] = getStringId();
  1839. $houseInfo["createTime"] = date("Y-m-d H:i:s");
  1840. $houseInfo["createUser"] = $this->user["uid"];
  1841. houseInfoModel::insert($houseInfo);
  1842. }
  1843. }
  1844. }
  1845. $housepurchase["decideDetail"] = implode("", $descideDesc);
  1846. return new Response(Response::SUCCESS, "", $housepurchase);
  1847. }
  1848. }