123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?php
- namespace Cas\Controller;
- use Cas\Dao\LotteryData;
- use KIF\Dao\AbstractDao;
- use Cas\Module\Lottery;
- use KIF\Core\Request;
- use KIF\Verify;
- use Cas\Dao\UserInfo;
- use Cas\Dao\LotteryUserFeedback;
- use Cas\Module\LotteryEventsTypeTry;
- use KIF\String\Filter;
- use Cas\Dao\LotteryEventsForms;
- /**
- * 反馈评价
- */
- class FeedBack extends EventsController {
-
- /**
- * 页面:默认修改页
- */
- public function doDefault() {
- # 获取用户信息
- $objUserData = new UserInfo();
- $uid = $this->getRunTimeUid();
- $userData = $objUserData -> get($uid);
- $this->setOutput('userData', $userData);
-
-
- $lottery_data_id = Request::g('lottery_data_id');
- if (!Verify::unsignedInt($lottery_data_id)) {
- self::fail_exit('无效id');
- }
-
-
-
- $objMlottery = new Lottery();
- $lotteryData = $objMlottery-> getOneLotteryData($lottery_data_id);
-
- if(!isset($lotteryData['uid'])||$lotteryData['uid']!=$uid){
- self::echo_404();
- }
- $objLotteryUserFeedback = new LotteryUserFeedback();
-
- $data = array();
- $data['uid'] = $uid;
- $data['events_id'] = $lotteryData['events_id'];
- $data['lottery_data_id'] = $lottery_data_id;
- $data['status'] = 1;
- $ids = $objLotteryUserFeedback->findIdsBy ( $data, 1, $order = ' id desc');
- $feedback = $objLotteryUserFeedback->gets ( $ids );
-
- if ($feedback) {
- $feedback = array_pop($feedback);
- if ($feedback['pic']) {
- $feedback['pic'] = explode(',', $feedback['pic']);
- }
-
- }
-
- $this->setOutput('lottery_data_id', $lottery_data_id);
- $this->setOutput('title', '填写评价信息');
- $this->setOutput('lotteryData', $lotteryData);
- $this->setOutput('feedback', $feedback);
- $up = isset($_REQUEST['up'])?$_REQUEST['up']:null;
- $this->setOutput('action', 'gift');
- $this->setOutput('upAction',$up );
- $this->setOutput('notShowWeixinShare', true);
- $r = Request::g('r');
- if ($r) {
- $r = base64_decode($r);
- $this->setOutput('refer', $r);
- $this->setOutput('action', '');
- }
- $this->setOutput('display', 1);
- $this->tpl = 'feedback';
- }
-
- /**
- * 事件ajax : 填写评价
- */
- public function doUp() {
- # 1.必要参数验证
- $uid = $this->getRunTimeUid();
- if (!Verify::unsignedInt($uid)) {
- self::ajax_fail_exit('无效用户id');
- }
- $lottery_data_id = Request::g('lottery_data_id');
- if (!Verify::unsignedInt($lottery_data_id)) {
- self::ajax_fail_exit('无效id');
- }
-
-
- $objMlottery = new Lottery();
- $lotteryData = $objMlottery-> getOneLotteryData($lottery_data_id);
-
- if(!$lotteryData){
- self::ajax_fail_exit('无效id');
- }
- if(!isset($lotteryData['uid'])||$lotteryData['uid']!=$uid){
- self::ajax_fail_exit('无效id');
- }
-
- $events_id = $lotteryData['events_id'];
- if (!Verify::unsignedInt($events_id)) {
- self::ajax_fail_exit('无效id');
- }
- $objMLottery = new Lottery();
- $eventData = $objMLottery->getOneLotteryEvents ( $events_id );
- if (!$eventData) {
- self::ajax_fail_exit('无效id');
- }
- $type = $eventData['type'];
- if (!in_array($type, array(4,6))) {
- self::ajax_fail_exit('无效类型');
- }
- # 以下为数据验证
- if ($type == 4) {
- # 验证是否有试用权限
- $objLotteryEventsTypeTry = new LotteryEventsTypeTry($uid, $events_id);
- $tmpData = $objLotteryEventsTypeTry -> userTry() ;
- if($tmpData->isSuccess()){
- self::ajax_fail_exit('没有申请');
- }
- }
- if ($type == 6) {
- # 验证是否有邀请函
- }
-
- $objLotteryUserFeedback = new LotteryUserFeedback();
-
- $data = array();
- $data['uid'] = $uid;
- $data['events_id'] = $events_id;
- $data['lottery_data_id'] = $lottery_data_id;
- $data['status'] = 1;
-
- $info = $objLotteryUserFeedback->fetchOne ( $data);
- $data['content'] = Request::g('content');
- $data['pic'] = Request::g('pic');
- if ($info) {
- $tmpResult = $objLotteryUserFeedback->modify($data, array (
- 'id' => $info['id']
- ));
- } else {
- $tmpResult = $objLotteryUserFeedback->add($data);
- }
-
- if (!$tmpResult) {
- self::ajax_fail_exit('错误的反馈信息');
- }
-
- self::ajax_success_exit();
- }
-
- public function display() {
- return $this->render();
- }
- }
|