12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace Cas\Controller;
- use Cas\Module\Lottery;
- use Cas\Dao\LotteryUserHelp;
- use Cas\Dao\LotteryUserHelpLog;
- use KIF\Verify;
- use KIF\Core\Request;
- class UserHelp extends EventsController {
- public function doApply() {
-
- # 1.必要参数验证
- $uid = $this->getRunTimeUid();
- if (!Verify::unsignedInt($uid)) {
- self::ajax_fail_exit('无效用户id');
- }
- $help_id = Request::g('help_id');
- if (!Verify::unsignedInt($help_id)) {
- self::ajax_fail_exit('无效试用id');
- }
- $source_user = Request::g('source_user');
- if (!Verify::unsignedInt($source_user)) {
- self::ajax_fail_exit('无效用户id');
- }
- if ($uid == $source_user) {
- self::ajax_fail_exit('不能给自己助力');
- }
- $help_session = Request::g('help_session');
- $state = $this->shareSession($help_id, $source_user, $help_session);
- if (!$state) {
- self::ajax_fail_exit('无效试用id');
- }
-
- $events_id = Request::g('events_id');
- if (!Verify::unsignedInt($events_id)) {
- self::ajax_fail_exit('无效试用id');
- }
-
- $this->LotteryUserHelpLog = new LotteryUserHelpLog ();
- $this->LotteryUserHelp = new LotteryUserHelp ();
- $totals = $this->LotteryUserHelpLog->totals(array('help_id' => $help_id));
- $this->LotteryUserHelp->modify(array('num' => $totals), array('id' => $help_id));
- $condition = array
- (
- 'help_id' => $help_id,
- 'events_id' => $events_id,
- 'uid' => $uid,
- );
- $info = $this->LotteryUserHelpLog->fetchOne ( $condition);
- if ($info) {
- self::ajax_fail_exit('您只能助力一次');
- # modify
- $this->LotteryUserHelpLog->modify($condition, array('id' => $info['id']));
- } else {
- # add
- $id = $this->LotteryUserHelpLog->add($condition);
- }
-
- self::ajax_success_exit();
- }
- public function display() {
- return $this->render ();
- }
- }
-
|