数据迁移

This commit is contained in:
邓皓元 2019-02-11 16:24:08 +08:00
parent 68db63e437
commit fc3d66fba7
8 changed files with 101 additions and 17 deletions

View File

@ -19,7 +19,7 @@
></Step>
</Steps>
<Row type="flex" justify="center" class="umar-t15" v-if="[3, 4].indexOf(current) !== -1">
<Row type="flex" justify="center" class="umar-t15" v-if="steps[current] && steps[current]['datePicker']">
<DatePicker
:editable="false"
placeholder="请选择时间"

View File

@ -38,19 +38,27 @@ export default {
'title': '同步套餐',
'content': '所有套餐的数据',
'command': 'real:sync-package',
'max': 25
},
{
'title': '同步流量池',
'content': '所有流量池的数据',
'command': 'real:sync-flow-pool',
'max': 30
},
{
'title': '同步订单',
'content': '指定月份的销售订单数据',
'command': 'real:sync-order',
'max': 65
'max': 70,
'datePicker': true
},
{
'title': '同步企业订单',
'content': '指定月份的续费及增值包数据',
'command': 'real:sync-added-order',
'max': 100
'max': 100,
'datePicker': true
}
],
current: 0,
@ -64,6 +72,10 @@ export default {
},
methods: {
call() {
if (!this.steps[this.current]) {
return;
}
this.disabled = true;
let params = {};
@ -74,7 +86,7 @@ export default {
return this.$Message.error('命令错误');
}
if ([3, 4].indexOf(this.current) !== -1) {
if (this.steps[this.current]['datePicker']) {
if (!this.month) {
return this.$Message.error('请选择要同步的月份');
}
@ -95,8 +107,6 @@ export default {
}
}, 1000);
console.log(this.current);
service.post('/api/artisan/call', params).then(res => {
if (res.code == 0) {
this.circle.content = this.steps[this.current]['title'] + '完成';
@ -110,7 +120,6 @@ export default {
}
this.disabled = false;
console.log(this.circle);
clearInterval(interval);
}).catch((err) => {
console.log(err);

View File

@ -1,6 +1,75 @@
SELECT
ckb_custom_handle_log.custom_no,
min((ckb_custom.card_number)::text) AS sim,
CASE ckb_custom_handle_log.type
WHEN 13 THEN
0
WHEN 11 THEN
1
WHEN 14 THEN
2
WHEN 15 THEN
3
ELSE
NULL::integer
END AS order_type,
concat(to_char(to_timestamp((ckb_custom_handle_log.create_time)::double precision), 'YYYYMMDDHHMISS'::text), CASE ckb_custom_handle_log.type
WHEN 13 THEN
0
WHEN 11 THEN
1
WHEN 14 THEN
2
WHEN 15 THEN
3
ELSE
NULL::integer
END, CASE ckb_custom_handle_log.pay_type
WHEN 10 THEN
2
WHEN 11 THEN
3
WHEN 12 THEN
0
ELSE
NULL::integer
END, lpad((virtual_companies.id)::text, 3, '0'::text), lpad((virtual_packages.id)::text, 4, '0'::text), lpad((((ckb_custom_handle_log.order_account)::integer * 100))::text, 6, '0'::text)) AS order_sn,
COALESCE(virtual_companies.id, 0) AS company_id,
COALESCE(virtual_packages.id, 0) AS package_id,
COALESCE(min(virtual_products.id), 0) AS product_id,
CASE ckb_custom_handle_log.pay_type
WHEN 10 THEN
'wx'::text
WHEN 11 THEN
'alipay'::text
WHEN 12 THEN
'bank'::text
ELSE
NULL::text
END AS pay_channel,
((ckb_custom_handle_log.order_account)::integer * 100) AS unit_price,
to_timestamp((ckb_custom_handle_log.create_time)::double precision) AS created_at,
count(*) AS counts
FROM ((((vd_old.ckb_custom_handle_log
LEFT JOIN vd_old.ckb_custom ON (((ckb_custom.custom_no)::text = (ckb_custom_handle_log.custom_no)::text)))
LEFT JOIN virtual_companies ON ((((virtual_companies.sn)::text = concat('No', lpad((ckb_custom_handle_log.company)::text, 11, '0'::text)))
AND (virtual_companies.deleted_at IS NULL))))
LEFT JOIN virtual_packages ON ((((virtual_packages.sn)::text = (ckb_custom_handle_log.content)::text)
AND (virtual_packages.deleted_at IS NULL))))
LEFT JOIN virtual_products ON (((virtual_products.sn)::text = concat(ckb_custom_handle_log.content, '_', virtual_companies.id, '_', ((ckb_custom_handle_log.order_account)::integer * 100)))))
WHERE (ckb_custom_handle_log.type = ANY (ARRAY[11, 13, 14, 15]))
GROUP BY
ckb_custom_handle_log.create_time,
virtual_companies.id,
virtual_packages.id,
ckb_custom_handle_log.order_account,
ckb_custom_handle_log.custom_no,
ckb_custom_handle_log.type,
ckb_custom_handle_log.pay_type;
INSERT INTO virtual_orders ("type", sn, "source", company_id, package_id, product_id, pay_channel, unit_price, counts, total_price, custom_price, order_at, order_status, transaction_status, created_at, updated_at) (
SELECT
MIN("type"),
MIN(order_type),
order_sn,
1,
MIN(company_id),
@ -25,7 +94,7 @@ INSERT INTO virtual_orders ("type", sn, "source", company_id, package_id, produc
INSERT INTO virtual_order_cards ("type", sim, order_id, company_id, package_id, counts, created_at, updated_at) (
SELECT
logs. "type" AS "type",
logs.order_type AS "type",
logs.sim::BIGINT AS sim,
virtual_orders.ID AS order_id,
logs.company_id,
@ -37,12 +106,12 @@ INSERT INTO virtual_order_cards ("type", sim, order_id, company_id, package_id,
logs
LEFT JOIN virtual_orders ON virtual_orders.sn = logs.order_sn
WHERE
logs. "type" = 0) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP))
logs.order_type = 0) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP))
DO NOTHING;
INSERT INTO virtual_order_renewal_cards ("type", sim, order_id, company_id, package_id, counts, created_at, updated_at) (
SELECT
logs. "type" AS "type",
logs.order_type AS "type",
logs.sim::BIGINT AS sim,
virtual_orders.ID AS order_id,
logs.company_id,
@ -54,12 +123,12 @@ INSERT INTO virtual_order_renewal_cards ("type", sim, order_id, company_id, pack
logs
LEFT JOIN virtual_orders ON virtual_orders.sn = logs.order_sn
WHERE
logs. "type" = 1) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP))
logs.order_type = 1) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP))
DO NOTHING;
INSERT INTO virtual_order_renewal_package_cards ("type", sim, order_id, company_id, package_id, counts, created_at, updated_at) (
SELECT
logs. "type" AS "type",
logs.order_type AS "type",
logs.sim::BIGINT AS sim,
virtual_orders.ID AS order_id,
logs.company_id,
@ -71,12 +140,12 @@ INSERT INTO virtual_order_renewal_package_cards ("type", sim, order_id, company_
logs
LEFT JOIN virtual_orders ON virtual_orders.sn = logs.order_sn
WHERE
logs. "type" = 2) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP))
logs.order_type = 2) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP))
DO NOTHING;
INSERT INTO virtual_order_flows_package_cards ("type", sim, order_id, company_id, package_id, counts, created_at, updated_at) (
SELECT
logs. "type" AS "type",
logs.order_type AS "type",
logs.sim::BIGINT AS sim,
virtual_orders.ID AS order_id,
logs.company_id,
@ -88,6 +157,6 @@ INSERT INTO virtual_order_flows_package_cards ("type", sim, order_id, company_id
logs
LEFT JOIN virtual_orders ON virtual_orders.sn = logs.order_sn
WHERE
logs. "type" = 3) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP))
logs.order_type = 3) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP))
DO NOTHING;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-7b1dff40.ca5cf5af.css rel=prefetch><link href=/js/chunk-00ae0766.9e6b7bf3.js rel=prefetch><link href=/js/chunk-7b1dff40.f63ca56c.js rel=prefetch><link href=/css/app.36043160.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.3925395d.js rel=preload as=script><link href=/js/chunk-vendors.02a4e5bc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.36043160.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.02a4e5bc.js></script><script src=/js/app.3925395d.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-7b1dff40.ca5cf5af.css rel=prefetch><link href=/js/chunk-00ae0766.9e6b7bf3.js rel=prefetch><link href=/js/chunk-7b1dff40.5edb4c7e.js rel=prefetch><link href=/css/app.36043160.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.254f6ec9.js rel=preload as=script><link href=/js/chunk-vendors.02a4e5bc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.36043160.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.02a4e5bc.js></script><script src=/js/app.254f6ec9.js></script></body></html>