<?php

include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/services/WechatLotteryService.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/casarover/application/controllers/SessionController.php';
$cellphone = $_GET['cellphone'];
$wls = new WechatLotteryService();
$sc = new SessionController();
$openid = $sc->getCode();
if (isset($openid)) {
    $wls->save_winner_cellphone($openid, $cellphone);
    echo "{\"msg\":\"success\"}";
} else {
    echo "{\"error\":\"获取中奖信息失败!请点击上方抽奖按钮!\"}";
}
Ejemplo n.º 2
0
$json_obj = json_decode($res, true);
$access_token = $json_obj['access_token'];
$openid = $json_obj['openid'];
/** For your local testing: */
$pm = new PropertyManager();
$dummy_openid = $pm->getDummyOpenid();
if (empty($openid) && isset($dummy_openid)) {
    $openid = $dummy_openid;
}
/** localhost test context END.*/
// Lottery logic
if (isset($openid)) {
    $r = rand(0, 7);
    $gua = rand(0, 3);
    // Draw lottery. 抽奖放在这里
    $wls = new WechatLotteryService();
    // Today's drawing time. 第几次抽奖
    $today_time = $wls->save_onelot($openid);
    $rewardDao = new RewardDao();
    $reward_row = $rewardDao->getByOpenid($openid);
    if ($today_time == WechatLotteryService::OVER_LIMIT) {
        // Draw action over daily limit
        header("Location:result.php?price=-1&casa=" . $r . "&gua=" . $gua);
    } else {
        if ($reward_row) {
            // Already won, 中过奖了
            header("Location:result.php?price=0&casa=" . $r . "&gua=" . $gua);
        } else {
            $win = $wls->draw();
            // 中奖了
            if ($win) {