|
@@ -471,4 +471,349 @@
|
|
|
|
|
|
ORDER BY c.customer_id desc
|
|
|
</select>
|
|
|
+
|
|
|
+ <!-- 导出客诉信息到excel -->
|
|
|
+ <select id="listStatisticalCustomer" resultType="CustomerStatisticalInfo">
|
|
|
+SELECT
|
|
|
+ c.customer_id customerId,
|
|
|
+ cc.orderId orderId,
|
|
|
+ DATE_FORMAT(c.customer_create_time,'%Y-%m-%d') AS createTime,
|
|
|
+ c.customer_name AS customerName,
|
|
|
+ c.customer_tel AS customerTel,
|
|
|
+(CASE
|
|
|
+WHEN c.customer_counsel_type = 1 THEN
|
|
|
+ '售前咨询'
|
|
|
+WHEN c.customer_counsel_type = 2 THEN
|
|
|
+ '售后咨询'
|
|
|
+WHEN c.customer_counsel_type = 3 THEN
|
|
|
+ '其它'
|
|
|
+ELSE
|
|
|
+ '未知'
|
|
|
+END) AS counselType,
|
|
|
+(CASE
|
|
|
+WHEN c.customer_source_type = 1 THEN
|
|
|
+ '400电话'
|
|
|
+WHEN c.customer_source_type = 2 THEN
|
|
|
+ '微信公众号'
|
|
|
+WHEN c.customer_source_type = 3 THEN
|
|
|
+ '其它'
|
|
|
+ELSE
|
|
|
+ '未知'
|
|
|
+END) AS sourceType,
|
|
|
+ct.complaint_class_name as complaintClassName,
|
|
|
+csc.small_class_name as smallClassName,
|
|
|
+qd.describe_title as describeTitle,
|
|
|
+qd.describe_handle_desc as describeHandleDesc,
|
|
|
+(CASE
|
|
|
+WHEN c.customer_is_solve = 1 THEN
|
|
|
+ '已解决'
|
|
|
+WHEN c.customer_is_solve = 2 THEN
|
|
|
+ '未解决'
|
|
|
+WHEN c.customer_is_solve = 3 THEN
|
|
|
+ '换新'
|
|
|
+WHEN c.customer_is_solve = 4 THEN
|
|
|
+ '维修'
|
|
|
+WHEN c.customer_is_solve = 5 THEN
|
|
|
+ '补发'
|
|
|
+WHEN c.customer_is_solve = 6 THEN
|
|
|
+ '退货'
|
|
|
+WHEN c.customer_is_solve = 7 THEN
|
|
|
+ '无理由退货'
|
|
|
+ELSE
|
|
|
+ '未知'
|
|
|
+END) AS customerIsSolve,
|
|
|
+DATE_FORMAT(oi.sales_pay_time,'%Y-%m-%d') AS salesPayTime,
|
|
|
+sc.company_name AS companyName,
|
|
|
+si.store_name AS storeName,
|
|
|
+soi.item_product_name AS itemProductName,
|
|
|
+soi.item_product_color as itemProductColor,
|
|
|
+soi.item_num as itemNum,
|
|
|
+(CASE
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'sto' THEN
|
|
|
+ '申通快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'yto' THEN
|
|
|
+ '圆通快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'sf' THEN
|
|
|
+ '顺丰快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'ems' THEN
|
|
|
+ '邮政EMS'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'zto' THEN
|
|
|
+ '中通快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'zjs' THEN
|
|
|
+ '宅急送'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'yunda' THEN
|
|
|
+ '韵达快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'cces' THEN
|
|
|
+ 'cces快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'pick' THEN
|
|
|
+ '上门提货'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'htky' THEN
|
|
|
+ '汇通快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'ttkdex' THEN
|
|
|
+ '天天快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'stars' THEN
|
|
|
+ '星晨急便'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'jd' THEN
|
|
|
+ '京东快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'dbkd' THEN
|
|
|
+ '德邦快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = '02' THEN
|
|
|
+ '上门送货'
|
|
|
+WHEN cc.relationBackLogisticsCompany = 'lianhaowuliu' THEN
|
|
|
+ '联昊通'
|
|
|
+ELSE
|
|
|
+ '未知'
|
|
|
+END) AS relationBackLogisticsCompany,
|
|
|
+cc.relationBackLogisticsNo AS relationBackLogisticsNo,
|
|
|
+DATE_FORMAT(cc.relationBackReceiptDate,'%Y-%m-%d') AS relationBackReceiptDate,
|
|
|
+(CASE
|
|
|
+WHEN cc.relationBackStatus = 1 THEN
|
|
|
+ '未寄回'
|
|
|
+WHEN cc.relationBackStatus = 2 THEN
|
|
|
+ '已寄回'
|
|
|
+WHEN cc.relationBackStatus = 3 THEN
|
|
|
+ '已收货'
|
|
|
+ELSE
|
|
|
+ '未知'
|
|
|
+END) AS relationBackStatus,
|
|
|
+(CASE
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'sto' THEN
|
|
|
+ '申通快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'yto' THEN
|
|
|
+ '圆通快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'sf' THEN
|
|
|
+ '顺丰快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'ems' THEN
|
|
|
+ '邮政EMS'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'zto' THEN
|
|
|
+ '中通快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'zjs' THEN
|
|
|
+ '宅急送'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'yunda' THEN
|
|
|
+ '韵达快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'cces' THEN
|
|
|
+ 'cces快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'pick' THEN
|
|
|
+ '上门提货'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'htky' THEN
|
|
|
+ '汇通快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'ttkdex' THEN
|
|
|
+ '天天快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'stars' THEN
|
|
|
+ '星晨急便'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'jd' THEN
|
|
|
+ '京东快递'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'dbkd' THEN
|
|
|
+ '德邦快递'
|
|
|
+WHEN cc.relationBackLogisticsCompany = '02' THEN
|
|
|
+ '上门送货'
|
|
|
+WHEN cc.relationSendLogisticsCompany = 'lianhaowuliu' THEN
|
|
|
+ '联昊通'
|
|
|
+ELSE
|
|
|
+ '未知'
|
|
|
+END) AS relationSendLogisticsCompany,
|
|
|
+cc.relationSendLogisticsNo AS relationSendLogisticsNo,
|
|
|
+(CASE
|
|
|
+WHEN c.customer_out_damaged = 1 THEN
|
|
|
+ '是'
|
|
|
+WHEN c.customer_out_damaged = 2 THEN
|
|
|
+ '否'
|
|
|
+ELSE
|
|
|
+ '未知'
|
|
|
+END) AS customerOutDamaged,
|
|
|
+(CASE
|
|
|
+WHEN c.customer_secondary_customer = 1 THEN
|
|
|
+ '是'
|
|
|
+WHEN c.customer_secondary_customer = 2 THEN
|
|
|
+ '否'
|
|
|
+ELSE
|
|
|
+ '未知'
|
|
|
+END) AS customerSecondaryCustomer
|
|
|
+FROM
|
|
|
+ tb_rst_customer_info c
|
|
|
+LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ '3' AS customerIsSolve,
|
|
|
+ renewed_id AS relationId,
|
|
|
+ customer_id AS customerId,
|
|
|
+ tb_rst_relation_order.sales_id AS orderId,
|
|
|
+ signclosed_id AS signclosedId,
|
|
|
+ renewed_back_efast_order_id AS relationBackEfastOrderId,
|
|
|
+ renewed_back_name AS relationBackName,
|
|
|
+ renewed_back_tel AS relationBackTel,
|
|
|
+ renewed_back_status AS relationBackStatus,
|
|
|
+ renewed_back_logistics_company AS relationBackLogisticsCompany,
|
|
|
+ renewed_back_logistics_no AS relationBackLogisticsNo,
|
|
|
+ renewed_back_postage AS relationBackPostage,
|
|
|
+ renewed_back_machine_no AS relationBackMachineNo,
|
|
|
+ renewed_send_status AS relationSendStatus,
|
|
|
+ renewed_send_name AS relationSendName,
|
|
|
+ renewed_send_tel AS relationSendTel,
|
|
|
+ province_number AS provinceNumber,
|
|
|
+ city_number AS cityNumber,
|
|
|
+ area_number AS areaNumber,
|
|
|
+ renewed_send_merge_address AS relationSendMergeAddress,
|
|
|
+ renewed_send_address AS relationSendAddress,
|
|
|
+ renewed_send_logistics_company AS relationSendLogisticsCompany,
|
|
|
+ renewed_send_logistics_no AS relationSendLogisticsNo,
|
|
|
+ renewed_desc AS relationDesc,
|
|
|
+ renewed_state AS relationState,
|
|
|
+ renewed_alipay AS relationAlipay,
|
|
|
+ renewed_is_transfer AS relationIsTransfer,
|
|
|
+ renewed_alipay_name AS relationAlipayName,
|
|
|
+ renewed_back_receipt_date AS relationBackReceiptDate
|
|
|
+ FROM
|
|
|
+ tb_rst_renewed
|
|
|
+ LEFT JOIN tb_rst_relation_order on tb_rst_relation_order.relation_id = tb_rst_renewed.renewed_id
|
|
|
+ where tb_rst_relation_order.relation_type = '3'
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ '4' AS customerIsSolve,
|
|
|
+ repair_id AS relationId,
|
|
|
+ customer_id AS customerId,
|
|
|
+ tb_rst_relation_order.sales_id AS orderId,
|
|
|
+ signclosed_id AS signclosedId,
|
|
|
+ repair_back_efast_order_id AS relationBackEfastOrderId,
|
|
|
+ repair_back_name AS relationBackName,
|
|
|
+ repair_back_tel AS relationBackTel,
|
|
|
+ repair_back_status AS relationBackStatus,
|
|
|
+ repair_back_logistics_company AS relationBackLogisticsCompany,
|
|
|
+ repair_back_logistics_no AS relationBackLogisticsNo,
|
|
|
+ repair_back_postage AS relationBackPostage,
|
|
|
+ repair_back_machine_no AS relationBackMachineNo,
|
|
|
+ repair_send_status AS relationSendStatus,
|
|
|
+ repair_send_name AS relationSendName,
|
|
|
+ repair_send_tel AS relationSendTel,
|
|
|
+ province_number AS provinceNumber,
|
|
|
+ city_number AS cityNumber,
|
|
|
+ area_number AS areaNumber,
|
|
|
+ repair_send_merge_address AS relationSendMergeAddress,
|
|
|
+ repair_send_address AS relationSendAddress,
|
|
|
+ repair_send_logistics_company AS relationSendLogisticsCompany,
|
|
|
+ repair_send_logistics_no AS relationSendLogisticsNo,
|
|
|
+ repair_desc AS relationDesc,
|
|
|
+ repair_state AS relationState,
|
|
|
+ repair_alipay AS relationAlipay,
|
|
|
+ repair_is_transfer AS relationIsTransfer,
|
|
|
+ repair_alipay_name AS relationAlipayName,
|
|
|
+ repair_back_receipt_date AS relationBackReceiptDate
|
|
|
+ FROM
|
|
|
+ tb_rst_repair
|
|
|
+ LEFT JOIN tb_rst_relation_order on tb_rst_relation_order.relation_id = tb_rst_repair.repair_id
|
|
|
+ where tb_rst_relation_order.relation_type = '4'
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ '5' AS customerIsSolve,
|
|
|
+ reissue_id AS relationId,
|
|
|
+ customer_id AS customerId,
|
|
|
+ tb_rst_relation_order.sales_id AS orderId,
|
|
|
+ NULL AS signclosedId,
|
|
|
+ reissue_back_efast_order_id AS relationBackEfastOrderId,
|
|
|
+ NULL AS relationBackName,
|
|
|
+ NULL AS relationBackTel,
|
|
|
+ NULL AS relationBackStatus,
|
|
|
+ NULL AS relationBackLogisticsCompany,
|
|
|
+ NULL AS relationBackLogisticsNo,
|
|
|
+ NULL AS relationBackPostage,
|
|
|
+ NULL AS relationBackMachineNo,
|
|
|
+ reissue_send_status AS relationSendStatus,
|
|
|
+ reissue_send_name AS relationSendName,
|
|
|
+ reissue_send_tel AS relationSendTel,
|
|
|
+ province_number AS provinceNumber,
|
|
|
+ city_number AS cityNumber,
|
|
|
+ area_number AS areaNumber,
|
|
|
+ reissue_send_merge_address AS relationSendMergeAddress,
|
|
|
+ reissue_send_address AS relationSendAddress,
|
|
|
+ reissue_send_logistics_company AS relationSendLogisticsCompany,
|
|
|
+ reissue_send_logistics_no AS relationSendLogisticsNo,
|
|
|
+ reissue_desc AS relationDesc,
|
|
|
+ reissue_state AS relationState,
|
|
|
+ NULL AS relationAlipay,
|
|
|
+ NULL AS relationIsTransfer,
|
|
|
+ NULL AS relationAlipayName,
|
|
|
+ NULL AS relationBackReceiptDate
|
|
|
+ FROM
|
|
|
+ tb_rst_reissue
|
|
|
+ LEFT JOIN tb_rst_relation_order on tb_rst_relation_order.relation_id = tb_rst_reissue.reissue_id
|
|
|
+ where tb_rst_relation_order.relation_type = '5'
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ '6' AS customerIsSolve,
|
|
|
+ back_goods_id AS relationId,
|
|
|
+ customer_id AS customerId,
|
|
|
+ tb_rst_relation_order.sales_id AS orderId,
|
|
|
+ signclosed_id AS signclosedId,
|
|
|
+ NULL AS relationBackEfastOrderId,
|
|
|
+ back_goods_back_name AS relationBackName,
|
|
|
+ back_goods_back_tel AS relationBackTel,
|
|
|
+ back_goods_back_status AS relationBackStatus,
|
|
|
+ back_goods_back_logistics_company AS relationBackLogisticsCompany,
|
|
|
+ back_goods_back_logistics_no AS relationBackLogisticsNo,
|
|
|
+ back_goods_back_postage AS relationBackPostage,
|
|
|
+ back_goods_back_machine_no AS relationBackMachineNo,
|
|
|
+ NULL AS relationSendStatus,
|
|
|
+ NULL AS relationSendName,
|
|
|
+ NULL AS relationSendTel,
|
|
|
+ NULL AS provinceNumber,
|
|
|
+ NULL AS cityNumber,
|
|
|
+ NULL AS areaNumber,
|
|
|
+ NULL AS relationSendMergeAddress,
|
|
|
+ NULL AS relationSendAddress,
|
|
|
+ NULL AS relationSendLogisticsCompany,
|
|
|
+ NULL AS relationSendLogisticsNo,
|
|
|
+ back_goods_desc AS relationDesc,
|
|
|
+ back_goods_state AS relationState,
|
|
|
+ back_goods_alipay AS relationAlipay,
|
|
|
+ back_goods_is_transfer AS relationIsTransfer,
|
|
|
+ back_goods_alipay_name AS relationAlipayName,
|
|
|
+ back_goods_back_receipt_date AS relationBackReceiptDate
|
|
|
+ FROM
|
|
|
+ tb_rst_back_goods
|
|
|
+ LEFT JOIN tb_rst_relation_order on tb_rst_relation_order.relation_id = tb_rst_back_goods.back_goods_id
|
|
|
+ where tb_rst_relation_order.relation_type = '6'
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ '7' AS customerIsSolve,
|
|
|
+ noreason_back_id AS relationId,
|
|
|
+ customer_id AS customerId,
|
|
|
+ tb_rst_relation_order.sales_id AS orderId,
|
|
|
+ signclosed_id AS signclosedId,
|
|
|
+ NULL AS relationBackEfastOrderId,
|
|
|
+ noreason_back_back_name AS relationBackName,
|
|
|
+ noreason_back_back_tel AS relationBackTel,
|
|
|
+ noreason_back_back_status AS relationBackStatus,
|
|
|
+ noreason_back_back_logistics_company AS relationBackLogisticsCompany,
|
|
|
+ noreason_back_back_logistics_no AS relationBackLogisticsNo,
|
|
|
+ noreason_back_back_postage AS relationBackPostage,
|
|
|
+ noreason_back_back_machine_no AS relationBackMachineNo,
|
|
|
+ NULL AS relationSendStatus,
|
|
|
+ NULL AS relationSendName,
|
|
|
+ NULL AS relationSendTel,
|
|
|
+ NULL AS provinceNumber,
|
|
|
+ NULL AS cityNumber,
|
|
|
+ NULL AS areaNumber,
|
|
|
+ NULL AS relationSendMergeAddress,
|
|
|
+ NULL AS relationSendAddress,
|
|
|
+ NULL AS relationSendLogisticsCompany,
|
|
|
+ NULL AS relationSendLogisticsNo,
|
|
|
+ noreason_back_desc AS relationDesc,
|
|
|
+ noreason_back_state AS relationState,
|
|
|
+ noreason_back_alipay AS relationAlipay,
|
|
|
+ noreason_back_is_transfer AS relationIsTransfer,
|
|
|
+ noreason_back_alipay_name AS relationAlipayName,
|
|
|
+ noreason_back_receipt_date AS relationBackReceiptDate
|
|
|
+ FROM
|
|
|
+ tb_rst_noreason_back
|
|
|
+ LEFT JOIN tb_rst_relation_order on tb_rst_relation_order.relation_id = tb_rst_noreason_back.noreason_back_id
|
|
|
+ where tb_rst_relation_order.relation_type = '7'
|
|
|
+ ) cc ON cc.customerId = c.customer_id
|
|
|
+LEFT JOIN tb_rst_sales_order_info oi ON cc.orderId = oi.sales_id
|
|
|
+LEFT JOIN tb_rst_question_describe qd ON c.customer_id = qd.customer_id
|
|
|
+LEFT JOIN tb_rst_complaint_question cq ON c.question_id = cq.question_id
|
|
|
+LEFT JOIN tb_rst_complaint_small_class csc ON csc.small_class_id = cq.small_class_id
|
|
|
+LEFT JOIN tb_rst_complaint_type ct ON ct.complaint_id = csc.complaint_id
|
|
|
+LEFT JOIN tb_rst_sales_company sc ON c.company_id = sc.company_id
|
|
|
+LEFT JOIN tb_rst_store_info si ON c.store_id = si.store_id
|
|
|
+LEFT JOIN tb_rst_sales_order_item soi ON soi.item_order_id = oi.sales_id
|
|
|
+ </select>
|
|
|
</mapper>
|