Compare commits
4 Commits
50e410eb54
...
61d8a0ca88
Author | SHA1 | Date |
---|---|---|
|
61d8a0ca88 | |
|
54b79c03ca | |
|
b74323dfcc | |
|
f1acb5c183 |
|
@ -2,6 +2,7 @@ package com.mcwl.web.controller.communityCenter;
|
||||||
|
|
||||||
|
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.communityCenter.domain.dto.CommunityListPageRes;
|
import com.mcwl.communityCenter.domain.dto.CommunityListPageRes;
|
||||||
import com.mcwl.communityCenter.domain.dto.CommunityRes;
|
import com.mcwl.communityCenter.domain.dto.CommunityRes;
|
||||||
|
@ -39,6 +40,25 @@ public class CommunityController {
|
||||||
return communityService.listByPage(communityListPageRes);
|
return communityService.listByPage(communityListPageRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 我创建的社区
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "我创建的社区")
|
||||||
|
@PostMapping("myCreate")
|
||||||
|
public R<Object> getMyCreateCommunity(@RequestBody @Valid PageDomain pageDomain) {
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 我加入的社区
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "我加入的社区")
|
||||||
|
@GetMapping("myJoin")
|
||||||
|
public R<Object> getMyJoinCommunity() {
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加社区
|
* 添加社区
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mcwl.web.controller.resource;
|
package com.mcwl.web.controller.pay.AliPay;
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@Api(tags = "商品购买记录")
|
@Api(tags = "商品购买记录")
|
||||||
@RequestMapping("/modelRechargeRecord")
|
@RequestMapping("/modelRechargeRecord")
|
||||||
@RestController
|
@RestController
|
||||||
public class ModelRechargeRecordController {
|
public class ModelPurchaseRecordController {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -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 + ")";
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,4 +20,11 @@ public class CommunityListPageRes extends PageDomain {
|
||||||
@ApiModelProperty(value = "社区标签")
|
@ApiModelProperty(value = "社区标签")
|
||||||
private Long communityTag;
|
private Long communityTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "用户id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,14 @@ package com.mcwl.communityCenter.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.mcwl.communityCenter.domain.Community;
|
import com.mcwl.communityCenter.domain.Community;
|
||||||
|
import org.apache.ibatis.annotations.MapKey;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
|
@ -23,13 +26,18 @@ public interface CommunityMapper extends BaseMapper<Community> {
|
||||||
* 查询所有社区加入人数, 以map形式返回,key为社区id,value为加入人数
|
* 查询所有社区加入人数, 以map形式返回,key为社区id,value为加入人数
|
||||||
* @return map
|
* @return map
|
||||||
*/
|
*/
|
||||||
|
@MapKey("id")
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
Map<Long, Integer> selectCommunityJoinNum();
|
Map<Long, Map<String, Object>> selectCommunityJoinNum();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有社区发布数量,以map形式返回,key为社区id,value为发布数量
|
* 查询所有社区发布数量,以map形式返回,key为社区id,value为发布数量
|
||||||
* @return map
|
* @return map
|
||||||
*/
|
*/
|
||||||
|
@MapKey("id")
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
Map<Long, Integer> selectCommunityPublishNum();
|
Map<Long, Map<String, Object>> selectCommunityPublishNum();
|
||||||
|
|
||||||
|
@InterceptorIgnore(tenantLine = "true")
|
||||||
|
List<Community> selectPageByCommunityTag(@Param("page") Page<Community> page, @Param("communityTag") Long communityTag);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,22 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
||||||
public TableDataInfo listByPage(CommunityListPageRes communityListPageRes) {
|
public TableDataInfo listByPage(CommunityListPageRes communityListPageRes) {
|
||||||
|
|
||||||
// 查询社区加入人数,以map形式返回,key为社区id,value为加入人数
|
// 查询社区加入人数,以map形式返回,key为社区id,value为加入人数
|
||||||
Map<Long, Integer> communityJoinNumMap = baseMapper.selectCommunityJoinNum();
|
Map<Long, Integer> communityJoinNumMap = new HashMap<>();
|
||||||
|
Map<Long, Map<String, Object>> joinMap = baseMapper.selectCommunityJoinNum();
|
||||||
|
if (joinMap != null && !joinMap.isEmpty()) {
|
||||||
|
joinMap.forEach((key, value) -> {
|
||||||
|
communityJoinNumMap.put(key, Integer.valueOf(value.get("joinNum").toString()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 查询社区发布数,以map形式返回,key为社区id,value为发布数
|
// 查询社区发布数,以map形式返回,key为社区id,value为发布数
|
||||||
Map<Long, Integer> communityPublishNumMap = baseMapper.selectCommunityPublishNum();
|
Map<Long, Integer> communityPublishNumMap = new HashMap<>();
|
||||||
|
Map<Long, Map<String, Object>> publishMap = baseMapper.selectCommunityPublishNum();
|
||||||
|
if (publishMap != null && !publishMap.isEmpty()) {
|
||||||
|
publishMap.forEach((key, value) -> {
|
||||||
|
communityPublishNumMap.put(key, Integer.valueOf(value.get("publishNum").toString()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Page<Community> page = new Page<>(communityListPageRes.getPageNum(), communityListPageRes.getPageSize());
|
Page<Community> page = new Page<>(communityListPageRes.getPageNum(), communityListPageRes.getPageSize());
|
||||||
|
|
||||||
|
@ -59,10 +71,14 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
||||||
OrderItem orderItem = new OrderItem(communityListPageRes.getOrderByColumn(), isAsc);
|
OrderItem orderItem = new OrderItem(communityListPageRes.getOrderByColumn(), isAsc);
|
||||||
page.addOrder(orderItem);
|
page.addOrder(orderItem);
|
||||||
|
|
||||||
baseMapper.selectPage(page, new LambdaQueryWrapper<Community>()
|
List<Community> communityList;
|
||||||
.eq(communityListPageRes.getCommunityTag() != null, Community::getCommunityTag, communityListPageRes.getCommunityTag()));
|
if (Objects.isNull(communityListPageRes.getUserId())) {
|
||||||
|
communityList = baseMapper.selectPageByCommunityTag(page, communityListPageRes.getCommunityTag());
|
||||||
|
} else {
|
||||||
|
baseMapper.selectPage(page, null);
|
||||||
|
communityList = page.getRecords();
|
||||||
|
}
|
||||||
|
|
||||||
List<Community> communityList = page.getRecords();
|
|
||||||
List<CommunityVo> communityVoList = new ArrayList<>();
|
List<CommunityVo> communityVoList = new ArrayList<>();
|
||||||
|
|
||||||
LocalDate currentLocalDate = LocalDate.now(ZoneId.systemDefault());
|
LocalDate currentLocalDate = LocalDate.now(ZoneId.systemDefault());
|
||||||
|
|
|
@ -4,6 +4,16 @@
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.mcwl.communityCenter.mapper.CommunityMapper">
|
<mapper namespace="com.mcwl.communityCenter.mapper.CommunityMapper">
|
||||||
|
|
||||||
|
<resultMap id="CommunityJoinNumMap" type="java.util.HashMap">
|
||||||
|
<id property="id" column="id" javaType="java.lang.Long" /> <!-- 键字段 -->
|
||||||
|
<result property="joinNum" column="join_num" javaType="java.lang.Integer" /> <!-- 值字段 -->
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="CommunityPublishNumMap" type="java.util.HashMap">
|
||||||
|
<id property="id" column="id" javaType="java.lang.Long" /> <!-- 键字段 -->
|
||||||
|
<result property="publishNum" column="publish_num" javaType="java.lang.Integer" /> <!-- 值字段 -->
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<select id="getByTenantIdAndCommunityId" resultType="com.mcwl.communityCenter.domain.Community">
|
<select id="getByTenantIdAndCommunityId" resultType="com.mcwl.communityCenter.domain.Community">
|
||||||
select id,
|
select id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
|
@ -17,16 +27,19 @@
|
||||||
and del_flag = '0';
|
and del_flag = '0';
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCommunityJoinNum" resultType="java.util.Map">
|
<select id="selectCommunityJoinNum" resultMap="CommunityJoinNumMap">
|
||||||
select c.id, COALESCE(count(*), 0)
|
select c.id as id, COALESCE(count(*), 0) as join_num
|
||||||
from cc_community c
|
from cc_community c
|
||||||
join cc_invite i on c.id = i.community_id
|
join cc_invite i on c.id = i.community_id
|
||||||
where c.del_flag = '0'
|
where c.del_flag = '0'
|
||||||
and i.del_flag = '0'
|
and i.del_flag = '0'
|
||||||
group by i.community_id
|
group by i.community_id
|
||||||
</select>
|
</select>
|
||||||
<select id="selectCommunityPublishNum" resultType="java.util.Map">
|
|
||||||
select c.id, COALESCE(count(*), 0)
|
|
||||||
|
|
||||||
|
<select id="selectCommunityPublishNum" resultMap="CommunityPublishNumMap">
|
||||||
|
select c.id as id, COALESCE(count(*), 0) as publish_num
|
||||||
from cc_community c
|
from cc_community c
|
||||||
join cc_publish p on c.id = p.community_id
|
join cc_publish p on c.id = p.community_id
|
||||||
join cc_question q on c.id = q.community_id
|
join cc_question q on c.id = q.community_id
|
||||||
|
@ -35,4 +48,26 @@
|
||||||
and q.del_flag = '0'
|
and q.del_flag = '0'
|
||||||
group by p.community_id
|
group by p.community_id
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectPageByCommunityTag" resultType="com.mcwl.communityCenter.domain.Community">
|
||||||
|
select
|
||||||
|
id,
|
||||||
|
tenant_id,
|
||||||
|
image_url,
|
||||||
|
community_name,
|
||||||
|
description,
|
||||||
|
community_tag,
|
||||||
|
type,
|
||||||
|
price,
|
||||||
|
validity_type,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time
|
||||||
|
from cc_community
|
||||||
|
<where>
|
||||||
|
<if test="communityTag != null">
|
||||||
|
and c.community_tag = #{communityTag}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -1,7 +1,7 @@
|
||||||
package com.mcwl.resource.mapper;
|
package com.mcwl.pay.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
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;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,5 +11,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ModelRechargeRecordMapper extends BaseMapper<ModelRechargeRecord> {
|
public interface ModelPurchaseRecordMapper extends BaseMapper<ModelPurchaseRecord> {
|
||||||
}
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.mcwl.pay.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DaiZibo
|
||||||
|
* @date 2025/3/28
|
||||||
|
* @apiNote
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ModelPurchaseRecordService {
|
||||||
|
|
||||||
|
}
|
|
@ -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 {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -123,6 +125,12 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
||||||
SysUser sysUser = sysUserService.selectUserById(SecurityUtils.getUserId());
|
SysUser sysUser = sysUserService.selectUserById(SecurityUtils.getUserId());
|
||||||
// 获取邀请人id
|
// 获取邀请人id
|
||||||
Long inviterUserId = sysUser.getInviterUserId();
|
Long inviterUserId = sysUser.getInviterUserId();
|
||||||
|
|
||||||
|
if (Objects.equals(productUserId, sysUser.getUserId())) {
|
||||||
|
throw new ServiceException("不能购买自己的商品", HttpStatus.SHOW_ERROR_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 邀请者获取的提成
|
// 邀请者获取的提成
|
||||||
Map<String, Double> map = new HashMap<>();
|
Map<String, Double> map = new HashMap<>();
|
||||||
if (productType == 0) {
|
if (productType == 0) {
|
||||||
|
@ -134,14 +142,13 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.isEmpty()) {
|
if (map.isEmpty()) {
|
||||||
throw new RuntimeException("商品不存在");
|
throw new ServiceException("商品不存在", HttpStatus.SHOW_ERROR_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 邀请人提成
|
// 邀请人提成
|
||||||
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());
|
||||||
|
@ -151,6 +158,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)) {
|
||||||
|
@ -543,7 +558,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)
|
||||||
|
@ -573,7 +588,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())
|
||||||
|
@ -606,7 +621,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())
|
||||||
|
@ -640,7 +655,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) {
|
||||||
|
@ -704,6 +719,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
||||||
.subtract(priceBigDecimal)
|
.subtract(priceBigDecimal)
|
||||||
.setScale(2, RoundingMode.HALF_UP)
|
.setScale(2, RoundingMode.HALF_UP)
|
||||||
.doubleValue());
|
.doubleValue());
|
||||||
|
sysUserService.updateUser(sysUser);
|
||||||
// 更新商家钱包金额
|
// 更新商家钱包金额
|
||||||
SysUser merchants = sysUserService.selectUserById(productUserId);
|
SysUser merchants = sysUserService.selectUserById(productUserId);
|
||||||
merchants.setWallet(new BigDecimal(merchants.getWallet().toString())
|
merchants.setWallet(new BigDecimal(merchants.getWallet().toString())
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -218,5 +218,4 @@ public class ModelVersion extends BaseEntity {
|
||||||
|
|
||||||
@ApiModelProperty(value = "加密后文件大小")
|
@ApiModelProperty(value = "加密后文件大小")
|
||||||
private String encryptionFileSize;
|
private String encryptionFileSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Date;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public class ModelRechargeRecord {
|
public class ResponseModelPurchaseRecord {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.mcwl.resource.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DaiZibo
|
|
||||||
* @date 2025/3/28
|
|
||||||
* @apiNote
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface ModelRechargeRecordService {
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -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()));
|
||||||
|
|
|
@ -9,6 +9,7 @@ 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.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;
|
||||||
|
@ -40,9 +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;
|
||||||
|
|
||||||
|
@ -141,11 +139,17 @@ 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());
|
ModelProduct modelProduct = modelMapper.selectById(modelVersion.getModelId());
|
||||||
if (modelProduct.getIsFree() == 0){
|
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){
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue