Commit c146c98b7230d281c0b5a3236595fa96e342345c
1 parent
f72a0870
分佣: 提现
Showing
6 changed files
with
26 additions
and
17 deletions
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java
| @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; | 6 | import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; |
| 7 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.*; | 7 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.*; |
| 8 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; | ||
| 8 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; | 9 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; |
| 9 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | 10 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; |
| 10 | import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; | 11 | import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; |
| @@ -41,15 +42,15 @@ public class AppBrokerageUserController { | @@ -41,15 +42,15 @@ public class AppBrokerageUserController { | ||
| 41 | @Resource | 42 | @Resource |
| 42 | private BrokerageWithdrawService brokerageWithdrawService; | 43 | private BrokerageWithdrawService brokerageWithdrawService; |
| 43 | 44 | ||
| 44 | - // TODO 芋艿:临时 mock => | ||
| 45 | @GetMapping("/get") | 45 | @GetMapping("/get") |
| 46 | @Operation(summary = "获得个人分销信息") | 46 | @Operation(summary = "获得个人分销信息") |
| 47 | @PreAuthenticated | 47 | @PreAuthenticated |
| 48 | public CommonResult<AppBrokerageUserRespVO> getBrokerageUser() { | 48 | public CommonResult<AppBrokerageUserRespVO> getBrokerageUser() { |
| 49 | + Optional<BrokerageUserDO> user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId())); | ||
| 49 | AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO() | 50 | AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO() |
| 50 | - .setBrokerageEnabled(true) | ||
| 51 | - .setBrokeragePrice(2000) | ||
| 52 | - .setFrozenPrice(3000); | 51 | + .setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false)) |
| 52 | + .setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0)) | ||
| 53 | + .setFrozenPrice(user.map(BrokerageUserDO::getFrozenPrice).orElse(0)); | ||
| 53 | return success(respVO); | 54 | return success(respVO); |
| 54 | } | 55 | } |
| 55 | 56 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/withdraw/AppBrokerageWithdrawCreateReqVO.java
| @@ -43,7 +43,7 @@ public class AppBrokerageWithdrawCreateReqVO { | @@ -43,7 +43,7 @@ public class AppBrokerageWithdrawCreateReqVO { | ||
| 43 | @NotBlank(message = "持卡人姓名不能为空", groups = {Bank.class}) | 43 | @NotBlank(message = "持卡人姓名不能为空", groups = {Bank.class}) |
| 44 | private String name; | 44 | private String name; |
| 45 | @Schema(description = "提现银行", example = "1") | 45 | @Schema(description = "提现银行", example = "1") |
| 46 | - @NotBlank(message = "提现银行不能为空", groups = {Bank.class}) | 46 | + @NotNull(message = "提现银行不能为空", groups = {Bank.class}) |
| 47 | private Integer bankName; | 47 | private Integer bankName; |
| 48 | @Schema(description = "开户地址", example = "海淀支行") | 48 | @Schema(description = "开户地址", example = "海淀支行") |
| 49 | private String bankAddress; | 49 | private String bankAddress; |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/AppTradeConfigController.java
| 1 | package cn.iocoder.yudao.module.trade.controller.app.config; | 1 | package cn.iocoder.yudao.module.trade.controller.app.config; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.util.ObjUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; | 5 | import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; |
| 6 | +import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; | ||
| 7 | +import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; | ||
| 5 | import io.swagger.v3.oas.annotations.tags.Tag; | 8 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 6 | import lombok.RequiredArgsConstructor; | 9 | import lombok.RequiredArgsConstructor; |
| 7 | import lombok.extern.slf4j.Slf4j; | 10 | import lombok.extern.slf4j.Slf4j; |
| @@ -10,8 +13,9 @@ import org.springframework.web.bind.annotation.GetMapping; | @@ -10,8 +13,9 @@ import org.springframework.web.bind.annotation.GetMapping; | ||
| 10 | import org.springframework.web.bind.annotation.RequestMapping; | 13 | import org.springframework.web.bind.annotation.RequestMapping; |
| 11 | import org.springframework.web.bind.annotation.RestController; | 14 | import org.springframework.web.bind.annotation.RestController; |
| 12 | 15 | ||
| 16 | +import javax.annotation.Resource; | ||
| 17 | + | ||
| 13 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 18 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 14 | -import static java.util.Arrays.asList; | ||
| 15 | 19 | ||
| 16 | @Tag(name = "用户 App - 交易配置") | 20 | @Tag(name = "用户 App - 交易配置") |
| 17 | @RestController | 21 | @RestController |
| @@ -20,17 +24,18 @@ import static java.util.Arrays.asList; | @@ -20,17 +24,18 @@ import static java.util.Arrays.asList; | ||
| 20 | @Validated | 24 | @Validated |
| 21 | @Slf4j | 25 | @Slf4j |
| 22 | public class AppTradeConfigController { | 26 | public class AppTradeConfigController { |
| 27 | + @Resource | ||
| 28 | + private TradeConfigService tradeConfigService; | ||
| 23 | 29 | ||
| 24 | @GetMapping("/get") | 30 | @GetMapping("/get") |
| 25 | public CommonResult<AppTradeConfigRespVO> getTradeConfig() { | 31 | public CommonResult<AppTradeConfigRespVO> getTradeConfig() { |
| 26 | - AppTradeConfigRespVO respVO = new AppTradeConfigRespVO(); | ||
| 27 | - respVO.setBrokeragePosterUrls(asList( | ||
| 28 | - "https://api.java.crmeb.net/crmebimage/product/2020/08/03/755bf516b1ca4b6db3bfeaa4dd5901cdh71kob20re.jpg", | ||
| 29 | - "https://api.java.crmeb.net/crmebimage/maintain/2021/03/01/406d729b84ed4ec9a2171bfcf6fd0634ughzbz9kfi.jpg", | ||
| 30 | - "https://api.java.crmeb.net/crmebimage/maintain/2021/03/01/efb1e4e7fe604fe1988b4213ce08cb11tdsyijtd2r.jpg" | ||
| 31 | - )); | ||
| 32 | - respVO.setBrokerageFrozenDays(10); | ||
| 33 | - respVO.setBrokerageWithdrawMinPrice(100); | 32 | + TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO()); |
| 33 | + | ||
| 34 | + AppTradeConfigRespVO respVO = new AppTradeConfigRespVO() | ||
| 35 | + .setBrokeragePosterUrls(tradeConfig.getBrokeragePostUrls()) | ||
| 36 | + .setBrokerageFrozenDays(tradeConfig.getBrokerageFrozenDays()) | ||
| 37 | + .setBrokerageWithdrawMinPrice(tradeConfig.getBrokerageWithdrawMinPrice()) | ||
| 38 | + .setBrokerageWithdrawType(tradeConfig.getBrokerageWithdrawType()); | ||
| 34 | return success(respVO); | 39 | return success(respVO); |
| 35 | } | 40 | } |
| 36 | 41 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/config/vo/AppTradeConfigRespVO.java
| @@ -18,4 +18,7 @@ public class AppTradeConfigRespVO { | @@ -18,4 +18,7 @@ public class AppTradeConfigRespVO { | ||
| 18 | @Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | 18 | @Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| 19 | private Integer brokerageWithdrawMinPrice; | 19 | private Integer brokerageWithdrawMinPrice; |
| 20 | 20 | ||
| 21 | + @Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]") | ||
| 22 | + private List<Integer> brokerageWithdrawType; | ||
| 23 | + | ||
| 21 | } | 24 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordService.java
| @@ -52,7 +52,7 @@ public interface BrokerageRecordService { | @@ -52,7 +52,7 @@ public interface BrokerageRecordService { | ||
| 52 | * @param brokeragePrice 佣金 | 52 | * @param brokeragePrice 佣金 |
| 53 | * @param title 标题 | 53 | * @param title 标题 |
| 54 | */ | 54 | */ |
| 55 | - void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, int brokeragePrice, String title); | 55 | + void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title); |
| 56 | 56 | ||
| 57 | /** | 57 | /** |
| 58 | * 取消佣金:将佣金记录,状态修改为已失效 | 58 | * 取消佣金:将佣金记录,状态修改为已失效 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageRecordServiceImpl.java
| @@ -229,12 +229,12 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { | @@ -229,12 +229,12 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { | ||
| 229 | 229 | ||
| 230 | @Override | 230 | @Override |
| 231 | @Transactional(rollbackFor = Exception.class) | 231 | @Transactional(rollbackFor = Exception.class) |
| 232 | - public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, int brokeragePrice, String title) { | 232 | + public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) { |
| 233 | // 校验佣金余额 | 233 | // 校验佣金余额 |
| 234 | BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId); | 234 | BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId); |
| 235 | int balance = Optional.of(user) | 235 | int balance = Optional.of(user) |
| 236 | .map(BrokerageUserDO::getBrokeragePrice).orElse(0); | 236 | .map(BrokerageUserDO::getBrokeragePrice).orElse(0); |
| 237 | - if (balance < brokeragePrice) { | 237 | + if (balance + brokeragePrice < 0) { |
| 238 | throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance)); | 238 | throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance)); |
| 239 | } | 239 | } |
| 240 | 240 |