Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
script
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚闰伍
script
Commits
5d430213
Commit
5d430213
authored
Jan 24, 2019
by
蘑菇🍄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SAMO
parent
dbc39f2a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
607 additions
and
0 deletions
+607
-0
合并会员临时表.sql
jnby-samo/合并会员临时表.sql
+38
-0
合并清理.sql
jnby-samo/合并清理.sql
+49
-0
导入指定的会员.sql
jnby-samo/导入指定的会员.sql
+62
-0
数据组装pro.sql
jnby-samo/数据组装pro.sql
+458
-0
No files found.
jnby-samo/合并会员临时表.sql
0 → 100644
View file @
5d430213
-- 会员信息集合
CREATE
TABLE
tab_gic_member_SAMO
LIKE
tab_gic_member_0
;
-- delete from `gic3.0`.tab_gic_member_SAMO ;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_0
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_1
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_2
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_3
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_4
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_5
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_6
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_7
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_8
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_9
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
-- 会员信息集合
CREATE
TABLE
tab_gic_member_clerk_SAMO
LIKE
tab_gic_member_clerk_0
;
-- delete from `gic3.0`.tab_gic_member_clerk_SAMO ;
delete
from
`gic3.0`
.
tab_gic_member_clerk_SAMO
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_0
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_1
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_2
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_3
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_4
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_5
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_6
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_7
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_8
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
insert
into
`gic3.0`
.
tab_gic_member_clerk_SAMO
select
*
from
`gic3.0`
.
tab_gic_member_clerk_9
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
jnby-samo/合并清理.sql
0 → 100644
View file @
5d430213
-- 清除全部导入的数据
DELETE
A
FROM
tab_gic_mall_order_refund_consult
A
LEFT
JOIN
tab_gic_mall_order_refund
B
ON
A
.
order_refund_id
=
B
.
order_refund_id
WHERE
B
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
A
.
from_erp
=
1
;
DELETE
A
FROM
tab_gic_mall_order_refund_logistics
A
LEFT
JOIN
tab_gic_mall_order_refund
B
ON
A
.
mall_order_id
=
B
.
order_id
WHERE
B
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
A
.
from_erp
=
1
;
DELETE
FROM
tab_gic_mall_order
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
tab_gic_mall_order_item
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
tab_gic_mall_order_logistics
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
tab_gic_mall_order_process
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
tab_gic_mall_order_refund
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
tab_gic_mall_collection
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
tab_gic_mall_evaluate
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
tab_gic_mall_order_batch_deliver_log
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
tab_gic_mall_shopping_cart
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
DELETE
FROM
`gic3.0`
.
tab_gic_member_address
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
-- 数据合并
insert
into
tab_gic_mall_order
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_order_copy
;
insert
into
tab_gic_mall_order_item
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_order_item_copy
;
insert
into
tab_gic_mall_order_logistics
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_order_logistics_copy
;
insert
into
tab_gic_mall_order_process
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_order_process_copy
;
insert
into
tab_gic_mall_order_refund_consult
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_order_refund_consult_copy
;
insert
into
tab_gic_mall_order_refund
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_order_refund_copy
;
insert
into
tab_gic_mall_order_refund_logistics
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_order_refund_logistics_copy
;
insert
into
tab_gic_mall_collection
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_collection_copy
;
insert
into
tab_gic_mall_evaluate
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_evaluate_copy
;
insert
into
tab_gic_mall_order_batch_deliver_log
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_order_batch_deliver_log_copy
;
insert
into
tab_gic_mall_shopping_cart
select
*
from
`order_import_CROQUIS`
.
tab_gic_mall_shopping_cart_copy
;
insert
into
`gic3.0`
.
tab_gic_member_address
select
*
from
`gic3.0`
.
tab_gic_member_address_copy
where
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
jnby-samo/导入指定的会员.sql
0 → 100644
View file @
5d430213
DELETE
A
FROM
tab_gic_mall_order_batch_deliver_log
A
LEFT
JOIN
tab_gic_mall_order
B
ON
A
.
order_id
=
B
.
order_id
WHERE
B
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
B
.
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
)
and
A
.
from_erp
=
1
;
DELETE
A
FROM
tab_gic_mall_order_refund_consult
A
LEFT
JOIN
tab_gic_mall_order_refund
B
ON
A
.
order_refund_id
=
B
.
order_refund_id
WHERE
B
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
B
.
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
)
and
A
.
from_erp
=
1
;
DELETE
A
FROM
tab_gic_mall_order_refund_logistics
A
LEFT
JOIN
tab_gic_mall_order_refund
B
ON
A
.
mall_order_id
=
B
.
order_id
WHERE
B
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
B
.
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
)
and
A
.
from_erp
=
1
;
DELETE
FROM
tab_gic_mall_order
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
DELETE
FROM
tab_gic_mall_order_item
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
DELETE
FROM
tab_gic_mall_order_logistics
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
DELETE
FROM
tab_gic_mall_order_process
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
DELETE
FROM
tab_gic_mall_order_refund
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
DELETE
FROM
tab_gic_mall_collection
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
DELETE
FROM
tab_gic_mall_evaluate
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
DELETE
FROM
`gic3.0`
.
tab_gic_member_address
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
DELETE
FROM
tab_gic_mall_shopping_cart
WHERE
from_erp
=
1
and
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
and
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
-- 合并单个人的数据
-- WX20062935
INSERT
INTO
tab_gic_mall_order_item
SELECT
*
FROM
tab_gic_mall_order_item_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
INSERT
INTO
tab_gic_mall_order
SELECT
*
FROM
tab_gic_mall_order_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
INSERT
INTO
tab_gic_mall_shopping_cart
SELECT
*
FROM
tab_gic_mall_shopping_cart_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
INSERT
INTO
tab_gic_mall_collection
SELECT
*
FROM
tab_gic_mall_collection_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
insert
into
`gic3.0`
.
tab_gic_member_address
SELECT
*
FROM
`gic3.0`
.
tab_gic_member_address_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
insert
into
tab_gic_mall_evaluate
SELECT
*
FROM
tab_gic_mall_evaluate_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
insert
into
tab_gic_mall_order_logistics
SELECT
*
FROM
tab_gic_mall_order_logistics_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
insert
into
tab_gic_mall_order_refund
SELECT
*
FROM
tab_gic_mall_order_refund_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
insert
into
tab_gic_mall_order_process
SELECT
*
FROM
tab_gic_mall_order_process_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
);
INSERT
INTO
tab_gic_mall_order_refund_consult
SELECT
*
FROM
tab_gic_mall_order_refund_consult_copy
WHERE
order_refund_id
in
(
SELECT
order_refund_id
FROM
tab_gic_mall_order_refund_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
)
);
INSERT
INTO
tab_gic_mall_order_refund_logistics
SELECT
*
FROM
tab_gic_mall_order_refund_logistics_copy
WHERE
mall_order_id
in
(
SELECT
order_id
FROM
tab_gic_mall_order_refund_copy
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
)
);
INSERT
INTO
tab_gic_mall_order_batch_deliver_log
SELECT
*
FROM
tab_gic_mall_order_batch_deliver_log_copy
WHERE
order_id
in
(
SELECT
order_id
FROM
tab_gic_mall_order
WHERE
member_id
in
(
'ff80808166174bfd016619bd2fbd1657'
,
'ff8080816717fc9c01671a89e80c4f17'
,
'ff80808163b2461d0163b2787ad50179'
)
);
jnby-samo/数据组装pro.sql
0 → 100644
View file @
5d430213
-- 清除导入的临时数据
truncate
from
tab_gic_mall_order_copy
;
truncate
from
tab_gic_mall_order_item_copy
;
truncate
from
tab_gic_mall_order_logistics_copy
;
truncate
from
tab_gic_mall_order_process_copy
;
truncate
from
tab_gic_mall_order_refund_consult_copy
;
truncate
from
tab_gic_mall_order_refund_copy
;
truncate
from
tab_gic_mall_order_refund_logistics_copy
;
truncate
from
tab_gic_mall_collection_copy
;
truncate
from
tab_gic_mall_evaluate_copy
;
truncate
from
tab_gic_mall_order_batch_deliver_log_copy
;
truncate
from
`gic3.0`
.
tab_gic_member_address_copy
;
truncate
from
tab_gic_mall_shopping_cart_copy
;
-- 数据填充,订单地址所在区域
update
`order_import_SAMO`
.
order_import
A
inner
join
(
select
county_id
,
full_name
from
`gic3.0`
.
tab_gic_county
)
c
on
(
locate
(
A
.
province_name
,
c
.
full_name
)
>
0
and
locate
(
A
.
city_name
,
c
.
full_name
)
>
0
and
locate
(
A
.
area_name
,
c
.
full_name
)
>
0
)
set
A
.
area_id
=
c
.
county_id
;
-- 数据填充,收货地址所在区域
update
`order_import_SAMO`
.
order_member_address
A
inner
join
(
select
county_id
,
full_name
from
`gic3.0`
.
tab_gic_county
)
c
on
(
locate
(
A
.
province
,
c
.
full_name
)
>
0
and
locate
(
A
.
city
,
c
.
full_name
)
>
0
and
locate
(
A
.
area
,
c
.
full_name
)
>
0
)
set
A
.
county_id
=
c
.
county_id
;
-- 把地址写入【tab_gic_member_address_copy】临时表
-- isdefault=Y 则为默认地址
-- 地址表 退订状态 1:未退订,0:退订 ,
-- tab_gic_member_sms 营销短信是否退订:1.退订
INSERT
INTO
`gic3.0`
.
`tab_gic_member_address_copy`
(
`member_address_id`
,
`member_id`
,
`member_personal_id`
,
`is_default`
,
`address_type`
,
`address`
,
`county_id`
,
`longitude`
,
`latitude`
,
`create_time`
,
`update_time`
,
`status`
,
`enterprise_id`
,
`member_name`
,
`phone_number`
,
`nationcode`
,
`clique_id`
,
`clique_member_id`
,
`ecommerce_buyer_id`
,
`subscribe_status`
,
`from_erp`
)
select
replace
(
uuid
(),
'-'
,
''
)
as
member_address_id
,
members_view
.
member_id
,
null
as
member_personal_id
,
IF
(
addr
.
isdefault
=
'Y'
,
1
,
0
)
as
is_default
,
1
as
address_type
,
addr
.
address
,
addr
.
county_id
,
null
as
longitude
,
null
as
latitude
,
now
()
as
create_time
,
now
()
as
update_time
,
1
as
status
,
members_view
.
enterprise_id
,
addr
.
buyer_name
,
addr
.
buyer_moile
as
phone_number
,
null
as
nationcode
,
members_view
.
clique_id
,
members_view
.
clique_member_id
,
-
1
as
ecommerce_buyer_id
,
IF
(
IFNULL
(
count
(
DISTINCT
s
.
unsubscribe
=
1
),
0
)
>
0
,
0
,
1
)
as
subscribe_status
,
1
as
from_erp
FROM
`order_import_SAMO`
.
order_member_address
addr
LEFT
JOIN
`gic3.0`
.
tab_gic_member_SAMO
members_view
on
members_view
.
card_num
=
addr
.
member_number
LEFT
JOIN
`gic3.0`
.
tab_gic_member_sms
s
on
s
.
phone_number
=
addr
.
buyer_moile
WHERE
s
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
GROUP
BY
addr
.
member_number
,
addr
.
address
;
-- 把订单信息写入临时表【tab_gic_mall_order_copy】
INSERT
INTO
`tab_gic_mall_order_copy`
(
`order_id`
,
`erp_order_id`
,
`order_number`
,
`order_process_id`
,
`order_step`
,
`enterprise_id`
,
`brand_id`
,
`member_id`
,
`mall_pro_all_price`
,
`actual_freight`
,
`mall_order_freight`
,
`discount_amount`
,
`discount_amount_info`
,
`amount_payable_info`
,
`pay_amount`
,
`pay_type`
,
`coupon_card_log_id`
,
`coupon_card_code`
,
`get_points`
,
`use_points`
,
`clerk_id`
,
`store_id`
,
`address_id`
,
`address_info`
,
`area_id`
,
`buyer_name`
,
`buyer_phone`
,
`logistics_company_id`
,
`logistics_number`
,
`pay_number`
,
`pay_time`
,
`order_show`
,
`evaluation_status`
,
`new_status`
,
`remarks`
,
`create_time`
,
`update_time`
,
`pay_amount_all`
,
`stock_decrease`
,
`clique_id`
,
`clique_member_id`
,
`deliver_store_id`
,
`delivery_type`
,
`store_code`
,
`clerk_code`
,
`trade_close_reason`
,
`order_version`
,
`from_erp`
,
`order_sequence`
)
select
replace
(
uuid
(),
'-'
,
''
)
as
order_id
,
oi
.
erp_order_id
,
pay_number
as
order_number
,
replace
(
uuid
(),
'-'
,
''
)
as
order_process_id
,
IF
(
oi
.
create_time
<
(
date_sub
(
now
()
,
interval
3
day
)),
0
,
oi
.
order_step
)
as
order_step
,
members_view
.
enterprise_id
,
'-1'
as
brand_id
,
members_view
.
member_id
,
oi
.
mall_pro_all_price
,
oi
.
actual_freight
,
oi
.
actual_freight
as
mall_order_freight
,
oi
.
discount_amount
,
oi
.
discount_amount_info
,
oi
.
amount_payable_info
,
oi
.
pay_amount
,
oi
.
pay_type
,
null
as
coupon_card_log_id
,
oi
.
coupon_card_code
,
oi
.
get_points
,
oi
.
use_points
,
clerk
.
clerk_id
,
clerk
.
store_id_order
as
store_id
,
addr
.
member_address_id
,
oi
.
address_info
,
addr
.
county_id
as
area_id
,
oi
.
buyer_name
,
oi
.
buyer_phone
,
logistics
.
`logistics_company_id`
,
oi
.
logistics_number
,
oi
.
pay_number
,
oi
.
pay_time
,
oi
.
order_show
,
oi
.
evaluation_status
,
oi
.
new_status
,
oi
.
remarks
,
oi
.
erp_create_time
,
oi
.
erp_create_time
as
update_time
,
oi
.
pay_amount_all
,
oi
.
stock_decrease
,
members_view
.
clique_id
,
members_view
.
clique_member_id
,
null
as
deliver_store_id
,
0
as
delivery_type
,
oi
.
store_code
,
oi
.
clerk_code
,
null
as
trade_close_reason
,
'version_1.0'
as
order_version
,
1
as
from_erp
,
null
as
order_sequence
FROM
`order_import_SAMO`
.
order_import
oi
left
join
`gic3.0`
.
tab_gic_member_SAMO
members_view
on
members_view
.
card_num
=
oi
.
member_card_num
LEFT
join
(
SELECT
*
FROM
`gic3.0`
.
tab_gic_member_address
UNION
SELECT
*
FROM
`gic3.0`
.
tab_gic_member_address_copy
)
addr
on
addr
.
member_id
=
members_view
.
member_id
left
join
`gic3.0`
.
tab_gic_logistics_company
logistics
on
oi
.
logistics_company_code
LIKE
CONCAT
(
'%'
,
logistics
.
logistics_company_name
,
'%'
)
left
join
`gic3.0`
.
tab_gic_member_clerk_SAMO
clerk
on
clerk
.
member_id
=
members_view
.
member_id
WHERE
members_view
.
member_id
is
not
null
-- AND oi.member_card_num in ('WX60206813','WX60332175','WX01805426')
GROUP
BY
oi
.
erp_order_id
;
-- 把订单项写入导临时表【tab_gic_mall_order_item_copy】
INSERT
INTO
`tab_gic_mall_order_item_copy`
(
`order_item_id`
,
`order_id`
,
`enterprise_id`
,
`brand_id`
,
`member_id`
,
`mall_pro_id`
,
`mall_pro_name`
,
`mall_pro_price`
,
`mall_pro_image_url`
,
`mall_pro_number`
,
`mall_pro_spu_price`
,
`mall_pro_sku_id`
,
`mall_pro_sku_code`
,
`mall_pro_sku_attr`
,
`discount_amount_info`
,
`amount_payable_info`
,
`pay_amount`
,
`get_points`
,
`use_points`
,
`order_item_freight`
,
`freight_template_id`
,
`max_refund_price`
,
`refund_price`
,
`refund_points`
,
`create_time`
,
`update_time`
,
`refund_number`
,
`activity_discount_id`
,
`activity_full_reduction_id`
,
`activity_freight_id`
,
`activity_tiered_id`
,
`clique_id`
,
`clique_member_id`
,
`refund_status`
,
`order_item_status`
,
`pro_code`
,
`order_item_number`
,
`brand_code`
,
`member_card_no`
,
`delivered_count`
,
`no_delivere_count`
,
from_erp
)
select
replace
(
uuid
(),
'-'
,
''
)
as
order_item_id
,
o
.
order_id
,
o
.
enterprise_id
,
o
.
brand_id
,
o
.
member_id
,
pro
.
mall_pro_id
,
IFNULL
(
oitem
.
mall_pro_name
,
pro
.
pro_name
)
as
mall_pro_name
,
IFNULL
(
oitem
.
mall_pro_price
,
0
)
,
IFNULL
(
oitem
.
goods_img
,
sku
.
mall_pro_propvalue_image_url
)
as
mall_pro_image_url
,
IFNULL
(
oitem
.
mall_pro_number
,
0
)
,
IFNULL
(
pro
.
mall_pro_spu_price
,
0
)
,
sku
.
mall_pro_sku_id
,
oitem
.
mall_pro_sku_code
,
IFNULL
(
sku
.
mall_prop_values
,
'[{}]'
)
as
mall_pro_sku_attr
,
oitem
.
discount_amount_info
,
oitem
.
amount_payable_info
,
IFNULL
(
oitem
.
pay_amount
,
0
),
IFNULL
(
oitem
.
get_points
,
0
)
,
oitem
.
use_points
,
oitem
.
order_item_freight
,
pro
.
freight_template_id
,
IFNULL
(
oitem
.
pay_amount
,
0
)
as
max_refund_price
,
IFNULL
(
oitem
.
pay_amount
,
0
)
as
refund_price
,
IFNULL
(
oitem
.
get_points
,
0
)
as
refund_points
,
oitem
.
erp_create_time
,
oitem
.
erp_create_time
as
update_time
,
0
as
refund_number
,
NULL
as
activity_discount_id
,
NULL
as
activity_full_reduction_id
,
NULL
as
activity_freight_id
,
NULL
as
activity_tiered_id
,
o
.
clique_id
,
o
.
clique_member_id
,
IF
(
o
.
order_step
=
5
||
o
.
order_step
=
6
,
1
,
0
)
as
refund_status
,
IF
(
o
.
order_step
<=
4
,
o
.
order_step
,
2
)
as
order_item_status
,
pro
.
pro_code
,
oitem
.
order_item_number
,
pro
.
brand_code
,
oitem
.
member_card_no
,
0
as
delivered_count
,
0
as
no_delivere_count
,
1
as
from_erp
FROM
`order_import_SAMO`
.
order_item_import
oitem
left
join
tab_gic_mall_order_copy
o
on
o
.
erp_order_id
=
oitem
.
erp_order_id
left
join
`gic_mall`
.
tab_gic_mall_pro
pro
on
pro
.
pro_code
=
oitem
.
mall_pro_code
and
pro
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
left
join
`gic_mall`
.
tab_gic_mall_pro_sku
sku
on
sku
.
mall_pro_sku_code
=
oitem
.
mall_pro_sku_code
and
sku
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
where
o
.
order_id
is
not
NULL
and
oitem
.
member_card_no
is
not
NULL
-- AND oitem.member_card_no in ('WX60206813','WX60332175','WX01805426')
GROUP
BY
oitem
.
erp_order_item_id
;
-- 订单项退款状态: 0无退款 1退款中 2成功 3失败
-- 订单项状态 0(交易关闭),2待发货,3已发货,4已确认(交易成功)
-- 订单状态 0交易关闭 1未付款(待付款、等待买家付款) 2已付款未发货(待发货、买家已付款) 3已发货未签收(待收货、已发货)
-- 4已确认交易结束,5已发货订单项退款中,6待付款订单项退款中,7部分发货',
-- 把发货的物流信息写入导临时表【tab_gic_mall_order_logistics_copy】
INSERT
INTO
`tab_gic_mall_order_logistics_copy`
(
`mall_order_logistics_id`
,
`mall_order_id`
,
`logistics_company_id`
,
`logistics_company_name`
,
`logistics_company_code`
,
`courier_number`
,
`logistics_information`
,
`create_time`
,
`update_time`
,
`enterprise_id`
,
`clique_id`
,
`member_id`
,
`clique_member_id`
,
`weight`
,
`order_item_id`
,
`order_item_num`
,
`order_item_sum_num`
,
from_erp
)
select
replace
(
uuid
(),
'-'
,
''
)
as
mall_order_logistics_id
,
o
.
order_id
as
mall_order_id
,
logistics
.
logistics_company_id
,
logistics
.
logistics_company_name
,
logistics
.
logistics_company_code
,
logis
.
courier_number
,
logis
.
logistics_information
,
logis
.
erp_create_time
,
logis
.
erp_update_time
,
o
.
`enterprise_id`
,
o
.
`clique_id`
,
o
.
`member_id`
,
o
.
`clique_member_id`
,
0
as
weight
,
item
.
order_item_id
,
logis
.
send_num
,
IFNULL
(
item
.
mall_pro_number
,
0
)
as
`order_item_sum_num`
,
1
as
from_erp
FROM
`order_import_SAMO`
.
order_logistics_import
logis
left
join
tab_gic_mall_order_copy
o
on
o
.
erp_order_id
=
logis
.
erp_order_id
left
join
tab_gic_mall_order_item_copy
item
on
item
.
pro_code
=
logis
.
mall_pro_code
left
join
`gic3.0`
.
tab_gic_logistics_company
logistics
on
logis
.
logistics_company_name
LIKE
CONCAT
(
'%'
,
logistics
.
logistics_company_name
,
'%'
)
-- where o.member_in in ('ff80808166174bfd016619bd2fbd1657','ff8080816717fc9c01671a89e80c4f17','ff80808163b2461d0163b2787ad50179' )
;
-- 把字符串【courierNumber】替换成正则的物流单号
UPDATE
`tab_gic_mall_order_logistics_copy`
SET
logistics_information
=
replace
(
logistics_information
,
'courierNumber'
,
courier_number
);
-- 把字符串【logisticsCompanyCode】替换成正则的物流公司编号
UPDATE
`tab_gic_mall_order_logistics_copy`
SET
logistics_information
=
replace
(
logistics_information
,
'logisticsCompanyCode'
,
logistics_company_code
);
-- 把退款的物流信息写入导临时表【tab_gic_mall_order_refund_logistics_copy】
INSERT
INTO
`tab_gic_mall_order_refund_logistics_copy`
(
`mall_order_logistics_id`
,
`mall_order_id`
,
`logistics_company_id`
,
`logistics_company_name`
,
`logistics_company_code`
,
`courier_number`
,
`logistics_information`
,
`create_time`
,
`update_time`
,
`weight`
,
`order_item_id`
,
`from_erp`
)
select
replace
(
uuid
(),
'-'
,
''
)
as
mall_order_logistics_id
,
o
.
order_id
as
mall_order_id
,
logistics
.
logistics_company_id
,
logistics
.
logistics_company_name
,
logistics
.
logistics_company_code
,
logis
.
courier_number
,
logis
.
logistics_information
,
logis
.
erp_create_time
,
logis
.
erp_update_time
,
0
as
weight
,
item
.
order_item_id
,
1
as
from_erp
FROM
`order_import_SAMO`
.
order_refund_logistics_import
logis
left
join
tab_gic_mall_order_copy
o
on
o
.
erp_order_id
=
logis
.
erp_order_id
left
join
tab_gic_mall_order_item_copy
item
on
item
.
pro_code
=
logis
.
mall_pro_code
left
join
`gic3.0`
.
tab_gic_logistics_company
logistics
on
logis
.
logistics_company_name
LIKE
CONCAT
(
'%'
,
logistics
.
logistics_company_name
,
'%'
)
-- where o.member_in in ('ff80808166174bfd016619bd2fbd1657','ff8080816717fc9c01671a89e80c4f17','ff80808163b2461d0163b2787ad50179' )
GROUP
BY
logis
.
courier_number
;
-- 把字符串【courierNumber】替换成正则的物流单号
UPDATE
`tab_gic_mall_order_refund_logistics_copy`
SET
logistics_information
=
replace
(
logistics_information
,
'courierNumber'
,
courier_number
);
-- 把字符串【logisticsCompanyCode】替换成正则的物流公司编号
UPDATE
`tab_gic_mall_order_refund_logistics_copy`
SET
logistics_information
=
replace
(
logistics_information
,
'logisticsCompanyCode'
,
logistics_company_code
);
-- 把订单处理流程写入临时表【tab_gic_mall_order_process_copy】
INSERT
INTO
`tab_gic_mall_order_process_copy`
(
`order_process_id`
,
`order_id`
,
`enterprise_id`
,
`brand_id`
,
`member_id`
,
`order_step`
,
`order_close`
,
`order_refund`
,
`create_time`
,
`update_time`
,
`reminding_times`
,
`clique_id`
,
`clique_member_id`
,
`from_erp`
)
select
o
.
order_process_id
,
o
.
order_id
,
o
.
enterprise_id
,
o
.
brand_id
,
o
.
member_id
,
p
.
order_step
,
p
.
order_close
,
0
as
order_refund
,
p
.
erp_create_time
,
p
.
erp_update_time
,
0
as
reminding_times
,
o
.
`clique_id`
,
o
.
`clique_member_id`
,
1
as
from_erp
FROM
`order_import_SAMO`
.
order_process_import
p
left
join
tab_gic_mall_order_copy
o
on
o
.
erp_order_id
=
p
.
erp_order_id
WHERE
o
.
order_id
is
not
NULL
-- and o.member_in in ('ff80808166174bfd016619bd2fbd1657','ff8080816717fc9c01671a89e80c4f17','ff80808163b2461d0163b2787ad50179' )
;
-- 把订单退款申请写入临时表【tab_gic_mall_order_refund_copy】
INSERT
INTO
`tab_gic_mall_order_refund_copy`
(
`order_refund_id`
,
`order_id`
,
`order_item_id`
,
`enterprise_id`
,
`brand_id`
,
`apply_user`
,
`actual_number`
,
`member_id`
,
`order_process_id`
,
`refund_number`
,
`max_refund_price`
,
`apply_refund_price`
,
`refund_price`
,
`refund_points`
,
`refund_status`
,
`refund_reason`
,
`refund_fail_reason`
,
`create_time`
,
`update_time`
,
`out_trade_no`
,
`refund_describe`
,
`order_refund_number`
,
`clique_id`
,
`clique_member_id`
,
`apply_channel`
,
`refund_type`
,
`refund_logistics_id`
,
`order_item_num`
,
`order_item_sum_num`
,
`order_num`
,
`refund_deliver_type`
,
`refund_seller_address_id`
,
`refund_seller_desc`
,
`refund_process_time`
,
`refund_goods_time`
,
`doc_no`
,
`from_erp`
)
SELECT
replace
(
uuid
(),
'-'
,
''
)
as
order_refund_id
,
o
.
order_id
,
item
.
order_item_id
,
members_view
.
enterprise_id
,
o
.
brand_id
,
members_view
.
member_id
as
apply_user
,
r
.
actual_number
,
members_view
.
member_id
,
o
.
order_process_id
,
r
.
refund_number
,
r
.
apply_refund_price
as
max_refund_price
,
r
.
apply_refund_price
,
r
.
refund_price
,
r
.
refund_points
,
r
.
refund_status
,
r
.
refund_reason
,
null
as
refund_fail_reason
,
r
.
erp_create_time
,
r
.
erp_create_time
as
update_time
,
r
.
out_trade_no
,
null
as
refund_describe
,
REPLACE
(
unix_timestamp
(
r
.
erp_create_time
),
'.'
,
''
)
as
order_refund_number
,
members_view
.
clique_id
,
members_view
.
clique_member_id
,
r
.
apply_channel
,
r
.
refund_type
,
null
as
refund_logistics_id
,
r
.
order_item_num
,
r
.
order_item_sum_num
,
SUM
(
item
.
mall_pro_number
)
as
order_num
,
r
.
refund_deliver_type
,
null
as
refund_seller_address_id
,
null
as
refund_seller_desc
,
null
as
refund_process_time
,
null
as
refund_goods_time
,
o
.
order_number
as
doc_no
,
1
as
from_erp
FROM
`order_import_SAMO`
.
order_refund_import
r
left
join
tab_gic_mall_order_copy
o
on
o
.
order_number
=
r
.
out_trade_no
left
join
tab_gic_mall_order_item_copy
item
on
item
.
order_id
=
o
.
order_id
and
r
.
apply_refund_price
=
item
.
pay_amount
left
join
`gic3.0`
.
tab_gic_member_SAMO
members_view
on
members_view
.
card_num
=
r
.
member_card_no
WHERE
o
.
order_id
is
not
NULL
-- and o.member_in in ('ff80808166174bfd016619bd2fbd1657','ff8080816717fc9c01671a89e80c4f17','ff80808163b2461d0163b2787ad50179' )
group
by
r
.
order_item_number
;
-- 批量发货记录
INSERT
INTO
`tab_gic_mall_order_batch_deliver_log_copy`
(
`mall_order_batch_deliver_log_id`
,
`batch_id`
,
`enterprise_id`
,
`order_id`
,
`order_number`
,
`courier_number`
,
`logistics_company_id`
,
`logistics_company_code`
,
`logistics_company_name`
,
`create_time`
,
`update_time`
,
`status`
,
`clique_id`
,
`from_erp`
)
select
replace
(
uuid
(),
'-'
,
''
)
as
mall_order_batch_deliver_log_id
,(
concat
(
o
.
enterprise_id
,
REPLACE
(
unix_timestamp
(
d
.
`erp_create_time`
),
'.'
,
''
)
)
)
as
batch_id
,
o
.
enterprise_id
,
o
.
order_id
,
o
.
order_number
,
d
.
courier_number
,
logistics
.
logistics_company_id
,
logistics
.
logistics_company_code
,
logistics
.
logistics_company_name
,
d
.
`erp_create_time`
,
d
.
`erp_update_time`
,
d
.
`status`
,
o
.
`clique_id`
,
1
as
from_erp
from
`order_import_SAMO`
.
order_batch_deliver_import
d
left
join
tab_gic_mall_order_copy
o
on
o
.
order_number
=
d
.
order_number
left
join
`gic3.0`
.
tab_gic_logistics_company
logistics
on
d
.
logistics_company_name
LIKE
CONCAT
(
'%'
,
logistics
.
logistics_company_name
,
'%'
)
WHERE
o
.
order_id
is
not
NULL
-- and o.member_in in ('ff80808166174bfd016619bd2fbd1657','ff8080816717fc9c01671a89e80c4f17','ff80808163b2461d0163b2787ad50179' )
;
-- 把退款协商结果导入导临时表【tab_gic_mall_order_refund_consult_copy】
INSERT
INTO
`tab_gic_mall_order_refund_consult_copy`
(
`order_refund_consult_id`
,
`order_refund_id`
,
`role`
,
`msg`
,
`refund_reason`
,
`refund_type`
,
`refund_price`
,
`description`
,
`img_url`
,
`create_time`
,
`update_time`
,
`refund_point`
,
`msg_type`
,
`refund_deliver_type`
,
`from_erp`
)
SELECT
replace
(
uuid
(),
'-'
,
''
)
as
order_refund_consult_id
,
r
.
order_refund_id
,
2
as
role
,
'商家已同意退货'
as
msg
,
'不喜欢/不想要'
as
refund_reason
,
2
as
refund_type
,
r
.
refund_price
,
null
as
description
,
null
as
img_url
,
r
.
create_time
,
r
.
create_time
as
update_time
,
r
.
refund_points
,
null
as
msg_type
,
1
as
refund_deliver_type
,
1
as
from_erp
FROM
tab_gic_mall_order_refund_copy
r
;
UPDATE
order_evaluate_import
e
LEFT
JOIN
tab_gic_mall_pro_sku
sku
ON
e
.
mall_pro_sku_code
=
sku
.
mall_pro_sku_code
SET
e
.
mall_pro_id
=
sku
.
mall_pro_id
-- 把商品评论导入导临时表【tab_gic_mall_evaluate_copy】
INSERT
INTO
`tab_gic_mall_evaluate_copy`
(
`evaluate_id`
,
`enterprise_id`
,
`member_id`
,
`evaluate_type`
,
`mall_order_id`
,
`mall_order_item_id`
,
`mall_pro_id`
,
`evaluate_content`
,
`evaluate_score`
,
`show_status`
,
`status`
,
`reply_content`
,
`reply_status`
,
`reply_date`
,
`create_time`
,
`update_time`
,
`clique_id`
,
`clique_member_id`
,
`member_card_no`
,
`member_nickname`
,
`from_erp`
)
SELECT
REPLACE
(
UUID
(),
'-'
,
''
)
AS
evaluate_id
,
itemc
.
enterprise_id
,
itemc
.
member_id
,
e
.
evaluate_type
,
itemc
.
order_id
AS
mall_order_id
,
itemc
.
order_item_id
AS
mall_order_item_id
,
itemc
.
mall_pro_id
,
e
.
evaluate_content
,
e
.
evaluate_score
,
e
.
show_status
,
e
.
status
,
e
.
reply_content
,
e
.
reply_status
,
e
.
reply_date
,
e
.
erp_create_time
,
NULL
AS
update_time
,
itemc
.
clique_id
,
itemc
.
clique_member_id
,
e
.
member_card_no
,
NULL
AS
third_nickname
,
1
AS
from_erp
FROM
`order_import_SAMO`
.
order_evaluate_import
e
LEFT
JOIN
tab_gic_mall_order_copy
o
ON
o
.
erp_order_id
=
e
.
erp_order_id
LEFT
JOIN
tab_gic_mall_order_item_copy
itemc
ON
itemc
.
mall_pro_sku_code
=
e
.
mall_pro_sku_code
AND
itemc
.
order_id
=
o
.
order_id
group
by
e
.
id
;
UPDATE
tab_gic_mall_evaluate_copy
e
inner
JOIN
`gic3.0`
.
tab_gic_member_SAMO
members_view
ON
members_view
.
card_num
=
e
.
member_card_no
SET
e
.
member_id
=
members_view
.
member_id
,
e
.
clique_member_id
=
members_view
.
clique_member_id
,
e
.
member_nickname
=
members_view
.
third_nickname
,
e
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
,
e
.
clique_id
=
members_view
.
clique_id
where
members_view
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
-- 把收藏夹导入导临时表【tab_gic_mall_collection_copy】
INSERT
INTO
`tab_gic_mall_collection_copy`
(
`collection_id`
,
`member_id`
,
`enterprise_id`
,
`brand_id`
,
`mall_pro_id`
,
`mall_pro_name`
,
`mall_pro_collected_price`
,
`mall_pro_price`
,
`mall_pro_image_url`
,
`mall_pro_spu_price`
,
`status`
,
`create_time`
,
`update_time`
,
`clique_id`
,
`clique_member_id`
,
`from_erp`
)
SELECT
replace
(
uuid
(),
'-'
,
''
)
as
collection_id
,
members_view
.
member_id
,
members_view
.
enterprise_id
,
pro
.
brand_id
,
pro
.
mall_pro_id
,
pro
.
pro_name
as
mall_pro_name
,
pro
.
mall_pro_spu_price
as
mall_pro_collected_price
,
pro
.
mall_pro_spu_price
as
mall_pro_price
,
pro
.
mall_pro_image_url
,
pro
.
mall_pro_spu_price
,
co
.
`status`
,
co
.
erp_create_time
,
co
.
erp_create_time
as
update_time
,
members_view
.
clique_id
,
members_view
.
clique_member_id
,
1
as
from_erp
from
`order_import_SAMO`
.
collect_import
co
left
join
`gic_mall`
.
tab_gic_mall_pro
pro
on
pro
.
pro_code
=
co
.
mall_pro_code
and
pro
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
left
join
`gic3.0`
.
tab_gic_member_SAMO
members_view
on
members_view
.
card_num
=
co
.
card_no
-- WHERE co.card_no in ('WX60206813','WX60332175','WX01805426')
group
by
co
.
card_no
,
co
.
mall_pro_code
;
-- 把购物车信息导入导临时表【tab_gic_mall_shopping_cart_copy】
INSERT
INTO
`tab_gic_mall_shopping_cart_copy`
(
`shopping_cart_id`
,
`member_id`
,
`enterprise_id`
,
`brand_id`
,
`mall_pro_id`
,
`mall_pro_name`
,
`mall_pro_sku_id`
,
`mall_pro_sku_attr`
,
`mall_pro_price`
,
`mall_pro_image_url`
,
`mall_pro_number`
,
`mall_pro_sku_price`
,
`mall_pro_payable_price`
,
`status`
,
`create_time`
,
`update_time`
,
`mall_pro_summary_price`
,
`clique_id`
,
`clique_member_id`
,
`from_erp`
)
SELECT
replace
(
uuid
(),
'-'
,
''
)
as
shopping_cart_id
,
members_view
.
member_id
,
members_view
.
enterprise_id
,
pro
.
brand_id
,
pro
.
mall_pro_id
,
cart
.
mall_pro_name
,
sku
.
mall_pro_sku_id
,
IFNULL
(
sku
.
mall_prop_values
,
'[{}]'
)
as
mall_pro_sku_attr
,
cart
.
mall_pro_price
,
pro
.
mall_pro_image_url
,
cart
.
mall_pro_number
,
sku
.
mall_pro_sku_price
,
cart
.
mall_pro_summary_price
as
mall_pro_payable_price
,
IF
(
isnull
(
pro
.
mall_pro_id
),
0
,
1
)
as
status
,
cart
.
erp_create_time
,
cart
.
erp_create_time
as
update_time
,
cart
.
mall_pro_summary_price
,
members_view
.
clique_id
,
members_view
.
clique_member_id
,
1
as
from_erp
from
`order_import_SAMO`
.
mall_shoopping_cart
cart
left
join
`gic_mall`
.
tab_gic_mall_pro
pro
on
pro
.
pro_code
=
cart
.
mall_pro_code
and
pro
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
left
join
`gic_mall`
.
tab_gic_mall_pro_sku
sku
on
sku
.
mall_pro_sku_code
=
cart
.
mall_sku_code
and
sku
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
left
join
`gic3.0`
.
tab_gic_member_SAMO
members_view
on
members_view
.
card_num
=
cart
.
cardno
-- WHERE cart.cardno in ('WX60206813','WX60332175','WX01805426')
group
by
cart
.
cardno
,
cart
.
mall_pro_code
,
cart
.
mall_sku_code
;
-- 订单项的发货,未发货
update
tab_gic_mall_order_item_copy
A
INNER
JOIN
(
select
order_item_id
,
IFNULL
(
sum
(
order_item_num
),
0
)
delivered_count
from
tab_gic_mall_order_logistics_copy
group
by
order_item_id
)
c
on
A
.
order_item_id
=
c
.
order_item_id
set
A
.
delivered_count
=
c
.
delivered_count
,
A
.
no_delivere_count
=
(
mall_pro_number
-
c
.
delivered_count
)
WHERE
A
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
;
-- 退款数量
update
tab_gic_mall_order_item_copy
A
INNER
JOIN
(
select
IFNULL
(
count
(
order_item_id
),
0
)
refund_number
,
order_item_id
from
tab_gic_mall_order_refund_copy
WHERE
refund_status
=
2
group
by
order_item_id
)
r
on
A
.
order_item_id
=
r
.
order_item_id
set
A
.
refund_number
=
r
.
refund_number
WHERE
A
.
enterprise_id
=
'ff80808164f65d9501651798e0f8143d'
AND
r
.
refund_number
is
not
null
;
\ 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