<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2017/12/1
 * Time: 17:18
 */

namespace App\Http\Controllers\Manage\Channel;

use App\Http\Controllers\Controller;
use App\Modules\Channel\Services\ChannelService;
use App\Modules\Trade\Services\OrderService;
use Illuminate\Http\Request;

/**
 * 渠道数据统计
 * Class ChannelDataController
 * @package App\Http\Controllers\Manage\Channel
 */
class ChannelDataController extends Controller
{
    function getChannleData(Request $request)
    {
        //获取所有的渠道
        $channels = ChannelService::getAllChannels();
        if (!empty($channels)) {
            //遍历循环获取每个渠道下面的数据
            foreach ($channels as $channelItem) {
                $channelId = $channelItem->id;
                $channelItem->dataInfo = OrderService::getChannelToday($channelId);
            }
        }
        return json_encode($channels);
    }
}