diff --git a/oms_web/oms_vue/src/api/finance/payment.js b/oms_web/oms_vue/src/api/finance/payment.js
index e7a2da46..4c7fcedf 100644
--- a/oms_web/oms_vue/src/api/finance/payment.js
+++ b/oms_web/oms_vue/src/api/finance/payment.js
@@ -104,10 +104,11 @@ export function applyPaymentApi(data) {
}
// 申请退款
-export function applyRefund(id) {
+export function applyRefund(data) {
return request({
- url: '/finance/payment/applyRefund/'+id,
- method: 'get',
+ url: '/finance/payment/applyRefund',
+ method: 'post',
+ data: data,
needLoading: true
})
}
diff --git a/oms_web/oms_vue/src/views/dataProcess/projectTransfer.vue b/oms_web/oms_vue/src/views/dataProcess/projectTransfer.vue
index 64c17ea5..e7e4f814 100644
--- a/oms_web/oms_vue/src/views/dataProcess/projectTransfer.vue
+++ b/oms_web/oms_vue/src/views/dataProcess/projectTransfer.vue
@@ -122,14 +122,14 @@
-
+
-
+
申请退款
确 定
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -377,6 +427,25 @@ export default {
// 付款申请弹窗
applyPaymentOpen: false,
applyPaymentForm: {},
+ // 退款申请弹窗
+ applyRefundOpen: false,
+ applyRefundTaxRate: null,
+ applyRefundOriginalTotalPriceWithTax: null,
+ applyRefundMaxAmount: null,
+ applyRefundCalcWithoutTax: false,
+ applyRefundCalcTaxAmount: false,
+ applyRefundForm: {},
+ applyRefundRules: {
+ paymentMethod: [{ required: true, message: "请选择退款方式", trigger: "change" }],
+ payName: [{ required: true, message: "请输入账户名称", trigger: "blur" }],
+ payBankNumber: [{ required: true, message: "请输入银行账号", trigger: "blur" }],
+ payBankOpenAddress: [{ required: true, message: "请输入银行开户行", trigger: "blur" }],
+ bankNumber: [{ required: true, message: "请输入银行行号", trigger: "blur" }],
+ totalPriceWithTax: [
+ { required: true, message: "请输入含税金额", trigger: "blur" },
+ { validator: (rule, value, callback) => this.validateApplyRefundTotalPrice(rule, value, callback), trigger: ["blur", "change"] }
+ ]
+ }
};
},
created() {
@@ -393,7 +462,9 @@ export default {
payBankNumber: row.payBankNumber,
payBankOpenAddress: row.payBankOpenAddress,
bankNumber: row.bankNumber,
- totalPriceWithTax: row.totalPriceWithTax
+ totalPriceWithTax: row.totalPriceWithTax,
+ totalPriceWithoutTax: row.totalPriceWithoutTax,
+ taxAmount: row.taxAmount
};
this.applyPaymentOpen = true;
},
@@ -501,12 +572,105 @@ export default {
},
/** 申请退款按钮操作 */
handleApplyRefund(row) {
- this.$modal.confirm('收款单退款申请,确认提交至财务审批吗?').then(() => {
- return applyRefund(row.id);
- }).then(() => {
- this.getList();
- this.$modal.msgSuccess("申请退款成功");
- }).catch(() => {});
+ this.applyRefundTaxRate = row.taxRate || null;
+ this.applyRefundOriginalTotalPriceWithTax = row.totalPriceWithTax || null;
+ this.applyRefundMaxAmount = row.remainingRefundAmount || row.totalPriceWithTax || null;
+ this.applyRefundCalcWithoutTax = this.isValidRefundAmount(row.totalPriceWithoutTax);
+ this.applyRefundCalcTaxAmount = this.isValidRefundAmount(row.taxAmount);
+ this.applyRefundForm = {
+ id: row.id,
+ paymentMethod: row.paymentMethod || null,
+ payName: row.payName || null,
+ payBankNumber: row.payBankNumber || null,
+ payBankOpenAddress: row.payBankOpenAddress || null,
+ bankNumber: row.bankNumber || null,
+ totalPriceWithTax: row.remainingRefundAmount || row.totalPriceWithTax || null,
+ totalPriceWithoutTax: null,
+ taxAmount: null,
+ remark: null
+ };
+ this.syncApplyRefundAmounts();
+ this.applyRefundOpen = true;
+ this.$nextTick(() => {
+ this.$refs["applyRefundForm"] && this.$refs["applyRefundForm"].clearValidate();
+ });
+ },
+ canApplyRefund(row) {
+ const remainingRefundAmount = Number(row.remainingRefundAmount);
+ return row.paymentBillType !== 'REFUND'
+ && row.paymentStatus === '2'
+ && ['WAIT_REFUNDED', 'PART_REFUNDED', null, undefined, ''].includes(row.refundStatus)
+ && !Number.isNaN(remainingRefundAmount)
+ && remainingRefundAmount > 0;
+ },
+ validateApplyRefundTotalPrice(rule, value, callback) {
+ if (value === null || value === undefined || value === '') {
+ callback();
+ return;
+ }
+ const currentValue = Number(value);
+ const maxValue = Number(this.applyRefundMaxAmount);
+ if (Number.isNaN(currentValue)) {
+ callback(new Error("含税金额格式不正确"));
+ return;
+ }
+ if (currentValue <= 0) {
+ callback(new Error("含税金额必须大于0"));
+ return;
+ }
+ if (!Number.isNaN(maxValue) && currentValue > maxValue) {
+ callback(new Error("含税金额不能大于剩余可退款金额"));
+ return;
+ }
+ callback();
+ },
+ syncApplyRefundAmounts() {
+ const totalPriceWithTax = Number(this.applyRefundForm.totalPriceWithTax);
+ const taxRate = Number(this.applyRefundTaxRate);
+ if (Number.isNaN(totalPriceWithTax) || this.applyRefundForm.totalPriceWithTax === '' || this.applyRefundForm.totalPriceWithTax === null) {
+ this.applyRefundForm.totalPriceWithoutTax = null;
+ this.applyRefundForm.taxAmount = null;
+ return;
+ }
+ if (Number.isNaN(taxRate)) {
+ this.applyRefundForm.totalPriceWithoutTax = this.applyRefundCalcWithoutTax ? totalPriceWithTax.toFixed(2) : null;
+ this.applyRefundForm.taxAmount = this.applyRefundCalcTaxAmount ? '0.00' : null;
+ return;
+ }
+ const taxAmount = (totalPriceWithTax * taxRate).toFixed(2);
+ const totalPriceWithoutTax = (totalPriceWithTax - Number(taxAmount)).toFixed(2);
+ this.applyRefundForm.taxAmount = this.applyRefundCalcTaxAmount ? taxAmount : null;
+ this.applyRefundForm.totalPriceWithoutTax = this.applyRefundCalcWithoutTax ? totalPriceWithoutTax : null;
+ },
+ isValidRefundAmount(value) {
+ const amount = Number(value);
+ return value !== null && value !== undefined && value !== '' && !Number.isNaN(amount) && amount !== 0;
+ },
+ submitApplyRefund() {
+ this.$refs["applyRefundForm"].validate(valid => {
+ if (!valid) {
+ return;
+ }
+ const submitData = {
+ id: this.applyRefundForm.id,
+ paymentMethod: this.applyRefundForm.paymentMethod,
+ payName: this.applyRefundForm.payName,
+ payBankNumber: this.applyRefundForm.payBankNumber,
+ payBankOpenAddress: this.applyRefundForm.payBankOpenAddress,
+ bankNumber: this.applyRefundForm.bankNumber,
+ totalPriceWithTax: this.applyRefundForm.totalPriceWithTax,
+ totalPriceWithoutTax: this.applyRefundForm.totalPriceWithoutTax,
+ taxAmount: this.applyRefundForm.taxAmount,
+ remark: this.applyRefundForm.remark
+ };
+ this.$modal.confirm('付款单退款申请,确认提交至财务审批吗?').then(() => {
+ return applyRefund(submitData);
+ }).then(() => {
+ this.applyRefundOpen = false;
+ this.getList();
+ this.$modal.msgSuccess("申请退款成功");
+ }).catch(() => {});
+ });
},
handleDelete(id){
this.$modal.confirm('确认删除该笔预付单数据吗?').then(() => {
@@ -559,6 +723,10 @@ export default {
if (value === null || value === undefined || value === '') return '';
return value.substring(0, 10);
},
+ formatTaxRate(value) {
+ if (value === null || value === undefined || value === '') return '';
+ return `${Number(value) * 100}%`;
+ },
handleUpdatePaymentBillSubmit(form) {
console.log(form);
updatePaymentBill(form).then(response => {
diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPaymentBillController.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPaymentBillController.java
index 6265418a..f975d31c 100644
--- a/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPaymentBillController.java
+++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPaymentBillController.java
@@ -259,11 +259,11 @@ public class OmsPaymentBillController extends BaseController
/**
* 申请退款
*/
- @GetMapping("/applyRefund/{id}")
+ @PostMapping("/applyRefund")
@ResponseBody
- public AjaxResult applyRefund(@PathVariable("id") Long id) {
+ public AjaxResult applyRefund(@RequestBody OmsPaymentBill paymentBill) {
try {
- return omsPaymentBillService.applyRefund(id);
+ return omsPaymentBillService.applyRefund(paymentBill);
} catch (Exception e) {
logger.error("申请退款失败", e);
return AjaxResult.error("操作失败:" + e.getMessage());
diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPaymentBill.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPaymentBill.java
index 31ff59c1..176418f0 100644
--- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPaymentBill.java
+++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPaymentBill.java
@@ -70,6 +70,9 @@ public class OmsPaymentBill extends BaseEntity
@Excel(name = "税额")
private BigDecimal taxAmount;
+ /** 税率 */
+ private BigDecimal taxRate;
+
/** 删除标志(0代表存在 2代表删除) */
private String delFlag;
@@ -130,6 +133,10 @@ public class OmsPaymentBill extends BaseEntity
/** 退款状态 */
private String refundStatus;
+ /** 已申请退款金额 */
+ private BigDecimal refundedAmount;
+ /** 剩余可退款金额 */
+ private BigDecimal remainingRefundAmount;
private String hzUserName;
private Long approveUser;
private Date applyTime;
@@ -194,8 +201,8 @@ public class OmsPaymentBill extends BaseEntity
@Getter
public enum RefundStatusEnum {
- /** 应付单生成 */
- REFUNDED("REFUND_APPLIED", "已申请退款"),
+ REFUNDED("REFUND_APPLIED", "全部退款"),
+ PART_REFUNDED("PART_REFUNDED", "部分退款"),
WAIT_REFUNDED("WAIT_REFUNDED", "未退款")
;
diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/OmsPayablePaymentDetailMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/OmsPayablePaymentDetailMapper.java
index 9289f07b..4fb46473 100644
--- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/OmsPayablePaymentDetailMapper.java
+++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/OmsPayablePaymentDetailMapper.java
@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
+import java.util.Map;
public interface OmsPayablePaymentDetailMapper {
public int insertOmsPayablePaymentDetail(OmsPayablePaymentDetail omsPayablePaymentDetail);
@@ -19,6 +20,8 @@ public interface OmsPayablePaymentDetailMapper {
List selectByPaymentPlanIds(@Param("paymentPlanIds") List paymentPlanIds);
+ List