package shop.alien.lawyer.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestParam;
import shop.alien.entity.result.R;
import shop.alien.entity.store.LawyerConsultationOrder;
import shop.alien.entity.store.dto.LawyerConsultationOrderDto;
import shop.alien.entity.store.dto.PayStatusRequest;
import shop.alien.entity.store.vo.LawyerConsultationOrderVO;

import java.util.Date;
import java.util.Map;

/**
 * 咨询订单 服务类
 *
 * @author system
 * @since 2025-01-XX
 */
public interface LawyerConsultationOrderService extends IService<LawyerConsultationOrder> {

    /**
     * 分页查询咨询订单列表（包含律师信息）
     *
     * @param pageNum      页码
     * @param pageSize     页容
     * @param orderNumber  订单编号
     * @param clientUserId 客户端用户ID
     * @param lawyerUserId 律师用户ID
     * @param lawyerName   律师姓名
     * @param orderStatus  订单状态
     * @return IPage<LawyerConsultationOrderVO>
     */
    R<IPage<LawyerConsultationOrderVO>> getConsultationOrderList(int pageNum, int pageSize, String orderNumber,
                                                          Integer clientUserId, Integer lawyerUserId, String lawyerName, Integer orderStatus);

    /**
     * 新增咨询订单
     *
     * @param consultationOrder 咨询订单
     * @return R<LawyerConsultationOrder>
     */
    R<LawyerConsultationOrder> addConsultationOrder(LawyerConsultationOrder consultationOrder);

    /**
     * 编辑咨询订单
     *
     * @param consultationOrder 咨询订单
     * @return R<LawyerConsultationOrder>
     */
    R<LawyerConsultationOrder> editConsultationOrder(LawyerConsultationOrder consultationOrder);

    /**
     * 删除咨询订单
     *
     * @param id 主键
     * @return R<Boolean>
     */
    R<Boolean> deleteConsultationOrder(Integer id);

    /**
     * 开始咨询律师
     *
     * @param lawyerConsultationOrder        律师ID
     * @param lawyerConsultationOrder        咨询问题（可选）
     * @param lawyerConsultationOrder       关联的AI会话ID（可选）
     * @param lawyerConsultationOrder    客户端用户ID（可选）
     * @param lawyerConsultationOrder 法律问题场景ID（可选）
     * @return R<Map<String, Object>>
     */
    //R<Map<String, Object>> startConsultation(Integer lawyerId, String question, String sessionId, Integer clientUserId, Integer problemScenarioId);


    R<LawyerConsultationOrderDto> consultNow(LawyerConsultationOrder lawyerConsultationOrder);

    /**
     * 支付订单
     *
     * @param  request 请求对象
     * @return R<Map<String, Object>>
     */
    R<LawyerConsultationOrderDto> payStatus(PayStatusRequest request);


    /**
     * 根据用户Id查询订单列表（包含律师信息）
     *
     * @param pageNum      页码
     * @param pageSize     页容
     * @param userId  订单编号
     * @param orderStatus 订单状态
     * @return IPage<LawyerConsultationOrderVO>
     */
    Map<String, Object> getConsultationOrderListById(int pageNum, int pageSize, String userId, String orderStatus, String lawyerName);

    /**
     * 获取咨询订单详情
     *
     * @param lawyerOrderId 订单ID
     * @return 咨询订单详情VO
     */
    LawyerConsultationOrderVO getConsultationOrderDetail(String lawyerOrderId);

    boolean cancelOrder(String id);

    /**
     * 查询咨询订单（律师端）
     *
     * @param pageNum      页码
     * @param pageSize     页容
     * @param startDate  开始时间
     * @param endDate 结束时间
     * @param lawyerId 律师ID
     * @return IPage<LawyerConsultationOrderVO>
     */
    Map<String, Object> getLawyerConsultationOrderInfo(int pageNum, int pageSize, String startDate, String endDate, String clientUserName, String orderStatus, String lawyerId);

    /**
     * 订单检查
     *
     * @param clientUserId
     * @param lawyerUserId
     * @return
     */
   R<Map<String, String>> checkOrder(Integer clientUserId,Integer lawyerUserId);


   /**
   * 获取律师收入
   *
   * @param lawyerConsultationOrderVO
   * @return
   */
   R<Map<String, Object>> getOrderIncome(LawyerConsultationOrderVO lawyerConsultationOrderVO);


    /**
     * 用户端申请退款
     *
     * @param clientUserId
     * @param orderId
     * @return
     */
    R<Boolean> applyRefund(String clientUserId, String orderId, String applyRefundReason);


    /**
     * 用户端完成订单
     *
     * @param clientUserId
     * @param orderId
     * @return
     */
    R<Boolean> completeOrder(String clientUserId, String orderId);

    LawyerConsultationOrder getApplyRefundDetail(String orderId);
}

