<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="io.renren.modules.app.dao.WxzjxjDao">

	<select id="selectxq" resultType="io.renren.modules.app.entity.XlkEntity">
		select xqmc,xqbm from xqxx
		where 1=1

	</select>

	<select id="selectxm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select xmmc,xmbm from xm
		where xqbm=#{bm}

	</select>

	<select id="selectlz" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select dhmc,dhbm from zhxx
		where xmbm=#{bm}

	</select>

	<select id="selectjsyh" resultType="io.renren.modules.app.entity.XlkEntity">
		select yhmc,yhbm from yhxx
		where 1=1

	</select>

	<select id="selectjsfs" resultType="io.renren.modules.app.entity.XlkEntity">
		select billname,billcode from
		h_jsfs
		where 1=1

	</select>

	<select id="selectfwbylz" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.XlkEntity">
		select fwbm,xm,mphm,mj,sfsc,cczh
		from fwxx
		where dhbm=#{id}

	</select>

	<select id="selectfw" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from fwxx where fwbm=#{fwbm}

	</select>

	<insert id="insertbc" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		ywpz(djbh,djlx,djrq,dwbm,cbwdbm,bank_Code,gzdbm,zph,je,czybm,czyxm,bz,pzz,pzh,
		flsh,jsfs,kjqj,syxm,dhbm,fpfs,pzzt,xgbm,jkfx,shrbm,shrxm,shrq,shzt)
		values(#{djbh},#{djlx},#{djrq},#{dwbm},#{cbwdbm},#{bankCode},
		#{gzdbm},#{zph},#{je},#{czybm},#{czyxm},#{bz},#{pzz},#{pzh},#{flsh},#{jsfs},#{kjqj},
		#{syxm},#{dhbm},#{fpfs},#{pzzt},#{xgbm},#{jkfx},#{shrbm},#{shrxm},#{shrq},'1')
	</insert>

	<insert id="insertgrmx" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into ywpzmx(
		djbh,dhbm,fwbm,bjje,je,jdf
		) values(
		#{djbh},#{dhbm},#{fwbm},#{je},#{je},'0'
		)
	</insert>

	<update id="updatefwgrje" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update fwxx set
		grje=#{grje},dqye=#{dqye} where fwbm=#{fwbm}
	</update>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select
		distinct
		y.djbh,y.djrq,s.dwmc,q.xqmc,x.xmmc,z.dhmc,z.dhbm,f.mphm,f.xm,f.dz,a.yhmc,
		h.billname,f.mj,y.je,f.grje,y.czyxm,y.shrq,y.bz,y.zph,f.fwbm,y.bank_code bankCode,y.cbwdbm,y.jsfs,z.xmbm,q.xqbm
		from ywpz
		y,ywpzmx m,zhxx z,xqxx q,xm x,sfdw s,fwxx
		f,yhxx a,h_jsfs h
		where
		y.djbh=m.djbh and m.dhbm=z.dhbm and
		m.fwbm=f.fwbm and z.xmbm=x.xmbm
		and
		x.xqbm=q.xqbm and x.dwbm=s.dwbm and y.bank_code=a.yhbm and
		y.jsfs=h.billcode and y.djlx='05'

		<if test=" djbh!=null and djbh!='' ">
			and y.djbh like CONCAT(#{djbh},"%")
		</if>
		<!-- <if test=" kjqj!=null and kjqj!='' ">
			and y.kjqj like CONCAT(#{kjqj},"%")
		</if> -->
		<if test=" dwbm!=null and dwbm!='' ">
			and s.dwbm like CONCAT(#{dwbm},"%")
		</if>
		<if test=" xqbm!=null and xqbm!='' ">
			and q.xqbm like CONCAT(#{xqbm},"%")
		</if>
		<if test=" xmbm!=null and xmbm!='' ">
			and x.xmbm like CONCAT(#{xmbm},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and y.dhbm like CONCAT(#{dhbm},"%")
		</if>
		<if test=" xm!=null and xm!='' ">
			and f.xm like CONCAT(#{xm},"%")
		</if>
		<if test=" beginrq!=null and beginrq!='' and endrq!=null and endrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		order by y.djbh desc
	</select>

	<delete id="deleteywpz" parameterType="java.lang.String">
		delete from ywpz where djbh=#{id}
	</delete>
	
	<delete id="deleteywpzmx" parameterType="java.lang.String">
		delete from ywpzmx where djbh=#{id}
	</delete>
	
	<select id="queryByCount" parameterType="java.lang.String"
		resultType="java.lang.String">
		select max(substr(djbh,17,4)) from ywpz where
		substr(shrq,1,7)=substr(#{date},1,7) and djlx='05'

	</select>
	<select id="selectzhxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select * from zhxx where dhbm=#{dhbm}

	</select>
	
	<update id="updatezhxx" parameterType="io.renren.modules.app.entity.ZhxxEntity">
     update zhxx set gryjje=#{gryjje},dqye=#{dqye} where dhbm=#{dhbm}
	</update>
	
	<select id="selectxmbydh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XlkEntity">
		select dwbm from xm where xmbm=(select xmbm from zhxx where dhbm=#{id})

	</select>

</mapper>