Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
154ba0cd
Commit
154ba0cd
authored
Jun 16, 2025
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新提交
parent
2b7f9efb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
54 deletions
+60
-54
server/app/Http/Controllers/V1/Auth/Chemsite/CompanyAuthController.php
...tp/Controllers/V1/Auth/Chemsite/CompanyAuthController.php
+1
-1
server/app/Http/Controllers/V1/Chemicals/MsdsController.php
server/app/Http/Controllers/V1/Chemicals/MsdsController.php
+44
-46
server/app/Services/Api/ChemicalsMsdsService.php
server/app/Services/Api/ChemicalsMsdsService.php
+14
-6
server/app/Services/AuthService.php
server/app/Services/AuthService.php
+1
-1
No files found.
server/app/Http/Controllers/V1/Auth/Chemsite/CompanyAuthController.php
View file @
154ba0cd
...
...
@@ -70,7 +70,7 @@ class CompanyAuthController extends Controller
{
$message
=
[
'companyToken.required'
=>
"公司token必传"
,
'cusNumber.required'
=>
"客户编号必传"
,
//
'cusNumber.required' => "客户编号必传",
];
$this
->
validateRequest
(
$request
,
$message
);
...
...
server/app/Http/Controllers/V1/Chemicals/MsdsController.php
View file @
154ba0cd
...
...
@@ -15,22 +15,13 @@ use App\Exceptions\ServerRunTimeException;
use
App\Rhawn\Services\Chemsite\ChemsiteCompanyService
;
use
App\Services\Api\ChemicalsMsdsService
;
use
App\Services\Api\Chemsite\ChemsiteCustomerService
;
use
App\Services\Api\RhawnOrdersService
;
use
App\Services\CustomerService
;
use
App\Services\FileService
;
use
Illuminate\Http\Request
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
use
App\Http\Controllers\V1\Controller
;
use
App\Support\Traits\Helpers
;
use
OpenApi\Annotations\Post
;
use
OpenApi\Annotations\RequestBody
;
use
OpenApi\Annotations\MediaType
;
use
OpenApi\Annotations\Schema
;
use
OpenApi\Annotations\Property
;
use
OpenApi\Annotations\Response
as
AnnotationResponse
;
use
OpenApi\Annotations
as
OA
;
class
MsdsController
extends
Controller
{
use
Helpers
;
...
...
@@ -42,51 +33,58 @@ class MsdsController extends Controller
public
function
getMsds
(
Request
$request
)
{
$companyCode
=
$request
->
get
(
'company_code'
);
$cusNumber
=
$request
->
get
(
'cus_number'
);
if
(
!
$companyCode
){
return
Response
::
ok
(
'验证失败,参数缺少!'
);
}
try
{
$companyCode
=
$request
->
get
(
'company_code'
);
$cusNumber
=
$request
->
get
(
'cus_number'
);
$companyInfo
=
app
(
ChemsiteCompanyService
::
class
)
->
getCompanyThroughCusCode
(
$companyCode
);
if
(
!
$companyInfo
){
throw
new
ServerRunTimeException
(
'经销商不存在'
);
}
if
(
$cusNumber
){
$customer
=
app
(
ChemsiteCustomerService
::
class
)
->
getCustomerByNumber
(
$cusNumber
);
if
(
!
$customer
){
throw
new
ServerRunTimeException
(
'客户不存在'
);
$params
=
$this
->
formatKeysfromArray
(
$request
->
all
(),
'toUnderScore'
);
$cas
=
$params
[
'cas'
];
$msdsType
=
$params
[
'msds_type'
];
if
(
!
$companyCode
){
return
Response
::
ok
(
'验证失败,参数缺少!'
);
}
if
(
!
$cas
){
return
Response
::
ok
(
'验证失败,缺少cas参数!'
);
}
if
(
!
$msdsType
){
return
Response
::
ok
(
'验证失败,缺少msds类型参数!'
);
}
}
if
(
$customer
[
'com_id'
]
!=
$companyInfo
[
'com_id'
]){
throw
new
ServerRunTimeException
(
'不是该经销商的客户'
);
}
$platformCompanyInfo
=
app
(
CustomerService
::
class
)
->
getPlatformCustomer
([
'cus_number'
=>
$companyCode
]);
$this
->
chemicalsMsdsService
->
getMsds
(
'270912-72-6'
,
'cn'
,
$platformCompanyInfo
);
if
(
!
in_array
(
$msdsType
,
[
'cn'
,
'en'
])){
return
Response
::
ok
(
'验证失败,获取类型错误!'
);
}
$companyInfo
=
app
(
ChemsiteCompanyService
::
class
)
->
getCompanyThroughCusCode
(
$companyCode
);
if
(
!
$companyInfo
){
throw
new
ServerRunTimeException
(
'经销商不存在'
);
}
if
(
$cusNumber
){
$customer
=
app
(
ChemsiteCustomerService
::
class
)
->
getCustomerByNumber
(
$cusNumber
);
if
(
!
$customer
){
throw
new
ServerRunTimeException
(
'客户不存在'
);
}
if
(
$customer
[
'com_id'
]
!=
$companyInfo
[
'com_id'
]){
throw
new
ServerRunTimeException
(
'不是该经销商的客户'
);
}
}
$customerCode
=
$request
->
get
(
'customer_code'
);
$companyCode
=
$request
->
get
(
'company_code'
);
$cusNumber
=
$request
->
get
(
'cus_number'
);
if
(
!
$companyCode
){
return
Response
::
ok
(
'验证失败,参数缺少!'
);
}
if
(
!
$customerCode
){
return
Response
::
ok
(
'客户编号不存在!'
);
$platformCompanyInfo
=
app
(
CustomerService
::
class
)
->
getPlatformCustomer
([
'cus_number'
=>
$companyCode
]);
$pdf
=
$this
->
chemicalsMsdsService
->
getMsds
(
$cas
,
$msdsType
,
$platformCompanyInfo
);
return
Response
::
success
(
$this
->
formatKeysfromArray
([
'download'
=>
$pdf
]),
'操作成功'
);
}
catch
(
\Throwable
$exception
){
return
$this
->
returnErrorExecptionResponse
(
$exception
,
'获取msds失败'
);
}
$this
->
checkCustomerType
(
$customerCode
,
$this
->
controllerType
);
}
$requestParams
=
$this
->
formatKeysfromArray
(
$request
->
all
(),
'toUnderScore'
);
$requestParams
=
array_merge
(
$requestParams
,[
'customer_code'
=>
$customerCode
]);
public
function
downloadFile
(
$path
)
{
try
{
$orderList
=
$this
->
rhawnOrdersService
->
getCustomerRhawnOrdersList
(
$requestParams
);
if
(
$orderList
){
$orderList
=
$this
->
formatKeysfromArray
(
$orderList
,
'toCamelCase'
);
}
return
Response
::
success
(
$orderList
,
'操作成功'
);
ob_end_clean
();
return
app
(
FileService
::
class
)
->
download
(
$path
);
}
catch
(
\Throwable
$exception
){
return
$this
->
returnErrorExecptionResponse
(
$exception
,
'获取订单列表失败'
);
$this
->
returnErrorExecptionResponse
(
$exception
);
}
}
...
...
server/app/Services/Api/ChemicalsMsdsService.php
View file @
154ba0cd
...
...
@@ -12,6 +12,12 @@ class ChemicalsMsdsService
public
function
getMsds
(
$cas
,
$type
=
null
,
$comInfo
=
null
)
{
$fileService
=
app
(
FileService
::
class
);
$msdPdf
=
$fileService
->
getFileListByModelData
(
$comInfo
[
'cus_type'
]
.
'_'
.
$cas
.
'_msds'
,
$comInfo
[
'cus_number'
]);
if
(
$msdPdf
){
return
$fileService
->
getDownloadUrl
(
current
(
$msdPdf
)[
'uniqueid'
]);
}
$findResult
=
shell_exec
(
'find '
.
env
(
'MSDS_FILE_DIR'
)
.
' -iname \''
.
$cas
.
'\' -print'
);
if
(
is_null
(
$findResult
)){
return
null
;
...
...
@@ -31,10 +37,8 @@ class ChemicalsMsdsService
$this
->
getPdfApp
()
->
render
();
$pdf
=
$this
->
getPdfApp
()
->
output
();
$fileService
=
app
(
FileService
::
class
);
if
(
$pdf
){
$fileName
=
$cas
.
'/'
.
$cas
.
'_msds.pdf'
;
$fileName
=
$cas
.
'/'
.
$comInfo
[
'cus_number'
]
.
'_'
.
$cas
.
'_'
.
$comInfo
[
'cus_type'
]
.
'_msds.pdf'
;
$realPath
=
$fileService
->
getFileFolderPath
()
.
'/'
.
$fileName
;
if
(
$fileService
->
saveToFile
(
$realPath
,
$pdf
)){
$fileSave
=
[];
...
...
@@ -45,11 +49,15 @@ class ChemicalsMsdsService
$fileSave
[
'extension'
]
=
'pdf'
;
$fileSave
[
'mime_type'
]
=
'application/pdf'
;
$fileSave
[
'byte_size'
]
=
''
;
$fileSave
[
'model_name'
]
=
$cas
.
'_msds'
;
$fileSave
[
'model_data_id'
]
=
1
;
$fileService
->
saveFileRecord
(
$fileSave
);
$fileSave
[
'model_name'
]
=
$comInfo
[
'cus_type'
]
.
'_'
.
$cas
.
'_msds'
;
$fileSave
[
'model_data_id'
]
=
$comInfo
[
'cus_number'
];
if
(
$fileService
->
saveFileRecord
(
$fileSave
)){
return
$fileService
->
getDownloadUrl
(
$fileSave
[
'uniqueid'
]);
}
}
}
}
return
null
;
}
}
server/app/Services/AuthService.php
View file @
154ba0cd
...
...
@@ -44,7 +44,7 @@ class AuthService
$platformCustomer
=
current
(
$platformCustomer
->
toArray
());
if
(
$platformCustomer
[
'cus_type'
]
==
'chemsite'
){
$token
[
'company_token'
]
=
$requestParams
[
'customer_token'
];
$token
[
'cus_number'
]
=
$requestParams
[
'cus_number'
];
$token
[
'cus_number'
]
=
$requestParams
[
'cus_number'
]
??
''
;
}
else
{
$token
[
'customer_token'
]
=
$requestParams
[
'customer_token'
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment