Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
32cbf26b
authored
Jun 03, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix
parent
95decd27
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
.env
app/Http/Controllers/Api/SupplierAccountApiController.php
app/Http/Services/SupplierAccountService.php
.env
View file @
32cbf26b
...
@@ -75,6 +75,12 @@ RABBITMQ_LOGIN=guest
...
@@ -75,6 +75,12 @@ RABBITMQ_LOGIN=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_QUEUE=wms_service
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
ES_SKU_URL=http://soso12.ichunt.com/search/Es/searchSku
MAIL_DRIVER=smtp
MAIL_DRIVER=smtp
...
...
app/Http/Controllers/Api/SupplierAccountApiController.php
View file @
32cbf26b
...
@@ -14,6 +14,8 @@ use App\Model\SupplierChannelModel;
...
@@ -14,6 +14,8 @@ use App\Model\SupplierChannelModel;
use
App\Model\SupplierLogModel
;
use
App\Model\SupplierLogModel
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Hash
;
use
Illuminate\Support\Facades\Hash
;
use
PhpAmqpLib\Connection\AMQPStreamConnection
;
use
PhpAmqpLib\Message\AMQPMessage
;
//通用API,比如获取品牌列表,分类列表等
//通用API,比如获取品牌列表,分类列表等
class
SupplierAccountApiController
extends
Controller
class
SupplierAccountApiController
extends
Controller
...
@@ -58,6 +60,8 @@ class SupplierAccountApiController extends Controller
...
@@ -58,6 +60,8 @@ class SupplierAccountApiController extends Controller
//还要插入一个redis
//还要插入一个redis
$redis
=
new
RedisModel
();
$redis
=
new
RedisModel
();
$redis
->
hset
(
'yunxin_api_user_mobile'
,
$data
[
'mobile'
],
$id
);
$redis
->
hset
(
'yunxin_api_user_mobile'
,
$data
[
'mobile'
],
$id
);
$accountService
=
new
SupplierAccountService
();
$accountService
->
pushToInitData
(
$data
[
'supplier_code'
]);
$this
->
response
(
0
,
'添加成功'
);
$this
->
response
(
0
,
'添加成功'
);
}
}
$this
->
response
(
-
1
,
'添加失败'
);
$this
->
response
(
-
1
,
'添加失败'
);
...
@@ -91,6 +95,8 @@ class SupplierAccountApiController extends Controller
...
@@ -91,6 +95,8 @@ class SupplierAccountApiController extends Controller
//还要插入一个redis
//还要插入一个redis
$redis
=
new
RedisModel
();
$redis
=
new
RedisModel
();
$redis
->
hset
(
'yunxin_api_user_mobile'
,
$data
[
'mobile'
],
$data
[
'id'
]);
$redis
->
hset
(
'yunxin_api_user_mobile'
,
$data
[
'mobile'
],
$data
[
'id'
]);
$accountService
=
new
SupplierAccountService
();
$accountService
->
pushToInitData
(
$data
[
'supplier_code'
]);
$this
->
response
(
0
,
'修改成功'
);
$this
->
response
(
0
,
'修改成功'
);
}
}
$this
->
response
(
-
1
,
'修改失败'
,
$result
);
$this
->
response
(
-
1
,
'修改失败'
,
$result
);
...
...
app/Http/Services/SupplierAccountService.php
View file @
32cbf26b
...
@@ -9,6 +9,9 @@ use App\Http\Transformers\SupplierAccountTransformer;
...
@@ -9,6 +9,9 @@ use App\Http\Transformers\SupplierAccountTransformer;
use
App\Model\LogModel
;
use
App\Model\LogModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContactModel
;
use
App\Model\SupplierContactModel
;
use
Carbon\Carbon
;
use
PhpAmqpLib\Connection\AMQPStreamConnection
;
use
PhpAmqpLib\Message\AMQPMessage
;
class
SupplierAccountService
class
SupplierAccountService
{
{
...
@@ -22,4 +25,27 @@ class SupplierAccountService
...
@@ -22,4 +25,27 @@ class SupplierAccountService
$list
[
'data'
]
=
$transformer
->
transformList
(
$list
[
'data'
]);
$list
[
'data'
]
=
$transformer
->
transformList
(
$list
[
'data'
]);
return
$list
;
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment