chore: 初始开源发布

iotlcm-app:小程序端 + 用户端服务。

- app/:uni-app 小程序前端(基于 unibest,MIT)
  - 微信 AppID → YOUR_WX_APPID,uni-app AppID → __UNI__YOURAPPID
  - 内网后端地址 → admin.iotlcm.example.com
  - 应用标题与 unibest 模板 README 重写(保留上游致谢与 MIT 声明)
- server/:GoFrame 用户端服务(基于 XiuAdmin,Apache-2.0)
  - module xiuadmin → git.5iot.com/iotlcm-public/iotlcm-app(360 文件)
  - 支付回调地址 → app.iotlcm.example.com,商户名与应用名泛化
  - 真实手机号 → 合法 11 位编造号(保留号段前 3 位 + 后 4 位)
  - 依赖号码尾部的断言同步更新
  - 补 server/LICENSE(Apache-2.0)
- 移除内部资产:CI 触发器
- 补根 README,LF 行尾 + .gitattributes

已知:TestSysDept_RefreshDeptAncestors 在源仓同一提交上同样失败,属既有缺陷。
This commit is contained in:
MiFaZhan
2026-10-26 14:01:25 +08:00
commit 2ed5dfa6a1
1013 changed files with 138466 additions and 0 deletions
@@ -0,0 +1,142 @@
package app
import (
"reflect"
"testing"
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model/entity"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/os/gtime"
)
func TestAppRenewBeginDateFromExpireUsesPreviousMonthEnd(t *testing.T) {
expireAt := gtime.NewFromStr("2026-08-15 00:00:00")
got := appRenewBeginDateFromExpire(expireAt)
if got == nil {
t.Fatal("expected renew begin time")
}
if want := "2026-07-31 23:59:59"; got.Format("Y-m-d H:i:s") != want {
t.Fatalf("expected %s, got %s", want, got.Format("Y-m-d H:i:s"))
}
}
func TestAppRenewExpireAfterUsesPreviousMonthEnd(t *testing.T) {
expireAt := gtime.NewFromStr("2026-08-15 00:00:00")
got := appRenewExpireAfter(expireAt, 3)
if got == nil {
t.Fatal("expected renew expire after time")
}
if want := "2026-10-31 23:59:59"; got.Format("Y-m-d H:i:s") != want {
t.Fatalf("expected %s, got %s", want, got.Format("Y-m-d H:i:s"))
}
}
func TestAppRenewableDurationYearOptionsUsesYearConfig(t *testing.T) {
pkg := &entity.TSimFlowPackageInfo{
RenewableDurationConfig: gjson.New([]int{1, 2, 3}),
}
got, err := appRenewableDurationYearOptions(pkg)
if err != nil {
t.Fatalf("appRenewableDurationYearOptions() error = %v", err)
}
if want := []int{1, 2, 3}; !reflect.DeepEqual(got, want) {
t.Fatalf("appRenewableDurationYearOptions() = %#v, want %#v", got, want)
}
}
func TestAppRenewableDurationYearOptionsCompatibleWithLegacyMonthConfig(t *testing.T) {
pkg := &entity.TSimFlowPackageInfo{
RenewableDurationConfig: gjson.New([]int{12, 24, 36}),
}
got, err := appRenewableDurationYearOptions(pkg)
if err != nil {
t.Fatalf("appRenewableDurationYearOptions() error = %v", err)
}
if want := []int{1, 2, 3}; !reflect.DeepEqual(got, want) {
t.Fatalf("appRenewableDurationYearOptions() = %#v, want %#v", got, want)
}
}
func TestAppRenewApplyPriceRuleNormalizesPercentRatio(t *testing.T) {
if got, want := appRenewApplyPriceRule(100, 85, 5), 90.0; got != want {
t.Fatalf("appRenewApplyPriceRule() = %v, want %v", got, want)
}
if got, want := appRenewApplyPriceRule(100, 0.85, 5), 90.0; got != want {
t.Fatalf("appRenewApplyPriceRule() = %v, want %v", got, want)
}
}
func TestAppRenewEffectiveSalePriceUsesPriceOwnerBaseCost(t *testing.T) {
salePrice := appRenewEffectiveSalePriceFromBaseCosts(
appRenewEffectiveBaseCosts{
AgentCost: 80,
TerminalCost: 120,
},
appRenewPriceRule{
AgentCostRatio: 1.2,
AgentCostProfit: 3,
TerminalCostRatio: 1.5,
TerminalCostProfit: 6,
},
)
if got, want := salePrice.AgentShipmentPrice, 99.0; got != want {
t.Fatalf("agent shipment price = %v, want %v", got, want)
}
if got, want := salePrice.TerminalSalePrice, 186.0; got != want {
t.Fatalf("terminal sale price = %v, want %v", got, want)
}
}
func TestAppRenewPriceRuleUsesTargetAndDefaultSnapshots(t *testing.T) {
target := appRenewPriceRuleFromOverride("target", &entity.TSimFlowPackagePrice{
Id: 11,
AgentCostRatio: 0.9,
AgentCostProfit: 3,
UserCostRatio: 1.2,
UserCostProfit: 5,
})
if target.PriceSource != "target" || target.TargetPriceId != 11 || target.AgentDefaultPriceId != 0 {
t.Fatalf("target rule snapshot = %#v", target)
}
if got, want := appRenewEffectiveSalePriceFromBaseCosts(appRenewEffectiveBaseCosts{
AgentCost: 100,
TerminalCost: 100,
}, target).AgentShipmentPrice, 93.0; got != want {
t.Fatalf("target agent sale price = %v, want %v", got, want)
}
defaultRule := appRenewPriceRuleFromOverride("agentDefault", &entity.TSimFlowPackagePrice{
Id: 12,
AgentCostRatio: 80,
AgentCostProfit: 1,
UserCostRatio: 150,
UserCostProfit: 2,
})
if defaultRule.PriceSource != "agentDefault" || defaultRule.AgentDefaultPriceId != 12 || defaultRule.TargetPriceId != 0 {
t.Fatalf("default rule snapshot = %#v", defaultRule)
}
if got, want := appRenewEffectiveSalePriceFromBaseCosts(appRenewEffectiveBaseCosts{
AgentCost: 100,
TerminalCost: 100,
}, defaultRule).TerminalSalePrice, 152.0; got != want {
t.Fatalf("default terminal sale price = %v, want %v", got, want)
}
}
func TestAppRenewSystemBaseCostsFallsBackToCostPriceForTerminal(t *testing.T) {
pkg := &entity.TSimFlowPackageInfo{
CostPrice: 80,
TerminalCost: 0,
}
got := appRenewSystemBaseCosts(pkg)
if got.AgentCost != 80 || got.TerminalCost != 80 {
t.Fatalf("appRenewSystemBaseCosts() = %#v, want agent=80 terminal=80", got)
}
}