| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | <?phpnamespace 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 ();		$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 ();	}}	
 |