70 lines
2.1 KiB
PHP
70 lines
2.1 KiB
PHP
![]() |
<?php
|
||
|
|
||
|
namespace app\queue\command\kami91order;
|
||
|
|
||
|
|
||
|
use app\merchant\service\OrderService;
|
||
|
use app\order\service\Kami91OrderService;
|
||
|
use think\admin\Command;
|
||
|
use think\console\Input;
|
||
|
use think\console\Output;
|
||
|
use think\Collection;
|
||
|
|
||
|
/**
|
||
|
* 上传章节
|
||
|
* Class Book
|
||
|
* @package app\data\command
|
||
|
*/
|
||
|
class KamiOrderAssociation extends Command
|
||
|
{
|
||
|
protected function configure()
|
||
|
{
|
||
|
// $this->setName('xQueue:Book');
|
||
|
// $this->setDescription('导入章节内容');
|
||
|
$this->setName('xQueue:KamiOrderAssociation')->setDescription('[ 卡密列表 - 自动同步 ] 关联系统订单');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param Input $input
|
||
|
* @param Output $output
|
||
|
* @throws \think\admin\Exception
|
||
|
*/
|
||
|
protected function execute(Input $input, Output $output)
|
||
|
{
|
||
|
ini_set('memory_limit', '1024M');
|
||
|
|
||
|
$kami91server = Kami91OrderService::instance();
|
||
|
$where1 = [
|
||
|
'status' => '1' ,
|
||
|
];
|
||
|
$where[] = [
|
||
|
'product_key','like','%cardbuy%'
|
||
|
];
|
||
|
list($count, $total) = [0, $kami91server->db()->where($where)->where($where1)->count()];
|
||
|
|
||
|
// $orderlist = $kami91server->db()->where($where)->where($where1)->order('id asc')->select()->toArray();
|
||
|
|
||
|
$kami91server->db()->where($where)->where($where1)->chunk(100, function (Collection $data) use (&$count, $total) {
|
||
|
// var_dump($orderlist);die;
|
||
|
foreach ($data->toArray() as $vo) {
|
||
|
|
||
|
// $orderService = OrderService::instance();
|
||
|
$order = OrderService::instance()->get('', $vo['merchant_order_id'], $vo['mid']);
|
||
|
|
||
|
if ($order) {
|
||
|
$count++;
|
||
|
$upData = array();
|
||
|
$upData['order_id'] = $order['order_id'];
|
||
|
$upData['status'] = 4;
|
||
|
Kami91OrderService::instance()->db()->where(array('merchant_order_id' => $vo['merchant_order_id']))->update($upData);
|
||
|
$this->setQueueProgress("同步关联订单 {$vo['order_id']} ", $count / $total * 100);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
$this->setQueueSuccess("同步关联 {$count} 个订单完成!");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|