理财赎回-二开标准插件【赎回份数】的校验

This commit is contained in:
李贵强 2025-06-25 15:56:24 +08:00
parent 243dd7707f
commit c0efbb15c9
1 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,111 @@
package shjh.jhzj7.fi.fi.plugin.form;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.resource.ResManager;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.orm.query.QFilter;
import kd.tmc.cim.common.enums.CimEntityEnum;
import kd.tmc.cim.common.enums.RedeemWayEnum;
import kd.tmc.cim.common.helper.RevenueCalcHelper;
import kd.tmc.cim.formplugin.redeem.RedeemBillEdit;
import kd.tmc.fbp.common.helper.TmcDataServiceHelper;
import kd.tmc.fbp.common.helper.TmcViewInputHelper;
import kd.tmc.fbp.common.model.interest.IntBillInfo;
import kd.tmc.fbp.common.util.DateUtils;
import kd.tmc.fbp.common.util.EmptyUtil;
import java.math.BigDecimal;
import java.util.Date;
public class RedeemBillExtendEditPlugin extends RedeemBillEdit {
@Override
public void propertyChanged(PropertyChangedArgs args) {
// 如果不是 "copies" 属性才调用父类逻辑
if (!"copies".equals(args.getProperty().getName())) {
super.propertyChanged(args);
}
// 单独处理 "copies" 逻辑
if ("copies".equals(args.getProperty().getName())) {
this.checkCopies();
this.calAmount();
this.calRealRevenue();
}
}
private void checkCopies() {
String redeemWay = (String)this.getModel().getValue("redeemway");
//DynamicObject finBillNoF7 = (DynamicObject)this.getModel().getValue("finbillno");
if (RedeemWayEnum.copies_redeem.getValue().equals(redeemWay)) {
BigDecimal copies = (BigDecimal)this.getModel().getValue("copies");//赎回份数
BigDecimal shrsyfe = (BigDecimal)this.getModel().getValue("shjh_shrsyfe");//赎回日剩余份额
//BigDecimal surplusCopies = finBillNoF7.getBigDecimal("surpluscopies");//剩余份数
if (copies.compareTo(shrsyfe) > 0) {
this.getView().showTipNotification(ResManager.loadKDString("赎回份数不允许超过理财赎回日剩余份额,请重新输入。", "RedeemBillEdit_1", "tmc-cim-formplugin", new Object[0]));
TmcViewInputHelper.setValWithoutPropChgEvt(this.getView(), this.getModel(), "copies", 0);
return;
}
//this.getModel().setValue("surpluscopies", surplusCopies.subtract(copies));
}
}
private void calAmount() {
String redeemWay = (String)this.getModel().getValue("redeemway");
if (RedeemWayEnum.copies_redeem.getValue().equals(redeemWay)) {
BigDecimal buyCopies = (BigDecimal)this.getModel().getValue("copies");
BigDecimal iopv = (BigDecimal)this.getModel().getValue("iopv");
BigDecimal amount = iopv.multiply(buyCopies);
this.getModel().setValue("amount", amount);
}
}
private void calRealRevenue() {
String redeemWay = (String)this.getModel().getValue("redeemway");
DynamicObject finBillNoF7 = (DynamicObject)this.getModel().getValue("finbillno");
if (!EmptyUtil.isEmpty(finBillNoF7)) {
Long finBillId = (Long)finBillNoF7.getPkValue();
DynamicObject finBill = TmcDataServiceHelper.loadSingle(CimEntityEnum.cim_finsubscribe.getValue(), "endinstdate,iopv", new QFilter[]{new QFilter("id", "=", finBillId)});
if (RedeemWayEnum.amount_redeem.getValue().equals(redeemWay)) {
boolean isRevenue = (Boolean)this.getModel().getValue("isrevenue");
if (isRevenue) {
Date lastEndIntDate = finBill.getDate("endinstdate");
Date redeemDate = (Date)this.getModel().getValue("redeemdate");
IntBillInfo intBill = this.getIntBillInfo(finBillId, lastEndIntDate, redeemDate);
if (intBill != null) {
TmcViewInputHelper.setValWithoutDataChanged(this.getModel(), "realrevenue", intBill.getAmount());
}
}
} else {
BigDecimal redeemAmount = (BigDecimal)this.getModel().getValue("amount");
BigDecimal copies = (BigDecimal)this.getModel().getValue("copies");
BigDecimal iopv = finBill.getBigDecimal("iopv");
BigDecimal realRevenue = redeemAmount.subtract(iopv.multiply(copies));
TmcViewInputHelper.setValWithoutDataChanged(this.getModel(), "realrevenue", realRevenue);
}
}
}
private IntBillInfo getIntBillInfo(Long finBillId, Date lastEndIntDate, Date redeemDate) {
BigDecimal amount = (BigDecimal)this.getModel().getValue("amount");
BigDecimal surplusAmount = (BigDecimal)this.getModel().getValue("surplusamount");
IntBillInfo intBill;
if (BigDecimal.ZERO.compareTo(surplusAmount) != 0) {
intBill = RevenueCalcHelper.callInt(finBillId, redeemDate, amount);
} else {
if (EmptyUtil.isNoEmpty(lastEndIntDate)) {
lastEndIntDate = DateUtils.getNextDay(lastEndIntDate, 1);
}
intBill = RevenueCalcHelper.callInt(finBillId, lastEndIntDate, redeemDate);
}
return intBill;
}
}