分佣: 提现

This commit is contained in:
owen 2023-09-22 18:06:11 +08:00
parent f72a087007
commit c146c98b72
6 changed files with 26 additions and 17 deletions

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.*; import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.*;
import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService; import cn.iocoder.yudao.module.trade.service.brokerage.BrokerageRecordService;
@ -41,15 +42,15 @@ public class AppBrokerageUserController {
@Resource @Resource
private BrokerageWithdrawService brokerageWithdrawService; private BrokerageWithdrawService brokerageWithdrawService;
// TODO 芋艿临时 mock =>
@GetMapping("/get") @GetMapping("/get")
@Operation(summary = "获得个人分销信息") @Operation(summary = "获得个人分销信息")
@PreAuthenticated @PreAuthenticated
public CommonResult<AppBrokerageUserRespVO> getBrokerageUser() { public CommonResult<AppBrokerageUserRespVO> getBrokerageUser() {
Optional<BrokerageUserDO> user = Optional.ofNullable(brokerageUserService.getBrokerageUser(getLoginUserId()));
AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO() AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO()
.setBrokerageEnabled(true) .setBrokerageEnabled(user.map(BrokerageUserDO::getBrokerageEnabled).orElse(false))
.setBrokeragePrice(2000) .setBrokeragePrice(user.map(BrokerageUserDO::getBrokeragePrice).orElse(0))
.setFrozenPrice(3000); .setFrozenPrice(user.map(BrokerageUserDO::getFrozenPrice).orElse(0));
return success(respVO); return success(respVO);
} }

View File

@ -43,7 +43,7 @@ public class AppBrokerageWithdrawCreateReqVO {
@NotBlank(message = "持卡人姓名不能为空", groups = {Bank.class}) @NotBlank(message = "持卡人姓名不能为空", groups = {Bank.class})
private String name; private String name;
@Schema(description = "提现银行", example = "1") @Schema(description = "提现银行", example = "1")
@NotBlank(message = "提现银行不能为空", groups = {Bank.class}) @NotNull(message = "提现银行不能为空", groups = {Bank.class})
private Integer bankName; private Integer bankName;
@Schema(description = "开户地址", example = "海淀支行") @Schema(description = "开户地址", example = "海淀支行")
private String bankAddress; private String bankAddress;

View File

@ -1,7 +1,10 @@
package cn.iocoder.yudao.module.trade.controller.app.config; package cn.iocoder.yudao.module.trade.controller.app.config;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO; import cn.iocoder.yudao.module.trade.controller.app.config.vo.AppTradeConfigRespVO;
import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO;
import cn.iocoder.yudao.module.trade.service.config.TradeConfigService;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -10,8 +13,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static java.util.Arrays.asList;
@Tag(name = "用户 App - 交易配置") @Tag(name = "用户 App - 交易配置")
@RestController @RestController
@ -20,17 +24,18 @@ import static java.util.Arrays.asList;
@Validated @Validated
@Slf4j @Slf4j
public class AppTradeConfigController { public class AppTradeConfigController {
@Resource
private TradeConfigService tradeConfigService;
@GetMapping("/get") @GetMapping("/get")
public CommonResult<AppTradeConfigRespVO> getTradeConfig() { public CommonResult<AppTradeConfigRespVO> getTradeConfig() {
AppTradeConfigRespVO respVO = new AppTradeConfigRespVO(); TradeConfigDO tradeConfig = ObjUtil.defaultIfNull(tradeConfigService.getTradeConfig(), new TradeConfigDO());
respVO.setBrokeragePosterUrls(asList(
"https://api.java.crmeb.net/crmebimage/product/2020/08/03/755bf516b1ca4b6db3bfeaa4dd5901cdh71kob20re.jpg", AppTradeConfigRespVO respVO = new AppTradeConfigRespVO()
"https://api.java.crmeb.net/crmebimage/maintain/2021/03/01/406d729b84ed4ec9a2171bfcf6fd0634ughzbz9kfi.jpg", .setBrokeragePosterUrls(tradeConfig.getBrokeragePostUrls())
"https://api.java.crmeb.net/crmebimage/maintain/2021/03/01/efb1e4e7fe604fe1988b4213ce08cb11tdsyijtd2r.jpg" .setBrokerageFrozenDays(tradeConfig.getBrokerageFrozenDays())
)); .setBrokerageWithdrawMinPrice(tradeConfig.getBrokerageWithdrawMinPrice())
respVO.setBrokerageFrozenDays(10); .setBrokerageWithdrawType(tradeConfig.getBrokerageWithdrawType());
respVO.setBrokerageWithdrawMinPrice(100);
return success(respVO); return success(respVO);
} }

View File

@ -18,4 +18,7 @@ public class AppTradeConfigRespVO {
@Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") @Schema(description = "佣金提现最小金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer brokerageWithdrawMinPrice; private Integer brokerageWithdrawMinPrice;
@Schema(description = "提现方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 2]")
private List<Integer> brokerageWithdrawType;
} }

View File

@ -52,7 +52,7 @@ public interface BrokerageRecordService {
* @param brokeragePrice 佣金 * @param brokeragePrice 佣金
* @param title 标题 * @param title 标题
*/ */
void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, int brokeragePrice, String title); void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title);
/** /**
* 取消佣金将佣金记录状态修改为已失效 * 取消佣金将佣金记录状态修改为已失效

View File

@ -229,12 +229,12 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, int brokeragePrice, String title) { public void addBrokerage(Long userId, BrokerageRecordBizTypeEnum bizType, String bizId, Integer brokeragePrice, String title) {
// 校验佣金余额 // 校验佣金余额
BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId); BrokerageUserDO user = brokerageUserService.getBrokerageUser(userId);
int balance = Optional.of(user) int balance = Optional.of(user)
.map(BrokerageUserDO::getBrokeragePrice).orElse(0); .map(BrokerageUserDO::getBrokeragePrice).orElse(0);
if (balance < brokeragePrice) { if (balance + brokeragePrice < 0) {
throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance)); throw exception(BROKERAGE_WITHDRAW_USER_BALANCE_NOT_ENOUGH, new Money(0, balance));
} }