Skip to content

Instantly share code, notes, and snippets.

@brunokruse
Created March 10, 2014 18:50
Show Gist options
  • Save brunokruse/9471660 to your computer and use it in GitHub Desktop.
Save brunokruse/9471660 to your computer and use it in GitHub Desktop.
switch ($campaign['Campaign']['deal_type']) {
case 'lottery':
$enteredLotteryCount = $this->SpecialSaving->find('count', array(
'recursive' => -1,
'conditions' => array(
'private_token' => $private_token,
'campaign_id' => $campaign['Campaign']['id']
)
));
if ($enteredLotteryCount > 0) {
$result[$ckey]['entered_lottery'] = true;
}
$result[$ckey]['locked'] = true;
if (time() >= (strtotime($campaign['Campaign']['lottery_end_date']))) {
$winner = $this->Winner->find('count', array(
'conditions' => array(
'Winner.private_token' => $private_token,
'Winner.campaign_id' => $campaign['Campaign']['id']
)
));
if ($winner) {
$result[$ckey]['winner'] = true;
if (!empty($campaign['Campaign']['lottery_type']) AND $campaign['Campaign']['lottery_type'] == 'special') {
$result[$ckey]['lottery_contact'] = $campaign['Campaign']['lottery_contact'];
$result[$ckey]['lottery_contact_phone'] = $campaign['Campaign']['lottery_contact_phone'];
$result[$ckey]['lottery_code'] = $campaign['Campaign']['lottery_code'];
$result[$ckey]['discount'] = '';
$result[$ckey]['discount_percent'] = '';
} else {
$result[$ckey]['locked'] = false;
}
}
}
$result[$ckey]['lottery_end_date'] = strtotime($campaign['Campaign']['lottery_end_date']);
break;
case 'unlock':
$scanCount = count($campaign['Scan']);
$result[$ckey]['number_of_scan'] = $scanCount;
$result[$ckey]['scan_limit'] = (int) $campaign['Campaign']['scan_limit'];
if ($campaign['Campaign']['scan_limit'] < $scanCount) {
$result[$ckey]['locked'] = true;
}
break;
case 'social':
if (count($campaign['Social']) == 0) {
$result[$ckey]['locked'] = true;
}
break;
default:
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment