package org.springblade.audit.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.springblade.audit.entity.FctCsComplaintDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * <p>
 * 投诉回传数据表 Mapper 接口
 * </p>
 *
 * @author zbc
 * @since 2021-12-08
 */
public interface FctCsComplaintDetailMapper extends BaseMapper<FctCsComplaintDetail> {

	@Delete("Delete from FCT_CS_COMPLAINT_DETAIL where worksheetid in(" +
		"Select worksheetid from MID_CS_COMPLAINT_DETAIL)")
    void deleteWorkSheet();

	@Insert(" INSERT INTO FCT_CS_COMPLAINT_DETAIL (\n" +
		"            THEMONTH,\n" +
		"            IMPORT_TIME,\n" +
		"            DATA_SOURCE,\n" +
		"            WORKSHEETID,\n" +
		"            ACCEPT_TIME,\n" +
		"            DIAL_PHONENUM,\n" +
		"            ACCEPT_PHONENUM,\n" +
		"            SERVICE_STYLE,\n" +
		"            SERVICE_TYPE,\n" +
		"            SPNAME,\n" +
		"            PROVINCE,\n" +
		"            AREA,\n" +
		"            ACCEPT_WAY,\n" +
		"            COMPLAINT_TYPE,\n" +
		"            REFUND_REASON,\n" +
		"            DESCRIBE,\n" +
		"            HANDLE_RESULT,\n" +
		"            IS_REFUND,\n" +
		"            REFUND_TIMES,\n" +
		"            REFUND_MONEY,\n" +
		"            IS_HIGH_REFUND,\n" +
		"            OVER_TIME,\n" +
		"            COMPLAINT_UPGRADE,\n" +
		"            ACCEPT_DAY,\n" +
		"            IMPORT_DAY,\n" +
		"            SPID\n" +
		"        ) SELECT\n" +
		"        a.THEMONTH,\n" +
		"        a.IMPORT_TIME,\n" +
		"        a.DATA_SOURCE,\n" +
		"        a.WORKSHEETID,\n" +
		"        a.ACCEPT_TIME,\n" +
		"        a.DIAL_PHONENUM,\n" +
		"        a.ACCEPT_PHONENUM,\n" +
		"        a.SERVICE_STYLE,\n" +
		"        a.SERVICE_TYPE,\n" +
		"        a.SPNAME,\n" +
		"        a.PROVINCE,\n" +
		"        b.AREA,\n" +
		"        a.ACCEPT_WAY,\n" +
		"        a.COMPLAINT_TYPE,\n" +
		"        a.REFUND_REASON,\n" +
		"        a.DESCRIBE,\n" +
		"        a.HANDLE_RESULT,\n" +
		"        a.IS_REFUND,\n" +
		"        a.REFUND_TIMES,\n" +
		"        a.REFUND_MONEY,\n" +
		"        a.IS_HIGH_REFUND,\n" +
		"        a.OVER_TIME,\n" +
		"        a.COMPLAINT_UPGRADE,\n" +
		"        a.ACCEPT_DAY,\n" +
		"        a.IMPORT_DAY,\n" +
		"        a.SPID\n" +
		"        FROM\n" +
		"            MID_CS_COMPLAINT_DETAIL a\n" +
		"            LEFT JOIN ETL_VW_TB_CALLER_AREACODE b ON substr( a.accept_phonenum, 1, 7 )= b.CALLERHEAD")
	void fctCopyMid();
}
