| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | <?phpnamespace Cas\Module;use KIF\Verify;use Cas\Dao\LotteryEvents;use KIF\Core\Config;use Cas\Dao\LotteryPrize;use KIF\Cache\Memcached;use KIF\Dao\SqlHelper;use Cas\Dao\LotteryPrizeVirtualData;use Cas\Dao\LotteryData;use Cas\Module\LotteryLog;use Cas\Dao\LotteryEventsLog as DLog;use Cas\Module\Lottery;use Cas\Dao\LotteryEventsLetters;use Cas\Dao\LotteryEventsUserLetters;use Cas\Dao\LotteryEventsUserPrizeData;use KIF\Data\ResultWrapper;use KIF\Core\Request;use Cas\Dao\LotteryEventsVote;use Cas\Dao\LotteryEventsVoteUserLog;use Cas\Dao\LotteryEventsTry;use Cas\Dao\LotteryUserExpress;use KIF\Dao\AbstractDao;/** *	 *  试用 [模型] * * @author lihuanchun */class LotteryEventsTypeTry  {		private $uid;	private $events_id;	private $objMlottery;	private $objMLotteryLog;	private $thisTime;	private $objMLotteryEventsLimitations;	private $objDLotteryEventsTry;	private $objDLotteryUserExpress;			public function __construct($uid=null , $events_id=null ) {		$this->uid = $uid;		$this->events_id = $events_id;		$this->objMlottery = new Lottery();		$this->objMLotteryLog = new LotteryLog($uid,$events_id);		$this->thisTime = time();		$this->objMLotteryEventsLimitations = new LotteryEventsLimitations();				$this->objDLotteryEventsTry = new LotteryEventsTry();		$this->objDLotteryUserExpress = new LotteryUserExpress();	}			/**	 * 获取当前“试用”信息	 */	public function getEventsData(){		return $this->objMlottery->getOneLotteryEvents($this->events_id);	}			/**	 * 申请试用	 */	public function userTry(){				$eventsData = $this->objMlottery->getOneLotteryEvents($this->events_id);				# 活动是否开始		if($this->thisTime < $eventsData['begin_time'] || $this->thisTime > $eventsData['end_time']){			return ResultWrapper::fail('当前活动未开始');		}				# 活动的 用户行为限制		if(!$this->objMLotteryEventsLimitations->ckEventRestrictions($this->uid,Request::ip(), $this->events_id)){			return ResultWrapper::fail('您已提交过申请');		}				# 记录参与日志		$other = array(			'postData' => $_POST,			'getData' => $_GET		);		$this->objMLotteryLog ->addLog(DLog::LOG_TYPE_PARTICIPATION, $other);				return ResultWrapper::success('ok');	}		/**	 * 记录行为	 */	public function setLimitations(){		$this->objMLotteryEventsLimitations->setUserEventNum($this->uid, $this->events_id); // 记录用户参与UID(天)		$this->objMLotteryEventsLimitations->setIpEventNum(Request::ip(), $this->events_id);// 记录用户参与IP(天)		$this->objMLotteryEventsLimitations->setUserParticipationNum($this->uid, $this->events_id); // 记录用户参与次数				# 记录"参与成功"日志		$other = array();		$this->objMLotteryLog ->addLog(DLog::LOG_TYPE_PARTICIPATION_TRUE, $other);						# 记录"用户参与" other 表单内容		$other = array(				'表单内容:' => join(',', $_POST)		);		$this->objMLotteryLog ->addUserParticipateLog($other);					}	}
 |