123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470 |
- <?php
- namespace Cas\Controller\Admin;
- use Cas\Dao\LotteryData;
- use Cas\Module\LotteryDrawLetters;
- use Cas\Dao\LotteryEventsCodeData;
- use Cas\Dao\LotteryEventsInvitation;
- use KIF\Core\Request;
- use KIF\Page\Page;
- use KIF\Verify;
- use Cas\Dao\LotteryEvents as LotteryEvents;
- use KIF\Core\Config;
- use KIF\Image;
- use Cas\Dao\LotteryPrize;
- use KIF\Cache\Memcached;
- use KIF\Dao\SqlHelper;
- use Cas\Module\LotteryDraw;
- use Cas\Module\LotteryLog;
- use Cas\Dao\LotteryEventsTry;
- use Cas\Dao\LotteryEventsLetters;
- use Cas\Dao\LotteryEventsUserLetters;
- use Cas\Dao\LotteryEventsVote;
- use KIF\String\Filter;
- use Cas\Dao\LotteryEventsForms;
- use Cas\Module\WeixinUser;
- use KIF\Data\Convert;
- /**
- *
- *
- * 抽奖控制器
- *
- * @author lihuanchun
- */
- class Lottery extends Controller {
- private $objLottery;
- public function __construct() {
- header ( "Content-Type: text/html; charset=utf-8" );
- $this->objLottery = new \Cas\Module\Lottery ();
- }
-
- /**
- * 操作 ajax:测试抽奖页面
- */
- public function doTestWantToDraw() {
- $uid = Request::p ( 'uid' );
- $events_id = Request::p ( 'events_id' );
- $lotteryDataId = $this->objLottery->tmpWantToDraw ( $events_id, $uid );
- if (! $lotteryDataId) {
- $this->ajax_fail_exit ( '未中奖' );
- } else {
- $data = $this->objLottery->getOneLotteryData ( $lotteryDataId );
- $this->ajax_success_exit ( "中奖啦\n" );
- }
- }
-
- /**
- * ajax: 添加 活动【领码】
- */
- public function doAddEventCode() {
- $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 );
- }
- $this->ajax_success_exit ( "上传成功" );
- }
-
- /**
- * 页面:活动【领码】页面
- */
- public function doEventCodePage() {
- $events_id = Request::varGetInt ( 'events_id' );
- $eventsData = $this->objLottery->getOneLotteryEvents ( $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_lottery&a=EventCodePage&events_id={$events_id}";
- $url_tpl .= "&page={page}";
- // 分页
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
- $this->tpl = 'admin/lottery/event_code_data_list';
- $title = '抵用券信息';
- $this->setOutput ( 'title', $title );
- $this->setOutput ( 'page_html', $page_html );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'codeData', $codeData );
- $this->setOutput ( 'eventsData', $eventsData );
- $this->setOutput ( 'showAddCode', Request::g ( 'showAddCode' ) );
- }
-
- /**
- * 页面: 邀请函申请列表【活动】
- */
- public function doEventInvitationPage() {
- $objDLotteryEventsInvitation = new LotteryEventsInvitation ();
- $events_id = Request::varGetInt ( 'events_id' );
- $page = Request::varGetInt ( 'page', 1 );
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $condition = array (
- 'events_id' => $events_id
- );
- $applyIds = $objDLotteryEventsInvitation->findIdsBy ( $condition, $limit, 'id desc' );
- $applyData = $objDLotteryEventsInvitation->gets ( $applyIds );
- $total_num = $objDLotteryEventsInvitation->totals ( $condition );
- $url_tpl = Request::schemeDomain () . "?c=admin_lottery&a=EventInvitationPage&events_id={$events_id}";
- $url_tpl .= "&page={page}";
- // 分页
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
- $this->tpl = 'admin/lottery/event_invitation_list';
- $title = '邀请函表单信息';
- $this->setOutput ( 'title', $title );
- $this->setOutput ( 'page_html', $page_html );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'applyData', $applyData );
- }
-
- /**
- * 页面: 表单数据
- */
- public function doEventFormDataPage() {
- $events_id = Request::varGetInt ( 'events_id' );
- if (! Verify::unsignedInt ( $events_id )) {
- self::fail_exit_bs ( '无效events_id' );
- }
-
- $page = Request::varGetInt ( 'page', 1 );
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $condition = array (
- 'events_id' => $events_id
- );
-
- $objLotteryEventsForms = new LotteryEventsForms ();
- $ids = $objLotteryEventsForms->findIdsBy ( $condition, $limit, 'id desc' );
- $formData = $objLotteryEventsForms->gets ( $ids );
-
- $objLotteryEvents = new LotteryEvents ();
- $event = $objLotteryEvents->get ( $events_id );
-
- // 表单类型数据
- $formType = array ();
- foreach ( $event ['forms'] as $tmpForms ) {
- $formType [] = $tmpForms ['name'];
- }
-
- // 分页
- $total_num = $objLotteryEventsForms->totals ( $condition );
- $url_tpl = Request::schemeDomain () . "?c=admin_lottery&a=EventFormDataPage&events_id={$events_id}";
- $url_tpl .= "&page={page}";
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
-
- $this->tpl = 'admin/lottery/event_form_data';
- $title = "活动\"{$event['events_name']}\"表单数据";
- $this->setOutput ( 'title', $title );
- $this->setOutput ( 'page_html', $page_html );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'formData', $formData );
- $this->setOutput ( 'formType', $formType );
- }
-
- /**
- * 页面: 活动日志产看列表
- */
- public function doEventLogPage() {
- $objMLotteryLog = new LotteryLog ();
- $lotteryLogType = $objMLotteryLog->getType ();
- $events_id = Request::varGetInt ( 'events_id' );
- $page = Request::varGetInt ( 'page', 1 );
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $condition = array (
- 'events_id' => $events_id
- );
- $logData = $objMLotteryLog->findData ( $condition, $limit, 'id desc' );
- $total_num = $objMLotteryLog->getLogNum ( $condition );
- $url_tpl = Request::schemeDomain () . "?c=admin_lottery&a=EventLogPage&events_id={$events_id}";
- $url_tpl .= "&page={page}";
- // 分页
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
- $this->tpl = 'admin/lottery/event_log_list';
- $title = '活动日志';
- $this->setOutput ( 'title', $title );
- $this->setOutput ( 'page_html', $page_html );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'logData', $logData );
- $this->setOutput ( 'lotteryLogType', $lotteryLogType );
- }
-
- /**
- * 页面:创建活动页
- */
- public function doAddEventPage() {
- $objDLotteryEvents = new LotteryEvents ();
- $eventsType = $objDLotteryEvents->getType ();
- $this->tpl = 'admin/lottery/add_event';
- $title = '创建活动';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'eventsType', $eventsType );
- }
-
- /**
- * 事件:创建活动
- */
- public function doAddEvent() {
- $events_name = Request::p ( 'events_name' );
- $begin_time = Request::p ( 'begin_unix_time' );
- $end_time = Request::p ( 'end_unix_time' );
- $type = Request::varPostInt ( 'type' );
- $events_rules = $_POST ['events_rules'];
- $events_tips = $_POST ['events_tips'];
- $img_url = '';
- $tmpImgData = $this->loadImg ();
- if (is_array ( $tmpImgData )) {
- $img_url = $tmpImgData ['url'] [0];
- }
- $info = array (
- 'events_name' => $events_name,
- 'begin_time' => $begin_time,
- 'end_time' => $end_time,
- 'end_time_receive_prizes' => $end_time,
- 'type' => $type,
- 'img_url' => $img_url,
- 'authorize' => LotteryEvents::EVENT_AUTHORIZE_FALSE,
- 'events_rules' => $events_rules,
- 'events_tips' => $events_tips,
- 'delivery' => LotteryEvents::DELIVERY_FALSE,
- 'participation_user_num' => 0,
- 'participation_ip_num' => 0,
- 'winning_user_num' => 0,
- 'participation_user_all_num' => 0
- );
-
- $events_id = $this->objLottery->addLotteryEvents ( $info );
- if (! $events_id) {
- exit ( '创建活动失败' );
- }
- header ( "Location: " . Request::schemeDomain () . "/?c=admin_Lottery&a=EventPage&events_id={$events_id}" );
- }
-
- /**
- * 事件:修改活动
- */
- public function doUpEvent() {
- $events_id = Request::p ( 'events_id' );
- $events_name = Request::p ( 'events_name' );
- $display = Request::p ( 'display' );
- $authorize = Request::p ( 'authorize' );
- $list_display = Request::p ( 'list_display' ); // 是否在列表中出现
- $img_url = Request::p ( 'old_img_url' );
- $begin_time = Request::p ( 'begin_unix_time' );
- $end_time = Request::p ( 'end_unix_time' );
- $end_time_receive_prizes = Request::p ( 'end_unix_time_receive_prizes' );
- $type = Request::p ( 'type' );
- $delivery = Request::p ( 'delivery' );
- $events_rules = $_POST ['events_rules'];
- $operationt_tips = $_POST ['operationt_tips'];
-
- $events_tips = $_POST ['events_tips'];
- $participation_user_num = Request::p ( 'participation_user_num' );
- $participation_ip_num = Request::p ( 'participation_ip_num' );
- $winning_user_num = Request::p ( 'winning_user_num' );
- $participation_user_all_num = Request::p ( 'participation_user_all_num' );
- $tmpImgData = $this->loadImg ();
- if (is_array ( $tmpImgData )) {
- $img_url = $tmpImgData ['url'] [0];
- }
-
- $weixinShare_title = Request::p ( 'weixinShare_title' );
- $weixinShare_content = Request::p ( 'weixinShare_content' );
- $weixinShare_imgUrl = Request::p ( 'weixinShare_imgUrl' );
- $tmpImgData = $this->loadImg ( 'weixinShareImg' );
- if (is_array ( $tmpImgData )) {
- $weixinShare_imgUrl = $tmpImgData ['url'] [0];
- }
-
- $weixinShare_notAllow = Request::p ( 'weixinShare_notAllow' );
-
- $info = array (
- 'events_name' => $events_name,
- 'begin_time' => $begin_time,
- 'end_time' => $end_time,
- 'end_time_receive_prizes' => $end_time_receive_prizes,
- 'img_url' => $img_url,
- 'display' => $display,
- 'authorize' => $authorize,
- 'list_display' => $list_display,
- 'operationt_tips' => $operationt_tips,
- 'events_rules' => $events_rules,
- 'events_tips' => $events_tips,
- 'delivery' => $delivery,
- 'participation_user_num' => $participation_user_num,
- 'participation_ip_num' => $participation_ip_num,
- 'winning_user_num' => $winning_user_num,
- 'participation_user_all_num' => $participation_user_all_num,
- 'weixinShare' => array (
- 'title' => $weixinShare_title,
- 'content' => $weixinShare_content,
- 'imgUrl' => $weixinShare_imgUrl,
- 'notAllow' => $weixinShare_notAllow
- )
- );
-
- if ($type == LotteryEvents::TYPE_EVENTS_INVITATION) {
-
- // <邀请函> 白名单列表
- $invitation_white_list = Request::p ( 'invitation_white_list' );
- if ($invitation_white_list) {
- $invitation_white_list = explode ( "@", $invitation_white_list );
- $tmpData = array ();
- foreach ( $invitation_white_list as $key => $data ) {
- $tmpData [$data] = $data;
- }
- $info ['invitation_white_list'] = $tmpData;
- } else {
- $info ['invitation_white_list'] = '';
- }
- }
-
- // 其他
- if ($type == LotteryEvents::TYPE_EVENTS_OTHER) {
- $info ['other_url'] = Request::p ( 'other_url' );
- }
-
- if ($type == LotteryEvents::TYPE_EVENTS_INVITATION) {
- $info ['participation_user_max_num'] = Request::p ( 'participation_user_max_num' );
- }
-
- // 领券操作
- if ($type == LotteryEvents::TYPE_EVENTS_CODE) {
- $info ['two_dimensional_code'] = Request::p ( 'two_dimensional_code' );
- $info ['code_name'] = Request::p ( 'code_name' );
- $info ['code_img_url'] = Request::p ( 'code_old_img_url' );
- $tmpImgData = $this->loadImg ( 'code_image' );
- if (is_array ( $tmpImgData )) {
- $info ['code_img_url'] = $tmpImgData ['url'] [0];
- }
- }
-
-
- $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
- ) );
- header ( "Location: " . Request::schemeDomain () . "/?c=admin_Lottery&a=EventPage&events_id={$events_id}" );
- }
-
- /**
- * 页面:修改活动页
- */
- public function doUpEventPage() {
- $events_id = Request::g ( 'events_id' );
- $events_Data = $this->objLottery->getOneLotteryEvents ( $events_id );
-
- $this->objLottery->getOneLotteryEventsAndPrize($events_id);
-
- $objDLotteryEvents = new LotteryEvents ();
- $eventsType = $objDLotteryEvents->getType ();
- $deliveryType = $objDLotteryEvents->getDeliveryType ();
- $eventsAuthorize = $objDLotteryEvents->getAuthorize ();
- $eventsDisplayStatus = $objDLotteryEvents->getDisplay ();
- $eventsTwoDimensionalCodeType = $objDLotteryEvents->getTwoDimensionalCodeType ();
- $this->tpl = 'admin/lottery/up_event';
- $title = '修改活动';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'eventsType', $eventsType );
- $this->setOutput ( 'deliveryType', $deliveryType );
- $this->setOutput ( 'eventsAuthorize', $eventsAuthorize );
- $this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
- $this->setOutput ( 'events_Data', $events_Data );
- $this->setOutput ( 'eventsTwoDimensionalCodeType', $eventsTwoDimensionalCodeType );
- $this->setOutput ( 'formRegular', $this->formRegular () );
- }
-
- /**
- * 页面:活动列表页
- */
- public function doEventListPage() {
- $objDLotteryEvents = new LotteryEvents ();
-
- $eventsType = $objDLotteryEvents->getType ();
- $eventsDisplayStatus = $objDLotteryEvents->getDisplay ();
- $objDLotteryPrize = new LotteryPrize ();
- $prizeType = $objDLotteryPrize->getType ();
- $prizeDisplayStatus = $objDLotteryPrize->getDisplay ();
-
- // 取数据
- $page = Request::varGetInt ( 'page', 1 );
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $condition = array ();
- $allLotteryEventsIds = $objDLotteryEvents->findIdsBy ( $condition, $limit, 'id desc' );
-
- $eventsData = $objDLotteryEvents->gets ( $allLotteryEventsIds );
- $total_num = $this->objLottery->getLotteryEventsListNum ( $condition );
- $url_tpl = Request::schemeDomain () . "?c=admin_lottery&a=EventListPage";
- $url_tpl .= "&page={page}";
- // 分页
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
-
- $this->tpl = 'admin/lottery/event_list';
- $title = '活动列表';
- $this->setOutput ( 'title', $title );
- $this->setOutput ( 'page_html', $page_html );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'allEventsData', $eventsData );
- $this->setOutput ( 'eventsType', $eventsType );
- $this->setOutput ( 'eventsDisplay', $eventsDisplayStatus );
- $this->setOutput ( 'prizeType', $prizeType );
- $this->setOutput ( 'prizeDisplayStatus', $prizeDisplayStatus );
- }
-
- /**
- * 页面:活动详情页
- */
- public function doEventPage() {
- $events_id = Request::g ( 'events_id' );
- $eventsAndPrize_Data = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
-
- $objDLotteryEvents = new LotteryEvents ();
- $eventsType = $objDLotteryEvents->getType ();
- $eventsDisplayStatus = $objDLotteryEvents->getDisplay ();
- $eventsVoteType = $objDLotteryEvents->getVoteType ();
- $eventsAuthorizeStatus = $objDLotteryEvents->getAuthorize ();
- $eventsTwoDimensionalCodeType = $objDLotteryEvents->getTwoDimensionalCodeType ();
- $deliveryType = $objDLotteryEvents->getDeliveryType ();
- $objDLotteryPrize = new LotteryPrize ();
- $prizeType = $objDLotteryPrize->getType ();
- $prizeDisplayStatus = $objDLotteryPrize->getDisplay ();
- $objMemcached = new Memcached ();
-
- // 收集字母
- $lettersData = null;
- if ($eventsAndPrize_Data ['events'] ['type'] == \Cas\Dao\LotteryEvents::TYPE_EVENTS_LETTERS) {
- $objDLotteryEventsLetters = new LotteryEventsLetters ();
- $lettersData = $objDLotteryEventsLetters->getEventData ( $events_id );
- }
-
- // 投票
- $voteData = null;
- if ($eventsAndPrize_Data ['events'] ['type'] == \Cas\Dao\LotteryEvents::TYPE_EVENTS_VOTE) {
- $objDLotteryEventsVote = new LotteryEventsVote ();
- $voteData = $objDLotteryEventsVote->getThisEventData ( $events_id );
- }
-
- // 领码
- if ($eventsAndPrize_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 );
- }
-
- $objMLotteryDraw = new LotteryDraw ( null, $events_id );
- foreach ( $eventsAndPrize_Data ['prize'] as $key => $prize ) {
- $lottery_prize_draw_next_time_key = $objMLotteryDraw->getCacheKeyOfNextWinTime ( $key );
- $eventsAndPrize_Data ['prize'] [$key] ['nextTime'] = $objMemcached->get ( $lottery_prize_draw_next_time_key );
- }
-
- // 页面URL
- $thisurl = $this->objLottery->getEventsUrl ( $eventsAndPrize_Data ['events'] ['type'],$eventsAndPrize_Data ['create_time']);
- $this->setOutput ( 'thisurl', $thisurl );
-
- // APP载入URL
- $thisAppUrl = Request::schemeDomain () . '/redirect/?url=' . urlencode ( $thisurl ) . '&uf=';
- $this->setOutput ( 'thisAppUrl', $thisAppUrl );
-
- $this->tpl = 'admin/lottery/event';
- $title = '活动详情';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'eventsType', $eventsType );
- $this->setOutput ( 'eventsAuthorizeStatus', $eventsAuthorizeStatus );
- $this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
- $this->setOutput ( 'eventsVoteType', $eventsVoteType );
- $this->setOutput ( 'prizeType', $prizeType );
- $this->setOutput ( 'prizeDisplayStatus', $prizeDisplayStatus );
- $this->setOutput ( 'eventsAndPrize_Data', $eventsAndPrize_Data );
- $this->setOutput ( 'deliveryType', $deliveryType );
-
- $this->setOutput ( 'lettersData', $lettersData );
- $this->setOutput ( 'voteData', $voteData );
- $this->setOutput ( 'eventsTwoDimensionalCodeType', $eventsTwoDimensionalCodeType );
- }
-
- /**
- * 页面:投票详情列表
- */
- public function doEventVotePage() {
- $events_id = Request::g ( 'events_id' );
- $objDLotteryEvents = new LotteryEvents ();
- $eventsData = $objDLotteryEvents->get ( $events_id );
- $eventsVoteType = $objDLotteryEvents->getVoteType ();
-
- $objDLotteryEventsVote = new LotteryEventsVote ();
- $voteData = $objDLotteryEventsVote->getThisEventData ( $events_id );
-
- $this->tpl = 'admin/lottery/event_vote_list';
- $title = '投票详情';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'eventsData', $eventsData );
- $this->setOutput ( 'eventsVoteType', $eventsVoteType );
- $this->setOutput ( 'voteData', $voteData );
- }
-
- /**
- * 页面: 修改投票页
- */
- public function doUpEventVotePage() {
- $vote_id = Request::g ( 'vote_id' );
- $objDLotteryEventsVote = new LotteryEventsVote ();
- $voteOneData = $objDLotteryEventsVote->get ( $vote_id );
- $this->tpl = 'admin/lottery/up_event_vote';
- $title = '修改投票';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->setOutput ( 'voteOneData', $voteOneData );
- }
-
- /**
- * 事件: 修改投票信息
- */
- public function doUpEventVote() {
- $vote_id = Request::p ( 'vote_id' );
- $add_num = Request::p ( 'add_num' );
- $title = Request::p ( 'title' );
- $img_url = Request::p ( 'old_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
- );
- $objDLotteryEventsVote->modify ( $info, array (
- 'id' => $vote_id
- ) );
- header ( "Location: " . Request::schemeDomain () . "/?c=admin_Lottery&a=EventVotePage&events_id={$events_id}" );
- }
- public function doAddEventVote() {
- if (Request::isPost ()) {
- $title = Request::p ( 'title' );
- $events_id = Request::p ( 'events_id' );
-
- $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) {
- self::ajax_fail_exit ( '数据库操作失败' );
- }
-
- $this->redirect ( Request::schemeDomain () . "/?c=admin_Lottery&a=UpEventVotePage&vote_id={$id}" );
- } else {
- $events_id = Request::g ( 'events_id' );
- $this->tpl = 'admin/lottery/add_event_vote';
- $title = '修改投票';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( '添加投票项', Request::url (), '_self' );
- $this->setOutput ( 'events_id', $events_id );
- }
- }
-
- /**
- * 事件:ajax 创建投票活动
- */
- public function doCreateVote() {
- $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 );
- }
- $this->ajax_success_exit ( '创建成功' );
- }
-
- /**
- * 事件:ajax 创建收集字母
- */
- public function doCreateLetters() {
- $events_id = Request::p ( 'events_id' );
- $lettersText = Request::p ( 'lettersText' );
- $data = explode ( '@', $lettersText );
- $objDLotteryEvents = new LotteryEvents ();
- $info = array (
- 'ABC_data' => $data
- );
- $objDLotteryEvents->modify ( $info, array (
- 'id' => $events_id
- ) );
- $objDLotteryEventsLetters = new LotteryEventsLetters ();
- $objMLotteryDrawLetters = new LotteryDrawLetters ( null, $events_id );
-
- foreach ( $data as $key => $data ) {
- $info = array (
- 'ABC_name' => $data,
- 'events_id' => $events_id
- );
- $id = $objDLotteryEventsLetters->add ( $info );
- $objMLotteryDrawLetters->clear_draw_next_time ( $id );
- }
- $this->ajax_success_exit ( '创建成功' );
- }
-
- /**
- * 页面:添加奖项页面
- */
- public function doAddPrizePage() {
- $events_id = Request::g ( 'events_id' );
- $events_Data = $this->objLottery->getOneLotteryEvents ( $events_id );
- $objDLotteryEvents = new LotteryEvents ();
- $eventsType = $objDLotteryEvents->getType ();
- $eventsDisplayStatus = $objDLotteryEvents->getDisplay ();
- $objDLotteryPrize = new LotteryPrize ();
- $prizeType = $objDLotteryPrize->getType ();
- $prizeDisplayStatus = $objDLotteryPrize->getDisplay ();
- $prizeExpress = $objDLotteryPrize->getExpress ();
- $this->tpl = 'admin/lottery/add_prize';
- $title = '添加奖项';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'events_id', $events_id );
- $this->setOutput ( 'eventsType', $eventsType );
- $this->setOutput ( 'prizeExpress', $prizeExpress );
- $this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
- $this->setOutput ( 'prizeType', $prizeType );
- $this->setOutput ( 'prizeDisplayStatus', $prizeDisplayStatus );
- $this->setOutput ( 'events_Data', $events_Data );
- }
-
- /**
- * 事件:添加奖项
- */
- public function doAddPrize() {
- $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 ( '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 = '';
- $tmpImgData = $this->loadImg ();
- if (is_array ( $tmpImgData )) {
- $img_url = $tmpImgData ['url'] [0];
- }
- $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
- );
- $this->objLottery->addLotteryPrize ( $info );
- header ( "Location: " . Request::schemeDomain () . "/?c=admin_Lottery&a=EventPage&events_id={$events_id}" );
- }
-
- /**
- * 事件:增加奖项数量[虚拟,实物]
- */
- public function doAddPrizeNum() {
- $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 );
- header ( "Location: " . Request::schemeDomain () . "/?c=admin_Lottery&a=EventPage&events_id={$events_id}" );
- }
-
- /**
- * 事件ajax:减少奖项数量[实物]
- */
- public function doMinusPrizeNum() {
- $prize_id = Request::p ( 'pirze_id' );
- $num = Request::p ( 'num' );
- $this->objLottery->addLotteryPrizeNum ( $prize_id, - $num );
- $this->ajax_success_exit ( '操作成功' );
- }
-
- /**
- * 事件:修改奖项
- */
- public function doUpPrize() {
- $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 ( 'old_img_url' );
- $tmpImgData = $this->loadImg ();
- if (is_array ( $tmpImgData )) {
- $img_url = $tmpImgData ['url'] [0];
- }
- $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
- ) );
- header ( "Location: " . Request::schemeDomain () . "/?c=admin_Lottery&a=EventPage&events_id={$events_id}" );
- }
-
- /**
- * 页面:修改奖项页
- */
- public function doUpPrizePage() {
- $prize_id = Request::g ( 'prize_id' );
- $prize_data = $this->objLottery->getOneLotteryPrize ( $prize_id );
- $prize_data ['black_list'] = join ( "\n", $prize_data ['black_list'] );
- $prize_data ['hundred_percent_list'] = join ( "\n", $prize_data ['hundred_percent_list'] );
- $prize_data ['white_list'] = join ( "\n", $prize_data ['white_list'] );
- $event_data = $this->objLottery->getOneLotteryEvents ( $prize_data ['events_id'] );
- $objDLotteryEvents = new LotteryEvents ();
- $eventsType = $objDLotteryEvents->getType ();
- $eventsDisplayStatus = $objDLotteryEvents->getDisplay ();
- $objDLotteryPrize = new LotteryPrize ();
- $prizeType = $objDLotteryPrize->getType ();
- $prizeExpress = $objDLotteryPrize->getExpress ();
- $prizeDisplayStatus = $objDLotteryPrize->getDisplay ();
- $this->tpl = 'admin/lottery/up_prize';
- $title = '修改奖项';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'eventsType', $eventsType );
- $this->setOutput ( 'eventsDisplayStatus', $eventsDisplayStatus );
- $this->setOutput ( 'prizeType', $prizeType );
- $this->setOutput ( 'prizeExpress', $prizeExpress );
- $this->setOutput ( 'prizeDisplayStatus', $prizeDisplayStatus );
- $this->setOutput ( 'prize_data', $prize_data );
- $this->setOutput ( 'event_data', $event_data );
- }
-
- /**
- * 页面:获奖数据列表页
- */
- public function doLotteryDataListPage() {
- $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->tpl = 'admin/lottery/lottery_data_list';
- $title = '获奖数据列表';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $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 );
- }
-
- /**
- * 页面: 收集字母 数据
- */
- public function doLettersDataPage() {
- $events_id = Request::varGetInt ( 'events_id' );
- $objDLotteryEventsLetters = new LotteryEventsLetters ();
- $lettersData = $objDLotteryEventsLetters->getEventData ( $events_id );
- $eventsAndPrizeData = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
-
- $objMLotteryDrawLetters = new LotteryDrawLetters ( null, $events_id );
-
- foreach ( $lettersData as $key => $data ) {
- $lettersData [$key] ['next_time'] = $objMLotteryDrawLetters->getNextWinTime ( $data ['id'] );
- }
-
- $this->tpl = 'admin/lottery/event_letters_data';
- $title = '字母详情';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'lettersData', $lettersData );
-
- $this->setOutput ( 'eventsAndPrizeData', $eventsAndPrizeData );
- }
-
- /**
- * 页面: 用户收集字母列表
- */
- public function doLotteryEventsUserLettersPage() {
- $events_id = Request::varGetInt ( 'events_id' );
- $objDLotteryEventsLetters = new LotteryEventsLetters ();
- $lettersData = $objDLotteryEventsLetters->getEventData ( $events_id );
- $eventsAndPrizeData = $this->objLottery->getOneLotteryEventsAndPrize ( $events_id );
-
- $objDLotteryEventsUserLetters = new LotteryEventsUserLetters ();
- $condition = array (
- 'events_id' => $events_id
- );
- // 取数据
- $page = Request::varGetInt ( 'page', 1 );
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $allLotteryEventsIds = $objDLotteryEventsUserLetters->findIdsBy ( $condition, $limit, 'id desc' );
- $userData = $objDLotteryEventsUserLetters->gets ( $allLotteryEventsIds );
-
- foreach ( $userData as $key => $data ) {
- foreach ( $lettersData as $k => $d ) {
- if (isset ( $userData [$key] ['ABC_data'] [$d ['id']] )) {
- $userData [$key] ['ABC_data'] [$d ['id']] = array (
- 'state' => '已收集',
- 'ABC_name' => $d ['ABC_name']
- );
- } else {
- $userData [$key] ['ABC_data'] [$d ['id']] = array (
- 'state' => '未收集',
- 'ABC_name' => $d ['ABC_name']
- );
- ;
- }
- }
- }
-
- $total_num = $objDLotteryEventsUserLetters->totals ( $condition );
- $url_tpl = Request::schemeDomain () . "?c=admin_lottery&a=LotteryEventsUserLettersPage&events_id={$events_id}";
- $url_tpl .= "&page={page}";
- // 分页
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
- $this->tpl = 'admin/lottery/event_user_letters_list';
- $title = '用户收集字母列表';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'lettersData', $lettersData );
- $this->setOutput ( 'userData', $userData );
- $this->setOutput ( 'page_html', $page_html );
- $this->setOutput ( 'eventsAndPrizeData', $eventsAndPrizeData );
- }
-
- /**
- * 页面:修改收集字母数据
- */
- public function doUpLettersDataPage() {
- $letters_id = Request::varGetInt ( 'id' );
- $objDLotteryEventsLetters = new LotteryEventsLetters ();
- $letters_data = $objDLotteryEventsLetters->get ( $letters_id );
- $eventsAndPrizeData = $this->objLottery->getOneLotteryEventsAndPrize ( $letters_data ['events_id'] );
- $this->tpl = 'admin/lottery/up_letters';
- $title = '修改字母详情';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'letters_data', $letters_data );
- $this->setOutput ( 'eventsAndPrizeData', $eventsAndPrizeData );
- }
-
- /**
- * 事件:修改收集字母数据
- */
- public function doUpLettersData() {
- $id = Request::varPostInt ( 'letters_data_id' );
- $num = Request::varPostInt ( 'num' );
- $info = array (
- 'num' => $num
- );
- $tmpImgData = $this->loadImg ();
-
- if (is_array ( $tmpImgData )) {
- if ($tmpImgData ['url'] [1]) {
- $info ['img_1'] = $tmpImgData ['url'] [1];
- }
- if ($tmpImgData ['url'] [2]) {
- $info ['img_2'] = $tmpImgData ['url'] [2];
- }
- }
- $objDLotteryEventsLetters = new LotteryEventsLetters ();
- $condition = array (
- 'id' => $id
- );
- $objDLotteryEventsLetters->modify ( $info, $condition );
- $letters_data = $objDLotteryEventsLetters->get ( $id );
-
- $objMLotteryDrawLetters = new LotteryDrawLetters ( null, $letters_data ['events_id'] );
- $objMLotteryDrawLetters->clear_draw_next_time ( $id );
-
- header ( "Location: " . Request::schemeDomain () . "/?c=admin_Lottery&a=LettersDataPage&events_id={$letters_data['events_id']}" );
- }
-
- /**
- * 页面:虚拟数据列表页
- */
- public function doVirtualDataListPage() {
- $prize_id = Request::g ( 'prize_id' );
- $lottery_data_id = Request::g ( 'lottery_data_id' );
- $prizeData = $this->objLottery->getOneLotteryPrize ( $prize_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_Lottery&a=VirtualDataListPage&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 );
-
- $title = '虚拟数据列表';
- $this->setOutput ( 'title', $title );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'prizeVirtualData', $prizeVirtualData );
- $this->setOutput ( 'page_html', $page_html );
- $this->setOutput ( 'prizeData', $prizeData );
- $this->setOutput ( 'lotteryData', $lotteryData );
- $this->tpl = 'admin/lottery/prize_virtual_list';
- }
-
- /**
- * 事件ajax: 删除一条虚拟数据
- */
- public function doDelPrizeVirtual() {
- $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 doShowUserParticipateLogPage() {
- $events_id = Request::varGetInt ( 'events_id' );
- $groupByUid = Request::g ( 'groupByUid' );
-
- $objMLotteryLog = new LotteryLog ( null, $events_id );
-
- $eventData = $this->objLottery->getOneLotteryEvents ( $events_id );
- $this->setOutput ( 'eventData', $eventData );
-
- $page = Request::varGetInt ( 'page', 1 );
- $size = 20;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $order = ' id desc';
- if ($groupByUid) {
- $logData = $objMLotteryLog->findUserParticipateDataGroupByUid ( $limit, $order );
- } else {
- $condition = array (
- 'events_id' => $events_id
- );
-
- $logData = $objMLotteryLog->findUserParticipateData ( $condition, $limit, $order );
- }
-
- $uids = array ();
- foreach ( $logData as $key => $data ) {
- $uids [$data ['uid']] = $data ['uid'];
- }
-
- $objMWeixinUser = new WeixinUser ();
- $userData = $objMWeixinUser->gets ( $uids );
-
- $total_user_num = $objMLotteryLog->getUserParticipateLogNumGroupByUid ();
-
- if ($groupByUid) {
- $total_num = $total_user_num;
- } else {
- $total_num = $objMLotteryLog->getUserParticipateLogNum ( $condition );
- }
-
- $url_tpl = Request::schemeDomain () . "?c=admin_lottery&a=ShowUserParticipateLogPage&events_id={$events_id}";
- $url_tpl .= "&page={page}";
- // 分页
- $objPage = new Page ( $total_num, $url_tpl, $page, $size );
- $page_html = $objPage->html ();
- $this->tpl = 'admin/lottery/event_user_participate_log_list';
- $title = '查看用户参与活动日志';
- $this->setOutput ( 'title', $title );
- $this->setOutput ( 'page_html', $page_html );
- $this->addNavMenu ( '活动管理' );
- $this->addNavMenu ( $title, Request::url (), '_self' );
- $this->setOutput ( 'logData', $logData );
- $this->setOutput ( 'userData', $userData );
- $this->setOutput ( 'groupByUid', $groupByUid );
- $this->setOutput ( 'total_user_num', $total_user_num );
- }
-
- /**
- * 导出:获取用户参与活动日志
- * ?c=admin_lottery&a=ShowUserParticipateLogExportData&events_id=x
- * ?c=admin_lottery&a=ShowUserParticipateLogExportData&groupByUid=true&events_id=x
- */
- public function doShowUserParticipateLogExportData() {
- $events_id = Request::varGetInt ( 'events_id' );
- $groupByUid = Request::g ( 'groupByUid' );
-
- $datalist = array ();
- $objMLotteryLog = new LotteryLog ( null, $events_id );
-
- $allData = array ();
- if ($groupByUid) {
- $allData = $objMLotteryLog->findUserParticipateDataGroupByUid ();
- } else {
- $condition = array (
- 'events_id' => $events_id
- );
- $allData = $objMLotteryLog->findUserParticipateData ( $condition );
- }
-
- $uids = array ();
- foreach ( $allData as $key => $data ) {
- $uids [$data ['uid']] = $data ['uid'];
- }
- $objMWeixinUser = new WeixinUser ();
- $userData = $objMWeixinUser->gets ( $uids );
-
- $filename = '' . date ( 'YmdHis' ) . '.csv';
- header ( "Content-Type: application/vnd.ms-excel; charset=GBK" );
- header ( "Pragma: public" );
- header ( "Expires: 0" );
- header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header ( "Content-Type: application/force-download" );
- header ( "Content-Type: application/octet-stream" );
- header ( "Content-Type: application/download" );
- header ( 'Content-Disposition: attachment; filename=' . $filename );
- header ( "Content-Transfer-Encoding: binary " );
-
- $titleTag = '用户ID,昵称,时间,其他' . "\n";
-
- foreach ( $allData as $data ) {
- if (isset ( $data ['other'] )) {
- $otherStr = '';
- foreach ( $data ['other'] as $k => $d ) {
- $otherStr = $otherStr . $k . $d;
- }
- $titleTag .= $data ['uid'] . ',' . $userData [$data ['uid']] ['nickname'] . ',' . date ( 'Y-m-d H:i:s', $data ['create_time'] ) . ',' . $otherStr . "\n";
- } else {
- $titleTag .= $data ['uid'] . ',' . $userData [$data ['uid']] ['nickname'] . ',' . date ( 'Y-m-d H:i:s', $data ['create_time'] ) . ',空' . "\n";
- }
- }
-
- $titleTag = Convert::u82gb ( $titleTag );
-
- exit ( $titleTag );
- }
- public function display() {
- return $this->render ();
- }
-
- /**
- * 图片上传
- */
- 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;
- Image::transformFormat ( $file_path, $z_file_path, 'JPG' );
- /*
- * $img = imagecreatefromjpeg ( $z_file_path );
- * // 获取拍摄角度 旋转图片
- * $exifData = exif_read_data ( $file_path );
- * if (isset ( $exifData ['Orientation'] ) && $exifData ['Orientation'] == 6) {
- * $new = imagerotate ( $img, - 90, 0 );
- * imagejpeg ( $new, $z_file_path, 65 );
- * imagedestroy ( $new );
- * } else {
- * imagejpeg ( $img, $z_file_path, 65 );
- * imagedestroy ( $img );
- * }
- */
- @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+)+$/'
- )
- );
- }
- }
|