REAPI/app/queue/command/order/LinSuoKa.php

108 lines
3.5 KiB
PHP
Raw Normal View History

<?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} 个错误订单退款!");
}
#上周
}