<?php

use App\Base\Base;
use App\Services\Marketing\MarketingService;
use App\Exception\custom\MarketingException;
class MarketingController extends Base
{
    
    /**
     * 营销列表
     * 后台管理
     *
     */
    public function marketing_listAction()
    {
        $params = $this->params;
        $distributionList = MarketingService::marketingList($params);
        $this->success($distributionList);
    }

    /**
     * 添加团长
     * 后台管理
     *
     */
    public function add_marketingAction()
    {
        $params = $this->params;
        $addMarketing = MarketingService::addMarketing($params);
        if (!empty($addMarketing)) {
             $this->success();
        }
    }



    /**
     * 更新数据
     * 后台管理
     *
     */
    public function update_marketingAction()
    {
        $params = $this->params;

        $where['marketing_id'] = !empty($params['marketing_id']) ? $params['marketing_id'] : '';
        $param = [];
        if (empty($where['marketing_id'])) {
             throw new MarketingException(['cus' => 6]);
        }
        
        if (!empty($params['audit_status'])) {
            $param['audit_status'] = $params['audit_status'];
        }

        if (!empty($params['audit_user_name'])) {
            $param['audit_user_name'] = $params['audit_user_name'];
        }
         
        $srt = MarketingService::updateMarketing($param,$where);

        if (!empty($srt)) {
            $this->success();
        }else{
            throw new MarketingException(['cus' => 7]);
        }
    }
       
    
    /**
     * 获取详情数据
     * 后台管理
     *
     */
    public function marketing_infoAction()
    {
        $params = $this->params;
        $marketingInfo = MarketingService::marketingInfo($params);
        $this->success(['result' => $marketingInfo]);
    }
    

}