<?php
namespace app\admin\controller\auction;

use app\admin\controller\AuthController;
use app\admin\controller\Union;
use app\admin\model\auction\AuctionGu;
use app\admin\model\User;
use crmeb\services\{ExpressService,
    JsonService,
    MiniProgramService,
    upload\Upload,
    WechatService,
    FormBuilder as Form,
    CacheService,
    UtilService as Util,
    JsonService as Json};
use app\admin\model\system\{
    SystemAttachment as SystemAttachmentModel, SystemAttachmentCategory as Category
};
use think\facade\Route as Url;
use think\facade\Validate;

/**
 * 竞拍管理
 * Class StoreOrder
 * @package app\admin\controller\store
 */
class AuctionApply extends AuthController
{


    public function index()
    {


        return $this->fetch();
    }


    public function list()
    {
        $where = Util::getMore([
            ['status', ''],
            ['page', 1],
            ['limit', 20],
            ['auction']
        ]);
        $data = \app\admin\model\auction\AuctionApply::list($where);

        return Json::successlayui($data);
    }


    public function tg($id)
    {
        if (empty($id)) return Json::fail('失败');

        $data = \app\admin\model\auction\AuctionApply::where('id', '<>',1)->find($id);
        if (!$data){
            return Json::fail('当前状态无法修改');
        }
        $res = \app\admin\model\auction\AuctionApply::update(['status' => 2, 'id' => $id]);
        if ($res){
            return Json::success('成功!');
        }else{
            return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
        }
    }
    public function jj($id)
    {

        if (empty($id)) Json::fail('失败');
        $data = \app\admin\model\auction\AuctionApply::where('id', '<>',1)->find($id);
        if (!$data){
            return Json::fail('当前状态无法修改');
        }
        $res = \app\admin\model\auction\AuctionApply::update(['status' => 0, 'id' => $id]);
        if ($res){
            return Json::success('成功!');
        }else{
            return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
        }
    }
}