|
|
|
<?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.core.dao.ConfirmDao">
|
|
|
|
<!--查询机构表里税号-->
|
|
|
|
<select id="getTaxno" resultType="com.dxhy.core.job.entity.TAcOrg">
|
|
|
|
select distinct g.taxno, g.db_name, g.company, g.ace_id, g.ace_key, g.taxname
|
|
|
|
from sys_dept g
|
|
|
|
where g.org_type = '5'
|
|
|
|
and cj_status = '1'
|
|
|
|
and g.ace_id is not null
|
|
|
|
and g.ace_key is not null
|
|
|
|
</select>
|
|
|
|
<select id="getUpgradTaxno" resultType="com.dxhy.core.job.entity.TAcOrg">
|
|
|
|
select g.taxno, g.db_name, g.company, g.taxname
|
|
|
|
from sys_dept g
|
|
|
|
where g.org_type = '5'
|
|
|
|
and g.upgrade_status = '1'
|
|
|
|
and g.cj_status = '1'
|
|
|
|
|
|
|
|
</select>
|
|
|
|
<select id="getPullSapDataTaxNo" resultType="com.dxhy.core.job.entity.TAcOrg">
|
|
|
|
select g.taxno, g.db_name, g.company, g.taxname
|
|
|
|
from sys_dept g
|
|
|
|
where g.org_type = '5'
|
|
|
|
and g.upgrade_status = '1'
|
|
|
|
and g.cj_status = '1'
|
|
|
|
</select>
|
|
|
|
<!--查询机构表里税号 全票面-->
|
|
|
|
<select id="getTaxnoForQpm" resultType="com.dxhy.core.job.entity.TAcOrg">
|
|
|
|
select distinct g.taxno, g.db_name, g.company, g.ace_id, g.ace_key
|
|
|
|
from sys_dept g
|
|
|
|
where g.org_type = '5'
|
|
|
|
and cj_status = '1'
|
|
|
|
and is_collext = '1'
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!--查询属期表里是否有该税号-->
|
|
|
|
<select id="qryTaxCurrent" resultType="com.dxhy.core.job.pojo.TaxCurrent">
|
|
|
|
select taxno curTaxno,
|
|
|
|
current_tax_period incomeMoth,
|
|
|
|
latch_status latchStatus
|
|
|
|
from t_dx_tax_current g
|
|
|
|
where g.taxno = #{taxno}
|
|
|
|
</select>
|
|
|
|
<select id="findAllDkCount" resultType="com.dxhy.core.job.entity.TDxDkCount">
|
|
|
|
select taxno,
|
|
|
|
skssq,
|
|
|
|
sfdqskssq,
|
|
|
|
tj_status tjStatus,
|
|
|
|
qs_status qsStatus,
|
|
|
|
cxtj_status cxtjStatus,
|
|
|
|
cxqs_status cxqsStatus,
|
|
|
|
tj_user tjUser,
|
|
|
|
tj_date tjDate,
|
|
|
|
qr_user qrUser,
|
|
|
|
qr_date qrDate,
|
|
|
|
cxtj_user cxtjUser,
|
|
|
|
cxtj_date cxtjDate,
|
|
|
|
cxqr_user cxqrUser,
|
|
|
|
cxqr_date cxqrDate
|
|
|
|
from t_dx_dk_count
|
|
|
|
where taxno = #{taxno}
|
|
|
|
</select>
|
|
|
|
<!--插入属期表-->
|
|
|
|
<insert id="insertCurrent">
|
|
|
|
INSERT INTO t_dx_tax_current
|
|
|
|
(taxno,
|
|
|
|
taxname,
|
|
|
|
current_tax_period,
|
|
|
|
select_start_date,
|
|
|
|
select_end_date,
|
|
|
|
operation_end_date,
|
|
|
|
old_tax_no,
|
|
|
|
declare_period,
|
|
|
|
credit_rating,
|
|
|
|
create_time)
|
|
|
|
VALUES (#{taxCurrent.curTaxno},
|
|
|
|
#{taxCurrent.compName},
|
|
|
|
#{taxCurrent.incomeMoth},
|
|
|
|
#{taxCurrent.selectStartDate},
|
|
|
|
#{taxCurrent.selectEndDate},
|
|
|
|
#{taxCurrent.incomeEndDate},
|
|
|
|
#{taxCurrent.oldTaxno},
|
|
|
|
#{taxCurrent.appPeriod},
|
|
|
|
#{taxCurrent.compLevel},
|
|
|
|
now())
|
|
|
|
</insert>
|
|
|
|
<!--更新属期表-->
|
|
|
|
<update id="updateCurrent" databaseId="mysql">
|
|
|
|
update t_dx_tax_current
|
|
|
|
SET taxname= #{taxCurrent.compName},
|
|
|
|
current_tax_period=#{taxCurrent.incomeMoth},
|
|
|
|
select_start_date=#{taxCurrent.selectStartDate},
|
|
|
|
select_end_date=#{taxCurrent.selectEndDate},
|
|
|
|
operation_end_date=#{taxCurrent.incomeEndDate},
|
|
|
|
old_tax_no= #{taxCurrent.oldTaxno},
|
|
|
|
declare_period=#{taxCurrent.appPeriod},
|
|
|
|
credit_rating=#{taxCurrent.compLevel},
|
|
|
|
company_type = #{taxCurrent.companyType},
|
|
|
|
oil_type=#{taxCurrent.oilType},
|
|
|
|
taxpayer_type=#{taxCurrent.taxpayerType},
|
|
|
|
sync_time=#{taxCurrent.syncTime},
|
|
|
|
index_info=#{taxCurrent.indexInfo},
|
|
|
|
period_index_info = #{taxCurrent.periodIndexInfo},
|
|
|
|
month_index_info = #{taxCurrent.monthIndexInfo},
|
|
|
|
limit_dkse=#{taxCurrent.limitDkse},
|
|
|
|
update_time=now()
|
|
|
|
where taxno = #{taxCurrent.curTaxno}
|
|
|
|
</update>
|
|
|
|
<update id="updateCurrent" databaseId="oracle">
|
|
|
|
update t_dx_tax_current
|
|
|
|
SET taxname= #{taxCurrent.compName},
|
|
|
|
current_tax_period=#{taxCurrent.incomeMoth},
|
|
|
|
select_start_date=#{taxCurrent.selectStartDate},
|
|
|
|
select_end_date=#{taxCurrent.selectEndDate},
|
|
|
|
operation_end_date=#{taxCurrent.incomeEndDate},
|
|
|
|
old_tax_no= #{taxCurrent.oldTaxno},
|
|
|
|
declare_period=#{taxCurrent.appPeriod},
|
|
|
|
credit_rating=#{taxCurrent.compLevel},
|
|
|
|
company_type = #{taxCurrent.companyType},
|
|
|
|
oil_type=#{taxCurrent.oilType},
|
|
|
|
taxpayer_type=#{taxCurrent.taxpayerType},
|
|
|
|
sync_time=#{taxCurrent.syncTime},
|
|
|
|
index_info=#{taxCurrent.indexInfo},
|
|
|
|
period_index_info = #{taxCurrent.periodIndexInfo},
|
|
|
|
month_index_info = #{taxCurrent.monthIndexInfo},
|
|
|
|
limit_dkse=#{taxCurrent.limitDkse},
|
|
|
|
update_time=sysdate
|
|
|
|
where taxno = #{taxCurrent.curTaxno}
|
|
|
|
</update>
|
|
|
|
<!--查询申请认证批次号-->
|
|
|
|
<select id="getBatchNo" resultType="com.dxhy.core.job.entity.TDxApplyRecord">
|
|
|
|
select g.batch_no, g.ace_id, g.ace_key
|
|
|
|
from t_dx_apply_record g
|
|
|
|
where g.result_status = 'N'
|
|
|
|
group by g.batch_no, g.ace_id, g.ace_key
|
|
|
|
</select>
|
|
|
|
<!--认证结果返回,更新底账表-->
|
|
|
|
<update id="updateRecord">
|
|
|
|
update t_dx_record_invoice SET
|
|
|
|
rzh_yesorno= #{result.legalizeState},
|
|
|
|
rzh_date=#{rzhDate},
|
|
|
|
auth_status=#{result.authState},
|
|
|
|
rzh_type=#{result.legalizeType},
|
|
|
|
rzh_belong_date=#{result.legalizeBelongDate},
|
|
|
|
rzlx= #{result.rzlx},
|
|
|
|
rzh_back_msg=#{result.failureReason},
|
|
|
|
sfygx='1',
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
<if test="result.yxse!=null and result.yxse!=''">
|
|
|
|
dk_tax_amount=#{result.yxse},
|
|
|
|
</if>
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx}
|
|
|
|
<if test='result.authState=="4"'>
|
|
|
|
,cxrz_status='0'
|
|
|
|
,cxrz_date=null
|
|
|
|
</if>
|
|
|
|
<if test="result.bdkMessage!=null and result.bdkMessage!=''">
|
|
|
|
,bdk_message=#{result.bdkMessage}
|
|
|
|
</if>
|
|
|
|
where uuid=#{uuid}
|
|
|
|
</update>
|
|
|
|
<!--认证结果返回,更新底账表-->
|
|
|
|
<update id="updateApply">
|
|
|
|
update t_dx_apply_record
|
|
|
|
SET result_status='Y'
|
|
|
|
where uuid = #{uuid}
|
|
|
|
</update>
|
|
|
|
<!--插入日志表-->
|
|
|
|
<insert id="saveLog">
|
|
|
|
INSERT INTO t_dx_http_log
|
|
|
|
(type,
|
|
|
|
req_date,
|
|
|
|
req_text,
|
|
|
|
res_date,
|
|
|
|
res_text,
|
|
|
|
status,
|
|
|
|
taxno)
|
|
|
|
VALUES (#{tDxHttpLog.type},
|
|
|
|
#{tDxHttpLog.reqDate},
|
|
|
|
#{tDxHttpLog.reqText},
|
|
|
|
#{tDxHttpLog.resDate},
|
|
|
|
#{tDxHttpLog.resText},
|
|
|
|
#{tDxHttpLog.status},
|
|
|
|
#{tDxHttpLog.taxno})
|
|
|
|
</insert>
|
|
|
|
<select id="getApplyInvoiceByCount" resultType="java.lang.Integer">
|
|
|
|
select count(*)
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where (auth_status = '2' or cxrz_status = '1' or cxbdk_status = '1')
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
</select>
|
|
|
|
<!--查询要申请认证的发票-->
|
|
|
|
<select id="getApplyInvoice" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="mysql">
|
|
|
|
select invoice_code,
|
|
|
|
invoice_no,
|
|
|
|
invoice_type,
|
|
|
|
rzh_belong_date,
|
|
|
|
gf_tax_no,
|
|
|
|
rzlx,
|
|
|
|
dk_tax_amount,
|
|
|
|
tax_amount,
|
|
|
|
bdk_message
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where (auth_status = '2' or cxrz_status = '1' or cxbdk_status = '1')
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
limit 200
|
|
|
|
</select>
|
|
|
|
<!--查询要申请认证的发票-->
|
|
|
|
<select id="getApplyInvoice" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="oracle">
|
|
|
|
select invoice_code,
|
|
|
|
invoice_no,
|
|
|
|
invoice_type,
|
|
|
|
rzh_belong_date,
|
|
|
|
gf_tax_no,
|
|
|
|
rzlx,
|
|
|
|
dk_tax_amount,
|
|
|
|
tax_amount,
|
|
|
|
bdk_message
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where (auth_status = '2' or cxrz_status = '1' or cxbdk_status = '1')
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
<![CDATA[ and rownum <= 200
|
|
|
|
]]>
|
|
|
|
</select>
|
|
|
|
<!--插入日志表-->
|
|
|
|
<insert id="insertApplyRecord">
|
|
|
|
INSERT INTO t_dx_apply_record
|
|
|
|
(batch_no,
|
|
|
|
invoice_code,
|
|
|
|
invoice_no,
|
|
|
|
result_status,
|
|
|
|
create_date,
|
|
|
|
uuid)
|
|
|
|
VALUES (#{batchNo},
|
|
|
|
#{tDxApplyRecord.invoiceCode},
|
|
|
|
#{tDxApplyRecord.invoiceNo},
|
|
|
|
'N',
|
|
|
|
now(),
|
|
|
|
#{tDxApplyRecord.uuid})
|
|
|
|
</insert>
|
|
|
|
<!--申请认证成功,更新底账表-->
|
|
|
|
<update id="updateInvoiceRecord" databaseId="mysql">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET auth_status='3',
|
|
|
|
send_date=now()
|
|
|
|
where uuid = #{tDxApplyRecord.uuid}
|
|
|
|
</update>
|
|
|
|
<update id="updateInvoiceRecord" databaseId="oracle">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET auth_status='3',
|
|
|
|
send_date=sysdate
|
|
|
|
where uuid = #{tDxApplyRecord.uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!--删除日志 -->
|
|
|
|
<delete id="deleteLog">
|
|
|
|
delete
|
|
|
|
from t_dx_http_log
|
|
|
|
where log_id = #{httpLogId}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 获取数据源 -->
|
|
|
|
<select id="getDbSource" resultType="java.lang.String">
|
|
|
|
select db_name
|
|
|
|
from sys_dept
|
|
|
|
where db_name is not NULL
|
|
|
|
group by db_name
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<insert id="insertHandlelog" databaseId="mysql">
|
|
|
|
insert into t_dx_tax_handlelog
|
|
|
|
(handle_type,
|
|
|
|
user_account,
|
|
|
|
user_name,
|
|
|
|
handle_time,
|
|
|
|
period,
|
|
|
|
taxno)
|
|
|
|
values (#{handlelog.handleType},
|
|
|
|
#{handlelog.userAccount},
|
|
|
|
#{handlelog.userName},
|
|
|
|
now(),
|
|
|
|
#{handlelog.period},
|
|
|
|
#{handlelog.taxno})
|
|
|
|
</insert>
|
|
|
|
<insert id="insertHandlelog" databaseId="oracle">
|
|
|
|
insert into t_dx_tax_handlelog
|
|
|
|
(handle_type,
|
|
|
|
user_account,
|
|
|
|
user_name,
|
|
|
|
handle_time,
|
|
|
|
period,
|
|
|
|
taxno)
|
|
|
|
values (#{handlelog.handleType},
|
|
|
|
#{handlelog.userAccount},
|
|
|
|
#{handlelog.userName},
|
|
|
|
sysdate,
|
|
|
|
#{handlelog.period},
|
|
|
|
#{handlelog.taxno})
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 插入抵扣信息表 -->
|
|
|
|
<insert id="insertDkCount" databaseId="mysql">
|
|
|
|
insert into t_dx_dk_count (taxno, taxname, skssq, sign_status, create_date, sfdqskssq, apply_status)
|
|
|
|
value (#{taxno}, #{compName}, #{sq}, '0', now(), '1', '0')
|
|
|
|
</insert>
|
|
|
|
<!-- 插入抵扣信息表 -->
|
|
|
|
<insert id="insertDkCount" databaseId="oracle">
|
|
|
|
insert into t_dx_dk_count (taxno, taxname, skssq, sign_status, create_date, sfdqskssq, apply_status)
|
|
|
|
value (#{taxno}, #{compName}, #{sq}, '0', sysdate, '1', '0')
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<update id="updateDkCount">
|
|
|
|
update t_dx_dk_count
|
|
|
|
set sfdqskssq='0'
|
|
|
|
where taxno = #{taxno}
|
|
|
|
and sfdqskssq = '1'
|
|
|
|
</update>
|
|
|
|
<update id="updateDkCounts">
|
|
|
|
update t_dx_dk_count
|
|
|
|
set sfdqskssq='0',qs_status='2',qr_date=null
|
|
|
|
where taxno = #{taxno}
|
|
|
|
and skssq = #{skssq}
|
|
|
|
</update>
|
|
|
|
<update id="updateDkCountToNew">
|
|
|
|
update t_dx_dk_count
|
|
|
|
set apply_status = '0',
|
|
|
|
sfdqskssq='1',
|
|
|
|
tj_status='0',
|
|
|
|
qs_status='0',
|
|
|
|
tj_date=null,
|
|
|
|
cxtj_status='0',
|
|
|
|
cxqs_status='0',
|
|
|
|
tj_user = null,
|
|
|
|
qr_user=null,
|
|
|
|
qr_date=null,
|
|
|
|
cxtj_user= null,
|
|
|
|
cxqr_user= null,
|
|
|
|
cxtj_date=null,
|
|
|
|
cxqr_date=null
|
|
|
|
where taxno = #{taxno}
|
|
|
|
and skssq = #{skssq}
|
|
|
|
</update>
|
|
|
|
<delete id="deleteDkCount">
|
|
|
|
delete
|
|
|
|
from t_dx_dk_count
|
|
|
|
where taxno = #{taxno}
|
|
|
|
and skssq > #{skssq}
|
|
|
|
</delete>
|
|
|
|
<delete id="deleteDkCountDetail">
|
|
|
|
delete
|
|
|
|
from t_dx_dk_count_detail
|
|
|
|
where taxno = #{taxno}
|
|
|
|
and tj_month >= #{skssq}
|
|
|
|
</delete>
|
|
|
|
<!-- 查询需要逾期申请的总数量 -->
|
|
|
|
<select id="getApplyOverdueCount" resultType="java.lang.Integer">
|
|
|
|
select count(*)
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where yqsq_status = '1'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--查询要申请逾期的发票-->
|
|
|
|
<select id="getApplyOverdue" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="mysql">
|
|
|
|
select invoice_code
|
|
|
|
, invoice_no
|
|
|
|
, invoice_type
|
|
|
|
, yq_current_period as rzhBelongDate
|
|
|
|
, gf_tax_no
|
|
|
|
, rzlx
|
|
|
|
, dk_tax_amount
|
|
|
|
, tax_amount
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where yqsq_status = '1'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
limit 200
|
|
|
|
</select>
|
|
|
|
<select id="getApplyOverdue" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="oracle">
|
|
|
|
select invoice_code
|
|
|
|
, invoice_no
|
|
|
|
, invoice_type
|
|
|
|
, yq_current_period as rzhBelongDate
|
|
|
|
, gf_tax_no
|
|
|
|
, rzlx
|
|
|
|
, dk_tax_amount
|
|
|
|
, tax_amount
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where yqsq_status = '1'
|
|
|
|
and gf_tax_no = #{taxno} <![CDATA[ and rownum <= 200
|
|
|
|
]]>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--申请逾期成功,更新底账表-->
|
|
|
|
<update id="updateInvoiceRecordForOverdue" databaseId="mysql">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET yqsq_status='2',
|
|
|
|
send_date=now()
|
|
|
|
where uuid = #{tDxApplyRecord.uuid}
|
|
|
|
</update>
|
|
|
|
<update id="updateInvoiceRecordForOverdue" databaseId="oracle">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET yqsq_status='2',
|
|
|
|
send_date=sysdate
|
|
|
|
where uuid = #{tDxApplyRecord.uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!--逾期认证结果返回,更新底账表-->
|
|
|
|
<update id="updateRecordForOverdue" databaseId="mysql">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET yqsq_status=#{result.authState},
|
|
|
|
yq_current_period=#{result.legalizeBelongDate},
|
|
|
|
yqsq_msg=#{result.failureReason},
|
|
|
|
yqshzt='1',
|
|
|
|
yqsh_date=now(),
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
dk_tax_amount=#{result.yxse},
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx}
|
|
|
|
where uuid = #{uuid}
|
|
|
|
</update>
|
|
|
|
<update id="updateRecordForOverdue" databaseId="oracle">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET yqsq_status=#{result.authState},
|
|
|
|
yq_current_period=#{result.legalizeBelongDate},
|
|
|
|
yqsq_msg=#{result.failureReason},
|
|
|
|
yqshzt='1',
|
|
|
|
yqsh_date=sysdate,
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
dk_tax_amount=#{result.yxse},
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx}
|
|
|
|
where uuid = #{uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 查询需要不抵扣申请的总数量 -->
|
|
|
|
<select id="getApplyNoDeductionCount" resultType="java.lang.Integer">
|
|
|
|
select count(*)
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where auth_status = '2'
|
|
|
|
and rzlx = '4'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--查询要申请不抵扣的发票-->
|
|
|
|
<select id="getApplyNoDeduction" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="mysql">
|
|
|
|
select invoice_code
|
|
|
|
, invoice_no
|
|
|
|
, invoice_type
|
|
|
|
, rzh_belong_date as rzhBelongDate
|
|
|
|
, gf_tax_no
|
|
|
|
, rzlx
|
|
|
|
, dk_tax_amount
|
|
|
|
, tax_amount
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where auth_status = '2'
|
|
|
|
and rzlx = '4'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
limit 200
|
|
|
|
</select>
|
|
|
|
<select id="getApplyNoDeduction" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="oracle">
|
|
|
|
select invoice_code
|
|
|
|
, invoice_no
|
|
|
|
, invoice_type
|
|
|
|
, rzh_belong_date as rzhBelongDate
|
|
|
|
, gf_tax_no
|
|
|
|
, rzlx
|
|
|
|
, dk_tax_amount
|
|
|
|
, tax_amount
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where auth_status = '2'
|
|
|
|
and rzlx = '4'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
<![CDATA[ and rownum <= 200
|
|
|
|
]]>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--申请不抵扣成功,更新底账表-->
|
|
|
|
<update id="updateInvoiceRecordForNoDeduction">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET bdk_status='2'
|
|
|
|
where uuid = #{tDxApplyRecord.uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!--不抵扣认证结果返回,更新底账表-->
|
|
|
|
<update id="updateRecordForNoDeduction" databaseId="mysql">
|
|
|
|
update t_dx_record_invoice SET
|
|
|
|
rzh_yesorno= #{result.legalizeState},
|
|
|
|
rzh_date=#{rzhDate},
|
|
|
|
auth_status=#{result.authState},
|
|
|
|
rzh_type=#{result.legalizeType},
|
|
|
|
rzh_belong_date=#{result.legalizeBelongDate},
|
|
|
|
rzlx= #{result.rzlx},
|
|
|
|
rzh_back_msg=#{result.failureReason},
|
|
|
|
sfygx='1',
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
<if test="result.yxse!=null and result.yxse!=''">
|
|
|
|
dk_tax_amount=#{result.yxse},
|
|
|
|
</if>
|
|
|
|
<if test="result.bdkMessage!=null and result.bdkMessage!=''">
|
|
|
|
bdk_message=#{result.bdkMessage},
|
|
|
|
</if>
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx}
|
|
|
|
<if test='result.authState=="4"'>
|
|
|
|
,cxbdk_status='0'
|
|
|
|
,cxbdk_date=null
|
|
|
|
</if>
|
|
|
|
where uuid=#{uuid}
|
|
|
|
</update>
|
|
|
|
<!-- 退税认证结果返回 -->
|
|
|
|
<update id="updateRecordForDrawback">
|
|
|
|
update t_dx_record_invoice SET
|
|
|
|
rzh_yesorno= #{result.legalizeState},
|
|
|
|
rzh_date=#{rzhDate},
|
|
|
|
auth_status=#{result.authState},
|
|
|
|
rzh_type=#{result.legalizeType},
|
|
|
|
rzh_belong_date=#{result.legalizeBelongDate},
|
|
|
|
rzlx= #{result.rzlx},
|
|
|
|
rzh_back_msg=#{result.failureReason},
|
|
|
|
sfygx='1',
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
<if test="result.yxse!=null and result.yxse!=''">
|
|
|
|
dk_tax_amount=#{result.yxse},
|
|
|
|
</if>
|
|
|
|
<if test="result.bdkMessage!=null and result.bdkMessage!=''">
|
|
|
|
bdk_message=#{result.bdkMessage},
|
|
|
|
</if>
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx}
|
|
|
|
where uuid=#{uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<update id="updateRecordForNoDeduction" databaseId="oracle">
|
|
|
|
update t_dx_record_invoice SET
|
|
|
|
rzh_yesorno= #{result.legalizeState},
|
|
|
|
rzh_date=#{rzhDate},
|
|
|
|
auth_status=#{result.authState},
|
|
|
|
rzh_type=#{result.legalizeType},
|
|
|
|
rzh_belong_date=#{result.legalizeBelongDate},
|
|
|
|
rzlx= #{result.rzlx},
|
|
|
|
rzh_back_msg=#{result.failureReason},
|
|
|
|
sfygx='1',
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
<if test="result.yxse!=null and result.yxse!=''">
|
|
|
|
dk_tax_amount=#{result.yxse},
|
|
|
|
</if>
|
|
|
|
<if test="result.bdkMessage!=null and result.bdkMessage!=''">
|
|
|
|
bdk_message=#{result.bdkMessage},
|
|
|
|
</if>
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx}
|
|
|
|
<if test='result.authState=="4"'>
|
|
|
|
,cxbdk_status='0'
|
|
|
|
,cxbdk_date=null
|
|
|
|
</if>
|
|
|
|
where uuid=#{uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 查询需要撤销抵扣申请的总数量 -->
|
|
|
|
<select id="getApplyRebackRzCount" resultType="java.lang.Integer">
|
|
|
|
select count(*)
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where cxrz_status = '1'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--查询要申请撤销抵扣的发票-->
|
|
|
|
<select id="getApplyRebackRz" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="mysql">
|
|
|
|
select invoice_code
|
|
|
|
, invoice_no
|
|
|
|
, invoice_type
|
|
|
|
, cxrz_current_period as rzhBelongDate
|
|
|
|
, gf_tax_no
|
|
|
|
, rzlx
|
|
|
|
, dk_tax_amount
|
|
|
|
, tax_amount
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where cxrz_status = '1'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
limit 200
|
|
|
|
</select>
|
|
|
|
<select id="getApplyRebackRz" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="oracle">
|
|
|
|
select invoice_code
|
|
|
|
, invoice_no
|
|
|
|
, invoice_type
|
|
|
|
, cxrz_current_period as rzhBelongDate
|
|
|
|
, gf_tax_no
|
|
|
|
, rzlx
|
|
|
|
, dk_tax_amount
|
|
|
|
, tax_amount
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where cxrz_status = '1'
|
|
|
|
and gf_tax_no = #{taxno} <![CDATA[ and rownum <= 200
|
|
|
|
]]>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--申请撤销抵扣成功,更新底账表-->
|
|
|
|
<update id="updateInvoiceRecordForRebackRz">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET cxrz_status='2'
|
|
|
|
where uuid = #{tDxApplyRecord.uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!--撤销抵扣认证结果返回,更新底账表-->
|
|
|
|
<update id="updateRecordForRebackRz" databaseId="mysql">
|
|
|
|
update t_dx_record_invoice SET
|
|
|
|
cxrz_status=#{result.authState},
|
|
|
|
cxrz_date=now(),
|
|
|
|
cxrz_current_period=#{result.legalizeBelongDate},
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx},
|
|
|
|
rzh_back_msg=#{result.failureReason}
|
|
|
|
<if test='result.authState=="4"'>
|
|
|
|
,auth_status='6'
|
|
|
|
,rzh_yesorno='0'
|
|
|
|
,rzh_date = null
|
|
|
|
,rzh_belong_date = null
|
|
|
|
,rzh_type=null
|
|
|
|
,gx_user_account=null
|
|
|
|
,gx_user_name=null
|
|
|
|
,gx_date = null
|
|
|
|
,gx_type = null
|
|
|
|
,send_date = null
|
|
|
|
,sfygx = '0'
|
|
|
|
,confirm_user =null
|
|
|
|
,dk_tax_amount=tax_amount
|
|
|
|
</if>
|
|
|
|
<if test="result.bdkMessage!=null and result.bdkMessage!=''">
|
|
|
|
,bdk_message=#{result.bdkMessage}
|
|
|
|
</if>
|
|
|
|
where uuid=#{uuid}
|
|
|
|
</update>
|
|
|
|
<update id="updateRecordForRebackRz" databaseId="oracle">
|
|
|
|
update t_dx_record_invoice SET
|
|
|
|
cxrz_status=#{result.authState},
|
|
|
|
cxrz_date=sysdate,
|
|
|
|
cxrz_current_period=#{result.legalizeBelongDate},
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx},
|
|
|
|
rzh_back_msg=#{result.failureReason}
|
|
|
|
<if test='result.authState=="4"'>
|
|
|
|
,auth_status='6'
|
|
|
|
,rzh_yesorno='0'
|
|
|
|
,rzh_date = null
|
|
|
|
,rzh_belong_date = null
|
|
|
|
,rzh_type=null
|
|
|
|
,gx_user_account=null
|
|
|
|
,gx_user_name=null
|
|
|
|
,gx_date = null
|
|
|
|
,gx_type = null
|
|
|
|
,send_date = null
|
|
|
|
,sfygx = '0'
|
|
|
|
,confirm_user =null
|
|
|
|
,dk_tax_amount=tax_amount
|
|
|
|
</if>
|
|
|
|
<if test="result.bdkMessage!=null and result.bdkMessage!=''">
|
|
|
|
,bdk_message=#{result.bdkMessage}
|
|
|
|
</if>
|
|
|
|
where uuid=#{uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 查询需要撤销不抵扣申请的总数量 -->
|
|
|
|
<select id="getApplyRebackNoDeductionCount" resultType="java.lang.Integer">
|
|
|
|
select count(*)
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where cxbdk_status = '1'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--查询要申请撤销不抵扣的发票-->
|
|
|
|
<select id="getApplyRebackNoDeduction" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="mysql">
|
|
|
|
select invoice_code
|
|
|
|
, invoice_no
|
|
|
|
, invoice_type
|
|
|
|
, bdk_current_period as rzhBelongDate
|
|
|
|
, gf_tax_no
|
|
|
|
, rzlx
|
|
|
|
, dk_tax_amount
|
|
|
|
, tax_amount
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where cxbdk_status = '1'
|
|
|
|
and gf_tax_no = #{taxno}
|
|
|
|
limit 200
|
|
|
|
</select>
|
|
|
|
<select id="getApplyRebackNoDeduction" resultType="com.dxhy.core.entity.TDxRecordInvoice" databaseId="oracle">
|
|
|
|
select invoice_code
|
|
|
|
, invoice_no
|
|
|
|
, invoice_type
|
|
|
|
, bdk_current_period as rzhBelongDate
|
|
|
|
, gf_tax_no
|
|
|
|
, rzlx
|
|
|
|
, dk_tax_amount
|
|
|
|
, tax_amount
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where cxbdk_status = '1'
|
|
|
|
and gf_tax_no = #{taxno} <![CDATA[ and rownum <= 200
|
|
|
|
]]>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!--申请撤销不抵扣成功,更新底账表-->
|
|
|
|
<update id="updateInvoiceRecordForRebackNoDeduction">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
SET cxbdk_status='2'
|
|
|
|
where uuid = #{tDxApplyRecord.uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!--撤销不抵扣认证结果返回,更新底账表-->
|
|
|
|
<update id="updateRecordForRebackNoDeduction" databaseId="mysql">
|
|
|
|
update t_dx_record_invoice SET
|
|
|
|
cxbdk_status=#{result.authState},
|
|
|
|
cxbdk_date=now(),
|
|
|
|
bdk_current_period=#{result.legalizeBelongDate},
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx},
|
|
|
|
rzh_back_msg=#{result.failureReason}
|
|
|
|
<if test='result.authState=="4"'>
|
|
|
|
,auth_status='6'
|
|
|
|
,rzh_yesorno='0'
|
|
|
|
,rzh_date = null
|
|
|
|
,rzh_belong_date = null
|
|
|
|
,rzh_type=null
|
|
|
|
,gx_user_account=null
|
|
|
|
,gx_user_name=null
|
|
|
|
,gx_date = null
|
|
|
|
,gx_type = null
|
|
|
|
,send_date = null
|
|
|
|
,sfygx = '0'
|
|
|
|
,confirm_user =null
|
|
|
|
,dk_tax_amount=tax_amount
|
|
|
|
</if>
|
|
|
|
<if test="result.bdkMessage!=null and result.bdkMessage!=''">
|
|
|
|
,bdk_message=#{result.bdkMessage}
|
|
|
|
</if>
|
|
|
|
where uuid=#{uuid}
|
|
|
|
</update>
|
|
|
|
<update id="updateRecordForRebackNoDeduction" databaseId="oracle">
|
|
|
|
update t_dx_record_invoice SET
|
|
|
|
cxbdk_status=#{result.authState},
|
|
|
|
cxbdk_date=sysdate,
|
|
|
|
bdk_current_period=#{result.legalizeBelongDate},
|
|
|
|
xxly=#{result.xxly},
|
|
|
|
yqkgxbz=#{result.yqkgxbz},
|
|
|
|
glzt=#{result.glzt},
|
|
|
|
yclx=#{result.yclx},
|
|
|
|
rzh_back_msg=#{result.failureReason}
|
|
|
|
<if test='result.authState=="4"'>
|
|
|
|
,auth_status='6'
|
|
|
|
,rzh_yesorno='0'
|
|
|
|
,rzh_date = null
|
|
|
|
,rzh_belong_date = null
|
|
|
|
,rzh_type=null
|
|
|
|
,gx_user_account=null
|
|
|
|
,gx_user_name=null
|
|
|
|
,gx_date = null
|
|
|
|
,gx_type = null
|
|
|
|
,send_date = null
|
|
|
|
,sfygx = '0'
|
|
|
|
,confirm_user =null
|
|
|
|
,dk_tax_amount=tax_amount
|
|
|
|
</if>
|
|
|
|
<if test="result.bdkMessage!=null and result.bdkMessage!=''">
|
|
|
|
,bdk_message=#{result.bdkMessage}
|
|
|
|
</if>
|
|
|
|
where uuid=#{uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 撤销不抵扣成功之后 更新不抵扣相关字段 -->
|
|
|
|
<update id="updateBdkStatus">
|
|
|
|
update t_dx_record_invoice
|
|
|
|
set bdk_status='0',
|
|
|
|
bdk_date=null
|
|
|
|
where uuid = #{uuid}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 通过税号和当前数据查询抵扣统计表里是否存在 -->
|
|
|
|
<select id="findDkCount" resultType="java.lang.Integer">
|
|
|
|
select count(1)
|
|
|
|
from t_dx_dk_count
|
|
|
|
where taxno = #{taxno}
|
|
|
|
and skssq = #{incomeMonth}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 汇总需要发送税号认证的税号 -->
|
|
|
|
<select id="getNeedSendTaxNo" resultType="java.lang.String">
|
|
|
|
select distinct gf_tax_no from t_dx_record_invoice where
|
|
|
|
<if test='rzlx=="1"'>
|
|
|
|
auth_status='2' and rzlx = '1'
|
|
|
|
</if>
|
|
|
|
<if test='rzlx=="5"'>
|
|
|
|
yqsq_status='1'
|
|
|
|
</if>
|
|
|
|
<if test='rzlx=="4"'>
|
|
|
|
auth_status = '2' and rzlx = '4'
|
|
|
|
</if>
|
|
|
|
<if test='rzlx=="6"'>
|
|
|
|
cxrz_status='1'
|
|
|
|
</if>
|
|
|
|
<if test='rzlx=="7"'>
|
|
|
|
cxbdk_status='1'
|
|
|
|
</if>
|
|
|
|
group by gf_tax_no
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 汇总需要发送认证的税号不区分认证类型 -->
|
|
|
|
<select id="getAllNeedSendTaxNo" resultType="java.lang.String">
|
|
|
|
select distinct gf_tax_no
|
|
|
|
from t_dx_record_invoice
|
|
|
|
where auth_status = '2'
|
|
|
|
or cxrz_status = '1'
|
|
|
|
or cxbdk_status = '1'
|
|
|
|
group by gf_tax_no
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 通过税号查询id和key -->
|
|
|
|
<select id="findIdAndKeyByTaxno" resultType="com.dxhy.core.job.entity.TAcOrg">
|
|
|
|
select distinct g.taxno, g.db_name, g.company, g.ace_id, g.ace_key, password,company
|
|
|
|
from sys_dept g
|
|
|
|
where g.org_type = '5'
|
|
|
|
and g.cj_status = '1'
|
|
|
|
and g.taxno = #{taxno}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getTaxnoForDown" resultType="com.dxhy.core.job.entity.TAcOrg">
|
|
|
|
select distinct g.taxno, g.db_name, g.company, g.ace_id, g.ace_key
|
|
|
|
from sys_dept g
|
|
|
|
where g.org_type = '5'
|
|
|
|
and is_down = '1'
|
|
|
|
</select>
|
|
|
|
<select id="selectByuuid" resultType="java.lang.String">
|
|
|
|
select invoice_type from t_dx_record_invoice where uuid =#{uuid}
|
|
|
|
</select>
|
|
|
|
</mapper>
|