TryDetail.class.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace Cas\Controller;
  3. use KIF\Core\Request;
  4. use KIF\Verify;
  5. use Cas\Module\LotteryEventsTypeTry;
  6. /**
  7. *
  8. * 试用
  9. */
  10. class TryDetail extends Controller {
  11. public function doDefault() {
  12. $tryid = Request::g('tryid');
  13. if (!Verify::unsignedInt($tryid)) {
  14. self::fail_exit('无效id');
  15. }
  16. $uid = $this->getRunTimeUid();
  17. $objLotteryEventsTypeTry = new LotteryEventsTypeTry($uid, $tryid);
  18. $tryInfo = $objLotteryEventsTypeTry->getEventsData();
  19. $checkResult = self::checkLoginStatus($tryInfo['authorize'], Request::url());
  20. if (!$checkResult->isSuccess()) {
  21. self::redirect($checkResult->getData());
  22. }
  23. $this->tpl = 'tryDetail';
  24. $this->setOutput('title', '免费试用');
  25. $this->setOutput('tryInfo', $tryInfo);
  26. }
  27. public function doApply() {
  28. $realname = Request::g('realname');
  29. if (!$realname) {
  30. self::ajax_fail_exit('请填写姓名');
  31. }
  32. $phone = Request::g('phone');
  33. if (!$phone) {
  34. self::ajax_fail_exit('请填写有效手机号码');
  35. }
  36. $address = Request::g('address');
  37. if (!$address) {
  38. self::ajax_fail_exit('请填写收货地址');
  39. }
  40. $content = Request::g('content');
  41. if (!$content) {
  42. self::ajax_fail_exit('请填写申请宣言');
  43. }
  44. $uid = $this->getRunTimeUid();
  45. if (!Verify::unsignedInt($uid)) {
  46. self::ajax_fail_exit('无效用户id');
  47. }
  48. $tryid = Request::g('tryid');
  49. if (!Verify::unsignedInt($tryid)) {
  50. self::ajax_fail_exit('无效试用id');
  51. }
  52. $objLotteryEventsTypeTry = new LotteryEventsTypeTry($uid, $tryid);
  53. $tmpResult = $objLotteryEventsTypeTry->userTry($realname, $phone, $address, $content);
  54. if (!$tmpResult->isSuccess()) {
  55. self::ajax_fail_exit($tmpResult->getData());
  56. }
  57. self::ajax_success_exit();
  58. }
  59. public function display() {
  60. return $this->render();
  61. }
  62. }