import { http } from '@/common/service/service.js' import { USER_INFO } from '@/common/util/constants.js' const BASE = '/memberPrepaidMerchant' /** 当前登录门店 ID */ export function getMerchantId() { const info = uni.getStorageSync(USER_INFO) || {} return info.merchantId || '' } /** * auditStatus: 0未申请 / 1待审核 / 2已通过 / 3已驳回 * operationStatus: 0关闭 / 1开启 * reapplyStatus: 0不适用 / 1禁止重新申请 / 2允许重新申请 */ const api = { /** 查询商户行业是否支持储值(true 时显示储值管理入口) */ checkIndustryEligibility(merchantId = getMerchantId()) { return http.get(`${BASE}/industry/eligibility`, { params: { merchantId } }) }, /** 查询储值功能状态 */ getFeatureStatus(merchantId = getMerchantId()) { return http.get(`${BASE}/feature/status`, { params: { merchantId } }) }, /** 当前生效协议 */ getCurrentAgreement() { return http.get(`${BASE}/agreement/current`) }, /** 当前或最近申请详情 */ getApplication(merchantId = getMerchantId()) { return http.get(`${BASE}/feature/application`, { params: { merchantId } }) }, /** 提交开通申请 */ applyFeature(data, merchantId = getMerchantId()) { return http.post(`${BASE}/feature/apply`, data, { params: { merchantId } }) }, /** 开启储值功能 */ openFeature(merchantId = getMerchantId()) { return http.post(`${BASE}/feature/open`, {}, { params: { merchantId } }) }, /** 关闭储值功能 */ closeFeature(data, merchantId = getMerchantId()) { return http.post(`${BASE}/feature/close`, data || {}, { params: { merchantId } }) }, /** 当前门店详情 */ getCurrentStore(merchantId = getMerchantId()) { return http.get(`${BASE}/store/current`, { params: { merchantId } }) }, /** 可添加共享门店分页 */ getShareableStores(params = {}) { return http.get(`${BASE}/store/shareable/page`, { params: { merchantId: getMerchantId(), pageNo: 1, pageSize: 10, ...params } }) }, /** 已共享门店分页 */ getSharedStores(params = {}) { return http.get(`${BASE}/store/shared/page`, { params: { merchantId: getMerchantId(), pageNo: 1, pageSize: 10, ...params } }) }, /** 批量添加共享门店 */ addSharedStores(sharedStoreIds, merchantId = getMerchantId()) { return http.post( `${BASE}/store/shared`, { sharedStoreIds }, { params: { merchantId } } ) }, /** 移除共享门店 */ removeSharedStore(sharedStoreId, merchantId = getMerchantId()) { return http.delete(`${BASE}/store/shared/${sharedStoreId}`, {}, { params: { merchantId } }) }, /** 首页概览 */ getOverview(merchantId = getMerchantId()) { return http.get(`${BASE}/overview`, { params: { merchantId } }) }, /** 账户明细分页 */ getLedgerPage(params = {}) { return http.get(`${BASE}/account/ledger/page`, { params: { merchantId: getMerchantId(), pageNo: 1, pageSize: 10, ...params } }) }, /** 账户明细详情 */ getLedgerDetail(ledgerId, merchantId = getMerchantId()) { return http.get(`${BASE}/account/ledger/${ledgerId}/detail`, { params: { merchantId } }) }, /** 查询储值设置 */ getRechargeConfig(merchantId = getMerchantId()) { return http.get(`${BASE}/recharge/config`, { params: { merchantId } }) }, /** 保存储值设置 */ saveRechargeConfig(data, merchantId = getMerchantId()) { return http.put(`${BASE}/recharge/config`, data, { params: { merchantId } }) }, /** 可赠送优惠券分页 */ getCouponPage(params = {}) { return http.get(`${BASE}/recharge/coupon/page`, { params: { merchantId: getMerchantId(), pageNo: 1, pageSize: 50, ...params } }) } } export default api