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
dc0dc70b
Commit
dc0dc70b
authored
Sep 15, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add place_order_goods_list api
parent
ce7a1bc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
Goods.php
application/modules/Goods/controllers/Goods.php
+11
-0
GoodsService.php
application/services/goods/GoodsService.php
+65
-0
No files found.
application/modules/Goods/controllers/Goods.php
View file @
dc0dc70b
...
@@ -349,4 +349,15 @@ class GoodsController extends Base
...
@@ -349,4 +349,15 @@ class GoodsController extends Base
$res
=
GoodsSnapshotsService
::
goodsSnapshots
(
$this
->
params
);
$res
=
GoodsSnapshotsService
::
goodsSnapshots
(
$this
->
params
);
$this
->
success
([
"result"
=>
$res
]);
$this
->
success
([
"result"
=>
$res
]);
}
}
/**
* 下单时获取商品数据 sku and spu
* @throws Exception
*/
public
function
place_order_goods_listAction
()
{
$params
=
$this
->
params
;
$data
=
GoodsService
::
getPlaceOrderGoodsList
(
$params
);
$this
->
success
([
"result"
=>
$data
]);
}
}
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
dc0dc70b
...
@@ -1974,4 +1974,69 @@ class GoodsService
...
@@ -1974,4 +1974,69 @@ class GoodsService
}
}
return
$data
;
return
$data
;
}
}
/**
* 下单时获取商品数据
* @param array $params
* @return array
*/
public
static
function
getPlaceOrderGoodsList
(
$params
)
{
if
(
!
$goodsSkuList
=
self
::
getPlaceOrderGoodsSkuList
(
$params
))
{
return
[];
}
$goodsSpuList
=
self
::
getGoodsSpuList
([
'goods_spu_id'
=>
array_column
(
$goodsSkuList
,
'goods_spu_id'
)]);
$goodsSpuList
=
array_column
(
$goodsSpuList
,
null
,
'goods_spu_id'
);
$goodsSkuData
=
[];
foreach
(
$goodsSkuList
as
$goodsInfo
)
{
if
(
!
empty
(
$goodsSpuList
[
$goodsInfo
[
'goods_spu_id'
]]))
{
$goodsSpuInfo
=
$goodsSpuList
[
$goodsInfo
[
'goods_spu_id'
]];
$goodsSkuData
[]
=
[
'goods_sku_id'
=>
$goodsInfo
[
'goods_sku_id'
],
'goods_spu_id'
=>
$goodsInfo
[
'goods_spu_id'
],
'goods_version'
=>
$goodsInfo
[
'goods_version'
],
'price'
=>
$goodsInfo
[
'price'
],
'clear_price'
=>
$goodsInfo
[
'clear_price'
],
'rule_limit'
=>
$goodsInfo
[
'rule_limit'
],
'online_status'
=>
$goodsInfo
[
'online_status'
],
'inventory_rest'
=>
$goodsInfo
[
'inventory_rest'
],
'rule_refund'
=>
$goodsSpuInfo
[
'rule_refund'
],
'goods_sale_type'
=>
$goodsSpuInfo
[
'goods_sale_type'
],
'goods_type'
=>
$goodsSpuInfo
[
'goods_type'
],
'shop_id'
=>
$goodsSpuInfo
[
'shop_id'
],
'life_account_id'
=>
$goodsSpuInfo
[
'life_account_id'
]
];
}
}
return
$goodsSkuData
;
}
/**
* 下单时获取商品sku数据
* @param array $params
* @return array
*/
public
static
function
getPlaceOrderGoodsSkuList
(
$params
)
{
if
(
empty
(
$params
[
'goods_sku_id'
]))
{
return
[];
}
$goodsSkuIdList
=
[];
foreach
(
$params
[
'goods_sku_id'
]
as
$goodsSkuId
)
{
$goodsParams
=
GoodsSkuId
::
getGoodsSkuIdParams
(
$goodsSkuId
);
$goodsSkuIdList
[
$goodsParams
[
'goods_type'
]][]
=
$goodsSkuId
;
}
$goodsSkuList
=
[];
foreach
(
$goodsSkuIdList
as
$goodsType
=>
$goodsSkuIds
)
{
// 现在只有两种类型 实体,虚拟
if
(
$goodsType
==
GoodsSpu
::
TYPE_VIRTUAL
)
{
$goodsData
=
self
::
generalGetGoodsSkuList
([
'goods_sku_id'
=>
$goodsSkuIds
]);
}
else
{
$goodsData
=
self
::
generalGetPindanGoodsSkuList
([
'goods_sku_id'
=>
$goodsSkuIds
]);
}
$goodsSkuList
=
array_merge
(
$goodsSkuList
,
$goodsData
);
}
return
$goodsSkuList
;
}
}
}
\ 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