Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
20 个修改的文件
包含
276 行增加
和
428 行删除
app/Exceptions/CsideGlobalException.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Exceptions; | ||
| 4 | - | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use Exception; | ||
| 7 | -use Throwable; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * @notes: C端接口统一错误格式 | ||
| 11 | - * Class CsideGlobalException | ||
| 12 | - * @package App\Exceptions | ||
| 13 | - */ | ||
| 14 | -class CsideGlobalException extends Exception | ||
| 15 | -{ | ||
| 16 | - public function __construct($code = 0, $message = "", Throwable $previous = null) | ||
| 17 | - { | ||
| 18 | - $this->code = $code; | ||
| 19 | - $this->message = $message; | ||
| 20 | - if (empty($this->message)) { | ||
| 21 | - $this->message = Code::fromValue($code)->description; | ||
| 22 | - } | ||
| 23 | - } | ||
| 24 | -} |
| @@ -72,10 +72,6 @@ class Handler extends ExceptionHandler | @@ -72,10 +72,6 @@ class Handler extends ExceptionHandler | ||
| 72 | elseif($exception instanceof BsideGlobalException) { | 72 | elseif($exception instanceof BsideGlobalException) { |
| 73 | LogUtils::error("BsideGlobalException", [], $exceptionMessage); | 73 | LogUtils::error("BsideGlobalException", [], $exceptionMessage); |
| 74 | } | 74 | } |
| 75 | - //C端错误 | ||
| 76 | - elseif($exception instanceof CsideGlobalException) { | ||
| 77 | - LogUtils::error("CsideGlobalException", [], $exceptionMessage); | ||
| 78 | - } | ||
| 79 | //验证错误(非手动抛出) | 75 | //验证错误(非手动抛出) |
| 80 | elseif ($exception instanceof ValidationException) { | 76 | elseif ($exception instanceof ValidationException) { |
| 81 | LogUtils::error("参数验证失败", [], $exceptionMessage); | 77 | LogUtils::error("参数验证失败", [], $exceptionMessage); |
| @@ -114,9 +110,7 @@ class Handler extends ExceptionHandler | @@ -114,9 +110,7 @@ class Handler extends ExceptionHandler | ||
| 114 | $code = $exception->getCode(); | 110 | $code = $exception->getCode(); |
| 115 | }elseif ($exception instanceof BsideGlobalException) { | 111 | }elseif ($exception instanceof BsideGlobalException) { |
| 116 | $code = $exception->getCode(); | 112 | $code = $exception->getCode(); |
| 117 | - }elseif ($exception instanceof CsideGlobalException) { | ||
| 118 | - $code = $exception->getCode(); | ||
| 119 | - } elseif ($exception instanceof ValidationException) { | 113 | + }elseif ($exception instanceof ValidationException) { |
| 120 | $code = Code::USER_PARAMS_ERROE(); | 114 | $code = Code::USER_PARAMS_ERROE(); |
| 121 | $message = $code->description = Arr::first(Arr::first($exception->errors())); | 115 | $message = $code->description = Arr::first(Arr::first($exception->errors())); |
| 122 | } elseif ($exception instanceof NotFoundHttpException || $exception instanceof MethodNotAllowedHttpException) { | 116 | } elseif ($exception instanceof NotFoundHttpException || $exception instanceof MethodNotAllowedHttpException) { |
app/Helper/FormGlobalsoApi.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +namespace App\Helper; | ||
| 5 | + | ||
| 6 | +use App\Utils\HttpUtils; | ||
| 7 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Class FormGlobalsoApi | ||
| 12 | + * @package App\Helper | ||
| 13 | + * @author zbj | ||
| 14 | + * @date 2023/5/17 | ||
| 15 | + */ | ||
| 16 | +class FormGlobalsoApi | ||
| 17 | +{ | ||
| 18 | + //接口地址 | ||
| 19 | + protected $url = 'https://form.globalso.com'; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 设置询盘通知 | ||
| 23 | + * @author zbj | ||
| 24 | + * @date 2023/5/17 | ||
| 25 | + */ | ||
| 26 | + public function setInquiry($domain, $emails, $phones) | ||
| 27 | + { | ||
| 28 | + $api_url = $this->url . '/api/external-project/save/dc77a54480b184c4'; | ||
| 29 | + | ||
| 30 | + $params = [ | ||
| 31 | + 'token' => md5($domain.$emails.$phones.date("Y-m-d")), | ||
| 32 | + 'domain' => $domain, | ||
| 33 | + 'email' => $emails, | ||
| 34 | + 'phone' => $phones, | ||
| 35 | + ]; | ||
| 36 | + | ||
| 37 | + try { | ||
| 38 | + $res = HttpUtils::get($api_url, $params); | ||
| 39 | + $res = Arr::s2a($res); | ||
| 40 | + } catch (\Exception | GuzzleException $e) { | ||
| 41 | + errorLog('设置询盘通知', $params, $e); | ||
| 42 | + return false; | ||
| 43 | + } | ||
| 44 | + return $res; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 询盘列表 | ||
| 49 | + * @author zbj | ||
| 50 | + * @date 2023/5/17 | ||
| 51 | + */ | ||
| 52 | + public function getInquiryList($domain, $search = '', $page = 1, $page_size = 20) | ||
| 53 | + { | ||
| 54 | + $api_url = $this->url . '/api/external-interface/6a1bd159b1fd60af'; | ||
| 55 | + | ||
| 56 | + $params = [ | ||
| 57 | + 'token' => md5($domain.$search.date("Y-m-d")), | ||
| 58 | + 'domain' => $domain, | ||
| 59 | + 'limit' => $page_size, | ||
| 60 | + 'page' => $page, | ||
| 61 | + 'source' => '1,3' //来源类型 新项目用1,3 | ||
| 62 | + ]; | ||
| 63 | + if($search){ | ||
| 64 | + $params['name'] = $search; | ||
| 65 | + } | ||
| 66 | + try { | ||
| 67 | + $res = HttpUtils::get($api_url, $params); | ||
| 68 | + $res = Arr::s2a($res); | ||
| 69 | + } catch (\Exception | GuzzleException $e) { | ||
| 70 | + errorLog('询盘列表', $params, $e); | ||
| 71 | + return false; | ||
| 72 | + } | ||
| 73 | + return $res; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * 设置询盘信息已读 | ||
| 78 | + * @author zbj | ||
| 79 | + * @date 2023/5/17 | ||
| 80 | + */ | ||
| 81 | + public function saveInquiryRead($domain, $id) | ||
| 82 | + { | ||
| 83 | + $api_url = $this->url . '/api/external-interface/save/d1483a8e57cb485a'; | ||
| 84 | + | ||
| 85 | + $params = [ | ||
| 86 | + 'token' => md5($domain.$id.date("Y-m-d")), | ||
| 87 | + 'domain' => $domain, | ||
| 88 | + 'id' => $id, | ||
| 89 | + ]; | ||
| 90 | + | ||
| 91 | + try { | ||
| 92 | + $res = HttpUtils::get($api_url, $params); | ||
| 93 | + $res = Arr::s2a($res); | ||
| 94 | + } catch (\Exception | GuzzleException $e) { | ||
| 95 | + errorLog('设置询盘信息已读', $params, $e); | ||
| 96 | + return false; | ||
| 97 | + } | ||
| 98 | + return $res; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * 删除询盘信息 | ||
| 103 | + * @author zbj | ||
| 104 | + * @date 2023/5/17 | ||
| 105 | + */ | ||
| 106 | + public function delInquiry($domain, $ids) | ||
| 107 | + { | ||
| 108 | + $api_url = $this->url . '/api/external-interface/del/c4b11cf6f1508489'; | ||
| 109 | + $ids = Arr::arrToSet($ids); | ||
| 110 | + $params = [ | ||
| 111 | + 'token' => md5($domain.$ids.date("Y-m-d")), | ||
| 112 | + 'domain' => $domain, | ||
| 113 | + 'id' => $ids, | ||
| 114 | + ]; | ||
| 115 | + try { | ||
| 116 | + $res = HttpUtils::get($api_url, $params); | ||
| 117 | + $res = Arr::s2a($res); | ||
| 118 | + } catch (\Exception | GuzzleException $e) { | ||
| 119 | + errorLog('删除询盘信息', $params, $e); | ||
| 120 | + return false; | ||
| 121 | + } | ||
| 122 | + return $res; | ||
| 123 | + } | ||
| 124 | +} |
| @@ -2,16 +2,12 @@ | @@ -2,16 +2,12 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | namespace App\Http\Controllers\Bside; |
| 4 | 4 | ||
| 5 | -use App\Exceptions\BsideGlobalException; | ||
| 6 | -use App\Helper\Arr; | 5 | + |
| 7 | use App\Http\Logic\Bside\InquiryLogic; | 6 | use App\Http\Logic\Bside\InquiryLogic; |
| 8 | -use App\Http\Requests\Bside\InquiryRequest; | ||
| 9 | use App\Rules\Ids; | 7 | use App\Rules\Ids; |
| 10 | use App\Services\BatchExportService; | 8 | use App\Services\BatchExportService; |
| 11 | use Illuminate\Http\Request; | 9 | use Illuminate\Http\Request; |
| 12 | use Illuminate\Support\Facades\Storage; | 10 | use Illuminate\Support\Facades\Storage; |
| 13 | -use Illuminate\Validation\ValidationException; | ||
| 14 | -use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; | ||
| 15 | 11 | ||
| 16 | /** | 12 | /** |
| 17 | * 精准询盘 | 13 | * 精准询盘 |
| @@ -25,23 +21,18 @@ class InquiryController extends BaseController | @@ -25,23 +21,18 @@ class InquiryController extends BaseController | ||
| 25 | 21 | ||
| 26 | public function index(InquiryLogic $logic) | 22 | public function index(InquiryLogic $logic) |
| 27 | { | 23 | { |
| 28 | - $map = []; | ||
| 29 | - if(!empty($this->param['search'])){ | ||
| 30 | - $map[] = ['name|email|content', 'like', "%{$this->param['search']}%"]; | ||
| 31 | - } | ||
| 32 | - $sort = ['id' => 'desc']; | ||
| 33 | - $data = $logic->getList($map, $sort, ['id', 'name', 'email', 'phone', 'url', 'ip', 'ip_country', 'status', 'created_at']); | 24 | + $data = $logic->getApiList(); |
| 34 | return $this->success($data); | 25 | return $this->success($data); |
| 35 | } | 26 | } |
| 36 | 27 | ||
| 37 | public function info(Request $request, InquiryLogic $logic){ | 28 | public function info(Request $request, InquiryLogic $logic){ |
| 38 | $request->validate([ | 29 | $request->validate([ |
| 39 | - 'id'=>'required' | 30 | + 'id' => 'required', |
| 40 | ],[ | 31 | ],[ |
| 41 | 'id.required' => 'ID不能为空' | 32 | 'id.required' => 'ID不能为空' |
| 42 | ]); | 33 | ]); |
| 43 | $data = $logic->getInfo($this->param['id']); | 34 | $data = $logic->getInfo($this->param['id']); |
| 44 | - return $this->success(Arr::twoKeepKeys($data, ['id', 'name', 'email', 'phone', 'url', 'ip', 'ip_country', 'status', 'content', 'trans_content', 'created_at'])); | 35 | + return $this->success($data); |
| 45 | } | 36 | } |
| 46 | 37 | ||
| 47 | public function delete(Request $request, InquiryLogic $logic) | 38 | public function delete(Request $request, InquiryLogic $logic) |
| @@ -52,8 +43,8 @@ class InquiryController extends BaseController | @@ -52,8 +43,8 @@ class InquiryController extends BaseController | ||
| 52 | 'ids.required' => 'ID不能为空' | 43 | 'ids.required' => 'ID不能为空' |
| 53 | ]); | 44 | ]); |
| 54 | 45 | ||
| 55 | - $data = $logic->delete($this->param['ids']); | ||
| 56 | - return $this->success($data); | 46 | + $logic->delete($this->param['ids']); |
| 47 | + return $this->success(); | ||
| 57 | } | 48 | } |
| 58 | 49 | ||
| 59 | /** | 50 | /** |
| @@ -66,22 +57,20 @@ class InquiryController extends BaseController | @@ -66,22 +57,20 @@ class InquiryController extends BaseController | ||
| 66 | */ | 57 | */ |
| 67 | public function export(InquiryLogic $logic) | 58 | public function export(InquiryLogic $logic) |
| 68 | { | 59 | { |
| 69 | - $sort = ['id' => 'desc']; | ||
| 70 | - //最多到1w条 | ||
| 71 | - $data = $logic->getList([], $sort, ['name', 'email', 'phone', 'url', 'ip', 'ip_country', 'content', 'created_at'], 10000); | 60 | + $data = $logic->getApiList(true); |
| 72 | $data = $data['list'] ?? []; | 61 | $data = $data['list'] ?? []; |
| 73 | foreach ($data as &$item){ | 62 | foreach ($data as &$item){ |
| 74 | - $item['ip_address'] = "{$item['ip_country']}({$item['ip']})"; | 63 | + $item['ip_address'] = "{$item['country']}({$item['ip']})"; |
| 75 | } | 64 | } |
| 76 | 65 | ||
| 77 | $map = [ | 66 | $map = [ |
| 78 | - 'created_at' => '询盘发送时间', | 67 | + 'submit_time' => '询盘发送时间', |
| 79 | 'name' => '姓名', | 68 | 'name' => '姓名', |
| 80 | 'email' => '邮箱', | 69 | 'email' => '邮箱', |
| 81 | 'phone' => '电话', | 70 | 'phone' => '电话', |
| 82 | 'ip_address' => '访问国家/地区(IP)', | 71 | 'ip_address' => '访问国家/地区(IP)', |
| 83 | - 'url' => '发送页面', | ||
| 84 | - 'content' => '询盘内容', | 72 | + 'refer' => '发送页面', |
| 73 | + 'message' => '询盘内容', | ||
| 85 | ]; | 74 | ]; |
| 86 | 75 | ||
| 87 | //生成文件,发送到客户端 | 76 | //生成文件,发送到客户端 |
| @@ -94,4 +83,17 @@ class InquiryController extends BaseController | @@ -94,4 +83,17 @@ class InquiryController extends BaseController | ||
| 94 | // return Storage::disk('runtime')->download($file); //直接下载 | 83 | // return Storage::disk('runtime')->download($file); //直接下载 |
| 95 | return $this->success(['url' => $fileurl]); | 84 | return $this->success(['url' => $fileurl]); |
| 96 | } | 85 | } |
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 询盘通知设置 | ||
| 89 | + * @author zbj | ||
| 90 | + * @date 2023/5/17 | ||
| 91 | + */ | ||
| 92 | + public function set(Request $request, InquiryLogic $logic){ | ||
| 93 | + if($request->isMethod('get')){ | ||
| 94 | + return $this->success($logic->getSet()); | ||
| 95 | + } | ||
| 96 | + $logic->saveSet(); | ||
| 97 | + return $this->success(); | ||
| 98 | + } | ||
| 97 | } | 99 | } |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Controllers\Cside; | ||
| 4 | - | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use App\Http\Controllers\Controller; | ||
| 7 | -use Illuminate\Http\JsonResponse; | ||
| 8 | -use Illuminate\Http\Request; | ||
| 9 | -use Illuminate\Http\Exceptions\HttpResponseException; | ||
| 10 | -use Illuminate\Support\Facades\Cache; | ||
| 11 | -use Illuminate\Support\Facades\Session; | ||
| 12 | - | ||
| 13 | -class BaseController extends Controller | ||
| 14 | -{ | ||
| 15 | - protected $param = [];//所有请求参数 | ||
| 16 | - protected $token = ''; //token | ||
| 17 | - protected $request = [];//助手函数 | ||
| 18 | - protected $project = [];//当前登录用户详情 | ||
| 19 | - /** | ||
| 20 | - * 获取所有参数 | ||
| 21 | - */ | ||
| 22 | - public function __construct(Request $request) | ||
| 23 | - { | ||
| 24 | - $this->request = $request; | ||
| 25 | - $this->param = $this->request->all(); | ||
| 26 | - $this->token = $this->request->header('token'); | ||
| 27 | - if(!empty($this->token) && !empty(Cache::get($this->token))){ | ||
| 28 | - $info = Cache::get($this->token); | ||
| 29 | - $this->user = $info; | ||
| 30 | - $this->uid = $info['id']; | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * 成功返回 | ||
| 38 | - * @param array $data | ||
| 39 | - * @param string $code | ||
| 40 | - * @param bool $objectData | ||
| 41 | - * @return JsonResponse | ||
| 42 | - * @throws \Psr\Container\ContainerExceptionInterface | ||
| 43 | - * @throws \Psr\Container\NotFoundExceptionInterface | ||
| 44 | - */ | ||
| 45 | - function success(array $data = [], string $code = Code::SUCCESS, bool $objectData = false): JsonResponse | ||
| 46 | - { | ||
| 47 | - if ($objectData) { | ||
| 48 | - $data = (object)$data; | ||
| 49 | - } | ||
| 50 | - $code = Code::fromValue($code); | ||
| 51 | - $response = [ | ||
| 52 | - 'code' => $code->value, | ||
| 53 | - 'data' => $data, | ||
| 54 | - 'msg' => $code->description, | ||
| 55 | - ]; | ||
| 56 | - return response()->json($response,200); | ||
| 57 | - } | ||
| 58 | -} |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Controllers\Cside; | ||
| 4 | - | ||
| 5 | -use App\Http\Logic\Cside\InquiryLogic; | ||
| 6 | -use App\Http\Requests\Cside\InquiryRequest; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 精准询盘 | ||
| 10 | - * Class InquiryController | ||
| 11 | - * @package App\Http\Controllers\Bside | ||
| 12 | - * @author zbj | ||
| 13 | - * @date 2023/5/4 | ||
| 14 | - */ | ||
| 15 | -class InquiryController extends BaseController | ||
| 16 | -{ | ||
| 17 | - | ||
| 18 | - public function save(InquiryRequest $request, InquiryLogic $logic) | ||
| 19 | - { | ||
| 20 | - $data = $logic->save($this->param); | ||
| 21 | - return $this->success($data); | ||
| 22 | - } | ||
| 23 | -} |
| @@ -11,7 +11,6 @@ use App\Http\Middleware\Bside\EnableCrossRequestMiddleware; | @@ -11,7 +11,6 @@ use App\Http\Middleware\Bside\EnableCrossRequestMiddleware; | ||
| 11 | use App\Http\Middleware\Bside\ParamMiddleware as BsideParamMiddleware; | 11 | use App\Http\Middleware\Bside\ParamMiddleware as BsideParamMiddleware; |
| 12 | use App\Http\Middleware\Aside\LoginAuthMiddleware as AsideLoginAuthMiddleware; | 12 | use App\Http\Middleware\Aside\LoginAuthMiddleware as AsideLoginAuthMiddleware; |
| 13 | use App\Http\Middleware\Bside\LoginAuthMiddleware as BsideLoginAuthMiddleware; | 13 | use App\Http\Middleware\Bside\LoginAuthMiddleware as BsideLoginAuthMiddleware; |
| 14 | -use App\Http\Middleware\Cside\ParamMiddleware as CsideParamMiddleware; | ||
| 15 | use App\Http\Middleware\PreventRepeatQuitCallMiddleware; | 14 | use App\Http\Middleware\PreventRepeatQuitCallMiddleware; |
| 16 | use Illuminate\Foundation\Http\Kernel as HttpKernel; | 15 | use Illuminate\Foundation\Http\Kernel as HttpKernel; |
| 17 | 16 | ||
| @@ -77,11 +76,6 @@ class Kernel extends HttpKernel | @@ -77,11 +76,6 @@ class Kernel extends HttpKernel | ||
| 77 | //允许跨域请求 | 76 | //允许跨域请求 |
| 78 | EnableCrossRequestMiddleware::class | 77 | EnableCrossRequestMiddleware::class |
| 79 | ], | 78 | ], |
| 80 | - //C端中间件组 | ||
| 81 | - 'cside'=>[ | ||
| 82 | - //参数处理中间件--涉及-参数记录-参数加解密等 | ||
| 83 | - CsideParamMiddleware::class, | ||
| 84 | - ] | ||
| 85 | ]; | 79 | ]; |
| 86 | 80 | ||
| 87 | /** | 81 | /** |
| @@ -3,7 +3,10 @@ | @@ -3,7 +3,10 @@ | ||
| 3 | namespace App\Http\Logic\Bside; | 3 | namespace App\Http\Logic\Bside; |
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | -use App\Models\Inquiry; | 6 | +use App\Helper\FormGlobalsoApi; |
| 7 | +use App\Helper\Translate; | ||
| 8 | +use App\Http\Logic\Aside\Project\ProjectLogic; | ||
| 9 | +use App\Models\InquirySet; | ||
| 7 | 10 | ||
| 8 | /** | 11 | /** |
| 9 | * Class InquiryLogic | 12 | * Class InquiryLogic |
| @@ -11,25 +14,119 @@ use App\Models\Inquiry; | @@ -11,25 +14,119 @@ use App\Models\Inquiry; | ||
| 11 | * @author zbj | 14 | * @author zbj |
| 12 | * @date 2023/5/4 | 15 | * @date 2023/5/4 |
| 13 | */ | 16 | */ |
| 14 | -class InquiryLogic extends BaseLogic | 17 | +class InquiryLogic extends BaseLogic |
| 15 | { | 18 | { |
| 19 | + protected $form_globalso_api; | ||
| 20 | + | ||
| 16 | public function __construct() | 21 | public function __construct() |
| 17 | { | 22 | { |
| 18 | parent::__construct(); | 23 | parent::__construct(); |
| 19 | 24 | ||
| 20 | - $this->model = new Inquiry(); | 25 | + $this->form_globalso_api = new FormGlobalsoApi(); |
| 26 | + } | ||
| 27 | + | ||
| 28 | + public function getApiList($export = false) | ||
| 29 | + { | ||
| 30 | + $page_size = $export ? 1000 : 20; | ||
| 31 | + $search = $this->request['search'] ?: ''; | ||
| 32 | + $page = $this->request['page'] ?: 1; | ||
| 33 | + $project = (new ProjectLogic())->getInfo($this->user['project_id']); | ||
| 34 | + $domain = $project['deploy_optimize']['domain'] ?: ''; | ||
| 35 | + $list = $this->form_globalso_api->getInquiryList($domain, $search, $page, $page_size); | ||
| 36 | + //处理格式 免得前端又改 | ||
| 37 | + $data = [ | ||
| 38 | + "list" => [], | ||
| 39 | + "total" => 0, | ||
| 40 | + "page" => $page, | ||
| 41 | + "total_page" => 1, | ||
| 42 | + "size" => $page_size | ||
| 43 | + ]; | ||
| 44 | + if (!empty($list['status']) && $list['status'] == 200) { | ||
| 45 | + foreach ($list['data']['data'] as $item) { | ||
| 46 | + $data['list'][] = $item; | ||
| 47 | + } | ||
| 48 | + $data['total'] = $list['data']['total']; | ||
| 49 | + $data['total_page'] = $list['data']['last_page']; | ||
| 50 | + } | ||
| 51 | + return $this->success($data); | ||
| 21 | } | 52 | } |
| 22 | 53 | ||
| 23 | public function getInfo($id) | 54 | public function getInfo($id) |
| 24 | { | 55 | { |
| 25 | - $info = $this->getCacheInfo($id); | ||
| 26 | - if(!$info){ | ||
| 27 | - $this->fail('数据不存在或者已经删除'); | 56 | + $project = (new ProjectLogic())->getInfo($this->user['project_id']); |
| 57 | + $domain = $project['deploy_optimize']['domain'] ?: ''; | ||
| 58 | + //修改状态为已读 | ||
| 59 | + if($this->request['read_status']){ | ||
| 60 | + $this->form_globalso_api->saveInquiryRead($domain, $id); | ||
| 61 | + } | ||
| 62 | + //翻译 | ||
| 63 | + $trans_message = ''; | ||
| 64 | + if($this->request['message']){ | ||
| 65 | + $trans_message = Translate::tran($this->request['message'], 'zh'); | ||
| 66 | + } | ||
| 67 | + return $this->success(['trans_message' => $trans_message]); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public function delete($ids, $map = []) | ||
| 71 | + { | ||
| 72 | + $project = (new ProjectLogic())->getInfo($this->user['project_id']); | ||
| 73 | + $domain = $project['deploy_optimize']['domain'] ?: ''; | ||
| 74 | + $ids = array_filter(Arr::splitFilterToArray($ids), 'intval'); | ||
| 75 | + if(!$ids){ | ||
| 76 | + $this->fail('ID不能为空'); | ||
| 77 | + } | ||
| 78 | + $this->form_globalso_api->delInquiry($domain, $ids); | ||
| 79 | + return $this->success(); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 读取设置 | ||
| 84 | + * @return array | ||
| 85 | + * @author zbj | ||
| 86 | + * @date 2023/5/17 | ||
| 87 | + */ | ||
| 88 | + public function getSet() | ||
| 89 | + { | ||
| 90 | + $set = InquirySet::where('project_id', $this->user['project_id'])->first(); | ||
| 91 | + if ($set) { | ||
| 92 | + return $this->success(Arr::twoKeepKeys($set->toArray(), ['emails', 'phones'])); | ||
| 93 | + } else { | ||
| 94 | + return $this->success(['emails' => '', 'phones' => '']); | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * 保存设置 | ||
| 100 | + * @author zbj | ||
| 101 | + * @date 2023/5/17 | ||
| 102 | + */ | ||
| 103 | + public function saveSet() | ||
| 104 | + { | ||
| 105 | + $project = (new ProjectLogic())->getInfo($this->user['project_id']); | ||
| 106 | + | ||
| 107 | + //同步到接口 | ||
| 108 | + $domain = parse_url($project['deploy_optimize']['domain'])['host'] ?? ['path']; | ||
| 109 | + $emails = Arr::arrToSet($this->request['emails'], 'trim'); | ||
| 110 | + $phones = Arr::arrToSet($this->request['phones'], 'trim'); | ||
| 111 | + | ||
| 112 | + $res = $this->form_globalso_api->setInquiry($domain, $emails, $phones); | ||
| 113 | + | ||
| 114 | + if (!$res) { | ||
| 115 | + $this->fail('保存失败'); | ||
| 28 | } | 116 | } |
| 29 | - //标记已读 | ||
| 30 | - if($info->status == Inquiry::STATUS_UNREAD){ | ||
| 31 | - parent::save(['id' => $info['id'], 'status' => Inquiry::STATUS_READ]); | 117 | + if ($res['status'] != 200) { |
| 118 | + $this->fail($res['message'] ?? '保存失败'); | ||
| 32 | } | 119 | } |
| 33 | - return $this->success($info->toArray()); | 120 | + //保存 |
| 121 | + $set = InquirySet::where('project_id', $this->user['project_id'])->first(); | ||
| 122 | + if (!$set) { | ||
| 123 | + $set = new InquirySet(); | ||
| 124 | + } | ||
| 125 | + $set->project_id = $this->user['project_id']; | ||
| 126 | + $set->emails = $emails; | ||
| 127 | + $set->phones = $phones; | ||
| 128 | + $set->save(); | ||
| 34 | } | 129 | } |
| 130 | + | ||
| 131 | + | ||
| 35 | } | 132 | } |
app/Http/Logic/Cside/BaseLogic.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Logic\Cside; | ||
| 4 | - | ||
| 5 | - | ||
| 6 | -use App\Enums\Common\Common; | ||
| 7 | -use App\Exceptions\BsideGlobalException; | ||
| 8 | -use App\Http\Logic\Logic; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @notes: 逻辑层基类 控制器调用 统一返回 统一抛出异常 | ||
| 12 | - */ | ||
| 13 | -class BaseLogic extends Logic | ||
| 14 | -{ | ||
| 15 | - | ||
| 16 | - protected $requestAll; | ||
| 17 | - | ||
| 18 | - protected $param; | ||
| 19 | - | ||
| 20 | - protected $request; | ||
| 21 | - | ||
| 22 | - protected $project; | ||
| 23 | - | ||
| 24 | - protected $side = Common::C; | ||
| 25 | - | ||
| 26 | - public function __construct() | ||
| 27 | - { | ||
| 28 | - $this->request = request(); | ||
| 29 | - $this->requestAll = request()->all(); | ||
| 30 | - $this->project = $this->request->get('project'); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - /** | ||
| 35 | - * 列表 | ||
| 36 | - * @param array $map | ||
| 37 | - * @param array $sort | ||
| 38 | - * @param array $columns | ||
| 39 | - * @param int $limit | ||
| 40 | - * @return array | ||
| 41 | - * @author zbj | ||
| 42 | - * @date 2023/4/13 | ||
| 43 | - */ | ||
| 44 | - public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) | ||
| 45 | - { | ||
| 46 | - $map[] = ['project_id' => $this->project['id']]; | ||
| 47 | - return parent::getList($map, $sort, $columns, $limit); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - /** | ||
| 51 | - * @param $id | ||
| 52 | - * @return mixed | ||
| 53 | - * @author zbj | ||
| 54 | - * @date 2023/4/15 | ||
| 55 | - */ | ||
| 56 | - public function getCacheInfo($id) | ||
| 57 | - { | ||
| 58 | - $info = parent::getCacheInfo($id); | ||
| 59 | - if ($info && $info['project_id'] != $this->project['id']) { | ||
| 60 | - $info = null; | ||
| 61 | - } | ||
| 62 | - return $info; | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - /** | ||
| 66 | - * 保存 | ||
| 67 | - * @param $param | ||
| 68 | - * @return array | ||
| 69 | - * @throws BsideGlobalException | ||
| 70 | - * @author zbj | ||
| 71 | - * @date 2023/4/13 | ||
| 72 | - */ | ||
| 73 | - public function save($param) | ||
| 74 | - { | ||
| 75 | - $param['project_id'] = $this->project['id']; | ||
| 76 | - return parent::save($param); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - /** | ||
| 80 | - * 批量删除 | ||
| 81 | - * @param $ids | ||
| 82 | - * @param array $map | ||
| 83 | - * @return array | ||
| 84 | - * @author zbj | ||
| 85 | - * @date 2023/4/13 | ||
| 86 | - */ | ||
| 87 | - public function delete($ids, $map = []) | ||
| 88 | - { | ||
| 89 | - $map[] = ['project_id' => $this->project['id']]; | ||
| 90 | - return parent::delete($ids, $map); | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | -} |
app/Http/Logic/Cside/InquiryLogic.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Logic\Cside; | ||
| 4 | - | ||
| 5 | -use App\Helper\Arr; | ||
| 6 | -use App\Models\Inquiry; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * Class InquiryLogic | ||
| 10 | - * @package App\Http\Logic\Bside | ||
| 11 | - * @author zbj | ||
| 12 | - * @date 2023/5/4 | ||
| 13 | - */ | ||
| 14 | -class InquiryLogic extends BaseLogic | ||
| 15 | -{ | ||
| 16 | - public function __construct() | ||
| 17 | - { | ||
| 18 | - parent::__construct(); | ||
| 19 | - | ||
| 20 | - $this->model = new Inquiry(); | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - public function save($param) | ||
| 24 | - { | ||
| 25 | - $param['ip_info'] = Arr::s2a($param['ip_info']); | ||
| 26 | - $param['ip'] = $param['ip_info']['ip'] ?? ''; | ||
| 27 | - $param['ip_country'] = $param['ip_info']['country'] ?? ''; | ||
| 28 | - return parent::save($param); | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | -} |
| @@ -4,7 +4,6 @@ namespace App\Http\Logic; | @@ -4,7 +4,6 @@ namespace App\Http\Logic; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Enums\Common\Common; | 6 | use App\Enums\Common\Common; |
| 7 | -use App\Exceptions\CsideGlobalException; | ||
| 8 | use \App\Helper\Common as CommonHelper; | 7 | use \App\Helper\Common as CommonHelper; |
| 9 | use App\Exceptions\AsideGlobalException; | 8 | use App\Exceptions\AsideGlobalException; |
| 10 | use App\Exceptions\BsideGlobalException; | 9 | use App\Exceptions\BsideGlobalException; |
| @@ -46,9 +45,6 @@ class Logic | @@ -46,9 +45,6 @@ class Logic | ||
| 46 | if((request()->path()[0]) == Common::B){ | 45 | if((request()->path()[0]) == Common::B){ |
| 47 | throw new BsideGlobalException($code, $message); | 46 | throw new BsideGlobalException($code, $message); |
| 48 | } | 47 | } |
| 49 | - if((request()->path()[0]) == Common::C){ | ||
| 50 | - throw new CsideGlobalException($code, $message); | ||
| 51 | - } | ||
| 52 | throw new AsideGlobalException($code, $message); | 48 | throw new AsideGlobalException($code, $message); |
| 53 | } | 49 | } |
| 54 | 50 |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Middleware\Cside; | ||
| 4 | - | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use App\Models\Project\Project; | ||
| 7 | -use App\Services\ProjectServer; | ||
| 8 | -use Closure; | ||
| 9 | -use Illuminate\Http\Request; | ||
| 10 | - | ||
| 11 | -class ParamMiddleware | ||
| 12 | -{ | ||
| 13 | - protected $param = []; | ||
| 14 | - | ||
| 15 | - protected $project = []; | ||
| 16 | - | ||
| 17 | - /** | ||
| 18 | - * Handle an incoming request. | ||
| 19 | - * | ||
| 20 | - * @param \Illuminate\Http\Request $request | ||
| 21 | - * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next | ||
| 22 | - * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse | ||
| 23 | - */ | ||
| 24 | - public function handle(Request $request, Closure $next) | ||
| 25 | - { | ||
| 26 | - $this->param = $request->all(); | ||
| 27 | - $domain = $request->header('domain'); | ||
| 28 | - if(!isset($domain) || empty($domain)){ | ||
| 29 | - return response(['code'=>Code::USER_ERROR,'msg'=>'非法请求']); | ||
| 30 | - } | ||
| 31 | - $project = Project::getProjectByDomain($domain); | ||
| 32 | - if(empty($project)){ | ||
| 33 | - return response(['code'=>Code::USER_ERROR,'msg'=>'非法请求']); | ||
| 34 | - } | ||
| 35 | - // 设置数据信息 | ||
| 36 | -// $project = ProjectServer::useProject($project['id']); | ||
| 37 | -// if($project){ | ||
| 38 | -// return response(['code'=>Code::USER_ERROR,'msg'=>'数据库未配置']); | ||
| 39 | -// } | ||
| 40 | - $request->attributes->add(['project' => $project]); | ||
| 41 | - return $next($request); | ||
| 42 | - } | ||
| 43 | -} |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Requests\Cside; | ||
| 4 | - | ||
| 5 | -use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * Class InquiryRequest | ||
| 9 | - * @package App\Http\Requests\Cside | ||
| 10 | - * @author zbj | ||
| 11 | - * @date 2023/5/4 | ||
| 12 | - */ | ||
| 13 | -class InquiryRequest extends FormRequest | ||
| 14 | -{ | ||
| 15 | - /** | ||
| 16 | - * Determine if the user is authorized to make this request. | ||
| 17 | - * | ||
| 18 | - * @return bool | ||
| 19 | - */ | ||
| 20 | - public function authorize() | ||
| 21 | - { | ||
| 22 | - return true; | ||
| 23 | - } | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * Get the validation rules that apply to the request. | ||
| 27 | - * | ||
| 28 | - * @return array | ||
| 29 | - */ | ||
| 30 | - public function rules() | ||
| 31 | - { | ||
| 32 | - return [ | ||
| 33 | - 'name' => 'required|max:200', | ||
| 34 | - 'email' => 'required|email|max:200', | ||
| 35 | - 'phone' => 'max:200', | ||
| 36 | - 'content' => 'required', | ||
| 37 | - ]; | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - public function messages() | ||
| 41 | - { | ||
| 42 | - return []; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | -} |
app/Models/Inquiry.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Models; | ||
| 4 | - | ||
| 5 | -use App\Helper\Arr; | ||
| 6 | -use Illuminate\Database\Eloquent\SoftDeletes; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * Class Inquiry | ||
| 10 | - * @package App\Models | ||
| 11 | - * @author zbj | ||
| 12 | - * @date 2023/5/4 | ||
| 13 | - */ | ||
| 14 | -class Inquiry extends Base | ||
| 15 | -{ | ||
| 16 | - use SoftDeletes; | ||
| 17 | - | ||
| 18 | - //设置关联表名 | ||
| 19 | - protected $table = 'gl_inquiry'; | ||
| 20 | - | ||
| 21 | - const STATUS_UNREAD = 0; | ||
| 22 | - const STATUS_READ = 1; | ||
| 23 | - | ||
| 24 | - public function setIpInfoAttribute($value){ | ||
| 25 | - $this->attributes['ip_info'] = Arr::a2s($value); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - public function getIpInfoAttribute($value){ | ||
| 29 | - return Arr::s2a($value); | ||
| 30 | - } | ||
| 31 | -} |
app/Models/InquirySet.php
0 → 100644
| @@ -40,7 +40,6 @@ class RouteServiceProvider extends ServiceProvider | @@ -40,7 +40,6 @@ class RouteServiceProvider extends ServiceProvider | ||
| 40 | //预定义两个端的API路由 | 40 | //预定义两个端的API路由 |
| 41 | $this->mapAsideRoute(); | 41 | $this->mapAsideRoute(); |
| 42 | $this->mapBsideRoute(); | 42 | $this->mapBsideRoute(); |
| 43 | - $this->mapCsideRoute(); | ||
| 44 | 43 | ||
| 45 | // 暂时无用 | 44 | // 暂时无用 |
| 46 | $this->routes(function () { | 45 | $this->routes(function () { |
| @@ -75,16 +74,6 @@ class RouteServiceProvider extends ServiceProvider | @@ -75,16 +74,6 @@ class RouteServiceProvider extends ServiceProvider | ||
| 75 | ->namespace($this->namespace . '\Bside') | 74 | ->namespace($this->namespace . '\Bside') |
| 76 | ->group(base_path('routes/bside.php')); | 75 | ->group(base_path('routes/bside.php')); |
| 77 | } | 76 | } |
| 78 | - /** | ||
| 79 | - *C端API路由 | ||
| 80 | - * @return void | ||
| 81 | - */ | ||
| 82 | - protected function mapCsideRoute(){ | ||
| 83 | - Route::middleware('cside') | ||
| 84 | - ->prefix('c') | ||
| 85 | - ->namespace($this->namespace . '\Cside') | ||
| 86 | - ->group(base_path('routes/cside.php')); | ||
| 87 | - } | ||
| 88 | 77 | ||
| 89 | /** | 78 | /** |
| 90 | * Configure the rate limiters for the application. | 79 | * Configure the rate limiters for the application. |
| @@ -60,12 +60,6 @@ return [ | @@ -60,12 +60,6 @@ return [ | ||
| 60 | 'via' => \App\Factory\LogFormatterFactory::class, | 60 | 'via' => \App\Factory\LogFormatterFactory::class, |
| 61 | 'prefix' => 'bside', | 61 | 'prefix' => 'bside', |
| 62 | ], | 62 | ], |
| 63 | - //自定义B端错误日志 | ||
| 64 | - 'cside' => [ | ||
| 65 | - 'driver' => 'custom', | ||
| 66 | - 'via' => \App\Factory\LogFormatterFactory::class, | ||
| 67 | - 'prefix' => 'cside', | ||
| 68 | - ], | ||
| 69 | 63 | ||
| 70 | 'stack' => [ | 64 | 'stack' => [ |
| 71 | 'driver' => 'stack', | 65 | 'driver' => 'stack', |
| @@ -199,6 +199,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -199,6 +199,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 199 | //精准询盘 | 199 | //精准询盘 |
| 200 | Route::prefix('inquiry')->group(function () { | 200 | Route::prefix('inquiry')->group(function () { |
| 201 | Route::get('/', [\App\Http\Controllers\Bside\InquiryController::class, 'index'])->name('inquiry'); | 201 | Route::get('/', [\App\Http\Controllers\Bside\InquiryController::class, 'index'])->name('inquiry'); |
| 202 | + Route::any('/set', [\App\Http\Controllers\Bside\InquiryController::class, 'set'])->name('inquiry_set'); | ||
| 202 | Route::get('/info', [\App\Http\Controllers\Bside\InquiryController::class, 'info'])->name('inquiry_info'); | 203 | Route::get('/info', [\App\Http\Controllers\Bside\InquiryController::class, 'info'])->name('inquiry_info'); |
| 203 | Route::any('/delete', [\App\Http\Controllers\Bside\InquiryController::class, 'delete'])->name('inquiry_delete'); | 204 | Route::any('/delete', [\App\Http\Controllers\Bside\InquiryController::class, 'delete'])->name('inquiry_delete'); |
| 204 | Route::any('/export', [\App\Http\Controllers\Bside\InquiryController::class, 'export'])->name('inquiry_export'); | 205 | Route::any('/export', [\App\Http\Controllers\Bside\InquiryController::class, 'export'])->name('inquiry_export'); |
routes/cside.php
已删除
100644 → 0
-
请 注册 或 登录 后发表评论