Commit 32cbf26b by mushishixian

fix

parent 95decd27
......@@ -75,6 +75,12 @@ RABBITMQ_LOGIN=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_QUEUE=wms_service
#RABBITMQ_HOST=192.168.1.237
#RABBITMQ_PORT=5672
#RABBITMQ_VHOST=/
#RABBITMQ_LOGIN=huntadmin
#RABBITMQ_PASSWORD=jy2y2900
ES_SKU_URL=http://soso12.ichunt.com/search/Es/searchSku
MAIL_DRIVER=smtp
......
......@@ -14,6 +14,8 @@ use App\Model\SupplierChannelModel;
use App\Model\SupplierLogModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
//通用API,比如获取品牌列表,分类列表等
class SupplierAccountApiController extends Controller
......@@ -58,6 +60,8 @@ class SupplierAccountApiController extends Controller
//还要插入一个redis
$redis = new RedisModel();
$redis->hset('yunxin_api_user_mobile', $data['mobile'], $id);
$accountService = new SupplierAccountService();
$accountService->pushToInitData($data['supplier_code']);
$this->response(0, '添加成功');
}
$this->response(-1, '添加失败');
......@@ -91,6 +95,8 @@ class SupplierAccountApiController extends Controller
//还要插入一个redis
$redis = new RedisModel();
$redis->hset('yunxin_api_user_mobile', $data['mobile'], $data['id']);
$accountService = new SupplierAccountService();
$accountService->pushToInitData($data['supplier_code']);
$this->response(0, '修改成功');
}
$this->response(-1, '修改失败', $result);
......
......@@ -9,6 +9,9 @@ use App\Http\Transformers\SupplierAccountTransformer;
use App\Model\LogModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use Carbon\Carbon;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;
class SupplierAccountService
{
......@@ -22,4 +25,27 @@ class SupplierAccountService
$list['data'] = $transformer->transformList($list['data']);
return $list;
}
//推送队列告诉搜索要去初始化数据
public function pushToInitData($supplierCode)
{
//还要去推送给搜索做品牌初始化任务
$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('yunxin_supplier_add', false, true, false, false);
$time = strtotime("2021-01-01 00:00:00");
$body = json_encode([
'canal' => $supplierCode,
'update_time' => $time
]);
$msg = new AMQPMessage($body,
['content_type' => 'text/plain', 'delivery_mode' => AMQPMessage::DELIVERY_MODE_PERSISTENT]);
$result = $channel->basic_publish($msg, '', 'yunxin_supplier_add');
dd($body);
$channel->close();
$conn->close();
}
}
\ No newline at end of file
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