修复支付宝支付
This commit is contained in:
Vendored
-29
@@ -14,72 +14,43 @@ declare module 'vue' {
|
||||
CommonAside: typeof import('./src/components/CommonAside.vue')['default']
|
||||
CommonHeader: typeof import('./src/components/CommonHeader.vue')['default']
|
||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||
ElAside: typeof import('element-plus/es')['ElAside']
|
||||
ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
|
||||
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
||||
ElBacktop: typeof import('element-plus/es')['ElBacktop']
|
||||
ElBadge: typeof import('element-plus/es')['ElBadge']
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
|
||||
ElCard: typeof import('element-plus/es')['ElCard']
|
||||
ElCascader: typeof import('element-plus/es')['ElCascader']
|
||||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
|
||||
ElCol: typeof import('element-plus/es')['ElCol']
|
||||
ElCollapse: typeof import('element-plus/es')['ElCollapse']
|
||||
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
|
||||
ElCollapseTransition: typeof import('element-plus/es')['ElCollapseTransition']
|
||||
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
|
||||
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
|
||||
ElContainer: typeof import('element-plus/es')['ElContainer']
|
||||
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
|
||||
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
|
||||
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
|
||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||
ElDivider: typeof import('element-plus/es')['ElDivider']
|
||||
ElDrawer: typeof import('element-plus/es')['ElDrawer']
|
||||
ElDropdown: typeof import('element-plus/es')['ElDropdown']
|
||||
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
|
||||
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
|
||||
ElEmpty: typeof import('element-plus/es')['ElEmpty']
|
||||
ElForm: typeof import('element-plus/es')['ElForm']
|
||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||
ElImage: typeof import('element-plus/es')['ElImage']
|
||||
ElInput: typeof import('element-plus/es')['ElInput']
|
||||
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
|
||||
ElLink: typeof import('element-plus/es')['ElLink']
|
||||
ElMain: typeof import('element-plus/es')['ElMain']
|
||||
ElMenu: typeof import('element-plus/es')['ElMenu']
|
||||
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
||||
ElOption: typeof import('element-plus/es')['ElOption']
|
||||
ElOptionGroup: typeof import('element-plus/es')['ElOptionGroup']
|
||||
ElPagination: typeof import('element-plus/es')['ElPagination']
|
||||
ElPopover: typeof import('element-plus/es')['ElPopover']
|
||||
ElProgress: typeof import('element-plus/es')['ElProgress']
|
||||
ElRadio: typeof import('element-plus/es')['ElRadio']
|
||||
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
|
||||
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||
ElRow: typeof import('element-plus/es')['ElRow']
|
||||
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
|
||||
ElStep: typeof import('element-plus/es')['ElStep']
|
||||
ElSteps: typeof import('element-plus/es')['ElSteps']
|
||||
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
||||
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
ElTabPane: typeof import('element-plus/es')['ElTabPane']
|
||||
ElTabs: typeof import('element-plus/es')['ElTabs']
|
||||
ElTag: typeof import('element-plus/es')['ElTag']
|
||||
ElTimeline: typeof import('element-plus/es')['ElTimeline']
|
||||
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
|
||||
ElTimeSelect: typeof import('element-plus/es')['ElTimeSelect']
|
||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||
ElTree: typeof import('element-plus/es')['ElTree']
|
||||
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
|
||||
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||
MessageDetailDialog: typeof import('./src/components/MessageDetailDialog.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
|
||||
@@ -230,6 +230,7 @@ import {
|
||||
} from "@element-plus/icons-vue";
|
||||
|
||||
import { getTenantList } from "@/api/modules";
|
||||
import { getProductOrderStatus } from "@/api/product";
|
||||
import { getCurrentUserProfile, logout } from "@/api/login";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { useMenuStore } from "@/stores/menu";
|
||||
@@ -437,9 +438,45 @@ async function loadModules() {
|
||||
}
|
||||
}
|
||||
|
||||
// 支付宝同步回跳会把交易参数附在地址查询串中(out_trade_no 为支付单号)。
|
||||
// 拿到支付单号后立即清理地址栏(保留 #/home 等路由 hash),避免用户停留在带支付
|
||||
// 签名参数的 URL 上;随后在后台重试同步订单(异步通知可能晚于回跳到达),
|
||||
// 开通完成后自动刷新模块,避免首页继续显示“请购买后使用”。
|
||||
async function syncReturnedPayment() {
|
||||
const payNo = new URLSearchParams(window.location.search).get("out_trade_no")?.trim();
|
||||
if (!payNo || !authStore.token) return;
|
||||
|
||||
// 参数已解析:从地址栏移除支付宝交易参数,恢复为干净的 /#/home
|
||||
window.history.replaceState({}, document.title, window.location.pathname + window.location.hash);
|
||||
|
||||
// 异步通知通常数秒内到达;最多等待约 15 秒
|
||||
const MAX_ATTEMPTS = 10;
|
||||
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
|
||||
let status = "";
|
||||
try {
|
||||
const res = await getProductOrderStatus(payNo);
|
||||
if (res?.code !== 200) return; // 非本租户订单,无需继续
|
||||
status = res.data?.status || "";
|
||||
} catch {
|
||||
// 回跳地址也可能来自其他业务订单;查询不到时直接忽略
|
||||
return;
|
||||
}
|
||||
if (status === "activated") {
|
||||
// 订单已开通:重新拉取模块与菜单,解锁「请购买后使用」的卡片
|
||||
await Promise.all([loadModules(), menuStore.refreshMenus()]);
|
||||
ElMessage.success("支付成功,功能已开通");
|
||||
return;
|
||||
}
|
||||
if (status === "closed") return;
|
||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
}
|
||||
}
|
||||
|
||||
// 组件挂载时加载模块列表
|
||||
onMounted(() => {
|
||||
// 先按当前状态渲染首页;支付回跳的订单同步在后台完成,成功后自动刷新模块
|
||||
loadModules();
|
||||
syncReturnedPayment();
|
||||
initTheme();
|
||||
// 拉取当前登录用户的角色 / 部门 / 职位,用于右上角展示
|
||||
if (authStore.token) {
|
||||
|
||||
@@ -114,14 +114,32 @@
|
||||
<el-table-column prop="create_time" label="下单时间" width="170" align="center" />
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 支付弹窗 -->
|
||||
<el-dialog v-model="payVisible" title="扫码支付" width="420px" :close-on-click-modal="false">
|
||||
<div v-if="payParams?.code_url" class="pay-body">
|
||||
<canvas ref="qrRef" class="pay-qr"></canvas>
|
||||
<p class="pay-tip">请使用{{ currentChannelName }}扫码支付</p>
|
||||
<p class="pay-amount">¥{{ Number(payAmount || 0).toFixed(2) }}</p>
|
||||
</div>
|
||||
<div v-else-if="payParams?.redirect_url" class="pay-body">
|
||||
<p class="pay-tip">正在跳转{{ currentChannelName }}收银台…</p>
|
||||
<el-button type="primary" @click="openPayUrl(payParams.redirect_url)">重新打开支付页</el-button>
|
||||
</div>
|
||||
<p class="pay-status">{{ payStatusText }}</p>
|
||||
<template #footer>
|
||||
<el-button @click="handleCancelPay">取消支付</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { computed, nextTick, onMounted, ref, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { ArrowLeft, OfficeBuilding, Box, User, InfoFilled } from "@element-plus/icons-vue";
|
||||
import QRCode from "qrcode";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import {
|
||||
getPackageList,
|
||||
@@ -138,6 +156,13 @@ const loading = ref(false);
|
||||
const packages = ref<any[]>([]);
|
||||
const buyingIds = ref<Record<string, boolean>>({});
|
||||
|
||||
const payVisible = ref(false);
|
||||
const payParams = ref<any>(null);
|
||||
const payStatusText = ref("");
|
||||
const payAmount = ref(0);
|
||||
const currentChannelName = ref("");
|
||||
const qrRef = ref<HTMLCanvasElement | null>(null);
|
||||
|
||||
const ordersVisible = ref(false);
|
||||
const myOrders = ref<any[]>([]);
|
||||
const ordersLoading = ref(false);
|
||||
@@ -183,6 +208,21 @@ const loadMyOrders = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const openPayUrl = (url: string) => {
|
||||
if (url) window.open(url, "_blank", "noopener,noreferrer");
|
||||
};
|
||||
|
||||
const renderQR = async () => {
|
||||
if (!payParams.value?.code_url) return;
|
||||
await nextTick();
|
||||
if (!qrRef.value) return;
|
||||
try {
|
||||
await QRCode.toCanvas(qrRef.value, payParams.value.code_url, { width: 200, margin: 1 });
|
||||
} catch (e) {
|
||||
console.error("二维码生成失败:", e);
|
||||
}
|
||||
};
|
||||
|
||||
const handleBuy = async (pkg: any) => {
|
||||
buyingIds.value[pkg.id] = true;
|
||||
try {
|
||||
@@ -195,13 +235,15 @@ const handleBuy = async (pkg: any) => {
|
||||
package_code: pkg.code,
|
||||
channel,
|
||||
pay_type: "",
|
||||
// 支付宝同步回跳地址:必须是完整 http(s) 地址,且不能带 # 和自定义参数,
|
||||
// 否则支付成功后收银台倒计时结束无处可跳、页面卡住,故取站点根路径
|
||||
return_url: window.location.origin + window.location.pathname,
|
||||
});
|
||||
if (res.code !== 200) {
|
||||
ElMessage.error(res.msg || "下单失败");
|
||||
return;
|
||||
}
|
||||
const orderNo = res.data?.order_no || "";
|
||||
const payParams = res.data?.pay_params || null;
|
||||
const offline = res.data?.offline === true;
|
||||
|
||||
if (offline) {
|
||||
@@ -210,10 +252,14 @@ const handleBuy = async (pkg: any) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 在线支付:复用产品购买的支付弹窗逻辑
|
||||
// 这里简单跳转到产品购买页的支付流程,或直接展示支付二维码
|
||||
// 为简化,直接用 orderNo 轮询状态
|
||||
ElMessage.success("下单成功,请完成支付");
|
||||
// 在线支付:展示扫码二维码或跳转收银台,并轮询订单状态
|
||||
payParams.value = res.data?.pay_params || null;
|
||||
payAmount.value = Number(res.data?.amount || pkg.price || 0);
|
||||
currentChannelName.value = channels.find((x: any) => x.channel === channel)?.name || channel;
|
||||
payStatusText.value = "请在有效期内完成支付,支付成功后由平台开通功能";
|
||||
payVisible.value = true;
|
||||
await renderQR();
|
||||
if (payParams.value?.redirect_url) openPayUrl(payParams.value.redirect_url);
|
||||
startPolling(orderNo);
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || "下单失败");
|
||||
@@ -247,11 +293,12 @@ const checkOrder = async (orderNo: string, silent = false) => {
|
||||
if (status === "activated") {
|
||||
stopPolling();
|
||||
ElMessage.success("购买成功,套餐已开通");
|
||||
payVisible.value = false;
|
||||
loadMyOrders();
|
||||
return;
|
||||
}
|
||||
if (status === "paid") {
|
||||
if (!silent) ElMessage.info("已支付,等待平台开通…");
|
||||
payStatusText.value = "已支付,等待平台开通…";
|
||||
return;
|
||||
}
|
||||
if (!silent) ElMessage.info("尚未检测到支付成功,请确认已完成支付");
|
||||
@@ -261,15 +308,23 @@ const checkOrder = async (orderNo: string, silent = false) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancelPay = () => {
|
||||
stopPolling();
|
||||
payVisible.value = false;
|
||||
ElMessage.info("已取消,订单仍可在「我的订单」中查看");
|
||||
};
|
||||
|
||||
watch(ordersVisible, (v) => {
|
||||
if (v) loadMyOrders();
|
||||
});
|
||||
|
||||
watch(payVisible, (v) => {
|
||||
if (!v) stopPolling();
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
loadPackages();
|
||||
});
|
||||
|
||||
import { watch } from "vue";
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
@@ -443,6 +498,34 @@ import { watch } from "vue";
|
||||
}
|
||||
}
|
||||
|
||||
.pay-body {
|
||||
text-align: center;
|
||||
|
||||
.pay-qr {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
.pay-tip {
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
margin: 12px 0 4px;
|
||||
}
|
||||
|
||||
.pay-amount {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: #f56c6c;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.pay-status {
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 80px 20px;
|
||||
|
||||
@@ -263,6 +263,9 @@ const handleBuy = async () => {
|
||||
product_code: product.value.code,
|
||||
channel: channels.value.length > 0 ? channel.value : "",
|
||||
pay_type: "",
|
||||
// 支付宝同步回跳地址:必须是完整 http(s) 地址,且不能带 # 和自定义参数,
|
||||
// 否则支付成功后收银台倒计时结束无处可跳、页面卡住,故取站点根路径
|
||||
return_url: window.location.origin + window.location.pathname,
|
||||
});
|
||||
if (res.code !== 200) {
|
||||
ElMessage.error(res.msg || "下单失败");
|
||||
|
||||
@@ -76,7 +76,7 @@ func (c *BackendModulesController) GetTenantList() {
|
||||
return
|
||||
}
|
||||
|
||||
// 查询当前租户套餐包含的模块 code 集合(含默认套餐回退)
|
||||
// 查询当前租户已开通的模块 code 集合(套餐模块 + 已开通产品订单关联模块,编码已规范化)
|
||||
tid := uint64(claims.TenantId)
|
||||
allowedCodes := services.GetTenantModuleCodes(tid)
|
||||
|
||||
@@ -84,7 +84,7 @@ func (c *BackendModulesController) GetTenantList() {
|
||||
for _, m := range rows {
|
||||
enabled := true
|
||||
if len(allowedCodes) > 0 {
|
||||
enabled = allowedCodes[m.Code]
|
||||
enabled = allowedCodes[services.NormalizeModuleCode(m.Code)]
|
||||
}
|
||||
enhanced = append(enhanced, moduleWithEnabled{SystemModules: m, Enabled: enabled})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"server/models"
|
||||
"server/services/payment"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
// 支付成功 -> 产品/套餐购买订单同步:
|
||||
// 渠道异步回调(或主动查询)把支付单置为 paid 时,支付服务会调用此处注册的钩子,
|
||||
// 自动把购买订单置为已开通;否则订单只能等前端轮询兜底或平台手动开通。
|
||||
func init() {
|
||||
payment.RegisterOrderSyncHook(syncProductOrderFromPayment)
|
||||
}
|
||||
|
||||
// syncProductOrderFromPayment 支付单成功后的钩子:按业务订单号同步购买订单状态并自动开通。
|
||||
// 返回错误时支付服务会保留 order_synced=0,由支付补偿任务(5 分钟一轮)重试。
|
||||
func syncProductOrderFromPayment(_ context.Context, payOrder *models.PlatformPaymentOrder) error {
|
||||
if payOrder == nil {
|
||||
return nil
|
||||
}
|
||||
orderNo := strings.TrimSpace(payOrder.OutTradeNo)
|
||||
if orderNo == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
var order models.PlatformProductOrder
|
||||
err := models.Orm.QueryTable(new(models.PlatformProductOrder)).
|
||||
Filter("order_no", orderNo).
|
||||
Filter("delete_time__isnull", true).
|
||||
One(&order)
|
||||
if err == orm.ErrNoRows {
|
||||
// 下单链路先建支付单、后落业务订单,渠道回调可能抢先到达:
|
||||
// 短时间内保留重试;超过窗口仍不存在说明不是本模块的支付单,视为无需同步。
|
||||
if time.Since(payOrder.CreateTime) < 10*time.Minute {
|
||||
return fmt.Errorf("产品订单 %s 尚未入库,等待重试", orderNo)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 已开通/已关闭等终态无需处理
|
||||
if order.Status != models.ProductOrderStatusPending && order.Status != models.ProductOrderStatusPaid {
|
||||
return nil
|
||||
}
|
||||
if order.Status == models.ProductOrderStatusPending {
|
||||
now := time.Now()
|
||||
order.Status = models.ProductOrderStatusPaid
|
||||
order.UpdateTime = &now
|
||||
if _, err := models.Orm.Update(&order, "Status", "UpdateTime"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return activateProductOrder(&order, "支付成功自动开通")
|
||||
}
|
||||
@@ -260,8 +260,17 @@ func (c *BackendProductPurchaseController) GetOrderStatus() {
|
||||
Filter("tid", uint64(claims.TenantId)).
|
||||
Filter("delete_time__isnull", true).
|
||||
One(&order); err != nil {
|
||||
c.jsonErr(404, 404, "订单不存在")
|
||||
return
|
||||
// 支付宝同步回跳地址携带的 out_trade_no 是支付单号(pay_no),此处兜底按支付单号查询,
|
||||
// 保证「支付完成自动跳回」的场景也能直接触发状态同步与自动开通。
|
||||
if err2 := models.Orm.QueryTable(new(models.PlatformProductOrder)).
|
||||
Filter("pay_no", orderNo).
|
||||
Filter("tid", uint64(claims.TenantId)).
|
||||
Filter("delete_time__isnull", true).
|
||||
OrderBy("-id").
|
||||
One(&order); err2 != nil {
|
||||
c.jsonErr(404, 404, "订单不存在")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 在线支付:同步渠道状态,支付成功后自动开通
|
||||
|
||||
@@ -144,18 +144,68 @@ func GetTenantPackageModules(tid uint64) ([]models.SystemTenantPackageModule, er
|
||||
return rows, err
|
||||
}
|
||||
|
||||
// GetTenantModuleCodes 获取租户已开通的功能模块编码集合(如 erp / oa / crm)
|
||||
// NormalizeModuleCode 规范化模块编码:去空格 + 统一小写。
|
||||
// 模块、套餐模块、产品关联模块来自不同配置入口,编码大小写可能不一致
|
||||
// (如模块 code=oa、产品关联功能填 OA),统一规范化后再比对。
|
||||
func NormalizeModuleCode(code string) string {
|
||||
return strings.ToLower(strings.TrimSpace(code))
|
||||
}
|
||||
|
||||
// GetTenantModuleCodes 获取租户已开通的功能模块编码集合(如 erp / oa / crm)。
|
||||
//
|
||||
// 权益由两部分组成:
|
||||
// - 当前生效套餐包含的模块;
|
||||
// - 已开通单品订单关联产品的模块。
|
||||
//
|
||||
// 单品购买不会替换租户当前套餐,因此必须与套餐模块取并集;否则产品订单即使
|
||||
// 已显示“已开通”,首页仍会把该模块判定为未购买。历史订单同样按产品当前的
|
||||
// module_code 识别,保证已存在的已开通订单可立即恢复对应模块权限。
|
||||
// 返回的 key 均为 NormalizeModuleCode 规范化后的编码。
|
||||
func GetTenantModuleCodes(tid uint64) map[string]bool {
|
||||
codes := map[string]bool{}
|
||||
mark := func(code string) {
|
||||
if c := NormalizeModuleCode(code); c != "" {
|
||||
codes[c] = true
|
||||
}
|
||||
}
|
||||
rows, err := GetTenantPackageModules(tid)
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
for _, r := range rows {
|
||||
mark(r.ModuleCode)
|
||||
}
|
||||
}
|
||||
|
||||
if tid == 0 {
|
||||
return codes
|
||||
}
|
||||
for _, r := range rows {
|
||||
code := strings.TrimSpace(r.ModuleCode)
|
||||
if code != "" {
|
||||
codes[code] = true
|
||||
|
||||
var orders []models.PlatformProductOrder
|
||||
if _, err := models.Orm.QueryTable(new(models.PlatformProductOrder)).
|
||||
Filter("tid", tid).
|
||||
Filter("status", models.ProductOrderStatusActivated).
|
||||
Filter("product_id__gt", 0).
|
||||
Filter("delete_time__isnull", true).
|
||||
All(&orders); err != nil || len(orders) == 0 {
|
||||
return codes
|
||||
}
|
||||
|
||||
productIDs := make([]uint64, 0, len(orders))
|
||||
for _, order := range orders {
|
||||
productIDs = append(productIDs, order.ProductID)
|
||||
}
|
||||
var products []models.PlatformProduct
|
||||
if _, err := models.Orm.QueryTable(new(models.PlatformProduct)).
|
||||
Filter("id__in", productIDs).
|
||||
All(&products); err != nil {
|
||||
return codes
|
||||
}
|
||||
for _, product := range products {
|
||||
code := product.ModuleCode
|
||||
if strings.TrimSpace(code) == "" {
|
||||
// 产品未显式关联功能模块时,按产品编码兜底匹配(产品编码通常即模块编码,如 oa)
|
||||
code = product.Code
|
||||
}
|
||||
mark(code)
|
||||
}
|
||||
return codes
|
||||
}
|
||||
@@ -403,7 +453,7 @@ func FilterMenusByTenantModules(menus []models.SystemMenu, allModules []models.S
|
||||
out = append(out, m)
|
||||
continue
|
||||
}
|
||||
if allowedCodes[code] {
|
||||
if allowedCodes[NormalizeModuleCode(code)] {
|
||||
out = append(out, m)
|
||||
}
|
||||
}
|
||||
@@ -425,7 +475,7 @@ func MarkMenusLockedByTenantModules(menus []models.SystemMenu, allModules []mode
|
||||
path = *m.Path
|
||||
}
|
||||
code, ok := ownerModuleCode(sorted, path)
|
||||
if ok && !allowedCodes[code] {
|
||||
if ok && !allowedCodes[NormalizeModuleCode(code)] {
|
||||
lockedIDs[m.ID] = true
|
||||
}
|
||||
kept = append(kept, m)
|
||||
|
||||
Vendored
-83
@@ -1,83 +0,0 @@
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
// biome-ignore lint: disable
|
||||
// oxlint-disable
|
||||
// ------
|
||||
// Generated by unplugin-vue-components
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
|
||||
export {}
|
||||
|
||||
/* prettier-ignore */
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
CommonAside: typeof import('./src/components/CommonAside.vue')['default']
|
||||
CommonHeader: typeof import('./src/components/CommonHeader.vue')['default']
|
||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||
ElAside: typeof import('element-plus/es')['ElAside']
|
||||
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
||||
ElBacktop: typeof import('element-plus/es')['ElBacktop']
|
||||
ElBadge: typeof import('element-plus/es')['ElBadge']
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElCard: typeof import('element-plus/es')['ElCard']
|
||||
ElCascader: typeof import('element-plus/es')['ElCascader']
|
||||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
|
||||
ElCol: typeof import('element-plus/es')['ElCol']
|
||||
ElCollapse: typeof import('element-plus/es')['ElCollapse']
|
||||
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
|
||||
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
|
||||
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
|
||||
ElContainer: typeof import('element-plus/es')['ElContainer']
|
||||
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
|
||||
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
|
||||
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
|
||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||
ElDivider: typeof import('element-plus/es')['ElDivider']
|
||||
ElDrawer: typeof import('element-plus/es')['ElDrawer']
|
||||
ElDropdown: typeof import('element-plus/es')['ElDropdown']
|
||||
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
|
||||
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
|
||||
ElEmpty: typeof import('element-plus/es')['ElEmpty']
|
||||
ElForm: typeof import('element-plus/es')['ElForm']
|
||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||
ElImage: typeof import('element-plus/es')['ElImage']
|
||||
ElInput: typeof import('element-plus/es')['ElInput']
|
||||
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
|
||||
ElLink: typeof import('element-plus/es')['ElLink']
|
||||
ElMain: typeof import('element-plus/es')['ElMain']
|
||||
ElMenu: typeof import('element-plus/es')['ElMenu']
|
||||
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
|
||||
ElOption: typeof import('element-plus/es')['ElOption']
|
||||
ElPageHeader: typeof import('element-plus/es')['ElPageHeader']
|
||||
ElPagination: typeof import('element-plus/es')['ElPagination']
|
||||
ElProgress: typeof import('element-plus/es')['ElProgress']
|
||||
ElRadio: typeof import('element-plus/es')['ElRadio']
|
||||
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
|
||||
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||
ElRow: typeof import('element-plus/es')['ElRow']
|
||||
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
|
||||
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
||||
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
ElTabPane: typeof import('element-plus/es')['ElTabPane']
|
||||
ElTabs: typeof import('element-plus/es')['ElTabs']
|
||||
ElTag: typeof import('element-plus/es')['ElTag']
|
||||
ElTimeline: typeof import('element-plus/es')['ElTimeline']
|
||||
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
|
||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||
ElTree: typeof import('element-plus/es')['ElTree']
|
||||
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
|
||||
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
export interface GlobalDirectives {
|
||||
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user