|
|
@@ -2,8 +2,10 @@ package com.sckw.payment.service;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.utils.OrderGenerateUtils;
|
|
|
import com.sckw.payment.dao.KwpLedgerLogisticsMapper;
|
|
|
@@ -17,31 +19,60 @@ import com.sckw.payment.model.constant.LogisticsUnitType;
|
|
|
import com.sckw.payment.model.dto.LedgerCountVo;
|
|
|
import com.sckw.payment.model.dto.LedgerLogisticsDto;
|
|
|
import com.sckw.payment.model.vo.req.*;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author xucaiqin
|
|
|
* @date 2023-07-10 16:38:36
|
|
|
*/
|
|
|
@Service
|
|
|
-@AllArgsConstructor
|
|
|
@Slf4j
|
|
|
public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
- private final KwpLedgerLogisticsTrackService logisticsTrackService;
|
|
|
- private final KwpSettlementLogisticsService settlementLogisticsService;
|
|
|
- private final KwpLedgerLogisticsUnitService logisticsUnitService;
|
|
|
- private final KwpLedgerLogisticsOrderService logisticsOrderService;
|
|
|
- private final KwpLedgerLogisticsMapper logisticsMapper;
|
|
|
+ @Resource
|
|
|
+ private KwpLedgerLogisticsTrackService logisticsTrackService;
|
|
|
+ @Resource
|
|
|
+ private KwpSettlementLogisticsService settlementLogisticsService;
|
|
|
+ @Resource
|
|
|
+ private KwpLedgerLogisticsUnitService logisticsUnitService;
|
|
|
+ @Resource
|
|
|
+ private KwpLedgerLogisticsOrderService logisticsOrderService;
|
|
|
+ @Resource
|
|
|
+ private KwpLedgerLogisticsMapper logisticsMapper;
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
+ private void changeDict(List<LedgerLogisticsDto> list) {
|
|
|
+ List<SysDictResDto> taxRateDict = remoteSystemService.queryDictByType(DictTypeEnum.TAX_RATE.getType());
|
|
|
+ Map<String, String> taxRateMap = new HashMap<>();
|
|
|
+ Map<String, String> tradingMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(taxRateDict)) {
|
|
|
+ taxRateMap = taxRateDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
|
|
|
+ }
|
|
|
+ List<SysDictResDto> tradingDict = remoteSystemService.queryDictByType(DictTypeEnum.TRADE_TYPE.getType());
|
|
|
+ if (!CollectionUtils.isEmpty(tradingDict)) {
|
|
|
+ tradingMap = tradingDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
|
|
|
+ }
|
|
|
+ for (LedgerLogisticsDto logisticsDto : list) {
|
|
|
+ Integer trading = logisticsDto.getTrading();
|
|
|
+ logisticsDto.setTradingLabel(tradingMap.get(String.valueOf(trading)));
|
|
|
+ Integer taxRate = logisticsDto.getTaxRate();
|
|
|
+ logisticsDto.setTaxRateLabel(taxRateMap.get(String.valueOf(taxRate)));
|
|
|
+
|
|
|
+ logisticsDto.setStatusLabel(LedgerEnum.getDesc(logisticsDto.getStatus()));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 分页查询物流对账单列表
|
|
|
@@ -52,7 +83,10 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
public PageRes<LedgerLogisticsDto> pageList(LogisticsReq logisticsReq) {
|
|
|
PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
|
|
|
List<LedgerLogisticsDto> kwpLedgerLogisticsList = logisticsMapper.pageSelect(logisticsReq, new ArrayList<>());
|
|
|
-
|
|
|
+ //字典转换
|
|
|
+ if (!CollectionUtils.isEmpty(kwpLedgerLogisticsList)) {
|
|
|
+ changeDict(kwpLedgerLogisticsList);
|
|
|
+ }
|
|
|
return new PageRes<>(new PageInfo<>(kwpLedgerLogisticsList));
|
|
|
}
|
|
|
|
|
|
@@ -68,11 +102,13 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
if (Objects.isNull(id)) {
|
|
|
//新增
|
|
|
logisticsReq.setGenerateTime(LocalDateTime.now());
|
|
|
+ logisticsReq.setStatus(LedgerEnum.TO_LEDGER.getStatus());
|
|
|
Long aLong = saveDraft(logisticsReq);
|
|
|
logisticsTrackService.saveTrack(aLong, "", LedgerTrackEnum.TO_LEDGER);
|
|
|
} else {
|
|
|
removeDraft(id);
|
|
|
logisticsReq.setGenerateTime(LocalDateTime.now());
|
|
|
+ logisticsReq.setStatus(LedgerEnum.TO_LEDGER.getStatus());
|
|
|
Long aLong = saveDraft(logisticsReq);
|
|
|
logisticsTrackService.saveTrack(aLong, "", LedgerTrackEnum.TO_LEDGER);
|
|
|
|
|
|
@@ -93,8 +129,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
KwpLedgerLogistics kwpLedgerLogistics = new KwpLedgerLogistics();
|
|
|
kwpLedgerLogistics.setId(Objects.isNull(logisticsSendReq.getId()) ? new IdWorker(1).nextId() : logisticsSendReq.getId());
|
|
|
kwpLedgerLogistics.setEntId(0L);
|
|
|
- kwpLedgerLogistics.setLLedgerNo("");
|
|
|
- kwpLedgerLogistics.setName("");
|
|
|
+ kwpLedgerLogistics.setName(logisticsSendReq.getName());
|
|
|
kwpLedgerLogistics.setStartTime(logisticsSendReq.getStartTime());
|
|
|
kwpLedgerLogistics.setEndTime(logisticsSendReq.getEndTime());
|
|
|
kwpLedgerLogistics.setTaxRate(logisticsSendReq.getTaxRate());
|
|
|
@@ -110,13 +145,14 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
kwpLedgerLogistics.setUrl("");
|
|
|
kwpLedgerLogistics.setGenerateTime(logisticsSendReq.getGenerateTime());
|
|
|
kwpLedgerLogistics.setRemark("");
|
|
|
- kwpLedgerLogistics.setStatus(LedgerEnum.SAVE.getStatus());
|
|
|
+ kwpLedgerLogistics.setStatus(logisticsSendReq.getStatus());
|
|
|
kwpLedgerLogistics.setCreateBy(0L);
|
|
|
kwpLedgerLogistics.setCreateTime(LocalDateTime.now());
|
|
|
kwpLedgerLogistics.setUpdateBy(0L);
|
|
|
kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
|
|
|
kwpLedgerLogistics.setDelFlag(0);
|
|
|
if (Objects.isNull(logisticsSendReq.getId())) {
|
|
|
+ kwpLedgerLogistics.setLLedgerNo(OrderGenerateUtils.generateOrderNo("LL"));
|
|
|
logisticsMapper.insert(kwpLedgerLogistics);
|
|
|
} else {
|
|
|
logisticsMapper.updateById(kwpLedgerLogistics);
|
|
|
@@ -130,7 +166,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
KwpLedgerLogisticsUnit kwpLedgerLogisticsUnit = new KwpLedgerLogisticsUnit();
|
|
|
kwpLedgerLogisticsUnit.setId(new IdWorker(1).nextId());
|
|
|
kwpLedgerLogisticsUnit.setLLedgerId(kwpLedgerLogistics.getId());
|
|
|
- kwpLedgerLogisticsUnit.setLLedgerNo("");
|
|
|
+ kwpLedgerLogisticsUnit.setLLedgerNo(kwpLedgerLogistics.getLLedgerNo());
|
|
|
kwpLedgerLogisticsUnit.setUnitType(LogisticsUnitType.SHIPPER);
|
|
|
kwpLedgerLogisticsUnit.setEntId(checkEntId);
|
|
|
kwpLedgerLogisticsUnit.setTopEntId(checkEntId);//todo
|
|
|
@@ -146,6 +182,26 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
kwpLedgerLogisticsUnit.setDelFlag(0);
|
|
|
|
|
|
logisticsUnits.add(kwpLedgerLogisticsUnit);
|
|
|
+
|
|
|
+ KwpLedgerLogisticsUnit carrierUnit = new KwpLedgerLogisticsUnit();
|
|
|
+ carrierUnit.setId(new IdWorker(1).nextId());
|
|
|
+ carrierUnit.setLLedgerId(kwpLedgerLogistics.getId());
|
|
|
+ carrierUnit.setLLedgerNo(kwpLedgerLogistics.getLLedgerNo());
|
|
|
+ carrierUnit.setUnitType(LogisticsUnitType.CARRIER);
|
|
|
+ carrierUnit.setEntId(checkEntId);//todo
|
|
|
+ carrierUnit.setTopEntId(checkEntId);//todo
|
|
|
+ carrierUnit.setFirmName("");
|
|
|
+ carrierUnit.setContacts("");
|
|
|
+ carrierUnit.setPhone("");
|
|
|
+ carrierUnit.setRemark("");
|
|
|
+ carrierUnit.setStatus(0);
|
|
|
+ carrierUnit.setCreateBy(0L);
|
|
|
+ carrierUnit.setCreateTime(LocalDateTime.now());
|
|
|
+ carrierUnit.setUpdateBy(0L);
|
|
|
+ carrierUnit.setUpdateTime(LocalDateTime.now());
|
|
|
+ carrierUnit.setDelFlag(0);
|
|
|
+
|
|
|
+ logisticsUnits.add(carrierUnit);
|
|
|
logisticsUnitService.saveList(logisticsUnits);
|
|
|
return kwpLedgerLogistics.getId();
|
|
|
}
|
|
|
@@ -159,6 +215,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String sendLedgerDraft(LogisticsSendReq logisticsReq) {
|
|
|
logisticsReq.setGenerateTime(null);
|
|
|
+ logisticsReq.setStatus(LedgerEnum.SAVE.getStatus());
|
|
|
Long aLong = saveDraft(logisticsReq);
|
|
|
logisticsTrackService.saveTrack(aLong, "", LedgerTrackEnum.SAVE);
|
|
|
return "草稿保存成功";
|
|
|
@@ -221,7 +278,6 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
throw new BusinessException("对账单不存在!");
|
|
|
}
|
|
|
backCheck(kwpLedgerLogistics.getStatus());
|
|
|
- backCheck(kwpLedgerLogistics.getStatus());
|
|
|
kwpLedgerLogistics.setStatus(LedgerEnum.BACK.getStatus());
|
|
|
kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
|
|
|
logisticsMapper.updateById(kwpLedgerLogistics);
|
|
|
@@ -235,11 +291,13 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
* @param confirmReq
|
|
|
* @return
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Integer confirmOrder(LedgerConfirmReq confirmReq) {
|
|
|
KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(confirmReq.getId());
|
|
|
if (Objects.isNull(kwpLedgerLogistics)) {
|
|
|
throw new BusinessException("对账单不存在!");
|
|
|
}
|
|
|
+ confirmCheck(kwpLedgerLogistics.getStatus());
|
|
|
kwpLedgerLogistics.setStatus(LedgerEnum.LEDGERED.getStatus());
|
|
|
kwpLedgerLogistics.setAuditPhone(confirmReq.getAuditPhone());
|
|
|
kwpLedgerLogistics.setAuditUser(confirmReq.getAuditUser());
|
|
|
@@ -262,6 +320,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
throw new BusinessException("对账单不存在!");
|
|
|
}
|
|
|
successCheck(kwpLedgerLogistics.getStatus());
|
|
|
+
|
|
|
kwpLedgerLogistics.setReceiptTime(ledgerReq.getReceiptTime());
|
|
|
kwpLedgerLogistics.setStatus(LedgerEnum.SUCCESS.getStatus());
|
|
|
kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
|
|
|
@@ -307,4 +366,10 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ public List<LedgerLogisticsDto> selectList(List<Long> ids) {
|
|
|
+ List<LedgerLogisticsDto> ledgerLogisticsDto = logisticsMapper.selectIds(ids);
|
|
|
+ changeDict(ledgerLogisticsDto);
|
|
|
+ return ledgerLogisticsDto;
|
|
|
+ }
|
|
|
}
|