Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product

This commit is contained in:
puhui999
2023-09-10 22:54:01 +08:00
36 changed files with 316 additions and 203 deletions

View File

@@ -27,7 +27,7 @@ public class BrokerageApiImpl implements BrokerageApi {
@Override
public boolean bindUser(Long userId, Long bindUserId, Boolean isNewUser) {
return brokerageUserService.bindUser(userId, bindUserId, isNewUser);
return brokerageUserService.bindBrokerageUser(userId, bindUserId, isNewUser);
}
}

View File

@@ -19,7 +19,6 @@ public class BrokerageUserRespVO extends BrokerageUserBaseVO {
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
// ========== 用户信息 ==========
@Schema(description = "用户头像", example = "https://www.iocoder.cn/xxx.png")
@@ -27,7 +26,6 @@ public class BrokerageUserRespVO extends BrokerageUserBaseVO {
@Schema(description = "用户昵称", example = "李四")
private String nickname;
// ========== 推广信息 ==========
@Schema(description = "推广用户数量(一级)", example = "20019")
@@ -37,7 +35,6 @@ public class BrokerageUserRespVO extends BrokerageUserBaseVO {
@Schema(description = "推广订单金额", example = "20019")
private Integer brokerageOrderPrice;
// ========== 提现信息 ==========
@Schema(description = "已提现金额", example = "20019")

View File

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.trade.controller.app.brokerage;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageProductPriceRespVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordPageReqVO;
import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record.AppBrokerageRecordRespVO;
import io.swagger.v3.oas.annotations.Operation;
@@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
@@ -40,4 +42,14 @@ public class AppBrokerageRecordController {
return success(new PageResult<>(asList(vo1, vo2), 10L));
}
@GetMapping("/get-product-brokerage-price")
@Operation(summary = "获得商品的分销金额")
public CommonResult<AppBrokerageProductPriceRespVO> getProductBrokeragePrice(@RequestParam("spuId") Long spuId) {
AppBrokerageProductPriceRespVO respVO = new AppBrokerageProductPriceRespVO();
respVO.setEnabled(true); // TODO @疯狂:需要开启分销 + 人允许分销
respVO.setBrokerageMinPrice(1);
respVO.setBrokerageMaxPrice(2);
return success(respVO);
}
}

View File

@@ -37,11 +37,19 @@ public class AppBrokerageUserController {
@PreAuthenticated
public CommonResult<AppBrokerageUserRespVO> getBrokerageUser() {
AppBrokerageUserRespVO respVO = new AppBrokerageUserRespVO()
.setBrokerageEnabled(true)
.setPrice(2000)
.setFrozenPrice(3000);
return success(respVO);
}
@PutMapping("/bind")
@Operation(summary = "绑定推广员")
@PreAuthenticated
public CommonResult<Boolean> bindBrokerageUser(@Valid @RequestBody AppBrokerageUserBindReqVO reqVO) {
return success(brokerageUserService.bindBrokerageUser(getLoginUserId(), reqVO.getBindUserId(), false));
}
// TODO 芋艿:临时 mock =>
@GetMapping("/get-summary")
@Operation(summary = "获得个人分销统计")
@@ -49,7 +57,7 @@ public class AppBrokerageUserController {
public CommonResult<AppBrokerageUserMySummaryRespVO> getBrokerageUserSummary() {
AppBrokerageUserMySummaryRespVO respVO = new AppBrokerageUserMySummaryRespVO()
.setYesterdayPrice(1)
.setPrice(2)
.setBrokeragePrice(2)
.setFrozenPrice(3)
.setWithdrawPrice(4)
.setFirstBrokerageUserCount(166)
@@ -84,16 +92,16 @@ public class AppBrokerageUserController {
public CommonResult<PageResult<AppBrokerageUserRankByPriceRespVO>> getBrokerageUserChildSummaryPageByPrice(AppBrokerageUserRankPageReqVO pageReqVO) {
AppBrokerageUserRankByPriceRespVO vo1 = new AppBrokerageUserRankByPriceRespVO()
.setId(1L).setNickname("芋1**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
.setPrice(10);
.setBrokeragePrice(10);
AppBrokerageUserRankByPriceRespVO vo2 = new AppBrokerageUserRankByPriceRespVO()
.setId(2L).setNickname("芋2**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
.setPrice(6);
.setBrokeragePrice(6);
AppBrokerageUserRankByPriceRespVO vo3 = new AppBrokerageUserRankByPriceRespVO()
.setId(3L).setNickname("芋3**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
.setPrice(4);
.setBrokeragePrice(4);
AppBrokerageUserRankByPriceRespVO vo4 = new AppBrokerageUserRankByPriceRespVO()
.setId(3L).setNickname("芋3**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
.setPrice(4);
.setBrokeragePrice(4);
return success(new PageResult<>(asList(vo1, vo2, vo3, vo4), 10L));
}
@@ -105,11 +113,11 @@ public class AppBrokerageUserController {
AppBrokerageUserChildSummaryPageReqVO pageReqVO) {
AppBrokerageUserChildSummaryRespVO vo1 = new AppBrokerageUserChildSummaryRespVO()
.setId(1L).setNickname("芋1**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
.setPrice(10).setPrice(20).setBrokerageOrderCount(30)
.setBrokeragePrice(10).setBrokeragePrice(20).setBrokerageOrderCount(30)
.setBrokerageTime(LocalDateTime.now());
AppBrokerageUserChildSummaryRespVO vo2 = new AppBrokerageUserChildSummaryRespVO()
.setId(1L).setNickname("芋2**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg")
.setPrice(20).setPrice(30).setBrokerageOrderCount(40)
.setBrokeragePrice(20).setBrokeragePrice(30).setBrokerageOrderCount(40)
.setBrokerageTime(LocalDateTime.now());
return success(new PageResult<>(asList(vo1, vo2), 10L));
}
@@ -118,15 +126,9 @@ public class AppBrokerageUserController {
@GetMapping("/get-rank-by-price")
@Operation(summary = "获得分销用户排行(基于佣金)")
@Parameter(name = "times", description = "时间段", required = true)
public CommonResult<Integer> getBrokerageUserRankByPrice(
public CommonResult<Integer> bindBrokerageUser(
@RequestParam("times") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime[] times) {
return success(1);
}
@PutMapping("/bind-user")
@Operation(summary = "绑定推广员")
public CommonResult<Boolean> getBrokerageUserRankByPrice(@Valid AppBrokerageUserBindReqVO reqVO) {
return success(brokerageUserService.bindUser(getLoginUserId(), reqVO.getBindUserId(), false));
}
}

View File

@@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.record;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 App - 商品的分销金额 Response VO")
@Data
public class AppBrokerageProductPriceRespVO {
@Schema(description = "是否开启", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Boolean enabled;
@Schema(description = "分销最小金额,单位:分", example = "100")
private Integer brokerageMinPrice;
@Schema(description = "分销最大金额,单位:分", example = "100")
private Integer brokerageMaxPrice;
}

View File

@@ -19,7 +19,7 @@ public class AppBrokerageUserChildSummaryRespVO {
private String avatar;
@Schema(description = "佣金金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer price;
private Integer brokeragePrice;
@Schema(description = "分销订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
private Integer brokerageOrderCount;

View File

@@ -14,7 +14,7 @@ public class AppBrokerageUserMySummaryRespVO {
private Integer withdrawPrice;
@Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408")
private Integer price;
private Integer brokeragePrice;
@Schema(description = "冻结的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "234")
private Integer frozenPrice;

View File

@@ -17,6 +17,6 @@ public class AppBrokerageUserRankByPriceRespVO {
private String avatar;
@Schema(description = "佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
private Integer price;
private Integer brokeragePrice;
}

View File

@@ -7,6 +7,9 @@ import lombok.Data;
@Data
public class AppBrokerageUserRespVO {
@Schema(description = "是否有分销资格", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
private Boolean brokerageEnabled;
@Schema(description = "可用的佣金,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2408")
private Integer price;

View File

@@ -41,7 +41,7 @@ public interface BrokerageRecordConvert {
: BrokerageRecordStatusEnum.SETTLEMENT.getStatus();
return new BrokerageRecordDO().setUserId(user.getId())
.setBizType(bizType.getType()).setBizId(bizId)
.setPrice(brokeragePrice).setTotalPrice(user.getPrice())
.setPrice(brokeragePrice).setTotalPrice(user.getBrokeragePrice())
.setTitle(title)
.setDescription(StrUtil.format(bizType.getDescription(), String.valueOf(brokeragePrice / 100.0)))
.setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime);

View File

@@ -43,7 +43,7 @@ public class BrokerageUserDO extends BaseDO {
private LocalDateTime bindUserTime;
/**
* 推广资格
* 是否有分销资格
*/
private Boolean brokerageEnabled;
/**
@@ -54,7 +54,7 @@ public class BrokerageUserDO extends BaseDO {
/**
* 可用佣金
*/
private Integer price;
private Integer brokeragePrice;
/**
* 冻结佣金
*/

View File

@@ -103,6 +103,6 @@ public interface BrokerageUserService {
* @param isNewUser 是否为新用户
* @return 是否绑定
*/
boolean bindUser(Long userId, Long bindUserId, Boolean isNewUser);
boolean bindBrokerageUser(Long userId, Long bindUserId, Boolean isNewUser);
}

View File

@@ -135,7 +135,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
// TODO @疯狂:因为现在 user 会存在使用验证码直接注册,所以 isNewUser 不太好传递我们是不是可以约定绑定的时间createTime 在 30 秒内,就认为新用户;
@Override
public boolean bindUser(Long userId, Long bindUserId, Boolean isNewUser) {
public boolean bindBrokerageUser(Long userId, Long bindUserId, Boolean isNewUser) {
// TODO @疯狂userId 为空,搞到参数校验里哇;
if (userId == null) {
throw exception(0);
@@ -146,7 +146,7 @@ public class BrokerageUserServiceImpl implements BrokerageUserService {
BrokerageUserDO brokerageUser = brokerageUserMapper.selectById(userId);
if (brokerageUser == null) { // 分销用户不存在的情况1. 新注册2. 旧数据3. 分销功能关闭后又打开
isNewBrokerageUser = true;
brokerageUser = new BrokerageUserDO().setId(userId).setBrokerageEnabled(false).setPrice(0).setFrozenPrice(0);
brokerageUser = new BrokerageUserDO().setId(userId).setBrokerageEnabled(false).setBrokeragePrice(0).setFrozenPrice(0);
}
// 2.1 校验能否绑定