订单电量记录
This commit is contained in:
parent
6dbe881081
commit
285a844fe8
|
@ -41,6 +41,9 @@ public class BillEleRecordConverterImpl implements BillEleRecordConverter {
|
|||
if (bill.getSuitEndTime() != null && timeEnd.isAfter(bill.getSuitEndTime())) {
|
||||
timeEnd = bill.getSuitEndTime();
|
||||
}
|
||||
if (time != null && timeEnd.isAfter(time)) {
|
||||
timeEnd = time;
|
||||
}
|
||||
|
||||
// 当前时间段的单价(元/度)
|
||||
BigDecimal price = RechargeUtils.getGearAmount(bill, chargeTime.getHour());
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.ruoyi.dashboard.domain.vo.BillCountVo;
|
|||
import com.ruoyi.iot.domain.response.CommandResponse;
|
||||
import com.ruoyi.iot.service.IotService;
|
||||
import com.ruoyi.ss.account.domain.AccountVO;
|
||||
import com.ruoyi.ss.billEleRecord.domain.BillEleRecord;
|
||||
import com.ruoyi.ss.billEleRecord.domain.BillEleRecordQuery;
|
||||
import com.ruoyi.ss.billEleRecord.service.BillEleRecordConverter;
|
||||
import com.ruoyi.ss.billEleRecord.service.BillEleRecordService;
|
||||
|
@ -1087,7 +1088,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
ServiceUtil.assertion(!TransactionBillStatus.SUCCESS.getStatus().equals(order.getStatus()), "当前订单状态不允许结束");
|
||||
ServiceUtil.assertion(device == null, "设备不存在");
|
||||
|
||||
LocalDateTime endTime = LocalDateTime.now(); // 结束使用的时间
|
||||
LocalDateTime now = LocalDateTime.now(); // 结束使用的时间
|
||||
|
||||
// 结束使用的电量:若蓝牙传过来的值为空或者小于当前电量,则使用当前电量,否则使用蓝牙传输的电量(谁大用谁)
|
||||
BigDecimal totalEle = this.calcTotalEle(device, bo.getTotalEle());
|
||||
|
@ -1098,7 +1099,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 修改结束使用的时间
|
||||
TransactionBill data = new TransactionBill();
|
||||
data.setSuitEndTime(endTime);
|
||||
data.setSuitEndTime(now);
|
||||
data.setSuitEndEle(totalEle);
|
||||
TransactionBillQuery query = new TransactionBillQuery();
|
||||
query.setBillId(order.getBillId());
|
||||
|
@ -1107,6 +1108,13 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
int update = this.updateByQuery(data, query);
|
||||
ServiceUtil.assertion(update != 1, "修改订单信息失败,请重试:" + order.getBillNo());
|
||||
|
||||
// 若是分时段电量,则记录一次电量金额
|
||||
if (SuitFeeType.TIMING_COUNT.getType().equals(order.getSuitFeeType())) {
|
||||
BillEleRecord record = billEleRecordConverter.toPo(order, device, now, now);
|
||||
int insertRecord = billEleRecordService.insertBillEleRecord(record);
|
||||
ServiceUtil.assertion(insertRecord != 1, "记录分时段订单%s用电量失败", order.getBillNo());
|
||||
}
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
|
@ -1114,7 +1122,7 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
|
||||
// 若成功,且为智能模式,则计算需要退款的金额, 若金额 > 0.01 则申请退款
|
||||
if ( success && SuitFeeMode.SMART.getMode().equals(order.getSuitFeeMode())) {
|
||||
BigDecimal refundAmount = this.calcRefundAmount(order, endTime, totalEle);
|
||||
BigDecimal refundAmount = this.calcRefundAmount(order, now, totalEle);
|
||||
if (BigDecimal.valueOf(0.01).compareTo(refundAmount) < 0) {
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
// 申请退款
|
||||
|
|
|
@ -100,7 +100,7 @@ public class BillMonitorTask {
|
|||
query.setType(TransactionBillType.RECHARGE.getType());
|
||||
query.setCreateTimeStart(DateUtils.toLocalDateTime(startTime));
|
||||
query.setIsFinished(true);
|
||||
query.setSuitFeeType(SuitFeeType.COUNT.getType());
|
||||
query.setSuitFeeTypes(SuitFeeType.rechargeEleList());
|
||||
query.setIsNullSuitEndTime(true);
|
||||
List<TransactionBillVO> list = transactionBillService.selectSmTransactionBillList(query);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user