You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sdny-order/order-management-invoice/src/main/resources/mybatis/mapper/OrderInvoiceInfoMapper.xml

2342 lines
96 KiB

<?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="com.dxhy.order.invoice.module.invoice.dao.OrderInvoiceInfoMapper">
<resultMap id="BaseResultMap"
type="com.dxhy.order.model.OrderInvoiceInfo">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="order_info_id" jdbcType="VARCHAR" property="orderInfoId"/>
<result column="order_process_info_id" jdbcType="VARCHAR" property="orderProcessInfoId"/>
<result column="fpqqlsh" jdbcType="VARCHAR" property="fpqqlsh"/>
<result column="kplsh" jdbcType="VARCHAR" property="kplsh"/>
<result column="ddh" jdbcType="VARCHAR" property="ddh"/>
<result column="mdh" jdbcType="VARCHAR" property="mdh"/>
<result column="ghf_nsrsbh" jdbcType="VARCHAR" property="ghfNsrsbh"/>
<result column="ghf_mc" jdbcType="VARCHAR" property="ghfMc"/>
<result column="ghf_sj" jdbcType="VARCHAR" property="ghfSj"/>
<result column="kphjje" jdbcType="VARCHAR" property="kphjje"/>
<result column="hjbhsje" jdbcType="VARCHAR" property="hjbhsje"/>
<result column="kpse" jdbcType="VARCHAR" property="kpse"/>
<result column="fply" jdbcType="VARCHAR" property="fply"/>
<result column="kplx" jdbcType="VARCHAR" property="kplx"/>
<result column="kpzt" jdbcType="VARCHAR" property="kpzt"/>
<result column="kprq" jdbcType="TIMESTAMP" property="kprq"/>
<result column="fpdm" jdbcType="VARCHAR" property="fpdm"/>
<result column="fphm" jdbcType="VARCHAR" property="fphm"/>
<result column="fpzl_dm" jdbcType="VARCHAR" property="fpzlDm"/>
<result column="jym" jdbcType="VARCHAR" property="jym"/>
<result column="kpr" jdbcType="VARCHAR" property="kpr"/>
<result column="fwm" jdbcType="VARCHAR" property="fwm"/>
<result column="ewm" jdbcType="VARCHAR" property="ewm"/>
<result column="jqbh" jdbcType="VARCHAR" property="jqbh"/>
<result column="pdf_url" jdbcType="VARCHAR" property="pdfUrl"/>
<result column="ch_bz" jdbcType="VARCHAR" property="chBz"/>
<result column="sykchje" jdbcType="VARCHAR" property="sykchje"/>
<result column="sykchbhsje" jdbcType="VARCHAR" property="sykchbhsje"/>
<result column="sykchse" jdbcType="VARCHAR" property="sykchse"/>
<result column="chyy" jdbcType="VARCHAR" property="chyy"/>
<result column="chsj" jdbcType="TIMESTAMP" property="chsj"/>
<result column="sbdm" jdbcType="VARCHAR" property="sbdm"/>
<result column="sbyy" jdbcType="VARCHAR" property="sbyy"/>
<result column="rz_zt" jdbcType="VARCHAR" property="rzZt"/>
<result column="sld" jdbcType="VARCHAR" property="sld"/>
<result column="zf_bz" jdbcType="VARCHAR" property="zfBz"/>
<result column="xhf_mc" property="xhfMc" jdbcType="VARCHAR"/>
<result column="xhf_nsrsbh" property="xhfNsrsbh" jdbcType="VARCHAR"/>
<result column="ent_id" property="entId" jdbcType="VARCHAR"/>
<result column="sld_mc" property="sldMc" jdbcType="VARCHAR"/>
<result column="fjh" property="fjh" jdbcType="VARCHAR"/>
<result column="mongodb_id" property="mongodbId" jdbcType="VARCHAR"/>
<result column="file_store_type" property="fileStoreType" jdbcType="VARCHAR"/>
<result column="dyzt" jdbcType="VARCHAR" property="dyzt"/>
<result column="dyztms" jdbcType="VARCHAR" property="dyztms"/>
<result column="qd_bz" jdbcType="VARCHAR" property="qdbz"/>
<result column="push_jos_status" jdbcType="VARCHAR" property="pushJosStatus"/>
<result column="push_status" jdbcType="VARCHAR"
property="pushStatus"/>
<result column="email_push_status" jdbcType="VARCHAR"
property="emailPushStatus"/>
<result column="short_msg_push_status" jdbcType="VARCHAR"
property="shortMsgPushStatus"/>
<result column="hzxxbbh" jdbcType="VARCHAR" property="hzxxbbh"/>
<result column="sksbdm" jdbcType="VARCHAR" property="sksbdm"/>
<result column="invoice_push_sbyy" jdbcType="VARCHAR" property="invoicePushSbyy"/>
<result column="email_push_sbyy" jdbcType="VARCHAR" property="emailPushSbyy"/>
<result column="short_msg_push_sbyy" jdbcType="VARCHAR" property="shortMsgPushSbyy"/>
<result column="invalid_push_status" jdbcType="VARCHAR" property="invalidPushStatus"/>
<result column="invalid_push_sbyy" jdbcType="VARCHAR" property="invalidPushSbyy"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="skcwdm" jdbcType="VARCHAR" property="skcwdm"/>
<result column="skcwms" jdbcType="VARCHAR" property="skcwms"/>
</resultMap>
<resultMap id="details"
type="com.dxhy.order.model.OrderInvoiceDetail">
<result column="kphjje" property="kphjje" jdbcType="VARCHAR"/>
<result column="fply" property="fply" jdbcType="VARCHAR"/>
<result column="ddly" property="ddly" jdbcType="VARCHAR"/>
<result column="kplx" property="kplx" jdbcType="VARCHAR"/>
<result column="kpr" property="kpr" jdbcType="VARCHAR"/>
<result column="skr" property="skr" jdbcType="VARCHAR"/>
<result column="fhr" property="fhr" jdbcType="VARCHAR"/>
<result column="kpse" property="kpse" jdbcType="VARCHAR"/>
<result column="mdh" property="mdh" jdbcType="VARCHAR"/>
<result column="order_info_id" property="orderInfoId" jdbcType="VARCHAR"/>
<result column="pdf_url" property="pdfUrl" jdbcType="VARCHAR"/>
<result column="qdbz" property="qdbz" jdbcType="VARCHAR"/>
<result column="sld" property="sld" jdbcType="VARCHAR"/>
<result column="sldmc" property="sldmc" jdbcType="VARCHAR"/>
<result column="xhfNsrsbh" property="xhfNsrsbh" jdbcType="VARCHAR"/>
<result column="entId" property="entId" jdbcType="VARCHAR"/>
<result column="xhfmc" property="xhfmc" jdbcType="VARCHAR"/>
<result column="zfbz" property="zfbz" jdbcType="VARCHAR"/>
<result column="id" property="id" jdbcType="VARCHAR"/>
<result column="hjbhsje" property="hjbhsje" jdbcType="VARCHAR"/>
<result column="ghf_sj" property="ghfSj" jdbcType="VARCHAR"/>
<result column="ghf_mc" property="ghfMc" jdbcType="VARCHAR"/>
<result column="ghfNsrsbh" property="ghfNsrsbh" jdbcType="VARCHAR"/>
<result column="fpzlDm" property="fpzlDm" jdbcType="VARCHAR"/>
<result column="fpqqlsh" property="fpqqlsh" jdbcType="VARCHAR"/>
<result column="fphm" property="fphm" jdbcType="VARCHAR"/>
<result column="fpdm" property="fpdm" jdbcType="VARCHAR"/>
<result column="ddh" property="ddh" jdbcType="VARCHAR"/>
<result column="ch_bz" property="chBz" jdbcType="VARCHAR"/>
<result column="kprq" property="kprq" jdbcType="TIMESTAMP"/>
<result column="ghfDz" property="ghfDz" jdbcType="VARCHAR"/>
<result column="ghfDh" property="ghfDh" jdbcType="VARCHAR"/>
<result column="ghfYh" property="ghfYh" jdbcType="VARCHAR"/>
<result column="ghfZh" property="ghfZh" jdbcType="VARCHAR"/>
<result column="bz" property="bz" jdbcType="VARCHAR"/>
<result column="bmbbbh" property="bmbbbh" jdbcType="VARCHAR"/>
<result column="push_status" property="pushStatus" jdbcType="VARCHAR"/>
<result column="push_jos_status" property="pushJosStatus" jdbcType="VARCHAR"/>
<result column="invoice_push_sbyy" property="invoicePushSbyy" jdbcType="VARCHAR"/>
<result column="email_push_sbyy" property="emailPushSbyy" jdbcType="VARCHAR"/>
<result column="short_msg_push_sbyy" property="shortMsgPushSbyy" jdbcType="VARCHAR"/>
<result column="invalid_push_status" property="invalidPushStatus" jdbcType="VARCHAR"/>
<result column="invalid_push_sbyy" property="invalidPushSbyy" jdbcType="VARCHAR"/>
<result column="order_process_info_id" property="orderProcessId" jdbcType="VARCHAR"/>
<result column="xhfDz" property="xhfDz" jdbcType="VARCHAR"/>
<result column="xhfDh" property="xhfDh" jdbcType="VARCHAR"/>
<result column="xhfZh" property="xhfZh" jdbcType="VARCHAR"/>
<result column="xhfYh" property="xhfYh" jdbcType="VARCHAR"/>
<result column="kpxm" property="kpxm" jdbcType="VARCHAR"/>
<result column="ddzt" property="ddzt" jdbcType="VARCHAR"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="kpzt" property="kpzt" jdbcType="VARCHAR"/>
<result column="check_time" property="checkTime" jdbcType="TIMESTAMP"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="sykchje" property="sykchje" jdbcType="VARCHAR"/>
<result column="sykchbhsje" jdbcType="VARCHAR" property="sykchbhsje"/>
<result column="sykchse" jdbcType="VARCHAR" property="sykchse"/>
<result column="bzdh" jdbcType="VARCHAR" property="bzdh"/>
<result column="xtly" jdbcType="VARCHAR" property="xtly"/>
<result column="gsdm" jdbcType="VARCHAR" property="gsdm"/>
<result column="bhzt" jdbcType="VARCHAR" property="bhzt"/>
<result column="ygxm" jdbcType="VARCHAR" property="ygxm"/>
<result column="kppzh" jdbcType="VARCHAR" property="kppzh"/>
<result column="pzgzrq" jdbcType="VARCHAR" property="pzgzrq"/>
<result column="yzfp" jdbcType="VARCHAR" property="yzfp"/>
<result column="origin_ddh" jdbcType="VARCHAR" property="originDdh"/>
<result column="origin_order_id" jdbcType="VARCHAR" property="originOrderId"/>
<result column="kb" jdbcType="VARCHAR" property="kb"/>
</resultMap>
<resultMap id="countMap"
type="com.dxhy.order.model.InvoiceCount">
<result column="count" property="count" jdbcType="VARCHAR"/>
<result column="jshj" property="jshj" jdbcType="VARCHAR"/>
<result column="hjje" property="hjje" jdbcType="VARCHAR"/>
<result column="hjse" property="hjse" jdbcType="VARCHAR"/>
<result column="fpzldm" property="fpzldm" jdbcType="VARCHAR"/>
<result column="time" property="time" jdbcType="VARCHAR"/>
<result column="jqbh" property="jqbh" jdbcType="VARCHAR"/>
<result column="sld" property="sld" jdbcType="VARCHAR"/>
<result column="nsrsbh" property="nsrsbh" jdbcType="VARCHAR"/>
<result column="xhfmc" property="xhfmc" jdbcType="VARCHAR"/>
<result column="kplx" property="kplx" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="countMonthAmountMap" type="com.dxhy.order.invoice.module.invoice.model.vo.InvoiceMonthAmountVo">
<result column="kpyf" property="kpyf" jdbcType="VARCHAR"/>
<result column="hjje" property="hjje" jdbcType="VARCHAR"/>
<result column="bhsje" property="bhsje" jdbcType="VARCHAR"/>
<result column="hjse" property="hjse" jdbcType="VARCHAR"/>
<result column="fpzldm" property="fpzldm" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="countInvoiceMap" type="com.dxhy.order.invoice.module.invoice.model.vo.CountInvoiceVO">
<result column="zkpl" property="zkpl" jdbcType="VARCHAR"/>
<result column="pkpl" property="pkpl" jdbcType="VARCHAR"/>
<result column="skpl" property="skpl" jdbcType="VARCHAR"/>
<result column="dkpl" property="dkpl" jdbcType="VARCHAR"/>
<result column="jkpl" property="jkpl" jdbcType="VARCHAR"/>
<result column="rkpl" property="rkpl" jdbcType="VARCHAR"/>
<result column="dzkpl" property="dzkpl" jdbcType="VARCHAR"/>
<result column="bykpl" property="bykpl" jdbcType="VARCHAR"/>
<result column="sykpl" property="sykpl" jdbcType="VARCHAR"/>
<result column="qlykpl" property="qlykpl" jdbcType="VARCHAR"/>
<result column="xhf_nsrsbh" property="xhfNsrsbh" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="countInvoiceItemMap" type="com.dxhy.order.invoice.module.invoice.model.vo.CountInvoiceItemVO">
<result column="kpl" property="kpl" jdbcType="VARCHAR"/>
<result column="pkpl" property="pkpl" jdbcType="VARCHAR"/>
<result column="zkpl" property="zkpl" jdbcType="VARCHAR"/>
<result column="ekpl" property="ekpl" jdbcType="VARCHAR"/>
<result column="jkpl" property="jkpl" jdbcType="VARCHAR"/>
<result column="rkpl" property="rkpl" jdbcType="VARCHAR"/>
<result column="dzkpl" property="dzkpl" jdbcType="VARCHAR"/>
<result column="tjrq" property="tjrq" jdbcType="VARCHAR"/>
<result column="xhf_nsrsbh" property="xhfNsrsbh" jdbcType="VARCHAR"/>
</resultMap>
<!--订单开票每日统计 销项后台使用-->
<resultMap id="countInvoiceByDayResultMap"
type="com.dxhy.order.invoice.module.invoice.model.vo.CountInoviceByDayVO">
<result column="xhfNsrsbh" property="xhfNsrsbh" jdbcType="VARCHAR"/>
<result column="xhfMc" property="xhfMc" jdbcType="VARCHAR"/>
<result column="ddjsrq" property="ddjsrq" jdbcType="VARCHAR"/>
<result column="ddzsl" property="ddzsl" jdbcType="VARCHAR"/>
<result column="kpcgdds" property="kpcgdds" jdbcType="VARCHAR"/>
<result column="wkpdds" property="wkpdds" jdbcType="VARCHAR"/>
<result column="kpsbdds" property="kpsbdds" jdbcType="VARCHAR"/>
</resultMap>
<!--订单每日开票失败数据统计 销项后台使用-->
<resultMap id="countFailedInvoiceByDayResultMap"
type="com.dxhy.order.invoice.module.invoice.model.vo.CountFailedInoviceByDayVO">
<result column="nsrsbh" property="nsrsbh" jdbcType="VARCHAR"/>
<result column="nsrmc" property="nsrmc" jdbcType="VARCHAR"/>
<result column="ddjsrq" property="ddjsrq" jdbcType="VARCHAR"/>
<result column="sbyy" property="sbyy" jdbcType="VARCHAR"/>
<result column="kpsbdd" property="kpsbdd" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="queryCountByMapResultMap" type="com.dxhy.order.invoice.module.invoice.model.bo.QueryCountInvoiceBO">
<result column="totalcount" jdbcType="VARCHAR" property="totalcount"/>
<result column="totalhjbhsje" jdbcType="VARCHAR" property="totalhjbhsje"/>
<result column="totalkphjje" jdbcType="VARCHAR" property="totalkphjje"/>
<result column="totalkpse" jdbcType="VARCHAR" property="totalkpse"/>
</resultMap>
<resultMap id="queryBzdhInvoiceResultMap" type="com.dxhy.order.model.page.OrderInvoiceInfoVo">
<result column="order_info_id" jdbcType="VARCHAR" property="orderInfoId"/>
<result column="fpqqlsh" jdbcType="VARCHAR" property="fpqqlsh"/>
<result column="ddh" jdbcType="VARCHAR" property="ddh"/>
<result column="bzdh" jdbcType="VARCHAR" property="bzdh"/>
<result column="ddzt" jdbcType="VARCHAR" property="ddzt"/>
<result column="fpzldm" jdbcType="VARCHAR" property="fpzlDm"/>
<result column="xhf_nsrsbh" jdbcType="VARCHAR" property="xhfNsrsbh"/>
<result column="xhf_mc" jdbcType="VARCHAR" property="xhfMc"/>
<result column="ghf_nsrsbh" jdbcType="VARCHAR" property="ghfNsrsbh"/>
<result column="ghf_mc" jdbcType="VARCHAR" property="ghfMc"/>
<result column="ent_id" jdbcType="VARCHAR" property="entId"/>
<result column="xtly" jdbcType="VARCHAR" property="xtly"/>
<result column="fpdm" jdbcType="VARCHAR" property="fpdm"/>
<result column="fphm" jdbcType="VARCHAR" property="fphm"/>
<result column="kphjje" jdbcType="VARCHAR" property="kphjje"/>
<result column="kpse" jdbcType="VARCHAR" property="kpse"/>
<result column="hjbhsje" jdbcType="VARCHAR" property="hjbhsje"/>
<result column="sykchje" jdbcType="VARCHAR" property="sykchje"/>
<result column="sykchbhsje" jdbcType="VARCHAR" property="sykchbhsje"/>
<result column="sykchse" jdbcType="VARCHAR" property="sykchse"/>
<result column="zf_bz" jdbcType="VARCHAR" property="zfBz"/>
<result column="ch_bz" jdbcType="VARCHAR" property="chBz"/>
<result column="fjh" jdbcType="VARCHAR" property="fjh"/>
<result column="kprq" jdbcType="TIMESTAMP" property="kprq"/>
</resultMap>
<resultMap id="countInvoiceByMonthResultMap" type="com.dxhy.order.invoice.module.invoice.model.bo.CountInvoiceByMonthBO">
<result column="dm" jdbcType="VARCHAR" property="dm"/>
<result column="zcount" jdbcType="VARCHAR" property="zcount"/>
</resultMap>
<sql id="Base_Column_List">
id,
order_info_id,
order_process_info_id,
fpqqlsh,
kplsh,
ddh,
mdh,
ghf_mc,
ghf_sj,
kphjje,
hjbhsje,
kpse,
fply,
kplx,
kpzt,
kprq,
fpdm,
fphm,
fpzl_dm,
jym,
kpr,
fwm,
ewm,
jqbh,
pdf_url,
ch_bz,
sykchje,
sykchbhsje,
sykchse,
chyy,
chsj,
sbdm,
sbyy,
rz_zt,
sld,
zf_bz,
xhf_nsrsbh,
ent_id,
dyzt,
dyztms,
sld_mc,
fjh,
file_store_type,
mongodb_id,
qd_bz,
push_status,
push_jos_status,
email_push_status,
short_msg_push_status,
hzxxbbh,
sksbdm,
invoice_push_sbyy,
email_push_sbyy,
short_msg_push_sbyy,
invalid_push_status,
invalid_push_sbyy,
create_time,
update_time,
xhf_mc,
skcwdm,
skcwms
</sql>
<!-- 此处分组按照条件,再次使用的时候注意! -->
<select id="getCountOfMoreMonth" resultMap="countMap">
<bind name="dataType" value="${dataType}"/>
SELECT
count( oii.kphjje ) count,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.kphjje as DECIMAL(40,2)) , 0.00) ) jshj,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.hjbhsje as DECIMAL(40,2)) , 0.00) ) hjje,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.kpse as DECIMAL(40,2)) , 0.00) ) hjse,
Max(oii.kplx) kplx,
Max(oii.xhf_nsrsbh) nsrsbh,
Max(oii.xhf_mc) xhfmc,
Max(oii.sld) sld,
Max(oii.sld_mc) sldMc,
Max(oii.fjh) fjh,
Max(oii.jqbh) jqbh,
<if test="dataType == 0">
<if test="timeFormatFlag == 0">
DATE_FORMAT(oii.kprq, '%Y-%m' ) time
</if>
<if test="timeFormatFlag == 1">
DATE_FORMAT(oii.kprq, '%Y-%m-%d' ) time
</if>
</if>
<if test="dataType == 1">
<if test="timeFormatFlag == 0">
trunc(Max(oii.kprq), 'mm' ) time
</if>
<if test="timeFormatFlag == 1">
trunc(Max(oii.kprq)) time
</if>
</if>
FROM
order_invoice_info oii
WHERE
oii.kpzt = '2'
<if test="dataType == 0">
<if test="startTime != null">
AND oii.kprq &gt;= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND oii.kprq &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="dataType == 1">
<if test="startTime != null">
AND oii.kprq &gt;= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND oii.kprq &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="shList != null and shList.size() == 0">
and oii.xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sld != '' and sld != null">
AND sld = #{sld}
</if>
<if test="sldFlag == 1 or timeFlag == 1 or kplxFlag == 1">
GROUP BY
</if>
<if test="timeFlag == 1">
<if test="dataType == 1">
<if test="timeFormatFlag == 0">
to_char(Max(oii.kprq),'yyyy-mm')
</if>
<if test="timeFormatFlag == 1">
to_char(Max(oii.kprq),'yyyy-mm-dd')
</if>
</if>
<if test="dataType == 0">
time
</if>
</if>
<choose>
<when test="timeFlag == 1 and sldFlag == 1">
,sld
</when>
<when test="sldFlag == 1">
sld
</when>
</choose>
<if test="kplxFlag == 1">
,kplx
</if>
ORDER BY
time DESC
</select>
<!-- 此处分组按照条件,再次使用的时候注意! -->
<select id="getCountOfMoreMonthBySldMc" resultMap="countMap">
<bind name="dataType" value="${dataType}"/>
SELECT
count( oii.kphjje ) count,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.kphjje as DECIMAL(40,2)) , 0.00) ) jshj,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.hjbhsje as DECIMAL(40,2)) , 0.00) ) hjje,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.kpse as DECIMAL(40,2)) , 0.00) ) hjse,
Max(oii.kplx) kplx,
Max(oii.xhf_nsrsbh) nsrsbh,
Max(oii.xhf_mc) xhfmc,
Max(oii.sld) sld,
Max(oii.sld_mc) sldMc,
Max(oii.sld_mc) sld_mc,
Max(oii.fjh) fjh,
Max(oii.jqbh) jqbh,
<if test="dataType == 0">
DATE_FORMAT(oii.kprq, '%Y-%m-%d' ) time
</if>
<if test="dataType == 1">
trunc(Max(oii.kprq)) time
</if>
FROM
order_invoice_info oii
WHERE
oii.kpzt = '2'
<if test="dataType == 0">
<if test="startTime != null">
AND oii.kprq &gt;= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND oii.kprq &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="dataType == 1">
<if test="startTime != null">
AND oii.kprq &gt;= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND oii.kprq &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="shList != null and shList.size() == 0">
and oii.xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="sldMc != '' and sldMc != null">
AND sld_mc = #{sldMc}
</if>
<if test="sldFlag == 1 ">
GROUP BY sld_mc
</if>
ORDER BY
time DESC
</select>
<!--按月统计开票-->
<select id="getDataOfMoreMonth" resultMap="countMap">
<bind name="dataType" value="${dataType}"/>
SELECT
count( oii.kphjje ) count,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.kphjje as DECIMAL(40,2)) , 0.00) ) jshj,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.hjbhsje as DECIMAL(40,2)) , 0.00) ) hjje,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.kpse as DECIMAL(40,2)) , 0.00) ) hjse,
Max(oii.kplx) kplx,
oii.xhf_nsrsbh nsrsbh,
oii.fpzl_dm fpzldm,
Max(oii.jqbh) jqbh,
Max(oii.sld) sld,
Max(oii.xhf_mc) xhfmc,
<if test="dataType == 0">
<if test="flagTime == 0">
DATE_FORMAT( oii.kprq, '%Y-%m' ) time
</if>
<if test="flagTime == 1">
DATE_FORMAT( oii.kprq, '%Y-%m-%d' ) time
</if>
</if>
<if test="dataType == 1">
<if test="flagTime == 0">
to_char(Max(oii.kprq),'yyyy-mm') time
</if>
<if test="flagTime == 1">
to_char(Max(oii.kprq),'yyyy-mm-dd') time
</if>
</if>
FROM
order_invoice_info oii
WHERE
oii.kpzt = '2'
<if test="dataType == 0">
<if test="startTime != null">
AND oii.kprq &gt;= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND oii.kprq &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="dataType == 1">
<if test="startTime != null">
AND oii.kprq >= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND oii.kprq &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="shList != null and shList.size() == 0">
and oii.xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
<if test="dataType == 0">
time
</if>
<if test="dataType == 1">
oii.kprq
</if>
<if test="flagFPZLDM == 1">
,oii.fpzl_dm
</if>
,oii.xhf_nsrsbh
ORDER BY
<if test="dataType == 0">
time
</if>
<if test="dataType == 1">
oii.kprq
</if>
DESC
</select>
<insert id="insertOrderInvoiceInfo"
parameterType="com.dxhy.order.model.OrderInvoiceInfo">
insert into order_invoice_info (id,
order_info_id,
order_process_info_id,
fpqqlsh,
kplsh,
ddh,
mdh,
ghf_mc,
ghf_sj,
kphjje,
hjbhsje,
kpse,
fply,
kplx,
kpzt,
kprq,
fpdm,
fphm,
fpzl_dm,
jym,
kpr,
fwm,
ewm,
jqbh,
pdf_url,
ch_bz,
sykchje,
sykchbhsje,
sykchse,
chsj,
chyy,
sbdm,
sbyy,
rz_zt,
zf_bz,
xhf_mc,
xhf_nsrsbh,
ent_id,
dyzt,
dyztms,
sld,
sld_mc,
fjh,
qd_bz,
push_status,
push_jos_status,
hzxxbbh,
sksbdm,
invoice_push_sbyy,
email_push_sbyy,
short_msg_push_status,
short_msg_push_sbyy,
invalid_push_status,
invalid_push_sbyy,
create_time,
update_time,
skcwdm,
skcwms)
values (#{id,jdbcType=VARCHAR},
#{orderInfoId,jdbcType=VARCHAR},
#{orderProcessInfoId,jdbcType=VARCHAR},
#{fpqqlsh,jdbcType=VARCHAR},
#{kplsh,jdbcType=VARCHAR},
#{ddh,jdbcType=VARCHAR},
#{mdh,jdbcType=VARCHAR},
#{ghfMc,jdbcType=VARCHAR},
#{ghfSj,jdbcType=VARCHAR},
#{kphjje,jdbcType=VARCHAR},
#{hjbhsje,jdbcType=VARCHAR},
#{kpse,jdbcType=VARCHAR},
#{fply,jdbcType=VARCHAR},
#{kplx,jdbcType=VARCHAR},
#{kpzt,jdbcType=VARCHAR},
#{kprq,jdbcType=TIMESTAMP},
#{fpdm,jdbcType=VARCHAR},
#{fphm,jdbcType=VARCHAR},
#{fpzlDm,jdbcType=VARCHAR},
#{jym,jdbcType=VARCHAR},
#{kpr,jdbcType=VARCHAR},
#{fwm,jdbcType=VARCHAR},
#{ewm,jdbcType=VARCHAR},
#{jqbh,jdbcType=VARCHAR},
#{pdfUrl,jdbcType=VARCHAR},
#{chBz,jdbcType=VARCHAR},
#{sykchje,jdbcType=VARCHAR},
#{sykchbhsje,jdbcType=VARCHAR},
#{sykchse,jdbcType=VARCHAR},
#{chsj,jdbcType=TIMESTAMP},
#{chyy,jdbcType=VARCHAR},
#{sbdm,jdbcType=VARCHAR},
#{sbyy,jdbcType=VARCHAR},
#{rzZt,jdbcType=VARCHAR},
#{zfBz,jdbcType=VARCHAR},
#{xhfMc,jdbcType=VARCHAR},
#{xhfNsrsbh,jdbcType=VARCHAR},
#{entId,jdbcType=VARCHAR},
#{dyzt,jdbcType=VARCHAR},
#{dyztms,jdbcType=VARCHAR},
#{sld,jdbcType=VARCHAR},
#{sldMc,jdbcType=VARCHAR},
#{fjh,jdbcType=VARCHAR},
#{qdbz,jdbcType=VARCHAR},
#{pushStatus,jdbcType=VARCHAR},
#{pushJosStatus,jdbcType=VARCHAR},
#{hzxxbbh,jdbcType=VARCHAR},
#{sksbdm,jdbcType=VARCHAR},
#{invoicePushSbyy,jdbcType=VARCHAR},
#{emailPushSbyy,jdbcType=VARCHAR},
#{shortMsgPushStatus,jdbcType=VARCHAR},
#{shortMsgPushSbyy,jdbcType=VARCHAR},
#{invalidPushStatus,jdbcType=VARCHAR},
#{invalidPushSbyy,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},
#{skcwdm,jdbcType=VARCHAR},
#{skcwms,jdbcType=VARCHAR})
</insert>
<update id="updateOrderInvoiceInfoByFpqqlsh" parameterType="com.dxhy.order.model.OrderInvoiceInfo">
update order_invoice_info
<set>
<if test="orderInvoiceInfo.orderInfoId != null">
order_info_id = #{orderInvoiceInfo.orderInfoId,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.orderProcessInfoId != null">
order_process_info_id =
#{orderInvoiceInfo.orderProcessInfoId,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.kplsh != null">
kplsh = #{orderInvoiceInfo.kplsh,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.ddh != null">
ddh = #{orderInvoiceInfo.ddh,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.mdh != null">
mdh = #{orderInvoiceInfo.mdh,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.ghfMc != null">
ghf_mc = #{orderInvoiceInfo.ghfMc,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.ghfSj != null">
ghf_sj = #{orderInvoiceInfo.ghfSj,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.kphjje != null">
kphjje = #{orderInvoiceInfo.kphjje,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.hjbhsje != null">
hjbhsje = #{orderInvoiceInfo.hjbhsje,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.kpse != null">
kpse = #{orderInvoiceInfo.kpse,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.fply != null">
fply = #{orderInvoiceInfo.fply,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.kplx != null">
kplx = #{orderInvoiceInfo.kplx,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.kpzt != null">
kpzt = #{orderInvoiceInfo.kpzt,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.kprq != null">
kprq = #{orderInvoiceInfo.kprq,jdbcType=TIMESTAMP},
</if>
<if test="orderInvoiceInfo.fpdm != null">
fpdm = #{orderInvoiceInfo.fpdm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.fphm != null">
fphm = #{orderInvoiceInfo.fphm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.fpzlDm != null">
fpzl_dm = #{orderInvoiceInfo.fpzlDm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.jym != null">
jym = #{orderInvoiceInfo.jym,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.kpr != null">
kpr = #{orderInvoiceInfo.kpr,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.fwm != null">
fwm = #{orderInvoiceInfo.fwm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.ewm != null">
ewm = #{orderInvoiceInfo.ewm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.jqbh != null">
jqbh = #{orderInvoiceInfo.jqbh,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.pdfUrl != null">
pdf_url = #{orderInvoiceInfo.pdfUrl,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.chBz != null">
ch_bz = #{orderInvoiceInfo.chBz,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.sykchje != null">
sykchje = #{orderInvoiceInfo.sykchje,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.sykchbhsje != null">
sykchbhsje = #{orderInvoiceInfo.sykchbhsje,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.sykchse != null">
sykchse = #{orderInvoiceInfo.sykchse,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.chsj != null">
chsj = #{orderInvoiceInfo.chsj,jdbcType=TIMESTAMP},
</if>
<if test="orderInvoiceInfo.sbdm != null">
sbdm = #{orderInvoiceInfo.sbdm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.sbyy != null">
sbyy = #{orderInvoiceInfo.sbyy,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.rzZt != null">
rz_zt = #{orderInvoiceInfo.rzZt,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.zfBz != null">
zf_bz = #{orderInvoiceInfo.zfBz,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.zfyy != null">
zfyy = #{orderInvoiceInfo.zfyy,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.zfsj != null">
zfsj = #{orderInvoiceInfo.zfsj,jdbcType=TIMESTAMP},
</if>
<if test="orderInvoiceInfo.xhfMc != null">
xhf_mc = #{orderInvoiceInfo.xhfMc,jdbcType=VARCHAR},
</if>
<!-- <if test="orderInvoiceInfo.xhfNsrsbh != null">
xhf_nsrsbh = #{orderInvoiceInfo.xhfNsrsbh,jdbcType=VARCHAR},
</if>-->
<if test="orderInvoiceInfo.entId != null">
ent_id = #{orderInvoiceInfo.entId,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.sld != null">
sld = #{orderInvoiceInfo.sld,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.sldMc != null">
sld_mc = #{orderInvoiceInfo.sldMc,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.fjh != null">
fjh = #{orderInvoiceInfo.fjh,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.qdbz != null">
qd_bz = #{orderInvoiceInfo.qdbz,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.hzxxbbh != null">
hzxxbbh = #{orderInvoiceInfo.hzxxbbh,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.sksbdm != null">
sksbdm = #{orderInvoiceInfo.sksbdm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.invoicePushSbyy != null">
invoice_push_sbyy = #{orderInvoiceInfo.invoicePushSbyy,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.emailPushSbyy != null">
email_push_sbyy = #{orderInvoiceInfo.emailPushSbyy,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.shortMsgPushStatus != null">
short_msg_push_status = #{orderInvoiceInfo.shortMsgPushStatus,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.shortMsgPushSbyy != null">
short_msg_push_sbyy = #{orderInvoiceInfo.shortMsgPushSbyy,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.invalidPushStatus != null">
invalid_push_status = #{orderInvoiceInfo.invalidPushStatus,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.invalidPushSbyy != null">
invalid_push_sbyy = #{orderInvoiceInfo.invalidPushSbyy,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.pushStatus != null and orderInvoiceInfo.pushStatus != ''">
push_status = #{orderInvoiceInfo.pushStatus,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.pushJosStatus != null and orderInvoiceInfo.pushJosStatus != ''">
push_jos_status = #{orderInvoiceInfo.pushJosStatus,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.emailPushStatus != null and orderInvoiceInfo.emailPushStatus != ''">
email_push_status = #{orderInvoiceInfo.emailPushStatus,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.dyzt != null">
dyzt = #{orderInvoiceInfo.dyzt,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.dyztms != null">
dyztms = #{orderInvoiceInfo.dyztms,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.fileStoreType != null">
file_store_type = #{orderInvoiceInfo.fileStoreType,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.mongodbId != null">
mongodb_id = #{orderInvoiceInfo.mongodbId,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.createTime != null">
create_time = #{orderInvoiceInfo.createTime,jdbcType=TIMESTAMP},
</if>
<if test="orderInvoiceInfo.updateTime != null">
update_time = #{orderInvoiceInfo.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="orderInvoiceInfo.skcwdm != null">
skcwdm = #{orderInvoiceInfo.skcwdm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.skcwms != null">
skcwms = #{orderInvoiceInfo.skcwms,jdbcType=VARCHAR},
</if>
</set>
<where>
<if test="orderInvoiceInfo.fpqqlsh != null">
and fpqqlsh = #{orderInvoiceInfo.fpqqlsh,jdbcType=VARCHAR}
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</update>
<update id="updateInvoiceInfoByNoAndCode" parameterType="com.dxhy.order.model.OrderInvoiceInfo">
update order_invoice_info
<set>
<if test="orderInvoiceInfo.voucherNo != null">
voucher_no = #{orderInvoiceInfo.voucherNo,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.accountDate != null">
account_date = #{orderInvoiceInfo.accountDate,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.checkNo != null">
check_no = #{orderInvoiceInfo.checkNo,jdbcType=VARCHAR},
</if>
</set>
<where>
<if test="orderInvoiceInfo.fpqqlsh != null">
and fpqqlsh = #{orderInvoiceInfo.fpqqlsh,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.fpdm != null and orderInvoiceInfo.fpdm != ''">
fpdm = #{orderInvoiceInfo.fpdm,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.fphm != null and orderInvoiceInfo.fphm != ''">
fphm = #{orderInvoiceInfo.fphm,jdbcType=VARCHAR},
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</update>
<select id="selectOrderInvoiceInfoByFpdmAndFphm" resultMap="BaseResultMap"
parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from order_invoice_info
<where>
<if test="fpdm !=null and fpdm != '' ">
and fpdm=#{fpdm,jdbcType=VARCHAR}
</if>
<if test="fphm !=null and fphm != '' ">
and fphm=#{fphm,jdbcType=VARCHAR}
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectInvoiceByOrder" resultMap="BaseResultMap"
parameterType="java.util.Map">
<bind name="dataType" value="${dataType}"/>
select
<include refid="Base_Column_List"/>
from order_invoice_info
where
<if test="dataType == 0">
<if test="map.startTime != null">
kprq>=DATE_FORMAT(#{map.startTime,jdbcType=VARCHAR},'%Y-%m-%d') and
</if>
<if test="map.endTime != null">
DATE_FORMAT(DATE_ADD(#{map.endTime,jdbcType=VARCHAR},INTERVAL 1 DAY),'%Y-%m-%d')>=kprq and
</if>
</if>
<if test="dataType == 1">
<if test="map.startTime != null">
trunc(kprq)>=to_date(#{map.startTime},'yyyy-mm-dd hh24:mi:ss') and
</if>
<if test="map.endTime != null">
to_date(#{map.endTime,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss')>=trunc(kprq) and
</if>
</if>
kpzt ='2'
<if test="map.zfbz!=null and map.zfbz!= '' ">
and zf_bz=#{map.zfbz,jdbcType=VARCHAR}
</if>
<if test="map.zfbzList != null">
and zf_bz in
<foreach collection="map.zfbzList" index="index" item="zfbzit"
open="(" separator="," close=")">
#{zfbzit,jdbcType=VARCHAR}
</foreach>
</if>
<if test="map.dyzt != null and map.dyzt != ''">
and dyzt = #{map.dyzt,jdbcType=VARCHAR}
</if>
<if test="map.dyztms != null and map.dyztms != ''">
and dyztms = #{map.dyztms,jdbcType=VARCHAR}
</if>
<if test="map.fpdm != null and map.fpdm != ''">
and fpdm = #{map.fpdm,jdbcType=VARCHAR}
</if>
<if test="map.fphm != null and map.fphm != '' ">
and fphm = #{map.fphm,jdbcType=VARCHAR}
</if>
<if test="map.fpzlDm != null and map.fpzlDm != ''">
and fpzl_dm = #{map.fpzlDm,jdbcType=VARCHAR}
</if>
<if test="map.fply != null and map.fply != ''">
and fply = #{map.fply,jdbcType=VARCHAR}
</if>
<if test="map.kplx != null and map.kplx != ''">
and kplx = #{map.kplx,jdbcType=VARCHAR}
</if>
<if test="map.fjh != null and map.fjh != ''">
and fjh= #{map.fjh,jdbcType=VARCHAR}
</if>
<if test="dataType == 0">
<if test="map.ddh != null and map.ddh != '' ">
and ddh like concat('%', #{map.ddh,jdbcType=VARCHAR},'%')
</if>
<if test="map.mdh != null and map.mdh != ''">
and mdh like concat('%',#{map.mdh,jdbcType=VARCHAR},'%')
</if>
<if test="map.ghfMc != null and map.ghfMc != '' ">
and ghf_mc like concat('%',#{map.ghfMc,jdbcType=VARCHAR},'%')
</if>
</if>
<if test="dataType == 1">
<if test="map.ddh != null and map.ddh != '' ">
and ddh like concat(concat('%', #{map.ddh,jdbcType=VARCHAR}),'%')
</if>
<if test="map.mdh != null and map.mdh != ''">
and mdh like concat(concat('%',#{map.mdh,jdbcType=VARCHAR}),'%')
</if>
<if test="map.ghfMc != null and map.ghfMc != '' ">
and ghf_mc like concat(concat('%',#{map.ghfMc,jdbcType=VARCHAR}),'%')
</if>
</if>
<if test="map.kpr != null and map.kpr != '' ">
and kpr = #{map.kpr,jdbcType=VARCHAR}
</if>
<if test="map.sld != null and map.sld != '' ">
and sld = #{map.sld,jdbcType=VARCHAR}
</if>
<if test="map.sldMc != null and map.sldMc != '' ">
and sld_mc = #{map.sldMc,jdbcType=VARCHAR}
</if>
<if test="map.qdbz != null ">
and qd_bz in
<foreach collection="map.qdbz" index="index" item="item"
open="(" separator="," close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</if>
<if test="map.fpzlList != null and map.fpzlList.size != 0">
and fpzl_dm in
<foreach collection="map.fpzlList" index="index" item="fpzl"
open="(" separator="," close=")">
#{fpzl,jdbcType=VARCHAR}
</foreach>
</if>
<if test="map.fphmStart != null and map.fphmStart != ''">
and fphm >= #{map.fphmStart,jdbcType=VARCHAR}
</if>
<if test="map.fphmEnd != null and map.fphmEnd != ''">
AND
#{map.fphmEnd,jdbcType=VARCHAR}>= fphm
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entList != null and entList.size() == 0">
and (ent_id = '' or ent_id is null)
</if>
<if test="entList != null and entList.size() == 1">
and (ent_id =
<foreach collection="entList" index="index" item="item">
#{item}
</foreach> or ent_id is null)
</if>
<if test="entList != null and entList.size() > 1">
and (ent_id in
<foreach collection="entList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach> or ent_id is null)
</if>
order by kprq desc,fpdm desc,fphm desc
</select>
<select id="selectVehicleInvoiceList" resultMap="BaseResultMap" parameterType="java.util.Map">
<bind name="dataType" value="${dataType}"/>
SELECT
oii.id,
oii.order_info_id,
oii.order_process_info_id,
oii.fpqqlsh,
oii.kplsh,
oii.ddh,
oii.mdh,
oi.ghf_nsrsbh,
oii.ghf_mc,
oii.ghf_sj,
oii.kphjje,
oii.hjbhsje,
oii.kpse,
oii.fply,
oii.kplx,
oii.kpzt,
oii.kprq,
oii.fpdm,
oii.fphm,
oii.fpzl_dm,
oii.jym,
oii.kpr,
oii.fwm,
oii.ewm,
oii.jqbh,
oii.pdf_url,
oii.ch_bz,
oii.sykchje,
oii.sykchbhsje,
oii.sykchse,
oii.chyy,
oii.chsj,
oii.sbdm,
oii.sbyy,
oii.rz_zt,
oii.sld,
oii.zf_bz,
oii.xhf_nsrsbh,
oii.ent_id,
oii.dyzt,
oii.dyztms,
oii.sld_mc,
oii.fjh,
oii.file_store_type,
oii.mongodb_id,
oii.qd_bz,
oii.push_status,
oii.push_jos_status,
oii.email_push_status,
oii.short_msg_push_status,
oii.hzxxbbh,
oii.sksbdm,
oii.invoice_push_sbyy,
oii.email_push_sbyy,
oii.short_msg_push_sbyy,
oii.invalid_push_status,
oii.invalid_push_sbyy,
oii.create_time,
oii.update_time,
oii.xhf_mc,
oii.skcwdm,
oii.skcwms
FROM
order_invoice_info oii
LEFT JOIN order_info oi ON oii.order_info_id = oi.id
WHERE
<if test="dataType == 0">
<if test="map.startTime != null and map.startTime != '' ">
oii.kprq>=#{map.startTime,jdbcType=TIMESTAMP} and
</if>
<if test="map.endTime != null and map.startTime != '' ">
#{map.endTime,jdbcType=TIMESTAMP}>=oii.kprq and
</if>
</if>
<if test="dataType == 1">
<if test="map.startTime != null">
trunc(oii.kprq)>=to_date(#{map.startTime},'yyyy-mm-dd hh24:mi:ss') and
</if>
<if test="map.endTime != null">
to_date(#{map.endTime,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss')>=trunc(oii.kprq) and
</if>
</if>
oii.kpzt ='2'
AND oii.zf_bz in ('0','1','3')
AND oii.fpzl_dm = '0'
AND (oi.qd_bz = '5' or oi.qd_bz = '6')
AND oii.fjh= #{map.fjh,jdbcType=VARCHAR}
<if test="shList != null and shList.size() == 0">
and oii.xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
ORDER BY
oii.kprq DESC,oii.fpdm DESC,oii.fphm DESC
</select>
<!-- <select id="selectByOrderIdArray" resultMap="BaseResultMap"-->
<!-- parameterType="string">-->
<!-- select-->
<!-- <include refid="Base_Column_List"/>-->
<!-- from order_invoice_info-->
<!-- where order_info_id in-->
<!-- <foreach collection="orderIdArrays" item="orderId" open="("-->
<!-- close=")" separator=",">-->
<!-- #{orderId}-->
<!-- </foreach>-->
<!-- </select>-->
<sql id="invoiceList">
SELECT oi.ghf_dz ghfDz,
oi.ghf_dh ghfDh,
oi.ghf_yh ghfYh,
oi.ghf_zh ghfZh,
oi.bz,
oi.bbm_bbh bmbbbh,
oi.xhf_mc xhfmc,
oi.ghf_nsrsbh ghfNsrsbh,
oi.ghf_email ghfEmail,
oi.xhf_dz xhfDz,
oi.xhf_dh xhfDh,
oi.xhf_zh xhfZh,
oi.xhf_yh xhfYh,
oii.ddh,
oii.fpdm,
oii.fphm,
oii.ghf_sj,
oii.ghf_mc,
oii.pdf_url,
oii.qd_bz qdbz,
oii.id,
oii.kprq,
oii.hjbhsje,
oii.fply,
oii.kplx,
oii.kphjje,
oii.kpse,
oii.kpr,
oii.zf_bz zfbz,
oii.fpzl_dm fpzlDm,
oii.fpqqlsh,
oii.ch_bz,
oii.mdh,
oii.order_info_id,
oii.sld,
oii.push_status,
oii.push_jos_status,
oii.kpzt,
oii.xhf_nsrsbh xhfNsrsbh,
oii.ent_id entId,
oii.sld_mc sldmc,
opi.ddly,
oii.order_process_info_id,
opi.ywlx,
opi.ywlx_id,
opi.kpxm,
opi.ddzt,
opi.update_time,
opi.check_time,
opi.create_time,
oii.sykchje,
oii.sykchbhsje,
oii.sykchse,
oii.short_msg_push_status,
oii.invoice_push_sbyy,
oii.email_push_sbyy,
oii.short_msg_push_sbyy,
oii.invalid_push_status,
oii.invalid_push_sbyy,
oii.email_push_status,
oii.sksbdm,
oii.skcwdm,
oii.skcwms,
opi.bzdh,
opi.xtly,
opi.gsdm,
opi.bhzt,
opi.ygxm,
opi.kppzh,
opi.pzgzrq,
opi.yzfp,
opi.origin_ddh,
opi.origin_order_id,
opi.kb
FROM order_invoice_info oii
LEFT JOIN order_info oi ON oii.order_info_id = oi.id
LEFT JOIN order_process_info opi ON oii.order_info_id = opi.order_info_id
<where>
<!-- 默认展示已开具的发票 -->
<choose>
<when test="map.kpzt != null and map.kpzt !=''">
<!-- 优税小程序 默认加载所有开票状态数据 -->
<choose>
<when test='map.kpzt == "7"'>
</when>
<otherwise>
and oii.kpzt = #{map.kpzt,jdbcType=VARCHAR}
</otherwise>
</choose>
</when>
<otherwise>
and oii.kpzt = '2'
</otherwise>
</choose>
<if test="map.ddly != null and map.ddly.size != 0">
and opi.ddly in
<foreach collection="map.ddly" index="index" item="ddlyit"
open="(" separator="," close=")">
#{ddlyit,jdbcType=VARCHAR}
</foreach>
</if>
<if test="map.qdbz != null">
and oii.qd_bz in
<foreach collection="map.qdbz" index="index" item="qdbzit"
open="(" separator="," close=")">
#{qdbzit,jdbcType=VARCHAR}
</foreach>
</if>
<if test="map.fpdm != null and map.fpdm != ''">
AND oii.fpdm = #{map.fpdm,jdbcType=VARCHAR}
</if>
<choose>
<when test="map.fphm != null and map.fphm !=''">
AND oii.fphm = #{map.fphm,jdbcType=VARCHAR}
</when>
<otherwise>
<if test="map.fpqh != null and map.fpqh != ''">
AND oii.fphm <![CDATA[ >= ]]> #{map.fpqh,jdbcType=VARCHAR}
</if>
<if test="map.fpzh != null and map.fpzh != ''">
AND oii.fphm <![CDATA[ <= ]]> #{map.fpzh,jdbcType=VARCHAR}
</if>
</otherwise>
</choose>
<if test="map.sld != null and map.sld !=''">
AND oii.sld = #{map.sld,jdbcType=VARCHAR}
</if>
<if test="map.sldMc != null and map.sldMc !=''">
AND oii.sld_mc = #{map.sldMc,jdbcType=VARCHAR}
</if>
<if test="map.ywlx != null and map.ywlx !=''">
AND opi.ywlx = #{map.ywlx,jdbcType=VARCHAR}
</if>
<if test="map.fply != null and map.fply!=''">
AND oii.fply = #{map.fply,jdbcType=VARCHAR}
</if>
<if test="map.kplx != null and map.kplx!=''">
AND oii.kplx = #{map.kplx,jdbcType=VARCHAR}
</if>
<if test="map.ddh != null and map.ddh!=''">
AND oii.ddh = #{map.ddh,jdbcType=VARCHAR}
</if>
<if test="dataType == 0">
<if test="map.gmfmc != null and map.gmfmc != ''">
AND opi.ghf_mc like concat('%', #{map.gmfmc,jdbcType=VARCHAR},'%')
</if>
</if>
<if test="dataType == 1">
<if test="map.gmfmc != null and map.gmfmc != ''">
AND opi.ghf_mc like concat(concat('%', #{map.gmfmc,jdbcType=VARCHAR}),'%')
</if>
</if>
<if test="map.fplx != null and map.fplx != '' ">
AND oii.fpzl_dm = #{map.fplx,jdbcType=VARCHAR}
</if>
<if test="map.fpzldm != null and map.fpzldm.size() == 1">
and oii.fpzl_dm =
<foreach collection="map.fpzldm" index="index" item="item">
#{item}
</foreach>
</if>
<if test="map.fpzldm != null and map.fpzldm.size() > 1">
and oii.fpzl_dm in
<foreach collection="map.fpzldm" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.kpr != null and map.kpr != '' ">
AND oii.kpr = #{map.kpr,jdbcType=VARCHAR}
</if>
<if test="map.mdh != null and map.mdh != '' ">
AND oii.mdh = #{map.mdh,jdbcType=VARCHAR}
</if>
<!-- 时间查询条件 此处兼容优税发票小助手 根据queryTime字段判断时间查询的字段-->
<choose>
<when test='map.queryTime !=null and map.queryTime == "updateTime" '>
<if test="dataType == 0">
<if test="map.startTime != null and map.startTime!= '' ">
AND opi.update_time >= #{map.startTime,jdbcType=TIMESTAMP}
</if>
<if test="map.endTime != null and map.endTime!= '' ">
AND #{map.endTime,jdbcType=TIMESTAMP} >= opi.update_time
</if>
</if>
<if test="dataType == 1">
<if test="map.startTime != null and map.startTime!= '' ">
AND trunc(opi.update_time) &gt;= to_date(#{map.startTime},'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="map.endTime != null and map.endTime!= '' ">
AND trunc(opi.update_time) &lt;= to_date(#{map.endTime},'yyyy-mm-dd hh24:mi:ss')
</if>
</if>
</when>
<when test='map.queryTime !=null and map.queryTime == "checkTime" '>
<if test="dataType == 0">
<if test="map.startTime != null and map.startTime!= '' ">
AND opi.check_time >= #{map.startTime,jdbcType=TIMESTAMP}
</if>
<if test="map.endTime != null and map.endTime!= '' ">
AND #{map.endTime,jdbcType=TIMESTAMP} >= opi.check_time
</if>
</if>
<if test="dataType == 1">
<if test="map.startTime != null and map.startTime!= '' ">
AND trunc(opi.check_time) &gt;= to_date(#{map.startTime},'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="map.endTime != null and map.endTime!= '' ">
AND trunc(opi.check_time) &lt;= to_date(#{map.endTime},'yyyy-mm-dd hh24:mi:ss')
</if>
</if>
</when>
<otherwise>
<if test="dataType == 0">
<if test="map.startTime != null and map.startTime!= '' ">
AND oii.kprq >= #{map.startTime,jdbcType=TIMESTAMP}
</if>
<if test="map.endTime != null and map.endTime!= '' ">
AND #{map.endTime,jdbcType=TIMESTAMP} >= oii.kprq
</if>
</if>
<if test="dataType == 1">
<if test="map.startTime != null and map.startTime!= '' ">
AND trunc(oii.kprq) &gt;= to_date(#{map.startTime},'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="map.endTime != null and map.endTime!= '' ">
AND trunc(oii.kprq) &lt;= to_date(#{map.endTime},'yyyy-mm-dd hh24:mi:ss')
</if>
</if>
</otherwise>
</choose>
<if test="shList != null and shList.size() == 0">
and oii.xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entList != null and entList.size() == 0">
and opi.ent_id = ''
</if>
<if test="entList != null and entList.size() == 1">
and opi.ent_id =
<foreach collection="entList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="entList != null and entList.size() > 1">
and opi.ent_id in
<foreach collection="entList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.fpqqlshList != null and map.fpqqlshList.size() == 1">
and oii.fpqqlsh =
<foreach collection="map.fpqqlshList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="map.fpqqlshList != null and map.fpqqlshList.size() > 1">
and oii.fpqqlsh in
<foreach collection="map.fpqqlshList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.kplshList != null and map.kplshList.size() == 1">
and oii.kplsh =
<foreach collection="map.kplshList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="map.kplshList != null and map.kplshList.size() > 1">
and oii.kplsh in
<foreach collection="map.kplshList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.sksbCode != null and map.sksbCode != ''">
and oii.sksbdm = #{map.sksbCode,jdbcType=VARCHAR}
</if>
<if test="map.chbz != null">
and oii.ch_bz in
<foreach collection="map.chbz" item="item"
open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="map.tsbz != null and map.tsbz != ''">
and oii.push_status = #{map.tsbz,jdbcType=VARCHAR}
</if>
<if test="map.tsjos != null and map.tsjos != ''">
and oii.push_jos_status = #{map.tsjos,jdbcType=VARCHAR}
</if>
<if test="map.zfbz!=null and map.zfbz!= '' ">
and oii.zf_bz=#{map.zfbz,jdbcType=VARCHAR}
</if>
<if test="map.zfbzList != null">
and oii.zf_bz in
<foreach collection="map.zfbzList" index="index" item="zfbzit"
open="(" separator="," close=")">
#{zfbzit,jdbcType=VARCHAR}
</foreach>
</if>
<if test="dataType == 0">
<if test="map.xhfmc != null and map.xhfmc != ''">
AND oii.xhf_mc like concat('%', #{map.xhfmc,jdbcType=VARCHAR},'%')
</if>
</if>
<if test="dataType == 1">
<if test="map.xhfmc != null and map.xhfmc != ''">
AND oii.xhf_mc like concat(concat('%', #{map.xhfmc,jdbcType=VARCHAR}),'%')
</if>
</if>
<if test="map.minhjje!=null and map.minhjje!= '' ">
and oii.kphjje &gt;= CAST(#{map.minhjje,jdbcType=VARCHAR} as DECIMAL)
</if>
<if test="map.maxhjje!=null and map.maxhjje!= '' ">
and oii.kphjje &lt;= CAST(#{map.maxhjje,jdbcType=VARCHAR} as DECIMAL)
</if>
<if test="map.bzdh!=null and map.bzdh!= '' ">
and opi.bzdh = #{map.bzdh,jdbcType=VARCHAR}
</if>
<if test="map.xtly!=null and map.xtly!= '' ">
and opi.xtly = #{map.xtly,jdbcType=VARCHAR}
</if>
<if test="map.gsdm!=null and map.gsdm!= '' ">
and opi.gsdm = #{map.gsdm,jdbcType=VARCHAR}
</if>
<if test="map.bhzt!=null and map.bhzt!= '' ">
and opi.bhzt = #{map.bhzt,jdbcType=VARCHAR}
</if>
<if test="map.ygxm!=null and map.ygxm!= '' ">
and opi.ygxm = #{map.ygxm,jdbcType=VARCHAR}
</if>
<if test="map.kppzh!=null and map.kppzh!= '' ">
and opi.kppzh = #{map.kppzh,jdbcType=VARCHAR}
</if>
<if test="map.pzgzrq!=null and map.pzgzrq!= '' ">
and opi.pzgzrq = #{map.pzgzrq,jdbcType=VARCHAR}
</if>
<if test="map.yzfp!=null and map.yzfp!= '' ">
and opi.yzfp = #{map.yzfp,jdbcType=VARCHAR}
</if>
<if test="map.originDdh!=null and map.originDdh!= '' ">
and opi.origin_ddh = #{map.originDdh,jdbcType=VARCHAR}
</if>
<if test="map.originOrderId!=null and map.originOrderId!= '' ">
and opi.origin_order_id = #{map.originOrderId,jdbcType=VARCHAR}
</if>
<if test="map.kb!=null and map.kb!= '' ">
and opi.kb = #{map.kb,jdbcType=VARCHAR}
</if>
</where>
</sql>
<select id="selectRedAndInvoiceBymap" resultMap="details"
parameterType="java.util.Map">
<bind name="dataType" value="${dataType}"/>
<include refid="invoiceList"/>
<choose>
<when test="map.orderBy !=null and map.orderBy == 'updateTime' ">
order by update_time desc
</when>
<when test="map.orderBy !=null and map.orderBy == 'checkTime' ">
order by check_time desc
</when>
<otherwise>
ORDER BY kprq DESC
</otherwise>
</choose>
</select>
<select id="selectInvoiceByIds" resultType="com.dxhy.order.model.OrderInvoiceDetail">
SELECT
oii.kprq kprq,
oii.xhf_mc xhfmc,
oii.ghf_mc ghfMc,
oii.fpdm,
oii.fphm,
oii.hjbhsje,
oii.kpse,
oii.kphjje,
oi.bz
FROM
order_invoice_info oii
left join order_info oi on oii.order_info_id = oi.id
where
oii.id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id,jdbcType=VARCHAR}
</foreach>
</select>
<select id="queryCountByMap" resultMap="queryCountByMapResultMap"
parameterType="java.util.Map">
<bind name="dataType" value="${dataType}"/>
SELECT
count(0) totalcount,
sum(IF(zfbz <![CDATA[ <> ]]> '1',CAST(hjbhsje AS DECIMAL(40,2)),0.00)) totalhjbhsje,
sum(IF(zfbz <![CDATA[ <> ]]> '1',CAST(kphjje AS DECIMAL(40,2)),0.00)) totalkphjje,
sum(IF(zfbz <![CDATA[ <> ]]> '1',CAST(kpse AS DECIMAL(40,2)),0.00)) totalkpse
FROM
(
<include refid="invoiceList"/>
) temp
</select>
<select id="selectInvoiceInfoByPushStatus"
resultMap="BaseResultMap" parameterType="java.lang.String">
<bind name="dataType" value="${dataType}"/>
select
<include refid="Base_Column_List"/>
from order_invoice_info
<where>
<if test="paramMap != null and paramMap.kpztList != null and paramMap.kpztList.size() == 1">
and kpzt =
<foreach collection="paramMap.kpztList" item="kpzt" open="(" close=")"
separator=",">
#{kpzt}
</foreach>
</if>
<if test="paramMap != null and paramMap.kpztList != null and paramMap.kpztList.size() > 1">
and kpzt in
<foreach collection="paramMap.kpztList" item="kpzt" open="(" close=")"
separator=",">
#{kpzt}
</foreach>
</if>
<if test="paramMap != null and paramMap.pushStatusList != null ">
and push_status in
<foreach collection="paramMap.pushStatusList" item="pushStatus" open="(" close=")"
separator=",">
#{pushStatus}
</foreach>
</if>
<if test="paramMap != null and paramMap.invalidPushStatusList != null ">
and invalid_push_status in
<foreach collection="paramMap.invalidPushStatusList" item="pushStatus" open="(" close=")"
separator=",">
#{pushStatus}
</foreach>
</if>
<if test="dataType == 0">
<if test="paramMap != null and paramMap.startTime != null and paramMap.startTime != ''">
and kprq >= #{paramMap.startTime,jdbcType=TIMESTAMP}
</if>
<if test="paramMap != null and paramMap.endTime != null and paramMap.endTime != ''">
and kprq <![CDATA[<= #{paramMap.endTime,jdbcType=TIMESTAMP}]]>
</if>
</if>
<if test="dataType == 1">
<if test="paramMap != null and paramMap.startTime != null and paramMap.startTime != ''">
and kprq >= to_date(#{paramMap.startTime,jdbcType=TIMESTAMP},'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="paramMap != null and paramMap.endTime != null and paramMap.endTime != ''">
and kprq &lt; to_date(#{paramMap.endTime,jdbcType=TIMESTAMP},'yyyy-mm-dd hh24:mi:ss')
</if>
</if>
<if test="paramMap != null and paramMap.kplsh != null and paramMap.kplsh != ''">
and kplsh = #{paramMap.kplsh,jdbcType=VARCHAR}
</if>
<if test="paramMap != null and paramMap.ddh != null and paramMap.ddh != ''">
and ddh = #{paramMap.ddh,jdbcType=VARCHAR}
</if>
<if test="paramMap != null and paramMap.fpdm != null and paramMap.fpdm != ''">
and fpdm = #{paramMap.fpdm,jdbcType=VARCHAR}
</if>
<if test="paramMap != null and paramMap.fphm != null and paramMap.fphm != ''">
and fphm = #{paramMap.fphm,jdbcType=VARCHAR}
</if>
<if test="paramMap != null and paramMap.fpqqlsh != null and paramMap.fpqqlsh != ''">
and fpqqlsh = #{paramMap.fpqqlsh,jdbcType=VARCHAR}
</if>
<if test="paramMap != null and paramMap.fpqqlshs != null ">
and fpqqlsh in
<foreach collection="paramMap.fpqqlshs" item="fpqqlsh"
open="(" close=")" separator=",">
#{fpqqlsh}
</foreach>
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectInvoiceInfoByEmailPushStatus"
resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from order_invoice_info
where kpzt in
<foreach collection="kpztList" item="kpzt" open="(" close=")"
separator=",">
#{kpzt}
</foreach>
<if test="emailPushStatus != null">
where email_push_status in
<foreach collection="emailPushStatus" item="status" open="(" close=")"
separator=",">
#{status}
</foreach>
</if>
<if test="date != null">
and create_time <![CDATA[ < ]]> #{date,jdbcType=TIMESTAMP}
</if>
<if test="fpzldm != null and fpzldm != ''">
and fpzl_dm = #{fpzldm,jdbcType=TIMESTAMP}
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
<!--selectOrderInvoiceInfoId -->
<select id="selectOrderInvoiceInfo"
resultMap="BaseResultMap"
parameterType="com.dxhy.order.model.OrderInvoiceInfo">
select
<include refid="Base_Column_List"/>
from
order_invoice_info
<where>
<if test="orderInvoiceInfo.id != null and orderInvoiceInfo.id != ''">
and id = #{orderInvoiceInfo.id,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.fpqqlsh != null and orderInvoiceInfo.fpqqlsh != ''">
and fpqqlsh = #{orderInvoiceInfo.fpqqlsh,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.orderProcessInfoId != null and orderInvoiceInfo.orderProcessInfoId != ''">
and order_process_info_id = #{orderInvoiceInfo.orderProcessInfoId,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.orderInfoId != null and orderInvoiceInfo.orderInfoId != ''">
and order_info_id = #{orderInvoiceInfo.orderInfoId,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.fpdm != null and orderInvoiceInfo.fpdm != ''">
and fpdm = #{orderInvoiceInfo.fpdm,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.fphm != null and orderInvoiceInfo.fphm != ''">
and fphm = #{orderInvoiceInfo.fphm,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.fpzlDm != null and orderInvoiceInfo.fpzlDm != ''">
and fpzl_dm = #{orderInvoiceInfo.fpzlDm,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.kplsh != null and orderInvoiceInfo.kplsh != ''">
and kplsh = #{orderInvoiceInfo.kplsh,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.hzxxbbh != null and orderInvoiceInfo.hzxxbbh != ''">
and hzxxbbh = #{orderInvoiceInfo.hzxxbbh,jdbcType=VARCHAR}
</if>
<if test="orderInvoiceInfo.sksbdm != null and orderInvoiceInfo.sksbdm != ''">
and sksbdm = #{orderInvoiceInfo.sksbdm,jdbcType=VARCHAR}
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<!--月开票金额统计查询-->
<select id="findInvoiceCountAmount" resultMap="countMonthAmountMap">
<bind name="dataType" value="${dataType}"/>
select
<if test="dataType == 0">
DATE_FORMAT(oii.kprq,'%Y-%m') kpyf,
</if>
<if test="dataType == 1">
to_char(Max(oii.kprq),'yyyy-mm') kpyf,
</if>
CAST(sum(oii.kphjje) as DECIMAL(40,2)) hjje,
CAST(sum(oii.hjbhsje) as DECIMAL(40,2)) bhsje,
CAST(sum(oii.kpse) as DECIMAL(40,2)) hjse,
oii.fpzl_dm fpzldm
from order_invoice_info oii
where oii.kpzt = '2'
<if test="paramMap.shList != null and paramMap.shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="paramMap.shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="paramMap.shList != null and paramMap.shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="paramMap.shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="dataType == 0">
<if test="paramMap != null and paramMap.startTime != null">
AND oii.kprq >= #{paramMap.startTime,jdbcType=TIMESTAMP}
</if>
<if test="paramMap != null and paramMap.endTime != null">
AND #{paramMap.endTime,jdbcType=TIMESTAMP} >= oii.kprq
</if>
</if>
<if test="dataType == 1">
<if test="paramMap != null and paramMap.startTime != null">
AND trunc(oii.kprq) &gt;= to_date(#{paramMap.startTime},'yyyy-mm-dd hh24:mi:ss')
</if>
<if test="paramMap != null and paramMap.endTime != null">
AND trunc(oii.kprq) &lt;= to_date(#{paramMap.endTime},'yyyy-mm-dd hh24:mi:ss')
</if>
</if>
group by fpzldm,kpyf
order by kpyf asc,fpzldm asc
</select>
<select id="countInvoiceByMonth" resultMap="countInvoiceByMonthResultMap">
select oii.fpzl_dm dm,count(1) zcount from order_invoice_info oii
<where>
oii.kpzt = '2'
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="map.startTime !=null and map.startTime != '' and map.endTime !=null and map.endTime != ''">
and oii.kprq
>= #{map.startTime} and
#{map.endTime} >= oii.kprq
</if>
</where>
group by oii.fpzl_dm
</select>
<select id="countInvoice" parameterType="map" resultMap="countInvoiceMap">
<bind name="dataType" value="${dataType}"/>
SELECT
COUNT(oii.id) zkpl,
COUNT(CASE oii.fpzl_dm WHEN 2 THEN oii.id ELSE NULL END) AS pkpl,
COUNT(CASE oii.fpzl_dm WHEN 0 THEN oii.id ELSE NULL END) AS skpl,
COUNT(CASE oii.fpzl_dm WHEN 51 THEN oii.id ELSE NULL END) AS dkpl,
COUNT(CASE oii.fpzl_dm WHEN 12 THEN oii.id ELSE NULL END) AS jkpl,
COUNT(CASE oii.fpzl_dm WHEN 42 THEN oii.id ELSE NULL END) AS rkpl,
COUNT(CASE oii.fpzl_dm WHEN 52 THEN oii.id ELSE NULL END) AS dzkpl,
COUNT(CASE WHEN DATE_FORMAT(oii.kprq,'%Y-%m') = DATE_FORMAT(NOW(),'%Y-%m') THEN oii.id ELSE NULL END) AS bykpl,
COUNT(CASE WHEN DATE_FORMAT(oii.kprq,'%Y-%m') = DATE_FORMAT(DATE_SUB(CURDATE(),INTERVAL 1 MONTH),'%Y-%m') THEN
oii.id ELSE NULL END) AS sykpl,
COUNT(CASE WHEN DATE_FORMAT(oii.kprq,'%Y-%m') = DATE_FORMAT(DATE_SUB(CURDATE(),INTERVAL 2 MONTH),'%Y-%m') THEN
oii.id ELSE NULL END) AS qlykpl,
oii.xhf_nsrsbh
FROM
order_invoice_info oii
WHERE
oii.kpzt = '2'
<if test="dataType == 0">
<if test="paramMap.startTime != null">
AND oii.kprq &gt;= #{paramMap.startTime,jdbcType=TIMESTAMP}
</if>
<if test="paramMap.endTime != null">
AND oii.kprq &lt; #{paramMap.endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="dataType == 1">
<if test="paramMap.startTime != null">
AND oii.kprq &gt;= #{paramMap.startTime,jdbcType=TIMESTAMP}
</if>
<if test="paramMap.endTime != null">
AND oii.kprq &lt; #{paramMap.endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="paramMap.shList != null and paramMap.shList.size() == 0">
and oii.xhf_nsrsbh = ''
</if>
<if test="paramMap.shList != null and paramMap.shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="paramMap.shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="paramMap.shList != null and paramMap.shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="paramMap.shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
oii.xhf_nsrsbh
</select>
<select id="countInvoiceItem" parameterType="map" resultMap="countInvoiceItemMap">
<bind name="dataType" value="${dataType}"/>
SELECT COUNT(oii.id) kpl,
COUNT(CASE oii.fpzl_dm WHEN 2 THEN oii.id ELSE NULL END) AS pkpl,
COUNT(CASE oii.fpzl_dm WHEN 0 THEN oii.id ELSE NULL END) AS zkpl,
COUNT(CASE oii.fpzl_dm WHEN 51 THEN oii.id ELSE NULL END) AS ekpl,
COUNT(CASE oii.fpzl_dm WHEN 12 THEN oii.id ELSE NULL END) AS jkpl,
COUNT(CASE oii.fpzl_dm WHEN 42 THEN oii.id ELSE NULL END) AS rkpl,
COUNT(CASE oii.fpzl_dm WHEN 52 THEN oii.id ELSE NULL END) AS dzkpl,
(CASE WHEN oii.kprq IS NULL THEN DATE_FORMAT(oii.create_time,'%Y-%m') ELSE DATE_FORMAT(oii.kprq,'%Y-%m') END) AS
tjrq,
oii.xhf_nsrsbh
FROM
order_invoice_info oii
WHERE
oii.kpzt = '2'
<if test="dataType == 0">
<if test="paramMap.startTime != null">
AND oii.kprq &gt;= #{paramMap.startTime,jdbcType=TIMESTAMP}
</if>
<if test="paramMap.endTime != null">
AND oii.kprq &lt; #{paramMap.endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="dataType == 1">
<if test="paramMap.startTime != null">
AND oii.kprq &gt;= #{paramMap.startTime,jdbcType=TIMESTAMP}
</if>
<if test="paramMap.endTime != null">
AND oii.kprq &lt; #{paramMap.endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="paramMap.shList != null and paramMap.shList.size() == 0">
and oii.xhf_nsrsbh = ''
</if>
<if test="paramMap.shList != null and paramMap.shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="paramMap.shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="paramMap.shList != null and paramMap.shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="paramMap.shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
oii.xhf_nsrsbh,tjrq
</select>
<select id="countInvoiceByDay" resultMap="countInvoiceByDayResultMap">
SELECT
opi.xhf_nsrsbh AS xhfNsrsbh,
opi.xhf_mc AS xhfMc,
DATE_FORMAT( opi.create_time, '%Y-%m-%d' ) AS ddjsrq,
count( 1 ) AS ddzsl,
SUM(
CASE
WHEN (
opi.ddzt = '0'
OR opi.ddzt = '1'
OR opi.ddzt = '2'
OR opi.ddzt = '3'
OR opi.ddzt = '4'
OR opi.ddzt = '9'
OR opi.ddzt = '10'
) THEN
1 ELSE 0
END
) AS wkpdds,
SUM( CASE WHEN ( opi.ddzt = '5' OR opi.ddzt = '7' ) THEN 1 ELSE 0 END ) AS kpcgdds,
SUM( CASE WHEN ( opi.ddzt = '6' OR opi.ddzt = '8' ) THEN 1 ELSE 0 END ) AS kpsbdds
FROM
order_process_info opi
WHERE
opi.order_status = '0'
AND opi.create_time &gt;= #{startTime,jdbcType=TIMESTAMP}
AND opi.create_time &lt;= #{endTime,jdbcType=TIMESTAMP}
<if test="xhfMc != null and xhfMc != ''">
AND opi.xhf_mc = #{xhfMc,jdbcType=VARCHAR}
</if>
<if test="shList != null and shList.size() == 1">
and opi.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and opi.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
opi.xhf_nsrsbh
</select>
<select id="countFailedInvoiceByDay" resultMap="countFailedInvoiceByDayResultMap">
SELECT
opi.xhf_nsrsbh AS nsrsbh,
opi.xhf_mc AS nsrmc,
DATE_FORMAT( opi.create_time, '%Y-%m-%d' ) AS ddjsrq,
opi.sbyy AS sbyy,
SUM( CASE WHEN ( opi.ddzt = '6' OR opi.ddzt = '8' ) THEN 1 ELSE 0 END ) AS kpsbdd
FROM
order_process_info opi
WHERE
opi.order_status = '0'
AND opi.create_time &gt;= #{startTime,jdbcType=TIMESTAMP}
AND opi.create_time &lt;= #{endTime,jdbcType=TIMESTAMP}
<if test="xhfMc != null and xhfMc != ''">
AND opi.xhf_mc = #{xhfMc,jdbcType=VARCHAR}
</if>
<if test="shList != null and shList.size() == 1">
and opi.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and opi.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
GROUP BY
opi.xhf_nsrsbh, opi.sbyy
HAVING
kpsbdd > 0
</select>
<select id="countInvoiceInfoByTime" resultMap="countMap">
<bind name="dataType" value="${dataType}"/>
SELECT
count( oii.hjbhsje ) count,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.hjbhsje as DECIMAL(40,2)) , 0.00) ) hjje,
SUM( IF( oii.zf_bz <![CDATA[ <> ]]> '1', CAST( oii.kpse as DECIMAL(40,2)) , 0.00) ) hjse
FROM
order_invoice_info oii
WHERE
oii.kpzt = '2'
<if test="dataType == 0">
<if test="startTime != null">
AND oii.kprq &gt;= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND oii.kprq &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="dataType == 1">
<if test="startTime != null">
AND oii.kprq >= #{startTime,jdbcType=TIMESTAMP}
</if>
<if test="endTime != null">
AND oii.kprq &lt; #{endTime,jdbcType=TIMESTAMP}
</if>
</if>
<if test="shList != null and shList.size() == 0">
and oii.xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and oii.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and oii.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="entList != null and entList.size() == 0">
and (oii.ent_id = '' or oii.ent_id is null)
</if>
<if test="entList != null and entList.size() == 1">
and (oii.ent_id =
<foreach collection="entList" index="index" item="item">
#{item}
</foreach> or oii.ent_id is null)
</if>
<if test="entList != null and entList.size() > 1">
and (oii.ent_id in
<foreach collection="entList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach> or oii.ent_id is null)
</if>
</select>
<select id="countInoviceInfo" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
oii.order_info_id
FROM
order_invoice_info oii
WHERE
(oii.zf_bz = '1' or oii.ch_bz = '1')
and oii.order_info_id in
<foreach collection="orderInfoIds" item="orderInfoId" open="(" separator="," close=")">
#{orderInfoId}
</foreach>
</select>
<update id="updateOrderInvoiceInfoByOrderId" parameterType="com.dxhy.order.model.OrderInvoiceInfo">
update order_invoice_info
<set>
<if test="orderInvoiceInfo.fpqqlsh != null">
fpqqlsh = #{orderInvoiceInfo.fpqqlsh,jdbcType=VARCHAR},
</if>
<if test="orderInvoiceInfo.updateTime != null">
update_time = #{orderInvoiceInfo.updateTime,jdbcType=TIMESTAMP},
</if>
</set>
<where>
<if test="orderInvoiceInfo.orderInfoId != null">
and order_info_id = #{orderInvoiceInfo.orderInfoId,jdbcType=VARCHAR}
</if>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</update>
<select id="selectInvoiceInfoByFpqqlshs" resultType="com.dxhy.order.model.OrderInvoiceInfo">
SELECT
oii.fpqqlsh,oii.fpdm,oii.fphm,oii.ddh
FROM
order_invoice_info oii
WHERE
oii.fpqqlsh IN
<foreach collection="fpqqlshs" item="fpqqlsh" open="(" separator="," close=")">
#{fpqqlsh}
</foreach>
AND ( oii.zf_bz = '0' OR oii.ch_bz = '0' )
</select>
<select id="selectInvoiceInfoByBzdh" resultMap="queryBzdhInvoiceResultMap">
SELECT
op.order_info_id,
op.fpqqlsh,
op.ddh,
op.bzdh,
op.ddzt,
op.fpzl_dm AS fpzldm,
op.xhf_nsrsbh,
op.xhf_mc,
op.ghf_nsrsbh,
op.ghf_mc,
op.ent_id,
op.xtly,
oii.fpdm,
oii.fphm,
oii.kphjje,
oii.kpse,
oii.hjbhsje,
oii.sykchje,
oii.sykchbhsje,
oii.sykchse,
oii.zf_bz,
oii.ch_bz,
oii.kprq,
oii.fjh,
op.ddzt
FROM
order_invoice_info oii INNER JOIN order_process_info op ON oii.order_info_id = op.order_info_id
WHERE
op.bzdh = #{bzdh,jdbcType=VARCHAR}
<if test="shList != null and shList.size() == 0">
and op.xhf_nsrsbh = ''
</if>
<if test="shList != null and shList.size() == 1">
and op.xhf_nsrsbh =
<foreach collection="shList" index="index" item="item">
#{item}
</foreach>
</if>
<if test="shList != null and shList.size() > 1">
and op.xhf_nsrsbh in
<foreach collection="shList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
AND op.order_status = '0'
</select>
</mapper>