package com.czg.order.service;

import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.GbOrderQueryParam;
import com.czg.order.dto.GroupJoinDTO;
import com.czg.order.entity.GbOrder;
import com.czg.order.vo.GbOrderCountVO;
import com.czg.order.vo.GbOrderDetailVO;
import com.czg.order.vo.GbWareVO;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;

import java.util.Map;

/**
 * 拼团订单表 服务层。
 *
 * @author ww
 * @since 2025-12-16
 */
public interface GbOrderService extends IService<GbOrder> {

    boolean upShopConfig(Integer status, Long shopId);

    //统计
    GbOrderCountVO countOrder(GbOrderQueryParam param);

    //列表 详细列表 detail的
    Page<GbOrderDetailVO> getGbOrderPage(GbOrderQueryParam param);

    //拼团订单详情
    GbOrderDetailVO getGoodsRecordDetail(Long shopId, Long detailId, String groupOrderNo);

    //商品详情
    GbWareVO getWareDetail(Long shopId, Long wareId, Long userId);

    //成团/参团 支付
    CzgResult<Map<String, Object>> groupJoin(GroupJoinDTO param);

    //核销
    boolean checkout(String verifyCode, Long shopId);

    //支付回调 处理成团人数, 如果没团则创团
    void payCallBack(Long recordId, Long payOrderId);

    //用户申请退款
    boolean applyRefund(CommonRefundDTO param, Long userId);

    //取消退款
    boolean cancelRefund(CommonRefundDTO param, Long userId, Long shopId);

    //退款 同意退款
    boolean agreeRefund(CommonRefundDTO param, Long shopId);

    //商品下架 同步操作退款
    boolean editGbWareOnlineStatus(Long id, Integer onlineStatus);

    //任务过期 自动退款 成团期限超时
    boolean expireRefund(Long gbOrderId,GbOrder order);

    //商品下架 退款 所属活动变更为下架状态
    boolean wareDownRefund(Long wareId);

    //店铺商品拼团功能关闭  退款
    boolean shopDownRefund(Long shopId);
}
