Compare commits
3 Commits
89b2c58938
...
1f50a33c78
Author | SHA1 | Date |
---|---|---|
|
1f50a33c78 | |
|
f432697d94 | |
|
80fcfd12ea |
|
@ -30,6 +30,11 @@ public class IncomeInfo extends BaseEntity {
|
|||
*/
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 类型 0付费加入 1付费问答
|
||||
*/
|
||||
|
|
|
@ -41,6 +41,12 @@ public class CommunityDetailVo {
|
|||
@ApiModelProperty(value = "社区名称")
|
||||
private String communityName;
|
||||
|
||||
/**
|
||||
* 社区标签
|
||||
*/
|
||||
@ApiModelProperty(value = "社区标签")
|
||||
private Integer communityTag;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
|
@ -53,6 +59,18 @@ public class CommunityDetailVo {
|
|||
@ApiModelProperty(value = "描述")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 社区类型
|
||||
*/
|
||||
@ApiModelProperty(value = "社区类型")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 有效期天数
|
||||
*/
|
||||
@ApiModelProperty(value = "有效期天数")
|
||||
private Integer validityDay;
|
||||
|
||||
/**
|
||||
* 创建天数
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,7 @@ public interface IncomeInfoMapper extends BaseMapper<IncomeInfo> {
|
|||
@InterceptorIgnore(tenantLine = "true")
|
||||
IncomeAmountVo questionIncome(@Param("userId") Long userId);
|
||||
|
||||
Double totalIncome();
|
||||
Double totalIncome(@Param("userId") Long userId);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<IncomeInfoListVo> incomeList(Page<IncomeInfo> page,
|
||||
|
|
|
@ -14,10 +14,7 @@ import com.mcwl.common.exception.ServiceException;
|
|||
import com.mcwl.common.utils.SecurityUtils;
|
||||
import com.mcwl.common.utils.StringUtils;
|
||||
import com.mcwl.communityCenter.constant.AdviceConstant;
|
||||
import com.mcwl.communityCenter.domain.Community;
|
||||
import com.mcwl.communityCenter.domain.CommunityAdvice;
|
||||
import com.mcwl.communityCenter.domain.CommunityUser;
|
||||
import com.mcwl.communityCenter.domain.Publish;
|
||||
import com.mcwl.communityCenter.domain.*;
|
||||
import com.mcwl.communityCenter.domain.dto.*;
|
||||
import com.mcwl.communityCenter.domain.vo.CommunityDetailVo;
|
||||
import com.mcwl.communityCenter.domain.vo.CommunityVo;
|
||||
|
@ -25,15 +22,19 @@ import com.mcwl.communityCenter.mapper.CommunityAdviceMapper;
|
|||
import com.mcwl.communityCenter.mapper.CommunityMapper;
|
||||
import com.mcwl.communityCenter.mapper.CommunityUserMapper;
|
||||
import com.mcwl.communityCenter.service.CommunityService;
|
||||
import com.mcwl.communityCenter.service.IncomeInfoService;
|
||||
import com.mcwl.communityCenter.service.PublishService;
|
||||
import com.mcwl.myInvitation.domain.CommissionRatio;
|
||||
import com.mcwl.myInvitation.domain.Consume;
|
||||
import com.mcwl.myInvitation.mapper.ConsumeMapper;
|
||||
import com.mcwl.myInvitation.service.CommissionRatioService;
|
||||
import com.mcwl.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
@ -58,6 +59,10 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
|
||||
private final ConsumeMapper consumeMapper;
|
||||
|
||||
private final IncomeInfoService incomeInfoService;
|
||||
|
||||
private final CommissionRatioService commissionRatioService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -142,6 +147,29 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
|
||||
sysUserService.updateUser(user);
|
||||
|
||||
|
||||
|
||||
// 从redis获取提成比例
|
||||
// 抽取社区比例
|
||||
String commissionRationCommunity = redisCache.getCacheObject("CommissionRationCommunity");
|
||||
if (Objects.isNull(commissionRationCommunity)) {
|
||||
CommissionRatio commissionRatio = commissionRatioService.lambdaQuery()
|
||||
.eq(CommissionRatio::getType, 2)
|
||||
.one();
|
||||
commissionRationCommunity = commissionRatio.getRatio().toString();
|
||||
redisCache.setCacheObject("CommissionRationCommunity", commissionRationCommunity);
|
||||
}
|
||||
|
||||
SysUser tenantUser = sysUserService.selectUserById(tenantId);
|
||||
BigDecimal getWallet = priceBigDecimal
|
||||
.multiply(new BigDecimal("1").subtract(new BigDecimal(commissionRationCommunity)));
|
||||
tenantUser.setWallet(getWallet
|
||||
.add(new BigDecimal(tenantUser.getWallet().toString()))
|
||||
.setScale(2, RoundingMode.HALF_UP)
|
||||
.doubleValue());
|
||||
sysUserService.updateUser(tenantUser);
|
||||
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
Date startTime = now.getTime();
|
||||
now.add(Calendar.YEAR, community.getValidityDay());
|
||||
|
@ -170,7 +198,7 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
communityAdvice.setAdviceType(AdviceConstant.COMMUNITY_NOTICE);
|
||||
communityAdvice.setUserId(tenantId);
|
||||
communityAdvice.setContent(StringUtils.format("{}加入{}社区,金币+{}",
|
||||
SecurityUtils.getLoginUser().getUser().getNickName(), community.getCommunityName(), price));
|
||||
SecurityUtils.getLoginUser().getUser().getNickName(), community.getCommunityName(), getWallet));
|
||||
communityAdviceMapper.insert(communityAdvice);
|
||||
|
||||
Consume consume = new Consume();
|
||||
|
@ -183,12 +211,20 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
|
||||
consume = new Consume();
|
||||
consume.setUserId(community.getTenantId());
|
||||
consume.setAmount(price);
|
||||
consume.setAmount(getWallet.doubleValue());
|
||||
consume.setProductId(communityId);
|
||||
consume.setType(3);
|
||||
consume.setWallet(sysUserService.selectUserById(community.getTenantId()).getWallet());
|
||||
consumeMapper.insert(consume);
|
||||
|
||||
IncomeInfo incomeInfo = new IncomeInfo();
|
||||
incomeInfo.setTenantId(tenantId);
|
||||
incomeInfo.setCommunityId(communityId);
|
||||
incomeInfo.setUserId(tenantId);
|
||||
incomeInfo.setType(0);
|
||||
incomeInfo.setAmount(getWallet.doubleValue());
|
||||
incomeInfoService.save(incomeInfo);
|
||||
|
||||
redisCache.deleteObject("communityJoinNumMap");
|
||||
|
||||
|
||||
|
@ -299,7 +335,7 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
|
||||
List<Community> myJoinCommunityList = baseMapper.getMyJoinCommunity(new Page<>(1, 100),
|
||||
SecurityUtils.getUserId(),
|
||||
new JoinCommunityListPageRes());
|
||||
JoinCommunityListPageRes.builder().isMyCreate(1).build());
|
||||
|
||||
Map<Long, Community> myJoinCommunityMap = myJoinCommunityList.stream()
|
||||
.collect(Collectors.toMap(Community::getId, Function.identity()));
|
||||
|
|
|
@ -49,7 +49,7 @@ public class IncomeInfoServiceImpl extends ServiceImpl<IncomeInfoMapper, IncomeI
|
|||
IncomeAmountVo questionIncome = baseMapper.questionIncome(SecurityUtils.getUserId());
|
||||
|
||||
// 累计收益
|
||||
Double totalIncome = baseMapper.totalIncome();
|
||||
Double totalIncome = baseMapper.totalIncome(SecurityUtils.getUserId());
|
||||
|
||||
IncomeInfoVo incomeInfoVo = IncomeInfoVo.builder()
|
||||
.communityIncome(communityIncome)
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.mcwl.communityCenter.domain.dto.*;
|
|||
import com.mcwl.communityCenter.domain.vo.QuestionCommentVo;
|
||||
import com.mcwl.communityCenter.domain.vo.QuestionVo;
|
||||
import com.mcwl.communityCenter.mapper.*;
|
||||
import com.mcwl.communityCenter.service.IncomeInfoService;
|
||||
import com.mcwl.communityCenter.service.QuestionCommentService;
|
||||
import com.mcwl.communityCenter.service.QuestionService;
|
||||
import com.mcwl.myInvitation.domain.Consume;
|
||||
|
@ -46,6 +47,8 @@ public class QuestionCommentServiceImpl extends ServiceImpl<QuestionCommentMappe
|
|||
|
||||
private final ConsumeMapper consumeMapper;
|
||||
|
||||
private final IncomeInfoService incomeInfoService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<Object> comment(QuestionCommentRes questionCommentRes) {
|
||||
|
@ -173,6 +176,14 @@ public class QuestionCommentServiceImpl extends ServiceImpl<QuestionCommentMappe
|
|||
consume.setWallet(sysUser.getWallet());
|
||||
consumeMapper.insert(consume);
|
||||
|
||||
IncomeInfo incomeInfo = new IncomeInfo();
|
||||
incomeInfo.setTenantId(tenantId);
|
||||
incomeInfo.setCommunityId(communityId);
|
||||
incomeInfo.setUserId(questionUserId);
|
||||
incomeInfo.setType(1);
|
||||
incomeInfo.setAmount(question.getAmount());
|
||||
incomeInfoService.save(incomeInfo);
|
||||
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
SELECT SUM(IF(DATE(create_time) = CURDATE(), amount, 0)) AS today_income,
|
||||
SUM(IF(DATE(create_time) = CURDATE() - INTERVAL 1 DAY, amount, 0)) AS yesterday_income
|
||||
FROM cc_income_info
|
||||
WHERE tenant_id = #{userId}
|
||||
WHERE user_id = #{userId}
|
||||
AND type = 0
|
||||
AND del_flag = '0'
|
||||
</select>
|
||||
|
@ -18,14 +18,14 @@
|
|||
SELECT SUM(IF(DATE(create_time) = CURDATE(), amount, 0)) AS today_income,
|
||||
SUM(IF(DATE(create_time) = CURDATE() - INTERVAL 1 DAY, amount, 0)) AS yesterday_income
|
||||
FROM cc_income_info
|
||||
WHERE tenant_id = #{userId}
|
||||
WHERE user_id = #{userId}
|
||||
AND type = 1
|
||||
AND del_flag = '0'
|
||||
</select>
|
||||
<select id="totalIncome" resultType="java.lang.Double">
|
||||
SELECT SUM(amount)
|
||||
FROM cc_income_info
|
||||
WHERE del_flag = '0'
|
||||
WHERE del_flag = '0' and user_id = #{userId}
|
||||
</select>
|
||||
<select id="incomeList" resultType="com.mcwl.communityCenter.domain.vo.IncomeInfoListVo">
|
||||
SELECT u.nick_name as user_name,
|
||||
|
@ -39,7 +39,7 @@
|
|||
on ii.tenant_id = c.tenant_id
|
||||
and ii.community_id = c.id
|
||||
left join sys_user u on c.tenant_id = u.user_id
|
||||
where ii.tenant_id = #{userId}
|
||||
where ii.user_id = #{userId}
|
||||
<if test="incomeInfoListPageRes.type != null ">
|
||||
and ii.type = #{incomeInfoListPageRes.type}
|
||||
</if>
|
||||
|
|
|
@ -34,6 +34,10 @@ public class CommissionRatio extends BaseEntity {
|
|||
* 类型 0邀请人-被邀请人 1公司-商家
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class CommissionRatioVo {
|
|||
*/
|
||||
private Double ratio;
|
||||
/**
|
||||
* 提成类型,平台手续费、邀请人提成
|
||||
* 提成类型,平台手续费、邀请人提成、星球手续费
|
||||
*/
|
||||
private String ratioName;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public class CommissionRatioServiceImpl extends ServiceImpl<CommissionRatioMappe
|
|||
|
||||
redisCache.deleteObject("CommissionRationInviterUser");
|
||||
redisCache.deleteObject("CommissionRationMerchant");
|
||||
redisCache.deleteObject("CommissionRationCommunity");
|
||||
|
||||
return this.getCommissionRatioVo(commissionRatio);
|
||||
}
|
||||
|
@ -66,11 +67,7 @@ public class CommissionRatioServiceImpl extends ServiceImpl<CommissionRatioMappe
|
|||
private CommissionRatioVo getCommissionRatioVo(CommissionRatio commissionRatio) {
|
||||
CommissionRatioVo vo = new CommissionRatioVo();
|
||||
BeanUtil.copyProperties(commissionRatio, vo);
|
||||
if (commissionRatio.getType() == 0) {
|
||||
vo.setRatioName("平台手续费");
|
||||
} else if (commissionRatio.getType() == 1) {
|
||||
vo.setRatioName("邀请人提成");
|
||||
}
|
||||
vo.setRatioName(commissionRatio.getDescription());
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue