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
612ff947
authored
Dec 03, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复
parent
2ffbafb0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
29 deletions
app/Http/Services/SkuService.php
app/Http/Services/SkuService.php
View file @
612ff947
...
...
@@ -110,7 +110,7 @@ class SkuService extends BaseService
$sku
[
'goods_label'
]
=
array_get
(
$goodsTag
,
'goods_label'
,
''
);
if
(
$this
->
orgId
==
1
)
{
$sku
[
'goods_label_name'
]
=
array_get
(
config
(
'field.SkuGoodsLabel'
),
$sku
[
'goods_label'
],
''
);
}
else
{
}
else
{
$sku
[
'goods_label_name'
]
=
array_get
(
config
(
'field.SkuGoodsLabelForIedge'
),
$sku
[
'goods_label'
],
''
);
}
$sku
[
'tags'
]
=
array_get
(
$goodsTag
,
'tags'
,
[]);
...
...
@@ -488,34 +488,7 @@ class SkuService extends BaseService
$goodsLabel
=
(
int
)
$goodsLabel
;
//判断是类型1(针对商品)还是类型2(针对供应商)
if
(
$type
==
1
)
{
$redis
=
new
RedisModel
();
$skuIds
=
explode
(
','
,
$skuIds
);
foreach
(
$skuIds
as
$skuId
)
{
$skuId
=
(
int
)
$skuId
;
$skuCache
=
$redis
->
hget
(
'sku'
,
$skuId
);
$skuCache
=
json_decode
(
$skuCache
,
true
);
$skuCache
[
'goods_label'
]
=
$goodsLabel
;
$redis
->
hset
(
'sku'
,
$skuId
,
json_encode
(
$skuCache
));
$dbInfo
=
getSpuSkuDb
(
$skuId
);
$connection
=
DB
::
connection
(
$dbInfo
[
"db"
]);
$table
=
$dbInfo
[
'table'
];
$connection
->
table
(
$table
)
->
where
(
'goods_id'
,
$skuId
)
->
update
([
'goods_label'
=>
$goodsLabel
,
]);
$goodsTag
=
$redis
->
hget
(
'goods_tag'
,
$skuId
);
if
(
$goodsTag
)
{
$goodsTag
=
json_decode
(
$goodsTag
,
true
);
$goodsTag
[
'goods_label'
]
=
$goodsLabel
;
}
else
{
$goodsTag
=
[
'goods_label'
=>
$goodsLabel
,
];
}
$redis
->
hset
(
'goods_tag'
,
$skuId
,
json_encode
(
$goodsTag
));
}
self
::
updateGoodsLabel
(
$skuIds
,
$goodsLabel
);
}
else
{
$data
=
[
'canal'
=>
$supplierCode
,
...
...
@@ -524,4 +497,26 @@ class SkuService extends BaseService
$this
->
batchUpdateSkuInfoQueue
(
$data
);
}
}
public
static
function
updateGoodsLabel
(
$skuIds
,
$goodsLabel
)
{
if
(
!
is_array
(
$skuIds
))
{
$skuIds
=
explode
(
','
,
trim
(
$skuIds
));
}
$conn
=
new
AMQPStreamConnection
(
config
(
'database.connections.rabbitmq2.host'
),
config
(
'database.connections.rabbitmq2.port'
),
config
(
'database.connections.rabbitmq2.login'
),
config
(
'database.connections.rabbitmq2.password'
));
foreach
(
$skuIds
as
$skuId
)
{
$channel
=
$conn
->
channel
();
$channel
->
queue_declare
(
'lie_footstone_update_sku_info_queue'
,
false
,
true
,
false
,
false
);
$msg
=
new
AMQPMessage
(
json_encode
([[
'goods_id'
=>
$skuId
,
'goods_label'
=>
$goodsLabel
,
]]),
array
(
'content_type'
=>
'text/plain'
));
$channel
->
basic_publish
(
$msg
,
''
,
'sku_update'
);
}
}
}
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