|  | @@ -650,5 +650,101 @@
 | 
	
		
			
				|  |  |              AND dict.dict_type = 'data_unitfees'
 | 
	
		
			
				|  |  |              AND w.f_pid = #{fId}
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    <select id="warehouseBillsFeesProfitList" resultType="java.util.Map">
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +        a.*,
 | 
	
		
			
				|  |  | +        ifnull( a.fAmount, 0 ) - ifnull( a.fStlamount, 0 ) AS nnfinished
 | 
	
		
			
				|  |  | +        FROM
 | 
	
		
			
				|  |  | +        (
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +        t.f_id AS fSrcpid,
 | 
	
		
			
				|  |  | +        c.f_name AS fName,
 | 
	
		
			
				|  |  | +        w.fId AS fId,
 | 
	
		
			
				|  |  | +        w.fName AS fFeesName,
 | 
	
		
			
				|  |  | +        w.f_mblno AS fMblno,
 | 
	
		
			
				|  |  | +        w.f_product_name AS fProductName,
 | 
	
		
			
				|  |  | +        w.f_marks AS fMarks,
 | 
	
		
			
				|  |  | +        t.f_billtype AS fBilltype,
 | 
	
		
			
				|  |  | +        t.f_review_date AS fReviewDate,
 | 
	
		
			
				|  |  | +        SUM( w.fAmount ) AS fAmount,
 | 
	
		
			
				|  |  | +        SUM( w.fStlamount ) AS fStlamount
 | 
	
		
			
				|  |  | +        FROM
 | 
	
		
			
				|  |  | +        t_warehousebills t
 | 
	
		
			
				|  |  | +        LEFT JOIN t_corps c ON c.f_id = t.f_corpid
 | 
	
		
			
				|  |  | +        LEFT JOIN (
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +        a.*,
 | 
	
		
			
				|  |  | +        MAX( CASE f_dc WHEN 'D' THEN f_amount ELSE 0 END ) fAmount,
 | 
	
		
			
				|  |  | +        MAX( CASE f_dc WHEN 'C' THEN f_amount ELSE 0 END ) fStlamount
 | 
	
		
			
				|  |  | +        FROM
 | 
	
		
			
				|  |  | +        (
 | 
	
		
			
				|  |  | +        SELECT
 | 
	
		
			
				|  |  | +        f.f_id AS f_id,
 | 
	
		
			
				|  |  | +        f.f_pid AS f_pid,
 | 
	
		
			
				|  |  | +        f.f_lineno AS f_lineno,
 | 
	
		
			
				|  |  | +        f.f_corpid,
 | 
	
		
			
				|  |  | +        f.f_feeid,
 | 
	
		
			
				|  |  | +        f.f_feeUnitid,
 | 
	
		
			
				|  |  | +        f.f_qty,
 | 
	
		
			
				|  |  | +        f.f_unitprice,
 | 
	
		
			
				|  |  | +        f.f_currency,
 | 
	
		
			
				|  |  | +        f.f_exrate,
 | 
	
		
			
				|  |  | +        f.f_taxrate,
 | 
	
		
			
				|  |  | +        f.f_dc,
 | 
	
		
			
				|  |  | +        f.f_billstatus,
 | 
	
		
			
				|  |  | +        f.f_statement_no,
 | 
	
		
			
				|  |  | +        f.f_accamount,
 | 
	
		
			
				|  |  | +        f.f_accamount_date,
 | 
	
		
			
				|  |  | +        f.f_stlamount_no,
 | 
	
		
			
				|  |  | +        f.f_stlamount,
 | 
	
		
			
				|  |  | +        f.f_stlamount_date,
 | 
	
		
			
				|  |  | +        f.f_invnos,
 | 
	
		
			
				|  |  | +        f.f_invamount,
 | 
	
		
			
				|  |  | +        f.f_askamount,
 | 
	
		
			
				|  |  | +        f.f_status,
 | 
	
		
			
				|  |  | +        f.remark,
 | 
	
		
			
				|  |  | +        f.f_mblno,
 | 
	
		
			
				|  |  | +        f.f_product_name,
 | 
	
		
			
				|  |  | +        f.f_marks,
 | 
	
		
			
				|  |  | +        c.f_id AS fId,
 | 
	
		
			
				|  |  | +        c.f_name AS fName,
 | 
	
		
			
				|  |  | +        sum( f.f_amount ) AS f_amount
 | 
	
		
			
				|  |  | +        FROM
 | 
	
		
			
				|  |  | +        t_warehousebillsfees AS f
 | 
	
		
			
				|  |  | +        LEFT JOIN t_corps AS c ON f.f_corpid = c.f_id
 | 
	
		
			
				|  |  | +        GROUP BY
 | 
	
		
			
				|  |  | +        f.f_mblno,
 | 
	
		
			
				|  |  | +        f.f_dc
 | 
	
		
			
				|  |  | +        ) AS a
 | 
	
		
			
				|  |  | +        GROUP BY
 | 
	
		
			
				|  |  | +        f_mblno
 | 
	
		
			
				|  |  | +        ) w ON w.f_pid = t.f_id
 | 
	
		
			
				|  |  | +        LEFT JOIN t_fees f ON w.f_feeid = f.f_id
 | 
	
		
			
				|  |  | +        <where>
 | 
	
		
			
				|  |  | +            <if test="fCorpid != null  and fCorpid != ''">and t.f_corpid = #{fCorpid} </if>
 | 
	
		
			
				|  |  | +            <if test="fToCorpid != null  and fToCorpid != ''">and w.f_corpid = #{fToCorpid} </if>
 | 
	
		
			
				|  |  | +            <if test="fMblno != null  and fMblno != ''">and w.f_mblno  like concat('%', #{fMblno}, '%') </if>
 | 
	
		
			
				|  |  | +            <if test="fMarks != null and fMarks != ''">and w.f_marks  like concat('%', #{fMarks}, '%') </if>
 | 
	
		
			
				|  |  | +            <if test="fProductName != null and fProductName != ''">and  w.f_product_name  like concat('%', #{fProductName}, '%') </if>
 | 
	
		
			
				|  |  | +            <if test='fBillstatus != null and fBillstatus != "" and fBillstatus == "0" '>
 | 
	
		
			
				|  |  | +                and w.f_billstatus != 6
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test='fBillstatus != null and fBillstatus != "" and fBillstatus == "1" '>
 | 
	
		
			
				|  |  | +                and w.f_billstatus = 6
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test='timeExamine != null and timeExamine[0] != null and timeExamine[0]!= ""'>
 | 
	
		
			
				|  |  | +                and t.f_review_date >= #{timeExamine[0]}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test='timeExamine != null and timeExamine[1] != null and timeExamine[1]!= ""'>
 | 
	
		
			
				|  |  | +                and t.f_review_date <= #{timeExamine[1]}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            <if test='fReconciliation!= null and fReconciliation != "" and fReconciliation == "0" '>
 | 
	
		
			
				|  |  | +                and ifnull(w.f_amount, 0) - ifnull(w.f_stlamount, 0) != 0
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  | +            and  t.f_review_date IS NOT NULL
 | 
	
		
			
				|  |  | +            GROUP BY
 | 
	
		
			
				|  |  | +            w.f_mblno
 | 
	
		
			
				|  |  | +        </where>
 | 
	
		
			
				|  |  | +        ) a
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  |  </mapper>
 |