ソースを参照

修改客户信息

liujiankang 7 年 前
コミット
dc1aecb039

+ 250 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/cm/CustomerStatisticalInfo.java

@@ -0,0 +1,250 @@
+package com.iamberry.rst.core.cm;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 客诉统计信息实体类
+ */
+public class CustomerStatisticalInfo implements Serializable {
+    private static final long serialVersionUID = 7150678136334412114L;
+    private Integer customerId;//客诉id
+    private Integer orderId;//订单id
+    private Date createTime;//创建日期
+    private String customerName;//姓名
+    private String customerTel;//联系电话
+    private String counselType;//类别
+    private String sourceType;//来源入口
+    private String complaintClassName;//问题类别
+    private String smallClassName;//小类名称
+    private String describeTitle;//客诉问题
+    private String describeHandleDesc;//处理过程
+    private String customerIsSolve;//处理结果
+    private Date salesPayTime;//购买日期
+    private String companyName;//销售公司
+    private String storeName;//销售渠道
+    private String itemProductName;//产品型号
+    private String itemProductColor;//产品颜色
+    private String itemNum;//产品数量
+    private String relationBackLogisticsCompany;//寄回快递
+    private String relationBackLogisticsNo;//寄回单号
+    private String relationBackReceiptDate;//签收日期
+    private String relationBackStatus;//寄回状态
+    private String relationSendLogisticsCompany;//寄出快递
+    private String relationSendLogisticsNo;//寄出单号
+    private String customerOutDamaged;//是否开箱损
+    private String customerSecondaryCustomer;//是否二次客诉
+
+    public Integer getCustomerId() {
+        return customerId;
+    }
+
+    public void setCustomerId(Integer customerId) {
+        this.customerId = customerId;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getCustomerName() {
+        return customerName;
+    }
+
+    public void setCustomerName(String customerName) {
+        this.customerName = customerName;
+    }
+
+    public String getCustomerTel() {
+        return customerTel;
+    }
+
+    public void setCustomerTel(String customerTel) {
+        this.customerTel = customerTel;
+    }
+
+    public String getCounselType() {
+        return counselType;
+    }
+
+    public void setCounselType(String counselType) {
+        this.counselType = counselType;
+    }
+
+    public String getSourceType() {
+        return sourceType;
+    }
+
+    public void setSourceType(String sourceType) {
+        this.sourceType = sourceType;
+    }
+
+    public String getComplaintClassName() {
+        return complaintClassName;
+    }
+
+    public void setComplaintClassName(String complaintClassName) {
+        this.complaintClassName = complaintClassName;
+    }
+
+    public String getSmallClassName() {
+        return smallClassName;
+    }
+
+    public void setSmallClassName(String smallClassName) {
+        this.smallClassName = smallClassName;
+    }
+
+    public String getDescribeTitle() {
+        return describeTitle;
+    }
+
+    public void setDescribeTitle(String describeTitle) {
+        this.describeTitle = describeTitle;
+    }
+
+    public String getDescribeHandleDesc() {
+        return describeHandleDesc;
+    }
+
+    public void setDescribeHandleDesc(String describeHandleDesc) {
+        this.describeHandleDesc = describeHandleDesc;
+    }
+
+    public String getCustomerIsSolve() {
+        return customerIsSolve;
+    }
+
+    public void setCustomerIsSolve(String customerIsSolve) {
+        this.customerIsSolve = customerIsSolve;
+    }
+
+    public Date getSalesPayTime() {
+        return salesPayTime;
+    }
+
+    public void setSalesPayTime(Date salesPayTime) {
+        this.salesPayTime = salesPayTime;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getStoreName() {
+        return storeName;
+    }
+
+    public void setStoreName(String storeName) {
+        this.storeName = storeName;
+    }
+
+    public String getItemProductName() {
+        return itemProductName;
+    }
+
+    public void setItemProductName(String itemProductName) {
+        this.itemProductName = itemProductName;
+    }
+
+    public String getItemProductColor() {
+        return itemProductColor;
+    }
+
+    public void setItemProductColor(String itemProductColor) {
+        this.itemProductColor = itemProductColor;
+    }
+
+    public String getItemNum() {
+        return itemNum;
+    }
+
+    public void setItemNum(String itemNum) {
+        this.itemNum = itemNum;
+    }
+
+    public String getRelationBackLogisticsCompany() {
+        return relationBackLogisticsCompany;
+    }
+
+    public void setRelationBackLogisticsCompany(String relationBackLogisticsCompany) {
+        this.relationBackLogisticsCompany = relationBackLogisticsCompany;
+    }
+
+    public String getRelationBackLogisticsNo() {
+        return relationBackLogisticsNo;
+    }
+
+    public void setRelationBackLogisticsNo(String relationBackLogisticsNo) {
+        this.relationBackLogisticsNo = relationBackLogisticsNo;
+    }
+
+    public String getRelationBackReceiptDate() {
+        return relationBackReceiptDate;
+    }
+
+    public void setRelationBackReceiptDate(String relationBackReceiptDate) {
+        this.relationBackReceiptDate = relationBackReceiptDate;
+    }
+
+    public String getRelationBackStatus() {
+        return relationBackStatus;
+    }
+
+    public void setRelationBackStatus(String relationBackStatus) {
+        this.relationBackStatus = relationBackStatus;
+    }
+
+    public String getRelationSendLogisticsCompany() {
+        return relationSendLogisticsCompany;
+    }
+
+    public void setRelationSendLogisticsCompany(String relationSendLogisticsCompany) {
+        this.relationSendLogisticsCompany = relationSendLogisticsCompany;
+    }
+
+    public String getRelationSendLogisticsNo() {
+        return relationSendLogisticsNo;
+    }
+
+    public void setRelationSendLogisticsNo(String relationSendLogisticsNo) {
+        this.relationSendLogisticsNo = relationSendLogisticsNo;
+    }
+
+    public String getCustomerOutDamaged() {
+        return customerOutDamaged;
+    }
+
+    public void setCustomerOutDamaged(String customerOutDamaged) {
+        this.customerOutDamaged = customerOutDamaged;
+    }
+
+    public String getCustomerSecondaryCustomer() {
+        return customerSecondaryCustomer;
+    }
+
+    public void setCustomerSecondaryCustomer(String customerSecondaryCustomer) {
+        this.customerSecondaryCustomer = customerSecondaryCustomer;
+    }
+}

+ 6 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/cm/CustomerService.java

@@ -156,4 +156,10 @@ public interface CustomerService {
 
     /*添加订单*/
     Integer addOrder(SalesOrder salesOrder);
+
+    /**
+     * 导出客诉信息到excel
+     * @return
+     */
+    List<CustomerStatisticalInfo> listStatisticalCustomer();
 }

+ 7 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/CustomerServiceImpl.java

@@ -1085,7 +1085,13 @@ public class CustomerServiceImpl implements CustomerService {
         }
         return orderNum;
     }
-        /**
+
+    @Override
+    public List<CustomerStatisticalInfo> listStatisticalCustomer() {
+        return customerInfoMapper.listStatisticalCustomer();
+    }
+
+    /**
          * 向Efast推送订单--添加订单
          * @return
          */

+ 7 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/mapper/CustomerInfoMapper.java

@@ -1,6 +1,7 @@
 package com.iamberry.rst.service.cm.mapper;
 
 import com.iamberry.rst.core.cm.CustomerInfo;
+import com.iamberry.rst.core.cm.CustomerStatisticalInfo;
 import com.iamberry.rst.core.order.ProductType;
 
 import java.util.List;
@@ -48,4 +49,10 @@ public interface CustomerInfoMapper {
      */
     List<CustomerInfo> listOnCustomer(CustomerInfo customerInfo);
 
+    /**
+     * 导出客诉信息到excel
+     * @return
+     */
+    List<CustomerStatisticalInfo> listStatisticalCustomer();
+
 }

+ 345 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/mapper/customerInfoMapper.xml

@@ -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>

+ 149 - 0
watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminCustomerController.java

@@ -26,6 +26,7 @@ import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang.StringUtils;
+import org.apache.poi.hssf.usermodel.*;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,8 +37,12 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.ModelAndView;
 
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
 import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -2011,5 +2016,149 @@ public class AdminCustomerController {
             return rj;
         }
     }
+
+
+
+    /**
+     * 下载客诉信息 (2018-05-29)
+     * @param request
+     * @param res
+     * @param
+     * @throws Exception
+     */
+    @RequestMapping("/download_customer_excel")
+    public void downloadEfastOrderExcel(HttpServletRequest request,HttpServletResponse res) throws Exception{
+        List<CustomerStatisticalInfo> customerList = customerService.listStatisticalCustomer();
+        String[] cells = {
+                "日期","姓名","联系电话","类别","来源入口",
+                "问题类别","小类名称","客诉问题","处理过程","购买日期",
+                "处理结果","销售公司","销售渠道","产品型号","产品颜色",
+                "产品数量","寄回快递","寄回单号","签收日期",
+                "状态","寄出快递","寄出快递","开箱损","二次客诉"
+        };
+        //导出订单Excel并下载
+        customerExcel(request,res,cells,customerList);
+
+    }
+
+
+    /**
+     * 导出订单Excel并下载
+     * @param request
+     * @param res
+     * @param cells
+     * @throws Exception
+     */
+    public void customerExcel(HttpServletRequest request,HttpServletResponse res,
+                                String[] cells,List<CustomerStatisticalInfo> customerList) throws Exception {
+
+        //创建一个workbook,对应一个Excel文件
+        HSSFWorkbook wb = new HSSFWorkbook();
+        //在workbook中添加一个sheet,对应Excel中的一个sheet
+        HSSFSheet sheet = wb.createSheet("导出订单");
+        //在sheet中添加表头第0行,老版本poi对excel行数列数有限制short
+        HSSFRow row = sheet.createRow((int) 0);
+        //创建单元格,设置值表头,设置表头居中
+        HSSFCellStyle style = wb.createCellStyle();
+        //居中格式
+        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
+        //设置表头
+
+        if (cells == null || cells.length == 0) {
+            return;
+        }
+        //循环设置表头
+        HSSFCell cell = null;
+        for (int i = 0;i < cells.length;i++) {
+            String name = cells[i];
+            cell = row.createCell(i);
+            cell.setCellValue(name);
+            cell.setCellStyle(style);
+        }
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        for (int i = 0; i < customerList.size(); i++) {
+            row = sheet.createRow((int) i + 1);
+            CustomerStatisticalInfo customerStatisticalInfo = customerList.get(i);
+
+            String createTime = "";
+            if(customerStatisticalInfo.getCreateTime() != null){
+                createTime = format.format(customerStatisticalInfo.getCreateTime());
+            }
+
+            String salesPayTime = "";
+            if(customerStatisticalInfo.getSalesPayTime() != null ){
+                salesPayTime = format.format(customerStatisticalInfo.getSalesPayTime());
+            }
+
+            // 创建单元格,设置值
+            row.createCell(0).setCellValue(createTime);
+            row.createCell(1).setCellValue(customerStatisticalInfo.getCustomerName() == null ? null : customerStatisticalInfo.getCustomerName());
+            row.createCell(2).setCellValue(customerStatisticalInfo.getCustomerTel() == null ? null : customerStatisticalInfo.getCustomerTel());
+            row.createCell(3).setCellValue(customerStatisticalInfo.getCounselType() == null ? null : customerStatisticalInfo.getCounselType());
+            row.createCell(4).setCellValue(customerStatisticalInfo.getSourceType() == null ? null : customerStatisticalInfo.getSourceType());
+            row.createCell(5).setCellValue(customerStatisticalInfo.getComplaintClassName() == null ? null : customerStatisticalInfo.getComplaintClassName());
+            row.createCell(6).setCellValue(customerStatisticalInfo.getSmallClassName() == null ? null : customerStatisticalInfo.getSmallClassName());
+            row.createCell(7).setCellValue(customerStatisticalInfo.getDescribeTitle() == null ? null : customerStatisticalInfo.getDescribeTitle());
+            row.createCell(8).setCellValue(customerStatisticalInfo.getDescribeHandleDesc() == null ? null : customerStatisticalInfo.getDescribeHandleDesc());
+            row.createCell(9).setCellValue(customerStatisticalInfo.getCustomerIsSolve() == null ? null : customerStatisticalInfo.getCustomerIsSolve());
+            row.createCell(10).setCellValue(salesPayTime);
+            row.createCell(11).setCellValue(customerStatisticalInfo.getCompanyName() == null ? null : customerStatisticalInfo.getCompanyName());
+            row.createCell(12).setCellValue(customerStatisticalInfo.getStoreName() == null ? null : customerStatisticalInfo.getStoreName());
+            row.createCell(13).setCellValue(customerStatisticalInfo.getItemProductName() == null ? null : customerStatisticalInfo.getItemProductName());
+            row.createCell(14).setCellValue(customerStatisticalInfo.getItemProductColor() == null ? null : customerStatisticalInfo.getItemProductColor());
+            row.createCell(15).setCellValue(customerStatisticalInfo.getItemNum() == null ? null : customerStatisticalInfo.getItemNum());
+            row.createCell(16).setCellValue(customerStatisticalInfo.getRelationBackLogisticsCompany() == null ? null : customerStatisticalInfo.getRelationBackLogisticsCompany());
+            row.createCell(17).setCellValue(customerStatisticalInfo.getRelationBackLogisticsNo() == null ? null : customerStatisticalInfo.getRelationBackLogisticsNo());
+            row.createCell(18).setCellValue(customerStatisticalInfo.getRelationBackReceiptDate() == null ? null : customerStatisticalInfo.getRelationBackReceiptDate());
+            row.createCell(19).setCellValue(customerStatisticalInfo.getRelationBackStatus() == null ? null : customerStatisticalInfo.getRelationBackStatus());
+            row.createCell(20).setCellValue(customerStatisticalInfo.getRelationSendLogisticsCompany() == null ? null : customerStatisticalInfo.getRelationSendLogisticsCompany());
+            row.createCell(21).setCellValue(customerStatisticalInfo.getRelationSendLogisticsNo() == null ? null : customerStatisticalInfo.getRelationSendLogisticsNo());
+            row.createCell(22).setCellValue(customerStatisticalInfo.getCustomerOutDamaged() == null ? null : customerStatisticalInfo.getCustomerOutDamaged());
+            row.createCell(23).setCellValue(customerStatisticalInfo.getCustomerSecondaryCustomer() == null ? null : customerStatisticalInfo.getCustomerSecondaryCustomer());
+        }
+        //下载导出订单Excel
+        downloadCustomerExcel(res,wb);
+    }
+
+    /**
+     * 下载导出客诉到Excel
+     * @param res
+     * @param wb
+     * @throws Exception
+     */
+    public void downloadCustomerExcel(HttpServletResponse res, HSSFWorkbook wb) throws Exception{
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String fileName = format.format(new Date()) + "客诉报表";
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        wb.write(os);
+        byte[] content = os.toByteArray();
+        InputStream is = new ByteArrayInputStream(content);
+        // 设置response参数,可以打开下载页面
+        res.reset();
+        res.setContentType("application/vnd.ms-excel;charset=utf-8");
+        res.setHeader("Content-Disposition", "attachment;filename="
+                + new String((fileName + ".xls").getBytes(), "iso-8859-1"));
+        ServletOutputStream out = res.getOutputStream();
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
+        try {
+            bis = new BufferedInputStream(is);
+            bos = new BufferedOutputStream(out);
+            byte[] buff = new byte[2048];
+            int bytesRead;
+            // Simple read/write loop.
+            while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
+                bos.write(buff, 0, bytesRead);
+            }
+        } catch (Exception e) {
+            // TODO: handle exception
+            e.printStackTrace();
+        } finally {
+            if (bis != null)
+                bis.close();
+            if (bos != null)
+                bos.close();
+        }
+    }
 }
 

+ 1 - 0
watero-rst-web/src/main/resources/watero-rst-orm.xml

@@ -100,6 +100,7 @@
 		<typeAlias type="com.iamberry.rst.core.customer.DockedContactInfo" alias="DockedContactInfo"/>
 		<typeAlias type="com.iamberry.rst.core.customer.TicketOpeningInfo" alias="TicketOpeningInfo"/>
 		<typeAlias type="com.iamberry.rst.core.customer.LowestPriceInfo" alias="LowestPriceInfo"/>
+		<typeAlias type="com.iamberry.rst.core.cm.CustomerStatisticalInfo" alias="CustomerStatisticalInfo"/>
 	</typeAliases>
 	<!-- PageHelper -->
 	<plugins>