Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
2c071c87
Commit
2c071c87
authored
Jun 15, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:商品详情主要逻辑
parent
797d2748
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
2 deletions
+113
-2
GoodsInfoFeValidate.php
application/library/Validate/GoodsInfoFeValidate.php
+21
-0
GoodsInfoOpValidate.php
application/library/Validate/GoodsInfoOpValidate.php
+21
-0
Goods.php
application/modules/Goods/controllers/Goods.php
+20
-2
GoodsService.php
application/services/goods/GoodsService.php
+51
-0
No files found.
application/library/Validate/GoodsInfoFeValidate.php
0 → 100644
View file @
2c071c87
<?php
namespace
Validate
;
/**
* Class GoodsInfoFeValidate
*
* @package Validate
*/
class
GoodsInfoFeValidate
extends
BaseValidate
{
protected
$rule
=
[
'goods_sku_id'
=>
'require'
,
];
protected
$message
=
[
"goods_sku_id"
=>
"商品id不能为空"
,
];
}
\ No newline at end of file
application/library/Validate/GoodsInfoOpValidate.php
0 → 100644
View file @
2c071c87
<?php
namespace
Validate
;
/**
* Class GoodsInfoOpValidate
*
* @package Validate
*/
class
GoodsInfoOpValidate
extends
BaseValidate
{
protected
$rule
=
[
'goods_spu_id'
=>
'require'
,
];
protected
$message
=
[
"goods_spu_id"
=>
"商品id不能为空"
,
];
}
\ No newline at end of file
application/modules/Goods/controllers/Goods.php
View file @
2c071c87
...
@@ -7,6 +7,8 @@ use \Validate\CheckGoodsNameValidate;
...
@@ -7,6 +7,8 @@ use \Validate\CheckGoodsNameValidate;
use
\Validate\GoodsAuditValidate
;
use
\Validate\GoodsAuditValidate
;
use
\Validate\GoodsAddValidate
;
use
\Validate\GoodsAddValidate
;
use
\Validate\GoodsEditValidate
;
use
\Validate\GoodsEditValidate
;
use
\Validate\GoodsInfoOpValidate
;
use
\Validate\GoodsInfoFeValidate
;
class
GoodsController
extends
Base
class
GoodsController
extends
Base
...
@@ -45,11 +47,27 @@ class GoodsController extends Base
...
@@ -45,11 +47,27 @@ class GoodsController extends Base
}
}
/**
/**
* 商品详情
*
后台
商品详情
*/
*/
public
function
infoAction
()
public
function
info
_op
Action
()
{
{
(
new
GoodsInfoOpValidate
())
->
validate
();
$params
=
$this
->
params
;
$data
=
GoodsService
::
getGoodsSpuInfo
(
$params
);
$this
->
success
([
"data"
=>
$data
]);
}
/**
* 前端商品详情
*/
public
function
info_feAction
()
{
(
new
GoodsInfoFeValidate
())
->
validate
();
$params
=
$this
->
params
;
$data
=
GoodsService
::
getGoodsSkuInfo
(
$params
);
$this
->
success
([
"data"
=>
$data
]);
}
}
/**
/**
...
...
application/services/goods/GoodsService.php
View file @
2c071c87
...
@@ -421,4 +421,55 @@ class GoodsService
...
@@ -421,4 +421,55 @@ class GoodsService
}
}
return
GoodsSku
::
save
(
$skuParams
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
return
GoodsSku
::
save
(
$skuParams
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
}
}
/**
* 后台用商品详情
* @param array $params
* @return array
* @throws GoodsException
*/
public
static
function
getGoodsSpuInfo
(
$params
=
[])
{
$data
=
[];
$goodsSpuId
=
$params
[
"goods_spu_id"
];
$goodsSpu
=
GoodsSpu
::
get
(
"*"
,
[
"goods_spu_id"
=>
$goodsSpuId
]);
if
(
empty
(
$goodsSpu
))
{
throw
new
GoodsException
([
"cus"
=>
15
]);
}
$goodsSkuList
=
GoodsSku
::
select
(
"*"
,
[
"goods_spu_id"
=>
$goodsSpuId
]);
//当前这里一个spu对应一个sku
if
(
!
empty
(
$goodsSkuList
))
{
foreach
(
$goodsSkuList
as
$key
=>
$sku
)
{
//todo::图片处理,门店,套餐,生活号信息
$data
[
"goods_info"
]
=
$sku
;
}
}
$recordList
=
GoodsOperationRecord
::
select
(
"*"
,
[
"goods_spu_id"
=>
$goodsSpuId
]);
if
(
!
empty
(
$recordList
))
{
//todo::处理展示内容
$data
[
"record_list"
]
=
$recordList
;
}
return
$data
;
}
/**
* 商品sku详情
* @param array $params
* @return array
* @throws GoodsException
*/
public
static
function
getGoodsSkuInfo
(
$params
=
[])
{
$data
=
[];
$goodsSkuId
=
$params
[
"goods_sku_id"
];
$goodsSku
=
GoodsSku
::
get
(
"*"
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
if
(
empty
(
$goodsSku
))
{
throw
new
GoodsException
([
"cus"
=>
15
]);
}
//todo::处理展示内容
$data
[
"goods_info"
]
=
$goodsSku
;
return
$data
;
}
}
}
\ No newline at end of file
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