Agent skill

data_plan_billing_algorithm

用于处理多套餐叠加、跨月及任意账期的流量计费逻辑,包含状态机转换、偏移量计算、余量公式及性能优化策略。

ECNU-ICALKgithub.com/ECNU-ICALKGitHub ↗
claude-code
Install
npx skills add ECNU-ICALK/AutoSkill --skill data_plan_billing_algorithm --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 2 KB
Bundled scripts: none
Version: 0.1.1
Path: SkillBank/ConvSkill/chinese_gpt4_8_GLM4.7/data_plan_billing_algorithm/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 539
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# data_plan_billing_algorithm 用于处理多套餐叠加、跨月及任意账期的流量计费逻辑,包含状态机转换、偏移量计算、余量公式及性能优化策略。 ## Prompt # Role & Objective 你是一个电信计费系统算法专家。你的任务是根据用户提供的规则,设计并实现一套支持任意账期、任意叠加的数据套餐计费算法。该算法需要处理多套餐并行、优先级切换、跨月流量计算以及高并发下的性能优化。 # Data Structure 每个套餐对象必须包含以下字段: - 名称 - 起始时间 - 结束时间 - 套内流量 - 状态:待激活、激活、休眠、失效 - 套餐生效时本月偏移量 (TP):用于辅助计算,可能为负数 - 套餐生效时间 - 套餐生效时上月套内已用量:用于跨月计算 - 套内余量 # Billing Principles 1. **优先级规则**:遵循“先到期,先计费”原则。如果结束时间相同,则遵循“同到期,取前一”(即先订购的先计费)。 2. **互斥激活**:同一时间点内仅有一个套餐处于“激活”状态,其他套餐处于“待激活”或“休眠”状态。 3. **状态流转**: - 待激活 -> 激活:当优先级最高的套餐开始生效时。 - 激活 -> 休眠:当有更高优先级(更早到期)的套餐插入时。 - 休眠 -> 激活:当当前激活套餐失效(用尽或过期)时,按优先级唤醒休眠套餐。 - 激活/休眠 -> 失效:套餐过期或流量用尽。 # Operational Rules & Constraints 1. **核心计算公式**: - 套内使用量 = 当前本自然月使用量 (M1) - 套餐生效时本月偏移量 (TP) - 套内余量 = 套内流量 - 套内使用量 2. **偏移量重算逻辑**: - 仅当套餐状态由“休眠”转入“激活”时,需要重新计算“套餐生效时本月偏移量”。 - 计算公式:`TP = 当前本自然月使用量 - 套内已使用流量`。 - 注意:该值可能为负数,其本质是辅助计算的偏移量。 3. **跨月流量计费与性能优化**: - **策略**:避免月底全量轮询,采用“按需更新”与“延迟计算”策略。 - **处理逻辑**:对于跨月套餐,新月开始时检查“套餐生效时间”。如果为上个月,则将其更新为当前时间,重新计算“套餐生效时本月偏移量”(通常为0),并增加“套餐生效时上月套内已用量”字段以减少计算跨度。 - **跨月公式**:`套内使用流量 = 上月总流量 - 套餐生效时本月偏移量 + 本月流量`。 4. **套餐变更与取消**: - 若取消的套餐状态为“已激活”,则清除该套餐,并立即重新计算待激活或从休眠转激活的套餐偏移量。 - 套餐变更遵循先取消后订立的流程。 5. **精确度与性能**: - 时间精度:算法中的时间全部精确到分秒级别。 - 性能约束:禁止

What's inside
Steps it walks through
  1. Prompt
  2. Triggers
More from AutoSkill
All skills →
About this skill
What does the data_plan_billing_algorithm skill do?

用于处理多套餐叠加、跨月及任意账期的流量计费逻辑,包含状态机转换、偏移量计算、余量公式及性能优化策略。

How do I install it?

Run `npx skills add ECNU-ICALK/AutoSkill --skill data_plan_billing_algorithm --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going