From e384b810bf360817c5d57e7c1d779c9b659079cc Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 25 Sep 2023 09:39:39 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=EF=BC=9A=E5=88=86=E9=94=80?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/number/MoneyUtils.java | 3 +++ .../api/spu/dto/ProductSpuRespDTO.java | 1 + .../dal/dataobject/spu/ProductSpuDO.java | 1 + .../module/trade/enums/DictTypeConstants.java | 1 + .../brokerage/BrokerageUserController.java | 7 ++++--- .../brokerage/AppBrokerageUserController.java | 4 +++- .../brokerage/BrokerageWithdrawMapper.java | 1 + .../brokerage/BrokerageRecordServiceImpl.java | 19 ++++++++----------- .../brokerage/BrokerageUserServiceImpl.java | 1 + .../api/user/dto/MemberUserRespDTO.java | 2 +- .../app/dict/AppDictDataController.java | 2 +- .../app/dict/vo/AppDictDataRespVO.java | 12 ------------ .../system/dal/mysql/dict/DictDataMapper.java | 4 +++- 13 files changed, 28 insertions(+), 30 deletions(-) diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java index cac8438e0..e0b739920 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/number/MoneyUtils.java @@ -61,10 +61,13 @@ public class MoneyUtils { /** * 分转元(字符串) * + * 例如说 fen 为 1 时,则结果为 0.01 + * * @param fen 分 * @return 元 */ public static String fenToYuanStr(int fen) { return new Money(0, fen).toString(); } + } diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java index fe2939efc..cad6bfcb2 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/spu/dto/ProductSpuRespDTO.java @@ -147,4 +147,5 @@ public class ProductSpuRespDTO { * true - 自行设置 */ private Boolean subCommissionType; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java index 905bb890b..9e073fee7 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java @@ -179,6 +179,7 @@ public class ProductSpuDO extends BaseDO { @TableField(typeHandler = JacksonTypeHandler.class) private List giveCouponTemplateIds; + // TODO @puhui999:字段估计要改成 brokerageType /** * 分销类型 * diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java index 4ff3c95f2..ff09e59d8 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/DictTypeConstants.java @@ -8,4 +8,5 @@ package cn.iocoder.yudao.module.trade.enums; public interface DictTypeConstants { String BROKERAGE_WITHDRAW_STATUS = "brokerage_withdraw_status"; // 佣金提现状态 + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java index f12a62358..8d27dd3b4 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/BrokerageUserController.java @@ -92,6 +92,7 @@ public class BrokerageUserController { Set userIds = convertSet(pageResult.getList(), BrokerageUserDO::getId); // 查询用户信息 Map userMap = memberUserApi.getUserMap(userIds); + // TODO @疯狂:看看下面两个 getBrokerageUserCountByBindUserId、getWithdrawSummaryByUserId 有没可能一次性出结果,不然 n 次有点太花性能了; // 合计分佣订单 Map userOrderSummaryMap = convertMap(userIds, userId -> userId, @@ -101,13 +102,13 @@ public class BrokerageUserController { Map brokerageUserCountMap = convertMap(userIds, userId -> userId, userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null)); - // 合计提现 Map withdrawMap = convertMap(userIds, userId -> userId, userId -> brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS)); - - return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, userOrderSummaryMap, withdrawMap)); + // 拼接返回 + return success(BrokerageUserConvert.INSTANCE.convertPage(pageResult, userMap, brokerageUserCountMap, + userOrderSummaryMap, withdrawMap)); } } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java index 2e8db1bbc..da78f9dff 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java @@ -77,13 +77,15 @@ public class AppBrokerageUserController { @PreAuthenticated public CommonResult getBrokerageUserSummary() { Long userId = getLoginUserId(); + // TODO @疯狂:后面这种,要不也改成 convert;感觉 controller 这样更容易看到整体;核心其实是 86、8/87、9/90、9/91 这阶段 // 统计 yesterdayPrice、withdrawPrice、firstBrokerageUserCount、secondBrokerageUserCount 字段 LocalDateTime yesterday = LocalDateTime.now().minusDays(1); LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO() .setYesterdayPrice(brokerageRecordService.getSummaryPriceByUserId(userId, BrokerageRecordBizTypeEnum.ORDER.getType(), beginTime, endTime)) - .setWithdrawPrice(Optional.ofNullable(brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS)).map(UserWithdrawSummaryBO::getPrice).orElse(0)) + .setWithdrawPrice(Optional.ofNullable(brokerageWithdrawService.getWithdrawSummaryByUserId(userId, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS)) + .map(UserWithdrawSummaryBO::getPrice).orElse(0)) .setBrokeragePrice(0).setFrozenPrice(0) .setFirstBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 1)) .setSecondBrokerageUserCount(brokerageUserService.getBrokerageUserCountByBindUserId(userId, 2)); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java index aa9fc09e0..f8ca4c5b7 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageWithdrawMapper.java @@ -41,4 +41,5 @@ public interface BrokerageWithdrawMapper extends BaseMapperX skuList = productSkuApi.getSkuListBySpuId(ListUtil.of(spuId)); if (BooleanUtil.isTrue(spu.getSubCommissionType())) { - // 3.1 商品单独分佣模式 fixedMinPrice = getMinValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice); fixedMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getFirstBrokeragePrice); + // 3.2 全局分佣模式(根据商品价格比例计算) } else { - // 3.2 全局分佣模式(根据商品价格比例计算) spuMinPrice = getMinValue(skuList, ProductSkuRespDTO::getPrice); spuMaxPrice = getMaxValue(skuList, ProductSkuRespDTO::getPrice); } - respVO.setBrokerageMinPrice(calculatePrice(spuMinPrice, tradeConfig.getBrokerageFirstPercent(), fixedMinPrice)); respVO.setBrokerageMaxPrice(calculatePrice(spuMaxPrice, tradeConfig.getBrokerageFirstPercent(), fixedMaxPrice)); return respVO; diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java index 182e457b5..8672f3069 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java @@ -236,6 +236,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { // 校验分销关系绑定模式 if (BrokerageBindModeEnum.REGISTER.getMode().equals(tradeConfig.getBrokerageBindMode())) { + // TODO @疯狂:是不是把 isNewUser 挪到这里好点呀? if (!BooleanUtil.isTrue(isNewUser)) { throw exception(BROKERAGE_BIND_MODE_REGISTER); // 只有在注册时可以绑定 } diff --git a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java index 85dad84d7..e55eda154 100644 --- a/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java +++ b/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/dto/MemberUserRespDTO.java @@ -36,7 +36,7 @@ public class MemberUserRespDTO { */ private String mobile; /** - * 创建时间 + * 创建时间(注册时间) */ private LocalDateTime createTime; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java index 2332875b8..1f4f78c80 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/AppDictDataController.java @@ -31,7 +31,7 @@ public class AppDictDataController { @GetMapping("/type") @Operation(summary = "根据字典类型查询字典数据信息") @Parameter(name = "type", description = "字典类型", required = true, example = "common_status") - public CommonResult> getDictDataListByType(@RequestParam String type) { + public CommonResult> getDictDataListByType(@RequestParam("type") String type) { List list = dictDataService.getEnabledDictDataListByType(type); return success(DictDataConvert.INSTANCE.convertList03(list)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/vo/AppDictDataRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/vo/AppDictDataRespVO.java index b7dfaf230..e2d141603 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/vo/AppDictDataRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dict/vo/AppDictDataRespVO.java @@ -6,7 +6,6 @@ import lombok.Data; import lombok.NoArgsConstructor; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; @Schema(description = "用户 App - 字典数据信息 Response VO") @@ -19,23 +18,12 @@ public class AppDictDataRespVO { private Long id; @Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - @NotBlank(message = "字典标签不能为空") - @Size(max = 100, message = "字典标签长度不能超过100个字符") private String label; @Schema(description = "字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "iocoder") - @NotBlank(message = "字典键值不能为空") - @Size(max = 100, message = "字典键值长度不能超过100个字符") private String value; @Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "sys_common_sex") - @NotBlank(message = "字典类型不能为空") - @Size(max = 100, message = "字典类型长度不能超过100个字符") private String dictType; - @Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default") - private String colorType; - @Schema(description = "css 样式", example = "btn-visible") - private String cssClass; - } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java index 85da83a5d..f92c86298 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java @@ -50,6 +50,8 @@ public interface DictDataMapper extends BaseMapperX { default List selectListByTypeAndStatus(String dictType, Integer status) { return selectList(new LambdaQueryWrapper() - .eq(DictDataDO::getDictType, dictType).eq(DictDataDO::getStatus, status)); + .eq(DictDataDO::getDictType, dictType) + .eq(DictDataDO::getStatus, status)); } + }