1. 【新增】售后单售后原因类型支持搜索

2. 【新增】手工创建订单折扣可输入正数

3. 【优化】盘点申请单确认

4. 【修复】采购退货单模拟出库失败问题

5. 【新增】订单金额客户实付与结算金额

6. 【优化】仓库发货统计报表物料名称显示

7. 【优化】自有仓储虚拟发货逻辑

8. 【修复】基础物料分类管理问题
This commit is contained in:
chenping
2026-04-01 11:59:17 +08:00
parent 9341122827
commit 61783b7d01
754 changed files with 46179 additions and 5700 deletions

View File

@@ -27,10 +27,12 @@ class inventorydepth_calculation_salesmaterial {
protected $obj;
protected $isInit = false;
protected $releaseStock = [];
protected $shopFreeze = []; // 缓存店铺冻结数据key为 sha1(shop_id.'-'.sm_id)
public function init($salesmaterial) {
$this->isInit = true;
$this->releaseStock = [];
$this->shopFreeze = [];
$smBn = [];
foreach ($salesmaterial as $key => $value) {
$smBn[] = $value['sales_material_bn'];
@@ -42,6 +44,30 @@ class inventorydepth_calculation_salesmaterial {
$this->releaseStock[$tmpsha1] = (int)$l['release_stock'];
}
}
// 批量查询冻结数据
$smIds = [];
foreach ($salesmaterial as $key => $value) {
$smIds[] = $value['sm_id'];
}
if (!empty($smIds)) {
$smIds = array_unique($smIds);
$orderObjectsFreezeModel = app::get('ome')->model('order_objects_freeze');
$freezeList = $orderObjectsFreezeModel->getList('sm_id,shop_id,quantity', [
'sm_id|in' => $smIds
]);
// 按 sm_id 和 shop_id 汇总
foreach ($freezeList as $freeze) {
$key = sha1($freeze['shop_id'].'-'.$freeze['sm_id']);
if (!isset($this->shopFreeze[$key])) {
$this->shopFreeze[$key] = 0;
}
$this->shopFreeze[$key] += (int)$freeze['quantity'];
}
}
}
public function get_release_stock($sku)
@@ -76,6 +102,54 @@ class inventorydepth_calculation_salesmaterial {
return [$this->releaseStock[$sha1], []];
}
/**
* 获取销售物料店铺冻结数量
* @param array $sku 包含 shop_product_bn, shop_id, shop_bn
* @return array [冻结数量, 详细信息]
*/
public function get_sales_material_shop_freeze($sku)
{
$shop_product_bn = $sku['shop_product_bn'];
$shop_id = $sku['shop_id'];
// 获取销售物料信息
$basicObj = kernel::single('inventorydepth_calculation_basicmaterial');
$salesMaterial = $basicObj->getSalesMaterial($shop_product_bn, $shop_id);
if (empty($salesMaterial)) {
return [0, ['warning' => '未找到销售物料']];
}
$sm_id = $salesMaterial['sm_id'];
$key = sha1($shop_id.'-'.$sm_id);
if (isset($this->shopFreeze[$key])) {
return [$this->shopFreeze[$key], ['info' => '销售物料店铺冻结', 'quantity' => $this->shopFreeze[$key]]];
}
if ($this->isInit) {
return [0, ['warning' => '初始化未查到']];
}
// 如果未初始化,则查询数据库
$orderObjectsFreezeModel = app::get('ome')->model('order_objects_freeze');
$freezeList = $orderObjectsFreezeModel->getList('quantity', [
'sm_id' => $sm_id,
'shop_id' => $shop_id
]);
$totalFreeze = 0;
foreach ($freezeList as $freeze) {
$totalFreeze += (int)$freeze['quantity'];
}
$freezeQuantity = (int)$totalFreeze;
$this->shopFreeze[$key] = $freezeQuantity;
return [$freezeQuantity, ['info' => '销售物料店铺冻结', 'quantity' => $freezeQuantity]];
}
/**
* 运行公式
*