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
4ceb18cd
Commit
4ceb18cd
authored
Sep 15, 2021
by
suntengda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hotfix_tuancan_slow' into pre_release
parents
a74f518a
68e76056
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
13 deletions
+57
-13
Marketing.php
application/modules/Marketing/controllers/Marketing.php
+57
-13
No files found.
application/modules/Marketing/controllers/Marketing.php
View file @
4ceb18cd
<?php
use
Api\PhpUtils\Log\FileLog
;
use
App\Base\Base
;
use
App\Services\marketing\MarketingService
;
use
App\Exception\custom\MarketingException
;
...
...
@@ -9,6 +10,7 @@ use \Validate\MarketingOnlineStatusValidate;
use
\Validate\MarketingInfoValidate
;
use
App\Models\marketing\mysql\Marketing
;
use
App\Models\marketing\mysql\MarketingPindan
;
use
Api\PhpUtils\Redis\RedisUtil
;
class
MarketingController
extends
Base
{
...
...
@@ -186,18 +188,56 @@ class MarketingController extends Base
$marketingIdsPrepare
=
array_keys
(
$list
[
'prepare'
]);
//已结束的 按结束时间倒序
$this
->
params
[
'page'
]
=
1
;
$this
->
params
[
'page_size'
]
=
10
;
$this
->
params
[
'sort_field'
]
=
'end_time'
;
$this
->
params
[
'sort_type'
]
=
'desc'
;
$this
->
params
[
'need_buy_num'
]
=
false
;
$this
->
params
[
'online_status'
]
=
[
Marketing
::
ONLINE_STATUS_QIDONG
,
Marketing
::
ONLINE_STATUS_GUANBI
,
Marketing
::
ONLINE_STATUS_DAOQI
];
//状态 , 1启用,2关闭,3 到期
$this
->
params
[
'activity_status'
]
=
MarketingPindan
::
ACTIVITY_STATUS_FINISHED
;
//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list
[
'end'
]
=
MarketingService
::
marketingList
(
$this
->
params
)[
'result'
];
$list
[
'end'
]
=
$list
[
'end'
]
?
array_column
(
$list
[
'end'
],
null
,
'marketing_id'
)
:
[];
$marketingIdsEnd
=
array_keys
(
$list
[
'end'
]);
$list
[
'end'
]
=
$this
->
getTuanCanEndList
();
$marketingIds
=
array_merge
(
$marketingIdsDoing
,
$marketingIdsPrepare
);
$list
=
$this
->
_fillSkuAndOrderInfo
(
$marketingIds
,
$list
);
$list
[
'life_account_id'
]
=
MarketingService
::
getPublicLifeAccountId
();
$this
->
success
([
'result'
=>
$list
]);
}
private
function
getTuanCanEndList
(){
try
{
$redis
=
RedisUtil
::
getInstance
(
'cache'
,[
'serializer'
=>
'php'
]);
$key
=
"tuancan_end_list_"
.
date
(
'Ymd'
);
$list
[
'end'
]
=
$redis
->
get
(
$key
);
if
(
empty
(
$list
[
'end'
]))
{
$this
->
params
[
'page'
]
=
1
;
$this
->
params
[
'page_size'
]
=
10
;
$this
->
params
[
'sort_field'
]
=
'end_time'
;
$this
->
params
[
'sort_type'
]
=
'desc'
;
$this
->
params
[
'need_buy_num'
]
=
false
;
$this
->
params
[
'online_status'
]
=
[
Marketing
::
ONLINE_STATUS_QIDONG
,
Marketing
::
ONLINE_STATUS_GUANBI
,
Marketing
::
ONLINE_STATUS_DAOQI
];
//状态 , 1启用,2关闭,3 到期
$this
->
params
[
'activity_status'
]
=
MarketingPindan
::
ACTIVITY_STATUS_FINISHED
;
//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list
[
'end'
]
=
MarketingService
::
marketingList
(
$this
->
params
)[
'result'
];
$list
[
'end'
]
=
$list
[
'end'
]
?
array_column
(
$list
[
'end'
],
null
,
'marketing_id'
)
:
[];
$marketingIdsEnd
=
array_keys
(
$list
[
'end'
]);
$list
=
$this
->
_fillSkuAndOrderInfo
(
$marketingIdsEnd
,
$list
);
$redis
->
set
(
$key
,
json_encode
(
$list
[
'end'
]),[
'ex'
=>
86400
]);
//已结束列表 缓存一天
}
else
{
$list
[
'end'
]
=
json_decode
(
$list
[
'end'
],
true
);
}
}
catch
(
Exception
$e
)
{
FileLog
::
error
(
"获取团餐已结束列表异常"
,
$e
->
getMessage
(),
''
,
'suntengda@yidian-inc.com'
);
}
$marketingIds
=
array_merge
(
$marketingIdsDoing
,
$marketingIdsPrepare
,
$marketingIdsEnd
);
return
$list
[
'end'
]
??
[];
}
/**
* 给列表填充sku和订单相关信息
* @param $marketingIds
* @param $list
* @return mixed
* @throws \App\Exception\custom\InterfaceException
*/
private
function
_fillSkuAndOrderInfo
(
$marketingIds
,
$list
)
{
//获取活动的sku列表
$skuList
=
MarketingService
::
getGoodsSkuListByMarketingIds
(
$marketingIds
);
//获取活动支付用户列表
...
...
@@ -216,10 +256,14 @@ class MarketingController extends Base
$listPart
=
array_values
(
$listPart
);
}
unset
(
$listPart
);
$list
[
'life_account_id'
]
=
MarketingService
::
getPublicLifeAccountId
();
$this
->
success
([
'result'
=>
$list
])
;
return
$list
;
}
/**
* 切换活动状态
* @throws \App\Exception\custom\ParamException
...
...
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