<?php
/**
 * Created by PhpStorm.
 * User: songdb
 * Date: 2017/12/2
 * Time: 15:36
 */

namespace App\Modules\SendOrder\Services;

use App\Modules\SendOrder\Services\SendOrderService;
use App\Modules\Channel\Services\ChannelService;
use App\Modules\User\Services\UserService;
use App\Modules\OfficialAccount\Services\ForceSubscribeService;
use App\Modules\Trade\Services\OrderService;

class SendOrderDayStatService
{

    //生成每日派单
    static function generateStat()
    {
        $end_send_time = date("Y-m-d");
        $send_orders = SendOrderService::search(compact('end_send_time'),true);

        //用户

        //注册用户
        foreach ($send_orders as $send_order)
        {
            $data = [];

            $channel = ChannelService::getById($send_order->distribution_channel_id);

            $data['send_order_id'] = $send_order->id;
            $data['distribution_channel_id'] = $send_order->distribution_channel_id;
            $data['distribution_channel_name'] = $channel->nickname;
            $data['book_id'] = $send_order->book_id;
            $data['book_name'] = $send_order->book_name;
            $data['pv'] = SendOrderService::getPv($send_order->id);
            $data['uv'] = SendOrderService::getUv($send_order->id);
            $data['register_user_num'] = 0;//UserService::getPromotionTotal($send_order->id);
            $data['force_user_num'] = 0;// ForceSubscribeService::getFansNum($send_order->id);
            $data['send_time'] = $send_order->send_time;
            $data['cost'] = $send_order->cost;

            $data['pay_user_num'] = 0;
            $data['year_recharge_user_num'] = 0;
            $data['ticket_recharge_user_num'] = 0;
            $data['recharge_amount'] = 0;
            $data['first_recharge_amount'] = 0;
            $data['year_unpaid_num'] = 0;
            $data['year_paid_num'] = 0;
            $data['recharge_amount_in_half_day'] = 0;
            $data['recharge_amount_in_two_weeks'] = 0;

            dd($data);

        }

    }


}