1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153 |
- <?php
- namespace Cas\Controller\Admin\Activity;
- use Cas\Module\Lottery;
- use Cas\Dao\PlatformBulletin;
- use KIF\Core\Request;
- use Cas\Dao\LotteryEvents;
- use Cas\Controller\Admin\Controller;
- use Cas\Dao\Platform;
- use KIF\Core\Config;
- use Cas\Dao\LotteryPrize;
- use Cas\Dao\LotteryEventsVote;
- use Cas\Dao\LotteryEventsCodeData;
- use KIF\String\Filter;
- use KIF\Page\Page;
- use Cas\Module\LotteryDraw;
- use KIF\Cache\Memcached;
- use KIF\Dao\SqlHelper;
- /**
- * ["活动相关" - "互动设置" ]
- * 页面: 显示&修改 doPageShow
- *
- * @author lihuanchun
- *
- * 表单设置 [模板]
- * 事件:
- * 1.修改 doReqUpForm
- *
- * 奖项设置 [模板]
- * 事件:
- * 1.添加奖项 doReqAddPrize
- * 2.修改奖项 doReqUpPrize
- * 3.加减奖项数量
- * 3.1 增加奖项数量[虚拟,实物] doReqAddPrizeNum
- * 3.2 减少奖项数量[实物] doReqMinusPrizeNum
- *
- * 投票设置 [模板]
- * 事件:
- * 1.初始化 投票属性 图片类|| 文字类 doReqInitVote
- * 2.创建一个投票项 doReqCreateOneVote
- * 3.修改一个投票项 doUpOneVote
- *
- * 获奖数据列表 [模板]
- * 页面:PageLotteryDataList&events_id= (prize_id= )
- *
- * 券设置 [模板]
- * 事件:
- * 1.修改 券名称||券图片 doReqUpCode
- * 2.添加券 doReqEventCode
- */
- class SetInteractive extends Controller {
- private $objLottery; // 活动后端
- private $operatorData;
- private $showActivityTypeArr; // 当前页面包含的活动
-
- /**
- * 初始化
- */
- public function __construct() {
- header ( "Content-Type: text/html; charset=utf-8" );
- $this->objLottery = new Lottery ();
- $this->operatorData = $this->getUser ();
-
- # 能在当前页面显示的活动
- $this->showActivityTypeArr = array(
- LotteryEvents::TYPE_EVENTS_TURNTABLE,
- LotteryEvents::TYPE_EVENTS_SCRATCH,
- LotteryEvents::TYPE_EVENTS_LETTERS,
- LotteryEvents::TYPE_EVENTS_TRY,
- LotteryEvents::TYPE_EVENTS_VOTE,
- LotteryEvents::TYPE_EVENTS_INVITATION,
- LotteryEvents::TYPE_EVENTS_CODE,
- LotteryEvents::TYPE_EVENTS_OTHER,
- LotteryEvents::TYPE_EVENTS_SURVEY,
- );
-
- $events_id = isset($_REQUEST['events_id'])?$_REQUEST['events_id'] : null;
- if($events_id){
- $this->setNowUpPage($events_id, 'Interactive');
- }
-
- }
-
- /**
- * 默认
- */
- public function doDefault() {
- }
-
- /**
- * 页面: 显示&修改
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=PageShow&events_id=nnn
- * 参数: events_id 活动ID
- */
- public function doPageShow() {
- $events_id = Request::g ( 'events_id' );
- $events_Data = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
- // lsm_ep($events_Data);
-
- // 载入修改页面需要用到的配置
- $eventsDeliveryType = LotteryEvents::getDeliveryType (); // // [活动] 发货状态
- $eventsAuthorize = LotteryEvents::getAuthorize (); // [活动] 授权
- $eventsDisplayStatus = LotteryEvents::getDisplay (); // [活动] 是否显示
- $eventsTwoDimensionalCodeType = LotteryEvents::getTwoDimensionalCodeType (); // [领券活动] 是否是二维码输出 类型
- $eventsTypeData = LotteryEvents::getType (); // [活动] 类型
- $eventsBigTypeConfig = LotteryEvents::getBigTypeConfig (); // [活动] 大类
- $eventsFormRegular = $this->formRegular (); // [活动] 表单
- $prizeDisplay = LotteryPrize::getDisplay (); // [奖项] 显示状态
- $prizeExpress = LotteryPrize::getExpress (); // [奖项] 是否需要快递
- $prizeType = LotteryPrize::getType (); // [奖项] 类型
- $voteType = LotteryEvents::getVoteType();
-
- // 投票
- $voteData = null;
- if ($events_Data ['events'] ['type'] == \Cas\Dao\LotteryEvents::TYPE_EVENTS_VOTE) {
- $objDLotteryEventsVote = new LotteryEventsVote ();
- $voteData = $objDLotteryEventsVote->getThisEventData ( $events_id );
- }
-
- // 领码
- if ($events_Data ['events'] ['type'] == \Cas\Dao\LotteryEvents::TYPE_EVENTS_CODE) {
- $voteData = null;
- $objEventsCodeData = new LotteryEventsCodeData ();
- $useCodeDataNum = $objEventsCodeData->getEventsUseCodeDataNum ( $events_id );
- $codeDataNum = $objEventsCodeData->getEventsCodeDataNum ( $events_id );
- $this->setOutput ( 'codeDataNum', $codeDataNum );
- $this->setOutput ( 'useCodeDataNum', $useCodeDataNum );
- }
-
-
- $objMemcached = new Memcached();
- $objMLotteryDraw = new LotteryDraw(null,$events_id);
- foreach($events_Data['prize'] as $key=> $prize){
- $lottery_prize_draw_next_time_key = $objMLotteryDraw->getCacheKeyOfNextWinTime($key);
- $events_Data['prize'][$key]['nextTime'] = $objMemcached->get($lottery_prize_draw_next_time_key);
- }
-
-
-
- if ($events_Data['events']['forms']) {
- foreach ($events_Data['events']['forms'] as $tmpkey => $tmpval) {
- if ($tmpval['type'] == 'select') {
- $events_Data['events']['forms'][$tmpkey]['options'] = implode("\n", $tmpval['options']);
- }
- }
- }
-
- $this->setOutput ( 'eventsDeliveryType', $eventsDeliveryType );
- $this->setOutput ( 'eventsAuthorize', $eventsAuthorize );
- $this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
- $this->setOutput ( 'eventsTwoDimensionalCodeType', $eventsTwoDimensionalCodeType );
- $this->setOutput ( 'eventsTypeData', $eventsTypeData );
- $this->setOutput('typeData', $eventsTypeData);
- $this->setOutput ( 'eventsBigTypeConfig', $eventsBigTypeConfig );
- $this->setOutput ( 'eventsFormRegular', $eventsFormRegular );
- $this->setOutput ( 'prizeDisplay', $prizeDisplay );
- $this->setOutput ( 'prizeExpress', $prizeExpress );
- $this->setOutput ( 'prizeType', $prizeType );
- $this->setOutput('events_Data', $events_Data);
- $this->setOutput('eventData', $events_Data['events']);
- $this->setOutput('voteType', $voteType);
- $this->setOutput('voteData', $voteData);
- $this->setOutput('vote_id', Request::g('vote_id'));
- $this->setOutput('displayDesc', LotteryEvents::getDisplay());
-
- // 注:互动区根据配置 调用不同模板
- switch ($events_Data['events']['type']) {
- case LotteryEvents::TYPE_EVENTS_TURNTABLE: //大转盘
- if (Request::g('edit')) {
- $this->tpl = 'admin/activity/interactive_prize_edit';
- $prize_id = Request::g('prize_id');
- $prize = $events_Data['prize'][$prize_id];
- $prize['white_list'] = implode("\n", $prize['white_list']);
- $prize['hundred_percent_list'] = implode("\n", $prize['hundred_percent_list']);
- $prize['black_list'] = implode("\n", $prize['black_list']);
- $this->setOutput('prize_id', $prize_id);
- $this->setOutput('prize', $prize);
- } else if (Request::g('incr')) {
- $this->tpl = 'admin/activity/interactive_prize_incr';
- } else if (Request::g('decr')) {
- $this->tpl = 'admin/activity/interactive_prize_decr';
- } else {
- $this->tpl = 'admin/activity/interactive_prize';
- }
- break;
- case LotteryEvents::TYPE_EVENTS_SCRATCH: //刮刮卡
- if (Request::g('edit')) {
- $this->tpl = 'admin/activity/interactive_prize_edit';
- $prize_id = Request::g('prize_id');
- $prize = $events_Data['prize'][$prize_id];
- $prize['white_list'] = implode("\n", $prize['white_list']);
- $prize['hundred_percent_list'] = implode("\n", $prize['hundred_percent_list']);
- $prize['black_list'] = implode("\n", $prize['black_list']);
- $this->setOutput('prize_id', $prize_id);
- $this->setOutput('prize', $prize);
- } else if (Request::g('incr')) {
- $this->tpl = 'admin/activity/interactive_prize_incr';
- } else if (Request::g('decr')) {
- $this->tpl = 'admin/activity/interactive_prize_decr';
- } else {
- $this->tpl = 'admin/activity/interactive_prize';
- }
- break;
- case LotteryEvents::TYPE_EVENTS_TRY: //试用
- $this->tpl = 'admin/activity/interactive_input';
- break;
- case LotteryEvents::TYPE_EVENTS_SURVEY: //问卷调查
- $typ = Request::g('typ');
- $this->setOutput('typ', $typ);
- if($typ == 'input'){
- $this->tpl = 'admin/activity/interactive_input';
- break;
- }
- if($typ == 'prize'){
- $this->tpl = 'admin/activity/interactive_add_survey_prize';
- break;
- }
- if($typ == 'question'){
- $nextSort = 0;
- if(isset($events_Data['events']['survery_question'])){
- foreach ($events_Data['events']['survery_question'] as $key => $data){
- $nextSort = $key;
- }
- }
- $nextSort ++;
- $this->setOutput('nextSort', $nextSort);
- $this->tpl = 'admin/activity/interactive_question';
- break;
- }
- $this->tpl = 'admin/activity/interactive_survey_input_question';
- break;
- case LotteryEvents::TYPE_EVENTS_VOTE: //投票
- if (!$events_Data['events']['vote_type']) { //创建投票类型
- $this->tpl = 'admin/activity/interactive_vote_type';
- } else {
- $this->tpl = 'admin/activity/interactive_vote';
- if (Request::g('add_one_vote')) { //添加投票项
- $this->tpl = 'admin/activity/interactive_add_one_vote';
- }
- if (Request::g('update_one_vote')) { //修改投票项
- $this->tpl = 'admin/activity/interactive_update_one_vote';
- }
- }
- break;
- case LotteryEvents::TYPE_EVENTS_INVITATION: //邀请函
- $this->tpl = 'admin/activity/interactive_input';
- break;
- case LotteryEvents::TYPE_EVENTS_CODE: //领券
- $this->tpl = 'admin/activity/interactive_code';
- break;
- case LotteryEvents::TYPE_EVENTS_CUT_SCREEN: //切屏专题
- $this->tpl = 'admin/activity/interactive_input';
- break;
- }
-
- $navConfig = $this->getUpPageNav($events_id, 'Interactive');
-
- $title = '互动设置';
- $this->setOutput('title', $title);
- $this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
- $this->addNavMenu('活动列表');
- $this->addNavMenu($title);
- $this->setOutput ( 'navConfig', $navConfig );// 导航 显示 URL 配置
- $this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
- }
-
- /**
- * 删除一个调查问卷的奖品
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqDelSurveyQuestion
- */
- public function doReqDelSurveyQuestion(){
- $events_id = Request::p('events_id');
- $survery_question_id = Request::p('survery_question_id');
- $eventsData = $this->objLottery->getOneLotteryEvents($events_id);
- foreach($eventsData['survery_question'] as $key=>$data){
- if($key == $survery_question_id){
- unset($eventsData['survery_question'][$key]);
- }
- }
- $info['survery_question'] = $eventsData['survery_question'];
- $this->objLottery->upLotteryEvents ( $info, array (
- 'id' => $events_id
- ) );
- $this->ajax_success_exit('删除成功');
- }
-
-
-
- /**
- * 添加一个调查问卷的问题
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqAddSurveyQuestion
- */
- public function doReqAddSurveyQuestion(){
-
-
- $data = $_POST;
- $events_id = $data['events_id'];
- $sort = $data['f_sort_h'];
- $type = $data['f_type_h'];
- $choice = $data['f_choice_h'];
- $eventsData = $this->objLottery->getOneLotteryEvents($events_id);
-
- if(empty($eventsData['survery_question'])){
- $eventsData['survery_question'] = array();
- }
-
- if(isset($eventsData['survery_question'][$sort] )){
- $this->ajax_fail_exit('当前排序已有数据');
- }
-
- $info['survery_question'] = $eventsData['survery_question'];
- $info['survery_question'][$sort] = array();
- $info['survery_question'][$sort]['question'] = $data['f_question_h'];
- $info['survery_question'][$sort]['type'] = $type;
- $info['survery_question'][$sort]['choice'] = $choice;
-
-
- if($type == 'img'){
- for($i=1 ; $i<= $data['f_num_h']; $i++){
- $info['survery_question'][$sort]['answer'][$i] = array(
- 'img_url' => $data['img_url_'.$i],
- 'answer' => $data['img_url_answer_'.$i],
- );
- }
- }
-
- if($type == 'txt'){
- for($i=1 ; $i<= $data['f_num_h']; $i++){
- $info['survery_question'][$sort]['answer'][$i] = array(
- 'answer' => $data['txt_'.$i],
- );
- }
- }
-
- $this->objLottery->upLotteryEvents ( $info, array (
- 'id' => $events_id
- ) );
- $this->ajax_success_exit('添加成功');
- }
-
-
- /**
- * 添加一个调查问卷的奖品
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqAddSurveyPrize
- */
- public function doReqAddSurveyPrize(){
- $events_id = Request::p('events_id');
- $survery_prize_name = Request::p('survery_prize_name');
- $survery_prize_img_url = Request::p('img_url');
- $survery_prize_num = Request::p('survery_prize_num');
- $survery_prize_unit_name = Request::p('survery_prize_unit_name');
-
- $eventsData = $this->objLottery->getOneLotteryEvents($events_id);
- if(empty($eventsData['survery_prize'])){
- $eventsData['survery_prize'] = array();
- }
- $info['survery_prize'] = $eventsData['survery_prize'];
-
- $thisData = array(
- 'name' => $survery_prize_name,
- 'img_url' => $survery_prize_img_url,
- 'num' => $survery_prize_num,
- 'unit_name' => $survery_prize_unit_name,
- );
- array_push($info['survery_prize'] , $thisData);
- $this->objLottery->upLotteryEvents ( $info, array (
- 'id' => $events_id
- ) );
- $this->ajax_success_exit('添加成功');
- }
-
- /**
- * 删除一个调查问卷的奖品
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqDelSurveyPrize
- */
- public function doReqDelSurveyPrize(){
- $events_id = Request::p('events_id');
- $survery_prize_id = Request::p('survery_prize_id');
- $eventsData = $this->objLottery->getOneLotteryEvents($events_id);
- foreach($eventsData['survery_prize'] as $key=>$data){
- if($key == $survery_prize_id){
- unset($eventsData['survery_prize'][$key]);
- }
- }
- $info['survery_prize'] = $eventsData['survery_prize'];
- $this->objLottery->upLotteryEvents ( $info, array (
- 'id' => $events_id
- ) );
- $this->ajax_success_exit('删除成功');
- }
-
-
-
-
- /**
- * 事件:修改表单设置
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqUpForm
- * 参数:内方法内
- */
- public function doReqUpForm() {
- $events_id = Request::p ( 'events_id' );
- $formRegular = $this->formRegular ();
- if (isset ( $_POST ['f'] )) {
- $forms = Filter::arrayfilter ( $_POST ['f'] );
- foreach ( $forms as $tmpKey => $tmpForm ) {
- if (! $tmpForm ['name']) {
- unset ( $forms [$tmpKey] );
- }
-
- $regularid = $tmpForm ['rule'] ['regularid'];
- if (! empty ( $regularid ) && in_array ( $regularid, array_keys ( $formRegular ) )) {
- $forms [$tmpKey] ['rule'] ['regular'] = $formRegular [$regularid] ['regular'];
- } else {
- unset ( $forms [$tmpKey] ['rule'] ['regular'] );
- }
-
- if ($tmpForm ['options']) {
- $forms [$tmpKey] ['options'] = Filter::arrayfilter ( explode ( "\n", $tmpForm ['options'] ) );
- }
- }
- $info ['forms'] = $forms;
- $this->objLottery->upLotteryEvents ( $info, array (
- 'id' => $events_id
- ) );
- }
- // TODO 跳转页面自定义 返回 信息自定义
- $this->ajax_success_exit();
- }
-
- /**
- * 事件: 添加奖项
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqAddPrize
- * 参数:内方法内
- */
- public function doReqAddPrize() {
- $events_id = Request::p ( 'events_id' );
- $prize_name = Request::p ( 'prize_name' );
- $begin_hour = Request::p ( 'begin_hour' );
- $end_hour = Request::p ( 'end_hour' );
- $type = Request::p ( 'prize_type' );
- $prize_num = Request::p ( 'prize_num' );
- $virtual_data_str = Request::p ( 'virtual_data' );
- $white_list_str = Request::p ( 'white_list' );
- $hundred_percent_list_str = Request::p ( 'hundred_percent_list' );
- $black_list_str = Request::p ( 'black_list' );
- $express = Request::p ( 'express' );
- $img_url = Request::p('prize_image_url');
- $virtual_data = array ();
- $tmp_virtual_data = explode ( "\n", $virtual_data_str );
- foreach ( $tmp_virtual_data as $data ) {
- if (! empty ( $data )) {
- $virtual_data [$data] = $data;
- }
- }
- if ($type == LotteryPrize::TYPE_ENTITY) {
- $prize_num = count ( $virtual_data );
- }
- $white_list = array ();
- $tmp_white_list = explode ( "\n", $white_list_str );
- foreach ( $tmp_white_list as $data ) {
- if (! empty ( $data )) {
- $white_list [$data] = $data;
- }
- }
- $hundred_percent_list = array ();
- $tmp_hundred_percent_list = explode ( "\n", $hundred_percent_list_str );
- foreach ( $tmp_hundred_percent_list as $data ) {
- if (! empty ( $data )) {
- $hundred_percent_list [$data] = $data;
- }
- }
- $black_list = array ();
- $tmp_black_list = explode ( "\n", $black_list_str );
- foreach ( $tmp_black_list as $data ) {
- if (! empty ( $data )) {
- $black_list [$data] = $data;
- }
- }
- $info = array (
- 'events_id' => $events_id,
- 'prize_name' => $prize_name,
- 'prize_num' => $prize_num,
- 'type' => $type,
- 'white_list' => $white_list,
- 'hundred_percent_list' => $hundred_percent_list,
- 'black_list' => $black_list,
- 'begin_hour' => $begin_hour,
- 'end_hour' => $end_hour,
- 'img_url' => $img_url,
- 'virtual_data' => $virtual_data,
- 'express' => $express
- );
- $prize_id = $this->objLottery->addLotteryPrize ( $info );
- // TODO 跳转页面自定义 返回 信息自定义
- $this->ajax_success_exit($prize_id);
- }
-
-
- /**
- * 页面:获奖数据列表页
- * 地址: http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=PageLotteryDataList
- */
- public function doPageLotteryDataList() {
-
- $events_id = Request::g ( 'events_id' );
- $scratch_receive = Request::g ( 'scratch_receive' );
- $eventsAndPrizeData = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
- if ($eventsAndPrizeData ['events'] ['type'] == LotteryEvents::TYPE_EVENTS_SCRATCH) {
- }
- // 取数据
- $page = Request::varGetInt ( 'page', 1 );
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $condition = array (
- 'events_id' => $events_id
- );
-
- // 刮刮卡 跳将特殊处理
- $pieze_notreceive_num = array ();
- if ($eventsAndPrizeData ['events'] ['type'] == LotteryEvents::TYPE_EVENTS_SCRATCH) {
-
- $condition ['scratch_receive'] = LotteryData::EVENT_SCRATCH_RECEIVE_TRUE;
-
- foreach ( $eventsAndPrizeData ['prize'] as $prize ) {
- $for_condition = array (
- 'events_id' => $events_id,
- 'prize_id' => $prize ['id'],
- 'scratch_receive' => LotteryData::EVENT_SCRATCH_RECEIVE_FALSE
- );
- $pieze_notreceive_num [$prize ['id']] = $this->objLottery->getLotteryDataListNum ( $for_condition );
- }
- }
-
- // 筛选条件
- $prize_id = Request::g ( 'prize_id' );
- if ($prize_id) {
- $condition ['prize_id'] = $prize_id;
- }
-
- if ($scratch_receive == 'false') {
- $condition ['scratch_receive'] = LotteryData::EVENT_SCRATCH_RECEIVE_FALSE;
- }
-
- $total_num = $this->objLottery->getLotteryDataListNum ( $condition );
- $url_tpl = Request::schemeDomain () . "?c=admin_Lottery&a=LotteryDataListPage&events_id={$events_id}";
- if ($prize_id) {
- $url_tpl .= "&prize_id={$prize_id}";
- }
- $url_tpl .= "&page={page}";
- // 分页
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
-
- $order = 'id desc';
- $lotteryData = $this->objLottery->getLotteryDataList ( $condition, $limit, $order );
-
- $objDLotteryPrize = new LotteryPrize ();
- $prizeType = $objDLotteryPrize->getType ();
- $prizeDisplayStatus = $objDLotteryPrize->getDisplay ();
-
-
- $this->setOutput ( 'page_html', $page_html );
- $this->setOutput ( 'eventsAndPrizeData', $eventsAndPrizeData );
- $this->setOutput ( 'pieze_notreceive_num', $pieze_notreceive_num );
- $this->setOutput ( 'prizeType', $prizeType );
- $this->setOutput ( 'lotteryData', $lotteryData );
- }
-
-
- /**
- * 事件: 修改奖项
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqUpPrize
- * 参数:见方法内
- */
- public function doReqUpPrize() {
-
- $prize_id = Request::p ( 'prize_id' );
- $events_id = Request::p ( 'events_id' );
- $prize_name = Request::p ( 'prize_name' );
- $begin_hour = Request::p ( 'begin_hour' );
- $end_hour = Request::p ( 'end_hour' );
- $white_list_str = Request::p ( 'white_list' );
- $hundred_percent_list_str = Request::p ( 'hundred_percent_list' );
- $black_list_str = Request::p ( 'black_list' );
- $display = Request::p ( 'display' );
- $express = Request::p ( 'express' );
- $img_url = Request::p ( 'prize_image_url' );
- $white_list = array ();
- $tmp_white_list = explode ( "\n", $white_list_str );
- foreach ( $tmp_white_list as $data ) {
- if (! empty ( $data )) {
- $white_list [$data] = $data;
- }
- }
-
- $hundred_percent_list = array ();
- $tmp_hundred_percent_list = explode ( "\n", $hundred_percent_list_str );
- foreach ( $tmp_hundred_percent_list as $data ) {
- if (! empty ( $data )) {
- $hundred_percent_list [$data] = $data;
- }
- }
-
-
-
- $black_list = array ();
- $tmp_black_list = explode ( "\n", $black_list_str );
- foreach ( $tmp_black_list as $data ) {
- if (! empty ( $data )) {
- $black_list [$data] = $data;
- }
- }
- $info = array (
- 'events_id' => $events_id,
- 'prize_name' => $prize_name,
- 'white_list' => $white_list,
- 'hundred_percent_list' => $hundred_percent_list,
- 'black_list' => $black_list,
- 'begin_hour' => $begin_hour,
- 'end_hour' => $end_hour,
- 'img_url' => $img_url,
- 'display' => $display,
- 'express' => $express
- );
- $this->objLottery->UpLotteryPrize ( $info, array (
- 'id' => $prize_id
- ) );
- // TODO 跳转页面自定义 返回 信息自定义
- $redirect_url = Request::schemeDomain() . '/?c=Admin_Activity_SetInteractive&a=PageShow&events_id='.$events_id;
- $this->ajax_success_exit($redirect_url);
- }
-
- /**
- * 事件:增加奖项数量[虚拟,实物]
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqAddPrizeNum
- */
- public function doReqAddPrizeNum() {
- $virtual_data_str = Request::p ( 'virtual_data' );
- $prize_id = Request::p ( 'prize_id' );
- $num = Request::p ( 'prize_num' );
- $events_id = Request::p ( 'events_id' );
- $virtual_data = array ();
- $tmp_virtual_data = explode ( "\n", $virtual_data_str );
- foreach ( $tmp_virtual_data as $data ) {
- if (! empty ( $data )) {
- $virtual_data [$data] = $data;
- }
- }
- $this->objLottery->addLotteryPrizeNum ( $prize_id, $num, $virtual_data );
- // TODO 跳转页面自定义 返回 信息自定义
-
- if (Request::g('noajax')) {
- $this->redirect(Request::referer());
- } else {
- $this->ajax_success_exit();
- }
- }
-
- /**
- * 事件: 减少奖项数量[实物]
- * 地址: http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqMinusPrizeNum
- */
- public function doReqMinusPrizeNum() {
- $prize_id = Request::p ( 'prize_id' );
- $num = Request::p ( 'num' );
- $this->objLottery->addLotteryPrizeNum ( $prize_id, - $num );
- // TODO 跳转页面自定义 返回 信息自定义
- $this->ajax_success_exit();
- }
-
-
- /**
- * 事件:初始化 投票属性 图片类|| 文字类
- * 地址: http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqInitVote
- * 参数:见方法
- */
- public function doReqInitVote(){
- $events_id = Request::p ( 'events_id' );
- $vote_num = Request::p ( 'vote_num' );
- $vote_type = Request::p ( 'vote_type' );
- $vote_title = Request::p ( 'vote_title' );
- $objDLotteryEvents = new LotteryEvents ();
- $info = array (
- 'vote_type' => $vote_type,
- 'vote_title' => $vote_title
- );
- $objDLotteryEvents->modify ( $info, array (
- 'id' => $events_id
- ) );
- $objDLotteryEventsVote = new LotteryEventsVote ();
- for($i = 1; $i <= $vote_num; $i ++) {
- $info = array (
- 'events_id' => $events_id,
- 'title' => 'null',
- 'img_url' => 'null'
- );
- $objDLotteryEventsVote->add ( $info );
- }
- // TODO 跳转页面自定义 返回 信息自定义
-
- $this->ajax_success_exit();
- }
-
- /**
- * 事件:创建一个投票项
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqCreateOneVote
- */
- public function doReqCreateOneVote(){
- $title = Request::p ( 'title' );
- $events_id = Request::p ( 'events_id' );
-
- $img_url = Request::p('img_url');
- // $tmpImgData = $this->loadImg ();
- // if (is_array ( $tmpImgData )) {
- // $img_url = $tmpImgData ['url'] [0];
- // }
-
- $add_num = Request::p ( 'add_num' );
-
- $info = array (
- 'title' => $title,
- 'img_url' => $img_url,
- 'add_num' => $add_num,
- 'events_id' => $events_id
- );
- $objDLotteryEventsVote = new LotteryEventsVote ();
- $id = $objDLotteryEventsVote->add ( $info );
-
- if (!$id) {
- $this->ajax_fail_exit('创建投票项失败');
- }
-
- $redirect_url = Request::schemeDomain() . '/?c=Admin_Activity_SetInteractive&a=PageShow&events_id='.$events_id;
- $this->ajax_success_exit($redirect_url);
- }
-
- /**
- * 事件:修改一个投票项
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=UpOneVote
- */
- public function doUpOneVote(){
- $vote_id = Request::p ( 'vote_id' );
- $add_num = Request::p ( 'add_num' );
- $title = Request::p ( 'title' );
- $img_url = Request::p ( 'img_url' );
- $events_id = Request::p ( 'events_id' );
- $objDLotteryEventsVote = new LotteryEventsVote ();
- // $tmpImgData = $this->loadImg ();
- // if (is_array ( $tmpImgData )) {
- // $img_url = $tmpImgData ['url'] [0];
- // }
- $info = array (
- 'add_num' => $add_num,
- 'title' => $title,
- 'img_url' => $img_url
- );
- $tmpResult = $objDLotteryEventsVote->modify ( $info, array (
- 'id' => $vote_id
- ) );
-
- if (!$tmpResult->isSuccess()) {
- $this->ajax_fail_exit('修改投票项失败');
- }
-
- $redirect_url = Request::schemeDomain() . '/?c=Admin_Activity_SetInteractive&a=PageShow&events_id='.$events_id;
- $this->ajax_success_exit($redirect_url);
- }
-
- /**
- * 事件:修改 券名称||券图片
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqUpCode
- */
- public function doReqUpCode(){
- $info =array();
- $events_id = Request::p ( 'events_id' );
-
- # 券信息
- $info ['two_dimensional_code'] = LotteryEvents::TWO_DIMENSIONAL_CODE_FALSE;
- $info ['code_name'] = Request::p ( 'code_name' );
- $info ['code_img_url'] = Request::p ( 'code_img_url' );
-
- # 添加自定义表单
- $formRegular = $this->formRegular ();
- if (isset ( $_POST ['f'] )) {
- $forms = Filter::arrayfilter ( $_POST ['f'] );
- foreach ( $forms as $tmpKey => $tmpForm ) {
- if (! $tmpForm ['name']) {
- unset ( $forms [$tmpKey] );
- }
-
- $regularid = $tmpForm ['rule'] ['regularid'];
- if (! empty ( $regularid ) && in_array ( $regularid, array_keys ( $formRegular ) )) {
- $forms [$tmpKey] ['rule'] ['regular'] = $formRegular [$regularid] ['regular'];
- } else {
- unset ( $forms [$tmpKey] ['rule'] ['regular'] );
- }
-
- if ($tmpForm ['options']) {
- $forms [$tmpKey] ['options'] = Filter::arrayfilter ( explode ( "\n", $tmpForm ['options'] ) );
- }
- }
- $info ['forms'] = $forms;
- }
-
- $tmpReuslt = $this->objLottery->upLotteryEvents ( $info, array (
- 'id' => $events_id
- ) );
- if (!$tmpReuslt) {
- $this->ajax_fail_exit('服务器操作失败');
- }
-
- # 添加券
- $code_data = Request::p ( 'code_data' );
- $code_data = explode ( "\n", $code_data );
- $code_data = Filter::arrayfilter($code_data);
- if (count ( $code_data ) > 200) {
- $this->ajax_fail_exit ( '一次上传不允许超过200张券' );
- }
- $objDLotteryEventsCodeData = new LotteryEventsCodeData ();
- foreach ( $code_data as $key => $data ) {
- $info = array (
- 'events_id' => $events_id,
- 'data' => $data
- );
- $objDLotteryEventsCodeData->add ( $info );
- }
-
- $this->ajax_success_exit();
- }
-
- /**
- * 事件:添加券
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqAddEventCode
- */
- public function doReqAddEventCode() {
- $events_id = Request::p ( 'events_id' );
- $code_data = Request::p ( 'code_data' );
- $code_data = explode ( "\n", $code_data );
- foreach ( $code_data as $key => $data ) {
- if ($data) {
- $code_data [$data] = $data;
- }
- }
- if (count ( $code_data ) > 200) {
- $this->ajax_fail_exit ( '一次上传不允许超过200条记录' );
- }
- $objDLotteryEventsCodeData = new LotteryEventsCodeData ();
- foreach ( $code_data as $key => $data ) {
- $info = array (
- 'events_id' => $events_id,
- 'data' => $data
- );
- $objDLotteryEventsCodeData->add ( $info );
- }
- // TODO 跳转页面自定义 返回 信息自定义
- return;
- }
-
- /**
- * 查看券码页面
- */
- public function doReqShowEventCode() {
- $events_id = Request::g('events_id');
-
- $page = Request::varGetInt('page', 1);
-
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
-
- $condition = array (
- 'events_id' => $events_id
- );
- $objDLotteryEventsCodeData = new LotteryEventsCodeData ();
- $codeIds = $objDLotteryEventsCodeData->findIdsBy ( $condition, $limit, 'id desc' );
- $codeData = $objDLotteryEventsCodeData->gets ( $codeIds );
- $total_num = $objDLotteryEventsCodeData->totals ( $condition );
-
- # 分页
- $url_tpl = Request::schemeDomain () . "/?c=Admin_Activity_SetInteractive&a=ReqShowEventCode&events_id={$events_id}";
- $url_tpl .= "&page={page}";
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
-
- $events_id = Request::g ( 'events_id' );
- $events_Data = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
- $eventsTypeData = LotteryEvents::getType ();
-
- $navConfig = $this->getUpPageNav($events_id, 'Interactive');
-
- $this->tpl = 'admin/activity/interactive_code_show';
- $title = '互动设置';
- $this->setOutput('title', $title);
- $this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
- $this->addNavMenu('活动列表');
- $this->addNavMenu($title);
- $this->setOutput ( 'navConfig', $navConfig );// 导航 显示 URL 配置
-
- $this->setOutput('title', $title);
- $this->setOutput('events_Data', $events_Data);
- $this->setOutput('eventData', $events_Data['events']);
- $this->setOutput ( 'eventsTypeData', $eventsTypeData );
- $this->setOutput('typeData', $eventsTypeData);
- $this->setOutput('codeData', $codeData);
- $this->setOutput('page', $page-1);
- $this->setOutput('size', $size);
- $this->setOutput('page_html', $page_html);
- $this->setOutput('displayDesc', LotteryEvents::getDisplay());
- $this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
- }
-
-
- /**
- * 页面:虚拟数据列表页
- * 地址:http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=PageVirtualDataList&prize_id=
- * 参数:
- * 奖项id: prize_id
- * 使用 & 未使用 ottery_data_id true| false
- * 分页:page
- */
- public function doPageVirtualDataList() {
- $prize_id = Request::g ( 'prize_id' );
- $lottery_data_id = Request::g ( 'lottery_data_id' );
- $prizeData = $this->objLottery -> getOneLotteryPrize($prize_id);
- $events_id = $prizeData['events_id'];
- // 取数据
- $page = Request::varGetInt ( 'page', 1 );
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $condition = array (
- 'prize_id' => $prize_id
- );
- if($lottery_data_id=='true'){
- $condition['lottery_data_id'] = SqlHelper::addCompareOperator('!=', 0);
- }
- if($lottery_data_id=='false'){
- $condition['lottery_data_id'] = 0;
- }
- $order = 'id desc';
- $prizeVirtualData = $this->objLottery-> getLotteryPrizeVirtualDataList ( $condition, $limit, $order );
- $page_html = '';
- $total_num = $this->objLottery->getLotteryPrizeVirtualDataListNum($condition);
- $url_tpl = Request::schemeDomain () . "?c=Admin_Activity_SetInteractive&a=PageVirtualDataList&prize_id={$prize_id}";
- if($lottery_data_id){
- $url_tpl .= "&lottery_data_id={$lottery_data_id}";
- }
- $url_tpl .= "&page={page}";
- // 分页
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
-
- //通过data_id 获取用户中奖信息
- $dataIds = array();
- foreach($prizeVirtualData as $key => $data){
- if($data['lottery_data_id']){
- $dataIds[$data['lottery_data_id']] = $data['lottery_data_id'];
- }
- }
- $lotteryData = $this->objLottery->getLotteryDatas($dataIds);
-
- $navConfig = $this->getUpPageNav($events_id, 'Interactive');
- $title = '虚拟数据列表';
- $this->setOutput('title', $title);
- $this->setOutput('menu_active', array('name' => 'mypublish', 'item' => '')); //激活菜单
- $this->addNavMenu('互动设置');
- $this->addNavMenu($title);
- $this->setOutput ( 'navConfig', $navConfig );// 导航 显示 URL 配置
-
- $this->setOutput ( 'prizeVirtualData', $prizeVirtualData );
- $this->setOutput ( 'page_html', $page_html );
- $this->setOutput ( 'prizeData', $prizeData );
- $this->setOutput ( 'lotteryData', $lotteryData );
- $this->tpl = 'admin/activity/virtual_goods_list';
- $this->setOutput('displayDesc', LotteryEvents::getDisplay());
- $this->setOutput('pagePublicData', $this->getPagePublicData($events_id)); // 后台管理相关数据
- }
-
-
-
- /**
- * 事件:删除一个虚拟奖品
- * 地址 : http://cas.lishuy.com/?c=Admin_Activity_SetInteractive&a=ReqDelPrizeVirtual
- * 参数:
- * prize_id 奖项ID
- * prize_virtua_id 当前虚拟奖品ID
- */
- public function doReqDelPrizeVirtual(){
- $prize_id = Request::p ( 'prize_id' );
- $prize_virtua_id = Request::p ( 'prize_virtua_id' );
- $prizeData = $this->objLottery -> delLotteryPrizeVirtual($prize_virtua_id);
- $this->ajax_success_exit('删除成功');
- }
-
-
- /**
- * 方法:图片上传
- */
- public function loadImg($image_name = 'image') {
- $uploadConfig = Config::getInstance ()->get ( 'upload' );
- // 定义允许上传的文件扩展名
- $ext_arr = array (
- 'image' => array (
- 'gif',
- 'jpg',
- 'jpeg',
- 'png',
- 'bmp'
- )
- );
- if (! is_array ( $_FILES [$image_name] ['name'] )) {
- foreach ( $_FILES [$image_name] as $key => $data ) {
- unset ( $_FILES [$image_name] [$key] );
- $_FILES [$image_name] [$key] [] = $data;
- }
- }
- $file_url = array ();
- foreach ( $_FILES [$image_name] ['name'] as $key => $oneData ) {
- // 文件保存目录路径
- $save_path = $uploadConfig ['path'] . '/';
- $save_path = realpath ( $save_path ) . '/';
-
- // PHP上传失败
- if ($_FILES [$image_name] ['error'] [$key] != 0) {
- switch ($_FILES [$image_name] ['error'] [$key]) {
- case '1' :
- $error = '超过php.ini允许的大小。';
- break;
- case '2' :
- $error = '超过表单允许的大小。';
- break;
- case '3' :
- $error = '图片只有部分被上传。';
- break;
- case '4' :
- $error = '请选择图片。';
- break;
- case '6' :
- $error = '找不到临时目录。';
- break;
- case '7' :
- $error = '写文件到硬盘出错。';
- break;
- case '8' :
- $error = 'File upload stopped by extension。';
- break;
- case '999' :
- default :
- $error = '未知错误。';
- }
- return $error;
- }
- // 有上传文件时
- if (empty ( $_FILES ) === false) {
- // 原文件名
- $file_name = $_FILES [$image_name] ['name'] [$key];
- // 服务器上临时文件名
- $tmp_name = $_FILES [$image_name] ['tmp_name'] [$key];
- // 文件大小
- $file_size = $_FILES [$image_name] ['size'] [$key];
- // 检查文件名
- if (! $file_name) {
- return "请选择文件。";
- }
- // 检查目录
- if (@is_dir ( $save_path ) === false) {
- return "上传目录不存在。";
- }
- // 检查目录写权限
- if (@is_writable ( $save_path ) === false) {
- return "上传目录没有写权限。";
- }
- // 检查是否已上传
- if (@is_uploaded_file ( $tmp_name ) === false) {
- return "上传失败。";
- }
- // 检查目录名
- $dir_name = 'image';
- if (empty ( $ext_arr [$dir_name] )) {
- return "目录名不正确。";
- }
- // 获得文件扩展名
- $temp_arr = explode ( ".", $file_name );
- $file_ext = array_pop ( $temp_arr );
- $file_ext = trim ( $file_ext );
- $file_ext = strtolower ( $file_ext );
- // 检查扩展名
- if (in_array ( $file_ext, $ext_arr [$dir_name] ) === false) {
- return "上传文件扩展名是不允许的扩展名。\n只允许" . implode ( ",", $ext_arr [$dir_name] ) . "格式。";
- }
- // 创建文件夹
- $ymd = date ( "Ymd" );
- $ymd = date ( "Y" ) . '/' . date ( 'md' );
- // 文件保存目录URL
- $save_url = $uploadConfig ['url'] . '/';
- $new_file_name = '';
- $save_path .= $dir_name . "/" . $ymd . "/";
-
- $save_url .= $dir_name . "/" . $ymd . "/";
- if (! file_exists ( $save_path )) {
- if (! mkdir ( $save_path, 0775, true )) {
- return "创建目录失败:{$save_path}";
- }
- }
- // 新文件名
- $new_file_name = date ( "His" ) . '_' . rand ( 10000, 99999 ) . '.' . $file_ext;
- // 移动文件
- $file_path = $save_path . $new_file_name;
- // 原图上传
- if (move_uploaded_file ( $tmp_name, $file_path ) === false) {
- return "上传文件失败。";
- }
- error_reporting ( E_ALL );
- // 压缩65质量原图
- $this_basename = basename ( $file_path );
- $this_dirname = dirname ( $file_path );
- $z_file_path = $this_dirname . '/' . 'z.' . $this_basename;
- \KIF\Image::transformFormat ( $file_path, $z_file_path, 'JPG' );
- @chmod ( $file_path, 0777 );
- $file_url [$key] = $save_url . 'z.' . $new_file_name;
- }
- }
- return array (
- 'error' => 0,
- 'url' => $file_url
- );
- }
-
- /**
- * 表单验证规则
- *
- * @return multitype:multitype:string
- */
- public function formRegular() {
- return array (
- 1 => array (
- 'desc' => '手机验证',
- 'regular' => '/^(1[0-9][0-9]|15[0-9]|18[02-9]|14[57])[0-9]{8}$/'
- ),
- 2 => array (
- 'desc' => '邮箱验证',
- 'regular' => '/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/'
- )
- );
- }
- public function display() {
- return $this->render ();
- }
- }
-
|