package com.sifang.modules.releorder.dao;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.releorder.entity.CrmReleOrderDetail;
import com.sifang.modules.sys.common.persistence.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @title: CrmReleOrderDetailDao
 * @Author Tan
 * @Date: 2024/10/21 9:57
 * @Version 1.0
 */
@Repository
public class CrmReleOrderDetailDao extends BaseDao<CrmReleOrderDetail> {

    public List<Record> getReleOrderDetailList(String releCode) {
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT d.req_cont_number,d.is_project_company_model,d.customer_name,d.id_card_type,d.id_card_no, ");
        sql.append(" d.amount,d.incoming_date,d.ongrid_date,d.power_generation_no,e.power_station_code,e.filing_type ");
        sql.append(" FROM crm_rele_order_detail d ");
        sql.append(" LEFT JOIN crm_customer_incoming_application p ON p.partners_contract_number = d.req_cont_number ");
        sql.append(" LEFT JOIN crm_customer_entry e ON e.id = p.entry_id  ");
        sql.append(" WHERE 1 = 1  ");
        sql.append(" AND d.rele_code = "+"'"+releCode+"'");
        return Db.find(sql.toString());
    }

}