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
eb6c5aa4
Commit
eb6c5aa4
authored
Sep 09, 2025
by
hj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新提交00
parent
b491f7ea
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
3 deletions
+89
-3
server/app/Http/Controllers/V1/Bhua/ProductsController.php
server/app/Http/Controllers/V1/Bhua/ProductsController.php
+33
-0
server/app/Rhawn/Repositories/Eloquent/BhuaProductRepositoryEloquent.php
...n/Repositories/Eloquent/BhuaProductRepositoryEloquent.php
+18
-0
server/app/Services/Api/BhuaProductsService.php
server/app/Services/Api/BhuaProductsService.php
+35
-0
server/app/Services/Api/RhawnProductsService.php
server/app/Services/Api/RhawnProductsService.php
+3
-3
No files found.
server/app/Http/Controllers/V1/Bhua/ProductsController.php
View file @
eb6c5aa4
...
@@ -115,6 +115,12 @@ class ProductsController extends Controller
...
@@ -115,6 +115,12 @@ class ProductsController extends Controller
*/
*/
public
function
getProductsByBrand
(
Request
$request
)
public
function
getProductsByBrand
(
Request
$request
)
{
{
$customerCode
=
$request
->
get
(
'customer_code'
);
if
(
!
$customerCode
){
return
Response
::
ok
(
'客户编号不存在!'
);
}
$this
->
checkCustomerType
(
$customerCode
,
$this
->
controllerType
);
$brandId
=
$request
->
get
(
'brandId'
);
$brandId
=
$request
->
get
(
'brandId'
);
if
(
!
$brandId
){
if
(
!
$brandId
){
return
Response
::
ok
(
'品牌id不存在!'
);
return
Response
::
ok
(
'品牌id不存在!'
);
...
@@ -133,4 +139,31 @@ class ProductsController extends Controller
...
@@ -133,4 +139,31 @@ class ProductsController extends Controller
}
}
}
}
public
function
getBrandProductDetail
(
Request
$request
)
{
$customerCode
=
$request
->
get
(
'customer_code'
);
if
(
!
$customerCode
){
return
Response
::
ok
(
'客户编号不存在!'
);
}
$this
->
checkCustomerType
(
$customerCode
,
$this
->
controllerType
);
$brandId
=
$request
->
get
(
'brandId'
);
if
(
!
$brandId
){
return
Response
::
ok
(
'品牌id不存在!'
);
}
$pCode
=
$request
->
get
(
'productCode'
);
try
{
$productDetail
=
$this
->
bhuaProdcutService
->
getBrandProductDetail
(
$brandId
,
$pCode
);
if
(
$productDetail
){
$productDetail
=
$this
->
formatKeysfromArray
(
$productDetail
,
'toCamelCase'
);
}
return
Response
::
success
(
$productDetail
,
'操作成功'
);
}
catch
(
\Throwable
$exception
){
return
$this
->
returnErrorExecptionResponse
(
$exception
,
'获取产品详情失败'
);
}
}
}
}
server/app/Rhawn/Repositories/Eloquent/BhuaProductRepositoryEloquent.php
View file @
eb6c5aa4
...
@@ -176,4 +176,22 @@ class BhuaProductRepositoryEloquent extends BaseRepository implements BhuaProduc
...
@@ -176,4 +176,22 @@ class BhuaProductRepositoryEloquent extends BaseRepository implements BhuaProduc
}
}
return
null
;
return
null
;
}
}
public
function
getProductsDetailByBrandId
(
$brandId
,
$pCode
)
{
$productsModel
=
$this
->
join
(
'chemicals'
,
'chemicals.c_id'
,
'products.c_id'
);
$productsModel
=
$productsModel
->
where
(
'products.b_id'
,
$brandId
)
->
where
(
'p_status'
,
1
)
->
where
(
'p_show'
,
1
);
if
(
!
is_array
(
$pCode
)){
$productsModel
->
where
(
'products.p_code'
,
$pCode
);
}
else
{
$productsModel
->
whereIn
(
'products.p_code'
,
$pCode
);
}
$product
=
$productsModel
->
get
();
if
(
$product
){
return
$product
->
toArray
();
}
return
null
;
}
}
}
server/app/Services/Api/BhuaProductsService.php
View file @
eb6c5aa4
...
@@ -97,6 +97,41 @@ class BhuaProductsService
...
@@ -97,6 +97,41 @@ class BhuaProductsService
}
}
}
}
public
function
getBrandProductDetail
(
$brandId
,
$pCode
)
{
if
(
!
is_numeric
(
$brandId
)){
throw
new
\Exception
(
'品牌id类型错误'
,
502
);
}
if
(
!
in_array
(
$brandId
,[
40
,
1
,
10
,
108
,
161
,
7
,
188
,
5
,
4
,
32
])){
throw
new
\Exception
(
'品牌id不在授权范围之内'
,
502
);
}
try
{
$brand
=
$this
->
bhuaProductService
->
brandsRepository
->
getBrandById
(
$brandId
);
if
(
!
$brand
){
throw
new
\Exception
(
'没找到相应品牌id'
,
502
);
}
$products
=
$this
->
bhuaProductService
->
productRepository
->
getProductsDetailByBrandId
(
$brandId
,
$pCode
);
if
(
$products
){
$products
=
app
(
ProductsTransformer
::
class
)
->
transform
(
$products
);
}
return
$products
;
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':getProductsByBrandId'
,
'error'
);
throw
$exception
;
}
}
private
function
checkCustomerExist
(
$cusCode
)
{
//查询用户是否存在
$customer
=
$this
->
bhuaCustomerService
->
getBhuaCustomerThroughtCusCode
(
$cusCode
);
if
(
!
$customer
){
throw
new
\Exception
(
'客户编号为:['
.
$cusCode
.
']的用户不存在!'
,
500
);
}
return
$customer
;
}
}
}
server/app/Services/Api/RhawnProductsService.php
View file @
eb6c5aa4
...
@@ -42,7 +42,7 @@ class RhawnProductsService
...
@@ -42,7 +42,7 @@ class RhawnProductsService
return
$dataReturn
;
return
$dataReturn
;
}
catch
(
\Throwable
$exception
){
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':
cancelCustomerOrder
'
,
'error'
);
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':
getAllProducts
'
,
'error'
);
throw
$exception
;
throw
$exception
;
}
}
}
}
...
@@ -57,7 +57,7 @@ class RhawnProductsService
...
@@ -57,7 +57,7 @@ class RhawnProductsService
}
}
return
$products
;
return
$products
;
}
catch
(
\Throwable
$exception
){
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':
cancelCustomerOrder
'
,
'error'
);
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':
getProductDetail
'
,
'error'
);
throw
$exception
;
throw
$exception
;
}
}
}
}
...
@@ -73,7 +73,7 @@ class RhawnProductsService
...
@@ -73,7 +73,7 @@ class RhawnProductsService
}
}
return
$products
;
return
$products
;
}
catch
(
\Throwable
$exception
){
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':
cancelCustomerOrder
'
,
'error'
);
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':
getProductByCas
'
,
'error'
);
throw
$exception
;
throw
$exception
;
}
}
}
}
...
...
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