Commit 4ceb18cd authored by suntengda's avatar suntengda

Merge branch 'hotfix_tuancan_slow' into pre_release

parents a74f518a 68e76056
<?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,6 +188,24 @@ class MarketingController extends Base
$marketingIdsPrepare = array_keys($list['prepare']);
//已结束的 按结束时间倒序
$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';
......@@ -195,9 +215,29 @@ class MarketingController extends Base
$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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment