Commit 71d25a23 by mushishixian

推送任务方法

parent bc7d0c37
Showing with 29 additions and 1 deletions
...@@ -16,6 +16,8 @@ use GuzzleHttp\RequestOptions; ...@@ -16,6 +16,8 @@ use GuzzleHttp\RequestOptions;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
//这个服务是处理数据的,比如导出信息,或者临时修复数据,所以代码会比较多 //这个服务是处理数据的,比如导出信息,或者临时修复数据,所以代码会比较多
class DataService class DataService
...@@ -201,7 +203,7 @@ class DataService ...@@ -201,7 +203,7 @@ class DataService
'status' => $supplierModel::STATUS_BLOCK, 'status' => $supplierModel::STATUS_BLOCK,
'is_type' => 0, 'is_type' => 0,
'create_name' => 'admin', 'create_name' => 'admin',
'block_reason'=> '系统拉黑', 'block_reason' => '系统拉黑',
]; ];
$supplierId = $supplierModel->insertGetId($insertData); $supplierId = $supplierModel->insertGetId($insertData);
$supplierService = new SupplierService(); $supplierService = new SupplierService();
...@@ -260,6 +262,32 @@ class DataService ...@@ -260,6 +262,32 @@ class DataService
} }
} }
//推送更新供应商的队列
public function pushSupplierSKu()
{
$supplierModel = new SupplierChannelModel();
$suppliers = $supplierModel->where('is_type', 0)->limit(10)->get()->toArray();
$redis = new RedisModel();
foreach ($suppliers as $supplier) {
$supplierTag = $redis->hget('supplier_search_tags', $supplier['supplier_code']);
if (!$supplierTag) {
continue;
}
$message = json_encode([
'supplier_code' => $supplier['supplier_code'],
]);
$conn = new AMQPStreamConnection(config('database.connections.rabbitmq.host'),
config('database.connections.rabbitmq.port'),
config('database.connections.rabbitmq.login'),
config('database.connections.rabbitmq.password'));
$channel = $conn->channel();
$channel->queue_declare('supplier_zhuanmai_update', false, true, false, false);
$msg = new AMQPMessage($message,
array('content_type' => 'text/plain'));
$result = $channel->basic_publish($msg, '', 'supplier_zhuanmai_update');
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment