137 lines
5.2 KiB
PHP
137 lines
5.2 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, $kami91server->db()->whereRaw('status = 1 and ' . $whereRaw)->count()];
|
|
list($count, $total) = [0, $orderService->db()->where($where)->whereRaw('status = 7 and ' . $whereRaw)->count()];
|
|
|
|
$LockCardService = LockCardService::instance();
|
|
|
|
|
|
// print_r(1);die;
|
|
|
|
// $orderlist = $kami91server->db()->where($where)->where($where1)->order('id asc')->select()->toArray();
|
|
|
|
$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} 个订单状态完成!");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|