Example #1
0
 public function getSchemaFields()
 {
     $model = AdvData::model();
     $fields = array('date', 'tag', 'download_number', 'star_level', 'commands', 'active_number', 'new_user', 'left_user_2days', 'left_user_7days', 'left_user_14days');
     $options = array();
     foreach ($fields as $field) {
         $options[$field] = $model->getAttributeLabel($field);
     }
     return $options;
 }
Example #2
0
    public function actionindex()
    {
        $date = date("Y-m-d", strtotime("1 days ago"));
        $subject = "{$date}   上传业务明细";
        $adv_data = AdvData::model();
        $dataList = $adv_data->getDayToTalData($date);
        foreach ($dataList as $key => $value) {
            $str = "";
            $email = "";
            $i = 1;
            foreach ($value as $val) {
                if ($i % 2 == 0) {
                    $bgcolor = "#E6E6FA";
                } else {
                    $bgcolor = "#FFFFFF";
                }
                $str .= "<tr align='center' bgcolor='{$bgcolor}'  style='height:35px;'>";
                $str .= "<td>{$val['date']}</td>";
                $str .= "<td>{$val['adv_name']}</td>";
                $str .= "<td>{$val['tag']}</td>";
                $str .= "<td>{$val['download_number']}</td>";
                $str .= "<td>{$val['price']}</td>";
                $str .= "<td>{$val['total_price']}</td>";
                $str .= "</tr>";
                $email = $val['email'];
            }
            $content = <<<EOF
        您好!
        <br/>
        <br/>
        <table  cellpadding="5" cellspacing="0" border="0"  style="font-size:14px; width:800px;border-bottom:1px solid #E6E6FA;">
            <tr>
                <th colspan='11' style="height:1px;" bgcolor="#5d6075"></th>
            </tr>

            <tr align="center"  bgcolor="#f0f2fd" style='height:40px; border-bottom:1px solid #f0f2fd;'>
                <td>日期</td>
                <td>业务</td>
                <td>包名</td>
                <td>下载量</td>
                <td>单价</td>
                <td>总价</td>
            </tr>
            {$str}
        </table>

EOF;
            if ($email) {
                Yii::app()->mailer->send($email, $subject, $content);
                sleep(2);
            }
        }
    }
Example #3
0
 private function _mailBody()
 {
     //改成前一天的
     $date = date('Y-m-d');
     $datas = AdvData::model()->getDailyTotalData($date);
     $body = '';
     foreach ($datas as $date => $data) {
         foreach ($data as $item) {
             $body .= "<tr><td>{$date}</td><td>{$item['adv_name']}</td><td>{$item['download_number']}</td><td>{$item['total_price']}</td></tr>";
         }
     }
     return $body ? '<table cellspacing="0" cellpadding="1" border="1"><tr><th>日期</th><th>业务名称</th><th>下载总量</th><th>总价</th></tr>' . $body . '</table>' : '暂无今日数据';
 }
Example #4
0
 public function getAttribute($field)
 {
     switch ($field) {
         case 'adv.name':
             return $this->advertise->name;
         case 'channel.name':
             return $this->channel->name;
         case 'cp.name':
             return $this->advertise->cp->name;
         case 'uploader.name':
             return $this->uploader->name;
     }
     return parent::getAttribute($field);
 }
Example #5
0
 public function actionUpdate()
 {
     $model = AdvData::model();
     $result = $model->findAll();
     foreach ($result as $v) {
         $download_number = $v['download_number'];
         $price = $v['price'];
         $income_price = $v['income_price'];
         if ($price > 0) {
             $profit_margin = sprintf("%01.2f", floatval(($income_price - $price) / $price) * 100);
         } else {
             $profit_margin = "0.00";
         }
         $data = array('profit_margin' => $profit_margin, 'profit' => sprintf("%01.2f", floatval($income_price - $price) * intval($download_number)), 'running_account' => sprintf("%01.2f", floatval($income_price) * intval($download_number)), 'total_price' => sprintf("%01.2f", floatval($price) * intval($download_number)));
         $model->updateByPk($v['id'], $data);
     }
 }
Example #6
0
<table class="table table-bordered">
    <thead>
    <tr>
        <?php 
foreach ($this->getAdminAttributes() as $field) {
    ?>
            <th>
                <?php 
    echo AdvData::model()->getAttributeLabel($field);
    ?>
            </th>
        <?php 
}
?>
    </tr>
    </thead>
    <tbody>
    <?php 
foreach ($models as $model) {
    $duplicated = $model->isDataExists();
    ?>
        <tr<?php 
    if ($duplicated) {
        ?>
 class="duplicated" <?php 
    }
    ?>
>
            <?php 
    foreach ($this->getAdminAttributes() as $field) {
        ?>
Example #7
0
 public function actionUpload()
 {
     $data = $this->convertTextTo2DArray($_POST['data']);
     if (isset($_POST['adv_id']) && $_POST['adv_id']) {
         //上传业务下多个渠道的数据
         $advertise = Advertise::model()->findByPk($_POST['adv_id']);
         $models = $advertise->generateAdvChannelData($data, true);
     }
     $results = array();
     foreach ($models as $model) {
         $adv_channel_id = $model->adv_channel_id;
         $date = $model->date;
         $tag = $model->tag;
         $update_data = array('tag' => $model->tag, 'download_number' => $model->download_number, 'profit' => $model->profit, 'profit_margin' => $model->profit_margin, 'running_account' => $model->running_account, 'total_price' => $model->total_price, 'price' => $model->price, 'income_price' => $model->income_price, 'star_level' => $model->star_level);
         //update
         $dataList = AdvData::model()->getAdvCtime($date, $tag);
         if ($dataList) {
             $ctime = $dataList->ctime;
         }
         if ($model->isDataExists() && $this->checkExpireTime($ctime)) {
             $results[] = $model->updateByDateandAdvChannelId($date, $tag, $update_data);
         } else {
             try {
                 if (!$model->isDataExists() && $model->save()) {
                     $results[] = $model->id;
                 }
             } catch (Exception $e) {
                 Yii::log(json_encode(array('error' => $model->getErrors())), 'error', __CLASS__ . '.' . __FUNCTION__);
             }
         }
     }
     $counts = count($results);
     echo json_encode(array('code' => count($results) != 0 ? 0 : -1, 'message' => count($results) != 0 ? '上传成功' : '上传失败'));
 }
Example #8
0
    private function _detailedTotalContent($startTime, $endTime, $subject)
    {
        $adv_data = AdvData::model();
        $dataList = $adv_data->getDayDataForIn($startTime, $endTime, true);
        if ($dataList) {
            $content = <<<EOF
        您好!
        <br/>
        <br/>
        {$subject}:总激活{$dataList['active_sum']},流水{$dataList['running_sum']},利润{$dataList['profit_sum']},利润率{$dataList['profit_margin_sum']}
EOF;
        } else {
            $content = "暂无业务汇总";
        }
        $emails = array('*****@*****.**');
        $emails = $this->_mailerList();
        Yii::app()->mailer->send($emails, $subject, $content);
    }
Example #9
0
 public function getName()
 {
     return AdvData::model()->getAttributeLabel($this->field);
 }