<?php

use App\Base\Base;
use \App\Services\marketing\MarketingForOrderService;

class MarketingfororderController extends Base
{
    /**
     * 分销活动列表
     * @throws Exception
     */
    public function marketing_listAction()
    {
        $params = $this->params;
        $data = MarketingForOrderService::getMarketingList($params);
        $this->success(["result" => $data]);
    }

    /**
     * 分销活动的商品
     * @throws \App\Exception\custom\MarketingException
     */
    public function goods_listAction()
    {
        $params = $this->params;
        $data = MarketingForOrderService::getMarketingGoodsList($params);
        $this->success(["result" => $data]);
    }

    /**
     * 活动的自提点
     * @throws \App\Exception\custom\MarketingException
     */
    public function take_place_listAction()
    {
        $params = $this->params;

        $takePlaceList = MarketingForOrderService::getMarketingTakePlaceList($params);
        $addressList = [];
        //
        if (!empty($takePlaceList))
            $addressList =  array_values(array_unique(array_column($takePlaceList, 'address')));
        //
        $this->success(["result" => [
            'take_place_list' => $takePlaceList,
            'address_list' => $addressList
        ]]);
    }

}