Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
doc
/
ht_project_doc
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 45c442d3
authored
Sep 11, 2026
by
chenxi
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交改动内容
1 parent
70308311
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
27_v5.8.6_20260921/sql/DML/dj_smartcarlife_dml.sql
27_v5.8.6_20260921/sql/DML/dj_smartcarlife_dml.sql
0 → 100644
View file @
45c442d
UPDATE
dj_car_life_upgrade_goods
ug
SET
ug
.
status
=
IF
(
EXISTS
(
SELECT
1
FROM
dj_car_life_merchant_goods_info
mgi
WHERE
mgi
.
upgrade_goods_id
=
ug
.
id
AND
mgi
.
deleted_flag
=
'N'
AND
mgi
.
status
=
1
)
OR
EXISTS
(
SELECT
1
FROM
dj_car_life_purchase_goods_info
pgi
WHERE
pgi
.
upgrade_goods_id
=
ug
.
id
AND
pgi
.
deleted_flag
=
'N'
AND
pgi
.
status
=
1
),
1
,
0
),
ug
.
updated_by
=
'260920版本刷数据'
,
ug
.
updated_date
=
NOW
()
WHERE
ug
.
deleted_flag
=
'N'
AND
ug
.
status
IN
(
0
,
1
)
AND
ug
.
status
<>
IF
(
EXISTS
(
SELECT
1
FROM
dj_car_life_merchant_goods_info
mgi
WHERE
mgi
.
upgrade_goods_id
=
ug
.
id
AND
mgi
.
deleted_flag
=
'N'
AND
mgi
.
status
=
1
)
OR
EXISTS
(
SELECT
1
FROM
dj_car_life_purchase_goods_info
pgi
WHERE
pgi
.
upgrade_goods_id
=
ug
.
id
AND
pgi
.
deleted_flag
=
'N'
AND
pgi
.
status
=
1
),
1
,
0
);
-- ② 产品级:按聚合口径(上架SKU数=0→0;=总数→1;否则→2)重算,仅更新与当前值不同的行
-- 口径与 countStatusCount 一致:统计该产品下所有未删除 SKU(含草稿态)
UPDATE
dj_car_life_base_goods
bg
JOIN
(
SELECT
bg2
.
id
,
SUM
(
ug
.
status
=
1
)
AS
on_shelf_cnt
,
COUNT
(
ug
.
id
)
AS
total_cnt
FROM
dj_car_life_base_goods
bg2
JOIN
dj_car_life_upgrade_goods
ug
ON
ug
.
base_goods_id
=
bg2
.
id
AND
ug
.
deleted_flag
=
'N'
WHERE
bg2
.
deleted_flag
=
'N'
GROUP
BY
bg2
.
id
)
t
ON
t
.
id
=
bg
.
id
SET
bg
.
status
=
CASE
WHEN
t
.
on_shelf_cnt
=
0
THEN
0
WHEN
t
.
on_shelf_cnt
=
t
.
total_cnt
THEN
1
ELSE
2
END
,
bg
.
updated_by
=
'260920版本刷数据'
,
bg
.
updated_date
=
NOW
()
WHERE
bg
.
status
<>
CASE
WHEN
t
.
on_shelf_cnt
=
0
THEN
0
WHEN
t
.
on_shelf_cnt
=
t
.
total_cnt
THEN
1
ELSE
2
END
;
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment