|
|
@@ -352,7 +352,9 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
wrapper -> wrapper
|
|
|
.selectAs(DictionaryDetail::getName, SubscriptionItemListDistributeVo::getWarehouseModeCn)
|
|
|
)
|
|
|
+ .leftJoin(TextbookSubscriptionItemClass.class, TextbookSubscriptionItemClass::getTextbookSubscriptionItemId, TextbookWarehouseRecord::getDataItemId)
|
|
|
.eq(TextbookWarehouseRecord::getTextbookId, dto.getTextbookId())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getClassId()), TextbookSubscriptionItemClass::getBaseClassId, dto.getClassId())
|
|
|
.gt(TextbookWarehouseRecord::getRemainNumber, 0)
|
|
|
.orderByAsc(TextbookWarehouseRecord::getCreateDate)
|
|
|
;
|
|
|
@@ -602,6 +604,10 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
throw new MyException("第" + (i+1) + "本教材征订信息被修改,请刷新重试");
|
|
|
}
|
|
|
|
|
|
+ if((old.getInStockNum() + dto.getInNum()) < 0){
|
|
|
+ throw new MyException("第" + (i+1) + "本教材已入库数量产生负数,请输入合理的入库数量");
|
|
|
+ }
|
|
|
+
|
|
|
// 现在入库价格改动不影响征订项的价格相关属性
|
|
|
updateItem = new TextbookSubscriptionItem();
|
|
|
updateItem.setId(old.getId());
|
|
|
@@ -643,12 +649,26 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
textbookWarehouseRecordMapper.insert(textbookWarehouseRecord);
|
|
|
} else {
|
|
|
textbookWarehouseRecordId = oldTextbookWarehouseRecord.getId();
|
|
|
- textbookWarehouseRecord = BeanUtil.toBean(oldTextbookWarehouseRecord, TextbookWarehouseRecord.class);
|
|
|
- textbookWarehouseRecord.setWarehouseNumber(textbookWarehouseRecord.getWarehouseNumber() + dto.getInNum());
|
|
|
+ textbookWarehouseRecord = new TextbookWarehouseRecord();
|
|
|
+ textbookWarehouseRecord.setId(textbookWarehouseRecordId);
|
|
|
+
|
|
|
+ if(oldTextbookWarehouseRecord.getWarehouseNumber() + dto.getInNum() < 0){
|
|
|
+ throw new MyException("第" + (i+1) + "本教材已入库数量产生负数,请输入合理的入库数量");
|
|
|
+ }
|
|
|
+ textbookWarehouseRecord.setWarehouseNumber(oldTextbookWarehouseRecord.getWarehouseNumber() + dto.getInNum());
|
|
|
textbookWarehouseRecord.setTotalPrice(textbookWarehouseRecord.getSubtotal().multiply(BigDecimal.valueOf(textbookWarehouseRecord.getWarehouseNumber())));
|
|
|
- textbookWarehouseRecord.setActualWarehouseNumber(textbookWarehouseRecord.getActualWarehouseNumber() + dto.getInNum());
|
|
|
+
|
|
|
+ if(oldTextbookWarehouseRecord.getActualWarehouseNumber() + dto.getInNum() < 0){
|
|
|
+ throw new MyException("第" + (i+1) + "本教材实际入库数量产生负数,请输入合理的入库数量");
|
|
|
+ }
|
|
|
+ textbookWarehouseRecord.setActualWarehouseNumber(oldTextbookWarehouseRecord.getActualWarehouseNumber() + dto.getInNum());
|
|
|
textbookWarehouseRecord.setActualTotalPrice(textbookWarehouseRecord.getSubtotal().multiply(BigDecimal.valueOf(textbookWarehouseRecord.getActualWarehouseNumber())));
|
|
|
- textbookWarehouseRecord.setRemainNumber(textbookWarehouseRecord.getRemainNumber() + dto.getInNum());
|
|
|
+
|
|
|
+ if(oldTextbookWarehouseRecord.getRemainNumber() + dto.getInNum() < 0){
|
|
|
+ throw new MyException("第" + (i+1) + "本教材剩余库存数量产生负数,请输入合理的入库数量");
|
|
|
+ }
|
|
|
+ textbookWarehouseRecord.setRemainNumber(oldTextbookWarehouseRecord.getRemainNumber() + dto.getInNum());
|
|
|
+
|
|
|
textbookWarehouseRecord.setModifyDate(new Date());
|
|
|
textbookWarehouseRecord.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
textbookWarehouseRecordMapper.updateById(textbookWarehouseRecord);
|
|
|
@@ -662,7 +682,6 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
textbookWarehouseRecordDetail.setCreateDate(new Date());
|
|
|
textbookWarehouseRecordDetailMapper.insert(textbookWarehouseRecordDetail);
|
|
|
}
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|