Beispiel #1
0
function processingPaymentRequest($m, $pid)
{
    //calulate previous month
    if ($m != '') {
        $date = date('Y-m', strtotime($m . " months"));
    } else {
        $dates = getAllDateFromTrackingSummary();
    }
    //get list publishers
    if (!empty($pid)) {
        $pids[] = $pid;
    } else {
        $pids = getAllIdPublishers();
    }
    //get list websites
    if (!empty($pids)) {
        foreach ($pids as $pid) {
            if (!empty($dates)) {
                foreach ($dates as $date) {
                    $date = date('Y-m', strtotime($date));
                    excuteSumPayment($pid, $date);
                }
            } else {
                excuteSumPayment($pid, $date);
            }
        }
    }
}
Beispiel #2
0
function processingPaymentRequest()
{
    //calulate previous month
    $date = date('Y-m', strtotime("0 month"));
    //get list publishers
    $pids = getAllIdPublishers();
    //get list websites
    if (!empty($pids)) {
        foreach ($pids as $pid) {
            //checking
            if (!checkExistPaymentRequest($pid, $date)) {
                //get list website id
                $wids = getAllIdWebsites($pid);
                $data = sumEarnPerCampaign($wids, $date);
                $campaigns = $data['campaign'];
                $prid = insertPaymentRequest($pid, $date, $data['total']);
                //payment request id
                if (!empty($campaigns)) {
                    foreach ($campaigns as $cpid => $campaign) {
                        $amount = $campaign['cost'];
                        $impression = $campaign['impression'];
                        $click = $campaign['click'];
                        if ($click != 0 && $impression != 0) {
                            $ctr = $click / $impression;
                        } else {
                            $ctr = 0;
                        }
                        insertPaymentRequestDetail($pid, $cpid, $prid, $amount, $impression, $click, $ctr, $date);
                    }
                }
            }
        }
    }
}