diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelRechargeRecordController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/AliPay/ModelPurchaseRecordController.java similarity index 79% rename from mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelRechargeRecordController.java rename to mcwl-admin/src/main/java/com/mcwl/web/controller/pay/AliPay/ModelPurchaseRecordController.java index 2cf5911..fe8aff0 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelRechargeRecordController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/AliPay/ModelPurchaseRecordController.java @@ -1,4 +1,4 @@ -package com.mcwl.web.controller.resource; +package com.mcwl.web.controller.pay.AliPay; import io.swagger.annotations.Api; import org.springframework.web.bind.annotation.RequestMapping; @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController; @Api(tags = "商品购买记录") @RequestMapping("/modelRechargeRecord") @RestController -public class ModelRechargeRecordController { - +public class ModelPurchaseRecordController { } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java index ddb07b8..db88df2 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java @@ -7,9 +7,10 @@ import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.R; import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.utils.SecurityUtils; -import com.mcwl.communityCenter.service.InviteService; import com.mcwl.myInvitation.domain.Consume; import com.mcwl.myInvitation.service.ConsumeService; +import com.mcwl.pay.domain.ModelPurchaseRecord; +import com.mcwl.pay.mapper.ModelPurchaseRecordMapper; import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.domain.dto.ModelImagePageRes; @@ -48,6 +49,8 @@ import java.util.stream.Collectors; @RequestMapping("/model") public class MallProductController extends BaseController { + @Autowired + private ModelPurchaseRecordMapper modelPurchaseRecordMapper; @Autowired private ModelService modelService; @@ -163,13 +166,13 @@ public class MallProductController extends BaseController { R 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(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ModelPurchaseRecord::getUserId, SecurityUtils.getUserId()) + .eq(ModelPurchaseRecord::getProductId, id) + .eq(ModelPurchaseRecord::getProductType, 0); + ModelPurchaseRecord modelPurchaseRecord = modelPurchaseRecordMapper.selectOne(wrapper); data.setIsBuy(1); - if (Objects.isNull(consume)) { + if (Objects.isNull(modelPurchaseRecord)) { data.setIsBuy(0); } modelProductR.setData(data); diff --git a/mcwl-common/src/main/java/com/mcwl/common/enums/CommissionRationEnum.java b/mcwl-common/src/main/java/com/mcwl/common/enums/CommissionRationEnum.java new file mode 100644 index 0000000..f0c39df --- /dev/null +++ b/mcwl-common/src/main/java/com/mcwl/common/enums/CommissionRationEnum.java @@ -0,0 +1,31 @@ +package com.mcwl.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @Author:ChenYan + * @Project:McWl + * @Package:com.mcwl.pay.domain + * @Filename:PaymentStatus + * @Description TODO + * @Date:2025/1/3 17:24 + */ + +@Getter +@AllArgsConstructor +@NoArgsConstructor +public enum CommissionRationEnum { + + /** + * 佣金配给邀请者用户 + */ + COMMISSION_RATION_INVITER_USER("CommissionRationInviterUser"), + /** + * 佣金配给商家用户 + */ + COMMISSION_RATION_MERCHANT("CommissionRationMerchant"); + + private String name; +} diff --git a/mcwl-common/src/main/java/com/mcwl/common/enums/PaymentStatus.java b/mcwl-common/src/main/java/com/mcwl/common/enums/PaymentStatus.java new file mode 100644 index 0000000..5062ba1 --- /dev/null +++ b/mcwl-common/src/main/java/com/mcwl/common/enums/PaymentStatus.java @@ -0,0 +1,33 @@ +package com.mcwl.common.enums; + +/** + * @Author:ChenYan + * @Project:McWl + * @Package:com.mcwl.pay.domain + * @Filename:PaymentStatus + * @Description TODO + * @Date:2025/1/3 17:24 + */ + +public enum PaymentStatus { + + PENDING("待支付"), + COMPLETED("已支付"), + FAILED("支付失败"), + REFUNDED("已退款"); + + private final String description; + + PaymentStatus(String description) { + this.description = description; + } + + public String getDescription() { + return description; + } + + @Override + public String toString() { + return name() + "(" + description + ")"; + } +} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelRechargeRecordMapper.java b/mcwl-pay/src/main/java/com/mcwl/pay/mapper/ModelPurchaseRecordMapper.java similarity index 50% rename from mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelRechargeRecordMapper.java rename to mcwl-pay/src/main/java/com/mcwl/pay/mapper/ModelPurchaseRecordMapper.java index bfa7f3f..43bce44 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelRechargeRecordMapper.java +++ b/mcwl-pay/src/main/java/com/mcwl/pay/mapper/ModelPurchaseRecordMapper.java @@ -1,7 +1,7 @@ -package com.mcwl.resource.mapper; +package com.mcwl.pay.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.mcwl.resource.domain.ModelRechargeRecord; +import com.mcwl.pay.domain.ModelPurchaseRecord; import org.apache.ibatis.annotations.Mapper; /** @@ -11,5 +11,5 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper -public interface ModelRechargeRecordMapper extends BaseMapper { +public interface ModelPurchaseRecordMapper extends BaseMapper { } diff --git a/mcwl-pay/src/main/java/com/mcwl/pay/service/ModelPurchaseRecordService.java b/mcwl-pay/src/main/java/com/mcwl/pay/service/ModelPurchaseRecordService.java new file mode 100644 index 0000000..e04ecd3 --- /dev/null +++ b/mcwl-pay/src/main/java/com/mcwl/pay/service/ModelPurchaseRecordService.java @@ -0,0 +1,11 @@ +package com.mcwl.pay.service; + +/** + * @author DaiZibo + * @date 2025/3/28 + * @apiNote + */ + +public interface ModelPurchaseRecordService { + +} diff --git a/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/ModelPurchaseRecordServiceImpl.java b/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/ModelPurchaseRecordServiceImpl.java new file mode 100644 index 0000000..dec6bad --- /dev/null +++ b/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/ModelPurchaseRecordServiceImpl.java @@ -0,0 +1,18 @@ +package com.mcwl.pay.service.impl; + +import com.mcwl.pay.service.ModelPurchaseRecordService; +import org.springframework.stereotype.Service; + +/** + * 商品购买记录 + * + * @author DaiZibo + * @date 2025/3/28 + * @apiNote + */ + +@Service +public class ModelPurchaseRecordServiceImpl implements ModelPurchaseRecordService { + + +} diff --git a/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/OrderTradeServiceImpl.java b/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/OrderTradeServiceImpl.java index ab3db33..c16922f 100644 --- a/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/OrderTradeServiceImpl.java +++ b/mcwl-pay/src/main/java/com/mcwl/pay/service/impl/OrderTradeServiceImpl.java @@ -29,11 +29,13 @@ import com.mcwl.myInvitation.domain.Consume; import com.mcwl.myInvitation.service.CommissionRatioService; import com.mcwl.myInvitation.service.CommissionService; import com.mcwl.myInvitation.service.ConsumeService; +import com.mcwl.pay.domain.ModelPurchaseRecord; import com.mcwl.pay.domain.OrderTrade; import com.mcwl.pay.domain.enums.CommissionRationEnum; import com.mcwl.pay.domain.vo.IncomeVo; import com.mcwl.pay.domain.vo.TrendVo; import com.mcwl.pay.domain.vo.WalletRechargeRecordVo; +import com.mcwl.pay.mapper.ModelPurchaseRecordMapper; import com.mcwl.pay.mapper.OrderTradeMapper; import com.mcwl.pay.service.OrderTradeService; import com.mcwl.resource.domain.ModelImage; @@ -53,11 +55,8 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; /** * @Author:ChenYan @@ -81,6 +80,9 @@ public class OrderTradeServiceImpl extends ServiceImpl 模型金额(price) 邀请人提成(amount) */ - private Map modelOrderHandler(Long productUserId, Long modelId, SysUser sysUser) { + protected Map modelOrderHandler(Long productUserId, Long modelId, SysUser sysUser) { Consume consume = consumeService.lambdaQuery() .eq(Consume::getUserId, sysUser.getUserId()) .eq(Consume::getProductId, modelId) @@ -579,7 +588,7 @@ public class OrderTradeServiceImpl extends ServiceImpl 工作流金额(price) 邀请人提成(amount) */ - private Map workFlowOrderHandler(Long productUserId, Long workFlowId, SysUser sysUser) { + protected Map workFlowOrderHandler(Long productUserId, Long workFlowId, SysUser sysUser) { Consume consume = consumeService.lambdaQuery() .eq(Consume::getUserId, sysUser.getUserId()) @@ -612,7 +621,7 @@ public class OrderTradeServiceImpl extends ServiceImpl 图片金额(price) 邀请人提成(amount) */ - private Map imageOrderHandler(Long productUserId, Long imageId, SysUser sysUser) { + protected Map imageOrderHandler(Long productUserId, Long imageId, SysUser sysUser) { Consume consume = consumeService.lambdaQuery() .eq(Consume::getUserId, sysUser.getUserId()) @@ -646,7 +655,7 @@ public class OrderTradeServiceImpl extends ServiceImpl 商品价格(price) 邀请人提成(amount) */ - private Map getStringDoubleMap(Long productUserId, SysUser sysUser, Double price) { + protected Map getStringDoubleMap(Long productUserId, SysUser sysUser, Double price) { Double wallet = sysUser.getWallet(); if (wallet < price) { diff --git a/mcwl-resource/pom.xml b/mcwl-resource/pom.xml index adbf9f4..3f06f80 100644 --- a/mcwl-resource/pom.xml +++ b/mcwl-resource/pom.xml @@ -44,6 +44,5 @@ org.eclipse.paho.client.mqttv3 1.2.2 - diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelVersion.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelVersion.java index 57a419f..9d82274 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelVersion.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelVersion.java @@ -218,5 +218,4 @@ public class ModelVersion extends BaseEntity { @ApiModelProperty(value = "加密后文件大小") private String encryptionFileSize; - } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelRechargeRecord.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ResponseModelPurchaseRecord.java similarity index 94% rename from mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelRechargeRecord.java rename to mcwl-resource/src/main/java/com/mcwl/resource/domain/ResponseModelPurchaseRecord.java index 00b9fb0..472013e 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelRechargeRecord.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ResponseModelPurchaseRecord.java @@ -21,7 +21,7 @@ import java.util.Date; @NoArgsConstructor @AllArgsConstructor @Data -public class ModelRechargeRecord { +public class ResponseModelPurchaseRecord { private Long id; diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelMapper.java index d109f1c..1c44bf8 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/ModelMapper.java @@ -1,11 +1,10 @@ package com.mcwl.resource.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mcwl.resource.domain.ModelProduct; +import com.mcwl.resource.domain.ResponseModelPurchaseRecord; import com.mcwl.resource.domain.response.ResponseModelProduct; -import com.mcwl.resource.domain.vo.ModelImageLikeVo; import com.mcwl.resource.domain.vo.ModelLikeVo; import com.mcwl.resource.domain.vo.PageVo; import org.apache.ibatis.annotations.Mapper; @@ -46,4 +45,7 @@ public interface ModelMapper extends BaseMapper { List selectLikedModelsByUser(@Param("page") Page page, @Param("userId") Long userId, @Param("orderByColumn") String orderByColumn); + + ResponseModelPurchaseRecord selectIsBuy(@Param("id") Long id, @Param("userId") Long userId); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/ModelRechargeRecordService.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/ModelRechargeRecordService.java deleted file mode 100644 index 95f27be..0000000 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/ModelRechargeRecordService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.mcwl.resource.service; - -/** - * @author DaiZibo - * @date 2025/3/28 - * @apiNote - */ - -public interface ModelRechargeRecordService { -} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelRechargeRecordServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelRechargeRecordServiceImpl.java deleted file mode 100644 index c0c4110..0000000 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelRechargeRecordServiceImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mcwl.resource.service.impl; - -import com.mcwl.resource.mapper.ModelRechargeRecordMapper; -import com.mcwl.resource.service.ModelRechargeRecordService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * 商品购买记录 - * - * @author DaiZibo - * @date 2025/3/28 - * @apiNote - */ - -@Service -public class ModelRechargeRecordServiceImpl implements ModelRechargeRecordService { - - - @Autowired - private ModelRechargeRecordMapper rechargeRecordMapper; - - -} diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java index 593c67d..82b2deb 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java @@ -77,6 +77,7 @@ public class ModelServiceImpl extends ServiceImpl impl @Autowired private CollectServiceImpl collectService; + @Value("${mcwl.encryptUrl}") private String encryptUrl; @@ -575,20 +576,6 @@ public class ModelServiceImpl extends ServiceImpl impl modelProduct.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY,modelProduct.getCategory())); } - - //标签 -// if (StringUtils.isNotEmpty(modelProduct.getTags())){ -// ArrayList strings = new ArrayList<>(); -// String[] split = modelProduct.getTags().split(","); -// for (String s : split) { -// if (s != ""){ -// strings.add(s); -// } -// } -// modelProduct.setStyleList(strings); -// } -// modelProduct.setStyleList(new ArrayList<>()); - //功能 if (StringUtils.isNotEmpty(modelProduct.getFunctions())){ modelProduct.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS,modelProduct.getFunctions())); diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java index 80489f8..ec1c8d1 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelVersionServiceImpl.java @@ -9,6 +9,7 @@ import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.StringUtils; import com.mcwl.resource.domain.Collect; import com.mcwl.resource.domain.ModelProduct; +import com.mcwl.resource.domain.ResponseModelPurchaseRecord; import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.mapper.ModelMapper; import com.mcwl.resource.mapper.ModelVersionMapper; @@ -40,9 +41,6 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo @Autowired private ModelMapper modelMapper; - - - @Autowired private ModelVersionMapper modelVersionMapper; @@ -141,11 +139,17 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo return R.fail(HttpStatus.SHOW_ERROR_MSG,"此文件不可下载"); } - //校验是否购收费/购买 + //查询主表信息 ModelProduct modelProduct = modelMapper.selectById(modelVersion.getModelId()); if (modelProduct.getIsFree() == 0){ - - + //校验是否收费 + ResponseModelPurchaseRecord modelPurchaseRecord = modelMapper.selectIsBuy(modelProduct.getId(),SecurityUtils.getUserId()); + if (StringUtils.isNull(modelPurchaseRecord)){ + //校验是否是自己的 + if (!SecurityUtils.getUserId().equals(modelProduct.getUserId())){ + return R.fail(HttpStatus.SHOW_ERROR_MSG,"请先购买"); + } + } } if (modelVersion.getIsEncrypt() == 1){ diff --git a/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml index 992e223..8beee15 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml @@ -147,4 +147,12 @@ desc + +