Commit f7a3b1ef authored by suntengda's avatar suntengda

add app内团餐列表接口

parent 6316744f
......@@ -7,6 +7,8 @@ use App\Services\marketing\MarketingGoodsService;
use \Validate\MarketingGoodsRateValidate;
use \Validate\MarketingOnlineStatusValidate;
use \Validate\MarketingInfoValidate;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingPindan;
class MarketingController extends Base
{
......@@ -155,4 +157,63 @@ class MarketingController extends Base
$this->success();
}
/**
* app内团餐活动列表
* @throws \App\Exception\custom\InterfaceException
*/
public function tuancan_listAction()
{
$this->params['marketing_type'] = Marketing::MARKETING_TYPE_PINDAN;//1分销 2团购 3秒杀 4团餐
$this->params['online_status'] = Marketing::ONLINE_STATUS_QIDONG;//状态 , 1启用,2关闭,3 到期
$this->params['from'] = 1;//1 小程序前台 默认0 后台
//正在进行中的
$this->params['sort_field'] = 'end_time';
$this->params['sort_type'] = 'asc';
$this->params['need_buy_num'] = false;
$this->params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS;//1 未开始,2进行中,3已结束
$list['doing'] = MarketingService::marketingList($this->params)['result'];
$list['doing'] = $list['doing'] ? array_column($list['doing'], null, 'marketing_id') : [];
$marketingIdsDoing = array_keys($list['doing']);
//当天即将开始的
$this->params['page'] = 1;
$this->params['sort_field'] = 'end_time';
$this->params['sort_type'] = 'asc';
$this->params['need_buy_num'] = false;
$this->params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_START_TODAY;//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list['prepare'] = MarketingService::marketingList($this->params)['result'];
$list['prepare'] = $list['prepare'] ? array_column((array)$list['prepare'], null, 'marketing_id') : [];
$marketingIdsPrepare = array_keys($list['prepare']);
//已结束的
$this->params['page'] = 1;
$this->params['sort_field'] = 'end_time';
$this->params['sort_type'] = 'desc';
$this->params['need_buy_num'] = false;
$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']);
$marketingIds = array_merge($marketingIdsDoing, $marketingIdsPrepare, $marketingIdsEnd);
//获取活动的sku列表
$skuList = MarketingService::getGoodsSkuListByMarketingIds($marketingIds);
//获取活动支付用户列表
$orderUser = MarketingService::getMarketingOrderUser(['marketing_id' => $marketingIds]);
//获取活动支付用户数
$buyNum = MarketingService::getHaveBuyGoodsUserCount(['marketing_id' => $marketingIds]);
//组合sku和order信息
foreach ($list as &$listPart) {
foreach ($listPart as $marketingId => &$value) {
$value['sku_list'] = $skuList[$marketingId] ?? [];
$value['order_user'] = $orderUser[$marketingId] ?? [];
$value['participate_number'] = $buyNum[$marketingId] ?? 0;
}
unset($value);
}
unset($listPart);
$this->success(['result' => $list]);
}
}
\ No newline at end of file
......@@ -1083,11 +1083,6 @@ class MarketingService
return $marketing_list;
}
public static function tuancanList($params)
{
}
/**
* 获取多个活动的商品列表
* @param $marketingIds
......@@ -1140,6 +1135,26 @@ class MarketingService
return $list;
}
/**
* 获取活动支付用户列表
* @param $params
* @return array|mixed
* @throws InterfaceException
*/
public static function getMarketingOrderUser($params)
{
$url = config('interface', 'order.marketing.marketing_user');
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;
}
/**
*判断长度
*
......
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