This commit is contained in:
linfso 2025-05-29 17:22:32 +08:00
commit eb78a46cd0
9 changed files with 291 additions and 40 deletions

View File

@ -164,6 +164,25 @@ public class EmisQuotePriceController extends EmisBaseController
}
}
/**
* 批量修改费用报价
*/
@PreAuthorize("@ss.hasPermi('emis:emisQuotePrice:edit')")
@Log(title = "费用报价", businessType = BusinessType.UPDATE)
@PutMapping("/batch")
public AjaxResult batchEdit(@RequestBody List<EmisQuotePrice> emisQuotePriceList) {
try {
return toAjax(emisQuotePriceService.batchUpdateEmisQuotePrice(emisQuotePriceList));
} catch (Exception ex) {
ex.printStackTrace();
// 返回自定义异常
if (ex instanceof EmisBizError) {
return AjaxResult.error(ex.getMessage(), ((EmisBizError) ex).getErrorCode());
}
return AjaxResult.error("服务器异常,联系客服");
}
}
/**
* 删除费用报价
*/

View File

@ -106,4 +106,13 @@ public interface EmisSettleInvoiceChRecordMapper extends BaseMapper<EmisSettleIn
* @return 结果
*/
public int deleteEmisSettleInvoiceChRecordByIds(Long[] ids);
/**
* 根据applySeqNo列表查询额外字段信息
*
* @param applySeqNoList 申请序号列表
* @return 额外字段信息列表
*/
public List<EmisSettleInvoiceChRecord> selectExtraFieldsByApplySeqNos(
@Param("applySeqNoList") List<String> applySeqNoList);
}

View File

@ -4062,6 +4062,9 @@ public class EmisBaseService {
* @throws EmisBizError
*/
protected void checkFirstSigningDay(EmisWaybill emisWaybillOld, EmisWaybill emisWaybillNew) throws EmisBizError {
if ("1".equals(emisWaybillNew.getPaymentType())) {
return;
}
if (emisWaybillOld == null || emisWaybillOld.getOrderDate() == null || emisWaybillNew == null || StringUtil.isBlank(emisWaybillNew.getCustNo())) {
return;
}

View File

@ -70,4 +70,12 @@ public interface IEmisQuotePriceService
* @return 结果
*/
public int deleteEmisQuotePriceByQuoteId(Long quoteId);
/**
* 批量修改费用报价
*
* @param emisQuotePriceList 费用报价列表
* @return 结果
*/
public int batchUpdateEmisQuotePrice(List<EmisQuotePrice> emisQuotePriceList) throws EmisBizError;
}

View File

@ -152,4 +152,42 @@ public class EmisQuotePriceServiceImpl implements IEmisQuotePriceService
return emisQuotePriceMapper.deleteEmisQuotePriceByQuoteId(quoteId);
}
/**
* 批量修改费用报价
*
* @param emisQuotePriceList 费用报价列表
* @return 结果
*/
@Override
@Transactional
public int batchUpdateEmisQuotePrice(List<EmisQuotePrice> emisQuotePriceList) throws EmisBizError {
if (CollectionUtil.isEmpty(emisQuotePriceList)) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "费用报价列表不能为空");
}
int successCount = 0;
for (EmisQuotePrice emisQuotePrice : emisQuotePriceList) {
try {
// 检查是否重复
List<EmisQuotePrice> listOld = emisQuotePriceMapper.checkUnique(emisQuotePrice);
if (!CollectionUtil.isEmpty(listOld)) {
String estNameStr = "";
for (EmisQuotePrice item : listOld) {
estNameStr = estNameStr + item.getQuoteName() + ",";
}
throw new EmisBizError(EmisBizErrorType.EXISTS, "报价重复[" + estNameStr + "]");
}
// 更新主表
int ret = emisQuotePriceMapper.updateEmisQuotePrice(emisQuotePrice);
if (ret > 0) {
successCount++;
}
} catch (Exception e) {
throw new EmisBizError(EmisBizErrorType.SYS_EXCEPTION, "批量修改费用报价失败:" + e.getMessage());
}
}
return successCount;
}
}

View File

@ -11,12 +11,10 @@
package com.xdadan.erp.emis.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -37,6 +35,7 @@ import com.xdadan.erp.emis.service.openbill.hx.HXOrderGoods;
import com.xdadan.erp.emis.service.openbill.hx.HXOrderInfo;
import com.xdadan.erp.emis.service.openbill.hx.HXSdk;
import com.xdadan.erp.emis.utils.WaybillHelper;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -140,7 +139,7 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem
Future<List<EmisSettleInvoiceChRecordExportVO>> future = executor.submit(() -> {
PageHelper.startPage(currentPage, pageSize);
List<EmisSettleInvoiceChRecord> list = this.selectEmisSettleInvoiceChRecordListAll(
emisSettleInvoiceChRecord);
emisSettleInvoiceChRecord).stream().filter(i->!"3".equals(i.getOpenChStatus())).collect(Collectors.toList());
if (list == null || list.isEmpty()) {
return new ArrayList<>();
@ -170,7 +169,7 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem
// 付款日期
vo.setPayDate(InvoiceExportHelper.processPayDate(record.getExportPayDays()));
// 业务员
vo.setSalesmen(record.getSalesmen());
vo.setSalesmen(record.getApplyManName());
// 快递公司
vo.setExpressCompany(record.getSalesmen());
// 面单单号
@ -216,14 +215,49 @@ public class EmisSettleInvoiceChRecordServiceImpl extends EmisBaseService implem
}
@Override
public List<EmisSettleInvoiceChRecord> selectEmisSettleInvoiceChRecordListAll(EmisSettleInvoiceChRecord emisSettleInvoiceChRecord) {
public List<EmisSettleInvoiceChRecord> selectEmisSettleInvoiceChRecordListAll(
EmisSettleInvoiceChRecord emisSettleInvoiceChRecord) {
long startTime = System.currentTimeMillis();
List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper.selectEmisSettleInvoiceChRecordListAll(emisSettleInvoiceChRecord);
if (StringUtil.isNotBlank(emisSettleInvoiceChRecord.getInvoiceNo())) {
List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper
.selectEmisSettleInvoiceChRecordList(emisSettleInvoiceChRecord);
setEmisSettleInvoiceChRecords(emisSettleInvoiceChRecords);
return emisSettleInvoiceChRecords;
}
List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords = emisSettleInvoiceChRecordMapper
.selectEmisSettleInvoiceChRecordListAll(emisSettleInvoiceChRecord);
long endTime = System.currentTimeMillis();
log.info("查询渠道开票记录列表完成, 耗时: {}ms", (endTime - startTime));
return emisSettleInvoiceChRecords;
}
private void setEmisSettleInvoiceChRecords(List<EmisSettleInvoiceChRecord> emisSettleInvoiceChRecords) {
List<String> applySeqNoList = emisSettleInvoiceChRecords.stream()
.map(EmisSettleInvoiceChRecord::getApplySeqNo)
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(applySeqNoList)) {
List<EmisSettleInvoiceChRecord> extraInfoList = emisSettleInvoiceChRecordMapper
.selectExtraFieldsByApplySeqNos(applySeqNoList);
Map<String, EmisSettleInvoiceChRecord> extraInfoMap = extraInfoList.stream()
.collect(Collectors.toMap(
EmisSettleInvoiceChRecord::getApplySeqNo,
record -> record,
(existing, replacement) -> existing));
emisSettleInvoiceChRecords.forEach(record -> {
EmisSettleInvoiceChRecord extraInfo = extraInfoMap.get(record.getApplySeqNo());
if (extraInfo != null) {
record.setSendMonth(extraInfo.getSendMonth());
record.setSettleType(extraInfo.getSettleType());
record.setOpenBillRemark(extraInfo.getOpenBillRemark());
record.setPayDays(extraInfo.getPayDays());
}
});
}
}
@Override
public int checkHasSendToHx(String applySeqNo)

View File

@ -11,6 +11,9 @@
package com.xdadan.erp.emis.service.impl;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
@ -23,6 +26,7 @@ import com.xdadan.erp.emis.service.EmisBaseService;
import com.xdadan.erp.emis.service.IEmisSettleBillService;
import com.xdadan.erp.emis.service.IEmisSettleSubBillService;
import com.xdadan.erp.emis.utils.WaybillHelper;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
@ -132,23 +136,11 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
@Override
public int insertEmisSettlePayRecord(EmisSettlePayRecord emisSettlePayRecord,String payId) throws EmisBizError {
if(StringUtils.isEmpty(emisSettlePayRecord.getSettleBillNo())){
throw new EmisBizError(EmisBizErrorType.FAIL,"账单编号不能为空");
}
// 非空校验
checkParam(emisSettlePayRecord);
// || BigDecimal.ZERO.compareTo(emisSettlePayRecord.getPayMoney()) == 0
if("1".equals(emisSettlePayRecord.getRecType())) {
if (emisSettlePayRecord.getPayMoney() == null ) {
throw new EmisBizError(EmisBizErrorType.FAIL, "收款金额不能为空");
}
}
// || BigDecimal.ZERO.compareTo(emisSettlePayRecord.getRefundMoney()) == 0
else if("2".equals(emisSettlePayRecord.getRecType())) {
if (emisSettlePayRecord.getRefundMoney()== null ) {
throw new EmisBizError(EmisBizErrorType.FAIL, "退款金额不能为空");
}
}
// 校验交易日期不能晚于当天
checkDate(emisSettlePayRecord);
emisSettlePayRecord.setSettleBillNo(WaybillHelper.formatQueryValue(emisSettlePayRecord.getSettleBillNo()));
// 多账单合并收款
@ -232,6 +224,65 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
return 1;
}
private static void checkParam(EmisSettlePayRecord emisSettlePayRecord) throws EmisBizError {
if(StringUtils.isEmpty(emisSettlePayRecord.getSettleBillNo())){
throw new EmisBizError(EmisBizErrorType.FAIL,"账单编号不能为空");
}
if("1".equals(emisSettlePayRecord.getRecType())) {
if (emisSettlePayRecord.getPayMoney() == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "收款金额不能为空");
}
if (StringUtil.isBlank(emisSettlePayRecord.getPayType())) {
throw new EmisBizError(EmisBizErrorType.FAIL, "支付方式不能为空");
}
if (StringUtil.isBlank(emisSettlePayRecord.getPayMan())) {
throw new EmisBizError(EmisBizErrorType.FAIL, "收款人不能为空");
}
if (emisSettlePayRecord.getTradeDate() == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "交易日期不能为空");
}
} else if("2".equals(emisSettlePayRecord.getRecType())) {
if (emisSettlePayRecord.getRefundMoney() == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "退款金额不能为空");
}
if (StringUtil.isBlank(emisSettlePayRecord.getPayMan())) {
throw new EmisBizError(EmisBizErrorType.FAIL, "退款人不能为空");
}
if (StringUtil.isBlank(emisSettlePayRecord.getRefundMode())) {
throw new EmisBizError(EmisBizErrorType.FAIL, "退款方式不能为空");
}
if (StringUtil.isBlank(emisSettlePayRecord.getRefundReason())) {
throw new EmisBizError(EmisBizErrorType.FAIL, "退款原因不能为空");
}
if (emisSettlePayRecord.getRefundDate() == null) {
throw new EmisBizError(EmisBizErrorType.FAIL, "退款日期不能为空");
}
}
}
private static void checkDate(EmisSettlePayRecord emisSettlePayRecord) throws EmisBizError {
LocalDate today = LocalDate.now();
if (emisSettlePayRecord.getTradeDate() != null) {
LocalDate tradeDate = emisSettlePayRecord.getTradeDate().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
if (tradeDate.isAfter(today)) {
throw new EmisBizError(EmisBizErrorType.FAIL,
"交易时间不能晚于当天(" + today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ")");
}
}
if (emisSettlePayRecord.getRefundDate() != null) {
LocalDate refundDate = emisSettlePayRecord.getRefundDate().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
if (refundDate.isAfter(today)) {
throw new EmisBizError(EmisBizErrorType.FAIL,
"退款时间不能晚于当天(" + today.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ")");
}
}
}
/**
* 收款退款
* @param id

View File

@ -1451,6 +1451,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
// 检查是否已锁单
checkDBBillIsLock(emisWaybillOld);
// 校验寄件国家是否匹配线路
checkCountry(emisWaybillSave);
emisWaybillSave.setId(emisWaybillOld.getId());
// 把历史发货日期带过来用于重新计算预估到到时间
@ -3023,6 +3026,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
throw new EmisBizError(EmisBizErrorType.FAIL, "单号与子单号相同,请换单号");
}
// 校验寄件国家是否匹配线路
checkCountry(emisWaybillSave);
// 子单号做扣减
if ("1".equals(emisWaybillSave.getBlGenSubbill())) {
Integer subBillCount = emisElectronicSitePagService.getTotalAvailablePagCount(emisWaybillSave.getSendSiteCode(), "T7080", "1002");
@ -3208,6 +3214,19 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
}
private void checkCountry(EmisWaybill emisWaybillSave) throws EmisBizError {
EmisTransLine emisTransLine = new EmisTransLine();
emisTransLine.setLineCode(emisWaybillSave.getTransLineType());
List<EmisTransLine> emisTransLines = emisTransLineMapper.selectEmisTransLineList(emisTransLine);
if(CollectionUtil.isEmpty(emisTransLines)){
return;
}
if(emisWaybillSave.getSendCountry().equals(emisTransLines.get(0).getFromCountry())){
return;
}
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR, "寄件国家与所选线路不匹配" );
}
public int bindSalesmen(String empCode,String customerCode) throws EmisBizError {

View File

@ -171,12 +171,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="params.billCode != null and params.billCode != ''">
and EXISTS(
select 1 from emis_settle_bill x2,emis_settle_invoice_bill_rel x3,emis_settle_sub_bill x4
where x2.del_flag = '0' and x3.del_flag = '0' and x4.del_flag='0'
and a.apply_seq_no=x3.apply_seq_no
and x2.settle_bill_no=x3.settle_bill_no
and x4.settle_bill_no=x2.settle_bill_no
and FIND_IN_SET(x4.`bill_code`,#{params.billCode})
select 1 from
emis_settle_invoice_rel rel
where a.apply_seq_no=rel.apply_seq_no and
rel.del_flag = '0'
and FIND_IN_SET(rel.`bill_no`,#{params.billCode})
)
<!--
AND apply_seq_no IN (
@ -417,16 +416,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="params.billCode != null and params.billCode != ''">
AND EXISTS (
SELECT 1
FROM emis_settle_bill x2
INNER JOIN emis_settle_invoice_bill_rel x3 ON x2.settle_bill_no = x3.settle_bill_no
INNER JOIN emis_settle_sub_bill x4 ON x2.settle_bill_no = x4.settle_bill_no
WHERE x2.del_flag = '0'
AND x3.del_flag = '0'
AND x4.del_flag = '0'
AND a.apply_seq_no = x3.apply_seq_no
AND FIND_IN_SET(x4.bill_code, #{params.billCode})
and EXISTS(
select 1 from
emis_settle_invoice_rel rel
where a.apply_seq_no=rel.apply_seq_no and
rel.del_flag = '0'
and FIND_IN_SET(rel.`bill_no`,#{params.billCode})
)
</if>
@ -705,4 +700,79 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="selectExtraFieldsByApplySeqNos" resultMap="EmisSettleInvoiceChRecordResult">
SELECT
a.id,
a.apply_seq_no,
(
SELECT GROUP_CONCAT(DISTINCT CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m')))
FROM emis_settle_invoice_ch_record bd
LEFT JOIN emis_settle_invoice_rel ir ON ir.apply_seq_no = bd.apply_seq_no AND ir.del_flag = '0'
LEFT JOIN emis_waybill w ON w.bill_code = ir.bill_no AND w.del_flag = '0'
WHERE bd.apply_seq_no = a.apply_seq_no AND bd.del_flag = '0'
) as send_month,
(
SELECT b.settle_type
FROM emis_settle_invoice_ch_record bd
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
LEFT JOIN emis_settle_bill b ON b.settle_bill_no = ibr.settle_bill_no AND b.del_flag = '0'
WHERE bd.apply_seq_no = a.apply_seq_no AND bd.del_flag = '0'
LIMIT 1
) as settle_type,
(
SELECT
CASE
WHEN b.settle_type = '2' THEN
GROUP_CONCAT(DISTINCT
CONCAT(
CONCAT(SUBSTRING(DATE_FORMAT(w.send_date, '%Y'), 3, 2), DATE_FORMAT(w.send_date, '%m ')),
b.cust_name
) SEPARATOR '-'
)
ELSE
GROUP_CONCAT(DISTINCT
CONCAT(
DATE_FORMAT(w.send_date, '%m%d '),
w.send_company
) SEPARATOR '-'
)
END
FROM emis_settle_invoice_ch_record bd
LEFT JOIN emis_settle_invoice_rel ir ON ir.apply_seq_no = bd.apply_seq_no AND ir.del_flag = '0'
LEFT JOIN emis_waybill w ON w.bill_code = ir.bill_no AND w.del_flag = '0'
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
LEFT JOIN emis_settle_bill b ON b.settle_bill_no = ibr.settle_bill_no AND b.del_flag = '0'
WHERE bd.apply_seq_no = a.apply_seq_no AND bd.del_flag = '0'
) as open_bill_remark,
(
SELECT GROUP_CONCAT(DISTINCT
CONCAT(
DATE_FORMAT(pr.trade_date, '%m/%d'),
' 已付(',
CASE pr.pay_type
WHEN '1' THEN '企业微信收款'
WHEN '2' THEN '工行汇款3890'
WHEN '3' THEN '微信支付'
WHEN '4' THEN '支付宝'
WHEN '5' THEN '其他'
WHEN '6' THEN '招行付款'
ELSE pr.pay_type
END,
')'
)
)
FROM emis_settle_invoice_ch_record bd
LEFT JOIN emis_settle_invoice_bill_rel ibr ON ibr.apply_seq_no = bd.apply_seq_no AND ibr.del_flag = '0'
LEFT JOIN emis_settle_pay_bill_rel pbr ON ibr.settle_bill_no = pbr.settle_bill_no
LEFT JOIN emis_settle_pay_record pr ON pr.pay_id = pbr.pay_id
WHERE bd.apply_seq_no = a.apply_seq_no AND bd.del_flag = '0'
) as pay_days
FROM emis_settle_invoice_ch_record a
WHERE a.del_flag = '0'
AND a.apply_seq_no IN
<foreach collection="applySeqNoList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>