<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台（PHP版）
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码，建议反馈是我们前进的动力
// | 开源版本可自由商用，可去除界面版权logo
// | gitee下载：https://gitee.com/likeshop_gitee/likeadmin
// | github下载：https://github.com/likeshop-github/likeadmin
// | 访问官网：https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------


namespace app\adminapi\controller\group_activity;


use app\adminapi\logic\export\ExportLogic;
use app\common\service\ExcelExportService;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\group_activity\GroupUserOrderLists;
use app\adminapi\logic\group_activity\GroupUserOrderLogic;


/**
 * 用户拼团订单控制器
 * Class GroupOrderController
 * @package app\adminapi\controller\group_activity
 */
class GroupUserOrderController extends BaseAdminController
{


    /**
     * @notes 获取拼团订单列表
     * @return \think\response\Json
     * @author likeadmin
     * @date 2025/03/13 10:31
     */
    public function lists()
    {
        return $this->dataLists(new GroupUserOrderLists());
    }
    /**
     * @notes 用户订单退款
     */
    public function refundOrder() 
    {
        $params = $this->request->request('id');
        $result = GroupUserOrderLogic::refundOrder($params);
        if (true === $result) {
            return $this->success('退款成功', [], 1, 1);
        }
        return $this->fail(GroupUserOrderLogic::getError());
    }

    
    public function download()
    {
        $params = $this->request->post();
        $filename = "用户拼团订单列表";
        $result = ExportLogic::add([
            'download_type' => 11,
            'params' => $params,
            'name' => $filename,
            'admin_id' => $this->adminId,
        ]);
        if (false === $result) {
            return $this->fail(ExportLogic::getError());
        }
        
        (new ExcelExportService)->download($result);
        return $this->success('添加成功-'.$result, [], 1, 1);
    }

}