|
|
@@ -114,6 +114,9 @@ public class TransferServiceImpl implements ITransferService {
|
|
|
tradingBox.setTenantId(AuthUtil.getTenantId());
|
|
|
tradingBox.setStatus(0);
|
|
|
tradingBox.setPurchaseDate(new Date());
|
|
|
+ tradingBox.setUpdateTime(null);
|
|
|
+ tradingBox.setUpdateUser(null);
|
|
|
+ tradingBox.setUpdateUserName(null);
|
|
|
tradingBoxMapper.insert(tradingBox);
|
|
|
} else {
|
|
|
tradingBox.setUpdateTime(new Date());
|
|
|
@@ -261,8 +264,8 @@ public class TransferServiceImpl implements ITransferService {
|
|
|
TradingBoxFees tradingBoxFees = new TradingBoxFees();
|
|
|
tradingBoxFees.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
- if (ObjectUtils.isNull(tradingBoxItem.getPrice()) || tradingBoxItem.getPrice().equals(new BigDecimal("0"))){
|
|
|
- throw new RuntimeException("箱号:"+tradingBoxItem.getCode() + "请先维护堆存/天价格在计算费用");
|
|
|
+ if (ObjectUtils.isNull(tradingBoxItem.getPrice()) || tradingBoxItem.getPrice().equals(new BigDecimal("0"))) {
|
|
|
+ throw new RuntimeException("箱号:" + tradingBoxItem.getCode() + "请先维护堆存/天价格在计算费用");
|
|
|
}
|
|
|
tradingBoxFees.setAmount(tradingBoxItem.getPrice().multiply(BigDecimal.valueOf(days)));
|
|
|
tradingBoxFees.setPrice(tradingBoxItem.getPrice());
|
|
|
@@ -303,7 +306,7 @@ public class TransferServiceImpl implements ITransferService {
|
|
|
/*if (1 == tradingBoxFees.getFeesType()) {
|
|
|
items.setSrcFeesType("收费");
|
|
|
} else {*/
|
|
|
- items.setSrcFeesType("申请");
|
|
|
+ items.setSrcFeesType("申请");
|
|
|
// }
|
|
|
items.setSrcBoxBillType(tradingBoxFees.getBillType());
|
|
|
items.setItemType(tradingBox.getType());
|
|
|
@@ -417,7 +420,7 @@ public class TransferServiceImpl implements ITransferService {
|
|
|
tradingBoxItem.setUpdateTime(new Date());
|
|
|
tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- tradingBoxItem.setCount(tradingBoxItem.getCount()-1);
|
|
|
+ tradingBoxItem.setCount(tradingBoxItem.getCount() - 1);
|
|
|
if (tradingBoxFeesList.size() == 1) {
|
|
|
tradingBoxItem.setRentEndDate(null);
|
|
|
tradingBoxItem.setRentStartDate(tradingBoxItem.getLeaseCommencementDate());
|
|
|
@@ -439,148 +442,133 @@ public class TransferServiceImpl implements ITransferService {
|
|
|
if (ObjectUtils.isNull(codeList) || codeList.size() < 1) {
|
|
|
throw new RuntimeException("缺少必要参数");
|
|
|
}
|
|
|
- LambdaQueryWrapper<TradingBoxItem> tradingBoxItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- tradingBoxItemLambdaQueryWrapper.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
- .eq(TradingBoxItem::getCode, codeList.get(0))
|
|
|
- .eq(TradingBoxItem::getStockpilingStatus, "0");
|
|
|
- TradingBoxItem tradingBoxItemDetail = tradingBoxItemMapper.selectOne(tradingBoxItemLambdaQueryWrapper);
|
|
|
- if (ObjectUtils.isNotNull(tradingBoxItemDetail)) {
|
|
|
- TradingBox tradingBox = tradingBoxMapper.selectById(tradingBoxItemDetail.getPid());
|
|
|
- if (ObjectUtils.isNull(tradingBox)) {
|
|
|
- throw new RuntimeException("未找到单据信息");
|
|
|
- } else {
|
|
|
+ //账单数据
|
|
|
+ ApplyDTO applyDTO = new ApplyDTO();
|
|
|
+ applyDTO.setBillType("申请");
|
|
|
+ applyDTO.setTradeType("BOX");
|
|
|
+ //账单明细
|
|
|
+ List<Items> itemsList = new ArrayList<>();
|
|
|
+ for (String code : codeList) {
|
|
|
+ TradingBoxItem tradingBoxItem1 = tradingBoxItemMapper.selectListByCode(code);
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItem1)) {
|
|
|
+ tradingBoxItem1.setStockpilingStatus("1");
|
|
|
+ tradingBoxItem1.setUpdateTime(new Date());
|
|
|
+ tradingBoxItem1.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxItem1.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ int days = 0;
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItem1.getRentEndDate())) {
|
|
|
+ tradingBoxItem1.setRentStartDate(tradingBoxItem1.getRentEndDate());
|
|
|
+ days = (int) ((new Date().getTime() - tradingBoxItem1.getRentEndDate().getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ } else {
|
|
|
+ tradingBoxItem1.setRentStartDate(tradingBoxItem1.getCreateTime());
|
|
|
+ days = (int) ((new Date().getTime() - tradingBoxItem1.getCreateTime().getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
+ }
|
|
|
+ tradingBoxItem1.setRentEndDate(new Date());
|
|
|
+ tradingBoxItemMapper.updateById(tradingBoxItem1);
|
|
|
+ TradingBox tradingBox = tradingBoxMapper.selectById(tradingBoxItem1.getPid());
|
|
|
+ if (ObjectUtils.isNull(tradingBox)) {
|
|
|
+ throw new RuntimeException("未找到单据信息");
|
|
|
+ }
|
|
|
+ TradingBoxFees tradingBoxFees = new TradingBoxFees();
|
|
|
+ tradingBoxFees.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
+ tradingBoxFees.setAmount(tradingBoxItem1.getPrice().multiply(BigDecimal.valueOf(days)));
|
|
|
+ tradingBoxFees.setPrice(tradingBoxItem1.getPrice());
|
|
|
+ tradingBoxFees.setQuantity(BigDecimal.valueOf(days));
|
|
|
+ tradingBoxFees.setCurrency(tradingBoxItem1.getCurrency());
|
|
|
+ tradingBoxFees.setCode(tradingBoxItem1.getCode());
|
|
|
+ //获取费用id
|
|
|
+ R<FeesDesc> fees = feesDescClient.getFeesByName("堆存费");
|
|
|
+ if (fees.isSuccess() && fees.getData() != null) {
|
|
|
+ tradingBoxFees.setItemId(fees.getData().getId());
|
|
|
+ }
|
|
|
+ if ("DCF".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxFees.setFeesType(1);
|
|
|
+ tradingBoxFees.setBillType("堆存费");
|
|
|
+ }
|
|
|
+ tradingBoxFees.setPid(tradingBox.getId());
|
|
|
+ tradingBoxFees.setSrcOrderNo(tradingBox.getContractNo());
|
|
|
+ tradingBoxFees.setUnit(tradingBoxItem1.getBoxType());
|
|
|
+ tradingBoxFees.setExchangeRate(new BigDecimal(1));
|
|
|
+ tradingBoxFees.setRentStartDate(tradingBox.getRentStartDate());
|
|
|
+ tradingBoxFees.setRentEndDate(tradingBox.getRentCalculationDate());
|
|
|
+ tradingBoxFees.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxFees.setCreateTime(new Date());
|
|
|
+ tradingBoxFees.setTenantId(AuthUtil.getTenantId());
|
|
|
+ tradingBoxFees.setSubmitPay(1);
|
|
|
+ tradingBoxFeesMapper.insert(tradingBoxFees);
|
|
|
+
|
|
|
+ Items items = new Items();
|
|
|
+ if (1 == tradingBoxFees.getFeesType()) {
|
|
|
+ items.setSrcFeesType("收费");
|
|
|
+ } else {
|
|
|
+ items.setSrcFeesType("付费");
|
|
|
+ }
|
|
|
+ items.setSrcBoxBillType(tradingBoxFees.getBillType());
|
|
|
+ items.setItemType(tradingBox.getType());
|
|
|
+ items.setPrice(tradingBoxFees.getPrice());
|
|
|
//账单数据
|
|
|
- ApplyDTO applyDTO = new ApplyDTO();
|
|
|
- applyDTO.setBillType("申请");
|
|
|
- applyDTO.setTradeType("BOX");
|
|
|
- //账单明细
|
|
|
- List<Items> itemsList = new ArrayList<>();
|
|
|
- for (String code : codeList) {
|
|
|
- LambdaQueryWrapper<TradingBoxItem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
- .eq(TradingBoxItem::getCode, code)
|
|
|
- .eq(TradingBoxItem::getStockpilingStatus, "0");
|
|
|
- TradingBoxItem tradingBoxItem1 = tradingBoxItemMapper.selectOne(lambdaQueryWrapper);
|
|
|
- if (ObjectUtils.isNotNull()) {
|
|
|
- tradingBoxItem1.setStockpilingStatus("1");
|
|
|
- tradingBoxItem1.setUpdateTime(new Date());
|
|
|
- tradingBoxItem1.setUpdateUser(AuthUtil.getUserId());
|
|
|
- tradingBoxItem1.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- int days = 0;
|
|
|
- if (ObjectUtils.isNotNull(tradingBoxItem1.getRentEndDate())) {
|
|
|
- tradingBoxItem1.setRentStartDate(tradingBoxItem1.getRentEndDate());
|
|
|
- days = (int) ((new Date().getTime() - tradingBoxItem1.getRentEndDate().getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
- } else {
|
|
|
- tradingBoxItem1.setRentStartDate(tradingBoxItem1.getCreateTime());
|
|
|
- days = (int) ((new Date().getTime() - tradingBoxItem1.getCreateTime().getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
- }
|
|
|
- tradingBoxItem1.setRentEndDate(new Date());
|
|
|
- tradingBoxItemMapper.updateById(tradingBoxItem1);
|
|
|
- TradingBoxFees tradingBoxFees = new TradingBoxFees();
|
|
|
- tradingBoxFees.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
- tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
- tradingBoxFees.setAmount(tradingBoxItem1.getPrice().multiply(BigDecimal.valueOf(days)));
|
|
|
- tradingBoxFees.setPrice(tradingBoxItem1.getPrice());
|
|
|
- tradingBoxFees.setQuantity(BigDecimal.valueOf(days));
|
|
|
- tradingBoxFees.setCurrency(tradingBoxItem1.getCurrency());
|
|
|
- tradingBoxFees.setCode(tradingBoxItem1.getCode());
|
|
|
- //获取费用id
|
|
|
- R<FeesDesc> fees = feesDescClient.getFeesByName("堆存费");
|
|
|
- if (fees.isSuccess() && fees.getData() != null) {
|
|
|
- tradingBoxFees.setItemId(fees.getData().getId());
|
|
|
- }
|
|
|
- if ("DCF".equals(tradingBox.getType())) {
|
|
|
- tradingBoxFees.setFeesType(1);
|
|
|
- tradingBoxFees.setBillType("堆存费");
|
|
|
- }
|
|
|
- tradingBoxFees.setPid(tradingBox.getId());
|
|
|
- tradingBoxFees.setSrcOrderNo(tradingBox.getContractNo());
|
|
|
- tradingBoxFees.setUnit(tradingBoxItem1.getBoxType());
|
|
|
- tradingBoxFees.setExchangeRate(new BigDecimal(1));
|
|
|
- tradingBoxFees.setRentStartDate(tradingBox.getRentStartDate());
|
|
|
- tradingBoxFees.setRentEndDate(tradingBox.getRentCalculationDate());
|
|
|
- tradingBoxFees.setCreateUser(AuthUtil.getUserId());
|
|
|
- tradingBoxFees.setCreateTime(new Date());
|
|
|
- tradingBoxFees.setTenantId(AuthUtil.getTenantId());
|
|
|
- tradingBoxFees.setSubmitPay(1);
|
|
|
- tradingBoxFeesMapper.insert(tradingBoxFees);
|
|
|
-
|
|
|
- Items items = new Items();
|
|
|
- if (1 == tradingBoxFees.getFeesType()) {
|
|
|
- items.setSrcFeesType("收费");
|
|
|
- } else {
|
|
|
- items.setSrcFeesType("付费");
|
|
|
- }
|
|
|
- items.setSrcBoxBillType(tradingBoxFees.getBillType());
|
|
|
- items.setItemType(tradingBox.getType());
|
|
|
- items.setPrice(tradingBoxFees.getPrice());
|
|
|
- //账单数据
|
|
|
- items.setAmount(tradingBoxFees.getAmount());
|
|
|
- items.setQuantity(tradingBoxFees.getQuantity());
|
|
|
- items.setSrcOrderno(tradingBox.getContractNo());
|
|
|
- items.setCorpId(tradingBoxFees.getCorpId());
|
|
|
- items.setSrcParentId(tradingBox.getId());
|
|
|
- items.setCurrency(tradingBoxFees.getCurrency());
|
|
|
- items.setSrcType(5);
|
|
|
- items.setTradeType("BOX");
|
|
|
- items.setUnit(tradingBoxFees.getUnit());
|
|
|
- items.setSrcSysNo(tradingBoxFees.getCode());
|
|
|
- items.setRemarks(tradingBoxFees.getRemarks());
|
|
|
- items.setSrcBillNo(tradingBox.getSysNo());
|
|
|
- items.setStatusJT(0);
|
|
|
- items.setBillNo(tradingBox.getSysNo());
|
|
|
- items.setStockTime(tradingBox.getPurchaseDate());
|
|
|
- items.setRentStartDate(tradingBox.getRentStartDate());
|
|
|
- items.setRentEndDate(tradingBox.getRentCalculationDate());
|
|
|
- //获取费用id
|
|
|
- if (ObjectUtils.isNotNull(tradingBoxFees.getItemId())) {
|
|
|
- items.setCostType(tradingBoxFees.getItemId().toString());
|
|
|
- }
|
|
|
- items.setSrcFeesId(tradingBoxFees.getId());
|
|
|
- itemsList.add(items);
|
|
|
- applyDTO.setItemsList(itemsList);
|
|
|
- }
|
|
|
-
|
|
|
+ items.setAmount(tradingBoxFees.getAmount());
|
|
|
+ items.setQuantity(tradingBoxFees.getQuantity());
|
|
|
+ items.setSrcOrderno(tradingBox.getContractNo());
|
|
|
+ items.setCorpId(tradingBoxFees.getCorpId());
|
|
|
+ items.setSrcParentId(tradingBox.getId());
|
|
|
+ items.setCurrency(tradingBoxFees.getCurrency());
|
|
|
+ items.setSrcType(5);
|
|
|
+ items.setTradeType("BOX");
|
|
|
+ items.setUnit(tradingBoxFees.getUnit());
|
|
|
+ items.setSrcSysNo(tradingBoxFees.getCode());
|
|
|
+ items.setRemarks(tradingBoxFees.getRemarks());
|
|
|
+ items.setSrcBillNo(tradingBox.getSysNo());
|
|
|
+ items.setStatusJT(0);
|
|
|
+ items.setBillNo(tradingBox.getSysNo());
|
|
|
+ items.setStockTime(tradingBox.getPurchaseDate());
|
|
|
+ items.setRentStartDate(tradingBox.getRentStartDate());
|
|
|
+ items.setRentEndDate(tradingBox.getRentCalculationDate());
|
|
|
+ //获取费用id
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxFees.getItemId())) {
|
|
|
+ items.setCostType(tradingBoxFees.getItemId().toString());
|
|
|
}
|
|
|
+ items.setSrcFeesId(tradingBoxFees.getId());
|
|
|
+ itemsList.add(items);
|
|
|
+ applyDTO.setItemsList(itemsList);
|
|
|
applyDTO.setBelongCompany(tradingBox.getPurchaseCompanyName());
|
|
|
- if (CollectionUtils.isNotEmpty(itemsList)) {
|
|
|
- //生成账单
|
|
|
- R paymentApply = financeClient.paymentApplyBoxTube(applyDTO);
|
|
|
- if (!paymentApply.isSuccess()) {
|
|
|
- throw new RuntimeException(paymentApply.getMsg());
|
|
|
- }
|
|
|
- //给角色为财务的人发送消息
|
|
|
- R<String> clientDeptIds = sysClient.getRoleIds(SecureUtil.getTenantId(), "财务");
|
|
|
- if (clientDeptIds.isSuccess() && StringUtils.isNotBlank(clientDeptIds.getData())) {
|
|
|
- R<List<User>> userList = userClient.listUserByRoleId(Long.valueOf(clientDeptIds.getData()));
|
|
|
- if (userList.isSuccess() && CollectionUtils.isNotEmpty(userList.getData())) {
|
|
|
- for (User datum : userList.getData()) {
|
|
|
- //循环发送消息
|
|
|
- Message sendMessage = new Message();
|
|
|
- sendMessage.setParameter(String.valueOf(tradingBox.getId()));
|
|
|
- sendMessage.setUserName(AuthUtil.getUserName());
|
|
|
- sendMessage.setUserId(AuthUtil.getUserId());
|
|
|
- sendMessage.setToUserId(datum.getId());
|
|
|
- sendMessage.setToUserName(datum.getName());
|
|
|
- sendMessage.setMessageType(1);
|
|
|
- sendMessage.setTenantId(AuthUtil.getTenantId());
|
|
|
- sendMessage.setCreateUser(AuthUtil.getUserId());
|
|
|
- sendMessage.setCreateTime(new Date());
|
|
|
- sendMessage.setUrl(tradingBox.getUrl());
|
|
|
- sendMessage.setPageLabel(tradingBox.getPageLabel());
|
|
|
- sendMessage.setPageStatus(tradingBox.getPageStatus());
|
|
|
- sendMessage.setMessageBody("您订单" + tradingBox.getSysNo() + "审核通过,请查看");
|
|
|
- R save = messageClient.save(sendMessage);
|
|
|
- if (!save.isSuccess()) {
|
|
|
- throw new SecurityException("发送消息失败");
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(itemsList)) {
|
|
|
+ //生成账单
|
|
|
+ R paymentApply = financeClient.paymentApplyBoxTube(applyDTO);
|
|
|
+ if (!paymentApply.isSuccess()) {
|
|
|
+ throw new RuntimeException(paymentApply.getMsg());
|
|
|
+ }
|
|
|
+ //给角色为财务的人发送消息
|
|
|
+ /*R<String> clientDeptIds = sysClient.getRoleIds(SecureUtil.getTenantId(), "财务");
|
|
|
+ if (clientDeptIds.isSuccess() && StringUtils.isNotBlank(clientDeptIds.getData())) {
|
|
|
+ R<List<User>> userList = userClient.listUserByRoleId(Long.valueOf(clientDeptIds.getData()));
|
|
|
+ if (userList.isSuccess() && CollectionUtils.isNotEmpty(userList.getData())) {
|
|
|
+ for (User datum : userList.getData()) {
|
|
|
+ //循环发送消息
|
|
|
+ Message sendMessage = new Message();
|
|
|
+ sendMessage.setParameter(String.valueOf(tradingBox.getId()));
|
|
|
+ sendMessage.setUserName(AuthUtil.getUserName());
|
|
|
+ sendMessage.setUserId(AuthUtil.getUserId());
|
|
|
+ sendMessage.setToUserId(datum.getId());
|
|
|
+ sendMessage.setToUserName(datum.getName());
|
|
|
+ sendMessage.setMessageType(1);
|
|
|
+ sendMessage.setTenantId(AuthUtil.getTenantId());
|
|
|
+ sendMessage.setCreateUser(AuthUtil.getUserId());
|
|
|
+ sendMessage.setCreateTime(new Date());
|
|
|
+ sendMessage.setUrl(tradingBox.getUrl());
|
|
|
+ sendMessage.setPageLabel(tradingBox.getPageLabel());
|
|
|
+ sendMessage.setPageStatus(tradingBox.getPageStatus());
|
|
|
+ sendMessage.setMessageBody("您订单" + tradingBox.getSysNo() + "审核通过,请查看");
|
|
|
+ R save = messageClient.save(sendMessage);
|
|
|
+ if (!save.isSuccess()) {
|
|
|
+ throw new SecurityException("发送消息失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
}
|
|
|
}
|