|
@@ -238,158 +238,162 @@
|
|
|
|
|
|
<select id="listCustomer" parameterType="CustomerInfo" resultMap="customerMap">
|
|
|
SELECT
|
|
|
- c.customer_id,
|
|
|
- c.customer_counsel_type,
|
|
|
- c.question_id,
|
|
|
- c.store_id,
|
|
|
- c.company_id,
|
|
|
- c.customer_in_TDS,
|
|
|
- c.customer_out_TDS,
|
|
|
- c.customer_is_solve,
|
|
|
- c.customer_is_visit,
|
|
|
- c.customer_create_time,
|
|
|
- c.customer_desc,
|
|
|
- c.customer_out_damaged,
|
|
|
- c.customer_secondary_customer,
|
|
|
- c.customer_last_id,
|
|
|
- c.customer_initial_id,
|
|
|
- c.customer_name,
|
|
|
- c.customer_tel,
|
|
|
- c.customer_wechat_name,
|
|
|
- c.customer_source_type,
|
|
|
- c.customer_source,
|
|
|
- c.customer_province_id as customerProvinceId,
|
|
|
- c.customer_city_id as customerCityId,
|
|
|
- c.customer_district_id as customerDistrictId,
|
|
|
- csc.small_class_name,
|
|
|
- t.type_name,
|
|
|
- a.admin_name,
|
|
|
- qd.describe_title,
|
|
|
- sc.company_name,
|
|
|
- si.store_name,
|
|
|
- v.visit_status,
|
|
|
- v.visit_complete_date,
|
|
|
- v.visit_name,
|
|
|
- v.visit_tel,
|
|
|
- v.visit_date,
|
|
|
- v.visit_time_select,
|
|
|
- v.visit_complete_name,
|
|
|
- v.visit_complete_tel,
|
|
|
- sa.admin_name AS visitDesignatedAdminName,
|
|
|
- sx.sendback_status AS backStatus,
|
|
|
- cc.relationSendLogisticsNo AS sendLogisticsNo,
|
|
|
- cc.relationSendLogisticsCompany AS sendLogisticsCompany,
|
|
|
- cc.relationBackLogisticsNo AS backLogisticsNo,
|
|
|
- cc.relationBackLogisticsCompany AS backLogisticsCompany,
|
|
|
- oi.sales_pay_time AS salesTime,
|
|
|
- cc.procMethodId as procMethodId,
|
|
|
- cc.procMethodName as procMethodName,
|
|
|
- cc.procTypeId as procTypeId,
|
|
|
- cc.procTypeName as procTypeName,
|
|
|
- cc.customerIsSolve as customerIsSolve,
|
|
|
- cc.procMethodIsBack as procMethodIsBack,
|
|
|
- cc.procMethodIsSend as procMethodIsSend,
|
|
|
- cc.relationId as relationId,
|
|
|
- ri.receivingOne as receivingOne,
|
|
|
- ri.receivingTwo as receivingTwo,
|
|
|
- cs.stayBackNum as stayBackNum,
|
|
|
- cs.beenReturnedNum as beenReturnedNum,
|
|
|
- cs.stayQcConfirmNum as stayQcConfirmNum,
|
|
|
- cs.placeOrderNum as placeOrderNum,
|
|
|
- cs.beenOrderedNum as beenOrderedNum,
|
|
|
- cs.beDetected as beDetected,
|
|
|
- cs.beMaintenance as beMaintenance,
|
|
|
- cs.beRefurbished as beRefurbished,
|
|
|
- cs.beScrapped as beScrapped,
|
|
|
- cs.beContact as beContact,
|
|
|
- cs.completeMaintenanceNum as completeMaintenanceNum,
|
|
|
- cs.beenScrappedNum as beenScrappedNum,
|
|
|
- cs.beenRenovatedNum as beenRenovatedNum,
|
|
|
- ti.tag_flag as tagFlag
|
|
|
+ c.customer_id,
|
|
|
+ c.customer_counsel_type,
|
|
|
+ c.question_id,
|
|
|
+ c.store_id,
|
|
|
+ c.company_id,
|
|
|
+ c.customer_in_TDS,
|
|
|
+ c.customer_out_TDS,
|
|
|
+ c.customer_is_solve,
|
|
|
+ c.customer_is_visit,
|
|
|
+ c.customer_create_time,
|
|
|
+ c.customer_desc,
|
|
|
+ c.customer_out_damaged,
|
|
|
+ c.customer_secondary_customer,
|
|
|
+ c.customer_last_id,
|
|
|
+ c.customer_initial_id,
|
|
|
+ c.customer_name,
|
|
|
+ c.customer_tel,
|
|
|
+ c.customer_wechat_name,
|
|
|
+ c.customer_source_type,
|
|
|
+ c.customer_source,
|
|
|
+ c.customer_province_id as customerProvinceId,
|
|
|
+ c.customer_city_id as customerCityId,
|
|
|
+ c.customer_district_id as customerDistrictId,
|
|
|
+ csc.small_class_name,
|
|
|
+ t.type_name,
|
|
|
+ a.admin_name,
|
|
|
+ qd.describe_title,
|
|
|
+ sc.company_name,
|
|
|
+ si.store_name,
|
|
|
+ v.visit_status,
|
|
|
+ v.visit_complete_date,
|
|
|
+ v.visit_name,
|
|
|
+ v.visit_tel,
|
|
|
+ v.visit_date,
|
|
|
+ v.visit_time_select,
|
|
|
+ v.visit_complete_name,
|
|
|
+ v.visit_complete_tel,
|
|
|
+ sa.admin_name AS visitDesignatedAdminName,
|
|
|
+ sx.sendback_status AS backStatus,
|
|
|
+ cc.relationSendLogisticsNo AS sendLogisticsNo,
|
|
|
+ cc.relationSendLogisticsCompany AS sendLogisticsCompany,
|
|
|
+ cc.relationBackLogisticsNo AS backLogisticsNo,
|
|
|
+ cc.relationBackLogisticsCompany AS backLogisticsCompany,
|
|
|
+ oi.sales_pay_time AS salesTime,
|
|
|
+ cc.procMethodId as procMethodId,
|
|
|
+ cc.procMethodName as procMethodName,
|
|
|
+ cc.procTypeId as procTypeId,
|
|
|
+ cc.procTypeName as procTypeName,
|
|
|
+ cc.customerIsSolve as customerIsSolve,
|
|
|
+ cc.procMethodIsBack as procMethodIsBack,
|
|
|
+ cc.procMethodIsSend as procMethodIsSend,
|
|
|
+ cc.relationId as relationId,
|
|
|
+ ri.receivingOne as receivingOne,
|
|
|
+ ri.receivingTwo as receivingTwo,
|
|
|
+ cs.stayBackNum as stayBackNum,
|
|
|
+ cs.beenReturnedNum as beenReturnedNum,
|
|
|
+ cs.stayQcConfirmNum as stayQcConfirmNum,
|
|
|
+ cs.placeOrderNum as placeOrderNum,
|
|
|
+ cs.beenOrderedNum as beenOrderedNum,
|
|
|
+ cs.beDetected as beDetected,
|
|
|
+ cs.beMaintenance as beMaintenance,
|
|
|
+ cs.beRefurbished as beRefurbished,
|
|
|
+ cs.beScrapped as beScrapped,
|
|
|
+ cs.beContact as beContact,
|
|
|
+ cs.completeMaintenanceNum as completeMaintenanceNum,
|
|
|
+ cs.beenScrappedNum as beenScrappedNum,
|
|
|
+ cs.beenRenovatedNum as beenRenovatedNum,
|
|
|
+ ti.tag_flag as tagFlag
|
|
|
FROM
|
|
|
tb_rst_cm_customer_info c
|
|
|
LEFT JOIN (
|
|
|
- SELECT
|
|
|
- xx.*
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT
|
|
|
- tb_rst_cm_proc_method.proc_type_id AS customerIsSolve,
|
|
|
- tb_rst_cm_relation.relation_id AS relationId,
|
|
|
- customer_id AS customerId,
|
|
|
- tb_rst_cm_relation_order.sales_id AS orderId,
|
|
|
- relation_send_logistics_no AS relationSendLogisticsNo,
|
|
|
- relation_send_logistics_company AS relationSendLogisticsCompany,
|
|
|
- relation_back_logistics_no AS relationBackLogisticsNo,
|
|
|
- relation_back_logistics_company AS relationBackLogisticsCompany,
|
|
|
- tb_rst_cm_proc_method.proc_method_id AS procMethodId,
|
|
|
- tb_rst_cm_proc_method.proc_method_name AS procMethodName,
|
|
|
- tb_rst_cm_proc_type.proc_type_id AS procTypeId,
|
|
|
- tb_rst_cm_proc_type.proc_type_name AS procTypeName,
|
|
|
- tb_rst_cm_proc_method.proc_method_is_back AS procMethodIsBack,
|
|
|
- tb_rst_cm_proc_method.proc_method_is_send AS procMethodIsSend
|
|
|
- FROM
|
|
|
- tb_rst_cm_relation
|
|
|
- LEFT JOIN tb_rst_cm_proc_method ON tb_rst_cm_proc_method.proc_method_id = tb_rst_cm_relation.proc_method_id
|
|
|
- LEFT JOIN tb_rst_cm_proc_type ON tb_rst_cm_proc_type.proc_type_id = tb_rst_cm_proc_method.proc_type_id
|
|
|
- LEFT JOIN tb_rst_cm_relation_order ON tb_rst_cm_relation_order.relation_id = tb_rst_cm_relation.relation_id
|
|
|
- ) xx
|
|
|
+ SELECT
|
|
|
+ xx.*
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ tb_rst_cm_proc_method.proc_type_id AS customerIsSolve,
|
|
|
+ tb_rst_cm_relation.relation_id AS relationId,
|
|
|
+ customer_id AS customerId,
|
|
|
+ tb_rst_cm_relation_order.sales_id AS orderId,
|
|
|
+ relation_send_logistics_no AS relationSendLogisticsNo,
|
|
|
+ relation_send_logistics_company AS relationSendLogisticsCompany,
|
|
|
+ relation_back_logistics_no AS relationBackLogisticsNo,
|
|
|
+ relation_back_logistics_company AS relationBackLogisticsCompany,
|
|
|
+ tb_rst_cm_proc_method.proc_method_id AS procMethodId,
|
|
|
+ tb_rst_cm_proc_method.proc_method_name AS procMethodName,
|
|
|
+ tb_rst_cm_proc_type.proc_type_id AS procTypeId,
|
|
|
+ tb_rst_cm_proc_type.proc_type_name AS procTypeName,
|
|
|
+ tb_rst_cm_proc_method.proc_method_is_back AS procMethodIsBack,
|
|
|
+ tb_rst_cm_proc_method.proc_method_is_send AS procMethodIsSend
|
|
|
+ FROM
|
|
|
+ tb_rst_cm_relation
|
|
|
+ LEFT JOIN tb_rst_cm_proc_method ON tb_rst_cm_proc_method.proc_method_id = tb_rst_cm_relation.proc_method_id
|
|
|
+ LEFT JOIN tb_rst_cm_proc_type ON tb_rst_cm_proc_type.proc_type_id = tb_rst_cm_proc_method.proc_type_id
|
|
|
+ LEFT JOIN tb_rst_cm_relation_order ON tb_rst_cm_relation_order.relation_id = tb_rst_cm_relation.relation_id
|
|
|
+ ) xx
|
|
|
) cc ON cc.customerId = c.customer_id
|
|
|
LEFT JOIN (
|
|
|
- SELECT
|
|
|
- sxx.sendback_status,sxx.customer_id
|
|
|
- FROM
|
|
|
- (
|
|
|
- SELECT ss.sendback_status,ss.customer_id from (
|
|
|
- select tb_rst_cm_sendback_info.sendback_status,tb_rst_cm_sendback_info.relation_id,tb_rst_cm_relation.customer_id
|
|
|
- FROM tb_rst_cm_sendback_info
|
|
|
- LEFT JOIN tb_rst_cm_relation on tb_rst_cm_relation.relation_id = tb_rst_cm_sendback_info.relation_id
|
|
|
- ORDER BY sendback_id desc
|
|
|
- ) ss
|
|
|
- GROUP BY ss.relation_id
|
|
|
- ) sxx
|
|
|
+ SELECT
|
|
|
+ sxx.sendback_status,sxx.customer_id
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT ss.sendback_status,ss.customer_id from (
|
|
|
+ select tb_rst_cm_sendback_info.sendback_status,tb_rst_cm_sendback_info.relation_id,tb_rst_cm_relation.customer_id
|
|
|
+ FROM tb_rst_cm_sendback_info
|
|
|
+ LEFT JOIN tb_rst_cm_relation on tb_rst_cm_relation.relation_id = tb_rst_cm_sendback_info.relation_id
|
|
|
+ ORDER BY sendback_id desc
|
|
|
+ ) ss
|
|
|
+ GROUP BY ss.relation_id
|
|
|
+ ) sxx
|
|
|
) sx ON sx.customer_id = c.customer_id
|
|
|
|
|
|
- LEFT JOIN (SELECT
|
|
|
- signclosed_id,
|
|
|
- signclosed_customer_id,
|
|
|
- signclosed_logistics_number,
|
|
|
- COUNT(
|
|
|
- CASE signclosed_is_receiving
|
|
|
- WHEN 1 THEN
|
|
|
- 1
|
|
|
- END
|
|
|
- ) AS receivingOne,
|
|
|
- COUNT(
|
|
|
- CASE signclosed_is_receiving
|
|
|
- WHEN 2 THEN
|
|
|
- 2
|
|
|
- END
|
|
|
- ) AS receivingTwo
|
|
|
- FROM
|
|
|
- tb_rst_complaint_signclosed
|
|
|
- GROUP BY
|
|
|
- signclosed_customer_id) ri ON ri.signclosed_customer_id = c.customer_id
|
|
|
- LEFT JOIN (SELECT
|
|
|
- detect_id,
|
|
|
- customer_id,
|
|
|
- sum(case when (detect_state in (33,37) and detect_placeorder = 1) then 1 else 0 end) as stayBackNum,
|
|
|
- sum(case when (detect_state in (33,37) and detect_placeorder = 2) then 1 else 0 end) as beenReturnedNum,
|
|
|
- sum(case when (detect_state in (32,36) and maintenance_results = 2) then 1 else 0 end) as stayQcConfirmNum,
|
|
|
- sum(case when (detect_state in (32,36) and maintenance_results = 1 and detect_placeorder = 1) then 1 else 0 end) as placeOrderNum,
|
|
|
- sum(case when (detect_state in (32,36) and maintenance_results = 1 and detect_placeorder = 2) then 1 else 0 end) as beenOrderedNum,
|
|
|
- COUNT(CASE detect_state WHEN 1 THEN 1 END) AS beDetected,
|
|
|
- COUNT(case detect_state when 31 then 1 when 35 then 1 end) as beMaintenance,
|
|
|
- COUNT(case detect_state when 20 then 1 end) as beRefurbished,
|
|
|
- COUNT(case detect_state when 22 then 1 end) as beScrapped,
|
|
|
- COUNT(case detect_state when 30 then 1 when 34 then 1 WHEN 38 then 1 end) as beContact,
|
|
|
- COUNT(case detect_state when 32 then 1 when 36 then 1 end) as completeMaintenanceNum,
|
|
|
- COUNT(case detect_state when 23 then 1 end) as beenScrappedNum,
|
|
|
- COUNT(case detect_state when 21 then 1 end) as beenRenovatedNum
|
|
|
- FROM
|
|
|
- tb_rst_complaint_detect
|
|
|
- GROUP BY
|
|
|
- customer_id) cs ON cs.customer_id = c.customer_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ signclosed_id,
|
|
|
+ signclosed_customer_id,
|
|
|
+ signclosed_logistics_number,
|
|
|
+ COUNT(
|
|
|
+ CASE signclosed_is_receiving
|
|
|
+ WHEN 1 THEN
|
|
|
+ 1
|
|
|
+ END
|
|
|
+ ) AS receivingOne,
|
|
|
+ COUNT(
|
|
|
+ CASE signclosed_is_receiving
|
|
|
+ WHEN 2 THEN
|
|
|
+ 2
|
|
|
+ END
|
|
|
+ ) AS receivingTwo
|
|
|
+ FROM
|
|
|
+ tb_rst_complaint_signclosed
|
|
|
+ GROUP BY
|
|
|
+ signclosed_customer_id
|
|
|
+ ) ri ON ri.signclosed_customer_id = c.customer_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ detect_id,
|
|
|
+ customer_id,
|
|
|
+ sum(case when (detect_state in (33,37) and detect_placeorder = 1) then 1 else 0 end) as stayBackNum,
|
|
|
+ sum(case when (detect_state in (33,37) and detect_placeorder = 2) then 1 else 0 end) as beenReturnedNum,
|
|
|
+ sum(case when (detect_state in (32,36) and maintenance_results = 2) then 1 else 0 end) as stayQcConfirmNum,
|
|
|
+ sum(case when (detect_state in (32,36) and maintenance_results = 1 and detect_placeorder = 1) then 1 else 0 end) as placeOrderNum,
|
|
|
+ sum(case when (detect_state in (32,36) and maintenance_results = 1 and detect_placeorder = 2) then 1 else 0 end) as beenOrderedNum,
|
|
|
+ COUNT(CASE detect_state WHEN 1 THEN 1 END) AS beDetected,
|
|
|
+ COUNT(case detect_state when 31 then 1 when 35 then 1 end) as beMaintenance,
|
|
|
+ COUNT(case detect_state when 20 then 1 end) as beRefurbished,
|
|
|
+ COUNT(case detect_state when 22 then 1 end) as beScrapped,
|
|
|
+ COUNT(case detect_state when 30 then 1 when 34 then 1 WHEN 38 then 1 end) as beContact,
|
|
|
+ COUNT(case detect_state when 32 then 1 when 36 then 1 end) as completeMaintenanceNum,
|
|
|
+ COUNT(case detect_state when 23 then 1 end) as beenScrappedNum,
|
|
|
+ COUNT(case detect_state when 21 then 1 end) as beenRenovatedNum
|
|
|
+ FROM
|
|
|
+ tb_rst_complaint_detect
|
|
|
+ GROUP BY
|
|
|
+ customer_id
|
|
|
+ ) cs ON cs.customer_id = c.customer_id
|
|
|
LEFT JOIN tb_rst_cm_visit v ON v.customer_id = c.customer_id
|
|
|
LEFT JOIN tb_rst_sales_order_info oi ON cc.orderId = oi.sales_id
|
|
|
LEFT JOIN tb_rst_cm_question_describe qd ON c.customer_id = qd.customer_id
|
|
@@ -497,7 +501,7 @@
|
|
|
and cd.detect_state in(32,33,36,37)
|
|
|
</if>
|
|
|
<if test="afterState != null and afterState == 7">
|
|
|
- and cd.detect_state in(33,37) and cd.detect_placeorder = 1
|
|
|
+ and cd.detect_state in(33,37,39) and cd.detect_placeorder = 1
|
|
|
</if>
|
|
|
<if test="afterState != null and afterState == 8">
|
|
|
and cd.detect_state in(32,36) and cd.detect_placeorder = 1 AND maintenance_results = 1
|