import { request } from 'umi';
import { api } from '../api';

/**
 * 获取组员及组员账号列表
*/
export async function getAdAccountAllOfMember() {
  return request(api + '/adq/adAccount/allOfMember');
}
// export async function get_allOfMember() {
//   return fetch(api + '/adq/adAccount/allOfMember',{
//     headers:{
//       "content-Type":"application/json;charset=UTF-8",
//       "Authorization": `Bearer ${sessionStorage.getItem("Admin-Token")}`
//     }
//   }).then(res=>res.json())
// }

/**
 * 获取ADQ账号列表
 * @param adgroupName 广告名称
 * @param promotedObjectType 广告类型
 * @param accountId 账户ID
 * @param adgroupName 广告名称
 */
 export async function getAdqAdAccountList(params: {
  pageNum: number;
  pageSize: number;
  userId?:string;//用户ID
  accountIds?: string[];//账号本地ID
}) {
  return request(api + '/adq/adAccount/list', {
    method: 'POST',
    data: params,
  });
}
/**
 * 按账号同步计划
 * @param adAccountId 本地ID
 */
 export async function putAdqAdAccountSyncByIds(data:any) {
  return request(api + `/adq/adAccount/syncByIds`, {
    method: 'PUT',
    data
  });
}
/**
 * 获取ADQ计划列表
 * @param adgroupName 广告名称
 * @param promotedObjectType 广告类型
 * @param accountId 账户ID
 * @param adgroupName 广告名称
 */
 export async function getAdqCampaignList(params: {
  pageNum: number;
  pageSize: number;
  userId?:string;//用户ID
  accountId?: string;//账号本地ID
  campaignName?:string;//计划名称
  configuredStatus?:string;//计划状态
  campaignType?:string;//计划类型
  promotedObjectType?:string;//推广目标类型
}) {
  return request(api + '/adq/campaign/list', {
    method: 'POST',
    data: params,
  });
}
/**
 * 按账号同步计划
 * @param adAccountId 本地ID
 */
 export async function putAdqCampaignPage(adAccountId: any) {
  return request(api + `/adq/campaign/syncAll/${adAccountId} `, {
    method: 'PUT',
  });
}
/**
 * 获取ADQ广告列表
 * @param adgroupName 广告名称
 * @param promotedObjectType 广告类型
 * @param accountId 账户ID
 * @param adgroupName 广告名称
 */
 export async function getAdqAdgroupsList(params: {
  pageNum: number;
  pageSize: number;
  accountId: string;
  adgroupName?:string
}) {
  return request(api + '/adq/adgroups/list', {
    method: 'POST',
    data: params,
  });
}
/**
 * 同步ADQ广告列表
 *@param adAccountId 本地ID
 */
 export async function putAdqAdgroupsSync(data: any) {
  return request(api + `/adq/adgroups/sync`, {
    method: 'PUT',
    data
  });
}
/**
 * 获取ADQ创意列表
 * @param adgroupName 广告名称
 * @param promotedObjectType 广告类型
 * @param accountId 账户ID
 * @param adcreativeName
 */
export async function getAdqAdcreativeList(params: {
  pageNum: number;
  pageSize: number;
  accountId: string;
  adcreativeName?:string

}) {
  return request(api + '/adq/adcreative/list', {
    method: 'POST',
    data: params,
  });
}

/**
 * 获取ADQ落地页列表
 * @param adgroupName 广告名称
 * @param promotedObjectType 广告类型
 * @param accountId 账户ID
 */
export async function getAdqLandingPageList(params: {
  pageNum: number;
  pageSize: number;
  accountId: string;
  pageName: string;
  pageType: string;
  pageTemplateId: string;
  pageStatus: string;
}) {
  return request(api + '/adq/landingPageWechat/list ', {
    method: 'POST',
    data: params,
  });
}

/**
 * 按账号同步落地页
 * @param adAccountId 本地ID
 */
 export async function putAdqLandingPage(adAccountId: any) {
  return request(api + `/adq/landingPageWechat/syncAll/${adAccountId} `, {
    method: 'PUT',
  });
}
/**
 * 获取ADQ定向列表
 * @param adgroupName 广告名称
 * @param promotedObjectType 广告类型
 * @param accountId 账户ID
 */
export async function getAdqTargetingList(params: {
  pageNum: number;
  pageSize: number;
  accountId: string;
  pageName: string;
  pageType: string;
  pageTemplateId: string;
  pageStatus: string;
}) {
  return request(api + '/adq/targeting/list ', {
    method: 'POST',
    data: params,
  });
}

/**
 * 按账号同步ADQ定向列表
 * @param adAccountId 本地ID
 */
 export async function putAdqTargetingSyncAll(adAccountId: any) {
  return request(api + `/adq/targeting/syncAll/${adAccountId} `, {
    method: 'PUT',
  });
}

/**
 * 计划启停
 * @param adAccountId 本地ID
 */
 export async function putAdqCampaignConfigStatus(params: any) {
   let {accountId,campaignId,configuredStatus}=params
  return request(api + `/adq/campaign/configStatus/${accountId}/${campaignId}/${configuredStatus}`, {
    method: 'PUT',
  });
}
/**
 * 广告启停
 * @param adAccountId 本地ID
 */
 export async function putAdqAdgroupsConfigStatus(params: any) {
   let {accountId,adgroupId,configuredStatus}=params
  return request(api + `/adq/adgroups/configStatus/${accountId}/${adgroupId}/${configuredStatus}`, {
    method: 'PUT',
  });
}
