更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

+1 -22
View File
@@ -7,11 +7,6 @@ import (
"server/models"
)
// ERP 库存查询核心(两端共用):结存、流水、批次、预警、补货建议的算法只在这里实现一份,
// /backend/erp/stock* 与 /api/erp/stock* 的 handler 只负责取参数与输出各自的响应信封,
// 保证「手机上看到的库存数」和「Web 端看到的」永远是同一套口径。
// erpStockFilter 结存查询条件
type erpStockFilter struct {
WarehouseID uint64
ProductID uint64
@@ -23,7 +18,6 @@ type erpStockFilter struct {
SafetyState string
}
// erpStockListCore 库存结存列表(可按商品聚合),返回当前页、总数与金额合计
func erpStockListCore(a erpActor, f erpStockFilter, page, pageSize int) ([]erpStockRow, int64, float64, int, string) {
qs := models.Orm.QueryTable(new(models.ErpStock)).Filter("tenant_id", a.Tid)
if f.WarehouseID > 0 {
@@ -48,7 +42,7 @@ func erpStockListCore(a erpActor, f erpStockFilter, page, pageSize int) ([]erpSt
cats := erpCategoryMap(a.Tid)
list := make([]erpStockRow, 0, len(rows))
agg := map[uint64]int{} // 按商品聚合时的数量合计
agg := map[uint64]int{}
for _, s := range rows {
p := pmap[s.ProductID]
amount := round2f(s.Quantity * s.CostPrice)
@@ -56,7 +50,6 @@ func erpStockListCore(a erpActor, f erpStockFilter, page, pageSize int) ([]erpSt
if i, hit := agg[s.ProductID]; hit {
r := &list[i]
r.Quantity = round4f(r.Quantity + s.Quantity)
// 加权成本 = 合计金额 / 合计数量
base := r.Amount
r.Amount = round2f(base + amount)
if r.Quantity > 0.000001 {
@@ -78,7 +71,6 @@ func erpStockListCore(a erpActor, f erpStockFilter, page, pageSize int) ([]erpSt
list = append(list, row)
}
// 商品维度过滤(关键字/分类)在聚合后做,避免 SQL 里 JOIN 档案表
if f.Keyword != "" {
kw := f.Keyword
list = erpFilterRows(list, func(r erpStockRow) bool {
@@ -104,7 +96,6 @@ func erpStockListCore(a erpActor, f erpStockFilter, page, pageSize int) ([]erpSt
return list[start:end], total, round2f(sumAmount), 200, ""
}
// erpLedgerFilter 库存流水查询条件
type erpLedgerFilter struct {
ProductID uint64
WarehouseID uint64
@@ -115,7 +106,6 @@ type erpLedgerFilter struct {
DateTo string
}
// erpLedgerCore 库存流水(收发存明细追溯)
func erpLedgerCore(a erpActor, f erpLedgerFilter, page, pageSize int) ([]models.ErpStockLedger, int64, int, string) {
qs := models.Orm.QueryTable(new(models.ErpStockLedger)).Filter("tenant_id", a.Tid)
if f.ProductID > 0 {
@@ -162,7 +152,6 @@ func erpLedgerCore(a erpActor, f erpLedgerFilter, page, pageSize int) ([]models.
return rows, total, 200, ""
}
// erpWarningCore 库存预警:低于安全库存 / 超储 / 零库存 / 效期临近
func erpWarningCore(a erpActor) (map[string]interface{}, int, string) {
tid := a.Tid
var products []models.ErpProduct
@@ -176,7 +165,6 @@ func erpWarningCore(a erpActor) (map[string]interface{}, int, string) {
for _, s := range stocks {
qtyMap[s.ProductID] += s.Quantity
}
// 在途量:已生效未执行完的采购订单剩余数量,用于判断"缺货但已在途"
inTransit := erpPurchaseInTransit(tid)
cats := erpCategoryMap(tid)
@@ -192,7 +180,6 @@ func erpWarningCore(a erpActor) (map[string]interface{}, int, string) {
switch {
case p.SafetyQty > 0 && q < p.SafetyQty:
row.Type, row.TypeLabel = "low", "低于安全库存"
// 补货建议:补到安全库存的1.5倍,扣除在途
target := round4f(p.SafetyQty * 1.5)
if p.MaxQty > target {
target = round4f(p.MaxQty)
@@ -214,7 +201,6 @@ func erpWarningCore(a erpActor) (map[string]interface{}, int, string) {
}
}
// 效期预警:按批次结存取最近一次流水的到期日
expiring := erpExpiringBatches(tid, 30)
return map[string]interface{}{
@@ -225,7 +211,6 @@ func erpWarningCore(a erpActor) (map[string]interface{}, int, string) {
}, 200, ""
}
// erpReplenishCore 智能补货建议(按供应商分组,可一键生成采购订单)
func erpReplenishCore(a erpActor) ([]erpReplenishRow, int, string) {
tid := a.Tid
var products []models.ErpProduct
@@ -240,7 +225,6 @@ func erpReplenishCore(a erpActor) ([]erpReplenishRow, int, string) {
qtyMap[s.ProductID] += s.Quantity
}
inTransit := erpPurchaseInTransit(tid)
// 近期销量(30天销售出库)作为动态补货依据
sold := erpSoldQty(tid, 30)
rows := make([]erpReplenishRow, 0)
@@ -250,7 +234,6 @@ func erpReplenishCore(a erpActor) ([]erpReplenishRow, int, string) {
if p.MaxQty > target {
target = p.MaxQty
}
// 有销量数据时按「月销 + 安全库存」定目标,更贴近实际周转
if s := sold[p.ID]; s > 0 && s > target {
target = s + p.SafetyQty*0.5
}
@@ -269,7 +252,6 @@ func erpReplenishCore(a erpActor) ([]erpReplenishRow, int, string) {
return rows, 200, ""
}
// erpBatchFilter 批次台账查询条件
type erpBatchFilter struct {
WarehouseID uint64
ProductID uint64
@@ -278,7 +260,6 @@ type erpBatchFilter struct {
ExpireState string
}
// erpBatchCore 批次与效期台账
func erpBatchCore(a erpActor, f erpBatchFilter, page, pageSize int) ([]erpBatchRow, int64, int, string) {
qs := models.Orm.QueryTable(new(models.ErpStock)).
Filter("tenant_id", a.Tid).Exclude("batch_no", "")
@@ -296,7 +277,6 @@ func erpBatchCore(a erpActor, f erpBatchFilter, page, pageSize int) ([]erpBatchR
return nil, 0, 500, "查询失败: " + err.Error()
}
// 批次效期来自入库流水(同批次取最早到期日)
ids := erpStockProductIDs(rows)
pmap := erpProductMap(a.Tid, ids)
expireMap := erpBatchExpiry(a.Tid, ids, pmap)
@@ -354,7 +334,6 @@ func erpBatchCore(a erpActor, f erpBatchFilter, page, pageSize int) ([]erpBatchR
return list[start:end], total, 200, ""
}
// erpPageWindow 内存分页的取页区间,越界时收敛到末尾
func erpPageWindow(length, page, pageSize int) (int, int) {
start := (page - 1) * pageSize
if start > length {