ProductListController.class.php 1.28 KB
<?php
/**
 * 产品列表接口
 * User: yingcai
 * Date: 2018/2/2
 * Time: 上午11:44
 */

namespace Apicp\Controller\Order;

use Common\Common\Order;

class ProductListController extends AbstractController
{

    /**
     * ProductList
     * @author houyingcai
     * @desc 购买产品列表接口
     * @return array|bool 商品信息
                array(
                    'list' => array(
                        array(
                            'product_id' => '006474BE7F00000175505861C25D23D5', // 商品ID
                            'product_name' => '员圈直播服务', // 产品名称
                        ),
                    ),
                )
     */
    public function Index_post()
    {
        // 初始化返回列表数据
        $list = [];

        $orderService = &Order::instance();
        // 获取商品列表
        $result = $orderService->fetchProductList();

        // 格式化列表数据
        if (!empty($result['list'])) {

            foreach ($result['list'] as $val) {

                $list[] = [
                    'product_id' => $val['prId'],
                    'product_name' => $val['prName'],
                ];
            }
        }

        $this->_result = [
            'list' => $list,
        ];

        return true;
    }
}