|
|
@@ -28,6 +28,8 @@ import lombok.AllArgsConstructor;
|
|
|
import org.springblade.box.tube.dto.TradingBoxItemRentExcelEnter;
|
|
|
import org.springblade.box.tube.entity.*;
|
|
|
import org.springblade.box.tube.mapper.*;
|
|
|
+import org.springblade.box.tube.ocean.entity.ShippingBill;
|
|
|
+import org.springblade.box.tube.ocean.entity.ShippingFees;
|
|
|
import org.springblade.box.tube.service.ITradingBoxService;
|
|
|
import org.springblade.box.tube.service.ITransferService;
|
|
|
import org.springblade.box.tube.vo.TradingBoxVO;
|
|
|
@@ -107,6 +109,10 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
private final RedisTemplate<String, Object> redisTemplate;
|
|
|
private IRedisClient redisClient;
|
|
|
|
|
|
+ private final TransportItemFeesMapper transportItemFeesMapper;
|
|
|
+
|
|
|
+ private final TransportMapper transportMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<TradingBoxVO> selectTradingBoxPage(IPage<TradingBoxVO> page, TradingBoxVO tradingBox) {
|
|
|
return page.setRecords(baseMapper.selectTradingBoxPage(page, tradingBox));
|
|
|
@@ -131,7 +137,8 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
LambdaQueryWrapper<TradingBoxItem> tradingBoxItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
tradingBoxItemLambdaQueryWrapper.eq(TradingBoxItem::getIsDeleted, 0)
|
|
|
.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBoxItem::getPid, details.getId());
|
|
|
+ .eq(TradingBoxItem::getPid, details.getId())
|
|
|
+ .orderByDesc(TradingBoxItem::getCreateTime);
|
|
|
List<TradingBoxItem> tradingBoxItemList = tradingBoxItemMapper.selectList(tradingBoxItemLambdaQueryWrapper);
|
|
|
/*for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
//获取费用信息
|
|
|
@@ -156,7 +163,8 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
LambdaQueryWrapper<TradingBoxFees> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getIsDeleted, 0)
|
|
|
.eq(TradingBoxFees::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TradingBoxFees::getPid, details.getId());
|
|
|
+ .eq(TradingBoxFees::getPid, details.getId())
|
|
|
+ .orderByDesc(TradingBoxFees::getCreateTime);
|
|
|
List<TradingBoxFees> tradingBoxFeesList = tradingBoxFeesMapper.selectList(tradingBoxFeesLambdaQueryWrapper);
|
|
|
for (TradingBoxFees tradingBoxFees : tradingBoxFeesList) {
|
|
|
//品名
|
|
|
@@ -182,7 +190,8 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
tradingBoxFilesLambdaQueryWrapper.eq(TradingBoxFiles::getIsDeleted, 0)
|
|
|
.eq(TradingBoxFiles::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(TradingBoxFiles::getType, "1")
|
|
|
- .eq(TradingBoxFiles::getPid, details.getId());
|
|
|
+ .eq(TradingBoxFiles::getPid, details.getId())
|
|
|
+ .orderByDesc(TradingBoxFiles::getCreateTime);
|
|
|
List<TradingBoxFiles> tradingBoxFilesList = tradingBoxFilesMapper.selectList(tradingBoxFilesLambdaQueryWrapper);
|
|
|
details.setTradingBoxFilesList(tradingBoxFilesList);
|
|
|
}
|
|
|
@@ -247,7 +256,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(boxTypeNumber)){
|
|
|
+ if (ObjectUtils.isNotNull(boxTypeNumber)) {
|
|
|
tradingBox.setBoxTypeNumber(boxTypeNumber.substring(0, boxTypeNumber.length() - 1));
|
|
|
}
|
|
|
for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
@@ -303,6 +312,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
String updateChar = tradingBoxItem.getCode() + tradingBoxItem.getBoxType() + tradingBoxItem.getAddress() + tradingBoxItem.getNewDate() + tradingBoxItem.getStatus();
|
|
|
if (ObjectUtils.isNull(tradingBoxItem.getUpdateChar()) || !updateChar.equals(tradingBoxItem.getUpdateChar())) {
|
|
|
tradingBoxItem.setUpdateChar(updateChar);
|
|
|
+ tradingBoxItemMapper.updateById(tradingBoxItem);
|
|
|
if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
//更新箱档案信息
|
|
|
Archives archivesR = archivesMapper.selectOne(new LambdaQueryWrapper<Archives>().eq(Archives::getIsDeleted, 0).eq(Archives::getTenantId, AuthUtil.getTenantId()).eq(Archives::getCode, tradingBoxItem.getCode()));
|
|
|
@@ -491,7 +501,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(boxTypeNumber)){
|
|
|
+ if (ObjectUtils.isNotNull(boxTypeNumber)) {
|
|
|
tradingBox.setBoxTypeNumber(boxTypeNumber.substring(0, boxTypeNumber.length() - 1));
|
|
|
}
|
|
|
for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
@@ -504,6 +514,16 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
tradingBoxItem.setRentStartDate(tradingBoxItem.getLeaseCommencementDate());
|
|
|
}
|
|
|
if (tradingBoxItem.getId() == null) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<TradingBoxItem> tradingBoxItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ tradingBoxItemLambdaQueryWrapper.eq(TradingBoxItem::getIsDeleted,0)
|
|
|
+ .eq(TradingBoxItem::getTenantId,AuthUtil.getTenantId())
|
|
|
+ .eq(TradingBoxItem::getPid,tradingBox.getId())
|
|
|
+ .eq(TradingBoxItem::getCode,tradingBoxItem.getCode());
|
|
|
+ List<TradingBoxItem> tradingBoxItemList1 = tradingBoxItemMapper.selectList(tradingBoxItemLambdaQueryWrapper);
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItemList1) && tradingBoxItemList1.size()>0){
|
|
|
+ throw new RuntimeException("箱号:"+tradingBoxItem.getCode()+"已存在,保存失败");
|
|
|
+ }
|
|
|
if (tradingBox.getType().equals("ZR")) {
|
|
|
if (ObjectUtils.isNotNull(tradingBoxItem.getLeaseCommencementDate())) {
|
|
|
tradingBoxItem.setStatus("待使用");
|
|
|
@@ -526,6 +546,47 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
|
|
|
tradingBoxItem.setTenantId(AuthUtil.getTenantId());
|
|
|
tradingBoxItem.setPid(tradingBox.getId());
|
|
|
+
|
|
|
+ //计算租金费用
|
|
|
+ TradingBoxFees tradingBoxFees = new TradingBoxFees();
|
|
|
+ tradingBoxFees.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
+ tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
+ tradingBoxFees.setAmount(tradingBoxItem.getAmount());
|
|
|
+ tradingBoxFees.setPrice(tradingBoxItem.getAmount());
|
|
|
+ tradingBoxFees.setQuantity(BigDecimal.valueOf(tradingBoxItem.getOverdueDays()));
|
|
|
+ tradingBoxFees.setCurrency(tradingBoxItem.getCurrency());
|
|
|
+ tradingBoxFees.setCode(tradingBoxItem.getCode());
|
|
|
+ tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
+ //获取费用id
|
|
|
+ R<FeesDesc> fees = feesDescClient.getFeesByName("租金");
|
|
|
+ if (fees.isSuccess() && fees.getData() != null) {
|
|
|
+ tradingBoxFees.setItemId(fees.getData().getId());
|
|
|
+ }
|
|
|
+ if ("ZR".equals(tradingBox.getType())) {
|
|
|
+ tradingBoxFees.setFeesType(2);
|
|
|
+ tradingBoxFees.setBillType("租入");
|
|
|
+ } else {
|
|
|
+ tradingBoxFees.setFeesType(1);
|
|
|
+ tradingBoxFees.setBillType("租出");
|
|
|
+ }
|
|
|
+ tradingBoxFees.setPid(tradingBox.getId());
|
|
|
+ tradingBoxFees.setSrcOrderNo(tradingBox.getContractNo());
|
|
|
+ tradingBoxFees.setUnit(tradingBoxItem.getBoxType());
|
|
|
+ tradingBoxFees.setExchangeRate(new BigDecimal(1));
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxItem.getLeaseCommencementDate()) && ObjectUtils.isNotNull(tradingBoxItem.getOverdueDays())) {
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
+ calendar.setTime(tradingBoxItem.getLeaseCommencementDate());
|
|
|
+ calendar.add(Calendar.DATE, tradingBoxItem.getOverdueDays());
|
|
|
+ tradingBoxFees.setRentStartDate(calendar.getTime());
|
|
|
+ tradingBoxItem.setRentEndDate(calendar.getTime());
|
|
|
+ }
|
|
|
+ tradingBoxFees.setRentEndDate(tradingBox.getRentCalculationDate());
|
|
|
+ tradingBoxFees.setCreateUser(AuthUtil.getUserId());
|
|
|
+ tradingBoxFees.setCreateTime(new Date());
|
|
|
+ tradingBoxFees.setTenantId(AuthUtil.getTenantId());
|
|
|
+ tradingBoxFees.setSubmitPay(0);
|
|
|
+ tradingBoxFeesMapper.insert(tradingBoxFees);
|
|
|
+
|
|
|
tradingBoxItemMapper.insert(tradingBoxItem);
|
|
|
} else {
|
|
|
if (tradingBox.getType().equals("ZR") && "录入".equals(tradingBoxItem.getStatus())) {
|
|
|
@@ -576,6 +637,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
String updateChar = tradingBoxItem.getCode() + tradingBoxItem.getBoxType() + tradingBoxItem.getAddress() + tradingBoxItem.getNewDate() + tradingBoxItem.getStatus();
|
|
|
if (ObjectUtils.isNull(tradingBoxItem.getUpdateChar()) || !updateChar.equals(tradingBoxItem.getUpdateChar())) {
|
|
|
tradingBoxItem.setUpdateChar(updateChar);
|
|
|
+ tradingBoxItemMapper.updateById(tradingBoxItem);
|
|
|
if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
|
|
|
//更新箱档案信息
|
|
|
Archives archivesR = archivesMapper.selectOne(new LambdaQueryWrapper<Archives>().eq(Archives::getIsDeleted, 0).eq(Archives::getTenantId, AuthUtil.getTenantId()).eq(Archives::getCode, tradingBoxItem.getCode()));
|
|
|
@@ -758,7 +820,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
|
|
|
auditProecessDTO.setProcessType("租入审批");
|
|
|
|
|
|
- }else if ("ZC".equals(tradingBox.getType()) && checkFlag == 4) {
|
|
|
+ } else if ("ZC".equals(tradingBox.getType()) && checkFlag == 4) {
|
|
|
if (tradingBox.getCheckFlag() == 4 && selectTradingBox.getStatus() != 0) {
|
|
|
throw new SecurityException("订单已开启审核,请勿重复提交");
|
|
|
}
|
|
|
@@ -769,7 +831,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
|
|
|
auditProecessDTO.setProcessType("租出审批");
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
throw new SecurityException("请核失败:请核标识设置不正确");
|
|
|
}
|
|
|
|
|
|
@@ -826,6 +888,12 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
BigDecimal payAmount = new BigDecimal("0.00");
|
|
|
if (ObjectUtils.isNotNull(receivableOrderFeesList)) {
|
|
|
for (TradingBoxFees tradingBoxFees : receivableOrderFeesList) {
|
|
|
+ if (ObjectUtils.isNull(tradingBoxFees.getCorpId())) {
|
|
|
+ throw new RuntimeException("箱号:" + tradingBoxFees.getCode() + "付费对象不能为空");
|
|
|
+ }
|
|
|
+ if (0 == tradingBoxFees.getSubmitPay()) {
|
|
|
+ throw new RuntimeException("箱号:" + tradingBoxFees.getCode() + "应付费用未生成账单,操作失败");
|
|
|
+ }
|
|
|
payAmount = payAmount.add(tradingBoxFees.getPrice().multiply(tradingBoxFees.getExchangeRate(), MathContext.DECIMAL32));
|
|
|
}
|
|
|
}
|
|
|
@@ -840,6 +908,12 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
BigDecimal receivableAmount = new BigDecimal("0.00");
|
|
|
if (ObjectUtils.isNotNull(payOrderFeesList)) {
|
|
|
for (TradingBoxFees tradingBoxFees : payOrderFeesList) {
|
|
|
+ if (ObjectUtils.isNull(tradingBoxFees.getCorpId())) {
|
|
|
+ throw new RuntimeException("箱号:" + tradingBoxFees.getCode() + "收款对象不能为空");
|
|
|
+ }
|
|
|
+ if (0 == tradingBoxFees.getSubmitPay()) {
|
|
|
+ throw new RuntimeException("箱号:" + tradingBoxFees.getCode() + "应收费用未生成账单,操作失败");
|
|
|
+ }
|
|
|
receivableAmount = receivableAmount.add(tradingBoxFees.getPrice().multiply(tradingBoxFees.getExchangeRate(), MathContext.DECIMAL32));
|
|
|
}
|
|
|
}
|
|
|
@@ -881,7 +955,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
baseMapper.updateById(tradingBox);
|
|
|
|
|
|
//入库生成账单
|
|
|
- this.paymentApply(tradingBox, tradingBox.getType(), tradingBox.getType());
|
|
|
+// this.paymentApply(tradingBox, tradingBox.getType(), tradingBox.getType());
|
|
|
|
|
|
return R.success("审核通过");
|
|
|
}
|
|
|
@@ -920,7 +994,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
if (selectTradingBox == null) {
|
|
|
throw new SecurityException("撤销审核失败");
|
|
|
}
|
|
|
- //获取账单信息
|
|
|
+ /*//获取账单信息
|
|
|
Acc acc = new Acc();
|
|
|
acc.setSrcParentId(selectTradingBox.getId());
|
|
|
if ("BUY".equals(selectTradingBox.getType())) {
|
|
|
@@ -940,14 +1014,14 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
financeClient.remove(acc_.getId() + "");
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
selectTradingBox.setStatus(0);
|
|
|
selectTradingBox.setApprovalStatus("审核已撤销");
|
|
|
selectTradingBox.setUpdateTime(new Date());
|
|
|
selectTradingBox.setUpdateUser(AuthUtil.getUserId());
|
|
|
baseMapper.updateById(selectTradingBox);
|
|
|
//获取订单费用信息
|
|
|
- LambdaQueryWrapper<TradingBoxFees> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ /*LambdaQueryWrapper<TradingBoxFees> tradingBoxFeesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getIsDeleted, 0);
|
|
|
tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getPid, selectTradingBox.getId());
|
|
|
tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getTenantId, AuthUtil.getTenantId());
|
|
|
@@ -956,7 +1030,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
for (TradingBoxFees tradingBoxFees : tradingBoxFeesList) {
|
|
|
tradingBoxFees.setSubmitPay(0);
|
|
|
tradingBoxFeesMapper.updateById(tradingBoxFees);
|
|
|
- }
|
|
|
+ }*/
|
|
|
iCheckClient.deteleByBillId(tradingBox.getId());
|
|
|
return selectTradingBox;
|
|
|
}
|
|
|
@@ -1080,6 +1154,9 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
throw new RuntimeException("未查到箱信息");
|
|
|
}
|
|
|
if (tradingBox.getType().equals("ZR")) {
|
|
|
+ if (archivesR.getStatus().equals("使用")) {
|
|
|
+ throw new RuntimeException("箱号:" + archivesR.getCode() + "状态为使用中,退租失败!");
|
|
|
+ }
|
|
|
archivesR.setStatus("退租");
|
|
|
archivesR.setBoxAccessStatus("空箱离场");
|
|
|
archivesR.setUpdateTime(new Date());
|
|
|
@@ -1247,7 +1324,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
if (ObjectUtils.isNotNull(tradingBox.getRentCalculationDate()) && ObjectUtils.isNotNull(tradingBox.getRentStartDate())) {
|
|
|
days = (int) ((tradingBox.getRentCalculationDate().getTime() - tradingBox.getRentStartDate().getTime()) / (1000 * 3600 * 24)) + 1;
|
|
|
}
|
|
|
- Long pid = tradingBox.getId();
|
|
|
+ /*Long pid = tradingBox.getId();
|
|
|
|
|
|
//账单数据
|
|
|
ApplyDTO applyDTO = new ApplyDTO();
|
|
|
@@ -1259,7 +1336,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
applyDTO.setTradeType("BOX");
|
|
|
applyDTO.setBelongCompany(tradingBox.getPurchaseCompanyName());
|
|
|
//账单明细
|
|
|
- List<Items> itemsList = new ArrayList<>();
|
|
|
+ List<Items> itemsList = new ArrayList<>();*/
|
|
|
List<TradingBoxFees> tradingBoxFeesList = new ArrayList<>();
|
|
|
for (TradingBoxItem tradingBoxItem : tradingBoxItemList) {
|
|
|
TradingBoxFees tradingBoxFees = new TradingBoxFees();
|
|
|
@@ -1272,7 +1349,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
tradingBoxFees.setCode(tradingBoxItem.getCode());
|
|
|
tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
|
|
|
//获取费用id
|
|
|
- R<FeesDesc> fees = feesDescClient.getFeesByName("租金");
|
|
|
+ R<FeesDesc> fees = feesDescClient.getFeesByName("超期租金");
|
|
|
if (fees.isSuccess() && fees.getData() != null) {
|
|
|
tradingBoxFees.setItemId(fees.getData().getId());
|
|
|
}
|
|
|
@@ -1292,10 +1369,10 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
tradingBoxFees.setCreateUser(AuthUtil.getUserId());
|
|
|
tradingBoxFees.setCreateTime(new Date());
|
|
|
tradingBoxFees.setTenantId(AuthUtil.getTenantId());
|
|
|
- tradingBoxFees.setSubmitPay(1);
|
|
|
+ tradingBoxFees.setSubmitPay(0);
|
|
|
tradingBoxFeesMapper.insert(tradingBoxFees);
|
|
|
tradingBoxFeesList.add(tradingBoxFees);
|
|
|
- tradingBoxItem.setAmount(tradingBoxItem.getPrice().multiply(BigDecimal.valueOf(days)));
|
|
|
+ tradingBoxItem.setOverdueAmount(tradingBoxItem.getPrice().multiply(BigDecimal.valueOf(days)));
|
|
|
tradingBoxItem.setUpdateTime(new Date());
|
|
|
tradingBoxItem.setUpdateUser(AuthUtil.getUserId());
|
|
|
tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
|
|
|
@@ -1304,7 +1381,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
tradingBoxItem.setCount(tradingBoxItem.getCount() + 1);
|
|
|
tradingBoxItemMapper.updateById(tradingBoxItem);
|
|
|
|
|
|
- Items items = new Items();
|
|
|
+ /*Items items = new Items();
|
|
|
if (1 == tradingBoxFees.getFeesType()) {
|
|
|
items.setSrcFeesType("收费");
|
|
|
} else {
|
|
|
@@ -1337,9 +1414,9 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
}
|
|
|
items.setSrcFeesId(tradingBoxFees.getId());
|
|
|
itemsList.add(items);
|
|
|
- applyDTO.setItemsList(itemsList);
|
|
|
+ applyDTO.setItemsList(itemsList);*/
|
|
|
}
|
|
|
- if (CollectionUtils.isNotEmpty(itemsList)) {
|
|
|
+ /*if (CollectionUtils.isNotEmpty(itemsList)) {
|
|
|
//生成账单
|
|
|
R paymentApply = financeClient.paymentApplyBoxTube(applyDTO);
|
|
|
if (!paymentApply.isSuccess()) {
|
|
|
@@ -1373,7 +1450,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
tradingBox.setTradingBoxFeesList(tradingBoxFeesList);
|
|
|
return tradingBox;
|
|
|
}
|
|
|
@@ -1396,7 +1473,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
tradingBoxFeesLambdaQueryWrapper.eq(TradingBoxFees::getCode, tradingBoxItem.getCode());
|
|
|
tradingBoxFeesLambdaQueryWrapper.orderByDesc(TradingBoxFees::getCreateTime);
|
|
|
List<TradingBoxFees> tradingBoxFeesList = tradingBoxFeesMapper.selectList(tradingBoxFeesLambdaQueryWrapper);
|
|
|
- if (tradingBoxFeesList.size() > 0) {
|
|
|
+ if (tradingBoxFeesList.size() > 1) {
|
|
|
tradingBoxFeesMapper.deleteById(tradingBoxFeesList.get(0).getId());
|
|
|
//获取账单信息
|
|
|
Acc acc = new Acc();
|
|
|
@@ -1722,6 +1799,291 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
return tradingBox;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R generateBill(TradingBox tradingBoxs) {
|
|
|
+ if (tradingBoxs.getId() == null) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ if ("JK".equals(tradingBoxs.getType()) || "CK".equals(tradingBoxs.getType())){
|
|
|
+ Transport transport = transportMapper.selectById(tradingBoxs.getId());
|
|
|
+ Long pid = tradingBoxs.getId();
|
|
|
+
|
|
|
+ //账单数据
|
|
|
+ ApplyDTO applyDTO = new ApplyDTO();
|
|
|
+ if ("JKFC".equals(transport.getBillType())) {
|
|
|
+ applyDTO.setBillType("申请");
|
|
|
+ } else {
|
|
|
+ applyDTO.setBillType("收费");
|
|
|
+ }
|
|
|
+ applyDTO.setTradeType("BOX");
|
|
|
+ applyDTO.setBelongCompany(transport.getCorpName());
|
|
|
+
|
|
|
+ BigDecimal amount = BigDecimal.ZERO;//对账金额 销售订单生成的金额 销售金额-本次使用返利金额+费用明细
|
|
|
+ BigDecimal quantity = new BigDecimal("1");//对账数量 数量为 就是轮胎条数的和
|
|
|
+ BigDecimal price = BigDecimal.ZERO;//对账单价
|
|
|
+
|
|
|
+ //获取订单费用信息
|
|
|
+ List<TransportItemFees> transportItemFeesList = tradingBoxs.getTransportItemFeesList();
|
|
|
+ if (CollectionUtils.isNotEmpty(transportItemFeesList)) {
|
|
|
+ //账单明细
|
|
|
+ List<Items> itemsList = new ArrayList<>();
|
|
|
+ for (TransportItemFees tradingBoxFees : transportItemFeesList) {
|
|
|
+ Items items = new Items();
|
|
|
+ amount = tradingBoxFees.getAmount();
|
|
|
+ //计算单价
|
|
|
+ if (quantity.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ price = amount.divide(quantity, 5, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ if (1 == tradingBoxFees.getFeesType()) {
|
|
|
+ items.setSrcFeesType("收费");
|
|
|
+ } else {
|
|
|
+ items.setSrcFeesType("申请");
|
|
|
+ }
|
|
|
+ items.setSrcBoxBillType(tradingBoxFees.getBillType());
|
|
|
+ items.setItemType(transport.getBillType());
|
|
|
+ items.setPrice(price);
|
|
|
+ //账单数据
|
|
|
+ items.setAmount(amount);
|
|
|
+ items.setQuantity(quantity);
|
|
|
+ items.setCorpId(tradingBoxFees.getCorpId());
|
|
|
+ items.setSrcParentId(pid);
|
|
|
+ items.setCurrency(tradingBoxFees.getCurrency());
|
|
|
+ items.setSrcType(6);
|
|
|
+ items.setTradeType("BOX");
|
|
|
+ items.setUnit(tradingBoxFees.getUnit());
|
|
|
+ items.setRemarks(tradingBoxFees.getRemarks());
|
|
|
+ items.setStatusJT(0);
|
|
|
+ items.setStockTime(transport.getStartingRentDate());
|
|
|
+ //获取费用id
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxFees.getItemId())) {
|
|
|
+ items.setCostType(tradingBoxFees.getItemId().toString());
|
|
|
+ }
|
|
|
+ items.setSrcFeesId(tradingBoxFees.getId());
|
|
|
+
|
|
|
+ items.setSrcOrderno(transport.getContractNo());//合同号
|
|
|
+ items.setBillNo(transport.getSysNo());//系统号
|
|
|
+ items.setSrcSysNo(tradingBoxFees.getCode());//箱号
|
|
|
+ items.setSrcBillNo(transport.getBillNo());//提单号
|
|
|
+
|
|
|
+ itemsList.add(items);
|
|
|
+ applyDTO.setItemsList(itemsList);
|
|
|
+ //修改费用明细
|
|
|
+ tradingBoxFees.setSubmitPay(1);
|
|
|
+ transportItemFeesMapper.updateById(tradingBoxFees);
|
|
|
+ }
|
|
|
+ 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(pid));
|
|
|
+ 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(transport.getUrl());
|
|
|
+ sendMessage.setPageLabel(transport.getPageLabel());
|
|
|
+ sendMessage.setPageStatus(transport.getPageStatus());
|
|
|
+ sendMessage.setMessageBody("您订单" + transport.getSysNo() + "审核通过,请查看");
|
|
|
+ R save = messageClient.save(sendMessage);
|
|
|
+ if (!save.isSuccess()) {
|
|
|
+ throw new SecurityException("发送消息失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(transport);
|
|
|
+ }else{
|
|
|
+ TradingBox tradingBox = baseMapper.selectById(tradingBoxs.getId());
|
|
|
+ Long pid = tradingBoxs.getId();
|
|
|
+
|
|
|
+ //账单数据
|
|
|
+ ApplyDTO applyDTO = new ApplyDTO();
|
|
|
+ if ("ZR".equals(tradingBox.getType()) || "ZC".equals(tradingBox.getType())) {
|
|
|
+ applyDTO.setBillType("");
|
|
|
+ } else if ("BUY".equals(tradingBox.getType())) {
|
|
|
+ applyDTO.setBillType("申请");
|
|
|
+ } else if ("SELL".equals(tradingBox.getType())) {
|
|
|
+ applyDTO.setBillType("收费");
|
|
|
+ } else if ("DCF".equals(tradingBox.getType())) {
|
|
|
+ applyDTO.setBillType("申请");
|
|
|
+ }
|
|
|
+ applyDTO.setTradeType("BOX");
|
|
|
+ applyDTO.setBelongCompany(tradingBox.getPurchaseCompanyName());
|
|
|
+
|
|
|
+ BigDecimal amount = BigDecimal.ZERO;//对账金额 销售订单生成的金额 销售金额-本次使用返利金额+费用明细
|
|
|
+ BigDecimal quantity = new BigDecimal("1");//对账数量 数量为 就是轮胎条数的和
|
|
|
+ BigDecimal price = BigDecimal.ZERO;//对账单价
|
|
|
+
|
|
|
+ //获取订单费用信息
|
|
|
+ List<TradingBoxFees> tradingBoxFeesList = tradingBoxs.getTradingBoxFeesList();
|
|
|
+ if (CollectionUtils.isNotEmpty(tradingBoxFeesList)) {
|
|
|
+ //账单明细
|
|
|
+ List<Items> itemsList = new ArrayList<>();
|
|
|
+ for (TradingBoxFees tradingBoxFees : tradingBoxFeesList) {
|
|
|
+ Items items = new Items();
|
|
|
+ amount = tradingBoxFees.getAmount();
|
|
|
+ //计算单价
|
|
|
+ if (quantity.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ price = amount.divide(quantity, 5, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ if (1 == tradingBoxFees.getFeesType()) {
|
|
|
+ items.setSrcFeesType("收费");
|
|
|
+ } else {
|
|
|
+ items.setSrcFeesType("申请");
|
|
|
+ }
|
|
|
+ items.setSrcBoxBillType(tradingBoxFees.getBillType());
|
|
|
+ items.setItemType(tradingBox.getType());
|
|
|
+ items.setPrice(price);
|
|
|
+ //账单数据
|
|
|
+ items.setAmount(amount);
|
|
|
+ items.setQuantity(quantity);
|
|
|
+ items.setCorpId(tradingBoxFees.getCorpId());
|
|
|
+ items.setSrcParentId(pid);
|
|
|
+ items.setCurrency(tradingBoxFees.getCurrency());
|
|
|
+ items.setSrcType(5);
|
|
|
+ items.setTradeType("BOX");
|
|
|
+ items.setUnit(tradingBoxFees.getUnit());
|
|
|
+ items.setRemarks(tradingBoxFees.getRemarks());
|
|
|
+ items.setStatusJT(0);
|
|
|
+ items.setStockTime(tradingBox.getPurchaseDate());
|
|
|
+ //获取费用id
|
|
|
+ if (ObjectUtils.isNotNull(tradingBoxFees.getItemId())) {
|
|
|
+ items.setCostType(tradingBoxFees.getItemId().toString());
|
|
|
+ }
|
|
|
+ items.setSrcFeesId(tradingBoxFees.getId());
|
|
|
+ items.setSrcOrderno(tradingBox.getContractNo());//合同号
|
|
|
+ items.setBillNo(tradingBox.getSysNo());//系统号
|
|
|
+ items.setSrcSysNo(tradingBoxFees.getCode());//箱号
|
|
|
+ items.setSrcBillNo(null);//提单号
|
|
|
+ itemsList.add(items);
|
|
|
+ applyDTO.setItemsList(itemsList);
|
|
|
+ //修改费用明细
|
|
|
+ tradingBoxFees.setSubmitPay(1);
|
|
|
+ tradingBoxFeesMapper.updateById(tradingBoxFees);
|
|
|
+ }
|
|
|
+ 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(pid));
|
|
|
+ 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("发送消息失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(tradingBox);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R revokeBill(TradingBox tradingBox) {
|
|
|
+ if ("JKFC".equals(tradingBox.getType()) || "CKZY".equals(tradingBox.getType())){
|
|
|
+ Transport selectTransport = transportMapper.selectById(tradingBox.getId());
|
|
|
+ if (selectTransport == null) {
|
|
|
+ throw new SecurityException("撤销失败,未找到主表信息");
|
|
|
+ }
|
|
|
+ //获取账单信息
|
|
|
+ Acc acc = new Acc();
|
|
|
+ acc.setTradeType("BOX");
|
|
|
+ acc.setSrcType(6);
|
|
|
+ acc.setSrcParentId(tradingBox.getId());
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getTransportItemFeesList()) && tradingBox.getTransportItemFeesList().size() > 0) {
|
|
|
+ for (TransportItemFees transportItemFees : tradingBox.getTransportItemFeesList()) {
|
|
|
+ acc.setSrcFeesId(transportItemFees.getId());
|
|
|
+ R<List<Acc>> r = financeClient.getAccListByCondition(acc);
|
|
|
+ if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
+ for (Acc acc_ : r.getData()) {
|
|
|
+ //判断账单是否已有结算 true 不允许撤销审核 false 删除账单并撤销审核
|
|
|
+ if (!acc_.getSettlementAmount().equals(new BigDecimal("0.00"))) {
|
|
|
+ throw new SecurityException("订单已结算,不允许撤销");
|
|
|
+ } else {
|
|
|
+ financeClient.remove(acc_.getId() + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ transportItemFees.setSubmitPay(0);
|
|
|
+ transportItemFeesMapper.updateById(transportItemFees);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("撤销失败,请选择费用明细");
|
|
|
+ }
|
|
|
+ return R.data(selectTransport);
|
|
|
+ }else{
|
|
|
+ TradingBox selectTradingBox = baseMapper.selectById(tradingBox.getId());
|
|
|
+ if (selectTradingBox == null) {
|
|
|
+ throw new SecurityException("撤销失败,未找到主表信息");
|
|
|
+ }
|
|
|
+ //获取账单信息
|
|
|
+ Acc acc = new Acc();
|
|
|
+ acc.setTradeType("BOX");
|
|
|
+ acc.setSrcType(5);
|
|
|
+ acc.setSrcParentId(selectTradingBox.getId());
|
|
|
+ if (ObjectUtils.isNotNull(tradingBox.getTradingBoxFeesList()) && tradingBox.getTradingBoxFeesList().size() > 0) {
|
|
|
+ for (TradingBoxFees tradingBoxFees : tradingBox.getTradingBoxFeesList()) {
|
|
|
+ acc.setSrcFeesId(tradingBoxFees.getId());
|
|
|
+ R<List<Acc>> r = financeClient.getAccListByCondition(acc);
|
|
|
+ if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
+ for (Acc acc_ : r.getData()) {
|
|
|
+ //判断账单是否已有结算 true 不允许撤销审核 false 删除账单并撤销审核
|
|
|
+ if (!acc_.getSettlementAmount().equals(new BigDecimal("0.00"))) {
|
|
|
+ throw new SecurityException("订单已结算,不允许撤销");
|
|
|
+ } else {
|
|
|
+ financeClient.remove(acc_.getId() + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tradingBoxFees.setSubmitPay(0);
|
|
|
+ tradingBoxFeesMapper.updateById(tradingBoxFees);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("撤销失败,请选择费用明细");
|
|
|
+ }
|
|
|
+ return R.data(selectTradingBox);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 订单生成账单 并且推送财务消息
|
|
|
*
|
|
|
@@ -1735,9 +2097,9 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
|
|
|
|
|
|
//账单数据
|
|
|
ApplyDTO applyDTO = new ApplyDTO();
|
|
|
- if ("ZR".equals(billType) || "ZC".equals(billType)){
|
|
|
+ if ("ZR".equals(billType) || "ZC".equals(billType)) {
|
|
|
applyDTO.setBillType("");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
if ("BUY".equals(billType)) {
|
|
|
applyDTO.setBillType("申请");
|
|
|
} else {
|