/**
 * 提单-API
 */
import http from "@/http/http";
import { ActiveParams, Idparams, ResultInterface } from "../base/BaseDataModel";
import { CustomerBillDto, FeeGroupList, LadingBillFeeQueryResultDto, LadingBillFeeSetDto, LadingBillMainDto, LadingBillMainParam, LadingBillMoneyDetailDto, LadingBillMoneyDetailParam, LadingBillMoneyDto, LadingBillMoneyParam, LadingBillUpdateState, OrderReCountFeeParam } from "./ladingModle";

enum Api {
    ladingBillMainList = '/api/ladingBillMain/list',
    getLadingBillMainByPId = '/api/ladingBillMain/getLadingBillMainByPId',
    addBillMain = '/api/ladingBillMain/add',
    editBillMain = '/api/ladingBillMain/edit',
    deleteBillMain = '/api/ladingBillMain',
    getLadingBillFeeSetByPId = '/api/ladingBillFeeSet/getLadingBillFeeSetByPId',
    addFeeSet = '/api/ladingBillFeeSet/add',
    editFeeSet = '/api/ladingBillFeeSet/edit',
    customerFeeGroupList = '/api/customerFeeProductId/groupList',
    payableModel = '/api/payableModel/getPayableMode',
    receivableModel = '/api/receivableModel/getPayableMode',
    costFeeSetProductId = '/api/costFeeSetProductId/groupList',
    ladingBillFeeQuery = '/api/ladingBillFeeQuery/feeQuery',
    ladingBillMoneySave = '/api/ladingBillMoney/save',
    ladingBillMoneyList = '/api/ladingBillMoney/list',
    ladingBillMoneyPageList = '/api/ladingBillMoney/pageList',
    ladingBillMoneyDetailList = '/api/ladingBillMoney/detailList',
    ladingBillUpdateState = '/api/ladingBillMain/updateState',
    ladingBillMoneyCustomerBill = '/api/ladingBillMoney/customerBill',
    orderReCountFee = '/api/LadingOrder/orderReCountFee'
}

/**
 * 提单分页查询
 * @param parms 
 * @returns 
 */
export const api_ladingBillMainList = async (parms: LadingBillMainParam) => {
    return await http.post(Api.ladingBillMainList, parms)
}

/**
 * 根据单号查询提单类型
 * @param parms 
 * @returns 
 */
export const api_getLadingBillMainByPId = async (parms: Idparams) => {
    return await http.get(Api.getLadingBillMainByPId, parms)
}
/**
 * 根据单号查询提单费用设置
 * @param parms 
 * @returns 
 */
export const api_getLadingBillFeeSetByPId = async (parms: Idparams) => {
    return await http.get(Api.getLadingBillFeeSetByPId, parms)
}

/**
 * 新增提单
 * @param parms 
 * @returns 
 */
export const api_addLadingBillMain = async (parms: Omit<LadingBillMainDto, "id">) => {
    return await http.post(Api.addBillMain, parms)
}

/**
 * 编辑提单
 * @param parms 
 * @returns 
 */
export const api_editLadingBillMain = async (parms: LadingBillMainDto) => {
    return await http.post(Api.editBillMain, parms)
}

/**
 * 删除应收模版
 * @param parms 
 * @returns 
 */
export const api_deleteLadingBillMain = async (parms: Idparams) => {
    return await http.delete(Api.deleteBillMain, parms)
}

/**
 * 新增提单费用设置
 * @param parms 
 * @returns 
 */
export const api_addLadingBillFeeSet = async (parms: LadingBillFeeSetDto) => {
    return await http.post(Api.addFeeSet, parms)
}

/**
 * 编辑提单费用设置
 * @param parms 
 * @returns 
 */
export const api_editLadingBillFeeSet = async (parms: LadingBillFeeSetDto) => {
    return await http.post(Api.editFeeSet, parms)
}

/**
 * 客户费用编号分组接口
 * @param parms 
 * @returns 
 */
export const api_customerFeeGroupList = async (parms: FeeGroupList) => {
    return await http.post(Api.customerFeeGroupList, parms)
}

/**
 * 成本费用编号分组接口
 * @param parms 
 * @returns 
 */
export const api_costFeeSetProductIdList = async (parms: FeeGroupList) => {
    return await http.post(Api.costFeeSetProductId, parms)
}

/**
 * 获取应付模板数据
 * @param parms 
 * @returns 
 */
export const api_getPayableModeData = async (parms: Idparams) => {
    return await http.get(Api.payableModel, parms)
}

/**
 * 获取应收模板数据
 * @param parms 
 * @returns 
 */
export const api_getReceivableModelData = async (parms: Idparams) => {
    return await http.get(Api.receivableModel, parms)
}

/**
 * 提单费用试算
 * @param parms 
 * @returns 
 */
export const api_getLadingBillFeeQuery = async (parms: { ladingBillMainId: number }) => {
    return await http.get<LadingBillFeeQueryResultDto[]>(Api.ladingBillFeeQuery, parms)
}

/**
 * 费用保存接口
 * @param parms 
 * @returns 
 */
export const api_ladingBillMoneySave = async (parms: LadingBillMoneyDto[]) => {
    return await http.post(Api.ladingBillMoneySave, parms)
}

/**
 * 提单费用查询
 * @param parms 
 * @returns 
 */
export const api_ladingBillMoneyList = async (parms: LadingBillMoneyParam) => {
    return await http.post<LadingBillMoneyDto[]>(Api.ladingBillMoneyList, parms)
}

/**
 * 提单费用分页查询
 * @param parms 
 * @returns 
 */
export const api_ladingBillMoneyPageList = async (parms: LadingBillMoneyParam) => {
    return await http.post<ResultInterface<LadingBillMoneyDto>>(Api.ladingBillMoneyPageList, parms)
}

/**
 * 提单费用明细查询
 * @param parms 
 * @returns 
 */
export const api_ladingBillMoneyDetailList = async (parms: LadingBillMoneyDetailParam) => {
    return await http.post<LadingBillMoneyDetailDto[]>(Api.ladingBillMoneyDetailList, parms)
}

/**
 * 提单状态更新
 * @param parms 
 * @returns 
 */
export const api_ladingBillUpdateState = async (parms: LadingBillUpdateState) => {
    return await http.post(Api.ladingBillUpdateState, parms)
}

/**
 * 账单预览
 * @param parms 
 * @returns 
 */
export const api_ladingBillMoneyCustomerBill = async (parms: { mainId: number }) => {
    return await http.get<CustomerBillDto>(Api.ladingBillMoneyCustomerBill, parms)
}

/**
 * 尾程重算
 * @param parms 
 * @returns 
 */
export const api_orderReCountFee = async (parms: OrderReCountFeeParam) => {
    return await http.post(Api.orderReCountFee, parms)
}