Commit f4f5c988 authored by 332784038@qq.com's avatar 332784038@qq.com

补充新汇率业务的货币符号代码冗余值

parent aaee2a12
......@@ -62,3 +62,11 @@ VALUES
('货币汇率日志', 'ecw:currency:rate:history', 3, 4, @parent, '', '', '', 0, '115', '2023-07-09 16:02:32', '115', '2023-07-12 22:33:09', b'0', b'0', 'history', b'0', NULL);
COMMIT;
ALTER TABLE `ecw_currency_rate` ADD COLUMN `source_currency_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '原币种代码' AFTER `source_id`;
ALTER TABLE `ecw_currency_rate` ADD COLUMN `target_currency_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '目标种代码' AFTER `target_id`;
update `ecw_currency_rate` r left join `ecw_currency` c1 on r.source_id = c1.id left join `ecw_currency` c2 on r.target_id = c2.id
set r.`source_currency_code` = c1.fuhao, r.`target_currency_code` = c2.fuhao
\ No newline at end of file
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -41,11 +42,15 @@ public class CurrencyRateDO extends BaseDO {
*/
private Long sourceId;
@ApiModelProperty(value = "原币种代码", required = true)
private String sourceCurrencyCode;
/**
* 支付币种
*/
private Long targetId;
@ApiModelProperty(value = "目标种代码", required = true)
private String targetCurrencyCode;
/**
* 原币种金额
*/
......
......@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.ecw.convert.currencyRate.CurrencyRateConvert;
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.dal.dataobject.currencyRate.CurrencyRateLogDO;
import cn.iocoder.yudao.module.ecw.dal.mysql.currencyRate.CurrencyRateLogMapper;
......@@ -44,9 +45,11 @@ public class CurrencyRateServiceImpl implements CurrencyRateService {
private CurrencyRateLogMapper logMapper;
// 检查指定币种是否存在
private void currency(long id) {
Optional.ofNullable(currencyService.getCurrency((int) id))
private String currency(long id) {
CurrencyDO currencyDO = currencyService.getCurrency((int) id);
Optional.ofNullable(currencyDO)
.orElseThrow(() -> exception(CURRENCY_NOT_EXISTS));
return currencyDO.getFuhao();
}
@Override
......@@ -61,8 +64,8 @@ public class CurrencyRateServiceImpl implements CurrencyRateService {
rate(req.getSourceAmount(), req.getTargetAmount()); // check rate
// check if currencies exist
currency(sourceId);
currency(targetId);
req.setSourceCurrencyCode(currency(sourceId));
req.setTargetCurrencyCode(currency(targetId));
if (find(sourceId, targetId) != null) {
throw exception(CURRENCY_RATE_EXISTS);
......
......@@ -20,10 +20,16 @@ public class CurrencyRateCreateReqVO {
@NotNull(message = "原币种不能为空")
private Long sourceId;
@ApiModelProperty(value = "原币种代码", required = true)
private String sourceCurrencyCode;
@ApiModelProperty(value = "支付币种", required = true)
@NotNull(message = "支付币种不能为空")
private Long targetId;
@ApiModelProperty(value = "目标种代码", required = true)
private String targetCurrencyCode;
@ApiModelProperty(value = "原币种金额", required = true)
@NotNull(message = "原币种不能为空")
@Min(0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment