<?php
namespace app\admin\controller\index;

use app\admin\controller\BaseController;
use app\admin\server\index\ActivityServer;

class Activity extends BaseController
{

    /**
     * Notes:获取活动列表
     * @return \support\Response
     * User: YCP
     * Date: 2023/2/23
     */
    public function getActivityList()
    {
        [$page, $limit] = $this->getPage();
        $keywords = $this->request->get('keywords');
        $result         = ActivityServer::getActivityList($page, $limit, $keywords);
        return json_success($result, '成功');
    }


    /**
     * Notes:修改套餐项目
     * @return \support\Response
     * User: YCP
     * Date: 2022/10/18
     */
    public function updateActivity()
    {
        $params    = $this->request->post();
        $admin_id  = $this->request->admin_id;
        /*$this->validateCheck('life\PackageGoodsValidate',
            [
                'goods_id'        => $params['goods_id']?? '',
                'package_id'           => $params['package_id']?? '',
                'goods_name'      => $params['goods_name']?? '',
                'goods_num'     => $params['goods_num']?? '',
                'goods_price'    => $params['goods_price']?? '',
                'goods_weigh'   => $params['goods_weigh']?? '',
            ],
            'update');*/
        $result       = ActivityServer::updateActivity($params, $admin_id);
        return json_success($result, '修改成功');

    }

    /**
     * Notes:删除套餐项目
     * @return \support\Response
     * User: YCP
     * Date: 2022/10/18
     */
    public function delActivity()
    {
        $config_id = $this->request->get('config_id');
        $admin_id = $this->request->admin_id;
        //$this->validateCheck('life\PackageGoodsValidate', ['goods_id' => $goods_id], 'info');
        $result         = ActivityServer::delActivity($config_id,$admin_id);
        if ($result){
            return json_success($result, '删除成功');
        }else{
            throw new \Exception('删除失败！');
        }

    }

    /**
     * Notes:添加套餐项目
     * @return \support\Response
     * User: YCP
     * Date: 2022/10/18
     */
    public function addActivity()
    {
        
        $params    = $this->request->post();
        $admin_id  = $this->request->admin_id;
        /*$this->validateCheck('life\PackageGoodsValidate',
            [
                'package_id'      => $params['package_id']?? '',
                'goods_name'      => $params['goods_name']?? '',
                'goods_num'     => $params['goods_num']?? '',
                'goods_price'    => $params['goods_price']?? '',
                'goods_weigh'   => $params['goods_weigh']?? '',
            ],
            'create');*/
        $result         = ActivityServer::insertActivity($params, $admin_id);
        return json_success($result, '添加成功');
    }

    /**
     * Notes:查询套餐项目详情
     * @return \support\Response
     * User: YCP
     * Date: 2022/10/18
     */
    public function activityInfo()
    {
        $config_id = $this->request->get('config_id');
        //$this->validateCheck('life\PackageGoodsValidate', ['goods_id' => $goods_id], 'info');
        $result         = ActivityServer::activityInfo($config_id);
        return json_success($result, '成功');
    }


}
