Files
OMS/app/ome/lib/misc/task.php
2026-01-04 19:08:31 +08:00

107 lines
4.2 KiB
PHP
Raw Permalink 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 2012-2026 ShopeX (https://www.shopex.cn)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class ome_misc_task{
function week(){
}
function minute(){
//TODO:确认订单自动过期是1小时一次还是1分钟一次
//$time = time();
//定时回写库存每5分钟触发
/*
base_kvstore::instance('setting_ome')->fetch('auto_sync_store',$last_auto_sync_store);
if($last_auto_sync_store){
if($time >= ($last_auto_sync_store + 300)){
//API同步日志每5分钟触发一次以5分钟为基数将所有正在运行中的请求自动发起重试最多3次,超过3次的设置为失败)
//kernel::single('ome_sync_api_log')->auto_retry();
kernel::single('ome_sync_product')->run_stock_sync();
base_kvstore::instance('setting_ome')->store('auto_sync_store',$time);
}
}else{
base_kvstore::instance('setting_ome')->store('auto_sync_store',$time);
}*/
//自动取消订单(9分钟执行一次):目标(将超时订单,且未付款未确认的订单取消,同时向各绑定前端店铺发送同步)
/*
base_kvstore::instance('setting_ome')->fetch('auto_sync_cancel_order',$last_auto_sync_cancel_order);
if($last_auto_sync_cancel_order){
if($time >= ($last_auto_sync_cancel_order + 540)){
kernel::single('ome_sync_order')->cancel_order();
base_kvstore::instance('setting_ome')->store('auto_sync_cancel_order',$time);
}
}else{
base_kvstore::instance('setting_ome')->store('auto_sync_cancel_order',$time);
}
*/
//重新发起漏发的发货请求每5分钟一次
/*
base_kvstore::instance('setting_ome')->fetch('auto_sync_shipment',$last_auto_sync_shipment);
if($last_auto_sync_shipment){
if($time >= ($last_auto_sync_shipment + 60*5)){
kernel::single('ome_sync_order')->retry_shipment();
}
}else{
base_kvstore::instance('setting_ome')->store('auto_sync_shipment',$time);
}
*/
}
function hour(){
////将发起库存同步1小时后还是“同步中”的日志状态改为“失败”
//$db = kernel::database();
//$sql = "UPDATE sdb_ome_api_stock_log SET status='fail' WHERE status='running' AND createtime<".(time()-3600);
//$db->exec($sql);
////将发起发货同步超过30分钟状态还是“发货同步中”的订单改成“失败”
//$sql = "SELECT distinct orderBn, shopId FROM sdb_ome_shipment_log WHERE status = 'send' AND receiveTime < ".(time()-1800);
//$orderlist = $db->select($sql);
//if($orderlist){
//foreach($orderlist as $v){
//$order_arr[$v['shopId']][] = $v['orderBn'];
//}
//$shipmentLogObj = app::get('ome')->model('shipment_log');
//$orderObj = app::get('ome')->model('orders');
//foreach($order_arr as $k => $val){
//$orderObj->update(array('sync'=>'fail'),array('order_bn'=>$val,'shop_id'=>$k,'sync'=>'run'));
//$shipmentLogObj->update(array('status'=>'fail'),array('orderBn'=>$val,'shopId'=>$k,'status'=>'send'));
//}
//}
}
function day(){
//每天检测日志表将超过7天的数据清除放到副表不实际删除
//kernel::single('ome_sync_api_log')->clean();
//将超过2天的防止并发的历史数据清除
//kernel::single('ome_concurrent')->clean();
}
function month(){
}
}