import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SysMerchantVO, SysMerchantForm, SysMerchantQuery, SysUserMerchantForm } from './types';

/**
 * 查询商户信息拓展列表
 * @param query
 * @returns {*}
 */

export const listSysMerchant = (query?: SysMerchantQuery): AxiosPromise<SysMerchantVO[]> => {
  return request({
    url: '/system/merchant/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商户信息拓展详细
 * @param userId
 */
export const getSysMerchant = (userId: string | number): AxiosPromise<SysMerchantVO> => {
  return request({
    url: '/system/merchant/' + userId,
    method: 'get'
  });
};

/**
 * 新增商户信息拓展
 * @param data
 */
export const addSysMerchant = (data: SysUserMerchantForm) => {
  return request({
    url: '/system/merchant',
    method: 'post',
    data: data
  });
};

/**
 * 修改商户信息拓展
 * @param data
 */
export const updateSysMerchant = (data: SysUserMerchantForm) => {
  return request({
    url: '/system/merchant',
    method: 'put',
    data: data
  });
};

/**
 * 删除商户信息拓展
 * @param userId
 */
export const delSysMerchant = (userId: string | number | Array<string | number>) => {
  return request({
    url: '/system/merchant/' + userId,
    method: 'delete'
  });
};

/**
 * 商户用户密码重置
 * @param userId 用户ID
 * @param password 密码
 */
export const resetMerchantPwd = (userId: string | number, password: string) => {
  const data = {
    userId,
    password
  };
  return request({
    url: '/system/merchant/resetPwd',
    method: 'put',
    headers: {
      isEncrypt: true,
      repeatSubmit: false
    },
    data: data
  });
};