update BigDecimal类型初始化及空值校验
This commit is contained in:
@@ -50,7 +50,7 @@ public class LeaseOrderInfo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 订单总价
|
* 订单总价
|
||||||
*/
|
*/
|
||||||
private BigDecimal totalPrice;
|
private BigDecimal totalPrice = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单状态,0 表示待支付,1 表示(全部)已支付,2 表示已取消 3售后状态 4已退款 5已超时 10 部分已支付
|
* 订单状态,0 表示待支付,1 表示(全部)已支付,2 表示已取消 3售后状态 4已退款 5已超时 10 部分已支付
|
||||||
@@ -74,7 +74,7 @@ public class LeaseOrderInfo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 手续费
|
* 手续费
|
||||||
*/
|
*/
|
||||||
private BigDecimal fee;
|
private BigDecimal fee = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 店铺名称
|
* 店铺名称
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class LeaseOrderItem implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 商品单价
|
* 商品单价
|
||||||
*/
|
*/
|
||||||
private BigDecimal price;
|
private BigDecimal price = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 矿机挖矿币种 nexa rxd dgbo dgbq dgbs alph enx grs mona
|
* 矿机挖矿币种 nexa rxd dgbo dgbq dgbs alph enx grs mona
|
||||||
@@ -127,17 +127,17 @@ public class LeaseOrderItem implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 单机理论算力
|
* 单机理论算力
|
||||||
*/
|
*/
|
||||||
private BigDecimal theoryPower;
|
private BigDecimal theoryPower = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单机实际算力
|
* 单机实际算力
|
||||||
*/
|
*/
|
||||||
private BigDecimal practicalPower;
|
private BigDecimal practicalPower = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单机理论收益
|
* 单机理论收益
|
||||||
*/
|
*/
|
||||||
private BigDecimal theoryIncome;
|
private BigDecimal theoryIncome = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单机预估实际收益
|
* 单机预估实际收益
|
||||||
@@ -177,17 +177,17 @@ public class LeaseOrderItem implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 已支付金额
|
* 已支付金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal alreadyPayAmount;
|
private BigDecimal alreadyPayAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 已支付金额(真实)
|
* 已支付金额(真实)
|
||||||
*/
|
*/
|
||||||
private BigDecimal alreadyPayRealAmount;
|
private BigDecimal alreadyPayRealAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当日待支付确认金额
|
* 当日待支付确认金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal settlePayRealAmount;
|
private BigDecimal settlePayRealAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
private Integer numbers;
|
private Integer numbers;
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class LeaseOrderItem implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 收卖家手续费率
|
* 收卖家手续费率
|
||||||
*/
|
*/
|
||||||
private BigDecimal feeRate;
|
private BigDecimal feeRate = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,22 +76,22 @@ public class LeasePayRecordMessage implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 理论支付金额(根据商家定价)
|
* 理论支付金额(根据商家定价)
|
||||||
*/
|
*/
|
||||||
private BigDecimal amount;
|
private BigDecimal amount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*真实支付金额
|
*真实支付金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal realAmount;
|
private BigDecimal realAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实际应支付金额(根据一天内预估算力和实际算力差值计算得来)
|
* 实际应支付金额(根据一天内预估算力和实际算力差值计算得来)
|
||||||
*/
|
*/
|
||||||
private BigDecimal needAmount;
|
private BigDecimal needAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 钱包冻结金额
|
* 钱包冻结金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal blockAmount;
|
private BigDecimal blockAmount = BigDecimal.ZERO;
|
||||||
/**
|
/**
|
||||||
* 币种
|
* 币种
|
||||||
*/
|
*/
|
||||||
@@ -144,13 +144,18 @@ public class LeasePayRecordMessage implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 卖家手续费比例
|
* 卖家手续费比例
|
||||||
*/
|
*/
|
||||||
private BigDecimal feeRate;
|
private BigDecimal feeRate = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卖家手续费
|
||||||
|
*/
|
||||||
|
private BigDecimal sellerFee = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卖家实收金额 = 店铺手续费比例 * 买家实际支付金额
|
* 卖家实收金额 = 店铺手续费比例 * 买家实际支付金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal receivedAmount;
|
private BigDecimal receivedAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String sellerEmail;
|
private String sellerEmail;
|
||||||
|
|||||||
@@ -75,22 +75,22 @@ public class LeasePayRecordMessageInfo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 理论支付金额(根据商家定价)
|
* 理论支付金额(根据商家定价)
|
||||||
*/
|
*/
|
||||||
private BigDecimal amount;
|
private BigDecimal amount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*真实支付金额
|
*真实支付金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal realAmount;
|
private BigDecimal realAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实际应支付金额(根据一天内预估算力和实际算力差值计算得来)
|
* 实际应支付金额(根据一天内预估算力和实际算力差值计算得来)
|
||||||
*/
|
*/
|
||||||
private BigDecimal needAmount;
|
private BigDecimal needAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 钱包冻结金额
|
* 钱包冻结金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal blockAmount;
|
private BigDecimal blockAmount = BigDecimal.ZERO;
|
||||||
/**
|
/**
|
||||||
* 币种
|
* 币种
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class LeasePayWithdrawMessage implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 支付金额
|
* 支付金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal amount;
|
private BigDecimal amount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 交易hash
|
* 交易hash
|
||||||
@@ -70,7 +70,7 @@ public class LeasePayWithdrawMessage implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 手续费
|
* 手续费
|
||||||
*/
|
*/
|
||||||
private BigDecimal serviceCharge;
|
private BigDecimal serviceCharge = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 币种
|
* 币种
|
||||||
|
|||||||
@@ -55,12 +55,12 @@ public class LeasePaymentRecord implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 支付金额
|
* 支付金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal amount;
|
private BigDecimal amount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 已支付金额
|
* 已支付金额
|
||||||
*/
|
*/
|
||||||
private BigDecimal payAmount;
|
private BigDecimal payAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付状态0支付失败 1支付成功--全部货款已支付 2待支付 5支付已超时 10支付成功--已支付部分货款
|
* 支付状态0支付失败 1支付成功--全部货款已支付 2待支付 5支付已超时 10支付成功--已支付部分货款
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class LeaseShopConfig implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 余额(这个余额是租赁系统的收款余额,而不是卖家钱包真实余额,该余额只能用于提现)
|
* 余额(这个余额是租赁系统的收款余额,而不是卖家钱包真实余额,该余额只能用于提现)
|
||||||
*/
|
*/
|
||||||
private BigDecimal balance;
|
private BigDecimal balance = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
@@ -93,6 +93,6 @@ public class LeaseShopConfig implements Serializable {
|
|||||||
private Boolean del;
|
private Boolean del;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private BigDecimal price;
|
private BigDecimal price = BigDecimal.ZERO;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ public class LeaseSystemWallet implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 余额
|
* 余额
|
||||||
*/
|
*/
|
||||||
private BigDecimal balance;
|
private BigDecimal balance = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 冻结余额
|
* 冻结余额
|
||||||
*/
|
*/
|
||||||
private BigDecimal blcokBalance;
|
private BigDecimal blcokBalance = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 链名称
|
* 链名称
|
||||||
|
|||||||
@@ -72,22 +72,22 @@ public class LeaseSystemWalletTransaction implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 卖方--手续费率
|
* 卖方--手续费率
|
||||||
*/
|
*/
|
||||||
private BigDecimal feeRate;
|
private BigDecimal feeRate = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卖方--收款金额(未扣手续费)
|
* 卖方--收款金额(未扣手续费)
|
||||||
*/
|
*/
|
||||||
private BigDecimal amount;
|
private BigDecimal amount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卖方--实收金额(已扣手续费)
|
* 卖方--实收金额(已扣手续费)
|
||||||
*/
|
*/
|
||||||
private BigDecimal receivedAmount;
|
private BigDecimal receivedAmount = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卖方--手续费
|
* 卖方--手续费
|
||||||
*/
|
*/
|
||||||
private BigDecimal fee;
|
private BigDecimal fee = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 币种名称
|
* 币种名称
|
||||||
|
|||||||
@@ -80,34 +80,34 @@ public class LeaseUserOwnedProduct implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 购买算力的量,当 type 为 1 时有效
|
* 购买算力的量,当 type 为 1 时有效
|
||||||
*/
|
*/
|
||||||
private BigDecimal purchasedComputingPower;
|
private BigDecimal purchasedComputingPower = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预估商品结束时的总收益 单位币种
|
* 预估商品结束时的总收益 单位币种
|
||||||
*/
|
*/
|
||||||
private BigDecimal estimatedEndIncome;
|
private BigDecimal estimatedEndIncome = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预估商品结束时的总收益 单位usdt
|
* 预估商品结束时的总收益 单位usdt
|
||||||
*/
|
*/
|
||||||
private BigDecimal estimatedEndUsdtIncome;
|
private BigDecimal estimatedEndUsdtIncome = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前收益(根据购买机器到现在的平均算力计算得到) 单位币种
|
* 当前收益(根据购买机器到现在的平均算力计算得到) 单位币种
|
||||||
*/
|
*/
|
||||||
private BigDecimal currentIncome;
|
private BigDecimal currentIncome = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前收益(根据购买机器到现在的平均算力计算得到)单位usdt
|
* 当前收益(根据购买机器到现在的平均算力计算得到)单位usdt
|
||||||
*/
|
*/
|
||||||
private BigDecimal currentUsdtIncome;
|
private BigDecimal currentUsdtIncome = BigDecimal.ZERO;
|
||||||
|
|
||||||
private BigDecimal settleIncome ;
|
private BigDecimal settleIncome = BigDecimal.ZERO;
|
||||||
|
|
||||||
private BigDecimal settleUsdtIncome ;
|
private BigDecimal settleUsdtIncome = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品状态,0 表示运行中,1 表示已过期
|
* 商品状态,0 表示运行中,1 表示已过期
|
||||||
|
|||||||
@@ -83,12 +83,12 @@ public class LeaseUserWalletData implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 余额
|
* 余额
|
||||||
*/
|
*/
|
||||||
private BigDecimal balance;
|
private BigDecimal balance = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 冻结余额(用户购买机器完成租约所需金额)
|
* 冻结余额(用户购买机器完成租约所需金额)
|
||||||
*/
|
*/
|
||||||
private BigDecimal blockedBalance;
|
private BigDecimal blockedBalance = BigDecimal.ZERO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付地址二维码
|
* 支付地址二维码
|
||||||
|
|||||||
@@ -283,8 +283,14 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
|
|||||||
|
|
||||||
fromAddressMap.forEach((chainAndCoinKey, leaseUserWalletData) -> {
|
fromAddressMap.forEach((chainAndCoinKey, leaseUserWalletData) -> {
|
||||||
List<LeaseOrderInfo> leaseOrderInfos = collect.get(chainAndCoinKey);
|
List<LeaseOrderInfo> leaseOrderInfos = collect.get(chainAndCoinKey);
|
||||||
BigDecimal totalAmount = leaseOrderInfos.stream().map(LeaseOrderInfo::getTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
BigDecimal totalAmount = leaseOrderInfos.stream()
|
||||||
BigDecimal totalFee = leaseOrderInfos.stream().map(LeaseOrderInfo::getFee).reduce(BigDecimal.ZERO, BigDecimal::add);
|
.map(LeaseOrderInfo::getTotalPrice)
|
||||||
|
.map(price -> price != null ? price : BigDecimal.ZERO)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal totalFee = leaseOrderInfos.stream()
|
||||||
|
.map(LeaseOrderInfo::getFee)
|
||||||
|
.map(fee -> fee != null ? fee : BigDecimal.ZERO)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|
||||||
if (leaseUserWalletData.getBalance().subtract(leaseUserWalletData.getBlockedBalance()).compareTo(totalAmount.add(totalFee)) < 0){
|
if (leaseUserWalletData.getBalance().subtract(leaseUserWalletData.getBlockedBalance()).compareTo(totalAmount.add(totalFee)) < 0){
|
||||||
BigDecimal lackAmount = totalAmount.add(totalFee)
|
BigDecimal lackAmount = totalAmount.add(totalFee)
|
||||||
@@ -582,10 +588,10 @@ public class LeaseOrderInfoServiceImpl extends ServiceImpl<LeaseOrderInfoMapper,
|
|||||||
|
|
||||||
List<OrderItemDto> list = new ArrayList<>();
|
List<OrderItemDto> list = new ArrayList<>();
|
||||||
for (LeaseOrderItem leaseOrderItem : leaseOrderItems) {
|
for (LeaseOrderItem leaseOrderItem : leaseOrderItems) {
|
||||||
BigDecimal theoryPower = leaseOrderItem.getTheoryPower();
|
BigDecimal theoryPower = leaseOrderItem.getTheoryPower() != null ? leaseOrderItem.getTheoryPower() : BigDecimal.ZERO;
|
||||||
BigDecimal practicalPower = leaseOrderItem.getPracticalPower();
|
BigDecimal practicalPower = leaseOrderItem.getPracticalPower() != null ? leaseOrderItem.getPracticalPower() : BigDecimal.ZERO;
|
||||||
BigDecimal powerRatio = practicalPower.divide(theoryPower, 4, RoundingMode.HALF_UP);
|
BigDecimal powerRatio = theoryPower.compareTo(BigDecimal.ZERO) > 0 ? practicalPower.divide(theoryPower, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO;
|
||||||
BigDecimal alreadyPayRealAmount = leaseOrderItem.getAlreadyPayRealAmount();
|
BigDecimal alreadyPayRealAmount = leaseOrderItem.getAlreadyPayRealAmount() != null ? leaseOrderItem.getAlreadyPayRealAmount() : BigDecimal.ZERO;
|
||||||
|
|
||||||
orderInfoDto.setTotalTheoryPower(orderInfoDto.getTotalTheoryPower().add(theoryPower));
|
orderInfoDto.setTotalTheoryPower(orderInfoDto.getTotalTheoryPower().add(theoryPower));
|
||||||
orderInfoDto.setTotalPracticalPower(orderInfoDto.getTotalPracticalPower().add(practicalPower));
|
orderInfoDto.setTotalPracticalPower(orderInfoDto.getTotalPracticalPower().add(practicalPower));
|
||||||
|
|||||||
@@ -963,8 +963,10 @@ public class OrderAndPayTask {
|
|||||||
LeasePayRecordMessage record = recordMap.get(key);
|
LeasePayRecordMessage record = recordMap.get(key);
|
||||||
if (record != null) {
|
if (record != null) {
|
||||||
// 修改钱包的余额和冻结余额
|
// 修改钱包的余额和冻结余额
|
||||||
wallet.setBalance(wallet.getBalance().subtract(record.getRealAmount()));
|
BigDecimal realAmount = record.getRealAmount() != null ? record.getRealAmount() : BigDecimal.ZERO;
|
||||||
wallet.setBlockedBalance(wallet.getBlockedBalance().subtract(record.getBlockAmount()));
|
BigDecimal blockAmount = record.getBlockAmount() != null ? record.getBlockAmount() : BigDecimal.ZERO;
|
||||||
|
wallet.setBalance(wallet.getBalance().subtract(realAmount));
|
||||||
|
wallet.setBlockedBalance(wallet.getBlockedBalance().subtract(blockAmount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -990,7 +992,8 @@ public class OrderAndPayTask {
|
|||||||
LeasePayRecordMessage record = recordMap.get(key);
|
LeasePayRecordMessage record = recordMap.get(key);
|
||||||
if (record != null) {
|
if (record != null) {
|
||||||
// 修改钱包的余额
|
// 修改钱包的余额
|
||||||
wallet.setBalance(wallet.getBalance().add(record.getReceivedAmount()));
|
BigDecimal receivedAmount = record.getReceivedAmount() != null ? record.getReceivedAmount() : BigDecimal.ZERO;
|
||||||
|
wallet.setBalance(wallet.getBalance().add(receivedAmount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user