EnterpriseChangeRecord.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\CompanyApi;
  6. use app\common\api\DictApi;
  7. use app\common\api\EnterpriseApi;
  8. use app\common\api\TalentState;
  9. use app\common\model\MessageRecord;
  10. use app\common\model\TalentChecklog;
  11. class EnterpriseChangeRecord extends AdminController {
  12. public function gotoEnterpriseChangeRecordPage(){
  13. $talentTypeList = DictApi::findChildDictByCode("enterprise_tag");
  14. $industryFieldNewList = DictApi::findChildDictByCode("industry_field");
  15. $streetList = DictApi::findChildDictByCode("street");
  16. return view("",['enterprise_tag' => $talentTypeList,'industryFieldNew' => $industryFieldNewList,'street' => $streetList]);
  17. }
  18. public function findEnterpriseChangeRecordByPage(){
  19. $res = EnterpriseApi::getRecordList($this->request);
  20. return json($res);
  21. }
  22. public function gotoEnterpriseChangeDetailPage(){
  23. $id = trim($this->request['id']);
  24. if(!$id){
  25. return json(["msg" => 'ID不能为空!']);
  26. }
  27. $ecr = EnterpriseApi::getOneRecord($id);
  28. if (\StrUtil::isNotEmpAndNull($ecr['oldStreet']) || \StrUtil::isNotEmpAndNull($ecr['newStreet'])) {
  29. $streetList = DictApi::selectByParentCode("street");
  30. if (\StrUtil::isNotEmpAndNull($ecr['oldStreet'])) {
  31. $ecr['oldStreetName'] = $streetList[$ecr['oldStreet']];
  32. }
  33. if (\StrUtil::isNotEmpAndNull($ecr['newStreet'])) {
  34. $ecr['newStreetName'] = $streetList[$ecr['newStreet']];
  35. }
  36. }
  37. if (\StrUtil::isNotEmpAndNull($ecr['oldEnterpriseTag']) || \StrUtil::isNotEmpAndNull($ecr['newEnterpriseTag'])) {
  38. $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
  39. if (\StrUtil::isNotEmpAndNull($ecr['oldEnterpriseTag'])) {
  40. $ecr['oldEnterpriseTagName'] = $talentTypeList[$ecr['oldEnterpriseTag']];
  41. }
  42. if (\StrUtil::isNotEmpAndNull($ecr['newEnterpriseTag'])) {
  43. $ecr['newEnterpriseTagName'] = $talentTypeList[$ecr['newEnterpriseTag']];
  44. }
  45. }
  46. if (\StrUtil::isNotEmpAndNull($ecr['oldIndustryFieldNew']) || \StrUtil::isNotEmpAndNull($ecr['newIndustryFieldNew'])) {
  47. $industryFieldNewList = DictApi::selectByParentCode("industry_field");
  48. if (\StrUtil::isNotEmpAndNull($ecr['oldIndustryFieldNew'])) {
  49. $ecr['oldIndustryFieldNewName'] = $industryFieldNewList[$ecr['oldIndustryFieldNew']];
  50. }
  51. if (\StrUtil::isNotEmpAndNull($ecr['newIndustryFieldNew'])) {
  52. $ecr['newIndustryFieldNewName'] = $industryFieldNewList[$ecr['newIndustryFieldNew']];
  53. }
  54. }
  55. if (\StrUtil::isNotEmpAndNull($ecr['oldIndustryFieldOld'])) {
  56. $industry = DictApi::findDictByCode($ecr['oldIndustryFieldOld']);
  57. $ecr['oldIndustryFieldOldName'] = $industry['name'];
  58. }
  59. if (\StrUtil::isNotEmpAndNull($ecr['newIndustryFieldOld'])) {
  60. $industry = DictApi::findDictByCode($ecr['newIndustryFieldOld']);
  61. $ecr['newIndustryFieldOldName'] = $industry['name'];
  62. }
  63. switch ($ecr['checkState']){
  64. case 1:
  65. $ecr['checkStateName'] = '保存未提交';
  66. break;
  67. case 2:
  68. $ecr['checkStateName'] = '待审核';
  69. break;
  70. case 3:
  71. $ecr['checkStateName'] = '审核驳回';
  72. break;
  73. case 4:
  74. $ecr['checkStateName'] = '审核通过';
  75. break;
  76. case 5:
  77. $ecr['checkStateName'] = '重新提交';
  78. break;
  79. default:
  80. $ecr['checkStateName'] = '';
  81. break;
  82. }
  83. return view("",['ecr' => $ecr]);
  84. }
  85. public function gotoEnterpriseChangeExaminePage(){
  86. $id = trim($this->request['id']);
  87. if(!$id){
  88. return json(["msg" => 'ID不能为空!']);
  89. }
  90. $ecr = EnterpriseApi::getOneRecord($id);
  91. return view("",['ecr' => $ecr]);
  92. }
  93. public function doExamine(){
  94. $id = trim($this->request['id']);
  95. if(!$id){
  96. return json(["msg" => 'ID不能为空!','code' => 500]);
  97. }
  98. $ecr = EnterpriseApi::getOneRecord($id);
  99. if(!$ecr){
  100. return json(["msg" => '原始数据不存在!','code' => 500]);
  101. }
  102. $checkState = trim($this->request['checkState']);
  103. if ($checkState==null || ($checkState!=4 && $checkState!=3)) {
  104. return json(["msg" => '请选择审核状态!','code' => 500]);
  105. }
  106. $checkMsg = trim($this->request['checkMsg']);
  107. //如果审核状态为 审核驳回, 需要填写审核意见
  108. if ($checkState==3 && \StrUtil::isEmpOrNull($checkMsg)) {
  109. return json(["msg" => '审核驳回时,需要填写审核意见!','code' => 500]);
  110. }
  111. if (\StrUtil::isNotEmpAndNull($checkMsg) && strlen($checkMsg)>200) {
  112. return json(["msg" => '审核意见最多200个字符!','code' => 500]);
  113. }
  114. if ($ecr['checkState']!=2 && $ecr['checkState']!=3 && $ecr['checkState']!=5) {
  115. return json(["msg" => '不在审核范围内!','code' => 500]);
  116. }
  117. //如果为审核驳回,更新表中的审核状态 和 审核意见, 直接返回结果
  118. if ($checkState == 3) {
  119. $ecr->checkState = 3;
  120. $ecr->checkMsg = $checkMsg;
  121. $ecr->updateUser = session('user')['uid'];
  122. $ecr->updateTime = date("Y-m-d H:i:s");
  123. $ecr->save();
  124. //发送短信
  125. $record_data = [
  126. 'id' => getStringId(),
  127. 'bizId' => getStringId(),
  128. 'userId' => $ecr['mainId'],
  129. 'type' => 2,
  130. 'smsType' => 2,
  131. 'name' => $ecr['newName'],
  132. 'phone' => $ecr['newAgentPhone'],
  133. 'templateCode' => "【晋江市人才服务平台】您好!您提交申请的优秀人才{$checkMsg}因信息填写错误或上传不完整已被退回,请及时登录申报系统查看审核意见并重新提交。",
  134. 'params' => '企业信息变更',
  135. 'state' => 1,
  136. 'sendingDate' => date("Y-m-d H:i:s",time()),
  137. 'createTime' => date("Y-m-d H:i:s",time())
  138. ];
  139. $smsapi = new ChuanglanSmsApi();
  140. $result = $smsapi->sendSMS($ecr['newAgentPhone'],$record_data['templateCode']);
  141. MessageRecord::create($record_data);
  142. $company = CompanyApi::getOne(session('user')['companyId']);
  143. TalentChecklog::create([
  144. 'id' => getStringId(),
  145. 'mainId' => $ecr['id'],
  146. 'type' => 10,
  147. 'typeField' => null,
  148. 'active' => 1,
  149. 'state' => 2,
  150. 'step' => 101,
  151. 'stateChange' => "<span class='label label-info'>审核驳回</span>",
  152. 'description' => $checkMsg,
  153. 'createTime' => date("Y-m-d H:i:s",time()),
  154. 'createUser' => session('user')['name']."({$company['name']})"
  155. ]);
  156. return json(["msg" => '操作成功!',"code" => 200]);
  157. }
  158. }
  159. }