package org.jeecg.modules.app.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.app.dto.AppOrderInfoDTO;
import org.jeecg.modules.app.form.CreateOrderForm;
import org.jeecg.modules.app.form.PageOrdersForm;
import org.jeecg.modules.app.form.RefundOrderForm;
import org.jeecg.modules.app.form.UserPayForm;
import org.jeecg.modules.app.vo.OrderVO;
import org.jeecg.modules.app.vo.PageOrdersVO;
import org.jeecg.modules.app.vo.QueryOrderVerifyRecordsVO;
import org.jeecg.modules.system.app.entity.AppOrder;
import org.jeecg.modules.system.app.form.PriceChangeForm;
import org.jeecg.modules.system.entity.SysUser;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface IOrderService extends IService<AppOrder>{

    /**
     * @Author SheepHy
     * @Description 学校场地预约-创建
     * @Date 10:10 2025/7/14
     * @Param rulesId 时间段ID
     * @return OrderVO.createOrderPlaceSchool
     **/
    OrderVO.createOrderPlaceSchool createOrderPlaceSchool(String rulesId, String userIds);

    /**
     * @Author SheepHy
     * @Description 课程限购校验
     * @Date 16:22 2025/7/14
     * @Param courseId 课程ID
     * @return boolean
     **/
    boolean checkCourseLimitNum(String courseId, int limitNum);

    /**
     * @Author SheepHy
     * @Description 学校场地预约-预览页
     * @Date 10:10 2025/7/14
     * @Param placeId startTime
     * @return OrderVO.PreviewOrderPlaceSchool {@link OrderVO.PreviewOrderPlaceSchool}
     **/
    OrderVO.PreviewOrderPlaceSchool previewOrderPlaceSchool(String placeId, Date startTime);

    /**
     * @Author SheepHy
     * @Description 课程购买-预览页（学校课程、体育馆课程、教练课程）
     * @Date 15:43 2025/7/14
     * @Param courseId
     * @return OrderVO.PreviewOrderCourseSchool {@link OrderVO.PreviewOrderCourse}
     **/
    OrderVO.PreviewOrderCourse previewOrderCourse(String courseId);

    /**
     * @Author SheepHy
     * @Description 体育馆包场-预览页
     * @Date 16:13 2025/7/14
     * @Param placeId
     * @return OrderVO.PreviewOrderPlaceGymnasiumChartered {@link OrderVO.PreviewOrderPlaceGymnasiumChartered}
     **/
    OrderVO.PreviewOrderPlaceGymnasiumChartered previewOrderPlaceGymnasiumChartered(String rulesId);

    /**
     * @Author SheepHy
     * @Description 学校包场-预览时间选择
     * @Date 14:45 2025/7/17
     * @Param placeId
     * @return OrderVO.PreviewOrderPlaceSchoolTime {@link OrderVO.PreviewOrderPlaceSchoolTime}
     **/
    List<OrderVO.PreviewOrderPlaceSchoolTime> previewOrderPlaceSchoolTime(String placeId);

    UserPayForm createOrder(CreateOrderForm createOrderForm) throws IOException;

    UserPayForm orderChangePrice( PriceChangeForm priceChangeForm);

    /**
     * @Author SheepHy
     * @Description 体育馆无固定场-预览页
     * @Date 17:22 2025/8/4
     * @Param
     * @return
     **/
    OrderVO.PreviewOrderPlaceGymnasiumNoFixation previewOrderPlaceGymnasiumNoFixation(String placeId);

    AppOrderInfoDTO queryOrderInfo(String orderCode);

    List<QueryOrderVerifyRecordsVO> queryOrderVerifyRecords(String orderId, String ticketNo);

    String orderQuery(String orderCode) throws IOException;

    String cancelOrder(String orderId);

    IPage<PageOrdersVO> pageOrders(PageOrdersForm pageOrdersForm);

    String refundOrder(RefundOrderForm refundOrderForm) throws ParseException;

    String gameRefundOrder(String orderCode,String reason);

    Map<String, String> wechatPayNotify(HttpServletRequest request, HttpServletResponse response);

    UserPayForm payOrder(String appOrderId);

    Boolean cancelSchoolOrder(String orderId);
}
