<?php
/**
 * Author        : Tengda
 * Date          : 2021/7/29
 * Time          : 11:12 上午
 */

use App\Base\Base;
use App\Services\marketing\TakePlaceService;
use Validate\TakePlaceValidate;

class TakeplaceController extends Base
{
    public function detailAction()
    {
        if (empty($this->params['take_place_id'])) {
            $this->success(['result'=>[]]);
        }
        $res = TakePlaceService::detail($this->params['take_place_id']);
        $this->success(['result'=>$res]);
    }

    /**
     * 批量获取自提点信息
     * @throws Exception
     */
    public function get_detail_by_idsAction()
    {
        if (empty($this->params['take_place_ids'])) {
            $this->success(['result'=>[]]);
        }
        $res = TakePlaceService::getDetailByIds($this->params['take_place_ids']);

        $this->success(['result'=>$res]);
    }
    
    /**
     * 获取自提点列表
     * http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71671761
     * @throws \App\Exception\custom\ParamException
     */
    public function listAction()
    {
        (new TakePlaceValidate())->scene('list')->validate();

        $res = TakePlaceService::searchList($this->params);

        $this->success(['result'=>$res]);
    }

    /**
     * 添加自提点
     * http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71671759
     * @throws \App\Exception\custom\ParamException
     */
    public function addAction()
    {
        (new takePlaceValidate())->scene('add')->validate();

        $res = TakePlaceService::add($this->params);
        $this->success(['status'=>$res ? 'success' : 'failed']);
    }

    /**
     * 删除自提点
     * @throws \App\Exception\custom\ParamException
     */
    public function deleteAction()
    {
        (new takePlaceValidate())->scene('delete')->validate();

        $res = TakePlaceService::delete($this->params['take_place_id']);

        $this->success(['status'=>$res ? 'success' : 'failed']);
    }

    /**
     * 获取活动绑定的自提点列表
     * @throws \App\Exception\custom\ParamException
     */
    public function get_bind_listAction()
    {
        (new takePlaceValidate())->scene('bindList')->validate();

        $data = TakePlaceService::getPindanTakePlaceList($this->params);

        $this->success(['result'=>$data]);
    }

}