package com.hzs.sale.order.service;

import com.hzs.common.core.enums.EAgentApprovalStatus;
import com.hzs.common.core.enums.EApprovalBusiness;
import com.hzs.common.domain.sale.ext.SaOrderExt;
import com.hzs.common.domain.sale.order.SaOrderChargeLog;
import com.hzs.sale.deliver.param.DeductionSubmitParam;
import com.hzs.sale.order.dto.OrderQueryChargeDTO;
import com.hzs.sale.order.param.*;
import com.hzs.sale.order.vo.MyOrderVO;
import com.hzs.sale.order.vo.ValidateCancelOrderVO;
import com.hzs.system.sys.dto.ApprovalBusinessResultDTO;
import com.hzs.system.sys.dto.LoginUser;

import java.util.List;
import java.util.Map;

/**
 * @Description: 订单业务办理服务
 * @Author: jiang chao
 * @Time: 2023/2/1 17:49
 * @Classname: IOrderBusinessService
 * @PackageName: com.hzs.sale.order.service
 */
public interface IOrderBusinessService {

    /**
     * 校验是否有进行中的订单类签呈
     *
     * @param orderCodeList 订单编号列表
     * @param pkCountry     所属国家
     * @return
     */
    String checkBusinessExist(List<String> orderCodeList, Integer pkCountry);

    /**
     * 校验订单是否已经发货
     *
     * @param orderCodeList 订单编号列表
     * @param pkCountry     所属国家
     * @return
     */
    String checkOrderDeliver(List<String> orderCodeList, Integer pkCountry);

    /**
     * 校验新零售盒数产品是否可以换货
     *
     * @param param 请求入参
     * @return
     */
    String checkOrderRetailProduct(OrderProductParam param);

    /**
     * 本次业务修改费用
     *
     * @param saOrderList       订单列表
     * @param eApprovalBusiness 修改类型
     * @param pkCountry         所属国家
     * @return
     */
    Map<Long, OrderQueryChargeDTO> queryChargeLog(List<SaOrderExt> saOrderList, EApprovalBusiness eApprovalBusiness, Integer pkCountry);

    /**
     * 确认修改地址并发起审批（不走审批）
     *
     * @param param     入参
     * @param loginUser 登录用户
     * @return
     */
    String changeAddressApprovalFreeSign(OrderAddressParam param, LoginUser loginUser);

    /**
     * 确认修改地址并发起审批（走审批）
     *
     * @param param     入参
     * @param loginUser 登录用户
     * @return
     */
    String changeAddressApprovalSubmit(OrderAddressParam param, LoginUser loginUser);

    /**
     * 确认修改地址审批通过
     *
     * @param approvalBusinessResultDTO
     * @return
     */
    String changeAddressApprovalAgree(ApprovalBusinessResultDTO approvalBusinessResultDTO);

    /**
     * 确认修改地址审批驳回
     *
     * @param approvalBusinessResultDTO
     * @return
     */
    String changeAddressApprovalReject(ApprovalBusinessResultDTO approvalBusinessResultDTO);

    /**
     * 确认调整换货物（不走审核）
     *
     * @param param     入参
     * @param loginUser 登录用户
     * @return
     */
    String changeProductApprovalFreeSign(OrderProductParam param, LoginUser loginUser);

    /**
     * 确认调换货物并发起审批（走审批）
     *
     * @param param     入参
     * @param loginUser 登录用户
     * @return
     */
    String changeProductApprovalSubmit(OrderProductParam param, LoginUser loginUser);

    /**
     * 确认调换货物审批通过
     *
     * @param approvalBusinessResultDTO
     * @return
     */
    String changeProductApprovalAgree(ApprovalBusinessResultDTO approvalBusinessResultDTO);

    /**
     * 确认调换货物审批驳回
     *
     * @param approvalBusinessResultDTO
     * @return
     */
    String changeProductApprovalReject(ApprovalBusinessResultDTO approvalBusinessResultDTO);


    /**
     * 确认退单并发起审批（走审批）
     *
     * @param param     入参
     * @param loginUser 登录用户
     * @return
     */
    String returnOrderApprovalSubmit(OrderReturnParam param, LoginUser loginUser);

    /**
     * 确认合并退单并发起审批（走审批）
     *
     * @param param     入参
     * @param loginUser 登录用户
     * @return
     */
    String batchReturnOrderApprovalSubmit(OrderReturnBatchParam param, LoginUser loginUser);

    /**
     * 确认退单审批通过
     *
     * @param approvalBusinessResultDTO
     * @return
     */
    String returnOrderApprovalAgree(ApprovalBusinessResultDTO approvalBusinessResultDTO);

    /**
     * 确认退单审批驳回
     *
     * @param approvalBusinessResultDTO
     * @return
     */
    String returnOrderApprovalReject(ApprovalBusinessResultDTO approvalBusinessResultDTO);


    /**
     * 验证是否可以撤单
     *
     * @param orderCancelParam 参数
     * @param businessCode     审核验证的时候需要去掉自己
     * @return: Boolean
     * @Author: sui q
     * @Date: 2023/3/22 11:40
     */
    ValidateCancelOrderVO validateCancelOrder(OrderCancelParam orderCancelParam, String... businessCode);

    /**
     * 根据订单编号执行订单撤销操作
     *
     * @param pkApprove
     * @param orderCancelParam
     * @param validateCancelOrderVO
     */
    void revokeSaOrderByOrderCode(Long pkApprove, OrderCancelParam orderCancelParam, ValidateCancelOrderVO validateCancelOrderVO);

    /**
     * 撤销订单
     *
     * @param orderCancelParam      订单取消明细
     * @param validateCancelOrderVO 验证后的实体，含有订单，撤销列表
     * @param loginUser             登录用户
     * @return String
     */
    Boolean cancelOrder(OrderCancelParam orderCancelParam, ValidateCancelOrderVO validateCancelOrderVO, LoginUser loginUser);

    /**
     * 审核通过 撤销订单
     *
     * @param approvalBusinessResultDTO 参数
     * @param approvalBusiness          审核类型
     * @return: void
     * @Author: sui q
     * @Date: 2023/3/25 10:43
     */
    String cancelOrderApprovalAgree(ApprovalBusinessResultDTO approvalBusinessResultDTO, Integer approvalBusiness);

    /**
     * 审核驳回 撤销订单
     *
     * @param approvalBusinessResultDTO 参数
     * @param approvalBusiness          审核类型
     * @return: void
     * @Author: sui q
     * @Date: 2023/3/25 10:43
     */
    String cancelOrderApprovalReject(ApprovalBusinessResultDTO approvalBusinessResultDTO, Integer approvalBusiness);

    /**
     * 查询订单修改记录
     *
     * @param resultDTO         业务审批操作DTO
     * @param eApprovalBusiness 修改类型枚举
     * @return
     */
    List<SaOrderChargeLog> getSaOrderChargeLogs(ApprovalBusinessResultDTO resultDTO, EApprovalBusiness eApprovalBusiness);

    /**
     * 查询订单修改记录
     *
     * @param resultDTO  业务审批操作DTO
     * @param chargeType 修改类型
     * @return
     */
    List<SaOrderChargeLog> getSaOrderChargeLogs(ApprovalBusinessResultDTO resultDTO, Integer chargeType);

    /**
     * 更新订单修改记录
     *
     * @param chargeType     业务类型
     * @param businessCode   业务单号
     * @param pkCountry      所属国家
     * @param userId         用户ID
     * @param approvalStatus 审核状态
     * @return
     */
    boolean updateSaOrderChargeLog(EApprovalBusiness chargeType, String businessCode,
                                   Integer pkCountry, Long userId,
                                   EAgentApprovalStatus approvalStatus, String remark);

    /**
     * @description: 校验自助撤单
     * @author: zhang jing
     * @date: 2023/11/21 15:24
     * @param: [orderCancelParam, businessCode]
     * @return: com.hzs.sale.order.vo.ValidateCancelOrderVO
     **/
    MyOrderVO checkSelfOrder(Long userId, MyOrderVO myOrderVO);

    /**
     * 订单抵扣发起审批
     *
     * @param param     入参
     * @param loginUser 登录用户
     * @return
     */
    String orderDeductionSubmit(DeductionSubmitParam param, LoginUser loginUser);

    /**
     * 订单抵扣发起审批通过
     *
     * @param approvalBusinessResultDTO
     * @return
     */
    String orderDeductionAgree(ApprovalBusinessResultDTO approvalBusinessResultDTO);

    /**
     * 订单抵扣发起审批驳回
     *
     * @param approvalBusinessResultDTO
     * @return
     */
    String orderDeductionReject(ApprovalBusinessResultDTO approvalBusinessResultDTO);

}
