Compare commits

..

No commits in common. "a14993e1b85a54bee22ca169de52edce6e9a9999" and "9cc5c64fee605df8e36897d5811a7b1f894b15f6" have entirely different histories.

9 changed files with 83 additions and 155 deletions

BIN
.DS_Store vendored

Binary file not shown.

1
.gitignore vendored
View File

@ -36,7 +36,6 @@ dist/
nbdist/ nbdist/
.nb-gradle/ .nb-gradle/
.DS_Store .DS_Store
*.png
###################################################################### ######################################################################
# Others # Others

View File

@ -11,6 +11,8 @@
</template> </template>
<script> <script>
import request from '@/utils/request';
export default { export default {
name: "GlobalFilePreview", name: "GlobalFilePreview",
data() { data() {
@ -25,32 +27,25 @@ export default {
isPdf(filePath) { isPdf(filePath) {
return filePath && filePath.toLowerCase().endsWith('.pdf'); return filePath && filePath.toLowerCase().endsWith('.pdf');
}, },
getFileBaseName(filePath) { getImageUrl(resource) {
if (!filePath) return ''; return process.env.VUE_APP_BASE_API + "/common/download/resource?resource=" + resource;
const parts = filePath.split('/');
return parts[parts.length - 1] || '';
},
// 在线查看地址:后端以 inline 方式返回文件(图片/PDF 可直接在浏览器渲染)
getViewUrl(filePath, fileName) {
const resource = encodeURIComponent(filePath || '');
const name = encodeURIComponent(fileName || this.getFileBaseName(filePath));
return `${process.env.VUE_APP_BASE_API}/project/order/file/view?filePath=${resource}&fileName=${name}`;
}, },
handlePreview(attachment) { handlePreview(attachment) {
if (!attachment || !attachment.filePath) { if (!attachment) return;
return; if (this.isPdf(attachment.filePath)) {
} request({
const filePath = attachment.filePath.toLowerCase(); url: '/common/download/resource',
const isImage = /\.(png|jpg|jpeg|gif)$/.test(filePath); method: 'get',
if (this.isPdf(filePath)) { params: { resource: attachment.filePath },
this.currentPdfUrl = this.getViewUrl(attachment.filePath, attachment.fileName); responseType: 'blob'
this.pdfPreviewVisible = true; }).then(res => {
} else if (isImage) { const blob = new Blob([res.data], { type: 'application/pdf' });
this.currentImageUrl = this.getViewUrl(attachment.filePath, attachment.fileName); this.currentPdfUrl = URL.createObjectURL(blob);
this.imagePreviewVisible = true; this.pdfPreviewVisible = true;
});
} else { } else {
// 浏览器无法直接渲染的格式,改为新窗口打开(由浏览器决定预览或下载) this.currentImageUrl = this.getImageUrl(attachment.filePath);
window.open(this.getViewUrl(attachment.filePath, attachment.fileName), '_blank'); this.imagePreviewVisible = true;
} }
}, },
downloadFile(attachment){ downloadFile(attachment){

View File

@ -342,7 +342,6 @@ export default {
updatePaymentBill(form).then(() => { updatePaymentBill(form).then(() => {
this.$modal.msgSuccess("保存成功"); this.$modal.msgSuccess("保存成功");
this.paymentDetailOpen = false; this.paymentDetailOpen = false;
this.getDetails();
}).catch(error => { }).catch(error => {
console.error("保存补充附件失败", error); console.error("保存补充附件失败", error);
this.$modal.msgError("保存失败"); this.$modal.msgError("保存失败");

View File

@ -13,7 +13,6 @@
<div class="section"> <div class="section">
<el-divider content-position="left">付款单</el-divider> <el-divider content-position="left">付款单</el-divider>
<div class="section-actions"> <div class="section-actions">
<el-button v-if="editEnabled" type="primary" size="mini" @click="handleSaveAttachment">保存</el-button>
<el-button type="primary" size="mini" :loading="pdfExporting" @click="handleExportPDF">导出PDF</el-button> <el-button type="primary" size="mini" :loading="pdfExporting" @click="handleExportPDF">导出PDF</el-button>
<el-button size="mini" @click="handlePrint">打印</el-button> <el-button size="mini" @click="handlePrint">打印</el-button>
</div> </div>
@ -32,18 +31,7 @@
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8"> <el-col :span="8">
<div class="detail-item">含税总价(元): <div class="detail-item">含税总价(元):<span :class="{'red-text':detail.paymentBillType==='REFUND'}"> {{ formatCurrency(detail.totalPriceWithTax) }}</span></div>
<el-input-number
v-if="editEnabled"
v-model="editTotalPriceWithTax"
:precision="2"
:min="0.01"
:step="100"
size="mini"
style="width: 160px; margin-left: 8px"
/>
<span v-else :class="{'red-text':detail.paymentBillType==='REFUND'}"> {{ formatCurrency(detail.totalPriceWithTax) }}</span>
</div>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<div class="detail-item">未税总价(元): <span :class="{'red-text':detail.paymentBillType==='REFUND'}">{{ formatCurrency(detail.totalPriceWithoutTax) }}</span></div> <div class="detail-item">未税总价(元): <span :class="{'red-text':detail.paymentBillType==='REFUND'}">{{ formatCurrency(detail.totalPriceWithoutTax) }}</span></div>
@ -115,27 +103,19 @@
<el-button type="success" size="mini" icon="el-icon-download" :loading="zipDownloading" @click="handleDownloadAllAttachments" style="margin-bottom: 10px">一键下载附件</el-button> <el-button type="success" size="mini" icon="el-icon-download" :loading="zipDownloading" @click="handleDownloadAllAttachments" style="margin-bottom: 10px">一键下载附件</el-button>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24"> <el-col :span="24">
<div class="detail-item" style="align-items: flex-start"> <div class="detail-item">
<span style="margin-right: 10px">附件:</span> <span style="margin-right: 10px">附件:</span>
<file-upload v-if="!editEnabled" :value="detail.fileList" :disabled="true" :show-remove="false" :show-upload-btn="false"/> <file-upload :value="detail.fileList" :disabled="true" :show-remove="false" :show-upload-btn="false"/>
<div v-else class="attachment-edit-list">
<span v-for="file in visibleFileList" :key="file.id" class="attachment-edit-item">
<el-link type="primary" :underline="false" @click="handlePreviewAttachment(file)">
<i class="el-icon-document"></i> {{ file.fileName }}
</el-link>
<el-link type="danger" :underline="false" style="margin-left: 8px" @click="handleRemoveSavedFile(file)">删除</el-link>
</span>
<span v-if="visibleFileList.length === 0" style="color: #909399">暂无附件</span>
</div>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20" class="export-exclude" v-if="editEnabled && visibleFileList.length < 10"> <el-row :gutter="20" class="export-exclude" v-if="detail.fileList == null || detail.fileList.length < 10">
<el-col :span="24"> <el-col :span="24">
<div class="detail-item"> <div class="detail-item">
<span style="margin-right: 10px">附件补充:</span> <span style="margin-right: 10px">附件补充:</span>
<file-upload :value="fileList" @file-list-changed="handleFileListChanged" :limit="10 - visibleFileList.length" <file-upload :value="fileList" @file-list-changed="handleFileListChanged" :limit="detail.fileList == null ? 10 : 10 - detail.fileList.length"
:file-size="10" :file-type="['png', 'jpg', 'jpeg', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'zip', 'rar']"/> :file-size="10" :file-type="['png', 'jpg', 'jpeg', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf', 'zip', 'rar']"/>
<el-button type="primary" size="small" style="margin-left: 10px" @click="handleSaveAttachment">保存</el-button>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
@ -174,7 +154,6 @@
</div> </div>
</div> </div>
<edit-form :visible.sync="payableVisible" :data="selectedPayableRow" :z-index="2000" @close="payableVisible = false" /> <edit-form :visible.sync="payableVisible" :data="selectedPayableRow" :z-index="2000" @close="payableVisible = false" />
<global-file-preview ref="filePreview" />
</el-drawer> </el-drawer>
</template> </template>
@ -185,13 +164,12 @@ import { saveAs } from "file-saver";
import FileUpload from "@/components/FileUpload"; import FileUpload from "@/components/FileUpload";
import EditForm from "@/views/finance/payable/components/EditForm.vue"; import EditForm from "@/views/finance/payable/components/EditForm.vue";
import FlowOpinionTimeline from "@/views/finance/components/FlowOpinionTimeline.vue"; import FlowOpinionTimeline from "@/views/finance/components/FlowOpinionTimeline.vue";
import GlobalFilePreview from "@/components/GlobalFilePreview";
import { listCompletedFlows } from "@/api/flow"; import { listCompletedFlows } from "@/api/flow";
import { exportElementToPDF } from "@/views/approve/finance/pdfUtils"; import { exportElementToPDF } from "@/views/approve/finance/pdfUtils";
export default { export default {
name: "DetailDrawer", name: "DetailDrawer",
components: {FileUpload, EditForm, FlowOpinionTimeline, GlobalFilePreview}, components: {FileUpload, EditForm, FlowOpinionTimeline},
props: { props: {
visible: { visible: {
type: Boolean, type: Boolean,
@ -209,10 +187,7 @@ export default {
data() { data() {
return { return {
fileList: [], fileList: [],
// 编辑中的含税总价 fileId: null,
editTotalPriceWithTax: null,
// 已存在附件中被删除的附件ID
removedFileIds: [],
payableVisible: false, payableVisible: false,
selectedPayableRow: {}, selectedPayableRow: {},
approveLogs: [], approveLogs: [],
@ -222,18 +197,6 @@ export default {
zipDownloading: false, zipDownloading: false,
}; };
}, },
computed: {
// 仅"预付单"且处于"待提交(0)/已驳回(3)"状态时才允许编辑含税总价与附件
editEnabled() {
const detail = this.detail || {};
return detail.paymentBillType === 'PRE_PAYMENT' && ['0', '3'].includes(detail.approveStatus);
},
// 过滤掉已删除的已存在附件
visibleFileList() {
const list = Array.isArray(this.detail && this.detail.fileList) ? this.detail.fileList : [];
return list.filter(file => file && !this.removedFileIds.includes(file.id));
}
},
beforeDestroy() { beforeDestroy() {
if (this.approveLogsTimer) { if (this.approveLogsTimer) {
clearTimeout(this.approveLogsTimer); clearTimeout(this.approveLogsTimer);
@ -243,7 +206,8 @@ export default {
watch: { watch: {
visible(newVal) { visible(newVal) {
if (newVal) { if (newVal) {
this.resetEditState(); this.fileList = [];
this.fileId = null;
this.scheduleLoadApproveHistory(); this.scheduleLoadApproveHistory();
} else { } else {
if (this.approveLogsTimer) { if (this.approveLogsTimer) {
@ -255,7 +219,8 @@ export default {
}, },
detail: { detail: {
handler() { handler() {
this.resetEditState(); this.fileList = [];
this.fileId = null;
this.scheduleLoadApproveHistory(); this.scheduleLoadApproveHistory();
}, },
deep: true deep: true
@ -279,43 +244,23 @@ export default {
}, },
handleFileListChanged(fileList) { handleFileListChanged(fileList) {
this.fileList = fileList; this.fileList = fileList;
}, this.fileId = this.fileList.map(f => f.id).filter(id => !!id).join(',')
resetEditState() {
this.fileList = [];
this.removedFileIds = [];
this.editTotalPriceWithTax = this.detail ? this.detail.totalPriceWithTax : null;
},
handleRemoveSavedFile(file) {
if (file && file.id != null && !this.removedFileIds.includes(file.id)) {
this.removedFileIds.push(file.id);
}
},
handlePreviewAttachment(file) {
if (!file || !file.filePath) {
this.$modal.msgWarning('附件地址为空,无法预览');
return;
}
// 图片/PDF 弹窗预览,其他格式交由组件在新窗口打开
this.$refs.filePreview.handlePreview(file);
}, },
handleSaveAttachment() { handleSaveAttachment() {
const totalPriceWithTax = Number(this.editTotalPriceWithTax); if (this.fileList.length === 0) {
if (this.editTotalPriceWithTax === null || this.editTotalPriceWithTax === undefined this.$modal.msgWarning('请先上传附件');
|| this.editTotalPriceWithTax === '' || Number.isNaN(totalPriceWithTax) || totalPriceWithTax <= 0) {
this.$modal.msgWarning('请输入大于0的含税总价');
return; return;
} }
const keptFileIds = this.visibleFileList.map(f => f.id).filter(id => !!id); const oldFileId = this.detail.fileId;
const newFileIds = this.fileList.map(f => f.id).filter(id => !!id); this.fileId = oldFileId === null || oldFileId === '' ? this.fileId : oldFileId + ',' + this.fileId;
const saveData = { const saveData = {
id: this.detail.id, id: this.detail.id,
totalPriceWithTax: this.editTotalPriceWithTax, fileId: this.fileId,
fileId: keptFileIds.concat(newFileIds).join(','),
}; };
this.$emit('submit', saveData); this.$emit('submit', saveData);
}, },
getAllAttachments() { getAllAttachments() {
const saved = this.visibleFileList; const saved = Array.isArray(this.detail.fileList) ? this.detail.fileList : [];
// 补充附件:优先取已保存的,未点击保存前取当前新增的上传对象 // 补充附件:优先取已保存的,未点击保存前取当前新增的上传对象
const supplement = Array.isArray(this.fileList) ? this.fileList : []; const supplement = Array.isArray(this.fileList) ? this.fileList : [];
const result = []; const result = [];
@ -520,21 +465,6 @@ export default {
padding: 0 20px 20px 20px; /* Adjust padding to match dialog-body style */ padding: 0 20px 20px 20px; /* Adjust padding to match dialog-body style */
} }
.attachment-edit-list {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.attachment-edit-item {
display: inline-flex;
align-items: center;
border: 1px solid #EBEEF5;
border-radius: 4px;
padding: 2px 8px;
background: #fafafa;
}
.details-container { .details-container {
border: 1px solid #EBEEF5; border: 1px solid #EBEEF5;
padding: 20px; padding: 20px;

View File

@ -737,10 +737,10 @@ export default {
return `${Number(value) * 100}%`; return `${Number(value) * 100}%`;
}, },
handleUpdatePaymentBillSubmit(form) { handleUpdatePaymentBillSubmit(form) {
console.log(form);
updatePaymentBill(form).then(response => { updatePaymentBill(form).then(response => {
this.$modal.msgSuccess("保存成功"); this.$modal.msgSuccess("保存成功");
this.detailOpen = false; this.detailOpen = false;
this.getList();
}).catch(error => { }).catch(error => {
console.error("保存补充附件失败", error); console.error("保存补充附件失败", error);
this.$modal.msgError("保存失败"); this.$modal.msgError("保存失败");

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<!-- <property name="log.path" value="/Users/jiliu/WorkSpace/java/RuoYi/logs" />--> <property name="log.path" value="/Users/jiliu/WorkSpace/java/RuoYi/logs" />
<property name="log.path" value="/Users/kangwenjing/Downloads/project/logs" /> <!-- <property name="log.path" value="/Users/kangwenjing/Downloads/project/logs" />-->
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />

View File

@ -166,10 +166,13 @@ public class OmsInventoryInnerServiceImpl implements IOmsInventoryInnerService {
} }
omsInventoryInner.setWarehouseId(warehouseIdList.get(0)); omsInventoryInner.setWarehouseId(warehouseIdList.get(0));
OmsPurchaseOrderItem purchaseOrderItem = null;
//无采购单时无法跟踪入库完成度,默认已完成(每次入库即生成应付单,与原行为一致)
boolean innerComplete = true;
if (omsInventoryInner.getItemId() != null) { if (omsInventoryInner.getItemId() != null) {
List<OmsPurchaseOrderItem> purchaseOrderItems = purchaseOrderService.listByItemId(omsInventoryInner.getItemId()); List<OmsPurchaseOrderItem> purchaseOrderItems = purchaseOrderService.listByItemId(omsInventoryInner.getItemId());
if (CollUtil.isNotEmpty(purchaseOrderItems)) { if (CollUtil.isNotEmpty(purchaseOrderItems)) {
OmsPurchaseOrderItem purchaseOrderItem = purchaseOrderItems.stream() purchaseOrderItem = purchaseOrderItems.stream()
.filter(item -> item.getId().equals(omsInventoryInner.getItemId())) .filter(item -> item.getId().equals(omsInventoryInner.getItemId()))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
@ -183,6 +186,8 @@ public class OmsInventoryInnerServiceImpl implements IOmsInventoryInnerService {
if (currentInnerQuantity > remainingQuantity) { if (currentInnerQuantity > remainingQuantity) {
throw new ServiceException(StrUtil.format("入库数量[{}]超过采购单剩余可入库数量[{}]", currentInnerQuantity, remainingQuantity)); throw new ServiceException(StrUtil.format("入库数量[{}]超过采购单剩余可入库数量[{}]", currentInnerQuantity, remainingQuantity));
} }
innerComplete = (alreadyInnerQuantity + currentInnerQuantity) >= purchaseQuantity;
BigDecimal purchasePrice = purchaseOrderItem.getPrice(); BigDecimal purchasePrice = purchaseOrderItem.getPrice();
if (purchasePrice != null) { if (purchasePrice != null) {
for (InventoryInfo inventoryInfo : inventoryInfoList) { for (InventoryInfo inventoryInfo : inventoryInfoList) {
@ -197,14 +202,27 @@ public class OmsInventoryInnerServiceImpl implements IOmsInventoryInnerService {
OmsPayableBill payableBill = new OmsPayableBill(); OmsPayableBill payableBill = new OmsPayableBill();
VendorInfo vendorInfo = vendorInfoService.selectVendorInfoByVendorCode(vendorCode); VendorInfo vendorInfo = vendorInfoService.selectVendorInfoByVendorCode(vendorCode);
//入库付款厂商(INNER_PAY)或非标准品(服务/维保)在入库时生成应付单,金额按本次入库量计算 boolean innerPay = vendorInfo != null && VendorInfo.PayTypeEnum.INNER_PAY.getCode().equals(vendorInfo.getPayType());
if ((vendorInfo != null && VendorInfo.PayTypeEnum.INNER_PAY.getCode().equals(vendorInfo.getPayType())) boolean notStandard = !Arrays.asList("1", "2").contains(omsInventoryInner.getProductType());
|| !Arrays.asList("1", "2").contains(omsInventoryInner.getProductType())) { boolean isH3c = isH3C(productInfos.get(0).getVendorName());
//生成应付单:新华三直接生成;非新华三需入库完成后才生成
if ((innerPay || notStandard) && (isH3c || innerComplete)) {
BigDecimal reduce = inventoryInfoList.stream().map(InventoryInfo::getInnerPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal reduce = inventoryInfoList.stream().map(InventoryInfo::getInnerPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
//服务金额为单价*数量 没有具体的详情 BigDecimal totalPriceWithTax;
BigDecimal totalPriceWithTax = Arrays.asList("3", "22").contains(omsInventoryInner.getProductType()) ? //非新华三且有完整采购单信息时,按整条采购单数量*单价生成
reduce.multiply(new BigDecimal(omsInventoryInner.getQuantity())).setScale(2, RoundingMode.HALF_UP) boolean usePurchaseOrder = !isH3c && purchaseOrderItem != null
: reduce; && purchaseOrderItem.getQuantity() != null
&& purchaseOrderItem.getPrice() != null;
if (usePurchaseOrder) {
totalPriceWithTax = purchaseOrderItem.getQuantity()
.multiply(purchaseOrderItem.getPrice())
.setScale(2, RoundingMode.HALF_UP);
} else {
//新华三或无采购单信息:服务金额为单价*数量(无具体详情)
totalPriceWithTax = Arrays.asList("3", "22").contains(omsInventoryInner.getProductType()) ?
reduce.multiply(new BigDecimal(omsInventoryInner.getQuantity())).setScale(2, RoundingMode.HALF_UP)
: reduce;
}
//生成应付单 //生成应付单
payableBill.setInventoryCode(omsInventoryInner.getInnerCode()); payableBill.setInventoryCode(omsInventoryInner.getInnerCode());
payableBill.setVendorCode(omsInventoryInner.getVendorCode()); payableBill.setVendorCode(omsInventoryInner.getVendorCode());
@ -225,7 +243,12 @@ public class OmsInventoryInnerServiceImpl implements IOmsInventoryInnerService {
} }
BigDecimal finalTaxRate = taxRate == null ? new BigDecimal(defaultTax) : taxRate; BigDecimal finalTaxRate = taxRate == null ? new BigDecimal(defaultTax) : taxRate;
BigDecimal withoutTax = inventoryInfoList.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getInnerPrice().divide(BigDecimal.ONE.add(finalTaxRate), 2, RoundingMode.HALF_UP)), BigDecimal::add); BigDecimal withoutTax;
if (usePurchaseOrder) {
withoutTax = totalPriceWithTax.divide(BigDecimal.ONE.add(finalTaxRate), 2, RoundingMode.HALF_UP);
} else {
withoutTax = inventoryInfoList.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getInnerPrice().divide(BigDecimal.ONE.add(finalTaxRate), 2, RoundingMode.HALF_UP)), BigDecimal::add);
}
payableBill.setTotalPriceWithoutTax(withoutTax); payableBill.setTotalPriceWithoutTax(withoutTax);
payableBill.setTaxRate(finalTaxRate); payableBill.setTaxRate(finalTaxRate);
payableBill.setTaxAmount(totalPriceWithTax.subtract(payableBill.getTotalPriceWithoutTax())); payableBill.setTaxAmount(totalPriceWithTax.subtract(payableBill.getTotalPriceWithoutTax()));
@ -256,6 +279,16 @@ public class OmsInventoryInnerServiceImpl implements IOmsInventoryInnerService {
return code.toString(); return code.toString();
} }
/**
* 判断制造商是否为新华三
*
* @param vendorName 制造商名称
* @return 是新华三返回 true
*/
private boolean isH3C(String vendorName) {
return StringUtils.isNotEmpty(vendorName) && vendorName.startsWith("新华三");
}
/** /**
* 修改入库单信息 * 修改入库单信息
* *

View File

@ -19,7 +19,6 @@ import com.ruoyi.common.config.flow.ProcessConfig;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.ApproveStatusEnum; import com.ruoyi.common.enums.ApproveStatusEnum;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
@ -1021,34 +1020,7 @@ public class OmsPaymentBillServiceImpl implements IOmsPaymentBillService , TodoC
@Override @Override
public int updatePaymentBill(OmsPaymentBill omsPaymentBill) { public int updatePaymentBill(OmsPaymentBill omsPaymentBill) {
if (omsPaymentBill == null || omsPaymentBill.getId() == null) { return omsPaymentBillMapper.updateOmsPaymentBill(omsPaymentBill);
throw new ServiceException("付款单ID不能为空");
}
OmsPaymentBill existBill = omsPaymentBillMapper.selectOmsPaymentBillById(omsPaymentBill.getId());
if (existBill == null) {
throw new ServiceException("付款单不存在");
}
// 仅"预付单"允许编辑含税总价与附件
if (!OmsPaymentBill.PaymentBillTypeEnum.PRE_PAYMENT.getCode().equals(existBill.getPaymentBillType())) {
throw new ServiceException("仅预付单支持编辑");
}
// 仅"待提交"与"已驳回"状态允许编辑
if (!ApproveStatusEnum.WAIT_COMMIT.getCode().equals(existBill.getApproveStatus())
&& !ApproveStatusEnum.APPROVE_REJECT.getCode().equals(existBill.getApproveStatus())) {
throw new ServiceException("当前审批状态不允许编辑");
}
if (omsPaymentBill.getTotalPriceWithTax() != null
&& omsPaymentBill.getTotalPriceWithTax().compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("含税总价必须大于0");
}
// 白名单更新,避免越权修改审批状态、付款状态等字段
OmsPaymentBill updateBill = new OmsPaymentBill();
updateBill.setId(existBill.getId());
updateBill.setTotalPriceWithTax(omsPaymentBill.getTotalPriceWithTax());
updateBill.setFileId(omsPaymentBill.getFileId());
updateBill.setUpdateBy(ShiroUtils.getLoginName());
updateBill.setUpdateTime(DateUtils.getNowDate());
return omsPaymentBillMapper.updateOmsPaymentBill(updateBill);
} }
} }