Compare commits

...

5 Commits

Author SHA1 Message Date
yang ef36122845 Merge branch 'feature/community-center' into preview 2025-03-29 15:54:02 +08:00
Diyu0904 dbabbb686e 修改商品购买
文件下载新增购买校验
2025-03-29 14:55:23 +08:00
Diyu0904 61d8a0ca88 修改商品购买
文件下载新增购买校验
2025-03-29 14:55:11 +08:00
Diyu0904 54b79c03ca Merge branch 'feature/admin' into preview 2025-03-28 16:53:21 +08:00
Diyu0904 50e410eb54 修改商品购买
修改自定义状态吗
2025-03-28 16:52:28 +08:00
19 changed files with 264 additions and 41 deletions

BIN
blob 100644

Binary file not shown.

View File

@ -0,0 +1,19 @@
package com.mcwl.web.controller.pay.AliPay;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author DaiZibo
* @date 2025/3/28
* @apiNote
*/
@Api(tags = "商品购买记录")
@RequestMapping("/modelRechargeRecord")
@RestController
public class ModelPurchaseRecordController {
}

View File

@ -7,9 +7,10 @@ import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R; import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.communityCenter.service.InviteService;
import com.mcwl.myInvitation.domain.Consume; import com.mcwl.myInvitation.domain.Consume;
import com.mcwl.myInvitation.service.ConsumeService; 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.ModelProduct;
import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.dto.ModelImagePageRes;
@ -48,6 +49,8 @@ import java.util.stream.Collectors;
@RequestMapping("/model") @RequestMapping("/model")
public class MallProductController extends BaseController { public class MallProductController extends BaseController {
@Autowired
private ModelPurchaseRecordMapper modelPurchaseRecordMapper;
@Autowired @Autowired
private ModelService modelService; private ModelService modelService;
@ -163,13 +166,13 @@ public class MallProductController extends BaseController {
R<ModelProduct> modelProductR = modelService.selectModelById(id); R<ModelProduct> modelProductR = modelService.selectModelById(id);
ModelProduct data = modelProductR.getData(); ModelProduct data = modelProductR.getData();
if (Objects.nonNull(data)) { if (Objects.nonNull(data)) {
Consume consume = consumeService.lambdaQuery() LambdaQueryWrapper<ModelPurchaseRecord> wrapper = new LambdaQueryWrapper<>();
.eq(Consume::getUserId, SecurityUtils.getUserId()) wrapper.eq(ModelPurchaseRecord::getUserId, SecurityUtils.getUserId())
.eq(Consume::getProductId, id) .eq(ModelPurchaseRecord::getProductId, id)
.eq(Consume::getType, 0) .eq(ModelPurchaseRecord::getProductType, 0);
.one(); ModelPurchaseRecord modelPurchaseRecord = modelPurchaseRecordMapper.selectOne(wrapper);
data.setIsBuy(1); data.setIsBuy(1);
if (Objects.isNull(consume)) { if (Objects.isNull(modelPurchaseRecord)) {
data.setIsBuy(0); data.setIsBuy(0);
} }
modelProductR.setData(data); modelProductR.setData(data);

View File

@ -0,0 +1,31 @@
package com.mcwl.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/**
* @AuthorChenYan
* @ProjectMcWl
* @Packagecom.mcwl.pay.domain
* @FilenamePaymentStatus
* @Description TODO
* @Date2025/1/3 17:24
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum CommissionRationEnum {
/**
*
*/
COMMISSION_RATION_INVITER_USER("CommissionRationInviterUser"),
/**
*
*/
COMMISSION_RATION_MERCHANT("CommissionRationMerchant");
private String name;
}

View File

@ -0,0 +1,33 @@
package com.mcwl.common.enums;
/**
* @AuthorChenYan
* @ProjectMcWl
* @Packagecom.mcwl.pay.domain
* @FilenamePaymentStatus
* @Description TODO
* @Date2025/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 + ")";
}
}

View File

@ -12,7 +12,9 @@ public enum ResultCode {
SUCCESS(200),//成功 SUCCESS(200),//成功
FAIL(400),//失败 FAIL(400),//
FAIL_MSG(12202),//失败
FAIL_SIGN_IN(401),//登录失败 FAIL_SIGN_IN(401),//登录失败

View File

@ -1,9 +1,6 @@
package com.mcwl.framework.web.service; package com.mcwl.framework.web.service;
import com.mcwl.common.constant.CacheConstants; import com.mcwl.common.constant.*;
import com.mcwl.common.constant.Constants;
import com.mcwl.common.constant.RedisConstants;
import com.mcwl.common.constant.UserConstants;
import com.mcwl.common.core.domain.entity.SysUser; import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.core.domain.model.LoginUser; import com.mcwl.common.core.domain.model.LoginUser;
import com.mcwl.common.core.redis.RedisCache; import com.mcwl.common.core.redis.RedisCache;
@ -240,13 +237,13 @@ public class SysLoginService
System.out.println("验证码:"+cacheObject); System.out.println("验证码:"+cacheObject);
if (cacheObject == null) { if (cacheObject == null) {
// 处理未找到验证码的情况 // 处理未找到验证码的情况
throw new ErrorCodeException(ResultCode.FAIL,"验证码已过期或未发送"); throw new ErrorCodeException(ResultCode.FAIL_MSG,"验证码已过期或未发送");
} }
String c = (String) cacheObject; String c = (String) cacheObject;
if (!c.equals(code)){ if (!c.equals(code)){
//验证码错误 //验证码错误
throw new ErrorCodeException(ResultCode.FAIL,"验证码错误"); throw new ErrorCodeException(ResultCode.FAIL_MSG,"验证码错误");
} }
} }

View File

@ -0,0 +1,38 @@
package com.mcwl.pay.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
*
* @author DaiZibo
* @date 2025/3/28
* @apiNote
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ModelPurchaseRecord {
private Long id;
private Long productId;
private Integer productType;
private Long userId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}

View File

@ -0,0 +1,15 @@
package com.mcwl.pay.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mcwl.pay.domain.ModelPurchaseRecord;
import org.apache.ibatis.annotations.Mapper;
/**
* @author DaiZibo
* @date 2025/3/28
* @apiNote
*/
@Mapper
public interface ModelPurchaseRecordMapper extends BaseMapper<ModelPurchaseRecord> {
}

View File

@ -0,0 +1,11 @@
package com.mcwl.pay.service;
/**
* @author DaiZibo
* @date 2025/3/28
* @apiNote
*/
public interface ModelPurchaseRecordService {
}

View File

@ -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 {
}

View File

@ -29,11 +29,13 @@ import com.mcwl.myInvitation.domain.Consume;
import com.mcwl.myInvitation.service.CommissionRatioService; import com.mcwl.myInvitation.service.CommissionRatioService;
import com.mcwl.myInvitation.service.CommissionService; import com.mcwl.myInvitation.service.CommissionService;
import com.mcwl.myInvitation.service.ConsumeService; import com.mcwl.myInvitation.service.ConsumeService;
import com.mcwl.pay.domain.ModelPurchaseRecord;
import com.mcwl.pay.domain.OrderTrade; import com.mcwl.pay.domain.OrderTrade;
import com.mcwl.pay.domain.enums.CommissionRationEnum; import com.mcwl.pay.domain.enums.CommissionRationEnum;
import com.mcwl.pay.domain.vo.IncomeVo; import com.mcwl.pay.domain.vo.IncomeVo;
import com.mcwl.pay.domain.vo.TrendVo; import com.mcwl.pay.domain.vo.TrendVo;
import com.mcwl.pay.domain.vo.WalletRechargeRecordVo; import com.mcwl.pay.domain.vo.WalletRechargeRecordVo;
import com.mcwl.pay.mapper.ModelPurchaseRecordMapper;
import com.mcwl.pay.mapper.OrderTradeMapper; import com.mcwl.pay.mapper.OrderTradeMapper;
import com.mcwl.pay.service.OrderTradeService; import com.mcwl.pay.service.OrderTradeService;
import com.mcwl.resource.domain.ModelImage; import com.mcwl.resource.domain.ModelImage;
@ -53,11 +55,8 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/** /**
* @AuthorChenYan * @AuthorChenYan
@ -81,6 +80,9 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
@Autowired @Autowired
private CommissionService commissionService; private CommissionService commissionService;
@Autowired
private ModelPurchaseRecordMapper modelPurchaseRecordMapper;
@Autowired @Autowired
private ConsumeService consumeService; private ConsumeService consumeService;
@ -147,7 +149,6 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
Double amount = map.get("amount"); Double amount = map.get("amount");
// 商品价格 // 商品价格
Double price = map.get("price"); Double price = map.get("price");
// 保存消费表 // 保存消费表
Consume consume = new Consume(); Consume consume = new Consume();
consume.setUserId(SecurityUtils.getUserId()); consume.setUserId(SecurityUtils.getUserId());
@ -158,6 +159,14 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
consume.setConsumeDate(new Date()); consume.setConsumeDate(new Date());
consumeService.save(consume); consumeService.save(consume);
//添加购买记录表
ModelPurchaseRecord modelPurchaseRecord = ModelPurchaseRecord.builder()
.productId(productId)
.createTime(consume.getCreateTime())
.userId(SecurityUtils.getUserId())
.productType(consume.getType()).build();
modelPurchaseRecordMapper.insert(modelPurchaseRecord);
// 通过sysUser获取邀请人id // 通过sysUser获取邀请人id
if (Objects.isNull(inviterUserId)) { if (Objects.isNull(inviterUserId)) {
@ -555,7 +564,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
* @param sysUser * @param sysUser
* @return Map<String, Double> (price) (amount) * @return Map<String, Double> (price) (amount)
*/ */
private Map<String, Double> modelOrderHandler(Long productUserId, Long modelId, SysUser sysUser) { protected Map<String, Double> modelOrderHandler(Long productUserId, Long modelId, SysUser sysUser) {
Consume consume = consumeService.lambdaQuery() Consume consume = consumeService.lambdaQuery()
.eq(Consume::getUserId, sysUser.getUserId()) .eq(Consume::getUserId, sysUser.getUserId())
.eq(Consume::getProductId, modelId) .eq(Consume::getProductId, modelId)
@ -585,7 +594,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
* @param sysUser * @param sysUser
* @return Map<String, Double> (price) (amount) * @return Map<String, Double> (price) (amount)
*/ */
private Map<String, Double> workFlowOrderHandler(Long productUserId, Long workFlowId, SysUser sysUser) { protected Map<String, Double> workFlowOrderHandler(Long productUserId, Long workFlowId, SysUser sysUser) {
Consume consume = consumeService.lambdaQuery() Consume consume = consumeService.lambdaQuery()
.eq(Consume::getUserId, sysUser.getUserId()) .eq(Consume::getUserId, sysUser.getUserId())
@ -618,7 +627,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
* @param sysUser * @param sysUser
* @return Map<String, Double> (price) (amount) * @return Map<String, Double> (price) (amount)
*/ */
private Map<String, Double> imageOrderHandler(Long productUserId, Long imageId, SysUser sysUser) { protected Map<String, Double> imageOrderHandler(Long productUserId, Long imageId, SysUser sysUser) {
Consume consume = consumeService.lambdaQuery() Consume consume = consumeService.lambdaQuery()
.eq(Consume::getUserId, sysUser.getUserId()) .eq(Consume::getUserId, sysUser.getUserId())
@ -652,7 +661,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
* @param price * @param price
* @return Map<String, Double> (price) (amount) * @return Map<String, Double> (price) (amount)
*/ */
private Map<String, Double> getStringDoubleMap(Long productUserId, SysUser sysUser, Double price) { protected Map<String, Double> getStringDoubleMap(Long productUserId, SysUser sysUser, Double price) {
Double wallet = sysUser.getWallet(); Double wallet = sysUser.getWallet();
if (wallet < price) { if (wallet < price) {

View File

@ -44,6 +44,5 @@
<artifactId>org.eclipse.paho.client.mqttv3</artifactId> <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.2</version> <version>1.2.2</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -218,5 +218,4 @@ public class ModelVersion extends BaseEntity {
@ApiModelProperty(value = "加密后文件大小") @ApiModelProperty(value = "加密后文件大小")
private String encryptionFileSize; private String encryptionFileSize;
} }

View File

@ -0,0 +1,38 @@
package com.mcwl.resource.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
*
* @author DaiZibo
* @date 2025/3/28
* @apiNote
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ResponseModelPurchaseRecord {
private Long id;
private Long productId;
private Integer productType;
private Long userId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}

View File

@ -1,11 +1,10 @@
package com.mcwl.resource.mapper; package com.mcwl.resource.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mcwl.resource.domain.ModelProduct; import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.ResponseModelPurchaseRecord;
import com.mcwl.resource.domain.response.ResponseModelProduct; 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.ModelLikeVo;
import com.mcwl.resource.domain.vo.PageVo; import com.mcwl.resource.domain.vo.PageVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -46,4 +45,7 @@ public interface ModelMapper extends BaseMapper<ModelProduct> {
List<ModelLikeVo> selectLikedModelsByUser(@Param("page") Page<ModelLikeVo> page, List<ModelLikeVo> selectLikedModelsByUser(@Param("page") Page<ModelLikeVo> page,
@Param("userId") Long userId, @Param("userId") Long userId,
@Param("orderByColumn") String orderByColumn); @Param("orderByColumn") String orderByColumn);
ResponseModelPurchaseRecord selectIsBuy(@Param("id") Long id, @Param("userId") Long userId);
} }

View File

@ -77,6 +77,7 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
@Autowired @Autowired
private CollectServiceImpl collectService; private CollectServiceImpl collectService;
@Value("${mcwl.encryptUrl}") @Value("${mcwl.encryptUrl}")
private String encryptUrl; private String encryptUrl;
@ -575,20 +576,6 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
modelProduct.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY,modelProduct.getCategory())); modelProduct.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY,modelProduct.getCategory()));
} }
//标签
// if (StringUtils.isNotEmpty(modelProduct.getTags())){
// ArrayList<String> 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())){ if (StringUtils.isNotEmpty(modelProduct.getFunctions())){
modelProduct.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS,modelProduct.getFunctions())); modelProduct.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS,modelProduct.getFunctions()));

View File

@ -8,6 +8,8 @@ import com.mcwl.common.core.domain.R;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils; import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.Collect; 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.domain.ModelVersion;
import com.mcwl.resource.mapper.ModelMapper; import com.mcwl.resource.mapper.ModelMapper;
import com.mcwl.resource.mapper.ModelVersionMapper; import com.mcwl.resource.mapper.ModelVersionMapper;
@ -39,7 +41,6 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
@Autowired @Autowired
private ModelMapper modelMapper; private ModelMapper modelMapper;
@Autowired @Autowired
private ModelVersionMapper modelVersionMapper; private ModelVersionMapper modelVersionMapper;
@ -138,6 +139,19 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
return R.fail(HttpStatus.SHOW_ERROR_MSG,"此文件不可下载"); 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){ if (modelVersion.getIsEncrypt() == 1){
if (StringUtils.isEmpty(modelVersion.getEncryptionFilePath())){ if (StringUtils.isEmpty(modelVersion.getEncryptionFilePath())){

View File

@ -147,4 +147,12 @@
desc desc
</select> </select>
<select id="selectIsBuy" resultType="com.mcwl.resource.domain.ResponseModelPurchaseRecord">
SELECT id,product_id,product_type,user_id
FROM model_purchase_record
WHERE product_id = #{id}
and user_id = #{userId}
and product_type= 0
</select>
</mapper> </mapper>