换电完善
This commit is contained in:
parent
90f9d387d5
commit
c61e663fe3
@ -35,7 +35,7 @@ public class EbikeBorrowBatteryRecord implements Serializable {
|
|||||||
private Long borrowBatteryRecordId;
|
private Long borrowBatteryRecordId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 领取时间
|
* 领取数量
|
||||||
*/
|
*/
|
||||||
private Integer borrowNum;
|
private Integer borrowNum;
|
||||||
|
|
||||||
|
|||||||
@ -361,10 +361,14 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
if (record == null) {
|
if (record == null) {
|
||||||
throw new EbikeException("请领取电池后再尝试归还");
|
throw new EbikeException("请领取电池后再尝试归还");
|
||||||
}
|
}
|
||||||
|
if (batteryClaimVo.getCodes().size()!=record.getBorrowNum()){
|
||||||
|
throw new EbikeException("归还数量与领取数量不一致");
|
||||||
|
}
|
||||||
record.setIsReturn(Boolean.TRUE);
|
record.setIsReturn(Boolean.TRUE);
|
||||||
batteryRecordMapper.update(record);
|
batteryRecordMapper.update(record);
|
||||||
List<String> codes = batteryClaimVo.getCodes();
|
List<String> codes = batteryClaimVo.getCodes();
|
||||||
List<EbikeRecordCodes> list = new ArrayList<>();
|
List<EbikeRecordCodes> list = new ArrayList<>();
|
||||||
|
List<String> ecuSns = new ArrayList<>();
|
||||||
for (String code : codes) {
|
for (String code : codes) {
|
||||||
EbikeRecordCodes recordCodes = EbikeRecordCodes.builder()
|
EbikeRecordCodes recordCodes = EbikeRecordCodes.builder()
|
||||||
.batteryCode(code)
|
.batteryCode(code)
|
||||||
@ -372,10 +376,19 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
|
|||||||
.borrowBatteryRecordId(record.getBorrowBatteryRecordId())
|
.borrowBatteryRecordId(record.getBorrowBatteryRecordId())
|
||||||
.build();
|
.build();
|
||||||
list.add(recordCodes);
|
list.add(recordCodes);
|
||||||
|
if (!code.startsWith("B")) {
|
||||||
|
ecuSns.add(code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
recordCodesMapper.insertBatch(list);
|
recordCodesMapper.insertBatch(list);
|
||||||
}
|
}
|
||||||
|
if (!ecuSns.isEmpty()) {
|
||||||
|
UpdateChain.of(EbikeEcuInfo.class)
|
||||||
|
.set(EBIKE_ECU_INFO.IS_CLAIM, Boolean.FALSE)
|
||||||
|
.where(EBIKE_ECU_INFO.ECU_SN.in(ecuSns))
|
||||||
|
.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user