更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -8,16 +8,10 @@ import (
|
||||
"server/models"
|
||||
)
|
||||
|
||||
// BackendErpStockController 库存查询、流水追溯与预警
|
||||
//
|
||||
// 结存只能由流水驱动,因此这里全部是只读接口:任何"改库存"的需求都必须
|
||||
// 通过其他出入库/调拨/盘点单据生效来完成。
|
||||
// 查询与算法在 erp_stock_core.go,与移动端 /api/erp/stock* 共用同一份实现。
|
||||
type BackendErpStockController struct {
|
||||
BackendErpBaseController
|
||||
}
|
||||
|
||||
// List GET /backend/erp/stock/list 库存结存(可按商品聚合或按批次展开)
|
||||
func (c *BackendErpStockController) List() {
|
||||
cl, err := c.claims()
|
||||
if c.denied(err) {
|
||||
@@ -46,7 +40,6 @@ func (c *BackendErpStockController) List() {
|
||||
})
|
||||
}
|
||||
|
||||
// Ledger GET /backend/erp/stock/ledger 库存流水(收发存明细追溯)
|
||||
func (c *BackendErpStockController) Ledger() {
|
||||
cl, err := c.claims()
|
||||
if c.denied(err) {
|
||||
@@ -71,7 +64,6 @@ func (c *BackendErpStockController) Ledger() {
|
||||
c.listOK(rows, total, page, pageSize)
|
||||
}
|
||||
|
||||
// Warning GET /backend/erp/stock/warning 库存预警:低于安全库存 / 超储 / 零库存 / 效期临近
|
||||
func (c *BackendErpStockController) Warning() {
|
||||
cl, err := c.claims()
|
||||
if c.denied(err) {
|
||||
@@ -85,7 +77,6 @@ func (c *BackendErpStockController) Warning() {
|
||||
c.ok(data)
|
||||
}
|
||||
|
||||
// Replenish GET /backend/erp/stock/replenish 智能补货建议(按供应商分组,可一键生成采购订单)
|
||||
func (c *BackendErpStockController) Replenish() {
|
||||
cl, err := c.claims()
|
||||
if c.denied(err) {
|
||||
@@ -99,8 +90,6 @@ func (c *BackendErpStockController) Replenish() {
|
||||
c.ok(map[string]interface{}{"list": rows, "total": len(rows)})
|
||||
}
|
||||
|
||||
// Batch GET /backend/erp/stock/batch 批次与效期台账
|
||||
// 支持 warehouse_id / product_id / keyword / expire_state(expired|expiring|normal) 过滤。
|
||||
func (c *BackendErpStockController) Batch() {
|
||||
cl, err := c.claims()
|
||||
if c.denied(err) {
|
||||
@@ -123,7 +112,6 @@ func (c *BackendErpStockController) Batch() {
|
||||
c.listOK(list, total, page, pageSize)
|
||||
}
|
||||
|
||||
// erpBatchRow 批次台账行;未登记效期时 expire_in_days 为 null
|
||||
type erpBatchRow struct {
|
||||
ProductID uint64 `json:"product_id"`
|
||||
ProductCode string `json:"product_code"`
|
||||
@@ -141,7 +129,6 @@ type erpBatchRow struct {
|
||||
Expired bool `json:"expired"`
|
||||
}
|
||||
|
||||
// erpStockRow 库存结存行(列表按仓库+批次展开,或按商品聚合)
|
||||
type erpStockRow struct {
|
||||
ProductID uint64 `json:"product_id"`
|
||||
ProductCode string `json:"product_code"`
|
||||
@@ -160,7 +147,6 @@ type erpStockRow struct {
|
||||
SafetyState string `json:"safety_state"`
|
||||
}
|
||||
|
||||
// erpWarnRow 预警行:低库存/积压/缺货/效期共用一套字段
|
||||
type erpWarnRow struct {
|
||||
ProductID uint64 `json:"product_id"`
|
||||
ProductCode string `json:"product_code"`
|
||||
@@ -181,7 +167,6 @@ type erpWarnRow struct {
|
||||
ExpireInDays int `json:"expire_in_days"`
|
||||
}
|
||||
|
||||
// erpReplenishRow 补货建议行
|
||||
type erpReplenishRow struct {
|
||||
ProductID uint64 `json:"product_id"`
|
||||
ProductCode string `json:"product_code"`
|
||||
@@ -197,8 +182,6 @@ type erpReplenishRow struct {
|
||||
Amount float64 `json:"amount"`
|
||||
}
|
||||
|
||||
// ---- 内部 ----
|
||||
|
||||
func erpStockProductIDs(rows []models.ErpStock) []uint64 {
|
||||
seen := map[uint64]bool{}
|
||||
out := make([]uint64, 0, len(rows))
|
||||
@@ -223,7 +206,6 @@ func erpLedgerProductIDs(rows []models.ErpStockLedger) []uint64 {
|
||||
return out
|
||||
}
|
||||
|
||||
// erpPurchaseInTransit 已生效采购订单的未执行数量(按商品汇总)
|
||||
func erpPurchaseInTransit(tid string) map[uint64]float64 {
|
||||
out := map[uint64]float64{}
|
||||
var docs []models.ErpDocument
|
||||
@@ -251,7 +233,6 @@ func erpPurchaseInTransit(tid string) map[uint64]float64 {
|
||||
return out
|
||||
}
|
||||
|
||||
// erpSoldQty 近 n 天销售出库数量(按商品汇总)
|
||||
func erpSoldQty(tid string, days int) map[uint64]float64 {
|
||||
out := map[uint64]float64{}
|
||||
var rows []models.ErpStockLedger
|
||||
@@ -267,21 +248,15 @@ func erpSoldQty(tid string, days int) map[uint64]float64 {
|
||||
return out
|
||||
}
|
||||
|
||||
// erpBatchKey 批次主键:效期属于批次,不随所在仓库变化
|
||||
func erpBatchKey(productID uint64, batch string) string {
|
||||
return strconv.FormatUint(productID, 10) + "|" + batch
|
||||
}
|
||||
|
||||
// erpToday 本地零点,用于按日历日计算剩余天数
|
||||
func erpToday() time.Time {
|
||||
n := time.Now()
|
||||
return time.Date(n.Year(), n.Month(), n.Day(), 0, 0, 0, 0, time.Local)
|
||||
}
|
||||
|
||||
// erpBatchExpiry 批次到期日表(key = erpBatchKey)。
|
||||
//
|
||||
// 优先取该批次入库流水登记的最早到期日;没登记但商品配了保质期的,
|
||||
// 按该批次最早入库日推算,这样老数据与手工开单也能纳入效期管控。
|
||||
func erpBatchExpiry(tid string, productIDs []uint64, pmap map[uint64]models.ErpProduct) map[string]time.Time {
|
||||
out := map[string]time.Time{}
|
||||
if len(productIDs) == 0 {
|
||||
@@ -324,7 +299,6 @@ func erpBatchExpiry(tid string, productIDs []uint64, pmap map[uint64]models.ErpP
|
||||
return out
|
||||
}
|
||||
|
||||
// erpExpiringBatches 近 withinDays 天内到期(或已过期)且仍有库存的批次
|
||||
func erpExpiringBatches(tid string, withinDays int) []erpWarnRow {
|
||||
var stocks []models.ErpStock
|
||||
_, _ = models.Orm.QueryTable(new(models.ErpStock)).
|
||||
|
||||
Reference in new issue
Block a user