Files
OMS/app/ome/lib/stock/do.php
2025-12-28 23:13:25 +08:00

60 lines
2.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
class ome_stock_do{
function run($branch_id){
$branchObj = app::get('ome')->model('branch');
$branch_pObj = app::get('ome')->model('branch_product');
$branch = $branchObj->dump($branch_id);
$data['branch_id'] = $branch['branch_id'];
$data['time'] = strtotime(date("Ymd", time()));
if ($branch){
$oQueue = app::get('base')->model('queue');
$queueData = array(
'queue_title'=>'计算安全库存',
'start_time'=>time(),
'cursor_id'=>0,
'params'=>array(
'sdfdata'=>$data,
'app' => 'ome',
'mdl' => 'stock_change_log',
),
'worker'=>'ome_stock_to_do.run',
);
$oQueue->save($queueData);
app::get('base')->model('queue')->runtask($queueData['queue_id']);
return true;
}else {
return false;
}
}
function save_stock_safe_info($data){
if(@include(ROOT_DIR.'/config/db_exinfo.php')){
include(ROOT_DIR."/script/db_ex.php");
$db = new db_ex();
$server_name = $_SERVER['SERVER_NAME'];
$branch_id = $data['branch_id'];
$exec_hour = $data['stock_safe_time'];
$worker = "ome_stock_do:run";
if($exec_hour > DEFAULT_TIMEZONE){
$exec_hour = $exec_hour - DEFAULT_TIMEZONE;
}else{
$exec_hour = $exec_hour - DEFAULT_TIMEZONE + 24;
}
if($db->selectrow("SELECT oid FROM cron_stock_safe WHERE server_name='".$server_name."' AND branch_id=".$branch_id)){
$db->exec("UPDATE cron_stock_safe SET exec_hour=".$exec_hour." WHERE server_name='".$server_name."' AND branch_id=".$branch_id);
}else{
$db->exec("INSERT INTO cron_stock_safe(server_name,branch_id,exec_hour,worker) VALUES ('".$server_name."',".$branch_id.",".$exec_hour.",'".$worker."')");
}
}
}
}