コード例 #1
0
 /**
  * @param $attr
  */
 private function translate($attr)
 {
     $ad = new AD();
     $types = $ad->get_all_labels(PDO::FETCH_KEY_PAIR);
     $attr['code'] = md5($attr['id'] . BAOBEI_SALT);
     $attr['quote_rmb'] = number_format($attr['quote_rmb'] / 100, 2);
     $attr['ad_type'] = $types[$attr['ad_type']];
     $attr['cate'] = ADModel::$CATE[$attr['cate']];
     $permissions = $ad->get_permissions(['ad_id' => $attr['id']]);
     $permissions = array_values($permissions);
     $attr['permissions'] = implode("\n<br>", $permissions);
     $attr['feedback'] = ADModel::$FEEDBACK[$attr['feedback']];
     $attr['ad_desc'] = preg_replace('/<span style="color: rgb\\(255, 0, 0\\);">(.*?)<\\/span>/', '', $attr['ad_desc']);
     // 过滤掉标红文字
     if (is_numeric($attr['channel'])) {
         $channel = new Channel();
         $attr['channel'] = $channel->get_channel(array('id' => $attr['channel']))[$attr['channel']];
     }
     if ($attr['agreement_id']) {
         $agreement = new Agreement();
         $agreements = $agreement->get_agreements_basic(['id' => $attr['agreement_id']]);
         $agreement = $agreements[$attr['agreement_id']];
         $attr['agreement'] = $agreement['company_short'] ? $agreement['company_short'] : $agreement['company'];
     }
     return $attr;
 }
コード例 #2
0
 public function get_list()
 {
     $pagesize = isset($_REQUEST['pagesize']) ? (int) $_REQUEST['pagesize'] : 100;
     $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 0;
     $page_start = $page * $pagesize;
     $filters = array('keyword' => $_REQUEST['keyword']);
     $service = new Channel();
     $admin = new Admin();
     $me = $_SESSION['id'];
     $relative = array();
     $relative_sales = $admin->get_sales_by_me($me);
     if ($relative_sales) {
         foreach ($relative_sales as $id => $value) {
             $relative[] = array('key' => $id, 'value' => $value);
         }
     }
     $channel_list = $service->get_my_channel($filters, $page_start, $pagesize);
     $total = $service->get_my_channel_total();
     $this->output(array('code' => 0, 'msg' => 'get', 'list' => $channel_list, 'total' => $total, 'options' => array('channel_types' => ChannelModel::$TYPE, 'relativeSales' => $relative_sales)));
 }
コード例 #3
0
 public static function get_crm_res()
 {
     $result = array();
     $now = date('Y-m-d');
     $three_months_before = date('Y-m-d', strtotime('-3 months'));
     $filters = array('salesman' => $_SESSION['id']);
     $channel_service = new Channel();
     $channel_list = $channel_service->get_channel_ads($filters);
     $payment_list = $channel_service->get_channel_payment($filters, $three_months_before, $now);
     $quote_list = $channel_service->get_channel_quote($filters, $three_months_before, $now);
     $quantity_list = $channel_service->get_channel_ads_nums($filters, $three_months_before, $now);
     foreach ($quote_list as $key => $quote) {
         $total = 0;
         foreach ($quote as $item) {
             $quote_rmb = $item['quote_rmb'];
             $nums = $item['nums'];
             $total += (int) $quote_rmb * (int) $nums;
         }
         $result[$key] = array('total' => $total);
     }
     foreach ($payment_list as $key => $payment) {
         $cycle_total = 0;
         $rmb_total = 0;
         foreach ($payment as $item) {
             $paid_time = $item['paid_time'];
             $invoice_time = $item['invoice_time'];
             $cycle_days = Utils::calculate_date($paid_time, $invoice_time);
             $cycle_total += self::judge_days($cycle_days);
             $rmb_total += $item['rmb'];
         }
         $quote_nums = count($payment);
         $score_cycle = round((int) $cycle_total / (ChannelModel::$MAX_SCORES['cycle'] * $quote_nums), 2);
         $result[$key] = array_merge($result[$key], array('score_cycle' => $score_cycle, 'rmb' => $rmb_total));
         if (isset($result[$key]['total'])) {
             $payment_rate = round($result[$key]['rmb'] / $result[$key]['total'], 2);
             $score_payment_rate = round((int) self::judge_payment($payment_rate) / ChannelModel::$MAX_SCORES['payment_rate'], 2);
             $cut_rate = 1 - $payment_rate;
             $score_cut_rate = round((int) self::judge_payment($cut_rate) / ChannelModel::$MAX_SCORES['cut_rate'], 2);
             $result[$key] = array_merge($result[$key], array('payment_rate' => $score_payment_rate, 'cut_rate' => $score_cut_rate));
         }
     }
     foreach ($channel_list as $key => $channel) {
         $nums = 0;
         foreach ($channel as $item) {
             $feedback = $item['feedback'];
             $nums += $item['nums'];
             if (in_array($feedback, array_keys(ChannelModel::$FEEDBACK_SCORES))) {
                 $result[$key]['score_feedback'] += ChannelModel::$FEEDBACK_SCORES[$feedback] * $item['nums'];
             }
         }
         $result[$key]['nums'] = $nums;
         $score_nums = round((int) self::judge_nums($nums) / ChannelModel::$MAX_SCORES['nums'], 2);
         $score_feedback = round((int) $result[$key]['score_feedback'] / (ChannelModel::$MAX_SCORES['feedback'] * $nums), 2);
         $result[$key] = array_merge($result[$key], array('score_nums' => $score_nums, 'score_feedback' => $score_feedback));
     }
     foreach ($quantity_list as $key => $quantity) {
         $score = self::judge_quantity($quantity);
         if (isset($result[$key])) {
             $result[$key] = array_merge($result[$key], array('frequency' => round((int) $score / ChannelModel::$MAX_SCORES['quantity'], 2)));
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: AD.class.php プロジェクト: banketree/lemon-grass
 public function get_ad_channels(array $list)
 {
     $channels = array();
     foreach ($list as $key => $ad) {
         if (is_numeric($ad['channel'])) {
             $channels[] = $ad['channel'];
         } else {
             $list[$key]['channel_alias'] = $ad['channel'];
         }
     }
     if ($channels) {
         $service = new Channel();
         $channels = $service->get_channel(array('id' => $channels));
         foreach ($list as $key => $ad) {
             if (is_numeric($ad['channel'])) {
                 $list[$key]['channel_alias'] = $channels[$ad['channel']];
             }
         }
     }
     return $list;
 }