<?php
namespace app\api\controller;
use app\Request;
use crmeb\services\UtilService;

class JuniuController
{
    private static $appid ="jnz_formal_0001";
    private static $appsecret = "mxtw58mxbexwjk40ghin";
    private static $url = "https://new.juniuzu.com";
    /**
     * 获取商品列表
     * @param Request $request
     */
    public function lst(Request $request)
    {
        list($page,$keyword,$sort_field,$sort_way) = UtilService::postMore(
            [
                ['page',1],
                ['keyword',''],
                ['sort_field','sales_show'],
                ['sort_way','desc'],
            ],$request,true
        );
        $rs = do_request(self::$url.'/api/goods/getlist?'.http_build_query(compact('page','keyword','sort_field','sort_way')),[],null,false);
        return app('json')->success('获取成功',json_decode($rs,true));
    }

    /**
     * 获取商品详情
     * @param Request $request
     */
    public function info(Request $request)
    {
        $id = input('id',0);
        $rs = do_request(self::$url.'/api/goods/getdetail?'.http_build_query(compact('id')),[],null,false);
        return app('json')->success('获取成功',json_decode($rs,true));
    }

    public function getexpress(Request $request)
    {
        $sn = input('sn',0);
        $rs = do_request(self::$url.'/api/goods/getexpress?'.http_build_query(compact('sn')),[],null,false);
        return app('json')->success('获取成功',json_decode($rs,true));
    }
    /**
     * 创建订单
     * @param Request $request
     */
    public function order_create(Request $request)
    {

    }
}