正在显示
4 个修改的文件
包含
185 行增加
和
23 行删除
| @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | @@ -6,6 +6,7 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | use App\Http\Logic\Aside\Projects\InquiryInfoLogic; | 7 | use App\Http\Logic\Aside\Projects\InquiryInfoLogic; |
| 8 | use App\Models\Projects\InquiryUser; | 8 | use App\Models\Projects\InquiryUser; |
| 9 | +use PhpOffice\PhpSpreadsheet\IOFactory; | ||
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| 11 | * @remark :询盘中心 | 12 | * @remark :询盘中心 |
| @@ -29,20 +30,6 @@ class InquiryInfoController extends BaseController | @@ -29,20 +30,6 @@ class InquiryInfoController extends BaseController | ||
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| 32 | - * @remark :保存询盘信息 | ||
| 33 | - * @name :save | ||
| 34 | - * @author :lyh | ||
| 35 | - * @method :post | ||
| 36 | - * @time :2023/7/11 15:33 | ||
| 37 | - */ | ||
| 38 | - public function save(InquiryInfoLogic $inquiryInfoLogic){ | ||
| 39 | - //参数验证 | ||
| 40 | - $this->validationParam(); | ||
| 41 | - $inquiryInfoLogic->inquirySave(); | ||
| 42 | - $this->response('success'); | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - /** | ||
| 46 | * @remark :参数验证 | 33 | * @remark :参数验证 |
| 47 | * @name :validationParam | 34 | * @name :validationParam |
| 48 | * @author :lyh | 35 | * @author :lyh |
| @@ -72,11 +59,92 @@ class InquiryInfoController extends BaseController | @@ -72,11 +59,92 @@ class InquiryInfoController extends BaseController | ||
| 72 | 'type.required' => '类型不能为空', | 59 | 'type.required' => '类型不能为空', |
| 73 | ]); | 60 | ]); |
| 74 | } | 61 | } |
| 62 | + /** | ||
| 63 | + * @remark :保存询盘信息 | ||
| 64 | + * @name :save | ||
| 65 | + * @author :lyh | ||
| 66 | + * @method :post | ||
| 67 | + * @time :2023/7/11 15:33 | ||
| 68 | + */ | ||
| 69 | + public function save(InquiryInfoLogic $inquiryInfoLogic){ | ||
| 70 | + //参数验证 | ||
| 71 | + $this->validationParam(); | ||
| 72 | + $inquiryInfoLogic->inquirySave(); | ||
| 73 | + $this->response('success'); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * @remark :转发详情 | ||
| 78 | + * @name :info | ||
| 79 | + * @author :lyh | ||
| 80 | + * @method :post | ||
| 81 | + * @time :2023/7/12 17:19 | ||
| 82 | + */ | ||
| 83 | + public function forwardInfo(InquiryInfoLogic $inquiryInfoLogic){ | ||
| 84 | + $this->request->validate([ | ||
| 85 | + 'id'=>'required',// | ||
| 86 | + ],[ | ||
| 87 | + 'id.required' => 'ID不能为空', | ||
| 88 | + ]); | ||
| 89 | + $info = $inquiryInfoLogic->inquiryForwardInfo(); | ||
| 90 | + $this->response('success',Code::SUCCESS,$info); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * @param InquiryInfoLogic $inquiryInfoLogic | ||
| 95 | + * @remark :执行逻辑删除 | ||
| 96 | + * @name :del | ||
| 97 | + * @author :lyh | ||
| 98 | + * @method :post | ||
| 99 | + * @time :2023/7/12 14:10 | ||
| 100 | + */ | ||
| 101 | + public function del(InquiryInfoLogic $inquiryInfoLogic){ | ||
| 102 | + $this->request->validate([ | ||
| 103 | + 'id'=>'required',// | ||
| 104 | + ],[ | ||
| 105 | + 'id.required' => '名称不能为空', | ||
| 106 | + | ||
| 107 | + ]); | ||
| 108 | + $inquiryInfoLogic->inquiryInfoDel(); | ||
| 109 | + $this->response('success'); | ||
| 110 | + } | ||
| 75 | 111 | ||
| 76 | - public function ceshi(){ | ||
| 77 | - $inquiryUser = new InquiryUser(); | ||
| 78 | - for ($i = 0;$i <= 200;$i++){ | ||
| 79 | - $inquiryUser->edit(['xp_id'=>$i + 1],['id'=>$i + 1]); | 112 | + /** |
| 113 | + * @remark :导入询盘记录 | ||
| 114 | + * @name :ImportInquirySave | ||
| 115 | + * @author :lyh | ||
| 116 | + * @method :post | ||
| 117 | + * @time :2023/7/13 10:39 | ||
| 118 | + */ | ||
| 119 | + public function importInquirySave(InquiryInfoLogic $inquiryInfoLogic){ | ||
| 120 | + if ($this->request->hasFile('file')) { | ||
| 121 | + $path = $this->request->file('file')->getRealPath(); | ||
| 122 | + $spreadsheet = IOFactory::load($path); | ||
| 123 | + $worksheet = $spreadsheet->getActiveSheet(); | ||
| 124 | + $rows = $worksheet->toArray(); | ||
| 125 | + foreach ($rows as $row) { | ||
| 126 | + // 创建模型实例并设置属性 | ||
| 127 | + $inquiryInfoLogic->ImportInquiryInfoSave($row); | ||
| 128 | + } | ||
| 80 | } | 129 | } |
| 130 | + $this->response('success'); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * @remark :根据国家获取随机ip | ||
| 135 | + * @name :getSearchIpInfo | ||
| 136 | + * @author :lyh | ||
| 137 | + * @method :post | ||
| 138 | + * @time :2023/7/13 13:45 | ||
| 139 | + */ | ||
| 140 | + public function getSearchIpInfo(InquiryInfoLogic $inquiryInfoLogic){ | ||
| 141 | + $this->request->validate([ | ||
| 142 | + 'ip_area'=>'required',// | ||
| 143 | + ],[ | ||
| 144 | + 'ip_area.required' => '国家不能为空', | ||
| 145 | + | ||
| 146 | + ]); | ||
| 147 | + $info = $inquiryInfoLogic->getSearchIp(); | ||
| 148 | + $this->response('success',Code::SUCCESS,$info); | ||
| 81 | } | 149 | } |
| 82 | } | 150 | } |
| @@ -3,9 +3,10 @@ | @@ -3,9 +3,10 @@ | ||
| 3 | namespace App\Http\Logic\Aside\Projects; | 3 | namespace App\Http\Logic\Aside\Projects; |
| 4 | 4 | ||
| 5 | use App\Http\Logic\Aside\BaseLogic; | 5 | use App\Http\Logic\Aside\BaseLogic; |
| 6 | +use App\Models\InquiryIP; | ||
| 6 | use App\Models\Projects\InquiryInfo; | 7 | use App\Models\Projects\InquiryInfo; |
| 7 | use App\Models\Projects\InquiryUser; | 8 | use App\Models\Projects\InquiryUser; |
| 8 | -use mysql_xdevapi\Exception; | 9 | +use Illuminate\Support\Facades\DB; |
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| 11 | * @remark :询盘中心 | 12 | * @remark :询盘中心 |
| @@ -45,6 +46,9 @@ class InquiryInfoLogic extends BaseLogic | @@ -45,6 +46,9 @@ class InquiryInfoLogic extends BaseLogic | ||
| 45 | if(isset($map['type'])){ | 46 | if(isset($map['type'])){ |
| 46 | $query = $query->where('gl_inquiry_info.type',$map['type']); | 47 | $query = $query->where('gl_inquiry_info.type',$map['type']); |
| 47 | } | 48 | } |
| 49 | + if(isset($map['url'])){ | ||
| 50 | + $query = $query->where('gl_inquiry_info.url',$map['url']); | ||
| 51 | + } | ||
| 48 | $lists = $query->paginate($row, $this->selectParam(), 'page', $page); | 52 | $lists = $query->paginate($row, $this->selectParam(), 'page', $page); |
| 49 | return $this->success($lists); | 53 | return $this->success($lists); |
| 50 | } | 54 | } |
| @@ -79,12 +83,12 @@ class InquiryInfoLogic extends BaseLogic | @@ -79,12 +83,12 @@ class InquiryInfoLogic extends BaseLogic | ||
| 79 | * @time :2023/7/12 9:22 | 83 | * @time :2023/7/12 9:22 |
| 80 | */ | 84 | */ |
| 81 | public function inquirySave(){ | 85 | public function inquirySave(){ |
| 82 | -// try { | 86 | + try { |
| 83 | $xp_id = $this->inquiryInfoSave(); | 87 | $xp_id = $this->inquiryInfoSave(); |
| 84 | $this->inquiryUserSave($xp_id); | 88 | $this->inquiryUserSave($xp_id); |
| 85 | -// }catch (Exception $e){ | ||
| 86 | -// $this->fail('error'); | ||
| 87 | -// } | 89 | + }catch (\Exception $e){ |
| 90 | + $this->fail('error'); | ||
| 91 | + } | ||
| 88 | return $this->success(); | 92 | return $this->success(); |
| 89 | } | 93 | } |
| 90 | 94 | ||
| @@ -134,4 +138,77 @@ class InquiryInfoLogic extends BaseLogic | @@ -134,4 +138,77 @@ class InquiryInfoLogic extends BaseLogic | ||
| 134 | $inquiryUserModel = new InquiryUser(); | 138 | $inquiryUserModel = new InquiryUser(); |
| 135 | return $inquiryUserModel->add($param); | 139 | return $inquiryUserModel->add($param); |
| 136 | } | 140 | } |
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * @remark :逻辑删除 | ||
| 144 | + * @name :inquiryInfoDel | ||
| 145 | + * @author :lyh | ||
| 146 | + * @method :post | ||
| 147 | + * @time :2023/7/12 14:15 | ||
| 148 | + */ | ||
| 149 | + public function inquiryInfoDel(){ | ||
| 150 | + DB::beginTransaction(); | ||
| 151 | + try { | ||
| 152 | + $this->model->del(['id'=>$this->param['id']]); | ||
| 153 | + $inquiryUserModel = new InquiryUser(); | ||
| 154 | + $inquiryUserModel->del(['xp_id'=>$this->param['id']]); | ||
| 155 | + DB::commit(); | ||
| 156 | + }catch (\Exception $e){ | ||
| 157 | + DB::rollBack(); | ||
| 158 | + $this->fail('error'); | ||
| 159 | + } | ||
| 160 | + return $this->success(); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + /** | ||
| 164 | + * @remark :转发详情 | ||
| 165 | + * @name :inquiryForwardInfo | ||
| 166 | + * @author :lyh | ||
| 167 | + * @method :post | ||
| 168 | + * @time :2023/7/12 17:43 | ||
| 169 | + */ | ||
| 170 | + public function inquiryForwardInfo(){ | ||
| 171 | + $inquiryUserModel = new InquiryUser(); | ||
| 172 | + $info = $inquiryUserModel->read(['xp_id'=>$this->param['id']]); | ||
| 173 | + if($info === false){ | ||
| 174 | + $this->fail('error'); | ||
| 175 | + } | ||
| 176 | + return $this->success($info); | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + /** | ||
| 180 | + * @remark :导入保存数据 | ||
| 181 | + * @name :ImportInquiryInfoSave | ||
| 182 | + * @author :lyh | ||
| 183 | + * @method :post | ||
| 184 | + * @time :2023/7/13 10:59 | ||
| 185 | + */ | ||
| 186 | + public function ImportInquiryInfoSave($row){ | ||
| 187 | + $this->param = [ | ||
| 188 | + 'name'=>$row[0], | ||
| 189 | + 'email'=>$row[1], | ||
| 190 | + 'phone'=>$row[2], | ||
| 191 | + 'ip'=>$row[3], | ||
| 192 | + 'ip_area'=>$row[4], | ||
| 193 | + 'message'=>$row[5], | ||
| 194 | + 'type'=>$row[6], | ||
| 195 | + 'forward_url'=>$row[7], | ||
| 196 | + 'delay'=>$row[8], | ||
| 197 | + ]; | ||
| 198 | + $this->inquirySave(); | ||
| 199 | + return $this->success(); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + /** | ||
| 203 | + * @remark :根据国家获取随机ip | ||
| 204 | + * @name :getSearchIp | ||
| 205 | + * @author :lyh | ||
| 206 | + * @method :post | ||
| 207 | + * @time :2023/7/13 11:43 | ||
| 208 | + */ | ||
| 209 | + public function getSearchIp(){ | ||
| 210 | + $inquiryIpModel = new InquiryIP(); | ||
| 211 | + $info = $inquiryIpModel->where($this->param)->inRandomOrder()->first(); | ||
| 212 | + return $this->success($info); | ||
| 213 | + } | ||
| 137 | } | 214 | } |
app/Models/InquiryIP.php
0 → 100644
| @@ -259,6 +259,9 @@ Route::group([], function () { | @@ -259,6 +259,9 @@ Route::group([], function () { | ||
| 259 | Route::prefix('inquiry')->group(function () { | 259 | Route::prefix('inquiry')->group(function () { |
| 260 | Route::any('/', [Aside\Projects\InquiryInfoController::class, 'lists'])->name('admin.inquiry_lists'); | 260 | Route::any('/', [Aside\Projects\InquiryInfoController::class, 'lists'])->name('admin.inquiry_lists'); |
| 261 | Route::any('/save', [Aside\Projects\InquiryInfoController::class, 'save'])->name('admin.inquiry_save'); | 261 | Route::any('/save', [Aside\Projects\InquiryInfoController::class, 'save'])->name('admin.inquiry_save'); |
| 262 | + Route::any('/forwardInfo', [Aside\Projects\InquiryInfoController::class, 'forwardInfo'])->name('admin.inquiry_forwardInfo'); | ||
| 263 | + Route::any('/importInquirySave', [Aside\Projects\InquiryInfoController::class, 'importInquirySave'])->name('admin.inquiry_importInquirySave'); | ||
| 264 | + Route::any('/getSearchIpInfo', [Aside\Projects\InquiryInfoController::class, 'getSearchIpInfo'])->name('admin.inquiry_getSearchIpInfo'); | ||
| 262 | }); | 265 | }); |
| 263 | }); | 266 | }); |
| 264 | 267 |
-
请 注册 或 登录 后发表评论