
- 添加 LinSuoKa 类实现临时锁卡功能 - 优化卡密订单关联逻辑,处理状态为 4 的订单- 新增 redis 记录订单详情,用于限单和退款处理 - 修改 Qiling 类中的签名生成逻辑 - 更新 Test 控制器中的 test_ts 方法,增加对不同订单表的处理
136 lines
6.2 KiB
PHP
136 lines
6.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 = 300;
|
|
$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']);
|
|
$response = $vo['response']??[];
|
|
if(isset($response)){
|
|
$response = json_decode($response,true);
|
|
if(!is_array($response)){
|
|
$response = [];
|
|
}
|
|
}
|
|
|
|
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,'channel_callback_at'=>date('Y-m-d H:i:s'),'channel_callback_msg'=>json_encode(['is_auto'=>1,'msg'=>'自动化处理,已锁卡'])]);
|
|
|
|
$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,'channel_callback_at'=>date('Y-m-d H:i:s'),'channel_callback_msg'=>json_encode(['is_auto'=>1,'msg'=>'自动化处理,锁卡失败'])]);
|
|
|
|
$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,'channel_callback_at'=>date('Y-m-d H:i:s'),'channel_callback_msg'=>json_encode(['is_auto'=>1,'msg'=>'自动化处理,无卡密信息,无法确定资损,成功处理'])]);
|
|
|
|
$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,'channel_callback_at'=>date('Y-m-d H:i:s'),'channel_callback_msg'=>json_encode(['is_auto'=>1,'msg'=>'自动化处理,已锁卡'])]);
|
|
|
|
$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,'channel_callback_at'=>date('Y-m-d H:i:s'),'channel_callback_msg'=>json_encode(['is_auto'=>1,'msg'=>'自动化处理,锁卡失败'])]);
|
|
|
|
$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,'channel_callback_at'=>date('Y-m-d H:i:s'),'channel_callback_msg'=>json_encode(['is_auto'=>1,'msg'=>'自动化处理,无卡密信息,无法确定资损,成功处理'])]);
|
|
|
|
$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,'channel_callback_at'=>date('Y-m-d H:i:s'),'channel_callback_msg'=>json_encode(['is_auto'=>1,'msg'=>'自动化处理,渠道不支持锁卡,成功处理'])]);
|
|
|
|
$this->setQueueProgress("订单 {$vo['order_id']} 渠道不支持锁卡,成功处理", $count / $total * 100);
|
|
}
|
|
|
|
|
|
}
|
|
});
|
|
$this->setQueueSuccess("处理 {$count} 个订单状态完成!");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|