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
8a5f2486
authored
Aug 02, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化
parent
41245090
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
23 deletions
app/Http/Services/SupplierSearchTagService.php
app/Http/Services/SupplierService.php
app/Http/Services/SupplierSearchTagService.php
0 → 100644
View file @
8a5f2486
<?php
namespace
App\Http\Services
;
use
App\Model\RedisModel
;
use
App\Model\SupplierChannelModel
;
use
PhpAmqpLib\Connection\AMQPStreamConnection
;
use
PhpAmqpLib\Message\AMQPMessage
;
//这个服务是专门给搜索那边处理数据用的,供应商这边修改了标签以后,如果有变化,会影响对应的所有sku的标签
class
SupplierSearchTagService
{
//保存标签情况(搜索相关,不是系统标签和自定义标签)
//供应商性质为原厂(4)的话,写入标签2;已认证的话,写入标签3
public
function
saveSupplierSearchTags
(
$supplierId
)
{
$supplierModel
=
new
SupplierChannelModel
();
$supplier
=
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
first
()
->
toArray
();
$tagFlags
=
[];
//先去判断供应商性质是否为原厂,如果是的话,写入标签2
if
(
$supplier
[
'supplier_group'
]
==
4
)
{
$tagFlags
[]
=
2
;
}
if
(
$supplier
[
'has_certification'
]
==
1
)
{
$tagFlags
[]
=
3
;
}
$redis
=
new
RedisModel
();
$originTags
=
$redis
->
hget
(
'supplier_search_tags'
,
$supplier
[
'supplier_code'
]);
$tagFlags
=
json_encode
([
'supplier_code'
=>
$supplier
[
'supplier_code'
],
'tags'
=>
$tagFlags
,
]);
$redis
->
hset
(
'supplier_search_tags'
,
$supplier
[
'supplier_code'
],
$tagFlags
);
//判断是否发生变化,有变化才推送
if
(
$originTags
!=
$tagFlags
)
{
//{"supplier_code":"L00055"}
$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
(
json_encode
(
$message
),
array
(
'content_type'
=>
'text/plain'
));
$result
=
$channel
->
basic_publish
(
$msg
,
''
,
'supplier_zhuanmai_update'
);
}
}
}
\ No newline at end of file
app/Http/Services/SupplierService.php
View file @
8a5f2486
...
...
@@ -159,7 +159,8 @@ class SupplierService
//重新生成外部显示的编码
$this
->
generateSupplierSn
(
$supplierId
,
$channel
[
'supplier_group'
]);
//保存和搜索相关的标签情况
$this
->
saveSupplierSearchTags
(
$supplierId
);
$supplierSearchTagService
=
new
SupplierSearchTagService
();
$supplierSearchTagService
->
saveSupplierSearchTags
(
$supplierId
);
return
true
;
});
...
...
@@ -432,25 +433,4 @@ class SupplierService
}
}
//保存标签情况(搜索相关,不是系统标签和自定义标签)
//供应商性质为原厂(4)的话,写入标签2;已认证的话,写入标签3
public
function
saveSupplierSearchTags
(
$supplierId
)
{
$supplierModel
=
new
SupplierChannelModel
();
$supplier
=
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
first
()
->
toArray
();
$tagFlags
=
[];
//先去判断供应商性质是否为原厂,如果是的话,写入标签2
if
(
$supplier
[
'supplier_group'
]
==
4
)
{
$tagFlags
[]
=
2
;
}
if
(
$supplier
[
'has_certification'
]
==
1
)
{
$tagFlags
[]
=
3
;
}
$redis
=
new
RedisModel
();
$redis
->
hset
(
'supplier_search_tags'
,
$supplier
[
'supplier_code'
],
json_encode
([
'supplier_code'
=>
$supplier
[
'supplier_code'
],
'tags'
=>
$tagFlags
,
]));
}
}
\ 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