同订单两次
This commit is contained in:
parent
432dc7b3e7
commit
f8bfcd7295
@ -38,9 +38,6 @@ class MongoSyncJob implements ShouldQueue
|
|||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
$this->utcDateTime = $utcDateTime;
|
$this->utcDateTime = $utcDateTime;
|
||||||
set_time_limit(0);
|
|
||||||
ini_set('memory_limit', '4096m');
|
|
||||||
ini_set('default_socket_timeout', -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,9 +40,6 @@ class CardSyncJob implements ShouldQueue
|
|||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
$this->maxId = $maxId;
|
$this->maxId = $maxId;
|
||||||
set_time_limit(0);
|
|
||||||
ini_set('memory_limit', '4096m');
|
|
||||||
ini_set('default_socket_timeout', -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,9 +64,6 @@ class LogSyncJob implements ShouldQueue
|
|||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
$this->maxId = $maxId;
|
$this->maxId = $maxId;
|
||||||
set_time_limit(0);
|
|
||||||
ini_set('memory_limit', '4096m');
|
|
||||||
ini_set('default_socket_timeout', -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,7 +128,7 @@ class LogSyncJob implements ShouldQueue
|
|||||||
|
|
||||||
$counts = isset($relationArray[$k]) ? $relationArray[$k]['counts'] + 1 : 1;
|
$counts = isset($relationArray[$k]) ? $relationArray[$k]['counts'] + 1 : 1;
|
||||||
|
|
||||||
$relationArray[] = [
|
$relationArray[$k] = [
|
||||||
'order_sn' => $sn,
|
'order_sn' => $sn,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'sim' => $value['sim'],
|
'sim' => $value['sim'],
|
||||||
@ -175,7 +172,6 @@ class LogSyncJob implements ShouldQueue
|
|||||||
|
|
||||||
$builder->connection->insert($sql, Arr::flatten($array, 1));
|
$builder->connection->insert($sql, Arr::flatten($array, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollback();
|
DB::rollback();
|
||||||
Log::info("LogSyncJob ERROR #: maxId {$this->maxId} - page {$this->page}");
|
Log::info("LogSyncJob ERROR #: maxId {$this->maxId} - page {$this->page}");
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
-- 创建序列
|
||||||
CREATE SEQUENCE IF NOT EXISTS "virtual_order_cards_partition_id_seq"
|
CREATE SEQUENCE IF NOT EXISTS "virtual_order_cards_partition_id_seq"
|
||||||
INCREMENT 1
|
INCREMENT 1
|
||||||
MINVALUE 1
|
MINVALUE 1
|
||||||
MAXVALUE 2147483647 START 1
|
MAXVALUE 2147483647 START 1
|
||||||
CACHE 1;
|
CACHE 1;
|
||||||
|
|
||||||
|
-- 创建主表
|
||||||
CREATE TABLE "virtual_order_cards_partition" (
|
CREATE TABLE "virtual_order_cards_partition" (
|
||||||
"id" int4 NOT NULL DEFAULT nextval('virtual_order_cards_partition_id_seq'::regclass),
|
"id" int4 NOT NULL DEFAULT nextval('virtual_order_cards_partition_id_seq'::regclass),
|
||||||
"type" int2 NOT NULL DEFAULT 0,
|
"type" int2 NOT NULL DEFAULT 0,
|
||||||
@ -20,8 +22,10 @@ PARTITION BY
|
|||||||
"type"
|
"type"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- 序列
|
||||||
ALTER SEQUENCE "virtual_order_cards_partition_id_seq" OWNED BY "virtual_order_cards_partition"."id";
|
ALTER SEQUENCE "virtual_order_cards_partition_id_seq" OWNED BY "virtual_order_cards_partition"."id";
|
||||||
|
|
||||||
|
-- 备注
|
||||||
COMMENT ON COLUMN "virtual_order_cards_partition"."id" IS '关联表ID';
|
COMMENT ON COLUMN "virtual_order_cards_partition"."id" IS '关联表ID';
|
||||||
COMMENT ON COLUMN "virtual_order_cards_partition"."type" IS '订单类型(0:基础套餐 1:套餐续费 2:续费包 3:加油包 4:可选包 5:附加包)';
|
COMMENT ON COLUMN "virtual_order_cards_partition"."type" IS '订单类型(0:基础套餐 1:套餐续费 2:续费包 3:加油包 4:可选包 5:附加包)';
|
||||||
COMMENT ON COLUMN "virtual_order_cards_partition"."sim" IS 'SIM卡号';
|
COMMENT ON COLUMN "virtual_order_cards_partition"."sim" IS 'SIM卡号';
|
||||||
@ -31,21 +35,25 @@ COMMENT ON COLUMN "virtual_order_cards_partition"."package_id" IS '套餐ID';
|
|||||||
COMMENT ON COLUMN "virtual_order_cards_partition"."counts" IS '数量';
|
COMMENT ON COLUMN "virtual_order_cards_partition"."counts" IS '数量';
|
||||||
COMMENT ON TABLE "virtual_order_cards_partition" IS 'VD卡关联套餐订单';
|
COMMENT ON TABLE "virtual_order_cards_partition" IS 'VD卡关联套餐订单';
|
||||||
|
|
||||||
|
-- 分区表
|
||||||
CREATE TABLE virtual_order_cards PARTITION OF virtual_order_cards_partition FOR VALUES IN (0);
|
CREATE TABLE virtual_order_cards PARTITION OF virtual_order_cards_partition FOR VALUES IN (0);
|
||||||
CREATE TABLE virtual_order_renewal_cards PARTITION OF virtual_order_cards_partition FOR VALUES IN (1);
|
CREATE TABLE virtual_order_renewal_cards PARTITION OF virtual_order_cards_partition FOR VALUES IN (1);
|
||||||
CREATE TABLE virtual_order_renewal_package_cards PARTITION OF virtual_order_cards_partition FOR VALUES IN (2);
|
CREATE TABLE virtual_order_renewal_package_cards PARTITION OF virtual_order_cards_partition FOR VALUES IN (2);
|
||||||
CREATE TABLE virtual_order_flows_package_cards PARTITION OF virtual_order_cards_partition FOR VALUES IN (3);
|
CREATE TABLE virtual_order_flows_package_cards PARTITION OF virtual_order_cards_partition FOR VALUES IN (3);
|
||||||
|
|
||||||
|
-- 唯一索引
|
||||||
CREATE UNIQUE INDEX "virtual_order_cards_order_id_sim_deleted_at_unique" ON "virtual_order_cards" (order_id, sim, COALESCE(deleted_at, '1970-01-01 08:00:00'::timestamp));
|
CREATE UNIQUE INDEX "virtual_order_cards_order_id_sim_deleted_at_unique" ON "virtual_order_cards" (order_id, sim, COALESCE(deleted_at, '1970-01-01 08:00:00'::timestamp));
|
||||||
CREATE UNIQUE INDEX "virtual_order_renewal_cards_order_id_sim_deleted_at_unique" ON "virtual_order_cards" (order_id, sim, COALESCE(deleted_at, '1970-01-01 08:00:00'::timestamp));
|
CREATE UNIQUE INDEX "virtual_order_renewal_cards_order_id_sim_deleted_at_unique" ON "virtual_order_renewal_cards" (order_id, sim, COALESCE(deleted_at, '1970-01-01 08:00:00'::timestamp));
|
||||||
CREATE UNIQUE INDEX "virtual_order_renewal_package_cards_order_id_sim_deleted_at_unique" ON "virtual_order_cards" (order_id, sim, COALESCE(deleted_at, '1970-01-01 08:00:00'::timestamp));
|
CREATE UNIQUE INDEX "virtual_order_renewal_package_cards_order_id_sim_deleted_at_unique" ON "virtual_order_renewal_package_cards" (order_id, sim, COALESCE(deleted_at, '1970-01-01 08:00:00'::timestamp));
|
||||||
CREATE UNIQUE INDEX "virtual_order_flows_package_cards_order_id_sim_deleted_at_unique" ON "virtual_order_cards" (order_id, sim, COALESCE(deleted_at, '1970-01-01 08:00:00'::timestamp));
|
CREATE UNIQUE INDEX "virtual_order_flows_package_cards_order_id_sim_deleted_at_unique" ON "virtual_order_flows_package_cards" (order_id, sim, COALESCE(deleted_at, '1970-01-01 08:00:00'::timestamp));
|
||||||
|
|
||||||
|
-- 服务周期索引
|
||||||
CREATE INDEX "virtual_order_cards_timelines_index" ON "virtual_order_cards" USING GIN (timelines_array(sim));
|
CREATE INDEX "virtual_order_cards_timelines_index" ON "virtual_order_cards" USING GIN (timelines_array(sim));
|
||||||
CREATE INDEX "virtual_order_renewal_cards_timelines_index" ON "virtual_order_renewal_cards" USING GIN (timelines_array(sim));
|
CREATE INDEX "virtual_order_renewal_cards_timelines_index" ON "virtual_order_renewal_cards" USING GIN (timelines_array(sim));
|
||||||
CREATE INDEX "virtual_order_renewal_package_cards_timelines_index" ON "virtual_order_renewal_package_cards" USING GIN (timelines_array(sim));
|
CREATE INDEX "virtual_order_renewal_package_cards_timelines_index" ON "virtual_order_renewal_package_cards" USING GIN (timelines_array(sim));
|
||||||
CREATE INDEX "virtual_order_flows_package_cards_index" ON "virtual_order_flows_package_cards" USING GIN (timelines_array(sim));
|
CREATE INDEX "virtual_order_flows_package_cards_index" ON "virtual_order_flows_package_cards" USING GIN (timelines_array(sim));
|
||||||
|
|
||||||
|
-- 增删改卡表时更新索引
|
||||||
CREATE OR REPLACE FUNCTION REINDEX_TIMELINES ()
|
CREATE OR REPLACE FUNCTION REINDEX_TIMELINES ()
|
||||||
RETURNS TRIGGER
|
RETURNS TRIGGER
|
||||||
AS $$
|
AS $$
|
||||||
@ -71,3 +79,11 @@ OR DELETE
|
|||||||
ON cards
|
ON cards
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
EXECUTE PROCEDURE REINDEX_TIMELINES ();
|
EXECUTE PROCEDURE REINDEX_TIMELINES ();
|
||||||
|
|
||||||
|
-- 优化多核心建立索引
|
||||||
|
ALTER TABLE virtual_order_cards SET (parallel_workers = 4);
|
||||||
|
ALTER TABLE virtual_order_renewal_cards SET (parallel_workers = 4);
|
||||||
|
ALTER TABLE virtual_order_renewal_package_cards SET (parallel_workers = 4);
|
||||||
|
ALTER TABLE virtual_order_flows_package_cards SET (parallel_workers = 4);
|
||||||
|
SET max_parallel_maintenance_workers TO 4;
|
||||||
|
SET maintenance_work_mem TO '2GB';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user