<?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.FwwxdshDao">

	<!-- 可根据自己的需求，是否要使用 -->
	<resultMap type="io.renren.modules.app.entity.SqwxzqEntity"
		id="sqwxzqMap">
		<result property="sqdbh" column="sqdbh" />
		<result property="sqrq" column="sqrq" />
		<result property="sqdwbm" column="sqdwbm" />
		<result property="dhbm" column="dhbm" />
		<result property="sqje" column="sqje" />
		<result property="lx" column="lx" />
		<result property="wxbw" column="wxbw" />
		<result property="zfy" column="zfy" />
		<result property="zhs" column="zhs" />
		<result property="dwyj" column="dwyj" />
		<result property="gwhyj" column="gwhyj" />
		<result property="pzdwyj" column="pzdwyj" />
		<result property="jbrxm" column="jbrxm" />
		<result property="jbrdh" column="jbrdh" />
		<result property="bz" column="bz" />
		<result property="czybm" column="czybm" />
		<result property="czyxm" column="czyxm" />
		<result property="gzdbm" column="gzdbm" />
		<result property="shrbm" column="shrbm" />
		<result property="shrxm" column="shrxm" />
		<result property="shrq" column="shrq" />
		<result property="sfsh" column="sfsh" />
		<result property="sfjz" column="sfjz" />
		<result property="cbwdbm" column="cbwdbm" />
		<result property="sffp" column="sffp" />
		<result property="fprbm" column="fprbm" />
		<result property="fprxm" column="fprxm" />
		<result property="fprq" column="fprq" />
		<result property="fpfs" column="fpfs" />
		<result property="djbh" column="djbh" />
		<result property="jsdbh" column="jsdbh" />
		<result property="sfjs" column="sfjs" />
		<result property="sqdw" column="sqdw" />
	</resultMap>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.SqwxzqEntity"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">

		select
		distinct s.sqdbh,s.sqdw,s.sqrq,q.xqmc,x.xmmc,s.xmbm,sqje,
		s.sfsh,s.wxbw,s.zfy,s.zhs,s.jbrxm,s.jbrdh,s.dwyj,s.gwhyj,s.bz,s.shrxm,s.shrq,s.spje,s.pzdwyj,s.ysje,s.xzbflx,s.xzwxlx,s.wxdzt,s.fjid,s.sgdw,s.dsfsj
		from sqwxzq s,xm x,xqxx q
		where s.xmbm=x.xmbm
		and x.xqbm=q.xqbm
		<if test=" sqdbh!=null and sqdbh!='' ">
			and s.sqdbh like CONCAT(#{sqdbh},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and s.dhbm like CONCAT(#{dhbm},"%")
		</if>
		<if test=" sfsh!=null and sfsh!='' ">
			and s.sfsh like CONCAT(#{sfsh},"%")
		</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=" sqdw!=null and sqdw!='' ">
			and s.sqdw like CONCAT(#{sqdw},"%")
		</if>
		and s.sqrq between #{beginrq} and #{endrq}
		order by s.sqdbh desc
	</select>

	<select id="selectwxxmxxbysqdh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.WxjlbEntity">
		select
		j.id,j.fybm,j.sqje,w.wxxmmc,w.bz,j.dhbm,z.dhmc,x.xmmc from
		wxjlb
		j,wxxmxx
		w,zhxx z,xm x
		where
		j.fybm=w.wxxmbm and j.dhbm=z.dhbm and
		z.xmbm=x.xmbm and
		j.sqdbh=#{id}
	</select>

	<update id="updatetgsh" parameterType="io.renren.modules.app.entity.SqwxzqEntity">
		update sqwxzq set
		sfsh='1',shrbm=#{shrbm},shrxm=#{shrxm},shrq=#{shrq},spje=#{spje},pzdwyj=#{pzdwyj},wxdzt='2'
		where sqdbh=#{sqdbh}
	</update>

	<update id="updateqxsh" parameterType="io.renren.modules.app.entity.SqwxzqEntity">
		update sqwxzq set
		sfsh='0',shrxm='',shrq='',spje='0',pzdwyj='',wxdzt='1'
		where
		sqdbh=#{sqdbh}
	</update>

	<update id="updatebh" parameterType="io.renren.modules.app.entity.SqwxzqEntity">
		update sqwxzq set
		sfsh='2',wxdzt='1'
		where sqdbh=#{sqdbh}
	</update>

	<select id="queryByPageC" parameterType="io.renren.modules.app.entity.SqwxzqEntity"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">

		select
		distinct s.sqdbh,s.sqdw,s.sqrq,q.xqmc,x.xmmc,x.xmbm,s.sqje,
		s.wxbw,s.zfy,s.zhs,s.jbrxm,s.shrxm,s.shrq,s.spje,s.fprxm,s.fprq,s.sffp,s.fpfs,s.ysje,s.xzbflx,s.xzwxlx,s.wxdzt,s.fjid
		from sqwxzq s,xm x,xqxx q,ywpz y
		where s.xmbm=x.xmbm
		and x.xqbm=q.xqbm
		and
		sfsh='1'
		<if test=" sqdbh!=null and sqdbh!='' ">
			and s.sqdbh like CONCAT(#{sqdbh},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and s.dhbm like CONCAT(#{dhbm},"%")
		</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=" sqdw!=null and sqdw!='' ">
			and s.sqdw like CONCAT(#{sqdw},"%")
		</if>
		<if test=" sffp!=null and sffp!='' ">
			and s.sffp like CONCAT(#{sffp},"%")
		</if>

		and s.sqrq between #{beginrq} and #{endrq}
		order by s.sqdbh desc
	</select>

	<select id="queryByPageF" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select
		distinct
		f.fwbm,f.cczh,d.dymc,d.fwdybm,f.lc,f.mphm,f.xm,f.mj,f.grje,f.dqye,f.zqje,f.dwje,f.ggsy,f.xhje,f.dhbm,z.dhmc,z.xmbm,x.xmmc
		from fwxx
		f,dyxx d,zhxx z,xm x where f.mh=d.fwdybm and f.dhbm=z.dhbm
		and z.xmbm=x.xmbm and
		f.dhbm=#{id}
	</select>

	<update id="updatesqftzt" parameterType="io.renren.modules.app.entity.SqwxzqEntity">
		update sqwxzq set
		sffp='1',fpfs=#{fpfs},fprbm=#{fprbm},fprxm=#{fprxm},fprq=#{fprq},wxdzt='3'
		where
		sqdbh=#{sqdbh}
	</update>

	<insert id="insertftqc" parameterType="io.renren.modules.app.entity.FwxxEntity">
		insert into ftqc
		(sqdbh,fwbm,dhbm,sqje,dyftje) values
		(#{sqdbh},#{fwbm},#{dhbm},#{sqje},#{dyftje})
	</insert>
	<insert id="insertjsqc" parameterType="io.renren.modules.app.entity.FwxxEntity">
		insert into ftqc
		(sqdbh,fwbm,dhbm,zsje,dyftje2) values
		(#{sqdbh},#{fwbm},#{dhbm},#{zsje},#{dyftje2})
	</insert>
	<select id="selectfwxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select * from fwxx where fwbm=#{id}
	</select>
	<update id="updatefwgrje" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update fwxx set
		grje=#{grje} where fwbm=#{fwbm}
	</update>
	<update id="updatefwyztk" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update fwxx set
		grje=#{grje},dqye=#{dqye} where fwbm=#{fwbm}
	</update>

	<select id="selectftfw" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select
		f.fwbm,f.lc,f.mphm,f.xm,f.mj,f.grje,f.dwje,f.dqye,f.ggsy,f.zqje,f.zqje2,f.zqdwje,f.zqdwje2,f.zqkkfs,f.zqkkfs2,t.sqje,f.xhje,z.dhmc,z.dhbm,t.sqdbh,t.dyftje,x.xmmc
		from fwxx
		f,ftqc t,zhxx z,xm x where t.fwbm=f.fwbm and t.dhbm=z.dhbm
		and z.xmbm=x.xmbm and t.sqje!=0 and
		t.sqdbh=#{id}
	</select>
	<delete id="deletesqwxzq" parameterType="java.lang.String">
		delete from sqwxzq where
		sqdbh=#{id}
	</delete>
	<update id="updateqxft" parameterType="io.renren.modules.app.entity.SqwxzqEntity">
		update sqwxzq set
		sffp='0',fpfs='',fprxm='',fprq='',djbh='',wxdzt='2' where
		sqdbh=#{sqdbh}
	</update>

	<delete id="deleteftqcsc" parameterType="java.lang.String">
		delete from ftqc where
		sqdbh=#{id} and sqje!=0
	</delete>

	<delete id="deleteftqcye" parameterType="java.lang.String">
		delete from ftqc where
		sqdbh=#{id} and zsje!=0
	</delete>

	<update id="updatesqhbzt" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update sqwxzq set
		djbh=#{djbh} where sqdbh=#{sqdbh}
	</update>

	<insert id="insertywpzhb" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into ywpz
		(djbh,djlx,djrq,dwbm,je,cbwdbm,bank_code,gzdbm,czybm,czyxm,jsfs,zph,bz,kjqj,shrq,shzt,xgbm,sqdbh)
		values
		(#{djbh},#{djlx},#{djrq},#{dwbm},#{je},'0001',#{bankCode},'0001',#{czybm},#{czyxm},#{jsfs},#{zph2},#{bz},#{kjqj},#{shrq},'1',#{xgbm},#{sqdbh})
	</insert>

	<select id="queryByPageHB" parameterType="io.renren.modules.app.entity.SqwxzqEntity"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">

		select
		distinct s.sqdbh,s.sqdw,s.sqrq,q.xqmc,x.xmmc,z.dhmc,z.dhbm,
		s.wxbw,s.spje,s.shrxm,s.shrq,s.zhs,s.fpfs,s.sfjz,s.djbh
		from sqwxzq
		s,zhxx z,xm x,xqxx q
		where s.dhbm=z.dhbm and z.xmbm=x.xmbm and
		x.xqbm=q.xqbm and
		s.sffp='1'
		<if test=" sqdbh!=null and sqdbh!='' ">
			and s.sqdbh like CONCAT(#{sqdbh},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and s.dhbm like CONCAT(#{dhbm},"%")
		</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=" sqdw!=null and sqdw!='' ">
			and s.sqdw like CONCAT(#{sqdw},"%")
		</if>
		<if test=" sfjz!=null and sfjz!='' ">
			and s.sfjz like CONCAT(#{sfjz},"%")
		</if>

		and s.sqrq between #{beginrq} and #{endrq}
		order by s.sqdbh desc
	</select>

	<select id="selectywpzhbxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select h.yhmc,j.billname,y.djrq,y.zph,y.czyxm,y.shrq,y.bz
		from
		ywpz y,yhxx
		h,h_jsfs j where y.bank_code=h.yhbm and
		y.jsfs=j.billcode
		and
		y.djbh=#{id}
	</select>

	<select id="selectdjbhbysqdbh" parameterType="java.lang.String"
		resultType="java.lang.String">
		select djbh from ywpz where sqdbh=#{id} and djlx='21'
	</select>

	<select id="selectdjbhbysqdbh2" parameterType="java.lang.String"
		resultType="java.lang.String">
		select djbh from ywpz where sqdbh=#{id} and djlx='22'
	</select>

	<delete id="deleteywpz" parameterType="java.lang.String">
		delete from ywpz where
		djbh=#{djbh}
	</delete>

	<update id="updateqxhb" parameterType="java.lang.String">
		update
		sqwxzq set
		sfjz='0',djbh='' where sqdbh=#{id}
	</update>

	<select id="queryByPageJS" parameterType="io.renren.modules.app.entity.SqwxzqEntity"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">

		select
		distinct s.sqdbh,s.sqdw,s.sqrq,q.xqmc,x.xmmc,
		s.wxbw,s.spje,s.shrxm,s.shrq,s.zhs,s.fpfs,s.fprq,h.yhmc,j.billname,y.djrq,
		y.zph,y.bz,s.sfjs,s.jsdbh,s.wxdzt,s.jiesuanje,s.yebfje,s.xmbm,s.fjid,s.sqje,s.ysje,s.fpfs2,s.dsfsjfy,s.gcyebfje
		from sqwxzq s,xm x,xqxx q,ywpz y,yhxx
		h,h_jsfs
		j
		where s.xmbm=x.xmbm and
		s.sqdbh=y.sqdbh and
		y.bank_code=h.yhbm and y.jsfs=j.billcode
		and
		x.xqbm=q.xqbm and
		s.sffp='1' and y.djlx='21'
		<if test=" sqdbh!=null and sqdbh!='' ">
			and s.sqdbh like CONCAT(#{sqdbh},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and s.dhbm like CONCAT(#{dhbm},"%")
		</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=" sqdw!=null and sqdw!='' ">
			and s.sqdw like CONCAT(#{sqdw},"%")
		</if>
		<if test=" sfjs!=null and sfjs!='' ">
			and s.sfjs like CONCAT(#{sfjs},"%")
		</if>

		and s.sqrq between #{beginrq} and #{endrq}
		order by s.sqdbh desc
	</select>

	<select id="selectywpzjs" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">
		select sum(y.je) je,y.djrq shrq,h.yhmc,j.billname,y.czyxm,
		y.zph,y.bz
		from ywpz
		y,yhxx h,h_jsfs j where
		y.bank_code=h.yhbm
		and
		y.jsfs=j.billcode and y.sqdbh=#{id} and y.djlx='22' group by zph
	</select>

	<select id="selectfwbyftqc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select
		f.fwbm,d.dymc,d.fwdybm,f.lc,f.mphm,f.xm,f.mj,f.fwje,f.grje,f.dwje,f.dqye,f.zqje,f.zqje2,f.zqdwje,f.zqdwje2,f.zqkkfs,f.zqkkfs2,t.zsje,t.dhbm,z.dhmc,t.dyftje2,x.xmmc
		from fwxx
		f,ftqc t,dyxx d,zhxx z,xm x where f.mh=d.fwdybm and
		t.fwbm=f.fwbm and t.dhbm=z.dhbm and z.xmbm=x.xmbm and t.zsje!=0 and
		t.sqdbh=#{id}
	</select>

	<select id="selectfwbyftqc2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select
		f.fwbm,d.dymc,d.fwdybm,f.lc,f.mphm,f.xm,f.mj,f.fwje,f.grje,f.dwje,f.dqye,f.dhbm,z.dhmc,x.xmbm,x.xmmc
		from fwxx f,dyxx d,zhxx z,xm x,ftqc t where f.mh=d.fwdybm and
		f.dhbm=z.dhbm and t.fwbm=f.fwbm and z.xmbm=x.xmbm and
		t.sqdbh=#{sqdbh}
	</select>

	<update id="updatejszt" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update sqwxzq set
		sfjs='1',jsdbh=#{jsdbh},wxdzt='4',jiesuanje=#{jiesuanje},yebfje=#{yebfje},fpfs2=#{fpfs2},dsfsjfy=#{dsfsjfy},gcyebfje=#{gcyebfje}
		where sqdbh=#{sqdbh}
	</update>
	<update id="updateqxjszt" parameterType="java.lang.String">
		update sqwxzq set
		sfjs='0',jsdbh='',wxdzt='3',jiesuanje=0,yebfje=0,fpfs2='',dsfsjfy=0,gcyebfje=0
		where
		sqdbh=#{id}
	</update>
	<select id="selecteftqc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FtqcEntity">
		select * from ftqc where sqdbh=#{id}
	</select>
	<update id="updateftqczsje" parameterType="io.renren.modules.app.entity.FwxxEntity">
		update ftqc set
		zsje=#{sqje} where fwbm=#{fwbm} and sqdbh=#{sqdbh}
	</update>
	<insert id="insertywpzjs" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		ywpz(djbh,djlx,djrq,bank_code,gzdbm,cbwdbm,zph,je,czybm,czyxm,bz,jsfs,shrq,kjqj,dwbm)
		values(#{djbh},#{djlx},#{sqrq},#{jsyh},'0001','0001',#{jsh},#{jsje},#{jsrbm},#{jsr},#{jsbzhu},#{jsfshi},#{jsrq},#{kjqj},#{dwbm})
	</insert>
	<insert id="insertywpzmx" parameterType="io.renren.modules.app.entity.YwpzmxEntity">
		insert into
		ywpzmx(djbh,dhbm,fwbm,bjje,je,jdf)
		values(#{djbh},#{dhbm},#{fwbm},#{bjje},#{je},#{jdf})
	</insert>
	
	<insert id="insertywpzmxx" parameterType="io.renren.modules.app.entity.YwpzmxEntity">
		insert into
		ywpzmx(djbh,dhbm,fwbm,bjje,je,jdf,dwje,grje,qdwje,qgrje,hdwje,hgrje)
		values(#{djbh},#{dhbm},#{fwbm},#{bjje},#{je},#{jdf},#{dwje},#{grje},#{qdwje},#{qgrje},#{hdwje},#{hgrje})
	</insert>

	<update id="updateftqc" parameterType="io.renren.modules.app.entity.FtqcEntity">
		update ftqc set
		zsje=#{zsje} where fwbm=#{fwbm} and sqdbh=#{sqdbh}
	</update>

	<delete id="deleteywpzmx" parameterType="java.lang.String">
		delete from ywpzmx where
		djbh=#{id}
	</delete>

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

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

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

	<update id="updatezhxxzqje" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		zqje=#{zqje},dqye=#{dqye},gryjje=#{gryjje} where dhbm=#{dhbm}
	</update>

	<update id="updatezhxxgryjje" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		gryjje=#{gryjje},dqye=#{dqye} where dhbm=#{dhbm}
	</update>

	<select id="selectfwxxby" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select
		fwbm,mphm,cczh,xm,sfzh,mj,fwje,grje,dwje,dqye,ggsy,zqje,ljlx,xhjx,gfrq,xhje,dhbm
		from fwxx
		where fwbm=#{id}
	</select>
	<select id="selectwygsbydhbm" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select w.wygsmc from zhxx z,wygsxx w where
		z.wygsbm=w.wygsbm and
		z.dhbm=#{id}
	</select>

	<insert id="insertywpzyztk" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		ywpz(djbh,djlx,djrq,dwbm,bank_code,gzdbm,cbwdbm,zph,je,czybm,czyxm,dhbm,bz,shrq,jsfs,kjqj,shzt)
		values(#{djbh},#{djlx},#{djrq},#{dwbm},#{bankCode},#{gzdbm},#{cbwdbm},#{zph},#{je},#{czybm},#{czyxm},#{dhbm},#{bz},#{shrq},#{jsfs},#{kjqj},'1')
	</insert>

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

	<select id="queryByPageYZTK" 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.fwbm,f.mphm,f.xm,a.yhmc,j.billname,y.je,y.bz,y.czyxm,y.shrq,y.zph
		from ywpz y,ywpzmx m,zhxx z,xm x,xqxx q,sfdw s,fwxx f,yhxx a,h_jsfs j
		where y.djbh=m.djbh and y.dhbm=z.dhbm
		and z.xmbm=x.xmbm and
		x.xqbm=q.xqbm and x.dwbm=s.dwbm and m.fwbm=f.fwbm
		and y.jsfs=j.billcode
		and y.bank_code=a.yhbm and djlx='13'
		<if test=" djbh!=null and djbh!='' ">
			and y.djbh like CONCAT(#{djbh},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and y.dhbm like CONCAT(#{dhbm},"%")
		</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=" dwbm!=null and dwbm!='' ">
			and s.dwbm like CONCAT(#{dwbm},"%")
		</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>

	<insert id="insertywpzyzxh" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		ywpz(djbh,djlx,djrq,dwbm,bank_code,gzdbm,cbwdbm,zph,je,czybm,czyxm,dhbm,bz,shrq,jsfs,kjqj)
		values(#{djbh},#{djlx},#{djrq},#{dwbm},#{bankCode},#{gzdbm},#{cbwdbm},#{zph},#{grje},#{czybm},#{czyxm},#{dhbm},#{bz},#{shrq},#{jsfs},#{kjqj})
	</insert>

	<insert id="insertywpzmxyzxh" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		ywpzmx(djbh,dhbm,bjje,lxje,fwbm,jdf)
		values(#{djbh},#{dhbm},#{grje},#{xhjx},#{fwbm},'1')
	</insert>

	<update id="updatezhxxxhje" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update zhxx set
		xhje=#{grje},xhjx=#{xhjx} where dhbm=#{dhbm}
	</update>

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

	<update id="updatezhxxdqye" parameterType="io.renren.modules.app.entity.ZhxxEntity">
		update zhxx set
		dqye=#{dqye} where dhbm=#{dhbm}
	</update>

	<select id="selectfwxxdqye" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select dqye,fwbm from fwxx where fwbm=#{id}
	</select>

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

	<update id="updatefwxxxhje" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update fwxx set
		xhje=#{grje},xhjx=#{xhjx},sfsc=#{sfsc} where fwbm=#{fwbm}
	</update>

	<select id="queryByPageYZXH" 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,f.fwbm,f.mphm,f.xm,a.yhmc,j.billname,y.je,m.lxje
		xhjx,y.bz,y.czyxm,y.shrq,y.zph
		from ywpz y,ywpzmx m,zhxx z,xm x,xqxx
		q,sfdw s,fwxx f,yhxx a,h_jsfs j
		where y.djbh=m.djbh and y.dhbm=z.dhbm
		and z.xmbm=x.xmbm and x.xqbm=q.xqbm and x.dwbm=s.dwbm and
		m.fwbm=f.fwbm
		and y.jsfs=j.billcode and y.bank_code=a.yhbm and
		djlx='23'
		<if test=" djbh!=null and djbh!='' ">
			and y.djbh like CONCAT(#{djbh},"%")
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and y.dhbm like CONCAT(#{dhbm},"%")
		</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=" dwbm!=null and dwbm!='' ">
			and s.dwbm like CONCAT(#{dwbm},"%")
		</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>

	<select id="queryByCounthb" parameterType="java.lang.String"
		resultType="java.lang.String">
		select max(substr(djbh,17,4)) from ywpz where
		substr(djrq,1,7)=substr(#{date},1,7) and djlx='21'

	</select>
	<select id="queryByCountjs" parameterType="java.lang.String"
		resultType="java.lang.String">
		select max(substr(djbh,17,4)) from ywpz where
		substr(djrq,1,7)=substr(#{date},1,7) and djlx='22'

	</select>

	<select id="queryByCounttk" 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='13'

	</select>

	<select id="queryByCountxh" 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='23'

	</select>


	<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>

	<select id="selectzckje" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select dwbm,zckje from sfdw where dwbm=(select dwbm from xm
		where xmbm=(select xmbm from zhxx where dhbm=#{id}))

	</select>

	<update id="updatezckje" parameterType="io.renren.modules.app.entity.SfdwEntity">
		update sfdw set
		zckje=#{zckje} where dwbm=#{dwbm}
	</update>

	<select id="selectje" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select je from ywpz where djbh=#{id}

	</select>

	<select id="selectmx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzmxEntity">
		select * from ywpzmx where djbh=#{id}

	</select>

	<select id="selectfzhsmxdj" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select DISTINCT
		y.djbh,y.djlx,y.djrq,y.kjqj,y.je,z.xmbm,f.xm from ywpz
		y,ywpzmx m,zhxx
		z,fwxx f where y.djbh=m.djbh and m.dhbm=z.dhbm and
		m.fwbm=f.fwbm and
		y.djbh=#{id}
	</select>

	<insert id="insertfzhsmx" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		fzhsmx(gjkjqj,djbh,djlx,djrq,xmbm,jffse,zymc)values(#{kjqj},#{djbh},#{djlx},#{djrq},#{xmbm},#{je},#{xm})
	</insert>

	<insert id="insertfzhsmx2" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		fzhsmx(gjkjqj,djbh,djlx,djrq,xmbm,jffse,zymc,zqlx)values(#{kjqj},#{djbh},#{djlx},#{djrq},#{xmbm},#{je},#{xm},#{zqlx})
	</insert>

	<select id="selectfzhsmxjs" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select DISTINCT y.djbh,y.djlx,y.djrq,y.kjqj,y.je,z.xmbm
		from ywpz y,ywpzmx m,zhxx z where y.djbh=m.djbh and m.dhbm=z.dhbm and
		y.djbh=#{id}
	</select>

	<select id="deletefzhsmxjs" parameterType="java.lang.String">
		delete from fzhsmx
		where djbh=#{id}
	</select>

	<select id="selectdhbmbysqdbh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.ZhxxEntity">
		select dhbm,sqje zje from wxjlb where sqdbh=#{id}
	</select>

	<select id="selectdwbmbyxm" parameterType="java.lang.String"
		resultType="java.lang.String">
		select dwbm from xm where xmbm=#{id}
	</select>

	<delete id="deleteftywpz" parameterType="java.lang.String">
		delete from ywpz where
		sqdbh=#{id} and djlx='21'
	</delete>

	<delete id="deleteftywpzmx" parameterType="java.lang.String">
		delete from ywpzmx
		where djbh in (select djbh from ywpz where sqdbh=#{id} and djlx='21')
	</delete>

	<delete id="deletejsywpz" parameterType="java.lang.String">
		delete from ywpz where
		sqdbh=#{id} and djlx='22'
	</delete>

	<delete id="deletejsywpzmx" parameterType="java.lang.String">
		delete from ywpzmx
		where djbh in (select djbh from ywpz where sqdbh=#{id} and djlx='22')
	</delete>

	<select id="selectftqcsc" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FtqcEntity">
		<!-- select * from ftqc where sqdbh=#{id} and sqje!=0 -->
		select fwbm,dhbm,je sqje from ywpzmx where djbh=#{id}
	</select>
	
	<select id="selectftqcsc2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzmxEntity">
		<!-- select * from ftqc where sqdbh=#{id} and sqje!=0 -->
		select * from ywpzmx where djbh in ${id}
	</select>

	<select id="selectftqcye" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FtqcEntity">
		select fwbm,dhbm,je zsje from ywpzmx where djbh=#{id}
	</select>

	<select id="selectscbfqxmje" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">
		select sum(grje)+sum(dwje)+sum(zqje)+sum(zqje2) scbfqxmje
		from fwxx
		where dhbm in
		(select dhbm from zhxx where xmbm in ${id})
	</select>

	<select id="selectscbfhxmje" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">
		select sum(grje)+sum(dwje)+sum(zqje2) scbfhxmje from fwxx
		where dhbm
		in (select dhbm
		from zhxx where xmbm in ${id})
	</select>

	<select id="selectscbfqxmje2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">
		select sum(grje)+sum(dwje)+sum(zqje2) scbfqxmje from fwxx
		where dhbm in
		(select dhbm from zhxx where xmbm in ${id})
	</select>

	<select id="selectscbfhxmje2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.SqwxzqEntity">
		select sum(grje)+sum(dwje) scbfhxmje from fwxx where dhbm
		in (select dhbm
		from zhxx where xmbm in ${id})
	</select>

	<select id="selectwjdxbyfjid" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.FjEntity">
		select * from fjb where id=#{id}
	</select>

	<select id="selectfzdj" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select distinct
		y.djbh,y.djlx,y.djrq,s.xmbm,y.je,CONCAT(q.xqmc,'_',x.xmmc) xm,y.kjqj
		from
		ywpz y,sqwxzq s,xm x,xqxx q where y.sqdbh=s.sqdbh and
		s.xmbm=x.xmbm
		and
		x.xqbm=q.xqbm and y.djbh=#{id}
	</select>

	<select id="selectfzdj2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select distinct
		y.djbh,y.djlx,y.djrq,s.xmbm,y.je,CONCAT(q.xqmc,'_',x.xmmc) xm,y.kjqj
		from
		ywpz y,sqwxzq s,xm x,xqxx q where y.sqdbh=s.sqdbh and
		s.xmbm=x.xmbm
		and
		x.xqbm=q.xqbm and y.djbh=#{id}
	</select>

	<select id="selectkjqjbydjbh" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from fzhsye where gjkjqj=(select kjqj from ywpz
		where djbh=#{id}) and djlx='21'
	</select>

	<select id="selectkjqjbydjbh2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from fzhsye where gjkjqj=(select kjqj from ywpz
		where djbh=#{id}) and djlx='21'
	</select>

	<select id="selectmaxkjqj" resultType="string">
		select MAX(gjkjqj) from
		fzhsye where djlx='21'
	</select>

	<select id="selectfffff" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select y.xgbm xmbm,y.je jffse from ywpz y where
		y.djbh=#{id}
	</select>

	<select id="selectfffff2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select y.xgbm xmbm,y.je jffse from ywpz y where
		y.djbh=#{id}
	</select>

	<select id="selectqcye" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select qcye,jffse,qmye from fzhsye where gjkjqj=#{gjkjqj}
		and djlx=#{djlx} and xmbm=#{xmbm} and zqlx=#{zqlx}
	</select>

	<update id="updatefzhsye" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update fzhsye set
		jffse=#{jffse},qmye=#{qmye} where gjkjqj=#{gjkjqj}
		and xmbm=#{xmbm} and
		djlx=#{djlx} and zqlx=#{zqlx}
	</update>

	<update id="updatefzhsye111" parameterType="io.renren.modules.app.entity.YwpzEntity">
		update fzhsye set
		qcye=#{qcye},jffse=#{jffse},qmye=#{qmye} where
		gjkjqj=#{gjkjqj} and
		xmbm=#{xmbm} and djlx=#{djlx} and zqlx=#{zqlx}
	</update>

	<select id="selectfzhsye" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select * from fzhsye where gjkjqj=#{id} and (djlx='21' or
		djlx='22')
	</select>


	<insert id="insertfzhsye" parameterType="io.renren.modules.app.entity.YwpzEntity">
		insert into
		fzhsye(gjkjqj,xmbm,djlx,qcye,jffse,dffse,qmye,zqlx)values(#{gjkjqj},#{xmbm},#{djlx},#{qcye},#{jffse},#{dffse},#{qmye},#{zqlx})
	</insert>

	<select id="ywkjqj" parameterType="java.lang.String" resultType="java.lang.String">
		select kjqj from ywpz where djbh=#{id}
	</select>

	<delete id="deletefzhsdj" parameterType="java.lang.String">
		delete from fzhsmx where
		djbh=#{id}
	</delete>

	<select id="selectwxjlbsqje" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select sum(sqje) je from wxjlb where sqdbh=#{sqdbh} and
		dhbm=#{dhbm}
	</select>

	<select id="selectdjxx" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.YwpzEntity">
		select y.djrq,y.bank_code bankCode,y.jsfs,y.zph from ywpz
		y
		where y.sqdbh=#{id} and y.djlx='21'
	</select>

	<select id="queryByxm" parameterType="java.lang.String"
		resultType="java.lang.String">
		select xmmc from xm where xmbm in(select xmbm from zhxx
		where dhbm in (select dhbm from wxjlb where sqdbh=#{sqdbh}))
	</select>

	<select id="queryByxm2" parameterType="java.lang.String"
		resultType="io.renren.modules.app.entity.XmEntity">
		select xmmc,xmbm from xm where xmbm in(select xmbm from
		zhxx where dhbm in (select dhbm from wxjlb where sqdbh=#{sqdbh}))
	</select>

	<select id="selectmimi" resultType="io.renren.modules.app.entity.YwpzEntity">
		select sqdbh,xmbm,djbh,jsdbh
		from sqwxzq where czyxm !='huarun'
	</select>

	<select id="updatemimi" parameterType="java.lang.String">
		update ywpz set
		sqdbh=#{sqdbh},xgbm=#{xmbm} where djbh=#{djbh}
	</select>

	<select id="updatemimi2" parameterType="java.lang.String">
		update ywpz set
		sqdbh=#{sqdbh},xgbm=#{xmbm} where djbh=#{jsdbh}
	</select>

	<select id="queryByPageZQMXCX" parameterType="io.renren.modules.app.entity.YwpzEntity"
		resultType="io.renren.modules.app.entity.FwxxEntity">
		select
		m.djbh,y.djrq,m.je,m.dwje,m.grje,m.qdwje,m.qgrje,m.hdwje,m.hgrje,q.xqmc,q.xqbm,x.xmmc,x.xmbm,z.dhbm,z.dhmc,f.fwbm,f.mphm,f.xm,f.mj
		from ywpzmx m,fwxx f,zhxx z,xm x,xqxx q,ywpz y where m.djbh=y.djbh and m.fwbm=f.fwbm and
		f.dhbm=z.dhbm and z.xmbm=x.xmbm and x.xqbm=q.xqbm and SUBSTR(m.djbh
		FROM 1 FOR 2) in('21','22')
		<if test=" beginrq!=null and beginrq!='' ">
			and y.djrq between #{beginrq} and #{endrq}
		</if>
		<if test=" xqbm!=null and xqbm!='' ">
			and q.xqbm=#{xqbm}
		</if>
		<if test=" xmbm!=null and xmbm!='' ">
			and x.xmbm=#{xmbm}
		</if>
		<if test=" dhbm!=null and dhbm!='' ">
			and z.dhbm=#{dhbm}
		</if>
		<if test=" xm!=null and xm!='' ">
			and f.xm like '%${xm}%'
		</if>
		<if test=" djlx!=null and djlx!='' ">
			and SUBSTR(m.djbh FROM 1 FOR 2)=#{djlx}
		</if>
		<if test=" djbh!=null and djbh!='' ">
			and m.djbh like '%${djbh}%'
		</if>
	</select>
	
	<select id="selectscwca" parameterType="String" resultType="Double">
	select IFNULL(sum(je),0) je from ywpzmx where djbh in(select djbh from ywpz where djlx in('21','22') and xgbm in ${xmbms} and djrq&lt;#{djrq})
	</select>
	
	<select id="selectdjbhbysq" parameterType="String" resultType="String">
	select djbh from ywpz where sqdbh in ${id} and djlx='21'
	</select>
	
	<select id="selectfw" resultType="io.renren.modules.app.entity.FwxxEntity">
	select fwbm,zqje,zqkkfs,zqdwje from fwxx where zqje>0
	</select>
	
	<select id="selectfw2" resultType="io.renren.modules.app.entity.FwxxEntity">
	select fwbm,zqje2,zqkkfs2,zqdwje2 from fwxx where zqje2>0
	</select>
	
	<select id="selectfwmxxxx" parameterType="String" resultType="io.renren.modules.app.entity.YwpzmxEntity">
	select * from ywpzmx where SUBSTR(djbh FROM 1 FOR 2)='21' and fwbm=#{id}
	</select>
	
	<select id="selectfwmxxxx2" parameterType="String" resultType="io.renren.modules.app.entity.YwpzmxEntity">
	select * from ywpzmx where SUBSTR(djbh FROM 1 FOR 2)='22' and fwbm=#{id}
	</select>
	
	<update id="updateywpzmxft" parameterType="io.renren.modules.app.entity.YwpzmxEntity">
	update ywpzmx set dwje=#{dwje} where djbh=#{djbh} and fwbm=#{fwbm}
	</update>
	
	<update id="updateywpzmxft2" parameterType="io.renren.modules.app.entity.YwpzmxEntity">
	update ywpzmx set grje=#{grje} where djbh=#{djbh} and fwbm=#{fwbm}
	</update>
	
	<update id="updateywpzmxft3" parameterType="io.renren.modules.app.entity.YwpzmxEntity">
	update ywpzmx set dwje=#{dwje},grje=#{grje} where djbh=#{djbh} and fwbm=#{fwbm}
	</update>
	
	<select id="select1111" parameterType="String" resultType="io.renren.modules.app.entity.YwpzmxEntity">
	select ifnull(sum(dwje),0) dwje,ifnull(sum(grje),0) grje from ywpzmx where SUBSTR(djbh FROM 1 FOR 2) in('21','22') and fwbm=#{fwbm} and djbh not in ${djbhss}
	</select>

</mapper>