Merge pull request 'develop' (#313) from develop into master

Reviewed-on: http://git.xdadan.loc/tanex/emis-service/pulls/313
This commit is contained in:
heyu 2026-02-05 16:55:56 +08:00
commit 00617c933b
13 changed files with 377 additions and 11 deletions

View File

@ -115,6 +115,60 @@ public class EmisInvoiceCancellationController extends EmisBaseController
}
}
/**
* 发票红冲登记
*/
@PreAuthorize("@ss.hasPermi('emis:emisInvoiceCancellation:red')")
@Log(title = "发票红冲登记", businessType = BusinessType.UPDATE)
@PostMapping("/red")
public AjaxResult red(@RequestBody EmisInvoiceCancellation body)
{
if (body == null || body.getId() == null) {
return AjaxResult.error("id不能为空");
}
String redInvoiceNo = body.getRedInvoiceNo();
if (StringUtils.isEmpty(redInvoiceNo)) {
return AjaxResult.error("红冲发票号不能为空");
}
if (!redInvoiceNo.matches("\\d+")) {
return AjaxResult.error("红冲发票号必须为纯数字");
}
String userCode = SecurityUtils.getLoginUser().getUser().getEmpCode();
String siteCode = SecurityUtils.getLoginUser().getUser().getOwnerSiteCode();
try {
return toAjax(emisInvoiceCancellationService.red(body.getId(), redInvoiceNo, userCode, siteCode));
} catch (EmisBizError e) {
return AjaxResult.error(e.getMessage(), e.getErrorCode());
}
}
/**
* 修改红冲发票号
*/
@PreAuthorize("@ss.hasPermi('emis:emisInvoiceCancellation:redEdit')")
@Log(title = "修改红冲发票号", businessType = BusinessType.UPDATE)
@PostMapping("/red/edit")
public AjaxResult editRed(@RequestBody EmisInvoiceCancellation body)
{
if (body == null || body.getId() == null) {
return AjaxResult.error("id不能为空");
}
String redInvoiceNo = body.getRedInvoiceNo();
if (StringUtils.isEmpty(redInvoiceNo)) {
return AjaxResult.error("红冲发票号不能为空");
}
if (!redInvoiceNo.matches("\\d+")) {
return AjaxResult.error("红冲发票号必须为纯数字");
}
String userCode = SecurityUtils.getLoginUser().getUser().getEmpCode();
String siteCode = SecurityUtils.getLoginUser().getUser().getOwnerSiteCode();
try {
return toAjax(emisInvoiceCancellationService.editRed(body.getId(), redInvoiceNo, userCode, siteCode));
} catch (EmisBizError e) {
return AjaxResult.error(e.getMessage(), e.getErrorCode());
}
}
/**
* 删除发票作废表
*/
@ -207,12 +261,10 @@ public class EmisInvoiceCancellationController extends EmisBaseController
EmisSettleInvoiceRecord query = new EmisSettleInvoiceRecord();
query.setApplySeqNo(applySeqNo);
query.setInvoiceNo(invoiceNo);
List<EmisSettleInvoiceRecord> invoiceList = emisSettleInvoiceRecordService.selectEmisSettleInvoiceRecordList(query);
if (invoiceList == null || invoiceList.isEmpty()) {
EmisSettleInvoiceRecord invoice = emisSettleInvoiceRecordService.selectInvoiceInfoWithDetail(query);
if (invoice == null) {
return AjaxResult.error("发票不存在");
}
EmisSettleInvoiceRecord invoice = invoiceList.get(0);
if (!"2".equals(invoice.getInvoiceStatus())) {
return AjaxResult.error("未开票");
}

View File

@ -13,6 +13,7 @@ package com.xdadan.erp.emis.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xdadan.erp.common.annotation.Excel;
import com.xdadan.erp.common.annotation.audit.DataAuditField;
import com.xdadan.erp.common.annotation.audit.DataAuditTable;
import com.xdadan.erp.common.core.domain.BaseEntity;
import lombok.Data;
@ -28,6 +29,7 @@ import java.util.List;
* @date 2026-01-19 14:33:40
*/
@Data
@DataAuditTable(tableName = "emis_invoice_cancellation", tableComment = "发票作废表", bizKey = "applySeqNo")
public class EmisInvoiceCancellation extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -60,6 +62,17 @@ public class EmisInvoiceCancellation extends BaseEntity
private String auditSiteCode;
/* 驳回原因 */
private String auditRejectReason;
/* 开票状态 1-已开票 2-已作废,默认为1 */
private String invoiceStatus;
/* 红冲发票号 */
@DataAuditField(fieldComment = "红冲发票号")
private String redInvoiceNo;
/* 红冲发票登记人编码 */
private String redCreateBy;
/* 红冲发票登记网点编码 */
private String redCreateSite;
/* 红冲发票登记时间 */
private String redCreateTime;
// 扩展信息-查询返回
/* 开票记录表信息 */
@ -78,5 +91,13 @@ public class EmisInvoiceCancellation extends BaseEntity
private String custNo;
/* 客户名称 */
private String customerName;
/* 运单号,多个用逗号隔开 */
private String billCodes;
/* 销售联系人,多个用逗号隔开 */
private String salesmens;
/* 红冲发票登记人名称 */
private String redCreateByName;
/* 红冲发票登记网点名称 */
private String redCreateSiteName;
}

View File

@ -157,6 +157,10 @@ public class EmisSettleInvoiceRecord extends BaseEntity
private String opManName;
private String opSiteName;
/* 运单号,多个用逗号隔开 */
private String billCodes;
/* 销售联系人,多个用逗号隔开 */
private String salesmens;
List<EmisSettleInvoiceRel> invoiceRelList;

View File

@ -13,7 +13,10 @@ package com.xdadan.erp.emis.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdadan.erp.common.annotation.audit.DataAuditLog;
import com.xdadan.erp.common.annotation.audit.OperateType;
import com.xdadan.erp.emis.domain.EmisInvoiceCancellation;
import com.xdadan.erp.emis.service.impl.EmisInvoiceCancellationServiceImpl;
import org.apache.ibatis.annotations.Param;
/**
@ -105,4 +108,16 @@ public interface EmisInvoiceCancellationMapper extends BaseMapper<EmisInvoiceCan
* 查询是否存在未完结申请(审核状态0或1)
*/
int countActiveApply(@Param("invoiceId") Long invoiceId);
/**
* 发票红冲登记(更新红冲信息并将开票状态置为已作废)
*/
@DataAuditLog(operateType = OperateType.ADD, serviceClass = EmisInvoiceCancellationServiceImpl.class)
int updateRed(EmisInvoiceCancellation emisInvoiceCancellation);
/**
* 修改红冲发票号
*/
@DataAuditLog(operateType = OperateType.UPDATE, serviceClass = EmisInvoiceCancellationServiceImpl.class)
int updateRedInvoiceNo(EmisInvoiceCancellation emisInvoiceCancellation);
}

View File

@ -142,4 +142,12 @@ public interface EmisSettleInvoiceRecordMapper extends BaseMapper<EmisSettleInvo
*/
public int batchCancelDelayInvoice(@Param("ids") Long[] ids, @Param("cancelOpManCode") String cancelOpManCode, @Param("updateSite") String updateSite);
/**
* 根据申请序号/发票号查询发票信息(含运单号billCodes、销售联系人salesmens)
*
* @param emisSettleInvoiceRecord 查询条件(applySeqNo、invoiceNo)
* @return 发票记录
*/
EmisSettleInvoiceRecord selectInvoiceInfoWithDetail(EmisSettleInvoiceRecord emisSettleInvoiceRecord);
}

View File

@ -9,6 +9,7 @@
*/
package com.xdadan.erp.emis.service;
import com.xdadan.erp.common.core.audit.IDataAuditService;
import com.xdadan.erp.emis.domain.EmisInvoiceCancellation;
import java.util.List;
@ -19,7 +20,7 @@ import java.util.List;
* @author heyu
* @date 2026-01-19 14:33:40
*/
public interface IEmisInvoiceCancellationService {
public interface IEmisInvoiceCancellationService extends IDataAuditService {
/**
* 主键查询
*
@ -103,4 +104,26 @@ public interface IEmisInvoiceCancellationService {
* 是否存在审核中/已通过的申请
*/
boolean existsActiveApply(Long invoiceId);
/**
* 发票红冲登记(更新红冲信息并将开票状态置为已作废)
*
* @param id 申请ID
* @param redInvoiceNo 红冲发票号
* @param redCreateBy 红冲登记人
* @param redCreateSite 红冲登记网点
* @return 结果
*/
int red(Long id, String redInvoiceNo, String redCreateBy, String redCreateSite) throws com.xdadan.erp.emis.domain.exception.EmisBizError;
/**
* 修改红冲发票号
*
* @param id 申请ID
* @param redInvoiceNo 红冲发票号
* @param updateBy 修改人
* @param updateSite 修改网点
* @return 结果
*/
int editRed(Long id, String redInvoiceNo, String updateBy, String updateSite) throws com.xdadan.erp.emis.domain.exception.EmisBizError;
}

View File

@ -133,4 +133,12 @@ public interface IEmisSettleInvoiceRecordService {
*/
public int batchCancelDelayInvoice(Long[] ids) throws EmisBizError;
/**
* 根据申请序号/发票号查询发票信息(含运单号billCodes、销售联系人salesmens)
*
* @param emisSettleInvoiceRecord 查询条件(applySeqNo、invoiceNo)
* @return 发票记录
*/
EmisSettleInvoiceRecord selectInvoiceInfoWithDetail(EmisSettleInvoiceRecord emisSettleInvoiceRecord);
}

View File

@ -15,6 +15,7 @@ import java.util.List;
import com.xdadan.erp.common.utils.DateUtils;
import com.xdadan.erp.emis.domain.EmisInvoiceCancellation;
import com.xdadan.erp.emis.domain.EmisTmsSiteBatch;
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
import com.xdadan.erp.emis.domain.exception.EmisBizError;
import com.xdadan.erp.emis.mapper.EmisInvoiceCancellationMapper;
@ -35,6 +36,18 @@ public class EmisInvoiceCancellationServiceImpl implements IEmisInvoiceCancellat
@Autowired
private EmisInvoiceCancellationMapper emisInvoiceCancellationMapper;
/**
* 获取稽核数据
*
* @param id
* @return
*/
@Override
public Object getAuditObjectById(Object id) {
EmisInvoiceCancellation emisInvoiceCancellation = emisInvoiceCancellationMapper.selectEmisInvoiceCancellationById((Long) id);
return emisInvoiceCancellation;
}
/**
* 查询发票作废表
*
@ -185,6 +198,58 @@ public class EmisInvoiceCancellationServiceImpl implements IEmisInvoiceCancellat
return emisInvoiceCancellationMapper.countActiveApply(invoiceId) > 0;
}
@Override
public int red(Long id, String redInvoiceNo, String redCreateBy, String redCreateSite) throws EmisBizError {
if (id == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "id必传");
}
validateRedInvoiceNo(redInvoiceNo);
EmisInvoiceCancellation db = emisInvoiceCancellationMapper.selectEmisInvoiceCancellationById(id);
if (db == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "申请不存在");
}
EmisInvoiceCancellation update = new EmisInvoiceCancellation();
update.setId(id);
update.setRedInvoiceNo(redInvoiceNo);
update.setRedCreateBy(redCreateBy);
update.setRedCreateSite(redCreateSite);
// 开票状态:1-已开票 2-已作废
update.setInvoiceStatus("2");
update.setUpdateBy(redCreateBy);
update.setUpdateSite(redCreateSite);
return emisInvoiceCancellationMapper.updateRed(update);
}
@Override
public int editRed(Long id, String redInvoiceNo, String updateBy, String updateSite) throws EmisBizError {
if (id == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "id必传");
}
validateRedInvoiceNo(redInvoiceNo);
EmisInvoiceCancellation db = emisInvoiceCancellationMapper.selectEmisInvoiceCancellationById(id);
if (db == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "申请不存在");
}
EmisInvoiceCancellation update = new EmisInvoiceCancellation();
update.setId(id);
update.setRedInvoiceNo(redInvoiceNo);
update.setUpdateBy(updateBy);
update.setUpdateSite(updateSite);
return emisInvoiceCancellationMapper.updateRedInvoiceNo(update);
}
/**
* 校验红冲发票号为纯数字
*/
private void validateRedInvoiceNo(String redInvoiceNo) throws EmisBizError {
if (!StringUtils.hasText(redInvoiceNo)) {
throw new EmisBizError(EmisBizErrorType.FAIL, "红冲发票号不能为空");
}
if (!redInvoiceNo.matches("\\d+")) {
throw new EmisBizError(EmisBizErrorType.FAIL, "红冲发票号必须为纯数字");
}
}
private void validateRequired(EmisInvoiceCancellation emisInvoiceCancellation) throws EmisBizError {
if (emisInvoiceCancellation == null || emisInvoiceCancellation.getInvoiceId() == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "invoiceId必传");

View File

@ -1204,4 +1204,15 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
return emisSettleInvoiceRecordMapper.batchCancelDelayInvoice(ids, cancelOpManCode, updateSite);
}
/**
* 根据申请序号/发票号查询发票信息(含运单号billCodes、销售联系人salesmens)
*
* @param emisSettleInvoiceRecord 查询条件(applySeqNo、invoiceNo)
* @return 发票记录
*/
@Override
public EmisSettleInvoiceRecord selectInvoiceInfoWithDetail(EmisSettleInvoiceRecord emisSettleInvoiceRecord) {
return emisSettleInvoiceRecordMapper.selectInvoiceInfoWithDetail(emisSettleInvoiceRecord);
}
}

View File

@ -276,7 +276,7 @@ public class EmisSpecialZoneAddressMatchServiceImpl implements IEmisSpecialZoneA
}
// 去掉所有空白字符并统一转大写
String normalizedAddress = address.replaceAll("\\s+", "").toUpperCase();
String normalizedAddress = address.replaceAll("\\p{Z}+", "").toUpperCase();
if (StringUtils.isBlank(normalizedAddress))
{
return null;

View File

@ -19,9 +19,16 @@
<result property="auditManCode" column="audit_man_code"/>
<result property="auditSiteCode" column="audit_site_code"/>
<result property="auditRejectReason" column="audit_reject_reason"/>
<result property="invoiceStatus" column="invoice_status"/>
<result property="redInvoiceNo" column="red_invoice_no"/>
<result property="redCreateBy" column="red_create_by"/>
<result property="redCreateSite" column="red_create_site"/>
<result property="redCreateTime" column="red_create_time"/>
<result property="billMonth" column="bill_month"/>
<result property="custNo" column="cust_no"/>
<result property="customerName" column="customer_name"/>
<result property="billCodes" column="bill_codes"/>
<result property="salesmens" column="salesmens"/>
<association property="applyManName" column="apply_man_code"
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
@ -31,6 +38,10 @@
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
<association property="auditSiteName" column="audit_site_code"
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="redCreateByName" column="red_create_by"
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
<association property="redCreateSiteName" column="red_create_site"
select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
<association property="emisSettleInvoiceRecord" javaType="com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord">
<id property="id" column="inv_id"/>
@ -55,7 +66,9 @@
<sql id="selectEmisInvoiceCancellationVo">
select c.id, c.invoice_id, c.apply_seq_no, c.apply_date, c.apply_reason, c.apply_text_url,
c.apply_man_code, c.apply_site_code, c.audit_status, c.audit_date, c.audit_man_code, c.audit_site_code,
c.audit_reject_reason, c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
c.audit_reject_reason, c.invoice_status,
c.red_invoice_no, c.red_create_by, c.red_create_site, c.red_create_time,
c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
c.update_time, c.create_site, c.update_site,
i.id as inv_id, i.apply_seq_no as inv_apply_seq_no, i.apply_date as inv_apply_date,
i.customer_code as inv_customer_code, i.customer_name as inv_customer_name,
@ -65,11 +78,14 @@
i.invoice_no as inv_invoice_no, i.invoice_status as inv_invoice_status, i.payment_status as inv_payment_status,
GROUP_CONCAT(DISTINCT b.bill_month ORDER BY b.bill_month SEPARATOR ',') as bill_month,
GROUP_CONCAT(DISTINCT b.cust_no ORDER BY b.cust_no SEPARATOR ',') as cust_no,
GROUP_CONCAT(DISTINCT b.cust_name ORDER BY b.cust_name SEPARATOR ',') as customer_name
GROUP_CONCAT(DISTINCT b.cust_name ORDER BY b.cust_name SEPARATOR ',') as customer_name,
GROUP_CONCAT(DISTINCT r.bill_no ORDER BY r.bill_no SEPARATOR ',') as bill_codes,
GROUP_CONCAT(DISTINCT b.salesmen ORDER BY b.salesmen SEPARATOR ',') as salesmens
from emis_invoice_cancellation c
left join emis_settle_invoice_record i on c.invoice_id = i.id and i.del_flag = '0'
left join emis_settle_invoice_bill_rel rel on i.apply_seq_no = rel.apply_seq_no and rel.del_flag = '0'
left join emis_settle_bill b on rel.settle_bill_no = b.settle_bill_no and b.del_flag = '0'
left join emis_settle_invoice_rel r on i.apply_seq_no = r.apply_seq_no and r.del_flag = '0'
</sql>
<select id="selectEmisInvoiceCancellationList" parameterType="EmisInvoiceCancellation"
@ -86,6 +102,7 @@
<if test="auditStatus != null and auditStatus != ''"> and c.audit_status = #{auditStatus}</if>
<if test="auditManCode != null and auditManCode != ''"> and c.audit_man_code = #{auditManCode}</if>
<if test="auditSiteCode != null and auditSiteCode != ''"> and c.audit_site_code = #{auditSiteCode}</if>
<if test="invoiceStatus != null and invoiceStatus != ''"> and c.invoice_status = #{invoiceStatus}</if>
<if test="params.beginApplyDate != null and params.beginApplyDate != ''">
and c.apply_date <![CDATA[ >= ]]> #{params.beginApplyDate}
</if>
@ -98,6 +115,12 @@
<if test="params.endAuditDate != null and params.endAuditDate != ''">
and c.audit_date <![CDATA[ <= ]]> #{params.endAuditDate}
</if>
<if test="params.companyName != null and params.companyName != ''">
and i.company_name like concat('%', #{params.companyName}, '%')
</if>
<if test="params.applyMoney != null and params.applyMoney != ''">
and i.apply_money like concat('%', #{params.applyMoney}, '%')
</if>
<if test="params.settleBillNo != null and params.settleBillNo != ''">
and find_in_set(i.settle_bill_no, #{params.settleBillNo})
</if>
@ -162,7 +185,9 @@
</where>
group by c.id, c.invoice_id, c.apply_seq_no, c.apply_date, c.apply_reason, c.apply_text_url,
c.apply_man_code, c.apply_site_code, c.audit_status, c.audit_date, c.audit_man_code, c.audit_site_code,
c.audit_reject_reason, c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
c.audit_reject_reason, c.invoice_status,
c.red_invoice_no, c.red_create_by, c.red_create_site, c.red_create_time,
c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
c.update_time, c.create_site, c.update_site,
i.id, i.apply_seq_no, i.apply_date, i.customer_code, i.customer_name,
i.settle_bill_no, i.settle_bill_name, i.apply_money, i.add_tax_rate, i.add_open_money,
@ -176,7 +201,9 @@
where c.del_flag = '0' and c.id = #{id}
group by c.id, c.invoice_id, c.apply_seq_no, c.apply_date, c.apply_reason, c.apply_text_url,
c.apply_man_code, c.apply_site_code, c.audit_status, c.audit_date, c.audit_man_code, c.audit_site_code,
c.audit_reject_reason, c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
c.audit_reject_reason, c.invoice_status,
c.red_invoice_no, c.red_create_by, c.red_create_site, c.red_create_time,
c.remark, c.del_flag, c.create_by, c.create_time, c.update_by,
c.update_time, c.create_site, c.update_site,
i.id, i.apply_seq_no, i.apply_date, i.customer_code, i.customer_name,
i.settle_bill_no, i.settle_bill_name, i.apply_money, i.add_tax_rate, i.add_open_money,
@ -199,6 +226,11 @@
<if test="auditManCode != null and auditManCode != ''">audit_man_code,</if>
<if test="auditSiteCode != null and auditSiteCode != ''">audit_site_code,</if>
<if test="auditRejectReason != null and auditRejectReason != ''">audit_reject_reason,</if>
<if test="invoiceStatus != null and invoiceStatus != ''">invoice_status,</if>
<if test="redInvoiceNo != null and redInvoiceNo != ''">red_invoice_no,</if>
<if test="redCreateBy != null and redCreateBy != ''">red_create_by,</if>
<if test="redCreateSite != null and redCreateSite != ''">red_create_site,</if>
<if test="redCreateTime != null and redCreateTime != ''">red_create_time,</if>
<if test="remark != null and remark != ''">remark,</if>
del_flag,
<if test="createBy != null and createBy != ''">create_by,</if>
@ -221,6 +253,11 @@
<if test="auditManCode != null and auditManCode != ''">#{auditManCode},</if>
<if test="auditSiteCode != null and auditSiteCode != ''">#{auditSiteCode},</if>
<if test="auditRejectReason != null and auditRejectReason != ''">#{auditRejectReason},</if>
<if test="invoiceStatus != null and invoiceStatus != ''">#{invoiceStatus},</if>
<if test="redInvoiceNo != null and redInvoiceNo != ''">#{redInvoiceNo},</if>
<if test="redCreateBy != null and redCreateBy != ''">#{redCreateBy},</if>
<if test="redCreateSite != null and redCreateSite != ''">#{redCreateSite},</if>
<if test="redCreateTime != null and redCreateTime != ''">#{redCreateTime},</if>
<if test="remark != null and remark != ''">#{remark},</if>
'0',
<if test="createBy != null and createBy != ''">#{createBy},</if>
@ -247,6 +284,11 @@
<if test="auditManCode != null and auditManCode != ''">audit_man_code = #{auditManCode},</if>
<if test="auditSiteCode != null and auditSiteCode != ''">audit_site_code = #{auditSiteCode},</if>
<if test="auditRejectReason != null and auditRejectReason != ''">audit_reject_reason = #{auditRejectReason},</if>
<if test="invoiceStatus != null and invoiceStatus != ''">invoice_status = #{invoiceStatus},</if>
<if test="redInvoiceNo != null and redInvoiceNo != ''">red_invoice_no = #{redInvoiceNo},</if>
<if test="redCreateBy != null and redCreateBy != ''">red_create_by = #{redCreateBy},</if>
<if test="redCreateSite != null and redCreateSite != ''">red_create_site = #{redCreateSite},</if>
<if test="redCreateTime != null and redCreateTime != ''">red_create_time = #{redCreateTime},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
@ -257,6 +299,30 @@
where id = #{id}
</update>
<update id="updateRed" parameterType="EmisInvoiceCancellation">
update emis_invoice_cancellation
set red_invoice_no = #{redInvoiceNo},
red_create_by = #{redCreateBy},
red_create_site = #{redCreateSite},
red_create_time = now(),
invoice_status = #{invoiceStatus},
update_by = #{updateBy},
update_site = #{updateSite},
update_time = now()
where del_flag = '0'
and id = #{id}
</update>
<update id="updateRedInvoiceNo" parameterType="EmisInvoiceCancellation">
update emis_invoice_cancellation
set red_invoice_no = #{redInvoiceNo},
update_by = #{updateBy},
update_site = #{updateSite},
update_time = now()
where del_flag = '0'
and id = #{id}
</update>
<delete id="deleteEmisInvoiceCancellationById" parameterType="Long">
update emis_invoice_cancellation set del_flag = '2' where id = #{id}
</delete>

View File

@ -56,6 +56,8 @@
<result property="delayOpManCode" column="delay_op_man_code" />
<result property="delayOpDate" column="delay_op_date" />
<result property="salerCompanyName" column="saler_company_name" />
<result property="billCodes" column="bill_codes" />
<result property="salesmens" column="salesmens" />
<association property="applyManName" column="apply_man_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectEmpNameByCode"/>
<association property="applySiteName" column="apply_site_code" select="com.xdadan.erp.emis.mapper.EmisBaseMapper.selectSiteNameByCode"/>
@ -516,6 +518,97 @@
where a.id = #{id}
</select>
<!-- 根据申请序号/发票号查询发票信息(含运单号billCodes、销售联系人salesmens) -->
<select id="selectInvoiceInfoWithDetail" parameterType="EmisSettleInvoiceRecord"
resultMap="EmisSettleInvoiceRecordResult">
select a.id, a.apply_seq_no, a.apply_date, a.apply_man_code, a.apply_site_code, a.customer_code, a.customer_name, a.settle_bill_no, a.settle_bill_name, a.apply_money, a.invoice_type, a.openbill_scope, a.company_name, a.company_tax_no, a.company_tel, a.company_address, a.invioce_remark, a.bank_name, a.bank_acc_no, a.contact, a.phone, a.real_tax_type, a.orig_open_money, a.add_tax_rate, a.add_open_money, a.open_money_max, a.open_money, ch.invoice_no, a.reced_money, a.payment_status, a.invoice_status, a.invoice_status_desc, a.recieve_address, a.email, a.file_path, a.remark, a.bl_audit, a.audit_date, a.audit_man_code, a.audit_site_code, a.audit_note, a.op_man_code, a.op_date, a.op_site_code, a.open_ch_id, a.open_ch_status, a.open_ch_status_desc, a.open_com_code, a.bl_delay, a.delay_op_man_code, a.delay_op_date, ch.saler_company_name, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.create_site, a.update_site,
GROUP_CONCAT(DISTINCT r.bill_no ORDER BY r.bill_no SEPARATOR ',') as bill_codes,
GROUP_CONCAT(DISTINCT b.salesmen ORDER BY b.salesmen SEPARATOR ',') as salesmens
from emis_settle_invoice_record a
left join emis_settle_invoice_bill_rel rel
on a.apply_seq_no = rel.apply_seq_no and rel.del_flag = '0'
left join emis_settle_bill b
on rel.settle_bill_no = b.settle_bill_no and b.del_flag = '0'
left join emis_settle_invoice_rel r
on a.apply_seq_no = r.apply_seq_no and r.del_flag = '0'
left join (
select ch1.*
from emis_settle_invoice_ch_record ch1
inner join (
select apply_seq_no, max(id) as max_id
from emis_settle_invoice_ch_record
where del_flag = '0'
group by apply_seq_no
) ch2 on ch1.apply_seq_no = ch2.apply_seq_no and ch1.id = ch2.max_id
where ch1.del_flag = '0'
) ch on a.apply_seq_no = ch.apply_seq_no
where a.del_flag = '0'
<if test="applySeqNo != null and applySeqNo != ''">
and find_in_set(a.apply_seq_no, #{applySeqNo})
</if>
<if test="invoiceNo != null and invoiceNo != ''">
and find_in_set(a.invoice_no, #{invoiceNo})
</if>
group by a.id,
a.apply_seq_no,
a.apply_date,
a.apply_man_code,
a.apply_site_code,
a.customer_code,
a.customer_name,
a.settle_bill_no,
a.settle_bill_name,
a.apply_money,
a.invoice_type,
a.openbill_scope,
a.company_name,
a.company_tax_no,
a.company_tel,
a.company_address,
a.invioce_remark,
a.bank_name,
a.bank_acc_no,
a.contact,
a.phone,
a.real_tax_type,
a.orig_open_money,
a.add_tax_rate,
a.add_open_money,
a.open_money_max,
a.open_money,
a.invoice_no,
a.reced_money,
a.payment_status,
a.invoice_status,
a.invoice_status_desc,
a.recieve_address,
a.email,
a.file_path,
a.remark,
a.bl_audit,
a.audit_date,
a.audit_man_code,
a.audit_site_code,
a.audit_note,
a.op_man_code,
a.op_date,
a.op_site_code,
a.open_ch_id,
a.open_ch_status,
a.open_ch_status_desc,
a.open_com_code,
a.bl_delay,
a.delay_op_man_code,
a.delay_op_date,
a.del_flag,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.create_site,
a.update_site
</select>
<insert id="insertEmisSettleInvoiceRecord" parameterType="EmisSettleInvoiceRecord" useGeneratedKeys="true" keyProperty="id">
insert into emis_settle_invoice_record
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -65,7 +65,7 @@
select id, country_code, province_code, special_zone_name, special_zone_tag, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site
from emis_special_zone_address_match a
where a.del_flag = '0'
and #{normalizedAddress} like concat('%', upper(replace(a.special_zone_tag, ' ', '')), '%')
and #{normalizedAddress} like concat('%', upper(replace(replace(replace(a.special_zone_tag, ' ', ''), char(160), ''), char(12288), '')), '%')
limit 1
</select>