123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?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 doTest() {
- $this->LotteryUserHelp = new LotteryUserHelp ();
- $condition = array();
- $helpData = $this->LotteryUserHelp->fetchAll ($condition, 1000000, 'id desc');
- foreach ($helpData as $k => $v) {
- $this->LotteryUserHelp->modify(array('num' => $v['nums']), array('id' => $v['id']));
- }
- echo 'yes';die;
- }
- 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 ();
- $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);
- }
- $totals = $this->LotteryUserHelpLog->totals(array('help_id' => $help_id));
- $this->LotteryUserHelp->modify(array('num' => $totals), array('id' => $help_id));
-
- self::ajax_success_exit();
- }
- public function display() {
- return $this->render ();
- }
- }
-
|