<?php


namespace app\wuye\controller;


use app\admin\controller\Base;
use app\admin\controller\Common;
use think\facade\Db;
use think\facade\Request;

class Order extends Base
{
    protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class'];

    public function orderList() {

        //流水管理
        $page = Request::param('page',1);
        $where= [];
        if(Request::param('property_id')) {
            $where[] = ['hp.property_id','=',Request::param('property_id')];
        } else {
            return $this->returnJson([],'缺少参数',400);
        }
        if(Request::param('village_name')) {
            $village_name = Request::param('village_name');
            $where[] = ['hv.village_name','like','%'.$village_name.'%'];
        }
        $rest = Common::getWithDrawList($where,$page);
        $res['total'] = $rest['total'];
        $res['data'] = Common::changeField($rest['data']);
        return $this->returnJson($res,'success');

        }

        //查看流水详情
    public function detailOrder() {
        $id = Request::param('id');
        $where['id'] = $id;
        $rest =  Common::getWithDrawDetail($where);
        if(!$rest) {
            return $this->returnJson([],'暂未获取到任何数据',400);
        }
        $res['data'] = $rest['data'];
        $res['orderInfo'] = Common::changeField($rest['orderInfo'],['create_time','pay_time']);
        return $this->returnJson($res,'success');
    }

}