demand: TMS-财务中心销账审核:列表数据展示增添字段
This commit is contained in:
parent
fee685fd37
commit
004b8bf6ee
@ -19,7 +19,6 @@ import com.xdadan.erp.emis.domain.EmisWriteoffApplyDetail;
|
||||
import com.xdadan.erp.emis.domain.EmisSalesmenRel;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import com.xdadan.erp.emis.service.IEmisWriteoffApplyService;
|
||||
import com.xdadan.erp.emis.service.IEmisSettleInvoiceRecordService;
|
||||
import com.xdadan.erp.emis.service.IEmisSalesmenRelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -48,9 +47,6 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
@Autowired
|
||||
private IEmisSalesmenRelService emisSalesmenRelService;
|
||||
|
||||
@Autowired
|
||||
private IEmisSettleInvoiceRecordService emisSettleInvoiceRecordService;
|
||||
|
||||
/**
|
||||
* 查询销账申请列表
|
||||
*/
|
||||
@ -63,12 +59,6 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
|
||||
setPrivParams(emisWriteoffApply);
|
||||
|
||||
// 支持按发票号查询:将多行发票号格式化为逗号分隔
|
||||
if (emisWriteoffApply.getInvoiceNo() != null && !emisWriteoffApply.getInvoiceNo().trim().isEmpty()) {
|
||||
emisWriteoffApply.setInvoiceNo(
|
||||
com.xdadan.erp.emis.utils.WaybillHelper.formatQueryValue(emisWriteoffApply.getInvoiceNo()));
|
||||
}
|
||||
|
||||
// 处理params参数,支持运单号、账单号多选查询
|
||||
if (emisWriteoffApply.getParams() != null && emisWriteoffApply.getParams().containsKey("queryParams")) {
|
||||
String queryParams = (String) emisWriteoffApply.getParams().get("queryParams");
|
||||
@ -96,49 +86,6 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
|
||||
// 计算并设置申请账单相关字段
|
||||
if (list != null) {
|
||||
// 收集所有运单号,用于一次性查询对应的发票号
|
||||
java.util.Set<String> allBillCodes = new java.util.HashSet<>();
|
||||
|
||||
for (EmisWriteoffApply apply : list) {
|
||||
if (apply != null && apply.getDetailList() != null && !apply.getDetailList().isEmpty()) {
|
||||
for (EmisWriteoffApplyDetail detail : apply.getDetailList()) {
|
||||
if (detail != null && detail.getBillCode() != null && !detail.getBillCode().trim().isEmpty()) {
|
||||
allBillCodes.add(detail.getBillCode().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询所有相关运单号对应的发票记录,并构造 billCode -> 发票号列表 映射
|
||||
java.util.Map<String, java.util.List<String>> billInvoiceMap = new java.util.HashMap<>();
|
||||
if (!allBillCodes.isEmpty()) {
|
||||
java.util.List<String> billCodeList = new java.util.ArrayList<>(allBillCodes);
|
||||
java.util.List<com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord> invoiceRecords =
|
||||
emisSettleInvoiceRecordService.selectInvoiceRecordListByBillCodes(billCodeList);
|
||||
if (invoiceRecords != null) {
|
||||
for (com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord record : invoiceRecords) {
|
||||
if (record == null || record.getInvoiceNo() == null
|
||||
|| record.getInvoiceNo().trim().isEmpty()
|
||||
|| record.getBillCodes() == null
|
||||
|| record.getBillCodes().trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String[] codes = record.getBillCodes().split(",");
|
||||
for (String code : codes) {
|
||||
if (code == null) {
|
||||
continue;
|
||||
}
|
||||
String billCode = code.trim();
|
||||
if (billCode.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
billInvoiceMap.computeIfAbsent(billCode, k -> new java.util.ArrayList<>())
|
||||
.add(record.getInvoiceNo().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (EmisWriteoffApply apply : list) {
|
||||
if (apply != null && apply.getDetailList() != null && !apply.getDetailList().isEmpty()) {
|
||||
// 提取账单名称列表(去重)
|
||||
@ -177,23 +124,6 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
})
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
apply.setApplyRecMoney(totalAmount);
|
||||
|
||||
// 计算并设置发票号列表(去重后用逗号拼接)
|
||||
java.util.Set<String> invoiceNos = new java.util.LinkedHashSet<>();
|
||||
for (EmisWriteoffApplyDetail detail : apply.getDetailList()) {
|
||||
if (detail == null || detail.getBillCode() == null) {
|
||||
continue;
|
||||
}
|
||||
java.util.List<String> invList = billInvoiceMap.get(detail.getBillCode().trim());
|
||||
if (invList != null) {
|
||||
for (String inv : invList) {
|
||||
if (inv != null && !inv.trim().isEmpty()) {
|
||||
invoiceNos.add(inv.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
apply.setInvoiceNo(invoiceNos.isEmpty() ? "" : String.join(",", invoiceNos));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -212,12 +142,6 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
emisWriteoffApply = new EmisWriteoffApply();
|
||||
}
|
||||
|
||||
// 支持按发票号查询:将多行发票号格式化为逗号分隔
|
||||
if (emisWriteoffApply.getInvoiceNo() != null && !emisWriteoffApply.getInvoiceNo().trim().isEmpty()) {
|
||||
emisWriteoffApply.setInvoiceNo(
|
||||
com.xdadan.erp.emis.utils.WaybillHelper.formatQueryValue(emisWriteoffApply.getInvoiceNo()));
|
||||
}
|
||||
|
||||
// 处理params参数,支持运单号、账单号多选查询
|
||||
if (emisWriteoffApply.getParams() != null && emisWriteoffApply.getParams().containsKey("queryParams")) {
|
||||
String queryParams = (String) emisWriteoffApply.getParams().get("queryParams");
|
||||
@ -584,57 +508,8 @@ public class EmisWriteoffApplyController extends EmisBaseController {
|
||||
// 获取当前登录用户信息
|
||||
String currentEmpName = getLoginUser().getUser().getEmpName();
|
||||
|
||||
// 先为返回的明细填充发票号信息(每个运单可能存在多张发票,逗号分隔)
|
||||
java.util.Set<String> allBillCodes = list.stream()
|
||||
.filter(d -> d != null && d.getBillCode() != null && !d.getBillCode().trim().isEmpty())
|
||||
.map(d -> d.getBillCode().trim())
|
||||
.collect(java.util.stream.Collectors.toSet());
|
||||
|
||||
java.util.Map<String, String> billInvoiceStrMap = new java.util.HashMap<>();
|
||||
if (!allBillCodes.isEmpty()) {
|
||||
java.util.List<String> billCodeListAll = new java.util.ArrayList<>(allBillCodes);
|
||||
java.util.List<com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord> invoiceRecords =
|
||||
emisSettleInvoiceRecordService.selectInvoiceRecordListByBillCodes(billCodeListAll);
|
||||
if (invoiceRecords != null) {
|
||||
java.util.Map<String, java.util.Set<String>> billInvoiceSetMap = new java.util.HashMap<>();
|
||||
for (com.xdadan.erp.emis.domain.EmisSettleInvoiceRecord record : invoiceRecords) {
|
||||
if (record == null || record.getInvoiceNo() == null
|
||||
|| record.getInvoiceNo().trim().isEmpty()
|
||||
|| record.getBillCodes() == null
|
||||
|| record.getBillCodes().trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String invoiceNo = record.getInvoiceNo().trim();
|
||||
String[] codes = record.getBillCodes().split(",");
|
||||
for (String code : codes) {
|
||||
if (code == null) {
|
||||
continue;
|
||||
}
|
||||
String billCode = code.trim();
|
||||
if (billCode.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
billInvoiceSetMap.computeIfAbsent(billCode, k -> new java.util.LinkedHashSet<>())
|
||||
.add(invoiceNo);
|
||||
}
|
||||
}
|
||||
// 转换为逗号分隔的字符串
|
||||
for (java.util.Map.Entry<String, java.util.Set<String>> entry : billInvoiceSetMap.entrySet()) {
|
||||
billInvoiceStrMap.put(entry.getKey(),
|
||||
String.join(",", entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 验证权限和账单状态,并设置每条明细的发票号
|
||||
// 验证权限和账单状态
|
||||
for (EmisWriteoffApplyDetail detail : list) {
|
||||
if (detail != null && detail.getBillCode() != null) {
|
||||
String invoiceStr = billInvoiceStrMap.get(detail.getBillCode().trim());
|
||||
if (invoiceStr != null) {
|
||||
detail.setInvoiceNo(invoiceStr);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 验证用户权限:检查是否是运单的销售联系人/回款联系人/销售联系人关联的助理
|
||||
if (!hasPermissionToViewBill(detail, currentEmpName)) {
|
||||
return error("您没有权限查看运单 " + detail.getBillCode() + " 的信息");
|
||||
|
||||
@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="applyMoney" column="apply_money" />
|
||||
<result property="settleBillNo" column="settle_bill_no" />
|
||||
<result property="expressType" column="express_type" />
|
||||
<result property="invoiceNo" column="invoice_no" />
|
||||
<!-- 关联运单信息 -->
|
||||
<association property="emisWaybill" javaType="EmisWaybill">
|
||||
<result property="id" column="w_id"/>
|
||||
@ -242,7 +243,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ssb.bl_sensitive as ssb_bl_sensitive, ssb.bl_confirm_center as ssb_bl_confirm_center, ssb.confirm_center_date as ssb_confirm_center_date,
|
||||
ssb.confirm_center_note as ssb_confirm_center_note, ssb.confirm_center_man_code as ssb_confirm_center_man_code,
|
||||
ssb.confirm_center_code as ssb_confirm_center_code, ssb.bl_confirm_site as ssb_bl_confirm_site, ssb.confirm_site_date as ssb_confirm_site_date,
|
||||
ssb.confirm_site_man_code as ssb_confirm_site_man_code, ssb.confirm_site_note as ssb_confirm_site_note, ssb.confirm_site_code as ssb_confirm_site_code
|
||||
ssb.confirm_site_man_code as ssb_confirm_site_man_code, ssb.confirm_site_note as ssb_confirm_site_note, ssb.confirm_site_code as ssb_confirm_site_code,
|
||||
GROUP_CONCAT(DISTINCT ch.invoice_no ORDER BY ch.invoice_no SEPARATOR ',') as invoice_no
|
||||
from emis_writeoff_apply_detail wad
|
||||
left join emis_waybill w on wad.bill_code = w.bill_code and w.del_flag = '0'
|
||||
left join emis_trans_product tp on w.product_type = tp.prod_code and tp.del_flag = '0'
|
||||
@ -250,6 +252,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join emis_settle_sub_bill ssb on wad.bill_code = ssb.bill_code and ssb.del_flag = '0'
|
||||
left join emis_site send_site on w.send_site_code = send_site.site_code and send_site.del_flag = '0'
|
||||
left join emis_site dest_site on w.dispatch_underling_site_code = dest_site.site_code and dest_site.del_flag = '0'
|
||||
left join emis_settle_invoice_bill_rel sibr on ssb.settle_bill_no = sibr.settle_bill_no and sibr.del_flag = '0'
|
||||
left join emis_settle_invoice_record sir on sibr.apply_seq_no = sir.apply_seq_no and sir.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 sir.apply_seq_no = ch.apply_seq_no
|
||||
</sql>
|
||||
|
||||
<!-- 根据运单号汇总历史申请金额(仅统计财务中心未通过的数据:bl_center_confirmed != 1) -->
|
||||
@ -275,17 +290,95 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="settleBillNo != null and settleBillNo != ''"> and wad.settle_bill_no = #{settleBillNo}</if>
|
||||
<if test="applyMoney != null "> and wad.apply_money = #{applyMoney}</if>
|
||||
</where>
|
||||
group by wad.id, wad.apply_id, wad.apply_no, wad.bill_code, wad.apply_money, wad.settle_bill_no, wad.del_flag,
|
||||
wad.create_by, wad.create_time, wad.update_by, wad.update_time, wad.remark,
|
||||
w.id, w.order_sn, w.cust_order_id, w.bill_code, w.bill_code_sub, w.order_status, w.waybill_status, w.order_type, w.order_date,
|
||||
w.user_id, w.customer_code, w.customer_name, w.open_id, w.receive_name, w.receive_company, w.receive_mobile, w.receive_tel,
|
||||
w.receive_country, w.receive_province, w.receive_city, w.receive_county, w.receive_town, w.receive_address, w.receive_postcode,
|
||||
w.send_name, w.send_company, w.send_mobile, w.send_tel, w.send_country, w.send_province, w.send_city,
|
||||
w.send_county, w.send_town, w.send_address, w.send_postcode, w.freight, w.salesmen, w.payee, w.payment_type, w.product_type,
|
||||
tp.prod_name, w.parcel_qty, w.bill_weight, w.total_volume, w.send_date, w.dispatch_date, w.sign_man, w.sign_man_code,
|
||||
w.sign_site_code, w.sign_date, w.timezone_offset, w.payment_status, w.payment_date, w.payment_remark, w.order_remark, w.data_from,
|
||||
w.bl_special_goods, w.ext_info, w.lading_bill_code, w.company_code, w.departure_port, w.destination_port, w.box_quantity, w.settlement_weight,
|
||||
w.send_site_code, send_site.site_name, w.dispatch_underling_site_code, dest_site.site_name,
|
||||
sb.id, sb.settle_bill_no, sb.settle_bill_name, sb.settle_type, sb.settle_start_date, sb.settle_end_date, sb.bill_month,
|
||||
sb.rec_money, sb.reced_money, sb.invoiced_money, sb.cust_no, sb.cust_name, sb.customer_code, sb.customer_name, sb.site_code,
|
||||
sb.site_name, sb.satisfy_money, sb.allowance_money, sb.deduction_money, sb.other_money, sb.satisfy_reason, sb.allowance_reason,
|
||||
sb.deduction_reason, sb.other_reason, sb.open_bill_status, sb.payment_status, sb.charge_status, sb.send_piece_sum,
|
||||
sb.piece_number, sb.fee_weight, sb.uncollected_amount, sb.send_money_sum, sb.refund_amount, sb.refund_money,
|
||||
sb.payee, sb.salesmen, sb.credit_period, sb.credit_period_type, sb.settle_day, sb.payment_due_date, sb.bl_send_oms,
|
||||
sb.bl_confirm_center, sb.confirm_center_date, sb.confirm_center_note, sb.confirm_center_man_code, sb.confirm_center_code,
|
||||
sb.bl_confirm_site, sb.confirm_site_date, sb.confirm_site_man_code, sb.confirm_site_note, sb.confirm_site_code,
|
||||
ssb.id, ssb.bill_no, ssb.parent_bill_no, ssb.settle_bill_no, ssb.bill_code, ssb.bill_date, ssb.bill_fee, ssb.currency,
|
||||
ssb.settle_type, ssb.bl_split, ssb.bl_merge, ssb.bill_month, ssb.cust_no, ssb.cust_name, ssb.customer_code, ssb.customer_name,
|
||||
ssb.invoiced_money, ssb.reced_money, ssb.satisfy_money, ssb.allowance_money, ssb.deduction_money, ssb.other_money,
|
||||
ssb.satisfy_reason, ssb.allowance_reason, ssb.deduction_reason, ssb.other_reason, ssb.open_bill_status, ssb.payment_status,
|
||||
ssb.charge_status, ssb.payee, ssb.salesmen, ssb.bl_special_quote, ssb.bl_sensitive, ssb.bl_confirm_center, ssb.confirm_center_date,
|
||||
ssb.confirm_center_note, ssb.confirm_center_man_code, ssb.confirm_center_code, ssb.bl_confirm_site, ssb.confirm_site_date,
|
||||
ssb.confirm_site_man_code, ssb.confirm_site_note, ssb.confirm_site_code
|
||||
order by wad.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectEmisWriteoffApplyDetailById" parameterType="Long" resultMap="EmisWriteoffApplyDetailResult">
|
||||
<include refid="selectEmisWriteoffApplyDetailVo"/>
|
||||
where wad.id = #{id} and wad.del_flag = '0'
|
||||
group by wad.id, wad.apply_id, wad.apply_no, wad.bill_code, wad.apply_money, wad.settle_bill_no, wad.del_flag,
|
||||
wad.create_by, wad.create_time, wad.update_by, wad.update_time, wad.remark,
|
||||
w.id, w.order_sn, w.cust_order_id, w.bill_code, w.bill_code_sub, w.order_status, w.waybill_status, w.order_type, w.order_date,
|
||||
w.user_id, w.customer_code, w.customer_name, w.open_id, w.receive_name, w.receive_company, w.receive_mobile, w.receive_tel,
|
||||
w.receive_country, w.receive_province, w.receive_city, w.receive_county, w.receive_town, w.receive_address, w.receive_postcode,
|
||||
w.send_name, w.send_company, w.send_mobile, w.send_tel, w.send_country, w.send_province, w.send_city,
|
||||
w.send_county, w.send_town, w.send_address, w.send_postcode, w.freight, w.salesmen, w.payee, w.payment_type, w.product_type,
|
||||
tp.prod_name, w.parcel_qty, w.bill_weight, w.total_volume, w.send_date, w.dispatch_date, w.sign_man, w.sign_man_code,
|
||||
w.sign_site_code, w.sign_date, w.timezone_offset, w.payment_status, w.payment_date, w.payment_remark, w.order_remark, w.data_from,
|
||||
w.bl_special_goods, w.ext_info, w.lading_bill_code, w.company_code, w.departure_port, w.destination_port, w.box_quantity, w.settlement_weight,
|
||||
w.send_site_code, send_site.site_name, w.dispatch_underling_site_code, dest_site.site_name,
|
||||
sb.id, sb.settle_bill_no, sb.settle_bill_name, sb.settle_type, sb.settle_start_date, sb.settle_end_date, sb.bill_month,
|
||||
sb.rec_money, sb.reced_money, sb.invoiced_money, sb.cust_no, sb.cust_name, sb.customer_code, sb.customer_name, sb.site_code,
|
||||
sb.site_name, sb.satisfy_money, sb.allowance_money, sb.deduction_money, sb.other_money, sb.satisfy_reason, sb.allowance_reason,
|
||||
sb.deduction_reason, sb.other_reason, sb.open_bill_status, sb.payment_status, sb.charge_status, sb.send_piece_sum,
|
||||
sb.piece_number, sb.fee_weight, sb.uncollected_amount, sb.send_money_sum, sb.refund_amount, sb.refund_money,
|
||||
sb.payee, sb.salesmen, sb.credit_period, sb.credit_period_type, sb.settle_day, sb.payment_due_date, sb.bl_send_oms,
|
||||
sb.bl_confirm_center, sb.confirm_center_date, sb.confirm_center_note, sb.confirm_center_man_code, sb.confirm_center_code,
|
||||
sb.bl_confirm_site, sb.confirm_site_date, sb.confirm_site_man_code, sb.confirm_site_note, sb.confirm_site_code,
|
||||
ssb.id, ssb.bill_no, ssb.parent_bill_no, ssb.settle_bill_no, ssb.bill_code, ssb.bill_date, ssb.bill_fee, ssb.currency,
|
||||
ssb.settle_type, ssb.bl_split, ssb.bl_merge, ssb.bill_month, ssb.cust_no, ssb.cust_name, ssb.customer_code, ssb.customer_name,
|
||||
ssb.invoiced_money, ssb.reced_money, ssb.satisfy_money, ssb.allowance_money, ssb.deduction_money, ssb.other_money,
|
||||
ssb.satisfy_reason, ssb.allowance_reason, ssb.deduction_reason, ssb.other_reason, ssb.open_bill_status, ssb.payment_status,
|
||||
ssb.charge_status, ssb.payee, ssb.salesmen, ssb.bl_special_quote, ssb.bl_sensitive, ssb.bl_confirm_center, ssb.confirm_center_date,
|
||||
ssb.confirm_center_note, ssb.confirm_center_man_code, ssb.confirm_center_code, ssb.bl_confirm_site, ssb.confirm_site_date,
|
||||
ssb.confirm_site_man_code, ssb.confirm_site_note, ssb.confirm_site_code
|
||||
</select>
|
||||
|
||||
<select id="selectEmisWriteoffApplyDetailListByApplyId" parameterType="Long" resultMap="EmisWriteoffApplyDetailResult">
|
||||
<include refid="selectEmisWriteoffApplyDetailVo"/>
|
||||
where wad.apply_id = #{applyId} and wad.del_flag = '0'
|
||||
group by wad.id, wad.apply_id, wad.apply_no, wad.bill_code, wad.apply_money, wad.settle_bill_no, wad.del_flag,
|
||||
wad.create_by, wad.create_time, wad.update_by, wad.update_time, wad.remark,
|
||||
w.id, w.order_sn, w.cust_order_id, w.bill_code, w.bill_code_sub, w.order_status, w.waybill_status, w.order_type, w.order_date,
|
||||
w.user_id, w.customer_code, w.customer_name, w.open_id, w.receive_name, w.receive_company, w.receive_mobile, w.receive_tel,
|
||||
w.receive_country, w.receive_province, w.receive_city, w.receive_county, w.receive_town, w.receive_address, w.receive_postcode,
|
||||
w.send_name, w.send_company, w.send_mobile, w.send_tel, w.send_country, w.send_province, w.send_city,
|
||||
w.send_county, w.send_town, w.send_address, w.send_postcode, w.freight, w.salesmen, w.payee, w.payment_type, w.product_type,
|
||||
tp.prod_name, w.parcel_qty, w.bill_weight, w.total_volume, w.send_date, w.dispatch_date, w.sign_man, w.sign_man_code,
|
||||
w.sign_site_code, w.sign_date, w.timezone_offset, w.payment_status, w.payment_date, w.payment_remark, w.order_remark, w.data_from,
|
||||
w.bl_special_goods, w.ext_info, w.lading_bill_code, w.company_code, w.departure_port, w.destination_port, w.box_quantity, w.settlement_weight,
|
||||
w.send_site_code, send_site.site_name, w.dispatch_underling_site_code, dest_site.site_name,
|
||||
sb.id, sb.settle_bill_no, sb.settle_bill_name, sb.settle_type, sb.settle_start_date, sb.settle_end_date, sb.bill_month,
|
||||
sb.rec_money, sb.reced_money, sb.invoiced_money, sb.cust_no, sb.cust_name, sb.customer_code, sb.customer_name, sb.site_code,
|
||||
sb.site_name, sb.satisfy_money, sb.allowance_money, sb.deduction_money, sb.other_money, sb.satisfy_reason, sb.allowance_reason,
|
||||
sb.deduction_reason, sb.other_reason, sb.open_bill_status, sb.payment_status, sb.charge_status, sb.send_piece_sum,
|
||||
sb.piece_number, sb.fee_weight, sb.uncollected_amount, sb.send_money_sum, sb.refund_amount, sb.refund_money,
|
||||
sb.payee, sb.salesmen, sb.credit_period, sb.credit_period_type, sb.settle_day, sb.payment_due_date, sb.bl_send_oms,
|
||||
sb.bl_confirm_center, sb.confirm_center_date, sb.confirm_center_note, sb.confirm_center_man_code, sb.confirm_center_code,
|
||||
sb.bl_confirm_site, sb.confirm_site_date, sb.confirm_site_man_code, sb.confirm_site_note, sb.confirm_site_code,
|
||||
ssb.id, ssb.bill_no, ssb.parent_bill_no, ssb.settle_bill_no, ssb.bill_code, ssb.bill_date, ssb.bill_fee, ssb.currency,
|
||||
ssb.settle_type, ssb.bl_split, ssb.bl_merge, ssb.bill_month, ssb.cust_no, ssb.cust_name, ssb.customer_code, ssb.customer_name,
|
||||
ssb.invoiced_money, ssb.reced_money, ssb.satisfy_money, ssb.allowance_money, ssb.deduction_money, ssb.other_money,
|
||||
ssb.satisfy_reason, ssb.allowance_reason, ssb.deduction_reason, ssb.other_reason, ssb.open_bill_status, ssb.payment_status,
|
||||
ssb.charge_status, ssb.payee, ssb.salesmen, ssb.bl_special_quote, ssb.bl_sensitive, ssb.bl_confirm_center, ssb.confirm_center_date,
|
||||
ssb.confirm_center_note, ssb.confirm_center_man_code, ssb.confirm_center_code, ssb.bl_confirm_site, ssb.confirm_site_date,
|
||||
ssb.confirm_site_man_code, ssb.confirm_site_note, ssb.confirm_site_code
|
||||
order by wad.create_time desc
|
||||
</select>
|
||||
|
||||
@ -348,6 +441,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectEmisWriteoffApplyDetailListByApplyIdWithDetails" parameterType="Long" resultMap="EmisWriteoffApplyDetailResult">
|
||||
<include refid="selectEmisWriteoffApplyDetailVo"/>
|
||||
where wad.apply_id = #{applyId} and wad.del_flag = '0'
|
||||
group by wad.id, wad.apply_id, wad.apply_no, wad.bill_code, wad.apply_money, wad.settle_bill_no, wad.del_flag,
|
||||
wad.create_by, wad.create_time, wad.update_by, wad.update_time, wad.remark,
|
||||
w.id, w.order_sn, w.cust_order_id, w.bill_code, w.bill_code_sub, w.order_status, w.waybill_status, w.order_type, w.order_date,
|
||||
w.user_id, w.customer_code, w.customer_name, w.open_id, w.receive_name, w.receive_company, w.receive_mobile, w.receive_tel,
|
||||
w.receive_country, w.receive_province, w.receive_city, w.receive_county, w.receive_town, w.receive_address, w.receive_postcode,
|
||||
w.send_name, w.send_company, w.send_mobile, w.send_tel, w.send_country, w.send_province, w.send_city,
|
||||
w.send_county, w.send_town, w.send_address, w.send_postcode, w.freight, w.salesmen, w.payee, w.payment_type, w.product_type,
|
||||
tp.prod_name, w.parcel_qty, w.bill_weight, w.total_volume, w.send_date, w.dispatch_date, w.sign_man, w.sign_man_code,
|
||||
w.sign_site_code, w.sign_date, w.timezone_offset, w.payment_status, w.payment_date, w.payment_remark, w.order_remark, w.data_from,
|
||||
w.bl_special_goods, w.ext_info, w.lading_bill_code, w.company_code, w.departure_port, w.destination_port, w.box_quantity, w.settlement_weight,
|
||||
w.send_site_code, send_site.site_name, w.dispatch_underling_site_code, dest_site.site_name,
|
||||
sb.id, sb.settle_bill_no, sb.settle_bill_name, sb.settle_type, sb.settle_start_date, sb.settle_end_date, sb.bill_month,
|
||||
sb.rec_money, sb.reced_money, sb.invoiced_money, sb.cust_no, sb.cust_name, sb.customer_code, sb.customer_name, sb.site_code,
|
||||
sb.site_name, sb.satisfy_money, sb.allowance_money, sb.deduction_money, sb.other_money, sb.satisfy_reason, sb.allowance_reason,
|
||||
sb.deduction_reason, sb.other_reason, sb.open_bill_status, sb.payment_status, sb.charge_status, sb.send_piece_sum,
|
||||
sb.piece_number, sb.fee_weight, sb.uncollected_amount, sb.send_money_sum, sb.refund_amount, sb.refund_money,
|
||||
sb.payee, sb.salesmen, sb.credit_period, sb.credit_period_type, sb.settle_day, sb.payment_due_date, sb.bl_send_oms,
|
||||
sb.bl_confirm_center, sb.confirm_center_date, sb.confirm_center_note, sb.confirm_center_man_code, sb.confirm_center_code,
|
||||
sb.bl_confirm_site, sb.confirm_site_date, sb.confirm_site_man_code, sb.confirm_site_note, sb.confirm_site_code,
|
||||
ssb.id, ssb.bill_no, ssb.parent_bill_no, ssb.settle_bill_no, ssb.bill_code, ssb.bill_date, ssb.bill_fee, ssb.currency,
|
||||
ssb.settle_type, ssb.bl_split, ssb.bl_merge, ssb.bill_month, ssb.cust_no, ssb.cust_name, ssb.customer_code, ssb.customer_name,
|
||||
ssb.invoiced_money, ssb.reced_money, ssb.satisfy_money, ssb.allowance_money, ssb.deduction_money, ssb.other_money,
|
||||
ssb.satisfy_reason, ssb.allowance_reason, ssb.deduction_reason, ssb.other_reason, ssb.open_bill_status, ssb.payment_status,
|
||||
ssb.charge_status, ssb.payee, ssb.salesmen, ssb.bl_special_quote, ssb.bl_sensitive, ssb.bl_confirm_center, ssb.confirm_center_date,
|
||||
ssb.confirm_center_note, ssb.confirm_center_man_code, ssb.confirm_center_code, ssb.bl_confirm_site, ssb.confirm_site_date,
|
||||
ssb.confirm_site_man_code, ssb.confirm_site_note, ssb.confirm_site_code
|
||||
order by wad.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="applyDate" column="apply_date" />
|
||||
<result property="writeoffAmount" column="writeoff_amount" />
|
||||
<result property="payType" column="pay_type" />
|
||||
<result property="invoiceNo" column="invoice_no" />
|
||||
<result property="tradeDate" column="trade_date" />
|
||||
<result property="recipient" column="recipient" />
|
||||
<result property="applyMemo" column="apply_memo" />
|
||||
@ -45,67 +46,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEmisWriteoffApplyVo">
|
||||
select id,
|
||||
apply_no,
|
||||
apply_man_code,
|
||||
apply_man_name,
|
||||
apply_site_code,
|
||||
apply_site_name,
|
||||
apply_date,
|
||||
writeoff_amount,
|
||||
pay_type,
|
||||
trade_date,
|
||||
recipient,
|
||||
apply_memo,
|
||||
pay_id,
|
||||
bl_center_confirmed,
|
||||
center_confirm_man_code,
|
||||
center_confirm_man_name,
|
||||
center_confirm_date,
|
||||
center_confirm_note,
|
||||
center_reject_reason,
|
||||
bl_headquarters_confirmed,
|
||||
headquarters_confirm_man_code,
|
||||
headquarters_confirm_man_name,
|
||||
headquarters_confirm_date,
|
||||
headquarters_confirm_note,
|
||||
headquarters_reject_reason,
|
||||
revoke_date,
|
||||
revoke_man_code,
|
||||
revoke_man_name,
|
||||
revoke_reason,
|
||||
del_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
remark
|
||||
from emis_writeoff_apply
|
||||
select id, apply_no, apply_man_code, apply_man_name, apply_site_code, apply_site_name, apply_date, writeoff_amount, pay_type, trade_date, recipient, apply_memo, pay_id, bl_center_confirmed, center_confirm_man_code, center_confirm_man_name, center_confirm_date, center_confirm_note, center_reject_reason, bl_headquarters_confirmed, headquarters_confirm_man_code, headquarters_confirm_man_name, headquarters_confirm_date, headquarters_confirm_note, headquarters_reject_reason, revoke_date, revoke_man_code, revoke_man_name, revoke_reason, del_flag, create_by, create_time, update_by, update_time, remark from emis_writeoff_apply
|
||||
</sql>
|
||||
|
||||
<select id="selectEmisWriteoffApplyList" parameterType="EmisWriteoffApply" resultMap="EmisWriteoffApplyResult">
|
||||
select distinct wa.id,
|
||||
wa.apply_no,
|
||||
wa.apply_man_code,
|
||||
wa.apply_man_name,
|
||||
wa.apply_site_code,
|
||||
wa.apply_site_name,
|
||||
wa.apply_date,
|
||||
wa.writeoff_amount,
|
||||
wa.pay_type,
|
||||
wa.trade_date,
|
||||
wa.recipient,
|
||||
wa.apply_memo,
|
||||
wa.pay_id,
|
||||
select wa.id, wa.apply_no, wa.apply_man_code, wa.apply_man_name, wa.apply_site_code, wa.apply_site_name,
|
||||
wa.apply_date, wa.writeoff_amount, wa.pay_type, wa.trade_date, wa.recipient, wa.apply_memo, wa.pay_id,
|
||||
wa.bl_center_confirmed, wa.center_confirm_man_code, wa.center_confirm_man_name, wa.center_confirm_date,
|
||||
wa.center_confirm_note, wa.center_reject_reason, wa.bl_headquarters_confirmed, wa.headquarters_confirm_man_code,
|
||||
wa.headquarters_confirm_man_name, wa.headquarters_confirm_date, wa.headquarters_confirm_note,
|
||||
wa.headquarters_reject_reason, wa.revoke_date, wa.revoke_man_code, wa.revoke_man_name, wa.revoke_reason,
|
||||
wa.del_flag, wa.create_by, wa.create_time, wa.update_by, wa.update_time, wa.remark
|
||||
wa.del_flag, wa.create_by, wa.create_time, wa.update_by, wa.update_time, wa.remark,
|
||||
GROUP_CONCAT(DISTINCT ch.invoice_no ORDER BY ch.invoice_no SEPARATOR ',') as invoice_no
|
||||
from emis_writeoff_apply wa
|
||||
<if test="(params != null and params.queryParams != null and params.queryParams != '') or (settleBillName != null and settleBillName != '') or (invoiceNo != null and invoiceNo != '')">
|
||||
left join emis_writeoff_apply_detail wad on wa.id = wad.apply_id and wad.del_flag = '0'
|
||||
</if>
|
||||
left join emis_settle_sub_bill ssb on wad.bill_code = ssb.bill_code and ssb.del_flag = '0'
|
||||
left join emis_settle_invoice_bill_rel sibr on ssb.settle_bill_no = sibr.settle_bill_no and sibr.del_flag = '0'
|
||||
left join emis_settle_invoice_record sir on sibr.apply_seq_no = sir.apply_seq_no and sir.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 sir.apply_seq_no = ch.apply_seq_no
|
||||
<if test="settleBillName != null and settleBillName != ''">
|
||||
left join emis_settle_bill sb on wad.settle_bill_no = sb.settle_bill_no and sb.del_flag = '0'
|
||||
</if>
|
||||
@ -120,28 +88,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="applyDateStart != null "> and wa.apply_date >= #{applyDateStart}</if>
|
||||
<if test="applyDateEnd != null "> and wa.apply_date <= #{applyDateEnd}</if>
|
||||
<if test="writeoffAmount != null "> and wa.writeoff_amount = #{writeoffAmount}</if>
|
||||
<if test="payType != null and payType != ''"> and wa.pay_type = #{payType}</if>
|
||||
<if test="invoiceNo != null and invoiceNo != ''">
|
||||
and exists (
|
||||
select 1
|
||||
from emis_settle_invoice_record a
|
||||
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
|
||||
inner join emis_settle_invoice_rel rel on rel.apply_seq_no = a.apply_seq_no and rel.del_flag = '0'
|
||||
where a.del_flag = '0'
|
||||
and FIND_IN_SET(ch.invoice_no, REPLACE(#{invoiceNo}, '\n', ','))
|
||||
and rel.bill_no = wad.bill_code
|
||||
)
|
||||
</if>
|
||||
<if test="applyMemo != null and applyMemo != ''"> and wa.apply_memo like concat('%', #{applyMemo}, '%')</if>
|
||||
<if test="blCenterConfirmed != null and blCenterConfirmed != ''"> and wa.bl_center_confirmed = #{blCenterConfirmed}</if>
|
||||
<if test="centerConfirmManCode != null and centerConfirmManCode != ''"> and wa.center_confirm_man_code = #{centerConfirmManCode}</if>
|
||||
@ -160,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="revokeManName != null and revokeManName != ''"> and wa.revoke_man_name like concat('%', #{revokeManName}, '%')</if>
|
||||
<if test="revokeReason != null and revokeReason != ''"> and wa.revoke_reason like concat('%', #{revokeReason}, '%')</if>
|
||||
<if test="settleBillName != null and settleBillName != ''"> and sb.settle_bill_name like concat('%', #{settleBillName}, '%')</if>
|
||||
<if test="payType != null and payType != ''"> and wa.pay_type = #{payType}</if>
|
||||
<if test="params != null and params.queryParams != null and params.queryParams != ''">
|
||||
and (
|
||||
wad.bill_code in
|
||||
@ -170,6 +117,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach collection="params.queryParams.split('\n')" item="param" open="(" separator="," close=")">
|
||||
#{param}
|
||||
</foreach>
|
||||
or ch.invoice_no in
|
||||
<foreach collection="params.queryParams.split('\n')" item="param" open="(" separator="," close=")">
|
||||
#{param}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
|
||||
@ -197,6 +148,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
group by wa.id, wa.apply_no, wa.apply_man_code, wa.apply_man_name, wa.apply_site_code, wa.apply_site_name,
|
||||
wa.apply_date, wa.writeoff_amount, wa.pay_type, wa.trade_date, wa.recipient, wa.apply_memo, wa.pay_id,
|
||||
wa.bl_center_confirmed, wa.center_confirm_man_code, wa.center_confirm_man_name, wa.center_confirm_date,
|
||||
wa.center_confirm_note, wa.center_reject_reason, wa.bl_headquarters_confirmed, wa.headquarters_confirm_man_code,
|
||||
wa.headquarters_confirm_man_name, wa.headquarters_confirm_date, wa.headquarters_confirm_note,
|
||||
wa.headquarters_reject_reason, wa.revoke_date, wa.revoke_man_code, wa.revoke_man_name, wa.revoke_reason,
|
||||
wa.del_flag, wa.create_by, wa.create_time, wa.update_by, wa.update_time, wa.remark
|
||||
order by wa.create_time desc
|
||||
</select>
|
||||
|
||||
@ -291,7 +249,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="applySiteName != null and applySiteName != ''">apply_site_name = #{applySiteName},</if>
|
||||
<if test="applyDate != null">apply_date = #{applyDate},</if>
|
||||
<if test="writeoffAmount != null">writeoff_amount = #{writeoffAmount},</if>
|
||||
<if test="payType != null and payType != ''">pay_type = #{payType},</if>
|
||||
<if test="applyMemo != null and applyMemo != ''">apply_memo = #{applyMemo},</if>
|
||||
<if test="payId != null and payId != ''">pay_id = #{payId},</if>
|
||||
<if test="blCenterConfirmed != null and blCenterConfirmed != ''">bl_center_confirmed = #{blCenterConfirmed},</if>
|
||||
@ -450,6 +407,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="applyMoney" column="apply_money"/>
|
||||
<result property="settleBillNo" column="settle_bill_no"/>
|
||||
<result property="expressType" column="express_type"/>
|
||||
<result property="invoiceNo" column="invoice_no"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
@ -592,11 +550,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<!-- 根据运单号查询运单、结算账单、结算子账单信息 -->
|
||||
<select id="selectEmisWriteoffApplyDetailListByBillCodes" parameterType="java.util.List" resultMap="EmisWriteoffApplyDetailWithDetailsResult">
|
||||
select distinct
|
||||
select
|
||||
-- EmisWriteoffApplyDetail 基本信息
|
||||
w.bill_code as bill_code,
|
||||
0.00 as apply_money,
|
||||
ssb.settle_bill_no as settle_bill_no,
|
||||
GROUP_CONCAT(DISTINCT ch.invoice_no ORDER BY ch.invoice_no SEPARATOR ',') as invoice_no,
|
||||
|
||||
-- 运单信息
|
||||
w.id as w_id, w.order_sn as w_order_sn, w.cust_order_id as w_cust_order_id, w.bill_code as w_bill_code,
|
||||
@ -652,6 +611,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join emis_site send_site on w.send_site_code = send_site.site_code and send_site.del_flag = '0'
|
||||
left join emis_site dest_site on w.dispatch_underling_site_code = dest_site.site_code and dest_site.del_flag = '0'
|
||||
left join emis_trans_product tp on w.product_type = tp.prod_code and tp.del_flag = '0'
|
||||
left join emis_settle_invoice_bill_rel sibr on ssb.settle_bill_no = sibr.settle_bill_no and sibr.del_flag = '0'
|
||||
left join emis_settle_invoice_record sir on sibr.apply_seq_no = sir.apply_seq_no and sir.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 sir.apply_seq_no = ch.apply_seq_no
|
||||
where
|
||||
w.del_flag = '0'
|
||||
and w.bill_code in
|
||||
@ -660,6 +632,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
and w.order_status != '0'
|
||||
and w.order_status != '2'
|
||||
group by w.id, w.bill_code, ssb.id, ssb.settle_bill_no, sb.id
|
||||
order by w.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user