REAPI/app/queue/command/kami91order/KamiOrderTimeoutRefund.php
mzeros b8c34de8c8 refactor(merchant): 优化账户数据处理和订单逻辑
- 添加 endsWithDoubleZero 函数,用于处理数值字符串末尾的两个零
- 修改 Core.php 中的 queue 方法,增加对卡库提单的特殊处理逻辑
-调整 Feedov.php 中的订单查询和充值逻辑,提高系统稳定性
- 优化数据库配置,连接测试数据库以确保数据安全
2025-02-15 19:00:17 +08:00

68 lines
1.8 KiB
PHP

<?php
namespace app\queue\command\kami91order;
use app\merchant\service\OrderService;
//use app\order\service\Kami91OrderService;
use think\admin\Command;
use think\console\Input;
use think\console\Output;
use think\Collection;
/**
* 超时订单退款
* Class KamiOrderTimeoutRefund
* @package app\data\command
*/
class KamiOrderTimeoutRefund extends Command
{
protected function configure()
{
// $this->setName('xQueue:Book');
// $this->setDescription('导入章节内容');
$this->setName('xQueue:KamiOrderTimeoutRefund')->setDescription('[ 卡密列表 - 自动同步 ] 超时订单退款');
}
/**
* @param Input $input
* @param Output $output
* @throws \think\admin\Exception
*/
protected function execute(Input $input, Output $output)
{
ini_set('memory_limit', '1024M');
$orderService = OrderService::instance();
$cur = time();
$time = 60 * 3;
$whereRaw = $cur . '-unix_timestamp(create_at) >=' . $time;
list($count, $total) = [0, $orderService->db()->whereRaw('status = 1 and ' . $whereRaw)->count()];
$orderService->db()->whereRaw('status = 1 and ' . $whereRaw)->chunk(100, function (Collection $data) use (&$count, $total, $orderService) {
// var_dump($orderlist);die;
foreach ($data->toArray() as $vo) {
if ($vo['request'] && $vo['status'] == 1) {
$count++;
$vo['request'] = json_decode($vo['request'], true);
\app\order\service\OrderService::instance()->setCallback(1, $vo['order_id'], 3);
}
$this->setQueueProgress("超时订单退款 {$vo['order_id']} ", $count / $total * 100);
}
});
$this->setQueueSuccess("完成 {$count} 个超时订单退款!");
}
}