Commit e9fd377772fdacce40ba2e88dafa593b3b480e2d
1 parent
421bb7d1
分销:Review代码修改
Showing
20 changed files
with
131 additions
and
102 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java
| 1 | 1 | package cn.iocoder.yudao.framework.common.util.number; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.math.Money; | |
| 3 | 4 | import cn.hutool.core.util.NumberUtil; |
| 4 | 5 | |
| 5 | 6 | import java.math.BigDecimal; |
| ... | ... | @@ -16,7 +17,7 @@ public class MoneyUtils { |
| 16 | 17 | * 计算百分比金额,四舍五入 |
| 17 | 18 | * |
| 18 | 19 | * @param price 金额 |
| 19 | - * @param rate 百分比,例如说 56.77% 则传入 56.77 | |
| 20 | + * @param rate 百分比,例如说 56.77% 则传入 56.77 | |
| 20 | 21 | * @return 百分比金额 |
| 21 | 22 | */ |
| 22 | 23 | public static Integer calculateRatePrice(Integer price, Double rate) { |
| ... | ... | @@ -27,24 +28,43 @@ public class MoneyUtils { |
| 27 | 28 | * 计算百分比金额,向下传入 |
| 28 | 29 | * |
| 29 | 30 | * @param price 金额 |
| 30 | - * @param rate 百分比,例如说 56.77% 则传入 56.77 | |
| 31 | + * @param rate 百分比,例如说 56.77% 则传入 56.77 | |
| 31 | 32 | * @return 百分比金额 |
| 32 | 33 | */ |
| 33 | 34 | public static Integer calculateRatePriceFloor(Integer price, Double rate) { |
| 34 | 35 | return calculateRatePrice(price, rate, 0, RoundingMode.FLOOR).intValue(); |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | - /** | |
| 38 | - * 计算百分比金额 | |
| 39 | - * | |
| 40 | - * @param price 金额 | |
| 41 | - * @param rate 百分比,例如说 56.77% 则传入 56.77 | |
| 42 | - * @param scale 保留小数位数 | |
| 43 | - * @param roundingMode 舍入模式 | |
| 44 | - */ | |
| 45 | - public static BigDecimal calculateRatePrice(Number price, Number rate, int scale, RoundingMode roundingMode) { | |
| 46 | - return NumberUtil.toBigDecimal(price).multiply(NumberUtil.toBigDecimal(rate)) // 乘以 | |
| 47 | - .divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100 | |
| 48 | - } | |
| 38 | + /** | |
| 39 | + * 计算百分比金额 | |
| 40 | + * | |
| 41 | + * @param price 金额 | |
| 42 | + * @param rate 百分比,例如说 56.77% 则传入 56.77 | |
| 43 | + * @param scale 保留小数位数 | |
| 44 | + * @param roundingMode 舍入模式 | |
| 45 | + */ | |
| 46 | + public static BigDecimal calculateRatePrice(Number price, Number rate, int scale, RoundingMode roundingMode) { | |
| 47 | + return NumberUtil.toBigDecimal(price).multiply(NumberUtil.toBigDecimal(rate)) // 乘以 | |
| 48 | + .divide(BigDecimal.valueOf(100), scale, roundingMode); // 除以 100 | |
| 49 | + } | |
| 49 | 50 | |
| 51 | + /** | |
| 52 | + * 分转元 | |
| 53 | + * | |
| 54 | + * @param fen 分 | |
| 55 | + * @return 元 | |
| 56 | + */ | |
| 57 | + public static BigDecimal fenToYuan(int fen) { | |
| 58 | + return new Money(0, fen).getAmount(); | |
| 59 | + } | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * 分转元(字符串) | |
| 63 | + * | |
| 64 | + * @param fen 分 | |
| 65 | + * @return 元 | |
| 66 | + */ | |
| 67 | + public static String fenToYuanStr(int fen) { | |
| 68 | + return new Money(0, fen).toString(); | |
| 69 | + } | |
| 50 | 70 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java
0 → 100644
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageWithdrawStatusEnum.java
| ... | ... | @@ -22,9 +22,6 @@ public enum BrokerageWithdrawStatusEnum implements IntArrayValuable { |
| 22 | 22 | WITHDRAW_FAIL(21, "提现失败"), |
| 23 | 23 | ; |
| 24 | 24 | |
| 25 | - // TODO @疯狂:字典现在枚举在每个模块的 DictTypeConstants 里哈;可以创建一个出来;主要是想,治理每个模块到底有多少个枚举; | |
| 26 | - public static final String DICT_TYPE = "BROKERAGE_WITHDRAW_STATUS"; | |
| 27 | - | |
| 28 | 25 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray(); |
| 29 | 26 | |
| 30 | 27 | /** | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java
| ... | ... | @@ -67,8 +67,8 @@ public class AppBrokerageUserController { |
| 67 | 67 | @Operation(summary = "绑定推广员") |
| 68 | 68 | @PreAuthenticated |
| 69 | 69 | public CommonResult<Boolean> bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) { |
| 70 | - // TODO @疯狂:是不是 isNewUser 不用传递哈,交给 service 自己计算出来? | |
| 71 | - return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId(), false)); | |
| 70 | + MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId()); | |
| 71 | + return success(brokerageUserService.bindBrokerageUser(user.getId(), reqVO.getBindUserId(), user.getCreateTime())); | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | @GetMapping("/get-summary") | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageWithdrawController.java
| ... | ... | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBro |
| 9 | 9 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; |
| 10 | 10 | import cn.iocoder.yudao.module.trade.convert.brokerage.BrokerageWithdrawConvert; |
| 11 | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; |
| 12 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 13 | 12 | import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageWithdrawService; |
| 14 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 15 | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.*; |
| 19 | 18 | |
| 20 | 19 | import javax.annotation.Resource; |
| 21 | 20 | import javax.validation.Valid; |
| 22 | -import java.util.Map; | |
| 23 | 21 | |
| 24 | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | 23 | import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; |
| ... | ... | @@ -44,10 +42,7 @@ public class AppBrokerageWithdrawController { |
| 44 | 42 | // 分页查询 |
| 45 | 43 | PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage( |
| 46 | 44 | BrokerageWithdrawConvert.INSTANCE.convert(pageReqVO, getLoginUserId())); |
| 47 | - // 拼接信息 | |
| 48 | - // TODO @疯狂:后端可以直接用 DictFrameworkUtils.getDictDataLabel() 去渲染哈;这样就不用 getDictDataLabelMap 方法了; | |
| 49 | - Map<String, String> statusNameMap = dictDataApi.getDictDataLabelMap(BrokerageWithdrawStatusEnum.DICT_TYPE); | |
| 50 | - return success(BrokerageWithdrawConvert.INSTANCE.convertPage02(pageResult, statusNameMap)); | |
| 45 | + return success(BrokerageWithdrawConvert.INSTANCE.convertPage03(pageResult)); | |
| 51 | 46 | } |
| 52 | 47 | |
| 53 | 48 | @PostMapping("/create") | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.app.config; |
| 3 | 3 | import cn.hutool.core.util.ObjUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; |
| 6 | +import cn.iocoder.yudao.module.trade.convert.config.TradeConfigConvert; | |
| 6 | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; |
| 7 | 8 | import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; |
| 8 | 9 | import io.swagger.v3.oas.annotations.Operation; |
| ... | ... | @@ -33,13 +34,7 @@ public class AppTradeConfigController { |
| 33 | 34 | @Operation(summary = "获得交易配置") |
| 34 | 35 | public CommonResult<AppTradeConfigRespVO> getTradeConfig() { |
| 35 | 36 | TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO()); |
| 36 | - // TODO @疯狂:是不是直接 convert 就好啦; | |
| 37 | - AppTradeConfigRespVO respVO = new AppTradeConfigRespVO() | |
| 38 | - .setBrokeragePosterUrls(tradeConfig.getBrokeragePostUrls()) | |
| 39 | - .setBrokerageFrozenDays(tradeConfig.getBrokerageFrozenDays()) | |
| 40 | - .setBrokerageWithdrawMinPrice(tradeConfig.getBrokerageWithdrawMinPrice()) | |
| 41 | - .setBrokerageWithdrawType(tradeConfig.getBrokerageWithdrawType()); | |
| 42 | - return success(respVO); | |
| 37 | + return success(TradeConfigConvert.INSTANCE.convert02(tradeConfig)); | |
| 43 | 38 | } |
| 44 | 39 | |
| 45 | 40 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageRecordConvert.java
| ... | ... | @@ -4,6 +4,7 @@ import cn.hutool.core.math.Money; |
| 4 | 4 | import cn.hutool.core.util.ObjectUtil; |
| 5 | 5 | import cn.hutool.core.util.StrUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | +import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; | |
| 7 | 8 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 8 | 9 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordPageReqVO; |
| 9 | 10 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.record.BrokerageRecordRespVO; |
| ... | ... | @@ -51,7 +52,7 @@ public interface BrokerageRecordConvert { |
| 51 | 52 | .setBizType(bizType.getType()).setBizId(bizId) |
| 52 | 53 | .setPrice(brokeragePrice).setTotalPrice(user.getBrokeragePrice()) |
| 53 | 54 | .setTitle(title) |
| 54 | - .setDescription(StrUtil.format(bizType.getDescription(), new Money(0, Math.abs(brokeragePrice)))) | |
| 55 | + .setDescription(StrUtil.format(bizType.getDescription(), MoneyUtils.fenToYuanStr(Math.abs(brokeragePrice)))) | |
| 55 | 56 | .setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime) |
| 56 | 57 | .setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId); |
| 57 | 58 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/BrokerageWithdrawConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.convert.brokerage; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.map.MapUtil; | |
| 4 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; | |
| 5 | 5 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 6 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawPageReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.withdraw.BrokerageWithdrawRespVO; |
| ... | ... | @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBro |
| 9 | 9 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawPageReqVO; |
| 10 | 10 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.withdraw.AppBrokerageWithdrawRespVO; |
| 11 | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageWithdrawDO; |
| 12 | +import cn.iocoder.yudao.module.trade.enums.DictTypeConstants; | |
| 12 | 13 | import org.mapstruct.Mapper; |
| 13 | 14 | import org.mapstruct.factory.Mappers; |
| 14 | 15 | |
| ... | ... | @@ -44,10 +45,10 @@ public interface BrokerageWithdrawConvert { |
| 44 | 45 | |
| 45 | 46 | PageResult<AppBrokerageWithdrawRespVO> convertPage02(PageResult<BrokerageWithdrawDO> pageResult); |
| 46 | 47 | |
| 47 | - default PageResult<AppBrokerageWithdrawRespVO> convertPage02(PageResult<BrokerageWithdrawDO> pageResult, Map<String, String> statusNameMap) { | |
| 48 | + default PageResult<AppBrokerageWithdrawRespVO> convertPage03(PageResult<BrokerageWithdrawDO> pageResult) { | |
| 48 | 49 | PageResult<AppBrokerageWithdrawRespVO> result = convertPage02(pageResult); |
| 49 | 50 | for (AppBrokerageWithdrawRespVO vo : result.getList()) { |
| 50 | - vo.setStatusName(MapUtil.getStr(statusNameMap, String.valueOf(vo.getStatus()), "")); | |
| 51 | + vo.setStatusName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BROKERAGE_WITHDRAW_STATUS, vo.getStatus())); | |
| 51 | 52 | } |
| 52 | 53 | return result; |
| 53 | 54 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/config/TradeConfigConvert.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.convert.config; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigRespVO; |
| 4 | 4 | import cn.iocoder.yudao.module.trade.controller.admin.config.vo.TradeConfigSaveReqVO; |
| 5 | +import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; | |
| 5 | 6 | import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; |
| 6 | 7 | import org.mapstruct.Mapper; |
| 7 | 8 | import org.mapstruct.factory.Mappers; |
| ... | ... | @@ -20,4 +21,5 @@ public interface TradeConfigConvert { |
| 20 | 21 | |
| 21 | 22 | TradeConfigRespVO convert(TradeConfigDO bean); |
| 22 | 23 | |
| 24 | + AppTradeConfigRespVO convert02(TradeConfigDO tradeConfig); | |
| 23 | 25 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.brokerage; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.hutool.core.math.Money; | |
| 5 | 4 | import cn.hutool.core.util.ArrayUtil; |
| 6 | 5 | import cn.hutool.core.util.BooleanUtil; |
| 7 | 6 | import cn.hutool.core.util.ObjectUtil; |
| ... | ... | @@ -240,7 +239,6 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { |
| 240 | 239 | return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); |
| 241 | 240 | } |
| 242 | 241 | |
| 243 | - // TODO @疯狂:这个求出来,应该是不准的?例如说超过 100+ 名后? | |
| 244 | 242 | @Override |
| 245 | 243 | public Integer getUserRankByPrice(Long userId, LocalDateTime[] times) { |
| 246 | 244 | AppBrokerageUserRankPageReqVO pageParam = new AppBrokerageUserRankPageReqVO().setTimes(times); |
| ... | ... | @@ -261,15 +259,14 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { |
| 261 | 259 | int balance = Optional.of(user) |
| 262 | 260 | .map(BrokerageUserDO::getBrokeragePrice).orElse(0); |
| 263 | 261 | if (balance + brokeragePrice < 0) { |
| 264 | - // TODO @疯狂:要不 MoneyUtils 那,统一搞个 format 金额的方法?然后把分到元的字符串,统一收口掉; | |
| 265 | - throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance)); | |
| 262 | + throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); | |
| 266 | 263 | } |
| 267 | 264 | |
| 268 | 265 | // 2. 更新佣金余额 |
| 269 | 266 | boolean success = brokerageUserService.updateUserPrice(userId, brokeragePrice); |
| 270 | 267 | if (!success) { |
| 271 | 268 | // 失败时,则抛出异常。只会出现扣减佣金时,余额不足的情况 |
| 272 | - throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance)); | |
| 269 | + throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, MoneyUtils.fenToYuanStr(balance)); | |
| 273 | 270 | } |
| 274 | 271 | |
| 275 | 272 | // 3. 新增记录 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java
| ... | ... | @@ -187,7 +187,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 187 | 187 | /** |
| 188 | 188 | * 补全绑定用户的字段 |
| 189 | 189 | * |
| 190 | - * @param bindUserId 绑定的用户编号 | |
| 190 | + * @param bindUserId 绑定的用户编号 | |
| 191 | 191 | * @param brokerageUser update 对象 |
| 192 | 192 | * @return 补全后的 update 对象 |
| 193 | 193 | */ |
| ... | ... | @@ -261,12 +261,15 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // 下级不能绑定自己的上级 |
| 264 | - // TODO @疯狂:这里是不是查询不到的时候,应该有个 break 结束循环哈 | |
| 265 | 264 | for (int i = 0; i <= Short.MAX_VALUE; i++) { |
| 266 | 265 | if (Objects.equals(bindUser.getBindUserId(), user.getId())) { |
| 267 | 266 | throw exception(BROKERAGE_BIND_LOOP); |
| 268 | 267 | } |
| 269 | 268 | bindUser = getBrokerageUser(bindUser.getBindUserId()); |
| 269 | + // 找到根节点,结束循环 | |
| 270 | + if (bindUser == null || bindUser.getBindUserId() == null) { | |
| 271 | + break; | |
| 272 | + } | |
| 270 | 273 | } |
| 271 | 274 | } |
| 272 | 275 | |
| ... | ... | @@ -274,8 +277,8 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 274 | 277 | * 根据绑定用户编号,获得绑定用户编号列表 |
| 275 | 278 | * |
| 276 | 279 | * @param bindUserId 绑定用户编号 |
| 277 | - * @param level 绑定用户的层级。 | |
| 278 | - * 如果 level 为空,则查询 1+2 两个层级 | |
| 280 | + * @param level 绑定用户的层级。 | |
| 281 | + * 如果 level 为空,则查询 1+2 两个层级 | |
| 279 | 282 | * @return 绑定用户编号列表 |
| 280 | 283 | */ |
| 281 | 284 | private List<Long> buildBindUserIdsByLevel(Long bindUserId, Integer level) { | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java
| ... | ... | @@ -93,7 +93,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 93 | 93 | // 4. 通知用户 |
| 94 | 94 | Map<String, Object> templateParams = MapUtil.<String, Object>builder() |
| 95 | 95 | .put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime())) |
| 96 | - .put("price", new Money(0, withdraw.getPrice()).toString()) | |
| 96 | + .put("price", MoneyUtils.fenToYuanStr(withdraw.getPrice())) | |
| 97 | 97 | .put("reason", withdraw.getAuditReason()) |
| 98 | 98 | .build(); |
| 99 | 99 | NotifySendSingleToUserReqDTO reqDTO = new NotifySendSingleToUserReqDTO() |
| ... | ... | @@ -170,7 +170,7 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 170 | 170 | TradeConfigDO validateWithdrawPrice(Integer withdrawPrice) { |
| 171 | 171 | TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); |
| 172 | 172 | if (tradeConfig.getBrokerageWithdrawMinPrice() != null && withdrawPrice < tradeConfig.getBrokerageWithdrawMinPrice()) { |
| 173 | - throw exception(BROKERAGE_WITHDRAW_MIN_PRICE, new Money(0, tradeConfig.getBrokerageWithdrawMinPrice())); | |
| 173 | + throw exception(BROKERAGE_WITHDRAW_MIN_PRICE, MoneyUtils.fenToYuanStr(tradeConfig.getBrokerageWithdrawMinPrice())); | |
| 174 | 174 | } |
| 175 | 175 | return tradeConfig; |
| 176 | 176 | } | ... | ... |
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java
| ... | ... | @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.member.api.user.dto; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 6 | 8 | /** |
| 7 | 9 | * 用户信息 Response DTO |
| 8 | 10 | * |
| ... | ... | @@ -33,6 +35,10 @@ public class MemberUserRespDTO { |
| 33 | 35 | * 手机 |
| 34 | 36 | */ |
| 35 | 37 | private String mobile; |
| 38 | + /** | |
| 39 | + * 创建时间 | |
| 40 | + */ | |
| 41 | + private LocalDateTime createTime; | |
| 36 | 42 | |
| 37 | 43 | // ========== 其它信息 ========== |
| 38 | 44 | ... | ... |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java
| ... | ... | @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.system.api.dict; |
| 3 | 3 | import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; |
| 4 | 4 | |
| 5 | 5 | import java.util.Collection; |
| 6 | -import java.util.List; | |
| 7 | -import java.util.Map; | |
| 8 | 6 | |
| 9 | 7 | /** |
| 10 | 8 | * 字典数据 API 接口 |
| ... | ... | @@ -19,40 +17,23 @@ public interface DictDataApi { |
| 19 | 17 | * 2. 字典数据被禁用 |
| 20 | 18 | * |
| 21 | 19 | * @param dictType 字典类型 |
| 22 | - * @param values 字典数据值的数组 | |
| 20 | + * @param values 字典数据值的数组 | |
| 23 | 21 | */ |
| 24 | 22 | void validateDictDataList(String dictType, Collection<String> values); |
| 25 | 23 | |
| 26 | 24 | /** |
| 27 | 25 | * 获得指定的字典数据,从缓存中 |
| 28 | 26 | * |
| 29 | - * @param type 字典类型 | |
| 27 | + * @param type 字典类型 | |
| 30 | 28 | * @param value 字典数据值 |
| 31 | 29 | * @return 字典数据 |
| 32 | 30 | */ |
| 33 | 31 | DictDataRespDTO getDictData(String type, String value); |
| 34 | 32 | |
| 35 | 33 | /** |
| 36 | - * 获得指定类型的字典数据,从缓存中 | |
| 37 | - * | |
| 38 | - * @param type 字典类型 | |
| 39 | - * @return 字典数据 | |
| 40 | - */ | |
| 41 | - List<DictDataRespDTO> getDictDataList(String type); | |
| 42 | - | |
| 43 | - /** | |
| 44 | - * 获得指定类型的字典数据 标签字典,从缓存中 | |
| 45 | - * key:value, value: label | |
| 46 | - * | |
| 47 | - * @param type 字典类型 | |
| 48 | - * @return 字典数据 | |
| 49 | - */ | |
| 50 | - Map<String, String> getDictDataLabelMap(String type); | |
| 51 | - | |
| 52 | - /** | |
| 53 | 34 | * 解析获得指定的字典数据,从缓存中 |
| 54 | 35 | * |
| 55 | - * @param type 字典类型 | |
| 36 | + * @param type 字典类型 | |
| 56 | 37 | * @param label 字典数据标签 |
| 57 | 38 | * @return 字典数据 |
| 58 | 39 | */ | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.system.api.dict; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; |
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO; | |
| 5 | 4 | import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert; |
| 6 | 5 | import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; |
| 7 | 6 | import cn.iocoder.yudao.module.system.service.dict.DictDataService; |
| ... | ... | @@ -9,10 +8,6 @@ import org.springframework.stereotype.Service; |
| 9 | 8 | |
| 10 | 9 | import javax.annotation.Resource; |
| 11 | 10 | import java.util.Collection; |
| 12 | -import java.util.List; | |
| 13 | -import java.util.Map; | |
| 14 | - | |
| 15 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | |
| 16 | 11 | |
| 17 | 12 | /** |
| 18 | 13 | * 字典数据 API 实现类 |
| ... | ... | @@ -37,19 +32,6 @@ public class DictDataApiImpl implements DictDataApi { |
| 37 | 32 | } |
| 38 | 33 | |
| 39 | 34 | @Override |
| 40 | - public List<DictDataRespDTO> getDictDataList(String type) { | |
| 41 | - // TODO @疯狂:不用 DictDataExportReqVO 哈;可以考虑直接加个允许传递 type 传递的 | |
| 42 | - List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(type)); | |
| 43 | - return DictDataConvert.INSTANCE.convertList04(list); | |
| 44 | - } | |
| 45 | - | |
| 46 | - @Override | |
| 47 | - public Map<String, String> getDictDataLabelMap(String type) { | |
| 48 | - List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(type)); | |
| 49 | - return convertMap(list, DictDataDO::getValue, DictDataDO::getLabel); | |
| 50 | - } | |
| 51 | - | |
| 52 | - @Override | |
| 53 | 35 | public DictDataRespDTO parseDictData(String dictType, String label) { |
| 54 | 36 | DictDataDO dictData = dictDataService.parseDictData(dictType, label); |
| 55 | 37 | return DictDataConvert.INSTANCE.convert02(dictData); | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java
| 1 | 1 | package cn.iocoder.yudao.module.system.controller.app.dict; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataExportReqVO; | |
| 5 | 4 | import cn.iocoder.yudao.module.system.controller.app.dict.vo.AppDictDataRespVO; |
| 6 | 5 | import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert; |
| 7 | 6 | import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; |
| 8 | 7 | import cn.iocoder.yudao.module.system.service.dict.DictDataService; |
| 9 | 8 | import io.swagger.v3.oas.annotations.Operation; |
| 9 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 10 | 10 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | 11 | import org.springframework.validation.annotation.Validated; |
| 12 | 12 | import org.springframework.web.bind.annotation.GetMapping; |
| 13 | -import org.springframework.web.bind.annotation.PathVariable; | |
| 14 | 13 | import org.springframework.web.bind.annotation.RequestMapping; |
| 14 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 15 | 15 | import org.springframework.web.bind.annotation.RestController; |
| 16 | 16 | |
| 17 | 17 | import javax.annotation.Resource; |
| ... | ... | @@ -28,11 +28,11 @@ public class AppDictDataController { |
| 28 | 28 | @Resource |
| 29 | 29 | private DictDataService dictDataService; |
| 30 | 30 | |
| 31 | - // TODO @疯狂:暂时不用 path 参数哈;主要考虑一些中间件支持的一般,例如说链路追踪之类的;还是作为一个参数噶; | |
| 32 | - @GetMapping("/type/{dictType}") | |
| 31 | + @GetMapping("/type") | |
| 33 | 32 | @Operation(summary = "根据字典类型查询字典数据信息") |
| 34 | - public CommonResult<List<AppDictDataRespVO>> getDictDataList(@PathVariable String dictType) { | |
| 35 | - List<DictDataDO> list = dictDataService.getDictDataList(new DictDataExportReqVO().setDictType(dictType)); | |
| 33 | + @Parameter(name = "type", description = "字典类型", required = true, example = "common_status") | |
| 34 | + public CommonResult<List<AppDictDataRespVO>> getDictDataListByType(@RequestParam String type) { | |
| 35 | + List<DictDataDO> list = dictDataService.getEnabledDictDataListByType(type); | |
| 36 | 36 | return success(DictDataConvert.INSTANCE.convertList03(list)); |
| 37 | 37 | } |
| 38 | 38 | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/vo/AppDictDataRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.system.controller.app.dict.vo; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataBaseVO; | |
| 4 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 4 | import lombok.AllArgsConstructor; |
| 6 | 5 | import lombok.Data; |
| 7 | -import lombok.EqualsAndHashCode; | |
| 8 | 6 | import lombok.NoArgsConstructor; |
| 9 | 7 | |
| 8 | +import javax.validation.constraints.NotBlank; | |
| 9 | +import javax.validation.constraints.NotNull; | |
| 10 | +import javax.validation.constraints.Size; | |
| 11 | + | |
| 10 | 12 | @Schema(description = "用户 App - 字典数据信息 Response VO") |
| 11 | 13 | @Data |
| 12 | 14 | @NoArgsConstructor |
| 13 | 15 | @AllArgsConstructor |
| 14 | -@EqualsAndHashCode(callSuper = true) | |
| 15 | -public class AppDictDataRespVO extends DictDataBaseVO { | |
| 16 | - | |
| 17 | - // TODO @疯狂:app 的接口,不集成 admin 接口的 vo 哈;看看是不是只返回必要的字段,类似 remark、sort 不好返回的哈; | |
| 16 | +public class AppDictDataRespVO { | |
| 18 | 17 | |
| 19 | 18 | @Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 20 | 19 | private Long id; |
| 21 | 20 | |
| 21 | + @Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") | |
| 22 | + @NotBlank(message = "字典标签不能为空") | |
| 23 | + @Size(max = 100, message = "字典标签长度不能超过100个字符") | |
| 24 | + private String label; | |
| 25 | + | |
| 26 | + @Schema(description = "字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "iocoder") | |
| 27 | + @NotBlank(message = "字典键值不能为空") | |
| 28 | + @Size(max = 100, message = "字典键值长度不能超过100个字符") | |
| 29 | + private String value; | |
| 30 | + | |
| 31 | + @Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "sys_common_sex") | |
| 32 | + @NotBlank(message = "字典类型不能为空") | |
| 33 | + @Size(max = 100, message = "字典类型长度不能超过100个字符") | |
| 34 | + private String dictType; | |
| 35 | + | |
| 36 | + @Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default") | |
| 37 | + private String colorType; | |
| 38 | + @Schema(description = "css 样式", example = "btn-visible") | |
| 39 | + private String cssClass; | |
| 40 | + | |
| 22 | 41 | } | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java
| ... | ... | @@ -48,4 +48,8 @@ public interface DictDataMapper extends BaseMapperX<DictDataDO> { |
| 48 | 48 | .eqIfPresent(DictDataDO::getStatus, reqVO.getStatus())); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + default List<DictDataDO> selectListByTypeAndStatus(String dictType, Integer status) { | |
| 52 | + return selectList(new LambdaQueryWrapper<DictDataDO>() | |
| 53 | + .eq(DictDataDO::getDictType, dictType).eq(DictDataDO::getStatus, status)); | |
| 54 | + } | |
| 51 | 55 | } | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataService.java
| ... | ... | @@ -63,6 +63,14 @@ public interface DictDataService { |
| 63 | 63 | List<DictDataDO> getDictDataList(DictDataExportReqVO reqVO); |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | + * 获得字典数据列表 | |
| 67 | + * | |
| 68 | + * @param dictType 字典类型 | |
| 69 | + * @return 字典数据列表 | |
| 70 | + */ | |
| 71 | + List<DictDataDO> getEnabledDictDataListByType(String dictType); | |
| 72 | + | |
| 73 | + /** | |
| 66 | 74 | * 获得字典数据详情 |
| 67 | 75 | * |
| 68 | 76 | * @param id 字典数据编号 |
| ... | ... | @@ -84,7 +92,7 @@ public interface DictDataService { |
| 84 | 92 | * 2. 字典数据被禁用 |
| 85 | 93 | * |
| 86 | 94 | * @param dictType 字典类型 |
| 87 | - * @param values 字典数据值的数组 | |
| 95 | + * @param values 字典数据值的数组 | |
| 88 | 96 | */ |
| 89 | 97 | void validateDictDataList(String dictType, Collection<String> values); |
| 90 | 98 | |
| ... | ... | @@ -92,7 +100,7 @@ public interface DictDataService { |
| 92 | 100 | * 获得指定的字典数据 |
| 93 | 101 | * |
| 94 | 102 | * @param dictType 字典类型 |
| 95 | - * @param value 字典数据值 | |
| 103 | + * @param value 字典数据值 | |
| 96 | 104 | * @return 字典数据 |
| 97 | 105 | */ |
| 98 | 106 | DictDataDO getDictData(String dictType, String value); |
| ... | ... | @@ -101,7 +109,7 @@ public interface DictDataService { |
| 101 | 109 | * 解析获得指定的字典数据,从缓存中 |
| 102 | 110 | * |
| 103 | 111 | * @param dictType 字典类型 |
| 104 | - * @param label 字典数据标签 | |
| 112 | + * @param label 字典数据标签 | |
| 105 | 113 | * @return 字典数据 |
| 106 | 114 | */ |
| 107 | 115 | DictDataDO parseDictData(String dictType, String label); | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictDataServiceImpl.java
| ... | ... | @@ -67,6 +67,13 @@ public class DictDataServiceImpl implements DictDataService { |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | @Override |
| 70 | + public List<DictDataDO> getEnabledDictDataListByType(String dictType) { | |
| 71 | + List<DictDataDO> list = dictDataMapper.selectListByTypeAndStatus(dictType, CommonStatusEnum.ENABLE.getStatus()); | |
| 72 | + list.sort(COMPARATOR_TYPE_AND_SORT); | |
| 73 | + return list; | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 70 | 77 | public DictDataDO getDictData(Long id) { |
| 71 | 78 | return dictDataMapper.selectById(id); |
| 72 | 79 | } | ... | ... |