/**
 * api接口管理， 全部以$开头 
 * @author terrfly
 * @site https://www.jeequan.com
 * @date 2021/12/17 09:57
 */


import http from '@/http/http.js'
import appConfig from '@/config/appConfig.js'

/** 获取获取用户ID的跳转URL */
export function $getRedirectUrl (data) {
  return http.req('/api/cashier/redirectUrl', data, 'POST')
}

/** 获取url **/
export function $getChannelUserId (data) {
  return http.req('/api/cashier/channelUserId', data, 'POST')
}

/** 调起支付接口, 获取支付数据包 **/
export function $getPayPackage (amount, buyerRemark, mbrId, mbrTel,calcDiscount='') {

  let data = { amount: amount, buyerRemark: buyerRemark, channelUserId: appConfig.channelUserId, mbrId, mbrTel,discount:calcDiscount }

  // 是否 子商户小程序 调起
  data.isUseSubmchAccount = appConfig.isUseSubmchAccount
  return http.req('/api/cashier/pay', data, 'POST')
}

/** 调起支付接口, 获取订单信息 **/
export function $getPayOrderInfo () {
  return http.req('/api/cashier/payOrderInfo', null, 'POST')
}

/** 取消支付时  语音播报提示 **/
export function $payCancelBoardCast (payOrderId) {
  let data = { payOrderId: payOrderId }
  return http.req('/api/cashier/payCancelBoardCast', data, 'POST')
}

/** 调起支付后，返回内容上报服务器 **/
export function $payEventBoardCast (payOrderId, resData) {
  let data = { payOrderId: payOrderId, resData: resData }
  return http.req('/api/cashier/payEventBoardCast', data, 'POST')
}

/** 支付成功后，获取广告 **/
export function $getAdvert (data=null) {
  return http.req('/api/advert', data, 'GET')
}
// 查询是否开启会员模块 此接口 会返回 会员接口的baseURL
export function $getIsMemberPower () {
	let data = { channelUserId: appConfig.channelUserId }
  return http.req('/api/cashier/memberConfig', data, 'GET')
}

// 查询平台营销功能
export function $getMarketingConfig (configKey,storeId='') {
	let data = { channelUserId: appConfig.channelUserId,configKey:configKey,storeId:storeId }
  return http.req('/api/cashier/config', data, 'GET')
}


// 计算营销红包实付金额
export function $getCalcDiscount (amount,storeId = '') {
	let data = { channelUserId: appConfig.channelUserId,amount:amount,storeId:storeId }
  return http.req('/api/cashier/calcDiscount', data, 'GET')
}


// 支付成功后获取优惠详情 
export function $getDiscountDetail (payOrderId) { 
  return http.req('/api/cashier/getDiscountDetail/'+payOrderId, 'GET')
}

/** Api调起支付接口, 获取支付数据包 **/
export function $getApiPay (amount, code,buyerRemark='') {

  let data = { amount: amount,code:code,channelUserId:appConfig.channelUserId,auth_code:code, buyerRemark: buyerRemark }

  // 是否 子商户小程序 调起
  data.isUseSubmchAccount = appConfig.isUseSubmchAccount
  return http.req('/api/cashier/pay', data, 'POST')
}


/** 交易轮训支付请求门店 **/
export function $payApiDoRoute (amount, remark) {
  return http.req('/api/cashier/doRoute', { amount: amount, remark: remark }, 'POST')
}