Express.class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. # 获取用户信息
  73. $objUserData = new UserInfo();
  74. $uid = $this->getRunTimeUid();
  75. $userData = $objUserData -> get($uid);
  76. $lottery_data_id = Request::g('lottery_data_id');
  77. if (!Verify::unsignedInt($lottery_data_id)) {
  78. self::ajax_fail_exit('修改失败');
  79. }
  80. $objMlottery = new Lottery();
  81. $objDLotteryUserExpress = new LotteryUserExpress();
  82. $lotteryData = $objMlottery-> getOneLotteryData($lottery_data_id);
  83. if(!isset($lotteryData['uid'])||$lotteryData['uid']!=$uid){
  84. self::ajax_fail_exit('修改失败');
  85. }
  86. $info = array(
  87. 'uid' => $uid,
  88. 'user_name' => $realname,
  89. 'phone' => $phone,
  90. 'address' => $address
  91. );
  92. $objDLotteryUserExpress -> add($info,AbstractDao::PARAM_CREATE_ACTION_REPLACE);
  93. unset($info['uid']);
  94. $objDLotteryData = new LotteryData();
  95. $lotteryDataExpressInfo = array(
  96. 'express' => $info
  97. );
  98. $objDLotteryData -> modify($lotteryDataExpressInfo,array('id' => $lottery_data_id));
  99. self::ajax_success_exit('修改成功');
  100. }
  101. public function display() {
  102. return $this->render();
  103. }
  104. }