<?php
/*
 * @Descripttion:
 * @version:
 * @Author: kangkang
 * @Date: 2020-10-13 19:52:37
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-12-07 17:16:18
 */

namespace app\order\controller;

use app\order\model\ProductOrder as OrderModel;
use fastphp\base\Controller;

class Order extends Controller
{
    /**
     * @description: 导出数据
     * @param {*}
     * @return {*}
     */
    public function export()
    {
        $order_model = new OrderModel;
        $data = $_GET;
        dump($data);

        $where = "";
        die;
        
        // \exportToCsv('test.csv',['id','淘宝id','淘宝会员名','退款金额','子订单编号','交易编号','无关变量','无关变量','产品','申请时间','用户名','处理时间','备注','状态','扣除前余额','处理人','扣除后余额'],$list);
    }

    //认领的订单数
    public function takeOrderNum()
    {
        $get = $_GET;
        $order_model = new OrderModel;
        $date1 = date('Y-m-d',time());
        $date2 = date("Y-m-d H:i:s", time());
        if (!empty($get['Btime'])) {
            $date1 = date('Y-m-d', strtotime($get['Btime']));
            $date2 = date("Y-m-d 23:59:59", strtotime($get['Etime']));
        }
        
        $info = $order_model
                    ->field('count(1) as num')
                    ->where(['Channel'=>$this->userinfo['LoginName']])
                    ->where("CreateTime>'".$date1."' AND CreateTime<'".$date2."'")
                    ->fetch();
        $data = [
            'Code' => 10000,
            'Message' => '',
            'num' => $info['num']
        ];
        echo json_encode($data);
    }

}
