|
|
@@ -14,13 +14,15 @@ import com.sckw.payment.model.*;
|
|
|
import com.sckw.payment.model.constant.LedgerEnum;
|
|
|
import com.sckw.payment.model.constant.LedgerTrackEnum;
|
|
|
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.dto.*;
|
|
|
import com.sckw.payment.model.vo.req.*;
|
|
|
+import com.sckw.payment.model.vo.res.LedgerLogisticsDetailVo;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
import com.sckw.transport.api.dubbo.TransportDubboService;
|
|
|
import com.sckw.transport.api.model.dto.vo.KwtLogisticsOrderVO;
|
|
|
+import com.sckw.transport.api.model.dto.vo.LogisticsOrderVO;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
@@ -54,7 +56,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
@DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
private TransportDubboService transportDubboService;
|
|
|
|
|
|
- private void changeDict(List<LedgerLogisticsDto> list) {
|
|
|
+ private void changeDict(List<ILedger> list) {
|
|
|
List<SysDictResDto> taxRateDict = remoteSystemService.queryDictByType(DictTypeEnum.TAX_RATE.getType());
|
|
|
Map<String, String> taxRateMap = new HashMap<>();
|
|
|
Map<String, String> tradingMap = new HashMap<>();
|
|
|
@@ -66,7 +68,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
if (!CollectionUtils.isEmpty(tradingDict)) {
|
|
|
tradingMap = tradingDict.stream().collect(Collectors.toMap(SysDictResDto::getValue, SysDictResDto::getLabel, (a, b) -> a));
|
|
|
}
|
|
|
- for (LedgerLogisticsDto logisticsDto : list) {
|
|
|
+ for (ILedger logisticsDto : list) {
|
|
|
Integer trading = logisticsDto.getTrading();
|
|
|
logisticsDto.setTradingLabel(tradingMap.get(String.valueOf(trading)));
|
|
|
Integer taxRate = logisticsDto.getTaxRate();
|
|
|
@@ -76,19 +78,28 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 分页查询物流对账单列表
|
|
|
- *
|
|
|
- * @param logisticsReq 查询参数
|
|
|
- * @return
|
|
|
- */
|
|
|
- public PageRes<LedgerLogisticsDto> pageList(LogisticsReq logisticsReq) {
|
|
|
+ public PageRes<ILedger> shipperList(LogisticsReq logisticsReq) {
|
|
|
+ logisticsReq.setEntId(LoginUserHolder.getEntId());
|
|
|
+ PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
|
|
|
+ List<LedgerShipperDto> kwpLedgerLogisticsList = logisticsMapper.shipperSelect(logisticsReq);
|
|
|
+ //字典转换
|
|
|
+ if (!CollectionUtils.isEmpty(kwpLedgerLogisticsList)) {
|
|
|
+ List<ILedger> ledgerShipperDto = new ArrayList<>(kwpLedgerLogisticsList);
|
|
|
+ changeDict(ledgerShipperDto);
|
|
|
+ return new PageRes<>(new PageInfo<>(ledgerShipperDto));
|
|
|
+ }
|
|
|
+ return new PageRes<>(new PageInfo<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ public PageRes<ILedger> carrierList(LogisticsReq logisticsReq) {
|
|
|
logisticsReq.setEntId(LoginUserHolder.getEntId());
|
|
|
PageHelper.startPage(logisticsReq.getPage(), logisticsReq.getPageSize());
|
|
|
- List<LedgerLogisticsDto> kwpLedgerLogisticsList = logisticsMapper.pageSelect(logisticsReq, new ArrayList<>());
|
|
|
+ List<LedgerCarrierDto> kwpLedgerLogisticsList = logisticsMapper.carrierSelect(logisticsReq);
|
|
|
//字典转换
|
|
|
if (!CollectionUtils.isEmpty(kwpLedgerLogisticsList)) {
|
|
|
- changeDict(kwpLedgerLogisticsList);
|
|
|
+ List<ILedger> ledgerShipperDto = new ArrayList<>(kwpLedgerLogisticsList);
|
|
|
+ changeDict(ledgerShipperDto);
|
|
|
+ return new PageRes<>(new PageInfo<>(ledgerShipperDto));
|
|
|
}
|
|
|
return new PageRes<>(new PageInfo<>(kwpLedgerLogisticsList));
|
|
|
}
|
|
|
@@ -164,6 +175,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
}
|
|
|
/*保存物流订单关联数据*/
|
|
|
List<String> ids = logisticsSendReq.getIds();
|
|
|
+ //todo-xcq 校验当前订单是否已存在绑定的对账单
|
|
|
List<KwtLogisticsOrderVO> acceptCarriageOrderDetail = transportDubboService.getAcceptCarriageOrderDetail(ids);
|
|
|
if (CollectionUtils.isEmpty(acceptCarriageOrderDetail)) {
|
|
|
throw new BusinessException("未找到物流订单!");
|
|
|
@@ -187,6 +199,12 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
/*保存企业相关信息*/
|
|
|
Long checkEntId = logisticsSendReq.getCheckEntId();
|
|
|
|
|
|
+ Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(checkEntId));
|
|
|
+ EntCacheResDto entCacheResDto = entMap.get(checkEntId);
|
|
|
+ if (Objects.isNull(entCacheResDto)) {
|
|
|
+ entCacheResDto = new EntCacheResDto();
|
|
|
+ }
|
|
|
+
|
|
|
List<KwpLedgerLogisticsUnit> logisticsUnits = new ArrayList<>();
|
|
|
KwpLedgerLogisticsUnit kwpLedgerLogisticsUnit = new KwpLedgerLogisticsUnit();
|
|
|
kwpLedgerLogisticsUnit.setId(new IdWorker(1).nextId());
|
|
|
@@ -194,10 +212,10 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
kwpLedgerLogisticsUnit.setLLedgerNo(kwpLedgerLogistics.getLLedgerNo());
|
|
|
kwpLedgerLogisticsUnit.setUnitType(LogisticsUnitType.SHIPPER);
|
|
|
kwpLedgerLogisticsUnit.setEntId(checkEntId);
|
|
|
- kwpLedgerLogisticsUnit.setTopEntId(checkEntId);//todo-xcq
|
|
|
- kwpLedgerLogisticsUnit.setFirmName("");
|
|
|
- kwpLedgerLogisticsUnit.setContacts("");
|
|
|
- kwpLedgerLogisticsUnit.setPhone("");
|
|
|
+ kwpLedgerLogisticsUnit.setTopEntId(entCacheResDto.getId());
|
|
|
+ kwpLedgerLogisticsUnit.setFirmName(entCacheResDto.getFirmName());
|
|
|
+ kwpLedgerLogisticsUnit.setContacts(entCacheResDto.getContacts());
|
|
|
+ kwpLedgerLogisticsUnit.setPhone(entCacheResDto.getPhone());
|
|
|
kwpLedgerLogisticsUnit.setRemark("");
|
|
|
kwpLedgerLogisticsUnit.setStatus(0);
|
|
|
kwpLedgerLogisticsUnit.setCreateBy(LoginUserHolder.getUserId());
|
|
|
@@ -207,17 +225,22 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
kwpLedgerLogisticsUnit.setDelFlag(0);
|
|
|
|
|
|
logisticsUnits.add(kwpLedgerLogisticsUnit);
|
|
|
-
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
+ Map<Long, EntCacheResDto> entCarrierMap = remoteSystemService.queryEntTreeByIds(Collections.singletonList(entId));
|
|
|
+ EntCacheResDto entCacheResDto1 = entCarrierMap.get(entId);
|
|
|
+ if (Objects.isNull(entCacheResDto1)) {
|
|
|
+ entCacheResDto1 = new EntCacheResDto();
|
|
|
+ }
|
|
|
KwpLedgerLogisticsUnit carrierUnit = new KwpLedgerLogisticsUnit();
|
|
|
carrierUnit.setId(new IdWorker(1).nextId());
|
|
|
carrierUnit.setLLedgerId(kwpLedgerLogistics.getId());
|
|
|
carrierUnit.setLLedgerNo(kwpLedgerLogistics.getLLedgerNo());
|
|
|
carrierUnit.setUnitType(LogisticsUnitType.CARRIER);
|
|
|
- carrierUnit.setEntId(LoginUserHolder.getEntId());
|
|
|
- carrierUnit.setTopEntId(checkEntId);//todo-xcq
|
|
|
- carrierUnit.setFirmName("");
|
|
|
- carrierUnit.setContacts("");
|
|
|
- carrierUnit.setPhone("");
|
|
|
+ carrierUnit.setEntId(entId);//顶级企业id
|
|
|
+ carrierUnit.setTopEntId(entCacheResDto1.getId());//顶级企业id
|
|
|
+ carrierUnit.setFirmName(entCacheResDto1.getFirmName());
|
|
|
+ carrierUnit.setContacts(entCacheResDto1.getContacts());
|
|
|
+ carrierUnit.setPhone(entCacheResDto1.getPhone());
|
|
|
carrierUnit.setRemark("");
|
|
|
carrierUnit.setStatus(0);
|
|
|
carrierUnit.setCreateBy(LoginUserHolder.getUserId());
|
|
|
@@ -276,7 +299,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
}
|
|
|
revokeCheck(kwpLedgerLogistics.getStatus());
|
|
|
|
|
|
- kwpLedgerLogistics.setStatus(LedgerEnum.BACK.getStatus());
|
|
|
+ kwpLedgerLogistics.setStatus(LedgerEnum.REVOCATION.getStatus());
|
|
|
kwpLedgerLogistics.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
kwpLedgerLogistics.setUpdateTime(LocalDateTime.now());
|
|
|
logisticsMapper.updateById(kwpLedgerLogistics);
|
|
|
@@ -322,9 +345,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Integer confirmOrder(LedgerConfirmReq confirmReq) {
|
|
|
KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(confirmReq.getId());
|
|
|
- if (Objects.isNull(kwpLedgerLogistics)) {
|
|
|
- throw new BusinessException("对账单不存在!");
|
|
|
- }
|
|
|
+ orderCheck(kwpLedgerLogistics);
|
|
|
confirmCheck(kwpLedgerLogistics.getStatus());
|
|
|
kwpLedgerLogistics.setStatus(LedgerEnum.LEDGERED.getStatus());
|
|
|
kwpLedgerLogistics.setAuditPhone(confirmReq.getAuditPhone());
|
|
|
@@ -345,9 +366,8 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String orderSuccess(LedgerSuccessReq ledgerReq) {
|
|
|
KwpLedgerLogistics kwpLedgerLogistics = logisticsMapper.selectById(ledgerReq.getId());
|
|
|
- if (Objects.isNull(kwpLedgerLogistics)) {
|
|
|
- throw new BusinessException("对账单不存在!");
|
|
|
- }
|
|
|
+ orderCheck(kwpLedgerLogistics);
|
|
|
+
|
|
|
successCheck(kwpLedgerLogistics.getStatus());
|
|
|
|
|
|
kwpLedgerLogistics.setReceiptTime(ledgerReq.getReceiptTime());
|
|
|
@@ -370,7 +390,7 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
kwpSettlementLogistics.setSuccessUser(ledgerReq.getSuccessUser());
|
|
|
kwpSettlementLogistics.setSuccessPhone(ledgerReq.getSuccessPhone());
|
|
|
kwpSettlementLogistics.setReceiptTime(ledgerReq.getReceiptTime());
|
|
|
- kwpSettlementLogistics.setStatus(0);
|
|
|
+ kwpSettlementLogistics.setStatus(1);//1-待结算
|
|
|
kwpSettlementLogistics.setCreateBy(LoginUserHolder.getUserId());
|
|
|
kwpSettlementLogistics.setCreateTime(LocalDateTime.now());
|
|
|
kwpSettlementLogistics.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
@@ -383,8 +403,12 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
return "对账完成";
|
|
|
}
|
|
|
|
|
|
- public List<LedgerCountVo> orderCount() {
|
|
|
- Map<String, Long> map = logisticsMapper.countOrder(LoginUserHolder.getEntId());
|
|
|
+ /**
|
|
|
+ * @param unitType 1-托运方 2-承运方
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<LedgerCountVo> orderCount(Integer unitType) {
|
|
|
+ Map<String, Long> map = logisticsMapper.countOrder(LoginUserHolder.getEntId(), unitType);
|
|
|
LedgerCountVo ledgerCountVo;
|
|
|
List<LedgerCountVo> res = new ArrayList<>();
|
|
|
for (LedgerEnum value : LedgerEnum.values()) {
|
|
|
@@ -397,9 +421,53 @@ public class KwpLedgerLogisticsService extends AbsLedger {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
- public List<LedgerLogisticsDto> selectList(List<Long> ids) {
|
|
|
- List<LedgerLogisticsDto> ledgerLogisticsDto = logisticsMapper.selectIds(ids);
|
|
|
- changeDict(ledgerLogisticsDto);
|
|
|
- return ledgerLogisticsDto;
|
|
|
+ /**
|
|
|
+ * 托运方
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ILedger> selectShipperList(List<Long> ids) {
|
|
|
+ List<LedgerShipperDto> ledgerLogisticsDto = logisticsMapper.selectShipperIds(ids);
|
|
|
+ List<ILedger> ledgerLogistics = new ArrayList<>(ledgerLogisticsDto);
|
|
|
+ changeDict(ledgerLogistics);
|
|
|
+ return ledgerLogistics;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承运方
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ILedger> selectCarrierList(List<Long> ids) {
|
|
|
+ List<LedgerCarrierDto> ledgerLogisticsDto = logisticsMapper.selectCarrierIds(ids);
|
|
|
+ List<ILedger> ledgerLogistics = new ArrayList<>(ledgerLogisticsDto);
|
|
|
+ changeDict(ledgerLogistics);
|
|
|
+ return ledgerLogistics;
|
|
|
+ }
|
|
|
+
|
|
|
+ public LedgerLogisticsDetailVo queryDetail(Long id) {
|
|
|
+ LedgerLogisticsDto ledgerLogisticsDto = logisticsMapper.selectId(id);
|
|
|
+ orderCheck(ledgerLogisticsDto);
|
|
|
+ detailCheck(ledgerLogisticsDto.getStatus());
|
|
|
+
|
|
|
+ List<KwpLedgerLogisticsOrder> kwpLedgerLogisticsOrders = logisticsOrderService.queryList(ledgerLogisticsDto.getId());
|
|
|
+ LedgerLogisticsDetailVo ledgerLogisticsDetailVo = new LedgerLogisticsDetailVo();
|
|
|
+ ledgerLogisticsDetailVo.setId(ledgerLogisticsDto.getId());
|
|
|
+ ledgerLogisticsDetailVo.setLLedgerNo(ledgerLogisticsDto.getLLedgerNo());
|
|
|
+ ledgerLogisticsDetailVo.setName(ledgerLogisticsDto.getName());
|
|
|
+ ledgerLogisticsDetailVo.setFirmName(ledgerLogisticsDto.getFirmName());
|
|
|
+ ledgerLogisticsDetailVo.setTrading(ledgerLogisticsDto.getTrading());
|
|
|
+ ledgerLogisticsDetailVo.setTaxRate(ledgerLogisticsDto.getTaxRate());
|
|
|
+ ledgerLogisticsDetailVo.setTotalPrice(ledgerLogisticsDto.getTotalPrice());
|
|
|
+ ledgerLogisticsDetailVo.setActualPrice(ledgerLogisticsDto.getActualPrice());
|
|
|
+ ledgerLogisticsDetailVo.setStartTime(ledgerLogisticsDto.getStartTime());
|
|
|
+ ledgerLogisticsDetailVo.setEndTime(ledgerLogisticsDto.getEndTime());
|
|
|
+ ledgerLogisticsDetailVo.setRemark(ledgerLogisticsDto.getRemark());
|
|
|
+
|
|
|
+ List<LogisticsOrderVO> acceptCarriageOrderList = transportDubboService.getAcceptCarriageOrderList(kwpLedgerLogisticsOrders.stream().map(a -> Long.toString(a.getLOrderId())).collect(Collectors.toList()));
|
|
|
+ ledgerLogisticsDetailVo.setOrderList(acceptCarriageOrderList);
|
|
|
+ return ledgerLogisticsDetailVo;
|
|
|
}
|
|
|
}
|