123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-10-29 16:16:29
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-11-09 16:21:40
- */
- namespace app\index\logic;
- use app\index\model\safenotemodel;
- use think\Log;
- class safenotelogic
- {
- /**
- * 新增信息
- * 20211127
- * wj
- */
- public function newinfo($info)
- {
- log::info($info);
- $fillField = ['Label', 'Suggestion', 'type', 'DataId'];
- $fillFieldNum = ['Score'];
- foreach ($fillField as $key => $value) {
- if (!isset($info[$value]) || empty($info[$value])) {
- return backarr(0, "请求错误");
- }
- }
- foreach ($fillFieldNum as $key => $value) {
- if (!isset($info[$value]) || !is_numeric($info[$value])) {
- return backarr(0, "请求错误");
- }
- }
- $label = $info['Label'];
- $suggestion = $info['Suggestion'];
- $score = $info['Score'];
- $type = $info['type'];
- $contentid = $info['DataId'];
- $insertData = [
- 'label' => $info['Label'],
- 'suggestion' => $info['Suggestion'],
- 'score' => $info['Score'],
- 'contentid' => $contentid,
- 'createtime' => date("Y-m-d H:i:s"),
- ];
- //招工,找活
- $tablensme = '';
- switch ($type) {
- case '1':
- $tablensme = "invent";
- break;
- case '2':
- $tablensme = "jobhunting";
- break;
- }
- $insertData['tablename'] = $tablensme;
- log::info($insertData);
- $m_s = new safenotemodel();
- $id = $m_s->insertData($insertData);
- if (!$id) {
- return backarr(0, "操作失败");
- }
- return backarr(1, "操作成功", ['id' => $id]);
- }
- public function getresult($content, $dataid = null, $userid = null)
- {
- $type = 'wc';
- $data = [
- 'content' => $content,
- 'type' => $type,
- ];
- if ($dataid) {
- $data['dataid'] = $dataid;
- }
- if ($userid) {
- $data['userid'] = $userid;
- }
- log::info($data);
- $url = 'https://app.tjzhxx.cn:5443/api/tencent_cloud/safenote';
- $header = ['Content-Type:application/x-www-form-urlencoded'];
- $result = requestCurl($url, 'post', $data, $header);
- log::info($result);
- $result = json_decode($result, true);
- log::info($result);
- if (empty($result)) {
- return backarr(0, "无文本校验结果");
- }
- return $result;
- }
- //根据接口返回数据 自动审核
- //
- public function automaticcheck($data, $type = 1, $strict = true)
- {
- if ($strict) {
- //相应时间段 不严格校验
- //招工高峰时间段 13:00 - 17:00
- //找活高峰时间段 5:00 - 10:00
- $inventTime = ['0500', '1000'];
- $jobhuntingTime = ['1300', '1700'];
- $time = date('Hi');
- switch ($type) {
- case 1:
- if ($time >= $inventTime[0] && $time <= $inventTime[1]) {
- $strict = false;
- }
- break;
- case 2:
- if ($time >= $jobhuntingTime[0] && $time <= $jobhuntingTime[1]) {
- $strict = false;
- }
- break;
- }
- }
- //总是模糊校验的label
- $noStrictLabel = ['Ad', 'Normal'];
- $label = $data['Label'];
- $isNoStrictLabel = false;
- if (in_array($label, $noStrictLabel)) {
- $strict = false;
- $isNoStrictLabel = true;
- }
- //$suggestion = $data['Suggestion'];
- $suggestion = 'Block';
- if ($strict) {
- //Pass 审核通过
- $allowSuggestion = ['Pass'];
- if (in_array($suggestion, $allowSuggestion)) {
- return true;
- }
- } else {
- //Review Pass 审核通过
- $allowSuggestion = ['Review', 'Pass'];
- if ($isNoStrictLabel) {
- array_push($allowSuggestion, 'Block');
- }
- if (in_array($suggestion, $allowSuggestion)) {
- return true;
- }
- }
- return false;
- }
- public function replaceTel($str)
- {
- if (!is_string($str)) {
- return false;
- }
- preg_match_all("(1[3-9]{1}\d{9})", $str, $matches);
- $matches = $matches[0];
- if (is_array($matches)) {
- foreach ($matches as $key => $value) {
- $telno = $value;
- $endNum = substr($telno, -4, 4);
- $str = str_replace($endNum, "****", $str);
- }
- } elseif (is_string($matches)) {
- $telno = $matches;
- $endNum = substr($telno, -4, 4);
- $telstr = str_replace($endNum, "****", $str);
- $str = str_replace($telno, $telstr, $str);
- }
- return $str;
- }
- }
|