CouponFloorProcess.php 1.87 KB
<?php
/**
 * Created by PhpStorm.
 * User: Targaryen
 * Date: 2016/4/15
 * Time: 13:17
 */

namespace Plugin\DataProcess;


class CouponFloorProcess
{

    /**
     * 获取楼层数据
     *
     * @param $data
     * @return array
     */
    public static function getContent($data)
    {

        $result = array();

        if (empty($data)) {
            return array();
        }

        $build = array();
        foreach ($data as $v) {
            if (empty($v)) {
                continue;
            }
            $fun = $v['template_name'];
            if (empty($v['data']) || !is_callable("self::$fun")) {
                continue;
            }
            $build = self::$fun($v['data']);
            if (empty($build)) {
                continue;
            }
            $result[] = $build;
        }
        $build = array();
        return $result;
    }

    /**
     * 焦点图处理
     *
     * @param $data
     * @return mixed
     */
    private static function carousel_banner($data)
    {
        if (empty($data)) {
            return array();
        }
        $data['isCarouselBanner'] = true;
        return $data;
    }

    /**
     *
     * 领券楼层数据处理
     *
     * @param $data
     * @return array
     * @internal param $type
     */
    private static function getCoupon($data)
    {
        if (empty($data)) {
            return array();
        }
        foreach ($data['list'] as &$item) {
            switch ($item['status']) {
                case 1:
                    $item['isGet'] = true;
                    break;
                case 2:
                    $item['isZero'] = true;
                    break;
                case 3:
                    $item['isGeted'] = true;
                    break;
                default:
                    break;
            }
        }
        $data['isCoupon'] = true;
        return $data;
    }
}