client create
This commit is contained in:
parent
e59a4ce3e2
commit
3968794197
|
|
@ -4,16 +4,18 @@ require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
require_once __DIR__ . '/../support/bootstrap.php';
|
require_once __DIR__ . '/../support/bootstrap.php';
|
||||||
|
|
||||||
use ba\Random;
|
use ba\Random;
|
||||||
|
use extend\workermans\model\Base;
|
||||||
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
||||||
|
use support\Redis;
|
||||||
use support\think\Db;
|
use support\think\Db;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
|
use GatewayClient\Gateway;
|
||||||
|
|
||||||
$host = config('cons.mq.host');
|
$host = config('cons.mq.host');
|
||||||
$port = config('cons.mq.port');
|
$port = config('cons.mq.port');
|
||||||
$user = config('cons.mq.user');
|
$user = config('cons.mq.user');
|
||||||
$password = config('cons.mq.password');
|
$password = config('cons.mq.password');
|
||||||
$queue = config('cons.mq.queue_t') . '-order.print.queue';
|
$queue = config('cons.mq.queue_t') . '-order.print.queue';
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// define('AMQP_DEBUG', true);
|
// define('AMQP_DEBUG', true);
|
||||||
|
|
@ -71,18 +73,34 @@ try {
|
||||||
'data' => $data
|
'data' => $data
|
||||||
];
|
];
|
||||||
$snd_data_json = json_encode($snd_data);
|
$snd_data_json = json_encode($snd_data);
|
||||||
// 内部给收银机推送打订单
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
||||||
$url = 'http://127.0.0.1:8686/?method=sendToUid&account='. $send_id .'¶ms=' . $snd_data_json; // 替换为你的服务地址和端口
|
$res = Gateway::sendToUid($send_id, $snd_data_json);
|
||||||
$ch = curl_init();
|
Log::info('订单打印推送结果-->' . $res);
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
$result = Redis::get($snd_data['send_id']);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
if($result) {
|
||||||
$output = curl_exec($ch);
|
$msg_id_arr = json_decode($result, true);
|
||||||
if (curl_errno($ch)) {
|
$msg_id_arr_c = count($msg_id_arr);
|
||||||
$is_log = true;
|
$msg_id_arr[$msg_id_arr_c] = $snd_data;
|
||||||
$curl_error = 'Curl error: ' . curl_error($ch);
|
$result_n = json_encode($msg_id_arr);
|
||||||
|
Base::setredis_new($result_n, $snd_data['send_id']);
|
||||||
|
}else {
|
||||||
|
$params_arr_n[] = $snd_data;
|
||||||
|
print_r('数组-------->' . json_encode($params_arr_n)) . "\r\n";
|
||||||
|
Base::setredis_new(json_encode($params_arr_n), $snd_data['send_id']);
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
//
|
||||||
Log::info('内部通讯结果(订单打印)--->' . $output . '通讯ID--->cashier_' .$order['shop_id']. '---' . date('Y-m-d H:i:s') . "\n");
|
// 内部给收银机推送打订单
|
||||||
|
// $url = 'http://127.0.0.1:8686/?method=sendToUid&account='. $send_id .'¶ms=' . $snd_data_json; // 替换为你的服务地址和端口
|
||||||
|
// $ch = curl_init();
|
||||||
|
// curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
// $output = curl_exec($ch);
|
||||||
|
// if (curl_errno($ch)) {
|
||||||
|
// $is_log = true;
|
||||||
|
// $curl_error = 'Curl error: ' . curl_error($ch);
|
||||||
|
// }
|
||||||
|
// curl_close($ch);
|
||||||
|
// Log::info('内部通讯结果(订单打印)--->' . $output . '通讯ID--->cashier_' .$order['shop_id']. '---' . date('Y-m-d H:i:s') . "\n");
|
||||||
}else {
|
}else {
|
||||||
$curl_error = 'order Data is empty';
|
$curl_error = 'order Data is empty';
|
||||||
$is_log = true;
|
$is_log = true;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ use ba\Random;
|
||||||
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
||||||
use support\think\Db;
|
use support\think\Db;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
|
use GatewayClient\Gateway;
|
||||||
|
use support\Redis;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// define('AMQP_DEBUG', true);
|
// define('AMQP_DEBUG', true);
|
||||||
|
|
@ -55,17 +57,35 @@ use support\Log;
|
||||||
'data' => $data
|
'data' => $data
|
||||||
];
|
];
|
||||||
$snd_data_json = json_encode($snd_data);
|
$snd_data_json = json_encode($snd_data);
|
||||||
$url = 'http://127.0.0.1:8686/?method=' . $method . '&account='. $send_id .'¶ms=' . $snd_data_json; // 替换为你的服务地址和端口
|
Gateway::$registerAddress = '127.0.0.1:1238';
|
||||||
$ch = curl_init();
|
$res = Gateway::sendToGroup($send_id, $snd_data_json);
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
Log::info('商品更新推送结果-->' . $res);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
$result = Redis::get($snd_data['send_id']);
|
||||||
$output = curl_exec($ch);
|
if($result) {
|
||||||
if (curl_errno($ch)) {
|
$msg_id_arr = json_decode($result, true);
|
||||||
$is_log = true;
|
$msg_id_arr_c = count($msg_id_arr);
|
||||||
$curl_error = 'Curl error: ' . curl_error($ch);
|
$msg_id_arr[$msg_id_arr_c] = $snd_data;
|
||||||
|
$result_n = json_encode($msg_id_arr);
|
||||||
|
\extend\workermans\model\Base::setredis_new($result_n, $snd_data['send_id']);
|
||||||
|
}else {
|
||||||
|
$params_arr_n[] = $snd_data;
|
||||||
|
print_r('数组-------->' . json_encode($params_arr_n)) . "\r\n";
|
||||||
|
\extend\workermans\model\Base::setredis_new(json_encode($params_arr_n), $snd_data['send_id']);
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
|
||||||
Log::info('内部通讯结果(商品更新)--->' . $output . '通讯ID--->shop_id-->' .$send_id. '---' . date('Y-m-d H:i:s') . "\n");
|
|
||||||
|
|
||||||
|
// $url = 'http://127.0.0.1:8686/?method=' . $method . '&account='. $send_id .'¶ms=' . $snd_data_json; // 替换为你的服务地址和端口
|
||||||
|
// $ch = curl_init();
|
||||||
|
// curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
// $output = curl_exec($ch);
|
||||||
|
// if (curl_errno($ch)) {
|
||||||
|
// $is_log = true;
|
||||||
|
// $curl_error = 'Curl error: ' . curl_error($ch);
|
||||||
|
// }
|
||||||
|
// curl_close($ch);
|
||||||
|
// Log::info('内部通讯结果(商品更新)--->' . $output . '通讯ID--->shop_id-->' .$send_id. '---' . date('Y-m-d H:i:s') . "\n");
|
||||||
if($is_log) {
|
if($is_log) {
|
||||||
Db::table('tb_mq_log')->insert([
|
Db::table('tb_mq_log')->insert([
|
||||||
'queue' => $queue,
|
'queue' => $queue,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue