Express.class.php 4.2 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\LotteryUserExpress;
  9. use Cas\Dao\UserInfo;
  10. /**
  11. * 修改收获信息 (用户填写收货信息的页面)
  12. * lihuanchun
  13. * 着急写的:以后重新改
  14. *
  15. */
  16. class Express 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. # 获取用户最新收货地址
  27. $objDLotteryUserExpress = new LotteryUserExpress();
  28. $userExpress = $objDLotteryUserExpress -> getUserExpress($uid);
  29. $lottery_data_id = Request::g('lottery_data_id');
  30. if (!Verify::unsignedInt($lottery_data_id)) {
  31. self::fail_exit('无效id');
  32. }
  33. $objMlottery = new Lottery();
  34. $lotteryData = $objMlottery-> getOneLotteryData($lottery_data_id);
  35. if(!isset($lotteryData['uid'])||$lotteryData['uid']!=$uid){
  36. self::echo_404();
  37. }
  38. $prize_id = $lotteryData['prize_id'];
  39. $prizeData = array();
  40. $prizeData['prize_name'] = $lotteryData['run_time_data']['prize'][$prize_id]['prize_name'];
  41. $prizeData['img_url'] = $lotteryData['run_time_data']['prize'][$prize_id]['img_url'];
  42. $this->setOutput('title', '填写收货信息');
  43. $this->setOutput('lotteryData', $lotteryData);
  44. $this->setOutput('prizeData', $prizeData);
  45. $this->setOutput('userExpress', $userExpress);
  46. $up = isset($_REQUEST['up'])?$_REQUEST['up']:null;
  47. $this->setOutput('upAction',$up );
  48. $this->setOutput('notShowWeixinShare', true);
  49. $r = Request::g('r');
  50. if ($r) {
  51. $r = base64_decode($r);
  52. $this->setOutput('refer', $r);
  53. }
  54. $this->tpl = 'express';
  55. }
  56. /**
  57. * 事件ajax : 修改收货地址
  58. */
  59. public function doUpExpress() {
  60. $realname = Request::g('realname');
  61. if (!$realname) {
  62. self::ajax_fail_exit('请填写姓名');
  63. }
  64. $phone = Request::g('phone');
  65. if (!$phone) {
  66. self::ajax_fail_exit('请填写有效手机号码');
  67. }
  68. $address = Request::g('address');
  69. if (!$address) {
  70. self::ajax_fail_exit('请填写收货地址');
  71. }
  72. $sex = Request::g('sex');
  73. if (!$sex) {
  74. $sex = 1;
  75. }
  76. # 获取用户信息
  77. $objUserData = new UserInfo();
  78. $uid = $this->getRunTimeUid();
  79. $userData = $objUserData -> get($uid);
  80. $lottery_data_id = Request::g('lottery_data_id');
  81. if (!Verify::unsignedInt($lottery_data_id)) {
  82. self::ajax_fail_exit('修改失败');
  83. }
  84. $objMlottery = new Lottery();
  85. $objDLotteryUserExpress = new LotteryUserExpress();
  86. $lotteryData = $objMlottery-> getOneLotteryData($lottery_data_id);
  87. if(!isset($lotteryData['uid'])||$lotteryData['uid']!=$uid){
  88. self::ajax_fail_exit('修改失败');
  89. }
  90. $info = array(
  91. 'uid' => $uid,
  92. 'user_name' => $realname,
  93. 'phone' => $phone,
  94. 'address' => $address,
  95. 'sex' => $sex,
  96. );
  97. $objDLotteryUserExpress -> add($info,AbstractDao::PARAM_CREATE_ACTION_REPLACE);
  98. unset($info['uid']);
  99. $objDLotteryData = new LotteryData();
  100. $lotteryDataExpressInfo = array(
  101. 'express' => $info
  102. );
  103. $objDLotteryData -> modify($lotteryDataExpressInfo,array('id' => $lottery_data_id));
  104. self::ajax_success_exit('修改成功');
  105. }
  106. /**
  107. * 事件ajax : 只修改收货地址
  108. */
  109. public function doUpExpressYes() {
  110. $realname = Request::g('realname');
  111. if (!$realname) {
  112. self::ajax_fail_exit('请填写姓名');
  113. }
  114. $phone = Request::g('phone');
  115. if (!$phone) {
  116. self::ajax_fail_exit('请填写有效手机号码');
  117. }
  118. $address = Request::g('address');
  119. if (!$address) {
  120. self::ajax_fail_exit('请填写收货地址');
  121. }
  122. $sex = Request::g('sex');
  123. if (!$sex) {
  124. $sex = 1;
  125. }
  126. # 获取用户信息
  127. $objUserData = new UserInfo();
  128. $uid = $this->getRunTimeUid();
  129. $userData = $objUserData -> get($uid);
  130. $objDLotteryUserExpress = new LotteryUserExpress();
  131. $info = array(
  132. 'uid' => $uid,
  133. 'user_name' => $realname,
  134. 'phone' => $phone,
  135. 'address' => $address,
  136. 'sex' => $sex,
  137. );
  138. $objDLotteryUserExpress -> add($info,AbstractDao::PARAM_CREATE_ACTION_REPLACE);
  139. unset($info['uid']);
  140. self::ajax_success_exit('修改成功');
  141. }
  142. public function display() {
  143. return $this->render();
  144. }
  145. }