<?php

namespace app\api\controller;

use app\admin\validate\tools\GenerateTableValidate;
use app\admin\logic\tools\GeneratorLogic;
use app\common\logic\store_order\StoreOrderLogic;
use think\facade\Db;
use Webman\Config;

class IndexController extends BaseApiController
{
    public $notNeedLogin = ['app_update','express_list','province','city','area','street'];

    public function index()
    {
        
        

        $params=['store_id'=>2,'pay_type'=>17];
        $a=StoreOrderLogic::createOrder([1],0,null,$params);
        d($a);
           return json(['msg' =>create_password(123456, '11d3')]);
    }

    /**
     * @notes 下载文件
     */
    public function download()
    {
        $params = (new GenerateTableValidate())->goCheck('download');
        $result = GeneratorLogic::download($params['file']);
        if (false === $result) {
            return $this->fail(GeneratorLogic::getError() ?: '下载失败');
        }
        return response()->download($result, 'webman-curd.zip');
    }

    /**
     * @notes 获取app更新信息
     */
    public function app_update(){
       $find= Db::name('app_update')->where('type',2)->order('id','desc')->findOrEmpty();
       return $this->success('ok',$find);
    }

    
    /**
     * @notes 获取省列表
     */
    public function province(){
        $list= Db::name('geo_province')->select()->toArray();
        return $this->success('ok',$list);
    }
    /**
     * @notes 获取市列表
     */
    public function city(){
        $province_code=$this->request->get('code');
        $list= Db::name('geo_city')->where('province_code',$province_code)->select()?->toArray();
        return $this->success('ok',$list);
    }
    /**
     * @notes 获取区列表
     */
    public function area(){
        $city_code=$this->request->get('code');
        $list= Db::name('geo_area')->where('city_code',$city_code)->select()?->toArray();
        return $this->success('ok',$list);
    }
    /**
     * @notes 获取街道列表
     */
    public function street(){
        $area_code=$this->request->get('area_code');
        $list= Db::name('geo_street')->where('area_code',$area_code)->select()?->toArray();
        return $this->success('ok',$list);
    }

}