FeedBack.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. namespace Cas\Controller;
  3. use Cas\Dao\LotteryData;
  4. use KIF\Dao\AbstractDao;
  5. use Cas\Module\Lottery;
  6. use KIF\Core\Request;
  7. use KIF\Verify;
  8. use Cas\Dao\UserInfo;
  9. use Cas\Dao\LotteryUserFeedback;
  10. use Cas\Module\LotteryEventsTypeTry;
  11. use KIF\String\Filter;
  12. use Cas\Dao\LotteryEventsForms;
  13. /**
  14. * 反馈评价
  15. */
  16. class FeedBack extends EventsController {
  17. /**
  18. * 页面:默认修改页
  19. */
  20. public function doDefault() {
  21. # 获取用户信息
  22. $objUserData = new UserInfo();
  23. $uid = $this->getRunTimeUid();
  24. $userData = $objUserData -> get($uid);
  25. $this->setOutput('userData', $userData);
  26. $lottery_data_id = Request::g('lottery_data_id');
  27. if (!Verify::unsignedInt($lottery_data_id)) {
  28. self::fail_exit('无效id');
  29. }
  30. $objMlottery = new Lottery();
  31. $lotteryData = $objMlottery-> getOneLotteryData($lottery_data_id);
  32. if(!isset($lotteryData['uid'])||$lotteryData['uid']!=$uid){
  33. self::echo_404();
  34. }
  35. $objLotteryUserFeedback = new LotteryUserFeedback();
  36. $data = array();
  37. $data['uid'] = $uid;
  38. $data['events_id'] = $lotteryData['events_id'];
  39. $data['lottery_data_id'] = $lottery_data_id;
  40. $data['status'] = 1;
  41. $ids = $objLotteryUserFeedback->findIdsBy ( $data, 1, $order = ' id desc');
  42. $feedback = $objLotteryUserFeedback->gets ( $ids );
  43. if ($feedback) {
  44. $feedback = array_pop($feedback);
  45. if ($feedback['pic']) {
  46. $feedback['pic'] = explode(',', $feedback['pic']);
  47. }
  48. }
  49. $this->setOutput('lottery_data_id', $lottery_data_id);
  50. $this->setOutput('title', '填写评价信息');
  51. $this->setOutput('lotteryData', $lotteryData);
  52. $this->setOutput('feedback', $feedback);
  53. $up = isset($_REQUEST['up'])?$_REQUEST['up']:null;
  54. $this->setOutput('action', 'gift');
  55. $this->setOutput('upAction',$up );
  56. $this->setOutput('notShowWeixinShare', true);
  57. $r = Request::g('r');
  58. if ($r) {
  59. $r = base64_decode($r);
  60. $this->setOutput('refer', $r);
  61. $this->setOutput('action', '');
  62. }
  63. $this->setOutput('display', 1);
  64. $this->tpl = 'feedback';
  65. }
  66. /**
  67. * 事件ajax : 填写评价
  68. */
  69. public function doUp() {
  70. # 1.必要参数验证
  71. $uid = $this->getRunTimeUid();
  72. if (!Verify::unsignedInt($uid)) {
  73. self::ajax_fail_exit('无效用户id');
  74. }
  75. $lottery_data_id = Request::g('lottery_data_id');
  76. if (!Verify::unsignedInt($lottery_data_id)) {
  77. self::ajax_fail_exit('无效id');
  78. }
  79. $objMlottery = new Lottery();
  80. $lotteryData = $objMlottery-> getOneLotteryData($lottery_data_id);
  81. if(!$lotteryData){
  82. self::ajax_fail_exit('无效id');
  83. }
  84. if(!isset($lotteryData['uid'])||$lotteryData['uid']!=$uid){
  85. self::ajax_fail_exit('无效id');
  86. }
  87. $events_id = $lotteryData['events_id'];
  88. if (!Verify::unsignedInt($events_id)) {
  89. self::ajax_fail_exit('无效id');
  90. }
  91. $objMLottery = new Lottery();
  92. $eventData = $objMLottery->getOneLotteryEvents ( $events_id );
  93. if (!$eventData) {
  94. self::ajax_fail_exit('无效id');
  95. }
  96. $type = $eventData['type'];
  97. if (!in_array($type, array(4,6))) {
  98. self::ajax_fail_exit('无效类型');
  99. }
  100. # 以下为数据验证
  101. if ($type == 4) {
  102. # 验证是否有试用权限
  103. $objLotteryEventsTypeTry = new LotteryEventsTypeTry($uid, $events_id);
  104. $tmpData = $objLotteryEventsTypeTry -> userTry() ;
  105. if($tmpData->isSuccess()){
  106. self::ajax_fail_exit('没有申请');
  107. }
  108. }
  109. if ($type == 6) {
  110. # 验证是否有邀请函
  111. }
  112. $objLotteryUserFeedback = new LotteryUserFeedback();
  113. $data = array();
  114. $data['uid'] = $uid;
  115. $data['events_id'] = $events_id;
  116. $data['lottery_data_id'] = $lottery_data_id;
  117. $data['status'] = 1;
  118. $info = $objLotteryUserFeedback->fetchOne ( $data);
  119. $data['content'] = Request::g('content');
  120. $data['pic'] = Request::g('pic');
  121. if ($info) {
  122. $tmpResult = $objLotteryUserFeedback->modify($data, array (
  123. 'id' => $info['id']
  124. ));
  125. } else {
  126. $tmpResult = $objLotteryUserFeedback->add($data);
  127. }
  128. if (!$tmpResult) {
  129. self::ajax_fail_exit('错误的反馈信息');
  130. }
  131. self::ajax_success_exit();
  132. }
  133. public function display() {
  134. return $this->render();
  135. }
  136. }