feat(mcwl-admin): 增加模型、工作流和图片的购买判断逻辑
parent
a97285ba3c
commit
14f6021416
|
@ -160,7 +160,21 @@ public class MallProductController extends BaseController {
|
|||
@GetMapping("/selectModelById")
|
||||
public R<ModelProduct> selectModelById(@Valid @NotNull(message = "模型id不能为空") @RequestParam Long id) {
|
||||
|
||||
return modelService.selectModelById(id);
|
||||
R<ModelProduct> modelProductR = modelService.selectModelById(id);
|
||||
ModelProduct data = modelProductR.getData();
|
||||
if (Objects.nonNull(data)) {
|
||||
Consume consume = consumeService.lambdaQuery()
|
||||
.eq(Consume::getUserId, SecurityUtils.getUserId())
|
||||
.eq(Consume::getProductId, id)
|
||||
.eq(Consume::getType, 0)
|
||||
.one();
|
||||
data.setIsBuy(1);
|
||||
if (Objects.isNull(consume)) {
|
||||
data.setIsBuy(0);
|
||||
}
|
||||
modelProductR.setData(data);
|
||||
}
|
||||
return modelProductR;
|
||||
}
|
||||
|
||||
|
||||
|
@ -203,6 +217,7 @@ public class MallProductController extends BaseController {
|
|||
|
||||
/**
|
||||
* 校验模型名字是否唯一
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -544,7 +544,14 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
* @return Map<String, Double> 模型金额(price) 邀请人提成(amount)
|
||||
*/
|
||||
private Map<String, Double> modelOrderHandler(Long productUserId, Long modelId, SysUser sysUser) {
|
||||
|
||||
Consume consume = consumeService.lambdaQuery()
|
||||
.eq(Consume::getUserId, sysUser.getUserId())
|
||||
.eq(Consume::getProductId, modelId)
|
||||
.eq(Consume::getType, 0)
|
||||
.one();
|
||||
if (Objects.nonNull(consume)) {
|
||||
throw new ServiceException("您已经购买过此模型", HttpStatus.SHOW_ERROR_MSG);
|
||||
}
|
||||
ModelProduct modelProduct = modelService.lambdaQuery()
|
||||
.eq(ModelProduct::getId, modelId)
|
||||
.eq(ModelProduct::getUserId, productUserId)
|
||||
|
@ -567,6 +574,17 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
* @return Map<String, Double> 工作流金额(price) 邀请人提成(amount)
|
||||
*/
|
||||
private Map<String, Double> workFlowOrderHandler(Long productUserId, Long workFlowId, SysUser sysUser) {
|
||||
|
||||
Consume consume = consumeService.lambdaQuery()
|
||||
.eq(Consume::getUserId, sysUser.getUserId())
|
||||
.eq(Consume::getProductId, workFlowId)
|
||||
.eq(Consume::getType, 1)
|
||||
.one();
|
||||
if (Objects.nonNull(consume)) {
|
||||
throw new ServiceException("您已经购买过此工作流", HttpStatus.SHOW_ERROR_MSG);
|
||||
}
|
||||
|
||||
|
||||
WorkFlow workFlow = workFlowService.lambdaQuery()
|
||||
.eq(WorkFlow::getId, workFlowId)
|
||||
.eq(WorkFlow::getUserId, productUserId)
|
||||
|
@ -589,6 +607,17 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
* @return Map<String, Double> 图片金额(price) 邀请人提成(amount)
|
||||
*/
|
||||
private Map<String, Double> imageOrderHandler(Long productUserId, Long imageId, SysUser sysUser) {
|
||||
|
||||
Consume consume = consumeService.lambdaQuery()
|
||||
.eq(Consume::getUserId, sysUser.getUserId())
|
||||
.eq(Consume::getProductId, imageId)
|
||||
.eq(Consume::getType, 3)
|
||||
.one();
|
||||
if (Objects.nonNull(consume)) {
|
||||
throw new ServiceException("您已经购买过此图片", HttpStatus.SHOW_ERROR_MSG);
|
||||
}
|
||||
|
||||
|
||||
ModelImage modelImage = modelImageService.lambdaQuery()
|
||||
.eq(ModelImage::getId, imageId)
|
||||
.eq(ModelImage::getUserId, productUserId)
|
||||
|
@ -630,7 +659,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
|
||||
// 佣金配给邀请者用户比例
|
||||
String commissionRationInviterUser = redisCache.getCacheObject(CommissionRationEnum.COMMISSION_RATION_INVITER_USER.getName());
|
||||
if (Objects.isNull(CommissionRationMerchant)) {
|
||||
if (Objects.isNull(commissionRationInviterUser)) {
|
||||
CommissionRatio commissionRatio = commissionRatioService.lambdaQuery()
|
||||
.eq(CommissionRatio::getType, 0)
|
||||
.one();
|
||||
|
@ -640,6 +669,9 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
|||
Double rationMerchant = redisCache.getCacheObject(CommissionRationMerchant);
|
||||
Double rationInviterUser = redisCache.getCacheObject(commissionRationInviterUser);
|
||||
|
||||
rationMerchant = rationMerchant == null ? 0.0 : rationMerchant;
|
||||
rationInviterUser = rationInviterUser == null ? 0.0 : rationInviterUser;
|
||||
|
||||
// 将模型价格、抽取商家金额比例、佣金配给邀请者用户比例转换为BigDecimal类型
|
||||
BigDecimal priceBigDecimal = new BigDecimal(price.toString());
|
||||
BigDecimal rationMerchantBigDecimal = new BigDecimal(rationMerchant.toString());
|
||||
|
|
Loading…
Reference in New Issue