123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- <?php
- namespace Cas\Controller;
- use Cas\Dao\LotteryData;
- use Cas\Dao\LotteryEvents;
- use KIF\Core\Request;
- use Cas\Module\Lottery;
- use Cas\Dao\UserInfo;
- use Cas\Dao\LotteryUserFeedback;
- use Cas\Dao\ArticleLikeCounter;
- use Cas\Dao\LotteryUserHelp;
- use Cas\Module\LotteryLog;
- use Cas\Dao\LotteryUserExpress;
- /**
- *
- * 用户资料设置
- */
- class Member extends EventsController {
-
- public function doDefault() {
- $this->tpl = 'member';
-
- }
-
- /**
- * 我的首页
- */
- public function doMy() {
- # 获取当前用户的信息
- $objUserData = new UserInfo();
- $uid = $this->getRunTimeUid();
- $userData = $objUserData -> get($uid);
- $this->setOutput('userData', $userData);
- $thisTime = time();
- # 获取登录地址
- $url = Request::g('url');
- $thisUrl = Request::schemeDomain().'/member/my';
- $loginUrl = $this -> getLoginUrl($thisUrl);
- $this->setOutput('loginUrl', $loginUrl);
-
- # 判断是否需要登录
- $ckLogin = $this->ckLogin();
- $this->setOutput('ckLogin', $ckLogin);
- # 获取我的助力值
- $condition = array (
- //'events_id' => $events_id,
- 'uid' => $uid,
- );
- $objLotteryUserHelp = new LotteryUserHelp();
- $info = $objLotteryUserHelp->fetchAll ( $condition, 10000, 'id desc' );
- $num = 0;
- if ($info) {
- foreach ($info as $k => $v) {
- $num += $v['num'];
- }
- }
- $this->tpl = 'my';
- $this->setOutput('thisTime', $thisTime);
- $this->setOutput('title', '我的');
- $this->setOutput('num', $num);
- $this->setOutput('action', 'gift');
- $this->setOutput('display', 1);
- $this->setOutput('notShowWeixinShare', true);
- }
- /**
- * 资料设置
- */
- public function doSet() {
- # 获取当前用户的信息
- $objUserData = new UserInfo();
- $uid = $this->getRunTimeUid();
- $userData = $objUserData -> get($uid);
- $this->setOutput('userData', $userData);
- $thisTime = time();
- # 获取登录地址
- $url = Request::g('url');
- $thisUrl = Request::schemeDomain().'/member/set';
- $loginUrl = $this -> getLoginUrl($thisUrl);
- $this->setOutput('loginUrl', $loginUrl);
-
- # 判断是否需要登录
- $ckLogin = $this->ckLogin();
- $this->setOutput('ckLogin', $ckLogin);
- # 获取用户最新收货地址
- $objDLotteryUserExpress = new LotteryUserExpress();
-
- $userExpress = $objDLotteryUserExpress -> getUserExpress($uid);
- # 获取我的资料
- $this->tpl = 'my_set';
- $this->setOutput('thisTime', $thisTime);
- $this->setOutput('title', '我的资料');
- $this->setOutput('my', $userExpress);
- $this->setOutput('action', 'gift');
- $this->setOutput('display', 1);
- $this->setOutput('notShowWeixinShare', true);
- }
- /**
- * 我参与的活动
- */
- public function doAct() {
- # 获取当前用户的信息
- $objUserData = new UserInfo();
- $uid = $this->getRunTimeUid();
- $userData = $objUserData -> get($uid);
- $this->setOutput('userData', $userData);
- $thisTime = time();
- # 获取登录地址
- $url = Request::g('url');
- $thisUrl = Request::schemeDomain().'/member/act';
- $loginUrl = $this -> getLoginUrl($thisUrl);
- $this->setOutput('loginUrl', $loginUrl);
-
- # 判断是否需要登录
- $ckLogin = $this->ckLogin();
- $this->setOutput('ckLogin', $ckLogin);
- $plat_form_id = $this->getPlatFormId();
- $objLottery = new Lottery();
- # 根据uid,得到参与的活动
- $objMLotteryLog = new LotteryLog ();
- $condition = array('uid' => $uid);
- $totals = $objMLotteryLog -> getUserParticipateLogNum($condition);
- $offset = 0;
- $size = 10;
-
- $data = $objMLotteryLog->findUserParticipateData($condition, "{$offset},{$size}", 'create_time desc');
- $events_ids = array();
- foreach($data as $key=> $d) {
- $events_ids[$d['events_id']] = $d['events_id'];
- }
- $objDLotteryEvents = new LotteryEvents();
- $eventsData = $objDLotteryEvents -> gets($events_ids);
- $objMLottery = new Lottery();
- # 剩余天数
- $TIME = time();
- $objArticleLikeCounter = new ArticleLikeCounter();
- foreach ($eventsData as $tmpKey => $tmpData) {
- $rday = ($tmpData['end_time'] - $TIME) / (24 * 60 * 60);
- $eventsData[$tmpKey]['rday'] = ceil($rday);
- # 参与人数
- $objMLotteryLog = new LotteryLog ( null, $tmpData['id'] );
- $eventsData[$tmpKey]['user_total'] = $objMLotteryLog->getUserParticipateLogNumGroupByUid ();
- if ($tmpData['type'] == 9) {
- # 阅读人数
- $eventsData[$tmpKey]['click_num'] = $tmpData['click_num'] + ($tmpData['article_pass_base_num']?$tmpData['click_num'] + $tmpData['article_pass_base_num']:0);
- # 点赞人数
- $eventsData[$tmpKey]['likes'] = $objArticleLikeCounter->getLikes($tmpData['id']);
- $eventsData[$tmpKey]['likes'] = $eventsData[$tmpKey]['likes'] + $tmpData['article_praise'];
- } else {
- if (isset($tmpData['base_num']) && $tmpData['base_num']) {
- $eventsData[$tmpKey]['user_total'] += $tmpData['base_num'];
- }
- }
- $eventsData[$tmpKey]['url'] = $objMLottery->getEventsUrl($tmpData['type'],$tmpData['create_time']);
- }
- $this->setOutput('eventsData', $eventsData);
- $this->setOutput('title', '我参与的活动');
- $this->setOutput('totals', ceil($totals / $size));
- $this->tpl = 'my_act';
- $this->setOutput('action', 'gift');
- $this->setOutput('plat_form_id', $plat_form_id);
- $this->setOutput('display', 1);
- $this->setOutput('notShowWeixinShare', true);
- }
- /**
- * 事件:ajax翻页
- */
- public function doActAjax() {
- $page = Request::varGetInt('page', 1);
- $thisTime = time();
- $objLottery = new Lottery();
-
- $uid = $this->getRunTimeUid();
- $condition = array('uid' => $uid);
-
- $totals = $objLottery -> getLotteryDataListNum($condition);
- $size = 10;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $data = $objLottery->getLotteryDataList($condition, "{$offset},{$size}", 'create_time desc');
-
- $newData = array();
- $events_ids = array();
-
- $events_ids = array();
- foreach($data as $key=> $d) {
- $events_ids[$d['run_time_data']['events']['id']] = $d['run_time_data']['events']['id'];
- }
- $objDLotteryEvents = new LotteryEvents();
- $eventsData = $objDLotteryEvents -> gets($events_ids);
- # 剩余天数
- $TIME = time();
- $objArticleLikeCounter = new ArticleLikeCounter();
- foreach ($eventsData as $tmpKey => $tmpData) {
- $rday = ($tmpData['end_time'] - $TIME) / (24 * 60 * 60);
- $eventsData[$tmpKey]['rday'] = ceil($rday);
- # 参与人数
- $objMLotteryLog = new LotteryLog ( null, $tmpData['id'] );
- $eventsData[$tmpKey]['user_total'] = $objMLotteryLog->getUserParticipateLogNumGroupByUid ();
- if ($tmpData['type'] == 9) {
- # 阅读人数
- $eventsData[$tmpKey]['click_num'] = $tmpData['click_num'] + ($tmpData['article_pass_base_num']?$tmpData['click_num'] + $tmpData['article_pass_base_num']:0);
- # 点赞人数
- $eventsData[$tmpKey]['likes'] = $objArticleLikeCounter->getLikes($tmpData['id']);
- $eventsData[$tmpKey]['likes'] = $eventsData[$tmpKey]['likes'] + $tmpData['article_praise'];
- } else {
- if (isset($tmpData['base_num']) && $tmpData['base_num']) {
- $eventsData[$tmpKey]['user_total'] += $tmpData['base_num'];
- }
- }
- }
-
- $this->setOutput('eventsData', $eventsData);
- $this->tpl = 'ajax_my_act';
- $this->ajax_success_exit($this->render(true));
- }
-
- /**
- * 我的礼品
- */
- public function doGifts() {
- //填写收货地址 c=Express&lottery_data_id=3
- $objLottery = new Lottery();
- $thisTime = time();
- $plat_form_id = $this->getPlatFormId();
-
- # 获取用户信息
- $objUserData = new UserInfo();
- $uid = $this->getRunTimeUid();
- $userData = $objUserData -> get($uid);
- $this->setOutput('userData', $userData);
- # 获取登录地址
- $url = Request::g('url');
- $thisUrl = Request::schemeDomain().'/member/gifts';
- $loginUrl = $this -> getLoginUrl($thisUrl);
- $this->setOutput('loginUrl', $loginUrl);
-
- # 判断是否需要登录
- $ckLogin = $this->ckLogin();
- $this->setOutput('ckLogin', $ckLogin);
-
- $condition = array('audit' => 2, 'uid' => $uid,'scratch_receive' => LotteryData::EVENT_SCRATCH_RECEIVE_TRUE);
- $totals = $objLottery -> getLotteryDataListNum($condition);
- $offset = 0;
- $size = 6;
- $order = 'id desc';
- $data = $objLottery->getLotteryDataList($condition, "{$offset},{$size}", 'create_time desc');
-
- $newData = array();
- $events_ids = array();
-
- $objLotteryUserFeedback = new LotteryUserFeedback();
- foreach($data as $key=> $d){
- $data[$key]['feedback'] = 1;//不需要填写反馈
- $events_ids[$d['run_time_data']['events']['id']] = $d['run_time_data']['events']['id'];
- if (in_array($d['run_time_data']['events']['type'], array(4,0))) {
- $data[$key]['feedback'] = 2;//未填写反馈
- $where = array();
- $where['uid'] = $d['uid'];
- $where['events_id'] = $d['run_time_data']['events']['id'];
- $where['status'] = 1;
-
- $ids = $objLotteryUserFeedback->findIdsBy ( $where, 1, $order = ' id desc');
- if ($ids) {
- $data[$key]['feedback'] = 3;//已填写反馈
- }
- /*
- if (isset($d['express']) && $d['express']) {
- $data[$key]['feedback'] = 2;//未填写反馈
- $where = array();
- $where['uid'] = $d['uid'];
- $where['events_id'] = $d['run_time_data']['events']['id'];
- $where['status'] = 1;
-
- $ids = $objLotteryUserFeedback->findIdsBy ( $where, 1, $order = ' id desc');
- if ($ids) {
- $data[$key]['feedback'] = 3;//已填写反馈
- }
- } else {
- $data[$key]['feedback'] = 4;//未填写收货地址
- }
- */
- }
- }
- $objDLotteryEvents = new LotteryEvents();
- $eventsData = $objDLotteryEvents -> gets($events_ids);
- $time = time();
- foreach($data as $key=> $d){
- $eventsInfo = $eventsData[$d['run_time_data']['events']['id']];
- if ($v['feedback'] == 3) {
- # 查看是否过期
- if ($time > $eventsInfo['end_time']) {
- $data[$key]['feedback'] = 5;//未填写收货地址并且已经过期
- }
- }
- $newData[$key] = array();
- $newData[$key]['feedback'] = $d['feedback'];
- $thisEventID = $d['run_time_data']['events']['id'];
- $newData[$key]['prize_id'] = $d['prize_id'];
- $newData[$key]['prize_name'] = $d['run_time_data']['prize'][$d['prize_id']]['prize_name'];
- $newData[$key]['prize_type'] = $d['run_time_data']['prize'][$d['prize_id']]['type'];
- $newData[$key]['prize_express'] = $d['run_time_data']['prize'][$d['prize_id']]['express'];
-
- if ($d['run_time_data']['events']['type'] == LotteryEvents::TYPE_EVENTS_CODE) {
- //$newData[$key]['prize_img_url'] = $d['run_time_data']['events']['weixinShare']['imgUrl'];
- $newData[$key]['prize_img_url'] = $d['run_time_data']['prize'][$d['prize_id']]['img_url'];
- } else {
- $newData[$key]['prize_img_url'] = $d['run_time_data']['prize'][$d['prize_id']]['img_url'];
- }
-
- $newData[$key]['events_id'] = $thisEventID;
- $newData[$key]['events_delivery'] = $eventsData[$thisEventID]['delivery'];
- $newData[$key]['events_name'] = $eventsData[$thisEventID]['events_name'];
- $newData[$key]['events_type'] = $eventsData[$thisEventID]['type'];
- $newData[$key]['end_time_receive_prizes'] = $eventsData[$thisEventID]['end_time_receive_prizes'];
- $newData[$key]['virtual_data'] = $d['virtual_data'];
- $newData[$key]['express'] = $d['express'];
- $newData[$key]['lottery_data_id'] = $key;
- $newData[$key]['show_up_express_a'] = false;
- if($newData[$key]['end_time_receive_prizes'] < time() && empty($newData[$key]['express'])){
- $newData[$key]['show_up_express_a'] = true;
- }
- $newData[$key]['url'] = $objLottery -> getEventsUrl($eventsInfo['type'],$eventsInfo['create_time'],$this->platform['url']);
- }
-
- $this->tpl = 'gifts';
- $this->setOutput('thisTime', $thisTime);
- $this->setOutput('title', '我的奖品');
- $this->setOutput('data', $data);
- $this->setOutput('newData', $newData);
- $this->setOutput('totals', ceil($totals / $size));
- $this->setOutput('action', 'gift');
- $this->setOutput('display', 1);
- $this->setOutput('notShowWeixinShare', true);
- }
-
-
- /**
- * 事件:ajax翻页
- */
- public function doAjax() {
- $page = Request::varGetInt('page', 1);
- $thisTime = time();
- $objLottery = new Lottery();
-
- $uid = $this->getRunTimeUid();
- $condition = array('audit' => 2, 'uid' => $uid,'scratch_receive' => LotteryData::EVENT_SCRATCH_RECEIVE_TRUE);
-
- $totals = $objLottery -> getLotteryDataListNum($condition);
- $order = 'create_time desc';
- $size = 6;
- $offset = ($page - 1) * $size;
- $limit = "{$offset},{$size}";
- $data = $objLottery->getLotteryDataList($condition, "{$offset},{$size}", 'create_time desc');
-
- $newData = array();
- $events_ids = array();
-
- $objLotteryUserFeedback = new LotteryUserFeedback();
- foreach($data as $key=> $d){
- $data[$key]['feedback'] = 1;//不需要填写反馈
- $events_ids[$d['run_time_data']['events']['id']] = $d['run_time_data']['events']['id'];
- if (in_array($d['run_time_data']['events']['type'], array(4,0))) {
- $data[$key]['feedback'] = 2;//未填写反馈
- $where = array();
- $where['uid'] = $d['uid'];
- $where['events_id'] = $d['run_time_data']['events']['id'];
- $where['status'] = 1;
-
- $ids = $objLotteryUserFeedback->findIdsBy ( $where, 1, $order = ' id desc');
- $info = $objLotteryUserFeedback->gets ( $ids );
- if ($info) {
- $data[$key]['feedback'] = 3;//已填写反馈
- }
- /*
- if (isset($d['express']) && $d['express']) {
- $data[$key]['feedback'] = 2;//未填写反馈
- $where = array();
- $where['uid'] = $d['uid'];
- $where['events_id'] = $d['run_time_data']['events']['id'];
- $where['status'] = 1;
-
- $ids = $objLotteryUserFeedback->findIdsBy ( $where, 1, $order = ' id desc');
- $info = $objLotteryUserFeedback->gets ( $ids );
- if ($info) {
- $data[$key]['feedback'] = 3;//已填写反馈
- }
- } else {
- $data[$key]['feedback'] = 4;//未填写收货地址
- }
- */
- }
- }
- $objDLotteryEvents = new LotteryEvents();
- $eventsData = $objDLotteryEvents -> gets($events_ids);
-
- foreach($data as $key=> $d){
- $newData[$key] = array();
- $thisEventID = $d['run_time_data']['events']['id'];
- $newData[$key]['prize_id'] = $d['prize_id'];
- $newData[$key]['prize_name'] = $d['run_time_data']['prize'][$d['prize_id']]['prize_name'];
- $newData[$key]['prize_type'] = $d['run_time_data']['prize'][$d['prize_id']]['type'];
- $newData[$key]['prize_express'] = $d['run_time_data']['prize'][$d['prize_id']]['express'];
-
- if ($d['run_time_data']['events']['type'] == LotteryEvents::TYPE_EVENTS_CODE) {
- $newData[$key]['prize_img_url'] = $d['run_time_data']['events']['weixinShare']['imgUrl'];
- } else {
- $newData[$key]['prize_img_url'] = $d['run_time_data']['prize'][$d['prize_id']]['img_url'];
- }
-
- $newData[$key]['events_id'] = $thisEventID;
- $newData[$key]['events_delivery'] = $eventsData[$thisEventID]['delivery'];
- $newData[$key]['events_name'] = $eventsData[$thisEventID]['events_name'];
- $newData[$key]['events_type'] = $eventsData[$thisEventID]['type'];
- $newData[$key]['end_time_receive_prizes'] = $eventsData[$thisEventID]['end_time_receive_prizes'];
- $newData[$key]['virtual_data'] = $d['virtual_data'];
- $newData[$key]['express'] = $d['express'];
- $newData[$key]['lottery_data_id'] = $key;
- $newData[$key]['show_up_express_a'] = false;
- if($newData[$key]['end_time_receive_prizes'] < time() && empty($newData[$key]['express'])){
- $newData[$key]['show_up_express_a'] = true;
- }
- }
-
- $this->setOutput('data', $data);
- $this->setOutput('newData', $newData);
- $this->tpl = 'ajax_gifts';
- $this->ajax_success_exit($this->render(true));
- }
-
-
-
-
- public function display() {
- return $this->render();
- }
- }
|