mirror of
https://gitee.com/ShopeX/OMS
synced 2026-04-27 03:05:45 +08:00
1. 【新增】售后单售后原因类型支持搜索
2. 【新增】手工创建订单折扣可输入正数 3. 【优化】盘点申请单确认 4. 【修复】采购退货单模拟出库失败问题 5. 【新增】订单金额客户实付与结算金额 6. 【优化】仓库发货统计报表物料名称显示 7. 【优化】自有仓储虚拟发货逻辑 8. 【修复】基础物料分类管理问题
This commit is contained in:
@@ -55,8 +55,6 @@ class inventorydepth_calculation_basicmaterial {
|
||||
protected $shopFreeze = [];
|
||||
//订单指定仓预占
|
||||
protected $appointBranchFreeze = [];
|
||||
//全局预占
|
||||
protected $globalsFreeze = [];
|
||||
|
||||
// 专用供货仓信息
|
||||
protected $applySupplyBranches = [];
|
||||
@@ -575,7 +573,7 @@ class inventorydepth_calculation_basicmaterial {
|
||||
$this->actualStockMake[$sha1]['公式'] = '库存-仓库预占-指定仓预占';
|
||||
}
|
||||
} else {
|
||||
list($globals_freeze, ) = $this->get_globals_freeze($bm_id, $shop_bn, $shop_id);
|
||||
list($globals_freeze, $globals_freeze_detail) = $this->get_globals_freeze($bm_id, $shop_bn, $shop_id);
|
||||
$globals_freeze = (int) $globals_freeze;
|
||||
if($safe) {
|
||||
$actual_stock = $safeActual - $globals_freeze;
|
||||
@@ -585,6 +583,7 @@ class inventorydepth_calculation_basicmaterial {
|
||||
$this->actualStockMake[$sha1]['公式'] = '库存-全局预占-仓库预占-指定仓预占';
|
||||
}
|
||||
$this->actualStockMake[$sha1]['全局预占'] = $globals_freeze;
|
||||
$this->actualStockMake[$sha1]['全局预占明细'] = $globals_freeze_detail;
|
||||
}
|
||||
$this->actualStockMake[$sha1]['库存'] = $store_sum;
|
||||
$this->actualStockMake[$sha1]['仓库预占'] = $store_freeze_sum;
|
||||
@@ -603,10 +602,6 @@ class inventorydepth_calculation_basicmaterial {
|
||||
return [false, ['error'=>'仓库未绑定店铺']];
|
||||
}
|
||||
|
||||
$sha1Str = $shop_bn.'-'.$bm_id;
|
||||
$sha1 = sha1($sha1Str);
|
||||
if(isset($this->globalsFreeze[$sha1])) return [$this->globalsFreeze[$sha1], []];
|
||||
|
||||
# 获取这些仓所对应的所有店铺
|
||||
$shopListKey = sha1($shop_bn . '-' . json_encode($branches));
|
||||
if (!isset($this->shopList[$shopListKey])) {
|
||||
@@ -623,13 +618,24 @@ class inventorydepth_calculation_basicmaterial {
|
||||
}
|
||||
# 根据订单计算店铺预占(未发货订单) 该店铺下的商品ID
|
||||
$globals_freeze = 0;
|
||||
$shop_freeze_detail = [];
|
||||
foreach ($this->shopList[$shopListKey] as $key=>$value) {
|
||||
list($tmpNum, )= $this->get_shop_freeze($bm_id, $value['shop_bn'], $value['shop_id']);
|
||||
$globals_freeze += $tmpNum;
|
||||
$shop_freeze_detail[$value['shop_bn']] = [
|
||||
'shop_id' => $value['shop_id'],
|
||||
'freeze' => $tmpNum
|
||||
];
|
||||
}
|
||||
$this->globalsFreeze[$sha1] = $globals_freeze > 0 ? (int)$globals_freeze : 0;
|
||||
$globals_freeze = $globals_freeze > 0 ? (int)$globals_freeze : 0;
|
||||
|
||||
return [$this->globalsFreeze[$sha1], []];
|
||||
$detail = [
|
||||
'shop_branches' => $shop_branches,
|
||||
'branches' => $branches,
|
||||
'shop_freeze_detail' => $shop_freeze_detail
|
||||
];
|
||||
|
||||
return [$globals_freeze, $detail];
|
||||
}
|
||||
//获取订单店铺预占
|
||||
public function get_shop_freeze($bm_id, $shop_bn, $shop_id) {
|
||||
|
||||
@@ -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]];
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行公式
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user