package com.sifang.modules.supply.warehouse.dao;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.sifang.modules.supply.warehouse.entity.CrmSupplyInventoryOrderDetail;
import com.sifang.modules.sys.common.entity.Menu;
import com.sifang.modules.sys.common.persistence.BaseDao;
import com.sifang.modules.sys.common.persistence.Parameter;
import com.sifang.modules.sys.util.SqlBuilder;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class InventoryOrderDetailDao extends BaseDao<CrmSupplyInventoryOrderDetail> {

    public List<Record> listDetailByMainId(String mainId) {
        SqlBuilder sql = new SqlBuilder();
        sql.line("select d.*,m.qq_code from crm_supply_inventory_order_detail d left join crm_supply_material m on d.material_id=m.id where d.status = '0' and d.inventory_id = ?", mainId);
        sql.line(" order by d.sort asc");
        return Db.find(sql.build(), sql.params());
    }

    public List<CrmSupplyInventoryOrderDetail> findOrderDetailList(String orderId){

        return find("FROM CrmSupplyInventoryOrderDetail WHERE status='0' AND inventoryId=:p1 ", new Parameter(orderId));
    }
}
