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
83829666
Commit
83829666
authored
Aug 17, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 活动详情接口调整
parent
b3d2d4c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
MarketingService.php
application/services/marketing/MarketingService.php
+43
-0
No files found.
application/services/marketing/MarketingService.php
View file @
83829666
...
...
@@ -4,6 +4,8 @@
namespace
App\Services\marketing
;
use
Api\PhpServices\Ksy\Ks3Api
;
use
Api\PhpUtils\Http\HttpUtil
;
use
App\Exception\custom\InterfaceException
;
use
App\Models\goods\mysql\Ota
;
use
App\Models\goods\mysql\PindanGoodsSku
;
use
App\Models\marketing\mysql\Marketing
;
...
...
@@ -951,6 +953,15 @@ class MarketingService
$info
[
'marketing_info'
]
=
$marketingData
;
//有用户登录时候,当前用户购买的商品数量信息
$haveBuyGoodsStatistics
=
[];
if
(
!
empty
(
$params
[
"user_id"
]))
{
$haveBuyGoodsStatistics
=
self
::
getHaveBuyGoodsStatistics
([
"user_id"
=>
$params
[
"user_id"
],
"marketing_id"
=>
$marketingData
[
"id"
]]);
}
//活动中所有购买的商品数量信息
$allHaveBuyGoodsStatistics
=
self
::
getHaveBuyGoodsStatistics
([
"marketing_id"
=>
$marketingData
[
"id"
]]);
if
(
!
empty
(
$goodsSkuList
))
{
$otaIds
=
array_unique
(
array_column
(
$goodsSkuList
,
"ota_id"
));
$otas
=
Ota
::
select
([
"ota_id"
,
"ota_name"
],
[
"ota_id"
=>
$otaIds
]);
...
...
@@ -963,6 +974,18 @@ class MarketingService
$goodsSkuList
[
$key
][
"ota_name"
]
=
empty
(
$otasData
[
$item
[
"ota_id"
]][
"ota_name"
])
?
""
:
$otasData
[
$item
[
"ota_id"
]][
"ota_name"
];
$goodsSkuList
[
$key
][
"original_price"
]
=
empty
(
$item
[
"original_price"
])
?
''
:
sprintf
(
"%.2f"
,
(
int
)
$item
[
"original_price"
]
/
100
);
$goodsSkuList
[
$key
][
"price"
]
=
sprintf
(
"%.2f"
,
$item
[
"price"
]
/
100
);
$goodsSkuList
[
$key
][
"have_buy_goods_count"
]
=
0
;
//前端当前登录人的数据
$haveBuyGoodsSkuIds
=
array_keys
(
$haveBuyGoodsStatistics
);
if
(
in_array
(
$item
[
"goods_sku_id"
],
$haveBuyGoodsSkuIds
))
{
$goodsSkuList
[
$key
][
"have_buy_goods_count"
]
=
$haveBuyGoodsStatistics
[
$item
[
"goods_sku_id"
]];
}
//后台展示所有购买的数量
$allHaveBuyGoodsSkuIds
=
array_keys
(
$allHaveBuyGoodsStatistics
);
if
(
in_array
(
$item
[
"goods_sku_id"
],
$allHaveBuyGoodsSkuIds
))
{
$goodsSkuList
[
$key
][
"all_have_buy_goods_count"
]
=
$allHaveBuyGoodsStatistics
[
$item
[
"goods_sku_id"
]];
}
}
}
...
...
@@ -1020,4 +1043,24 @@ class MarketingService
"count"
=>
$count
]],
[]);
return
$res
[
'id_snow'
][
$type
]
??
[];
}
/**
* 指定活动的已购买商品统计
* @param array $params
* @return array|mixed
* @throws InterfaceException
*/
public
static
function
getHaveBuyGoodsStatistics
(
$params
=
[])
{
$url
=
config
(
'interface'
,
'order.order.have_buy_order_statistics'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$res
=
HttpUtil
::
get
(
$url
,
$params
);
$data
=
[];
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$data
=
$res
[
"response"
][
"result"
];
}
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