Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
<first-menu>
<menu-item href="/finance/packages" code="index">流量包</menu-item>
<menu-item href="/finance/packages/periods" code="period">有效期选项</menu-item>
<span class="item disabled">|</span>
<menu-item href="/finance/packages/user-packages" code="userPackage">用户流量包</menu-item>
<span class="item disabled">|</span>
<a href="/clusters/regions" target="_blank" class="item">区域设置 &nbsp; <i class="icon external small"></i></a>
</first-menu>

View File

@@ -0,0 +1,32 @@
{$layout "layout_popup"}
<h3>添加流量包</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<table class="ui table definition selectable">
<tr>
<td class="title">流量包尺寸 *</td>
<td>
<div class="ui fields inline">
<div class="ui field">
<input type="text" name="size" size="4" maxlength="4" ref="focus"/>
</div>
<div class="ui field">
<select class="ui dropdown" name="unit">
<option v-for="unit in unitOptions" :value="unit.code">{{unit.name}}</option>
</select>
</div>
</div>
<p class="comment">保存后不允许再修改此选项。</p>
</td>
</tr>
<tr>
<td>价格</td>
<td><span class="grey">在创建后设置</span></td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,45 @@
{$layout}
{$template "menu"}
<second-menu>
<menu-item @click.prevent="createPackage">[添加流量包]</menu-item>
</second-menu>
<div v-if="!enableTrafficPackages">
<div class="margin"></div>
<div class="ui message warning">尚未在 <a href="/finance/fee">[计费设置]</a> 里开启"启用流量包"选项,用户将无法使用设置的流量包。</div>
</div>
<p class="comment" v-if="packages.length == 0">暂时还没有流量包。</p>
<div v-if="packages.length > 0">
<table class="ui table selectable celled">
<thead>
<tr>
<th>流量包尺寸</th>
<th class="width10">价格项</th>
<th class="width6">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="p in packages">
<td>
<a href="" @click.prevent="updatePackage(p.id)">{{p.size}}{{p.unit.replace(/(.)B/, "$1iB")}} <i class="icon expand small"></i></a>
</td>
<td>
<a href="" @click.prevent="updatePrices(p.id)">
<span class="" v-if="p.countPrices > 0">{{p.countPrices}}<span class="grey">/{{totalPriceItems}}</span></span>
<span class="" v-else>[设置价格]</span>
</a>
</td>
<td>
<label-on :v-is-on="p.isOn"></label-on>
</td>
<td>
<a href="" @click.prevent="updatePackage(p.id)">修改</a>
&nbsp;
<a href="" @click.prevent="deletePackage(p.id)">删除</a>
</td>
</tr>
</table>
</div>

View File

@@ -0,0 +1,44 @@
Tea.context(function () {
this.createPackage = function () {
teaweb.popup("/finance/packages/createPopup", {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.updatePackage = function (packageId) {
teaweb.popup("/finance/packages/updatePopup?packageId=" + packageId, {
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.deletePackage = function (packageId) {
let that = this
teaweb.confirm("确定要删除此流量包吗?", function () {
that.$post("/finance/packages/delete")
.params({packageId: packageId})
.success(function () {
teaweb.success("删除成功", function () {
teaweb.reload()
})
})
})
}
this.updatePrices = function (packageId) {
teaweb.popup("/finance/packages/updatePricesPopup?packageId=" + packageId, {
width: "54em",
height: "30em",
onClose: function () {
teaweb.reload()
}
})
}
})

View File

@@ -0,0 +1,26 @@
{$layout "layout_popup"}
<h3>添加有效期选项</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<table class="ui table definition selectable">
<tr>
<td class="title">有效期选项 *</td>
<td>
<div class="ui fields inline">
<div class="ui field">
<input type="text" name="count" size="4" maxlength="4" ref="focus" placeholder="数量"/>
</div>
<div class="ui field">
<select class="ui dropdown" name="unit">
<option value="month"></option>
<option value="year"></option>
</select>
</div>
</div>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,35 @@
{$layout}
{$template "../menu"}
<second-menu>
<menu-item @click.prevent="createPeriod">[添加有效期选项]</menu-item>
</second-menu>
<div v-if="!enableTrafficPackages">
<div class="margin"></div>
<div class="ui message warning">尚未在 <a href="/finance/fee">[计费设置]</a> 里开启"启用流量包"选项,用户将无法使用设置的流量包。</div>
</div>
<p class="comment" v-if="periods.length == 0">暂时还没有有效期选项设置。</p>
<table class="ui table celled selectable" v-if="periods.length > 0">
<thead>
<tr>
<th>有效期选项</th>
<th class="width6">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="period in periods">
<td>
<a href="" @click.prevent="updatePeriod(period.id)">{{period.count}}{{period.unitName}} <i class="icon expand small"></i></a>
</td>
<td>
<label-on :v-is-on="period.isOn"></label-on>
</td>
<td>
<a href="" @click.prevent="updatePeriod(period.id)">修改</a> &nbsp;
<a href="" @click.prevent="deletePeriod(period.id)">删除</a>
</td>
</tr>
</table>

View File

@@ -0,0 +1,32 @@
Tea.context(function () {
this.createPeriod = function () {
teaweb.popup("/finance/packages/periods/createPopup", {
callback: function () {
teaweb.successRefresh("保存成功")
}
})
}
this.updatePeriod = function (periodId) {
teaweb.popup("/finance/packages/periods/period/updatePopup?periodId=" + periodId, {
callback: function () {
teaweb.successRefresh("保存成功")
}
})
}
this.deletePeriod = function (periodId) {
let that = this
teaweb.confirm("确定要删除此有效期选项吗?", function () {
that.$post("/finance/packages/periods/period/delete")
.params({
periodId: periodId
})
.success(function () {
teaweb.success("删除成功", function () {
teaweb.reload()
})
})
})
}
})

View File

@@ -0,0 +1,23 @@
{$layout "layout_popup"}
<h3>修改有效期选项</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="periodId" :value="period.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">有效期选项</td>
<td>{{period.count}}{{period.unitName}}</td>
</tr>
<tr>
<td>启用</td>
<td>
<checkbox name="isOn" v-model="period.isOn"></checkbox>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,26 @@
{$layout "layout_popup"}
<h3>修改流量包</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="packageId" :value="package.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">流量包尺寸</td>
<td>
{{package.size}}{{package.unit}}
</td>
</tr>
<tr>
<td>启用</td>
<td>
<checkbox name="isOn" v-model="package.isOn"></checkbox>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,51 @@
{$layout "layout_popup"}
<h3>流量包"{{package.size}}{{package.unit}}"价格 <span class="grey" style="font-size: 0.7em">(全部{{regions.length * periods.length}}项)</span></h3>
<table class="ui table celled selectable definition">
<!-- header -->
<thead class="full-width">
<tr>
<th class="two wide">
区域\有效期
</th>
<th v-for="period in periods" style="width: 10em">
{{period.name}}
</th>
<th>
<a href="/finance/packages/periods" target="_blank" style="font-weight: normal">[添加有效期]</a>
</th>
</tr>
</thead>
<tr v-for="region in regions">
<td>{{region.name}}</td>
<td v-for="period in periods">
<span v-if="prices[region.id + '@' + period.id] > 0">{{prices[region.id + '@' + period.id]}}元</span>
<span v-else class="disabled">[无]</span>
<div>
<a href="" @click.prevent="editPrice(region.id, period.id)"><span class="small">[设置]</span></a>
<div v-show="editingRegionId == region.id && editingPeriodId == period.id">
<div class="ui input small right labeled">
<input type="text" size="6" maxlength="6" :ref="'input' + region.id + '_' + period.id" placeholder="价格" @keyup.enter="savePrice(region.id, period.id)" @keypress.enter.prevent="1"/>
<span class="ui label"></span>
</div>
<div style="margin-top: 0.6em">
<button class="ui button tiny primary" type="button" @click.prevent="savePrice(region.id, period.id)">保存</button> &nbsp; <a href="" title="取消" @click.prevent="cancelEditing"><i class="icon remove small"></i></a>
</div>
</div>
</div>
</td>
<td></td>
</tr>
<!-- footer -->
<tr>
<td>
<a href="/clusters/regions" target="_blank" style="font-weight: normal">[添加区域]</a>
</td>
<td v-for="period in periods">
</td>
<td></td>
</tr>
</table>

View File

@@ -0,0 +1,72 @@
Tea.context(function () {
this.editingRegionId = 0
this.editingPeriodId = 0
this.editPrice = function (regionId, periodId) {
this.editingRegionId = regionId
this.editingPeriodId = periodId
let refs = this.$refs
if (typeof refs == "object") {
for (let k in refs) {
if (typeof k == "string" && k == "input" + regionId + "_" + periodId) {
let inputs = refs[k]
if (inputs.length > 0) {
setTimeout(function () {
inputs[0].focus()
}, 10)
}
break
}
}
}
}
this.cancelEditing = function () {
this.editingRegionId = 0
this.editingPeriodId = 0
}
this.savePrice = function (regionId, periodId) {
let refs = this.$refs
let price = -1
if (typeof refs == "object") {
for (let k in refs) {
if (typeof k == "string" && k == "input" + regionId + "_" + periodId) {
let inputs = refs[k]
if (inputs.length > 0) {
let input = inputs[0]
let newPrice = parseFloat(input.value)
if (isNaN(newPrice) || newPrice < 0) {
teaweb.warn("请输入一个正确的数字", function () {
input.focus()
})
return
}
price = newPrice
}
break
}
}
}
if (price < 0) {
teaweb.warn("请输入一个正确的数字", function () {
})
return
}
this.$post("/finance/packages/updatePrice")
.params({
packageId: this.package.id,
regionId: regionId,
periodId: periodId,
price: price
})
.success(function () {
this.editingRegionId = 0
this.editingPeriodId = 0
this.prices[regionId + "@" + periodId] = price
})
}
})

View File

@@ -0,0 +1,60 @@
{$layout "layout_popup"}
<h3>添加用户流量包</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="packageId" :value="packageId"/>
<input type="hidden" name="regionId" :value="regionId"/>
<input type="hidden" name="periodId" :value="periodId"/>
<table class="ui table definition selectable">
<tr>
<td>选择用户 *</td>
<td>
<user-selector></user-selector>
</td>
</tr>
<tr>
<td class="title">选择流量包规格 *</td>
<td>
<span v-if="packages.length > 0"><a v-for="p in packages" class="ui label basic" :class="{blue: p.id == packageId}" @click.prevent="selectPackage(p.id)">{{p.size}}{{p.unit.toUpperCase().replace(/(.)B/, "$1iB")}}</a></span>
<span v-else="" class="red">没有流量包可供选择</span>
</td>
</tr>
<tr>
<td>选择区域 *</td>
<td>
<span v-if="regions.length > 0"><a v-for="region in regions" class="ui label basic" :class="{blue: region.id == regionId && hasRegionPrice(region.id), disabled: !hasRegionPrice(region.id)}" @click.prevent="selectRegion(region.id)">{{region.name}}</a></span>
<span v-else="" class="red">没有区域可供选择</span>
</td>
</tr>
<tr>
<td>选择有效期 *</td>
<td>
<span v-if="periods.length > 0"><a v-for="period in periods" class="ui label basic" :class="{blue: period.id == periodId && hasPeriodPrice(period.id), disabled: !hasPeriodPrice(period.id)}" @click.prevent="selectPeriod(period.id)">{{period.count}}{{period.unitName}}</a></span>
<span v-else="" class="red">没有有效期可供选择</span>
</td>
</tr>
<tr>
<td>流量包数量 *</td>
<td>
<div class="ui input">
<select class="ui dropdown" name="count" v-model="count" @change="changeCount">
<option v-for="i in 20" :value="i">{{i}}</option>
</select>
</div>
</td>
</tr>
<tr>
<td>价格</td>
<td>
<span v-if="amount == 0" class="disabled">没有找到对应价格</span>
<span v-if="amount > 0">{{amount}}元</span>
<p class="comment">管理员操作时,此价格仅供展示,并不会从用户账户中扣款。</p>
</td>
</tr>
</table>
<submit-btn :class="{disabled: amount <= 0}"></submit-btn>
</form>

View File

@@ -0,0 +1,70 @@
Tea.context(function () {
this.packageId = 0
this.regionId = 0
this.periodId = 0
this.amount = -1
this.count = 1
this.selectPackage = function (packageId) {
this.packageId = packageId
this.regionId = 0
this.periodId = 0
this.reloadPrice()
}
this.selectRegion = function (regionId) {
this.regionId = regionId
this.periodId = 0
this.reloadPrice()
}
this.selectPeriod = function (periodId) {
this.periodId = periodId
this.reloadPrice()
}
this.changeCount = function () {
this.reloadPrice()
}
var requestId = 0
this.reloadPrice = function () {
var newRequestId = (++requestId)
this.$post(".price")
.params({
packageId: this.packageId,
regionId: this.regionId,
periodId: this.periodId,
count: this.count
})
.success(function (resp) {
if (newRequestId == requestId) {
this.amount = resp.data.amount
}
})
}
this.hasRegionPrice = function (regionId) {
if (this.packageId <= 0) {
return false
}
for (let k in this.prices) {
if (k.startsWith(this.packageId + "@" + regionId + "@")) {
return true
}
}
return false
}
this.hasPeriodPrice = function (periodId) {
if (this.packageId <= 0 || this.regionId <= 0) {
return false
}
for (let k in this.prices) {
if (k == this.packageId + "@" + this.regionId + "@" + periodId) {
return true
}
}
return false
}
})

View File

@@ -0,0 +1,53 @@
{$layout}
{$template "../menu"}
<second-menu>
<menu-item @click.prevent="createUserPackage">[添加用户流量包]</menu-item>
</second-menu>
<p class="comment" v-if="userPackages.length == 0">暂时还没有用户流量包。</p>
<div v-if="userPackages.length > 0">
<table class="ui table selectable celled">
<thead>
<tr>
<th>用户</th>
<th>流量包</th>
<th style="width: 7em">区域</th>
<th style="width: 7em">有效期</th>
<th style="width: 7em">开始日期</th>
<th style="width: 7em">结束日期</th>
<th style="width: 7em">已用流量</th>
<th style="width: 7em">剩余流量</th>
<th class="one op">操作</th>
</tr>
</thead>
<tr v-for="up in userPackages">
<td><user-link :v-user="up.user"></user-link></td>
<td>
<span v-if="up.package != null">{{up.package.size}}{{up.package.unit.toUpperCase().replace(/(.)B/, "$1iB")}}</span>
<span v-else class="disabled">[已删除]</span>
<div v-if="up.isUsedAll || up.isExpired">
<span v-if="up.isUsedAll" class="small red">已用尽</span>
<span v-else-if="up.isExpired" class="small red">已过期</span>
</div>
</td>
<td>
<span v-if="up.region != null">{{up.region.name}}</span>
<span v-else="" class="disabled">[已删除]</span>
</td>
<td>{{up.periodCount}}{{up.periodUnitName}}</td>
<td>{{up.dayFrom}}</td>
<td>{{up.dayTo}}</td>
<td><span :class="{disabled: up.usedSize == '0B'}">{{up.usedSize}}</span></td>
<td><span :class="{disabled: up.availableSize == '0B'}">{{up.availableSize}}</span></td>
<td>
<a href="" v-if="up.canDelete" @click.prevent="deleteUserPackage(up.id)">删除</a>
</td>
</tr>
</table>
<page-box></page-box>
</div>

View File

@@ -0,0 +1,24 @@
Tea.context(function () {
this.createUserPackage = function () {
teaweb.popup("/finance/packages/user-packages/createPopup", {
width: "44em",
height: "28em",
callback: function () {
teaweb.successRefresh("保存成功")
}
})
}
this.deleteUserPackage = function (userPackageId) {
let that = this
teaweb.confirm("确定要删除此用户流量包吗?", function () {
that.$post(".delete")
.params({
userPackageId: userPackageId
})
.success(function () {
teaweb.successRefresh("删除成功")
})
})
}
})