|
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
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.constant.Global;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
import com.sckw.core.model.vo.TableTop;
|
|
|
@@ -13,13 +14,16 @@ import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.payment.dao.KwpSettlementTradeMapper;
|
|
|
import com.sckw.payment.model.KwpSettlementTrade;
|
|
|
import com.sckw.payment.model.constant.SettlementEnum;
|
|
|
+import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
|
|
|
import com.sckw.payment.model.constant.TradeUnitType;
|
|
|
+import com.sckw.payment.model.constant.TradingEnum;
|
|
|
import com.sckw.payment.model.dto.*;
|
|
|
import com.sckw.payment.model.vo.req.SettlementTradeReq;
|
|
|
import com.sckw.payment.model.vo.res.SettlementSumVo;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -31,16 +35,22 @@ import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
+ * 贸易结算
|
|
|
* @author xucaiqin
|
|
|
* @date 2023-07-10 16:38:36
|
|
|
*/
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
public class KwpSettlementTradeService {
|
|
|
- private final KwpSettlementTradeMapper settlementTradeMapper;
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private RemoteSystemService remoteSystemService;
|
|
|
+
|
|
|
+ private final KwpSettlementTradeMapper settlementTradeMapper;
|
|
|
private final KwpLedgerTradeUnitService tradeUnitService;
|
|
|
+ @Resource
|
|
|
+ private KwpSettlementWalletService walletService;
|
|
|
+ @Resource
|
|
|
+ private KwpSettlementOfflineService offlineService;
|
|
|
|
|
|
/**
|
|
|
* 查询结算单详情
|
|
|
@@ -113,7 +123,8 @@ public class KwpSettlementTradeService {
|
|
|
settlementSellDto.setTotalPrice(settlementSellDto.changePrice(settlementTradeDto.getTotalPrice()));
|
|
|
settlementSellDto.setWaitPrice(settlementSellDto.changePrice(settlementTradeDto.getWaitPrice()));
|
|
|
UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(settlementTradeDto.getUpdateBy());
|
|
|
- settlementSellDto.setUpdateByLabel(Objects.nonNull(userCacheResDto)?userCacheResDto.getName():"");
|
|
|
+ settlementSellDto.setUpdateByLabel(Objects.nonNull(userCacheResDto) ? userCacheResDto.getName() : "");
|
|
|
+ settlementSellDto.setPercentage(settlementSellDto.changePercentage(settlementTradeDto.getActualPrice(), settlementTradeDto.getTotalPrice()));
|
|
|
res.add(settlementSellDto);
|
|
|
}
|
|
|
changeDict(res);
|
|
|
@@ -130,14 +141,15 @@ public class KwpSettlementTradeService {
|
|
|
settlementSellDto.setTotalPrice(settlementSellDto.changePrice(settlementTradeDto.getTotalPrice()));
|
|
|
settlementSellDto.setWaitPrice(settlementSellDto.changePrice(settlementTradeDto.getWaitPrice()));
|
|
|
UserCacheResDto userCacheResDto = remoteSystemService.queryUserCacheById(settlementTradeDto.getUpdateBy());
|
|
|
- settlementSellDto.setUpdateByLabel(Objects.nonNull(userCacheResDto)?userCacheResDto.getName():"");
|
|
|
+ settlementSellDto.setUpdateByLabel(Objects.nonNull(userCacheResDto) ? userCacheResDto.getName() : "");
|
|
|
+ settlementSellDto.setPercentage(settlementSellDto.changePercentage(settlementTradeDto.getActualPrice(), settlementTradeDto.getTotalPrice()));
|
|
|
res.add(settlementSellDto);
|
|
|
}
|
|
|
changeDict(res);
|
|
|
return new PageRes<>(settlementPageInfo, res);
|
|
|
}
|
|
|
}
|
|
|
- return new PageRes<>();
|
|
|
+ return new PageRes<>(settlementPageInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -212,7 +224,6 @@ public class KwpSettlementTradeService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 更新对账单
|
|
|
*
|
|
|
@@ -237,4 +248,27 @@ public class KwpSettlementTradeService {
|
|
|
.filter(a -> !Objects.equals(a.getStatus(), SettlementEnum.ALL_PAYMENT.getStatus()))
|
|
|
.map(KwpSettlementTrade::getStOrderNo).distinct().collect(Collectors.toList());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询贸易结算详情
|
|
|
+ *
|
|
|
+ * @param id 结算单id
|
|
|
+ * @param unitType 企业类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public SettlementDetailDto<SettlementTradeDto, SettlementWalletDto> queryDetail(Long id, Integer unitType) {
|
|
|
+ SettlementTradeDto settlementTradeDto = settlementTradeMapper.selectDetail(id, unitType);
|
|
|
+ if (Objects.isNull(settlementTradeDto)) {
|
|
|
+ throw new BusinessException("结算单不存在");
|
|
|
+ }
|
|
|
+ Map<String, SysDictResDto> dictResDtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.TRADE_TYPE.getType());
|
|
|
+ String trading = settlementTradeDto.getTrading();
|
|
|
+ SysDictResDto sysDictResDto = dictResDtoMap.get(trading);
|
|
|
+ if (Objects.nonNull(sysDictResDto)) {
|
|
|
+ settlementTradeDto.setTradingLabel(sysDictResDto.getLabel());
|
|
|
+ }
|
|
|
+ settlementTradeDto.setStatusLabel(SettlementEnum.getStatusDesc(settlementTradeDto.getStatus()));
|
|
|
+ List<SettlementWalletDto> settlementWallet = walletService.queryList(id, SettlementOrderTypeEnum.TRADE.getStatus(), TradingEnum.getPrefix(trading));
|
|
|
+ return new SettlementDetailDto<>(settlementTradeDto, settlementWallet);
|
|
|
+ }
|
|
|
}
|