|
|
|
@ -1,14 +1,19 @@ |
|
|
|
package com.qniao.dam.query.pointaccount.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.qniao.dam.api.query.pointaccount.user.request.PagePointAccountRecordQueryParams; |
|
|
|
import com.qniao.dam.api.query.pointaccount.user.response.GetUnreadPointAccountRecordVo; |
|
|
|
import com.qniao.dam.api.query.pointaccount.user.response.PagePointAccountRecordVo; |
|
|
|
import com.qniao.dam.domain.aggregate.pointaccount.entity.PointAccount; |
|
|
|
import com.qniao.dam.domain.aggregate.pointaccount.entity.PointAccountRecord; |
|
|
|
import com.qniao.dam.domian.aggregate.walletaccount.constant.IdentityTypeEnum; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.par.PointAccountRecordDao; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.pointaccount.PointAccountDao; |
|
|
|
import com.qniao.dam.query.pointaccount.PointAccountQueryService; |
|
|
|
import com.qniao.framework.utils.PageUtil; |
|
|
|
import com.qniao.framework.utils.TypeConvertUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
@ -19,6 +24,8 @@ public class PointAccountQueryServiceImpl implements PointAccountQueryService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private PointAccountDao pointAccountDao; |
|
|
|
@Resource |
|
|
|
private PointAccountRecordDao pointAccountRecordDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PointAccount queryByUserId(Long userId) { |
|
|
|
@ -58,4 +65,22 @@ public class PointAccountQueryServiceImpl implements PointAccountQueryService { |
|
|
|
return pointAccountDao.pagePointAccountRecord(pageUtil.toPageWithoutOrders(), queryParams); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public GetUnreadPointAccountRecordVo getUnreadPointAccountRecord(Long userId) { |
|
|
|
GetUnreadPointAccountRecordVo recordVo = null; |
|
|
|
PointAccount pointAccount = queryByUserId(userId); |
|
|
|
if (Objects.isNull(pointAccount.getId())) { |
|
|
|
PointAccountRecord pointAccountRecord = pointAccountRecordDao.selectOne(new LambdaQueryWrapper<PointAccountRecord>() |
|
|
|
.eq(PointAccountRecord::getPointAccountId, pointAccount.getId()) |
|
|
|
.eq(PointAccountRecord::getIsRead, false) |
|
|
|
.orderByDesc(PointAccountRecord::getCreateTime) |
|
|
|
.last("limit 1")); |
|
|
|
if (Objects.nonNull(pointAccountRecord)) { |
|
|
|
recordVo = TypeConvertUtils.convert(pointAccountRecord, GetUnreadPointAccountRecordVo.class); |
|
|
|
pointAccountRecordDao.updateIsRead(pointAccount.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
return recordVo; |
|
|
|
} |
|
|
|
|
|
|
|
} |