123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?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;
- /**
- *
- * 用户资料设置
- */
- class Member extends EventsController {
-
- public function doDefault() {
- $this->tpl = 'member';
-
- }
-
-
- /**
- * 我的礼品
- */
- 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);
-
- $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();
- }
- }
|