feat(communityCenter): 收入记录
parent
80fcfd12ea
commit
f432697d94
|
@ -30,6 +30,11 @@ public class IncomeInfo extends BaseEntity {
|
|||
*/
|
||||
private Long communityId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 类型 0付费加入 1付费问答
|
||||
*/
|
||||
|
|
|
@ -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,6 +22,7 @@ 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.Consume;
|
||||
import com.mcwl.myInvitation.mapper.ConsumeMapper;
|
||||
|
@ -58,6 +56,8 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
|
||||
private final ConsumeMapper consumeMapper;
|
||||
|
||||
private final IncomeInfoService incomeInfoService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -142,6 +142,11 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
|
||||
sysUserService.updateUser(user);
|
||||
|
||||
SysUser tenantUser = sysUserService.selectUserById(tenantId);
|
||||
tenantUser.setWallet(priceBigDecimal.add(new BigDecimal(tenantUser.getWallet().toString())).doubleValue());
|
||||
sysUserService.updateUser(tenantUser);
|
||||
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
Date startTime = now.getTime();
|
||||
now.add(Calendar.YEAR, community.getValidityDay());
|
||||
|
@ -189,6 +194,14 @@ public class CommunityServiceImpl extends ServiceImpl<CommunityMapper, Community
|
|||
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(price);
|
||||
incomeInfoService.save(incomeInfo);
|
||||
|
||||
redisCache.deleteObject("communityJoinNumMap");
|
||||
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue