<?php

namespace Home\Controller;
use OT\DataDictionary;
use Admin\Model\ApplyModel;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class DiscountController extends BaseController {

    const MODEL_NAME = 'PromoteWelfare';

    public function index($p=0){
        $map['promote_id'] = PID;
        //增加全平台福利
        $map['promote_id'] = ['in',PID.",-1,-2"];
        empty(I('game_name')) || $map['game_name'] = ['like','%'.I('game_name').'%'];
        empty(I('game_id')) || $map['game_id'] = I('game_id');
        $extend['map'] = $map;
        $this->meta_title = "我的福利";
        parent::data_lists($p,self::MODEL_NAME,$extend);
    }
    
    public function child_promote($p=0) {
        $child_promote = get_zi_promote_id(PID);
        $child_promote = $child_promote.",-1";//增加全平台福利
        if(empty($child_promote)){
            $this->display();
        }elseif(empty(I('promote_id')) || in_array(I('promote_id'),explode(',',$child_promote))){

            $map['promote_id'] = empty(I('promote_id')) ? ['in',$child_promote] : I('promote_id');

            empty(I('game_name')) || $map['game_name'] = ['like','%'.I('game_name').'%'];

            empty(I('game_id')) || $map['game_id'] = I('game_id');

            $extend['map'] = $map;
            $this->meta_title = "子渠道福利列表";
            parent::data_lists($p,self::MODEL_NAME,$extend);
        }
    }

}