apzl_leasing/src_sql/procedure/proc_test_zyh.sql

48 lines
2.3 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

create procedure proc_test_zyh()
BEGIN
-- 记录试图vi_product备注
SELECT
lpi.id lpiid,
lpi.`PRODUCT_ID` lpiproductid,
bt.typename, -- 产品名称
psl.SPECIFICname, -- 规格信息 一个产品信息 1n 规格信息,只有一个状态可用版本
psl.versionid, -- 版本信息
psl.`leasform`,-- 租赁类型
psl.equip_type,-- 车辆类型
psl.is_all_dealer,-- 产品适用所有经销商
psl.is_all_dealer_group,-- 产品适用所经销商集
psl.is_all_area,-- 产品适用所有区域
lpc.carid, -- 车型id
lcm.modelid, -- 车型编号
lcm.modelname, -- 车型名称
di.id diid, -- 经销商id
di.`distributor_no` didistributor_no, -- 经销商编号
di.`distributor_name` didistributor_name, -- 经销商名称
di.PROVINCES, -- 经销商省份
di.city, -- 经销商城市
lpdg.`id` lpdgid, -- 经销商集团id
lpdg.`distributgroupid` , -- 经销商集体编号
lpdg.`distributgroupname` , -- 经销商集团名称
di1.distributor_no di1distributor_no, -- 经销商集团下的经销商编号
di1.distributor_name di1distributor_name, -- 经销商集团下的经销商名称
di1.PROVINCES di1PROVINCES, -- 经销商集团下的经销商省份
di1.city di1city, -- 经销商集团下的经销商城市
lpd.`districtid`, -- 区域编号
lpd.`districtname`, -- 区域名称
ddr.`distributor_name` -- 省份名称
FROM (SELECT * FROM business_type WHERE LENGTH(sortno)>4 ) bt
LEFT JOIN lb_product_info lpi ON lpi.`PRODUCT_ID`=bt.typeno
LEFT JOIN prd_specific_library psl ON psl.`PRODUCTID`=lpi.`PRODUCT_ID` AND psl.status=1
LEFT JOIN LM_PRODUCT_CAR lpc ON lpc.`PRODUCTID`=lpi.`PRODUCT_ID` -- 产品nn 车型,
LEFT JOIN `lb_cardata_model` lcm ON lcm.id=lpc.`CARID`
LEFT JOIN LM_DISTRIBUTOR_TO_PRODUCT ltp ON ltp.product_id=lpi.`PRODUCT_ID`
LEFT JOIN `distributor_info` di ON ltp.`DISTRIBUTOR_ID`=di.id -- 产品 n:n 经销商
LEFT JOIN LM_PRODUCT_DISTRIBUTOR_GROUP lpdg ON lpdg.productid=lpi.`PRODUCT_ID`
LEFT JOIN DISTRIBUTOR_GROUP_RELATION dgr ON lpdg.`distributgroupid`=dgr.`group_id` -- 经销商集团 1n 经销商
LEFT JOIN distributor_info di1 ON di1.id=dgr.`distributor_id`
LEFT JOIN LM_PRODUCT_DISTRICT lpd ON lpd.`productid`=lpi.`PRODUCT_ID` -- 产品 nn 区域
LEFT JOIN DISTRICT_DISTRIBUTOR_RELATION ddr ON ddr.`DISTRict_code`=lpd.`districtid` -- 区域 1 n 省份
;
END;