Exemple #1
0
 public function actionHitAd()
 {
     if (Rays::isAjax()) {
         $adId = (int) $_POST['adId'];
         $ad = Ads::get($adId);
         if ($ad !== null) {
             (new Counter())->increaseCounter($adId, Ads::ENTITY_TYPE);
             //Ad访问计数器
             /** TODO 刷广告访问监测机制 */
             $user = User::get($ad->userId);
             if ($user !== null) {
                 $wallet = $user->getWallet();
                 //访问一次挣一元钱
                 $wallet->addMoney(1);
             }
         }
     }
 }
Exemple #2
0
 public function testGet()
 {
     $response = Ads::get()->setSelectionCriteria((new AdsSelectionCriteria())->setCampaignIds([CampaignsTest::DEFAULT_CAMPAIGN]))->setFieldNames([AdFieldEnum::Id, AdFieldEnum::State])->setTextAdFieldNames([TextAdFieldEnum::VCardId, TextAdFieldEnum::Href, TextAdFieldEnum::SitelinkSetId])->sendRequest(self::$connection);
     $ads = $response->getResult('Ads');
     $this->assertEquals(self::DEFAULT_AD, $ads[0]->Id);
 }