Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanbaoming
jiedao-api-boot-master
Commits
cbedcb77
Commit
cbedcb77
authored
Feb 24, 2025
by
332784038@qq.com
Committed by
wux
Feb 27, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
汇率模块调用api逻辑修改
parent
ec0f2a79
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
43 deletions
+57
-43
ExchangeRateRespDTO.java
...udao/module/ecw/api/currency/dto/ExchangeRateRespDTO.java
+9
-1
CurrecyApiImpl.java
.../iocoder/yudao/module/ecw/service/api/CurrecyApiImpl.java
+27
-6
CurrencyRateService.java
.../module/ecw/service/currencyRate/CurrencyRateService.java
+21
-0
LadingTemplateMapper.xml
.../resources/mapper/ladingTemplate/LadingTemplateMapper.xml
+0
-12
WarehouseMapper.xml
...w-impl/src/resources/mapper/warehouse/WarehouseMapper.xml
+0
-12
ZhongPaoMapper.xml
...ecw-impl/src/resources/mapper/zhongPao/ZhongPaoMapper.xml
+0
-12
No files found.
yudao-module-ecw/yudao-module-ecw-api/src/main/java/cn/iocoder/yudao/module/ecw/api/currency/dto/ExchangeRateRespDTO.java
View file @
cbedcb77
...
...
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.ecw.api.currency.dto;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.Date
;
@Data
...
...
@@ -20,7 +21,14 @@ public class ExchangeRateRespDTO {
private
String
targetCurrencyCode
;
@ApiModelProperty
(
value
=
"汇率"
)
private
java
.
math
.
BigDecimal
currencyRate
;
private
BigDecimal
currencyRate
;
@ApiModelProperty
(
value
=
"原币种基础兑换金额"
)
private
BigDecimal
sourceCurrencyAmount
;
@ApiModelProperty
(
value
=
"目标币种基础兑换金额"
)
private
BigDecimal
targetCurrencyAmount
;
@ApiModelProperty
(
value
=
"汇率有效期"
)
private
Date
expireDate
;
}
yudao-module-ecw/yudao-module-ecw-impl/src/main/java/cn/iocoder/yudao/module/ecw/service/api/CurrecyApiImpl.java
View file @
cbedcb77
...
...
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import
cn.iocoder.yudao.module.ecw.api.currency.dto.ExchangeRateRespDTO
;
import
cn.iocoder.yudao.module.ecw.convert.currency.CurrencyConvert
;
import
cn.iocoder.yudao.module.ecw.dal.dataobject.currency.CurrencyDO
;
import
cn.iocoder.yudao.module.ecw.dal.dataobject.currencyRate.CurrencyRateDO
;
import
cn.iocoder.yudao.module.ecw.service.currency.CurrencyService
;
import
cn.iocoder.yudao.module.ecw.service.currencyRate.CurrencyRateService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -36,14 +37,24 @@ public class CurrecyApiImpl implements CurrencyApi {
@Override
public
ExchangeRateRespDTO
getCurrencyRate
(
Long
sourceId
,
Long
targetId
)
{
ExchangeRateRespDTO
dto
=
new
ExchangeRateRespDTO
();
dto
.
setSourceCurrencyId
(
sourceId
);
dto
.
setTargetCurrencyId
(
targetId
);
if
(
sourceId
==
null
||
targetId
==
null
)
{
dto
.
setCurrencyRate
(
BigDecimal
.
ZERO
);
dto
.
setSourceCurrencyAmount
(
BigDecimal
.
ZERO
);
dto
.
setTargetCurrencyAmount
(
BigDecimal
.
ZERO
);
}
else
{
dto
.
setCurrencyRate
(
sourceId
.
equals
(
targetId
)
?
BigDecimal
.
ONE
:
currencyRateService
.
rate
(
sourceId
,
targetId
));
if
(
sourceId
.
equals
(
targetId
)){
dto
.
setSourceCurrencyAmount
(
BigDecimal
.
ONE
);
dto
.
setTargetCurrencyAmount
(
BigDecimal
.
ONE
);
dto
.
setCurrencyRate
(
BigDecimal
.
ONE
);
}
else
{
CurrencyRateDO
currencyRateDO
=
currencyRateService
.
exchangeBaseValue
(
sourceId
,
targetId
);
dto
.
setSourceCurrencyAmount
(
currencyRateDO
.
getSourceAmount
());
dto
.
setTargetCurrencyAmount
(
currencyRateDO
.
getTargetAmount
());
dto
.
setCurrencyRate
(
currencyRateService
.
rate
(
currencyRateDO
.
getSourceAmount
(),
currencyRateDO
.
getTargetAmount
()));
}
}
return
dto
;
...
...
@@ -77,10 +88,20 @@ public class CurrecyApiImpl implements CurrencyApi {
if
(
sourceId
==
null
||
targetId
==
null
)
{
dto
.
setCurrencyRate
(
BigDecimal
.
ZERO
);
dto
.
setSourceCurrencyAmount
(
BigDecimal
.
ZERO
);
dto
.
setTargetCurrencyAmount
(
BigDecimal
.
ZERO
);
}
else
{
dto
.
setSourceCurrencyId
(
sourceId
.
longValue
());
dto
.
setTargetCurrencyId
(
targetId
.
longValue
());
dto
.
setCurrencyRate
(
sourceId
.
equals
(
targetId
)
?
BigDecimal
.
ONE
:
currencyRateService
.
rate
(
sourceId
,
targetId
));
if
(
sourceId
.
equals
(
targetId
)){
dto
.
setSourceCurrencyAmount
(
BigDecimal
.
ONE
);
dto
.
setTargetCurrencyAmount
(
BigDecimal
.
ONE
);
dto
.
setCurrencyRate
(
BigDecimal
.
ONE
);
}
else
{
CurrencyRateDO
currencyRateDO
=
currencyRateService
.
exchangeBaseValue
(
sourceId
,
targetId
);
dto
.
setSourceCurrencyAmount
(
currencyRateDO
.
getSourceAmount
());
dto
.
setTargetCurrencyAmount
(
currencyRateDO
.
getTargetAmount
());
dto
.
setCurrencyRate
(
currencyRateService
.
rate
(
currencyRateDO
.
getSourceAmount
(),
currencyRateDO
.
getTargetAmount
()));
}
}
return
dto
;
...
...
yudao-module-ecw/yudao-module-ecw-impl/src/main/java/cn/iocoder/yudao/module/ecw/service/currencyRate/CurrencyRateService.java
View file @
cbedcb77
...
...
@@ -52,6 +52,27 @@ public interface CurrencyRateService {
.
orElseThrow
(()
->
exception
(
CURRENCY_RATE_TOO_SMALL
));
}
/**
* 获得两个币种的兑换基础值。
*
* @param sourceId 原币种编号
* @param targetId 支付币种编号
* @return 获得两个币种的兑换基础值
* @throws ServiceException 汇率不存在或过期
*/
default
CurrencyRateDO
exchangeBaseValue
(
long
sourceId
,
long
targetId
)
throws
ServiceException
{
CurrencyRateDO
entity
=
Optional
.
ofNullable
(
find
(
sourceId
,
targetId
))
.
orElseThrow
(()
->
exception
(
CURRENCY_RATE_NOT_EXISTS
));
LocalDate
now
=
LocalDate
.
now
();
if
(
now
.
isAfter
(
entity
.
getExpiration
()))
{
throw
exception
(
CURRENCY_RATE_EXPIRED
,
String
.
valueOf
(
sourceId
),
String
.
valueOf
(
targetId
));
}
return
entity
;
}
/**
* 计算两个币种的汇率。
*
...
...
yudao-module-ecw/yudao-module-ecw-impl/src/resources/mapper/ladingTemplate/LadingTemplateMapper.xml
deleted
100644 → 0
View file @
ec0f2a79
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.iocoder.yudao.module.ecw.dal.mysql.ladingTemplate.LadingTemplateMapper"
>
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
yudao-module-ecw/yudao-module-ecw-impl/src/resources/mapper/warehouse/WarehouseMapper.xml
deleted
100644 → 0
View file @
ec0f2a79
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.iocoder.yudao.module.ecw.dal.mysql.warehouse.WarehouseMapper"
>
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
yudao-module-ecw/yudao-module-ecw-impl/src/resources/mapper/zhongPao/ZhongPaoMapper.xml
deleted
100644 → 0
View file @
ec0f2a79
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.iocoder.yudao.module.ecw.dal.mysql.zhongPao.ZhongPaoMapper"
>
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment