Merge branch 'feature/community-center' into preview
commit
b74323dfcc
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加社区
|
* 添加社区
|
||||||
|
|
|
@ -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>
|
|
@ -123,6 +123,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,7 +140,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.isEmpty()) {
|
if (map.isEmpty()) {
|
||||||
throw new RuntimeException("商品不存在");
|
throw new ServiceException("商品不存在", HttpStatus.SHOW_ERROR_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 邀请人提成
|
// 邀请人提成
|
||||||
|
@ -704,6 +710,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())
|
||||||
|
|
Loading…
Reference in New Issue