$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) { // 中了几等奖 $price_level = $wls->draw_price();