import { defineComponent, computed, ref, reactive, unref, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrIncludeBooleanAttr, ssrRenderAttr, ssrLooseContain, ssrLooseEqual, ssrRenderList, ssrInterpolate, ssrRenderClass } from 'vue/server-renderer'; import { u as useApi } from './useApi-BNSkSrat.mjs'; import { u as useToast } from './useToast-MBvLaNjH.mjs'; import { a as useAuthStore } from './server.mjs'; import '../nitro/nitro.mjs'; import 'node:http'; import 'node:https'; import 'node:events'; import 'node:buffer'; import 'node:fs'; import 'node:path'; import 'node:crypto'; import 'node:url'; import '../routes/renderer.mjs'; import 'vue-bundle-renderer/runtime'; import 'unhead/server'; import 'devalue'; import 'unhead/utils'; import 'pinia'; import 'perfect-debounce'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "settlements", __ssrInlineRender: true, setup(__props) { useApi(); useToast(); const auth = useAuthStore(); const canManage = computed(() => auth.isAdmin); const rows = ref([]); const brands = ref([]); const channels = ref([]); const loading = ref(false); const generating = ref(false); const totals = reactive({ base: 0, brandNet: 0, channel: 0, platform: 0 }); const filters = reactive({ month: prevMonthStr(), brandid: 0, channelid: "", status: -1 }); const channelOptions = computed( () => filters.brandid ? channels.value.filter((ch) => ch.brandid === filters.brandid) : channels.value ); const summaryCards = computed(() => [ { label: "结算基数(订单实付)", value: totals.base, cls: "text-slate-800" }, { label: "品牌商实得", value: totals.brandNet, cls: "text-emerald-600" }, { label: "渠道商分成", value: totals.channel, cls: "text-indigo-600" }, { label: "平台留存", value: totals.platform, cls: "text-slate-600" } ]); function prevMonthStr() { const d = /* @__PURE__ */ new Date(); d.setDate(1); d.setMonth(d.getMonth() - 1); return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0"); } function fmtPeriod(p) { if (!p) return "-"; return Math.floor(p / 100) + "-" + String(p % 100).padStart(2, "0"); } function fmtMoney(cents) { return "¥" + ((Number(cents) || 0) / 100).toFixed(2); } function ratePct(rate) { return ((Number(rate) || 0) / 100).toFixed(2) + "%"; } function brandName(id) { if (!id) return "未归属品牌商"; const b = brands.value.find((x) => x.id === id); return b ? b.brand : "品牌商#" + Number(id).toString(16).toUpperCase(); } function channelName(id) { if (!id) return "未分配渠道"; const ch = channels.value.find((x) => x.id === id); return ch ? ch.name + " (" + ch.id + ")" : id; } const STATUS_LABELS = { 0: "草稿", 1: "已确认", 2: "已支付" }; const STATUS_CLASS = { 0: "badge-ghost", 1: "badge-warning", 2: "badge-success" }; function statusLabel(s) { return STATUS_LABELS[s] ?? String(s); } function statusClass(s) { return STATUS_CLASS[s] ?? "badge-ghost"; } return (_ctx, _push, _parent, _attrs) => { _push(`

月结算按订单实付金额分成,渠道商从品牌商那份里再切

`); if (canManage.value) { _push(`
`); } else { _push(``); } _push(`
`); if (!unref(auth).isBrandAccount && !unref(auth).isDealer) { _push(`
`); } else { _push(``); } if (!unref(auth).isDealer) { _push(`
`); } else { _push(``); } _push(`
`); ssrRenderList(summaryCards.value, (card) => { _push(`
${ssrInterpolate(card.label)}
${ssrInterpolate(fmtMoney(card.value))}
`); }); _push(`
`); if (canManage.value) { _push(``); } else { _push(``); } _push(``); if (loading.value) { _push(``); } else if (!rows.value.length) { _push(`该月暂无结算数据`); } else { _push(``); ssrRenderList(rows.value, (r, i) => { _push(``); if (canManage.value) { _push(``); } else { _push(``); } _push(``); }); _push(``); } _push(`
结算月品牌商渠道商订单数结算基数品牌比例品牌实得渠道比例渠道分成平台留存状态操作
${ssrInterpolate(fmtPeriod(r.period))}${ssrInterpolate(brandName(r.brandid))}${ssrInterpolate(channelName(r.channelid))}${ssrInterpolate(r.order_count)}${ssrInterpolate(fmtMoney(r.base_amount))}${ssrInterpolate(ratePct(r.brand_rate))}${ssrInterpolate(fmtMoney(r.brand_net))}${ssrInterpolate(ratePct(r.channel_rate))}${ssrInterpolate(fmtMoney(r.channel_amount))}${ssrInterpolate(fmtMoney(r.platform_amount))}${ssrInterpolate(statusLabel(r.status))}`); if (r.confirm_account) { _push(`
${ssrInterpolate(r.confirm_account)}
`); } else { _push(``); } _push(`
`); if (r.status === 0) { _push(``); } else { _push(``); } if (r.status === 1) { _push(``); } else { _push(``); } if (r.status > 0) { _push(``); } else { _push(``); } _push(`

结算基数 = 该月已支付订单实付金额合计,订单按下单时冻结的「来源设备」归属到品牌商与渠道商。
品牌商总提成 = 基数 × 品牌比例;渠道分成 = 品牌总提成 × 渠道比例;品牌实得 = 品牌总提成 − 渠道分成;平台留存 = 基数 − 品牌总提成。
比例在生成结算单时快照冻结,之后调整比例不影响已生成的月份;已确认的行重算时会跳过,需先退回草稿才能重算。

`); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/settlements.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; export { _sfc_main as default }; //# sourceMappingURL=settlements-36wv6bGk.mjs.map