Commit 8eb2b85c by 杨林龙

添加审计数据库脚本

1 parent 22002c48
select * from dj_2022_settlment_order WHERE finance_time BETWEEN '2022-01-01 00:00:00' AND '2022-12-31 00:00:00' ;
select sum(total*(hw_unit_price+pk_unit_price+install_unit_price))
from dj_2022_settlment_order WHERE finance_time BETWEEN '2022-01-01 00:00:00' AND '2022-12-31 00:00:00' ;
SELECT sum(income) FROM dj_2022_settlment_order WHERE finance_time BETWEEN '2022-01-01 00:00:00' AND '2022-12-31 00:00:00';
SELECT * FROM dj_device_details;
SELECT count(1) FROM dj_device_details WHERE active_time IS NULL ;
SELECT sum(ifnull(pk_price,0) + ifnull(hw_price,0) + ifnull(install_price,0)) ,LEFT(settle_time,4),device_type FROM dj_device_details GROUP BY LEFT(settle_time,4),device_type;
SELECT sum(ifnull(pk_price,0) + ifnull(hw_price,0) + ifnull(install_price,0)) ,LEFT(settle_time,4),device_type FROM dj_device_details_return GROUP BY LEFT(settle_time,4),device_type;
SELECT sum(install_price) FROM glsx_data.dj_device_details WHERE device_type = 6;
SELECT count(1) FROM dj_device_details WHERE settle_merchant = '遵义市千汇汽车销售服务有限公司';
SELECT count(1) FROM dj_device_details WHERE settle_merchant = '遵义千汇汽车销售服务有限公司';
SELECT * FROM dj_device_details_return ;
SELECT channel as '渠道', settle_merchant as '结算客户',sn as '设备号',
case when device_type = 8 then 'GPS' when device_type = 6 then '记录仪' when device_type = 12501 then '车充' end as '设备类型',
settle_time as '结算时间', 0-pk_price as '套餐价格',
0-hw_price as '硬件价格', 0-install_price as '安装价格', active_time as '激活时间' FROM dj_device_details_return;
# 追踪器的
SELECT channel as '渠道', settle_merchant as '结算客户',sn as '设备号',
'GPS' as '设备类型',
settle_time as '结算时间', pk_price as '套餐价格',
hw_price as '硬件价格', install_price as '安装价格', active_time as '激活时间' FROM dj_device_details where device_type =8 AND active_time IS NULL ;
# 记录仪&车充
SELECT channel as '渠道', settle_merchant as '结算客户',sn as '设备号',
case when device_type = 6 then '记录仪' when device_type = 12501 then '车充' end as '设备类型',
settle_time as '结算时间', pk_price as '套餐价格',
hw_price as '硬件价格', install_price as '安装价格', active_time as '激活时间' FROM dj_device_details WHERE device_type IN (6,12501)and active_time IS NULL ;
SELECT dsm.merchant_id,dsm.`merchant_name`,dsm.`created_date` AS createTime
#FROM glsx_data.dj_device_details_20230801 d LEFT JOIN dj_system_merchant dsm ON d.active_merchant =dsm.merchant_name
FROM glsx_data.dj_device_details d LEFT JOIN dj_system_merchant dsm ON d.active_merchant =dsm.merchant_name
WHERE active_merchant <> '' AND dsm.`merchant_id` IS NOT NULL AND
((active_time < '2023-01-01 00:00:00' AND DATE_ADD(active_time,INTERVAL pk_period MONTH) > '2023-01-01 00:00:00') OR
(active_time >= '2023-01-01 00:00:00' AND active_time < '2023-06-30 23:59:59'))
GROUP BY dsm.`merchant_id`;
SELECT *FROM dj_system_merchant dsm WHERE dsm.merchant_name = '太原远方通贸易有限公司-DJ';
SELECT *FROM dj_system_merchant dsm WHERE dsm.merchant_name = '武汉大智行汽车用品有限公司';
SELECT *FROM dj_system_merchant dsm WHERE dsm.merchant_name = '济宁鸿昌汽车销售服务有限公司';
SELECT *FROM dj_system_merchant dsm WHERE dsm.merchant_name = '泰安鸿泰汽车销售服务有限公司';
SELECT *FROM dj_system_merchant dsm WHERE dsm.merchant_name = '太原远方通贸易有限公司1';
SELECT * FROM dj_device_details a WHERE a.active_merchant IN ('太原远方通贸易有限公司-DJ','武汉大智行汽车用品有限公司','济宁鸿昌汽车销售服务有限公司'
'泰安鸿泰汽车销售服务有限公司','太原远方通贸易有限公司1');
SELECT * FROM platform_common_merchant where merchant_name in(
'北京千品猫科技有限公司',
'成都万增商贸有限公司',
'非常品牌生活文化传播(茂名)有限公司',
'南昌领鑫信息咨询有限公司',
'宁夏吉源辉汽车信息咨询服务有限公司',
'宁夏亿兴汽车销售有限公司',
'上海贵谱信息科技有限公司',
'宿州市小家汽车服务有限公司',
'云南金鼎汽车贸易有限公司',
'遵义市千汇汽车销售服务有限公司',
'长春子煜商贸有限公司'
);
SELECT * FROM platform_common_merchant where merchant_name in(
'赣州广虹雷克萨斯汽车销售服务有限公司',
'南京福之鼎汽车服务有限公司',
'陕西悍途领驭科技有限公司'
);
SELECT * FROM platform_common_merchant where merchant_name in(
'贵州林荣汽车贸易股份有限公司',
'呼伦贝尔冀海汽车贸易有限公司',
'唐山光辉汽车销售服务有限公司',
'唐山弘德丰田汽车销售服务有限公司',
'唐山冀东丰田汽车销售服务有限公司',
'通辽庞大一众汽车销售服务有限公司',
'乌鲁木齐庞大腾众汽车销售有限公司',
'新疆大地汽车销售有限责任公司',
'张家口庞大铭盛汽车销售服务有限公司'
);
SELECT * FROM platform_common_merchant where merchant_name in(
'大连庞大华通汽车贸易有限公司',
'广州市饰和汽车有限公司',
'呼伦贝尔市庞大龙盛丰田汽车销售服务有限公司',
'荣成新广利丰田汽车销售服务有限公司',
'深圳市爱车有道汽车服务有限公司',
'昌吉庞大丰雅丰田汽车销售服务有限公司',
'承德市通程汽车销售有限公司',
'赤峰冀腾汽车贸易有限公司',
'定西恒信丰田汽车销售服务有限公司',
'衡阳市畅安汽车贸易有限公司',
'山西瑞车汇汽车服务有限公司',
'唐山庞大泰达汽车销售服务有限公司',
'新疆庞大本顺汽车销售服务有限公司',
'延边金山丰田汽车销售服务有限公司',
'保定庞大本瑞汽车销售服务有限公司',
'北京冀贵汽车贸易有限公司',
'北京来广营中冀汽车销售有限公司',
'北京五方桥丰田汽车销售服务有限公司',
'承德本祥汽车销售服务有限公司',
'邯郸市誉丰汽车销售有限责任公司',
'合肥云成汽车科技有限公司',
'沈阳庞大华通汽车贸易有限公司',
'太原庞大丰扬丰田汽车销售服务有限公司',
'唐山市庞大众跃汽车销售服务有限公司'
);
SELECT * FROM platform_common_merchant where merchant_name in(
'赤峰市冀东本峰汽车销售服务有限公司',
'大连友联电子有限公司',
'廊坊市庞大一众汽车销售服务有限公司',
'乌兰察布庞大弘翔丰田汽车销售服务有限公司',
'西宁中冀汽车销售有限公司',
'新疆政辉贸易有限公司',
'张家口市庞大一众汽车销售有限公司',
'张家口市庞大众腾汽车销售有限公司',
'浙江众联晟通国际贸易有限公司',
'武汉荣方科技有限公司'
);
--('GPS','OBD') ('记录仪','车充')
--dj_2022_settlment_order_finance_06plus
select A.cus_name,A.sale_type,A.monthx '月份',A.total '财务数量',B.total '商务数量',(A.total - B.total) as gap,A.income as '财务收入',
b.income as '商务收入', (A.income - b.income) as gapincome FROM
(
SELECT TRIM(cus_name) as cus_name, substr(finance_time,1,7) as monthx, sale_type,
SUM(case when product_type='硬件' then total else 0 end) as total,SUM(income) as income,SUM(cost) FROM dj_2023_settlment_order_finance
where device_type in ('GPS','OBD') and product_type in ('硬件','服务','安装') and business_type ='智慧门店SAAS服务'
GROUP BY cus_name, substr(finance_time,1,7),sale_type
) as A
LEFT JOIN
(
SELECT cus_name,monthx,SUM(tmp.totalx) as total,sum(tmp.incomex) as income from
(
SELECT TRIM(cus_name) as cus_name, substr(finance_time,1,7) as monthx, sale_type,
(case when product_type='硬件' then total else 0 end) as totalx,
(total*(hw_unit_price+pk_unit_price+install_unit_price)) as incomex
FROM dj_2023_settlment_order
where device_type in ('GPS','OBD') and product_type in ('硬件') and business_type ='智慧门店SAAS服务'
) tmp
GROUP BY tmp.cus_name, tmp.monthx,sale_type
)
as B ON (B.cus_name = A.cus_name AND a.monthx = B.monthx) HAVING gap = 0 and abs(gapincome) >1.0;
#('GPS','OBD') ('记录仪','车充')
-- GPS
select A.cus_name,A.sale_type,A.monthx '月份',A.total '财务数量',B.total '商务数量',(A.total - B.total) as gap,A.income as '财务收入',
b.income as '商务收入', (A.income - b.income) as gapincome ,A.costx '财务成本',B.costx '商务成本',(A.costx - b.costx) as gapcost FROM
(
SELECT TRIM(cus_name) as cus_name, DATE_FORMAT(finance_time, '%Y-%m') as monthx, sale_type,
SUM(case when product_type='硬件' then total else 0 end) as total,SUM(income) as income,SUM(cost) AS costx FROM dj_2023_settlment_order_finance
where device_type in ('GPS','OBD') and product_type in ('硬件','服务','安装') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2022-12-01'
GROUP BY cus_name, DATE_FORMAT(finance_time, '%Y-%m'),sale_type
) as A
LEFT JOIN
(
SELECT cus_name,monthx,SUM(tmp.totalx) as total,sum(tmp.incomex) as income,sum(costx) AS costx from
(
SELECT TRIM(cus_name) as cus_name, DATE_FORMAT(finance_time, '%Y-%m') as monthx, sale_type,
(case when product_type='硬件' then total else 0 end) as totalx,
(total*(IFNULL(hw_unit_price,0) + IFNULL(pk_unit_price,0)+IFNULL(install_unit_price,0) )) as incomex ,cost AS costx
FROM dj_2023_settlment_order
where device_type in ('GPS','OBD') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2022-12-01'
) tmp
GROUP BY tmp.cus_name, tmp.monthx,sale_type
)
as B ON (B.cus_name = A.cus_name AND a.monthx = B.monthx) HAVING abs(gapincome) > 1.0;
-- 记录仪
select A.cus_name,A.sale_type,A.monthx '月份',A.total '财务数量',B.total '商务数量',(A.total - B.total) as gap,A.income as '财务收入',
b.income as '商务收入', (A.income - b.income) as gapincome, A.costx '财务成本',B.costx '商务成本',(A.costx - b.costx) as gapcost FROM
(
SELECT TRIM(cus_name) as cus_name, DATE_FORMAT(finance_time, '%Y-%m') as monthx, sale_type,
SUM(case when product_type='硬件' then total else 0 end) as total,SUM(income) as income,SUM(cost) AS costx FROM dj_2023_settlment_order_finance
where device_type in ('记录仪','车充') and product_type in ('硬件','服务','安装') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2022-12-01'
GROUP BY cus_name, DATE_FORMAT(finance_time, '%Y-%m'),sale_type
) as A
LEFT JOIN
(
SELECT cus_name,monthx,SUM(tmp.totalx) as total,sum(tmp.incomex) as income,sum(costx) AS costx from
(
SELECT TRIM(cus_name) as cus_name, DATE_FORMAT(finance_time, '%Y-%m') as monthx, sale_type,
(case when product_type='硬件' then total else 0 end) as totalx,
(total*(IFNULL(hw_unit_price,0) + IFNULL(pk_unit_price,0)+IFNULL(install_unit_price,0) )) as incomex,cost AS costx
FROM dj_2023_settlment_order
where device_type in ('记录仪','车充') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2022-12-01'
) tmp
GROUP BY tmp.cus_name, tmp.monthx,sale_type
)
as B ON (B.cus_name = A.cus_name AND a.monthx = B.monthx) HAVING abs(gapincome) > 1.0;
SELECT * FROM dj_2023_settlment_order_finance
where device_type in ('记录仪','车充') and product_type in ('硬件','服务','安装') and business_type ='SAAS系统订阅服务—旧版本'
AND cus_name = '上海轩泽汽车用品有限公司' AND LEFT(finance_time,7) = '2023-06' ;
SELECT * FROM dj_2023_settlment_order
where device_type in ('记录仪','车充') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本'
AND cus_name = '上海轩泽汽车用品有限公司' AND LEFT(finance_time,7) = '2023-06';
SELECT * from dj_2022_settlment_order_06plus where sale_type = '直销' and device_type in ('GPS','OBD') and product_type = '硬件' and product_name<>'销售折扣' and status <> 1 and total < 0 order by finance_time desc
SELECT * FROM dj_2022_settlment_order_06plus where total < 0 and device_type in ('GPS','OBD','记录仪','车充') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2022-09-01'
and product_name <>'销售折扣'
'六盘水天驰汽车有限公司'
select id,sn,delivery_order,delivery_time,settle_merchant from dj_2021_settle_details where settle_merchant = '六盘水天驰汽车有限公司'
and delivery_time < '2022-12-31 00:00:00' order by delivery_time desc limit 8
SELECT * from dj_2022_settle_details_return where settle_time > '2022-09-01'
SELECT * FROM dj_2022_settlment_order_06plus where product_name = '销售折扣';
SELECT * FROM dj_2021_delivery_device WHERE customer_name <> '' and update_time >= '2023-01-12';
SELECT * FROM dj_2021_delivery_device limit 100
SELECT * from dj_2022_settlment_order_06plus where cus_name = '恒信汽车集团股份有限公司' and total < 0
SELECT * FROM dj_2022_settlment_order_06plus where `status` <> 1 and device_type in ('GPS','OBD','记录仪','车充') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2022-09-01'
SELECT device_type,COUNT(1) from dj_2021_settle_details where settle_merchant = '安徽优盾信息科技有限公司' GROUP BY device_type
select * from dj_system_merchant WHERE merchant_name in(
'北京千品猫科技有限公司',
'成都万增商贸有限公司',
'非常品牌生活文化传播(茂名)有限公司',
'南昌领鑫信息咨询有限公司',
'宁夏吉源辉汽车信息咨询服务有限公司',
'宁夏亿兴汽车销售有限公司',
'上海贵谱信息科技有限公司',
'宿州市小家汽车服务有限公司',
'云南金鼎汽车贸易有限公司',
'遵义市千汇汽车销售服务有限公司',
'长春子煜商贸有限公司'
);
select * from dj_system_merchant WHERE merchant_name in(
'赣州广虹雷克萨斯汽车销售服务有限公司',
'南京福之鼎汽车服务有限公司',
'陕西悍途领驭科技有限公司'
);
select * from dj_system_merchant WHERE merchant_name in(
'贵州林荣汽车贸易股份有限公司',
'呼伦贝尔冀海汽车贸易有限公司',
'唐山光辉汽车销售服务有限公司',
'唐山弘德丰田汽车销售服务有限公司',
'唐山冀东丰田汽车销售服务有限公司',
'通辽庞大一众汽车销售服务有限公司',
'乌鲁木齐庞大腾众汽车销售有限公司',
'新疆大地汽车销售有限责任公司',
'张家口庞大铭盛汽车销售服务有限公司'
);
SELECT * FROM dj_system_merchant dsm WHERE dsm.merchant_name = '唐山市庞大众跃汽车销售服务有限公司';
select * from dj_system_merchant WHERE merchant_name in(
'大连庞大华通汽车贸易有限公司',
'广州市饰和汽车有限公司',
'呼伦贝尔市庞大龙盛丰田汽车销售服务有限公司',
'荣成新广利丰田汽车销售服务有限公司',
'深圳市爱车有道汽车服务有限公司',
'昌吉庞大丰雅丰田汽车销售服务有限公司',
'承德市通程汽车销售有限公司',
'赤峰冀腾汽车贸易有限公司',
'定西恒信丰田汽车销售服务有限公司',
'衡阳市畅安汽车贸易有限公司',
'山西瑞车汇汽车服务有限公司',
'唐山庞大泰达汽车销售服务有限公司',
'新疆庞大本顺汽车销售服务有限公司',
'延边金山丰田汽车销售服务有限公司',
'保定庞大本瑞汽车销售服务有限公司',
'北京冀贵汽车贸易有限公司',
'北京来广营中冀汽车销售有限公司',
'北京五方桥丰田汽车销售服务有限公司',
'承德本祥汽车销售服务有限公司',
'邯郸市誉丰汽车销售有限责任公司',
'合肥云成汽车科技有限公司',
'沈阳庞大华通汽车贸易有限公司',
'太原庞大丰扬丰田汽车销售服务有限公司',
'唐山市庞大众跃汽车销售服务有限公司'
);
SELECT * FROM dj_system_merchant where merchant_name in(
'赤峰市冀东本峰汽车销售服务有限公司',
'大连友联电子有限公司',
'廊坊市庞大一众汽车销售服务有限公司',
'乌兰察布庞大弘翔丰田汽车销售服务有限公司',
'西宁中冀汽车销售有限公司',
'新疆政辉贸易有限公司',
'张家口市庞大一众汽车销售有限公司',
'张家口市庞大众腾汽车销售有限公司',
'浙江众联晟通国际贸易有限公司',
'武汉荣方科技有限公司'
);
SELECT * FROM dj_system_merchant where merchant_name in(
'安康庞大冀安汽车贸易有限公司',
'贵州斯巴鲁汽车销售服务有限公司',
'江西华兴斯巴鲁汽车销售有限公司'
);
SELECT * FROM dj_system_merchant where merchant_name in(
'江西华兴斯巴鲁汽车销售有限公司'
);
SELECT *FROM dj_system_merchant dsm WHERE merchant_name = '北京猎豹商贸有限责任公司';
SELECT * FROM dj_system_merchant where merchant_name in(
'赤峰市冀东本峰汽车销售服务有限公司',
'大连友联电子有限公司',
'廊坊市庞大一众汽车销售服务有限公司',
'乌兰察布庞大弘翔丰田汽车销售服务有限公司',
'西宁中冀汽车销售有限公司',
'新疆政辉贸易有限公司',
'张家口市庞大一众汽车销售有限公司',
'张家口市庞大众腾汽车销售有限公司',
'浙江众联晟通国际贸易有限公司',
'武汉荣方科技有限公司'
);
SELECT * FROM dj_system_merchant where merchant_name in(
'武汉荣方科技有限公司'
);
SELECT * FROM dj_car_maintain;
\ No newline at end of file
SELECT COUNT(1) FROM dj_device_details_return;
SELECT COUNT(1) FROM dj_device_details_return_20230724;
SELECT * FROM dj_2023_settle_details_return;
SELECT * FROM dj_device_details_return;
-- 合并2023年退货数据到生产退货表
INSERT INTO dj_device_details_return (channel,sn,device_type,delivery_time,delivery_merchant,active_time,active_merchant,pk_name,pk_period,settle_merchant,settle_order,settle_time,pk_price,hw_price,install_price,hw_cost,install_cost)
SELECT channel,sn,device_type,delivery_time,delivery_merchant,active_time,active_merchant,pk_name,pk_period,settle_merchant,settle_order,settle_time,pk_price,hw_price,install_price,hw_cost,install_cost
FROM dj_2023_settle_details_return;
SELECT * FROM dj_system_merchant;
-- DROP TABLE dj_system_merchant_20230725;
-- DROP TABLE dj_system_merchant;
CREATE TABLE dj_system_merchant_20230725 LIKE dj_system_merchant;
INSERT INTO dj_system_merchant_20230725 SELECT * FROM dj_system_merchant;
SELECT COUNT(1) FROM dj_system_merchant;
SELECT COUNT(1) FROM dj_system_merchant_20230725;
SELECT * FROM dj_2023_settlment_order;
SELECT * FROM dj_device_details ddd ;
-- 备份数据
-- DROP TABLE dj_car_maintain;
CREATE TABLE dj_car_maintain_20230727 LIKE dj_car_maintain;
INSERT INTO dj_car_maintain_20230727 SELECT * FROM dj_car_maintain;
select count(1) from dj_car_maintain;
select count(1) from dj_car_maintain_20230727;
-- DROP TABLE dj_car_shop_warning;
CREATE TABLE dj_car_shop_warning_20230727 LIKE dj_car_shop_warning;
INSERT INTO dj_car_shop_warning_20230727 SELECT * FROM dj_car_shop_warning;
select count(1) from dj_car_shop_warning;
select count(1) from dj_car_shop_warning_20230727;
alter table dj_car_shop_warning
drop column plate_number,
drop column name,
drop column mobile,
drop column vehicle_id;
-- DROP TABLE ddh_rescue_event;
CREATE TABLE ddh_rescue_event_20230727 LIKE ddh_rescue_event;
INSERT INTO ddh_rescue_event_20230727 SELECT * FROM ddh_rescue_event;
select count(1) from ddh_rescue_event;
select count(1) from ddh_rescue_event_20230727;
alter table ddh_rescue_event
drop column DEVICE_NAME,
drop column SPEED,
drop column HANDLE_RESULT,
drop column HANDLE_DATE,
drop column REMIND_FLAG,
drop column SYNC_FLAG,
drop column SYNC_DATE,
drop column OUTBOUND_MEMBER_ID,
drop column OUTBOUND_RESULT,
drop column OUTBOUND_RESULT_DATE,
drop column REMARK,
drop column ACCURATE,
drop column is_emphasis_merchant,
drop column is_show,
drop column DEVICE_ID,
drop column model_result;
SELECT count(1) FROM dj_car_collision;
SELECT * FROM dj_car_collision;
SELECT * FROM dj_car_maintain WHERE svrtime> '2023-01-01';
SELECT count(1) FROM dj_car_maintain WHERE svrtime >= '2023-01-01';
SELECT count(1) FROM dj_car_shop_warning WHERE trigger_time >= '2023-01-01';
SELECT count(1) FROM ddh_rescue_event WHERE EVENT_DATE >= '2023-01-01';
select merchant_name,settle_merchant_name from dj_system_merchant where settle_merchant_name <>'' AND settle_merchant_name = '上海镕谊商务咨询有限公司';
SELECT * FROM dj_2023_settlment_order_1;
SELECT * FROM dj_device_details_2306_dtt;
select cus_name,finance_time,sale_type,device_type,total,pk_name,pk_term,hw_unit_price,
pk_unit_price,install_unit_price,id from dj_2023_settlment_order_1 where match_status =0 and total > 0
and product_type = '硬件' and device_type in ('记录仪','车充','GPS', 'OBD')
order by finance_time,cus_name,device_type;
SELECT * FROM dj_2023_settlment_order_1 WHERE cus_name = '上海镕谊商务咨询有限公司';
SELECT * FROM dj_2023_settlment_order WHERE business_type = 'SAAS系统订阅服务—旧版本';
-- DELETE FROM dj_2023_settlment_order WHERE business_type <> 'SAAS系统订阅服务—旧版本';
-- 'SAAS系统订阅服务—旧版本'
SELECT * FROM dj_2023_settlment_order WHERE cus_name = '其他';
-- UPDATE dj_2023_settlment_order SET sale_type ='渠道' WHERE cus_name = '其他';
SELECT * FROM dj_2022_settlment_order_1 WHERE cus_name = '其他';
SELECT * FROM dj_2023_settlment_order_1 WHERE cus_name = '其他';
SELECT * FROM dj_system_merchant dsm WHERE merchant_name = '其他';
SELECT * FROM dj_system_merchant dsm WHERE settle_merchant_name = '其他';
SELECT * FROM dj_system_merchant_20230725 WHERE merchant_name = '其他';
SELECT * FROM dj_system_merchant_20230725 WHERE settle_merchant_name = '其他';
SELECT DATE_FORMAT(svrtime, '%Y-%m'),COUNT(*) FROM dj_car_maintain
GROUP BY DATE_FORMAT(svrtime, '%Y-%m') DESC;
SELECT DATE_FORMAT(trigger_time, '%Y-%m'),COUNT(*) FROM dj_car_shop_warning
GROUP BY DATE_FORMAT(trigger_time, '%Y-%m') DESC;
SELECT DATE_FORMAT(EVENT_DATE, '%Y-%m'),COUNT(*) FROM ddh_rescue_event
GROUP BY DATE_FORMAT(EVENT_DATE, '%Y-%m') DESC;
SELECT * FROM dj_basic_device_info_test_2306;
SELECT * FROM dj_device_details ddd WHERE ddd.settle_merchant = '其他';
select distinct a.cus_name
from dj_2023_settlment_order a
left join
(select distinct merchant_name from glsx_data.dj_system_merchant) b
on a.cus_name =b.merchant_name
where b.merchant_name is null
and a.sale_type ='直销';
select distinct a.cus_name
from dj_2023_settlment_order a
left join
(select distinct settle_merchant_name from dj_system_merchant) b
on a.cus_name = b.settle_merchant_name
where b.settle_merchant_name is null
and a.sale_type ='直销';
SELECT a.`id`,a.`sn`,a.`active_time`,a.`active_merchant`,a.`pk_period`,a.`pk_price`,
b.`id`,b.`sn`,b.`active_time`,b.`active_merchant`,b.`pk_period`,b.`pk_price`
FROM `dj_device_details_20230724` a
LEFT JOIN `dj_device_details` b ON b.`sn`=a.`sn`
WHERE a.`active_time`!=b.`active_time` OR a.`pk_period`!=b.`pk_period`;
SELECT a.`id`,a.`sn`,a.`active_time`,a.`active_merchant`,a.`pk_period`,a.`pk_price`,
b.`id`,b.`sn`,b.`active_time`,b.`active_merchant`,b.`pk_period`,b.`pk_price`
FROM `dj_device_details_20230724` a
LEFT JOIN `dj_device_details_20230801` b ON b.`sn`=a.`sn`
WHERE a.`active_time`!=b.`active_time` OR a.`pk_period`!=b.`pk_period`;
SELECT count(1)
FROM dj_device_details d LEFT JOIN dj_system_merchant dsm ON d.active_merchant =dsm.merchant_name
WHERE active_merchant <> '' AND dsm.`merchant_id` IS NOT NULL AND
((active_time < '2023-06-01 00:00:00' AND DATE_ADD(active_time,INTERVAL pk_period MONTH) > '2023-06-01 00:00:00') OR
(active_time >= '2023-06-01 00:00:00' AND active_time < '2023-06-31 23:59:59'));
-- 业务线:智慧门店
-- 门店名称:商户名称
-- 开始合作时间:首单激活时间/首单结算时间
-- 订单数量:设备数量
-- 订单金额:硬件+服务+安装
-- 2022只统计2022年的
SELECT '智慧门店' AS '业务线',
settle_merchant AS '门店名称',
LEAST(ifnull(min(active_time),'2022-12-31 11:59:59'),ifnull(min(settle_time),'2022-12-31 11:59:59')) AS '开始合作时间',
count(1) AS '订单数量',
sum(ifnull(install_price,0) +ifnull(pk_price,0) +ifnull(hw_price,0)) AS '订单金额'
FROM dj_device_details ddd
WHERE LEFT(settle_time,4)='2022' GROUP BY settle_merchant ORDER BY settle_time ;
SELECT '智慧门店' AS '业务线',
settle_merchant AS '门店名称',
LEAST(ifnull(min(active_time),'2022-12-31 11:59:59'),ifnull(min(settle_time),'2022-12-31 11:59:59')) AS '开始合作时间',
count(1) AS '订单数量',
sum(ifnull(install_price,0) +ifnull(pk_price,0) +ifnull(hw_price,0)) AS '订单金额'
FROM dj_device_details ddd
WHERE LEFT(settle_time,4)='2022' AND settle_merchant = '杭州天一汽车有限公司' GROUP BY settle_merchant ORDER BY settle_time ;
SELECT * FROM dj_device_details WHERE settle_merchant = '广州远晟汽车服务有限公司'
AND LEFT(settle_time,4)='2022' ORDER BY settle_time ;
SELECT min(active_time),min(settle_time),LEAST(min(active_time),min(settle_time))
FROM dj_device_details WHERE LEFT(settle_time,4)='2022'
AND settle_merchant = '杭州天一汽车有限公司';
SELECT active_time,settle_time FROM dj_device_details WHERE LEFT(settle_time,4)='2022'
AND settle_merchant = '上海泓合科技服务有限公司';
SELECT LEAST('2023-01-01 10:00:00', '2023-01-02 09:00:00') AS min_time;
--('GPS','OBD') ('记录仪','车充')
--dj_2022_settlment_order_finance_06plus
select A.cus_name,A.sale_type,A.monthx '月份',A.total '财务数量',B.total '商务数量',(A.total - B.total) as gap,A.income as '财务收入',
b.income as '商务收入', (A.income - b.income) as gapincome FROM
(
SELECT TRIM(cus_name) as cus_name, substr(finance_time,1,7) as monthx, sale_type,
SUM(case when product_type='硬件' then total else 0 end) as total,SUM(income) as income,SUM(cost) FROM dj_2024_settlment_order_finance
where device_type in ('GPS','OBD') and product_type in ('硬件','服务','安装') and business_type ='智慧门店SAAS服务'
GROUP BY cus_name, substr(finance_time,1,7),sale_type
) as A
LEFT JOIN
(
SELECT cus_name,monthx,SUM(tmp.totalx) as total,sum(tmp.incomex) as income from
(
SELECT TRIM(cus_name) as cus_name, substr(finance_time,1,7) as monthx, sale_type,
(case when product_type='硬件' then total else 0 end) as totalx,
(total*(hw_unit_price+pk_unit_price+install_unit_price)) as incomex
FROM dj_2024_settlment_order
where device_type in ('GPS','OBD') and product_type in ('硬件') and business_type ='智慧门店SAAS服务'
) tmp
GROUP BY tmp.cus_name, tmp.monthx,sale_type
)
as B ON (B.cus_name = A.cus_name AND a.monthx = B.monthx) HAVING gap = 0 and abs(gapincome) >1.0;
#('GPS','OBD') ('记录仪','车充')
-- GPS
select A.cus_name,A.sale_type,A.monthx '月份',A.total '财务数量',B.total '商务数量',(A.total - B.total) as gap,A.income as '财务收入',
b.income as '商务收入', (A.income - b.income) as gapincome ,A.costx '财务成本',B.costx '商务成本',(A.costx - b.costx) as gapcost FROM
(
SELECT TRIM(cus_name) as cus_name, DATE_FORMAT(finance_time, '%Y-%m') as monthx, sale_type,
SUM(case when product_type='硬件' then total else 0 end) as total,SUM(income) as income,SUM(cost) AS costx FROM dj_2024_settlment_order_finance
where device_type in ('GPS','OBD') and product_type in ('硬件','服务','安装') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2024-01-01'
GROUP BY cus_name, DATE_FORMAT(finance_time, '%Y-%m'),sale_type
) as A
LEFT JOIN
(
SELECT cus_name,monthx,SUM(tmp.totalx) as total,sum(tmp.incomex) as income,sum(costx) AS costx from
(
SELECT TRIM(cus_name) as cus_name, DATE_FORMAT(finance_time, '%Y-%m') as monthx, sale_type,
(case when product_type='硬件' then total else 0 end) as totalx,
(total*(IFNULL(hw_unit_price,0) + IFNULL(pk_unit_price,0)+IFNULL(install_unit_price,0) )) as incomex ,cost AS costx
FROM dj_2024_settlment_order
where device_type in ('GPS','OBD') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2024-01-01'
) tmp
GROUP BY tmp.cus_name, tmp.monthx,sale_type
)
as B ON (B.cus_name = A.cus_name AND a.monthx = B.monthx) HAVING abs(gapincome) > 1.0;
gap <> 0
abs(gapincome) > 1.0
-- 记录仪
select A.cus_name,A.sale_type,A.monthx '月份',A.total '财务数量',B.total '商务数量',(A.total - B.total) as gap,A.income as '财务收入',
b.income as '商务收入', (A.income - b.income) as gapincome, A.costx '财务成本',B.costx '商务成本',(A.costx - b.costx) as gapcost FROM
(
SELECT TRIM(cus_name) as cus_name, DATE_FORMAT(finance_time, '%Y-%m') as monthx, sale_type,
SUM(case when product_type='硬件' then total else 0 end) as total,SUM(income) as income,SUM(cost) AS costx FROM dj_2024_settlment_order_finance
where device_type in ('记录仪','车充') and product_type in ('硬件','服务','安装') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2024-01-01'
GROUP BY cus_name, DATE_FORMAT(finance_time, '%Y-%m'),sale_type
) as A
LEFT JOIN
(
SELECT cus_name,monthx,SUM(tmp.totalx) as total,sum(tmp.incomex) as income,sum(costx) AS costx from
(
SELECT TRIM(cus_name) as cus_name, DATE_FORMAT(finance_time, '%Y-%m') as monthx, sale_type,
(case when product_type='硬件' then total else 0 end) as totalx,
(total*(IFNULL(hw_unit_price,0) + IFNULL(pk_unit_price,0)+IFNULL(install_unit_price,0) )) as incomex,cost AS costx
FROM dj_2024_settlment_order
where device_type in ('记录仪','车充') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2024-01-01'
) tmp
GROUP BY tmp.cus_name, tmp.monthx,sale_type
)
as B ON (B.cus_name = A.cus_name AND a.monthx = B.monthx) HAVING abs(gapincome) > 1.0;
gap <> 0
abs(gapincome) > 1.0
SELECT * FROM dj_2023_settlment_order_finance
where device_type in ('记录仪','车充') and product_type in ('硬件','服务','安装') and business_type ='SAAS系统订阅服务—旧版本'
AND cus_name = '上海轩泽汽车用品有限公司' AND LEFT(finance_time,7) = '2023-06' ;
SELECT * FROM dj_2023_settlment_order
where device_type in ('记录仪','车充') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本'
AND cus_name = '上海轩泽汽车用品有限公司' AND LEFT(finance_time,7) = '2023-06';
SELECT * from dj_2022_settlment_order_06plus where sale_type = '直销' and device_type in ('GPS','OBD') and product_type = '硬件' and product_name<>'销售折扣' and status <> 1 and total < 0 order by finance_time desc
SELECT * FROM dj_2022_settlment_order_06plus where total < 0 and device_type in ('GPS','OBD','记录仪','车充') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2022-09-01'
and product_name <>'销售折扣'
'六盘水天驰汽车有限公司'
select id,sn,delivery_order,delivery_time,settle_merchant from dj_2021_settle_details where settle_merchant = '六盘水天驰汽车有限公司'
and delivery_time < '2022-12-31 00:00:00' order by delivery_time desc limit 8
SELECT * from dj_2022_settle_details_return where settle_time > '2022-09-01'
SELECT * FROM dj_2022_settlment_order_06plus where product_name = '销售折扣';
SELECT * FROM dj_2021_delivery_device WHERE customer_name <> '' and update_time >= '2023-01-12';
SELECT * FROM dj_2021_delivery_device limit 100
SELECT * from dj_2022_settlment_order_06plus where cus_name = '恒信汽车集团股份有限公司' and total < 0
SELECT * FROM dj_2022_settlment_order_06plus where `status` <> 1 and device_type in ('GPS','OBD','记录仪','车充') and product_type in ('硬件') and business_type ='SAAS系统订阅服务—旧版本' and finance_time>= '2022-09-01'
SELECT device_type,COUNT(1) from dj_2021_settle_details where settle_merchant = '安徽优盾信息科技有限公司' GROUP BY device_type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!