REAPI/app/queue/command/order/LinSuoKa.php
e022dbff05 feat(queue): 新增临时锁卡任务
- 添加 LinSuoKa 类实现临时锁卡功能
- 优化卡密订单关联逻辑,处理状态为 4 的订单- 新增 redis 记录订单详情,用于限单和退款处理
- 修改 Qiling 类中的签名生成逻辑
- 更新 Test 控制器中的 test_ts 方法,增加对不同订单表的处理
2025-05-06 15:09:26 +08:00

108 lines
3.5 KiB
PHP
Raw 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
namespace app\queue\command\order;
use app\channel\service\ChannelService;
use app\merchant\service\MerchantService;
use app\merchant\service\OrderHistoryService;
use app\merchant\service\OrderLastHistoryService;
use app\merchant\service\OrderLastweekHistoryService;
use app\merchant\service\OrderService;
//use app\order\service\Kami91OrderService;
use app\merchant\service\OrderTwoHistoryService;
use think\admin\Command;
use think\console\Input;
use think\console\Output;
use think\Collection;
use think\facade\Db;
/**
* 临时锁卡
* Class KamiOrderTimeoutRefund
* @package app\data\command
*/
class LinSuoKa extends Command
{
protected function configure()
{
// $this->setName('xQueue:Book');
// $this->setDescription('导入章节内容');
$this->setName('xQueue:LinSuoKa')->setDescription('临时锁卡任务');
}
/**
* @param Input $input
* @param Output $output
* @throws \think\admin\Exception
*/
protected function execute(Input $input, Output $output)
{
ini_set('memory_limit', '1024M');
$channelService = ChannelService::instance();
list($count, $total) = [0, Db::name('test_ts')->whereNotNull('merchant_order_id')->count()];
// $taobao = new \app\openapi\controller\Taobao($this->app);
Db::name('test_ts')->whereNotNull('merchant_order_id')->chunk(100, function (Collection $data) use (&$count, $total, $channelService) {
// var_dump($orderlist);die;
foreach ($data->toArray() as $vo) {
$table = 'merchant_order_lastweek_history';
$order = Db::name($table)->where(['merchant_order_id'=>$vo['merchant_order_id']])->find();
// var_dump($vo);die;
if(!$order){
$table = 'merchant_order';
$order = Db::name($table)->where(['merchant_order_id'=>$vo['merchant_order_id']])->find();
if(!$order){
$table = 'merchant_order_last_history';
$order = Db::name($table)->where(['merchant_order_id'=>$vo['merchant_order_id']])->find();
if(!$order) {
continue;
}
}
}
$suoka = $channelService->call('lockCard', $order['cid'], $order);
// var_dump($suoka);die;
if($suoka !== 'ok' && $suoka !== 'old_ok'){
Db::name('test_ts_suoka_error')->insert(['merchant_order_id'=>$vo['merchant_order_id']]);
Db::name('test_ts')->whereLike('merchant_order_id', $vo['merchant_order_id'])->delete();//这个用like会不会太范了不会因为order是唯一只是怕空格影响
// var_dump($vo);
}else{
//
Db::name($table)->where(['merchant_order_id'=>$vo['merchant_order_id']])->update(['status'=>3]);//
Db::name('test_ts_suoka_yes')->insert(['merchant_order_id'=>$vo['merchant_order_id']]);
Db::name('test_ts')->whereLike('merchant_order_id', $vo['merchant_order_id'])->delete();//这个用like会不会太范了不会因为order是唯一只是怕空格影响
$count++;
$this->setQueueProgress(" {$vo['merchant_order_id']} ", $count / $total * 100);
}
}
});
$this->setQueueSuccess("总计 {$total} 个, 处理成功 {$count} 个错误订单退款!");
}
#上周
}