修改:协议和配置表

This commit is contained in:
chen wei bo
2025-09-08 15:11:11 +08:00
parent 5821bc17ae
commit 826e52d019
47 changed files with 12826 additions and 4127 deletions
@@ -25,6 +25,65 @@ export class PurchaseConfig extends BaseConfig {
return ConfigManager.tables.TbPurchaseConfig;
}
/**
* 获取所有配置 id,如果存在
*/
public getAllId(): any | null {
let allData = this.getAllConfig();
if (!allData) return null;
const dataArr = allData.getDataList();
let allId = [];
for (let oneData of dataArr) {
allId.push(oneData.id);
}
return allId;
}
/** 获取 充值商品的id数组,首位数字为 1 */
public getRechargeIds(): number[] {
let allId = this.getAllId();
if (!allId) return [];
// 获取所有 id
let resultId = [];
for (let one of allId) {
const firstDigit = one.toString()[0]; // 取首位字符
if (firstDigit === "1") {
resultId.push(one);
}
}
return resultId;
}
/** 获取 会员商品的id数组,首位数字为 2 */
public getMemberIds(): number[] {
let allId = this.getAllId();
if (!allId) return [];
// 获取所有 id
let resultId = [];
for (let one of allId) {
const firstDigit = one.toString()[0];
if (firstDigit === "2") {
resultId.push(one);
}
}
return resultId;
}
/** 获取 聊天商品的id数组,首位数字为 3 */
public getChatIds(): number[] {
let allId = this.getAllId();
if (!allId) return [];
// 获取所有 id
let resultId = [];
for (let one of allId) {
const firstDigit = one.toString()[0];
if (firstDigit === "3") {
resultId.push(one);
}
}
return resultId;
}
/**
* 获取配置,根据 id
*/
@@ -47,4 +106,11 @@ export class PurchaseConfig extends BaseConfig {
if (!oneData) return null;
return oneData.count;
}
/** 根据商品 id 获取商品价格 */
public getPriceById(id: number): number | null {
let oneData = this.getConfigById(id);
if (!oneData) return null;
return oneData.price;
}
}