feat(mcwl-admin): 增加模型、工作流和图片的购买判断逻辑

master
yang 2025-03-27 17:14:30 +08:00
parent a97285ba3c
commit 14f6021416
2 changed files with 55 additions and 8 deletions

View File

@ -93,8 +93,8 @@ public class MallProductController extends BaseController {
.ifPresent(m -> m.setIsBuy(1)); .ifPresent(m -> m.setIsBuy(1));
LambdaQueryWrapper<ModelVersion> modelVersionLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ModelVersion> modelVersionLambdaQueryWrapper = new LambdaQueryWrapper<>();
modelVersionLambdaQueryWrapper.eq(ModelVersion::getModelId,id); modelVersionLambdaQueryWrapper.eq(ModelVersion::getModelId, id);
modelVersionLambdaQueryWrapper.eq(ModelVersion::getDelFlag,"0"); modelVersionLambdaQueryWrapper.eq(ModelVersion::getDelFlag, "0");
List<ModelVersion> modelVersions = modelVersionMapper.selectList(modelVersionLambdaQueryWrapper); List<ModelVersion> modelVersions = modelVersionMapper.selectList(modelVersionLambdaQueryWrapper);
requestModel.setModelProduct(modelVersion1); requestModel.setModelProduct(modelVersion1);
@ -160,7 +160,21 @@ public class MallProductController extends BaseController {
@GetMapping("/selectModelById") @GetMapping("/selectModelById")
public R<ModelProduct> selectModelById(@Valid @NotNull(message = "模型id不能为空") @RequestParam Long id) { 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,21 +217,22 @@ public class MallProductController extends BaseController {
/** /**
* *
*
* @param name * @param name
* @return * @return
*/ */
@ApiOperation(value = "校验模型名字是否唯一") @ApiOperation(value = "校验模型名字是否唯一")
@GetMapping("/selectModelByName") @GetMapping("/selectModelByName")
public R selectModelByName(@RequestParam String name){ public R selectModelByName(@RequestParam String name) {
return modelService.selectModelByName(name); return modelService.selectModelByName(name);
} }
@ApiOperation(value = "个人中心更改背景") @ApiOperation(value = "个人中心更改背景")
@GetMapping("/updateBackgroundImg") @GetMapping("/updateBackgroundImg")
public R updateBackgroundImg(@RequestParam Long id,String path){ public R updateBackgroundImg(@RequestParam Long id, String path) {
sysUserService.updateBackgroundImg(id,path); sysUserService.updateBackgroundImg(id, path);
return R.ok(); return R.ok();
} }

View File

@ -544,7 +544,14 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
* @return Map<String, Double> (price) (amount) * @return Map<String, Double> (price) (amount)
*/ */
private Map<String, Double> modelOrderHandler(Long productUserId, Long modelId, SysUser sysUser) { 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() ModelProduct modelProduct = modelService.lambdaQuery()
.eq(ModelProduct::getId, modelId) .eq(ModelProduct::getId, modelId)
.eq(ModelProduct::getUserId, productUserId) .eq(ModelProduct::getUserId, productUserId)
@ -567,6 +574,17 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
* @return Map<String, Double> (price) (amount) * @return Map<String, Double> (price) (amount)
*/ */
private Map<String, Double> workFlowOrderHandler(Long productUserId, Long workFlowId, SysUser sysUser) { 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() WorkFlow workFlow = workFlowService.lambdaQuery()
.eq(WorkFlow::getId, workFlowId) .eq(WorkFlow::getId, workFlowId)
.eq(WorkFlow::getUserId, productUserId) .eq(WorkFlow::getUserId, productUserId)
@ -589,6 +607,17 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
* @return Map<String, Double> (price) (amount) * @return Map<String, Double> (price) (amount)
*/ */
private Map<String, Double> imageOrderHandler(Long productUserId, Long imageId, SysUser sysUser) { 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() ModelImage modelImage = modelImageService.lambdaQuery()
.eq(ModelImage::getId, imageId) .eq(ModelImage::getId, imageId)
.eq(ModelImage::getUserId, productUserId) .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()); String commissionRationInviterUser = redisCache.getCacheObject(CommissionRationEnum.COMMISSION_RATION_INVITER_USER.getName());
if (Objects.isNull(CommissionRationMerchant)) { if (Objects.isNull(commissionRationInviterUser)) {
CommissionRatio commissionRatio = commissionRatioService.lambdaQuery() CommissionRatio commissionRatio = commissionRatioService.lambdaQuery()
.eq(CommissionRatio::getType, 0) .eq(CommissionRatio::getType, 0)
.one(); .one();
@ -640,6 +669,9 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
Double rationMerchant = redisCache.getCacheObject(CommissionRationMerchant); Double rationMerchant = redisCache.getCacheObject(CommissionRationMerchant);
Double rationInviterUser = redisCache.getCacheObject(commissionRationInviterUser); Double rationInviterUser = redisCache.getCacheObject(commissionRationInviterUser);
rationMerchant = rationMerchant == null ? 0.0 : rationMerchant;
rationInviterUser = rationInviterUser == null ? 0.0 : rationInviterUser;
// 将模型价格、抽取商家金额比例、佣金配给邀请者用户比例转换为BigDecimal类型 // 将模型价格、抽取商家金额比例、佣金配给邀请者用户比例转换为BigDecimal类型
BigDecimal priceBigDecimal = new BigDecimal(price.toString()); BigDecimal priceBigDecimal = new BigDecimal(price.toString());
BigDecimal rationMerchantBigDecimal = new BigDecimal(rationMerchant.toString()); BigDecimal rationMerchantBigDecimal = new BigDecimal(rationMerchant.toString());