Commit 9f526217 by 周立明

脚本

1 parent 77af35c8
...@@ -2,6 +2,29 @@ ...@@ -2,6 +2,29 @@
### 陈希 -----------------end--------------------- ### 陈希 -----------------end---------------------
### 立明 -----------------start------------------- ### 立明 -----------------start-------------------
ALTER TABLE `dj_car_life_online_statement_account_trade_detail`
ADD COLUMN `division_order_code` varchar(32) NULL COMMENT '分账单编号' AFTER `gl_division_money`,
ADD COLUMN `reality_platform_merchant_id` int NULL COMMENT '实际分账平台方商户号' AFTER `division_date`,
ADD COLUMN `reality_platform_merchant_name` varchar(128) NULL COMMENT '实际分账平台方商户名称' AFTER `reality_platform_merchant_id`,
ADD COLUMN `estimated_arrival_time` varchar(10) NULL COMMENT '预计到账时间(分账日期+1个工作日)' AFTER `reality_platform_merchant_name`,
ADD INDEX `idx_division_order_code`(`division_order_code`);
CREATE TABLE `dj_car_life_online_statement_account_trade_distribution_detail` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`trade_detail_id` bigint(20) NOT NULL COMMENT '线上对账单交易明细ID',
`target_merchant_type` tinyint(2) NOT NULL COMMENT '分配对象类型(1:平台方;2:服务商;3:4s店)',
`reality_merchant_id` int(11) DEFAULT NULL COMMENT '实际商户号',
`reality_merchant_name` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '实际商户名称',
`division_money` decimal(11,2) NOT NULL COMMENT '分账金额',
`service_charge` decimal(11,2) NOT NULL COMMENT '手续费',
`created_by` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '创建人',
`created_date` datetime NOT NULL COMMENT '创建时间',
`updated_by` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '修改人',
`updated_date` datetime NOT NULL COMMENT '修改时间',
`deleted_flag` char(1) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '删除标示(D:已删除;N:未删除)',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='商户分账分配';
### 立明 -----------------end--------------------- ### 立明 -----------------end---------------------
### 彦峰 -----------------start------------------- ### 彦峰 -----------------start-------------------
......
...@@ -2,6 +2,54 @@ ...@@ -2,6 +2,54 @@
### 陈希 -----------------end--------------------- ### 陈希 -----------------end---------------------
### 立明 -----------------start------------------- ### 立明 -----------------start-------------------
update dj_car_life_online_statement_account_trade_detail a ,dj_car_life_order_division b
set a.reality_platform_merchant_id=b.reality_platform_merchant_id,a.reality_platform_merchant_name=b.reality_platform_merchant_name,
a.division_order_code=b.division_order_code
where a.pay_order_id=b.pay_order_id and a.deleted_flag='N' and b.deleted_flag='N' and b.division_type=2
and b.division_status=3 and a.division_order_code is null;
update dj_car_life_online_statement_account_trade_detail a ,dj_car_life_order_division b
set a.reality_platform_merchant_id=b.reality_platform_merchant_id,a.reality_platform_merchant_name=b.reality_platform_merchant_name,
a.division_order_code=b.division_order_code
where a.pay_order_id=b.pay_order_id and a.deleted_flag='N' and b.deleted_flag='N' and b.division_type=1
and b.division_status=3 and a.division_order_code is null;
update dj_car_life_online_statement_account_trade_detail a set a.estimated_arrival_time=(
select CONCAT(min(b.date),'') from dj_car_life_month_work_day_record b where b.deleted_flag='N' and b.date>DATE_FORMAT(a.division_date,'%Y-%m-%d') and is_not_work=0
) where deleted_flag='N' and a.estimated_arrival_time is null and a.division_date is not null;
insert into dj_car_life_online_statement_account_trade_distribution_detail(trade_detail_id,target_merchant_type,reality_merchant_id,reality_merchant_name,division_money,service_charge,created_by,created_date,updated_by,updated_date,deleted_flag)
select a.id,1,b.reality_platform_merchant_id,b.reality_platform_merchant_name, b.gl_division_money,
if(b.djzhy_sub_merchant_id is not null and b.djzhy_sub_merchant_id=b.fee_merchant_id,0,a.service_charge),
'system',NOW(),'system',now(),'N'
from dj_car_life_online_statement_account_trade_detail a
join dj_car_life_order_division b on b.division_order_code=a.division_order_code and b.deleted_flag='N'
where a.deleted_flag='N' AND b.gl_division_money>0;
insert into dj_car_life_online_statement_account_trade_distribution_detail(trade_detail_id,target_merchant_type,reality_merchant_id,reality_merchant_name,division_money,service_charge,created_by,created_date,updated_by,updated_date,deleted_flag)
select a.id,4,b.djzhy_sub_merchant_id,b.djzhy_sub_merchant_name, b.djzhy_sub_merchant_division_money,
if(b.djzhy_sub_merchant_id is not null and b.djzhy_sub_merchant_id=b.fee_merchant_id,a.service_charge,0),
'system',NOW(),'system',now(),'N'
from dj_car_life_online_statement_account_trade_detail a
join dj_car_life_order_division b on b.division_order_code=a.division_order_code and b.deleted_flag='N'
where a.deleted_flag='N' AND b.djzhy_sub_merchant_division_money>0;
insert into dj_car_life_online_statement_account_trade_distribution_detail(trade_detail_id,target_merchant_type,reality_merchant_id,reality_merchant_name,division_money,service_charge,created_by,created_date,updated_by,updated_date,deleted_flag)
select a.id,3,b.reality_shop_merchant_id,b.reality_shop_merchant_name, b.shop_division_money,0,'system',NOW(),'system',now(),'N'
from dj_car_life_online_statement_account_trade_detail a
join dj_car_life_order_division b on b.division_order_code=a.division_order_code and b.deleted_flag='N'
where a.deleted_flag='N' AND b.shop_division_money>0;
insert into dj_car_life_online_statement_account_trade_distribution_detail(trade_detail_id,target_merchant_type,reality_merchant_id,reality_merchant_name,division_money,service_charge,created_by,created_date,updated_by,updated_date,deleted_flag)
select a.id,2,b.reality_merchant_id,b.reality_merchant_name, b.division_money,0,'system',NOW(),'system',now(),'N'
from dj_car_life_merchant_distribution b
join dj_car_life_online_statement_account_trade_detail a on a.division_order_code=b.division_order_code and a.deleted_flag='N'
where b.deleted_flag='N' and b.target_merchant_type=2 and b.division_money>0
### 立明 -----------------end--------------------- ### 立明 -----------------end---------------------
### 彦峰 -----------------start------------------- ### 彦峰 -----------------start-------------------
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!