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

133 lines
5.0 KiB
PHP

<?php
namespace app\queue\command\kami91order;
use app\channel\service\ChannelService;
use app\kami\service\LockCardService;
use app\merchant\service\OrderService;
use think\admin\Command;
use think\console\Input;
use think\console\Output;
use think\Collection;
/**
* 强行更新订单状态
* Class KamiOrderStatusSync
* @package app\data\command
*/
class KamiOrderStatusForceUpdate extends Command
{
protected function configure()
{
// $this->setName('xQueue:Book');
// $this->setDescription('导入章节内容');
$this->setName('xQueue:KamiOrderStatusForceUpdate')->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();
// $where1 = [
// 'status' => 7
// ];
$where[] = [
'product_key', 'like', '%cardbuy%'
];
$cur = time();
$time = 600;
$whereRaw = $cur . '-unix_timestamp(create_at) >=' . $time;
$channelService = ChannelService::instance();
list($count, $total) = [0, $orderService->db()->where($where)->whereRaw('status = 7 and ' . $whereRaw)->count()];
$LockCardService = LockCardService::instance();
$orderService->db()->where($where)->whereRaw('status = 7 and ' . $whereRaw)->chunk(10, function (Collection $data) use (&$count, $total, $orderService,$channelService,$LockCardService) {
// var_dump($orderlist);die;
foreach ($data->toArray() as $vo) {
$count++;
$channelInfo = $channelService->get($vo['cid']);
if($channelInfo['suoka_status'] == 1){
if (isset($response['kami'])) {
$suoka = $channelService->call('lockCard', $vo['cid'], $vo);
if($suoka == 'ok' || $suoka == 'old_ok'){
$orderService->db()->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>3,'merchant_callback_error'=>2]);
$this->setQueueProgress("订单 {$vo['order_id']} 已经锁卡并退款处理", $count / $total * 100);
}else{
$orderService->db()->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>2,'merchant_callback_error'=>2]);
$this->setQueueProgress("订单 {$vo['order_id']} 无法锁卡,成功处理", $count / $total * 100);
}
}else{
$orderService->db()->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>2,'merchant_callback_error'=>2]);
$this->setQueueProgress("订单 {$vo['order_id']} 无法锁卡,成功处理", $count / $total * 100);
}
}elseif($channelInfo['suoka_status'] == 2){
if (isset($response['kami'])) {
$cardno = $response['kami']['cardno'];
$cardpwd = $response['kami']['cardpwd'];
$expire_time = $response['kami']['expired'];
$suoka = $LockCardService->call('suoka', $vo['cid'],$cardno,$cardpwd,$vo['pid'],$vo['cash']);
if($suoka == 'ok' || $suoka == 'old_ok'){
//
$orderService->db()->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>3,'merchant_callback_error'=>2]);
$this->setQueueProgress("订单 {$vo['order_id']} 已经锁卡并退款处理", $count / $total * 100);
}else{
$orderService->db()->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>2,'merchant_callback_error'=>2]);
$this->setQueueProgress("订单 {$vo['order_id']} 无法锁卡,成功处理", $count / $total * 100);
}
}else{
$orderService->db()->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>2,'merchant_callback_error'=>2]);
$this->setQueueProgress("订单 {$vo['order_id']} 无法锁卡,成功处理", $count / $total * 100);
}
} else{
$orderService->db()->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>2,'merchant_callback_error'=>2]);
$this->setQueueProgress("订单 {$vo['order_id']} 无法锁卡,成功处理", $count / $total * 100);
}
// $orderService = OrderService::instance();
// $order = OrderService::instance()->get('', $vo['merchant_order_id'], $vo['mid']);
}
});
$this->setQueueSuccess("处理 {$count} 个订单状态完成!");
}
}