import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CheckRecordVO, CheckRecordForm, CheckRecordQuery, UserItemVO } from '@/api/system/business/checkRecord/types';

/**
 * 查询用户核销记录列表
 * @param query
 * @returns {*}
 */

export const listCheckRecord = (query?: CheckRecordQuery): AxiosPromise<CheckRecordVO[]> => {
  return request({
    url: '/business/checkRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户核销记录详细
 * @param id
 */
export const getCheckRecord = (id: string | number): AxiosPromise<CheckRecordVO> => {
  return request({
    url: '/business/checkRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增用户核销记录
 * @param data
 */
export const addCheckRecord = (data: CheckRecordForm) => {
  return request({
    url: '/business/checkRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户核销记录
 * @param data
 */
export const updateCheckRecord = (data: CheckRecordForm) => {
  return request({
    url: '/business/checkRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户核销记录
 * @param id
 */
export const delCheckRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/checkRecord/' + id,
    method: 'delete'
  });
};

/**
 * 根据用户名/手机号查询用户道具列表
 * @param searchUserKeyword 用户名或手机号
 */
export const selectPlayerItemsListByUser = (searchUserKeyword: string): AxiosPromise<UserItemVO[]> => {
  return request({
    url: '/business/checkRecord/selectPlayerItemsListByUser',
    method: 'get',
    params: { searchUserKeyword } // ✅ 查询参数用 params
  });
};
