|
|
|
@ -1,15 +1,65 @@ |
|
|
|
package com.qniao.dam.application.service.ccur; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.qniao.dam.api.command.ccur.user.response.UserUseContactCardVo; |
|
|
|
import com.qniao.dam.application.service.right.RightApplicationService; |
|
|
|
import com.qniao.dam.domain.aggregate.ccur.vobj.ContactCardUsageRecord; |
|
|
|
import com.qniao.dam.domain.aggregate.pcur.vobj.ProfileCardUsageRecord; |
|
|
|
import com.qniao.dam.domian.aggregate.pcur.constant.CardUsageTyepEnum; |
|
|
|
import com.qniao.dam.domian.aggregate.right.constant.RightTypeEnum; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.ccur.ContactCardUsageRecordDao; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.pcur.ProfileCardUsageRecordDao; |
|
|
|
import com.qniao.dam.query.ccur.ContactCardUsageRecordQueryService; |
|
|
|
import com.qniao.dam.query.marriageinformation.MarriageInformationQueryService; |
|
|
|
import com.qniao.dam.query.mica.MarriageInformationContactApplyQueryService; |
|
|
|
import com.qniao.das.domian.aggregate.marriageinformation.MarriageInformation; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class ContactCardUsageRecordApplicationService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ContactCardUsageRecordQueryService contactCardUsageRecordQueryService; |
|
|
|
@Resource |
|
|
|
private MarriageInformationContactApplyQueryService marriageInformationContactApplyQueryService; |
|
|
|
@Resource |
|
|
|
private MarriageInformationQueryService marriageInformationQueryService; |
|
|
|
@Resource |
|
|
|
private ContactCardUsageRecordDao contactCardUsageRecordDao; |
|
|
|
@Resource |
|
|
|
private RightApplicationService rightApplicationService; |
|
|
|
|
|
|
|
public UserUseContactCardVo use(ContactCardUsageRecord usageRecord) { |
|
|
|
return null; |
|
|
|
UserUseContactCardVo vo = new UserUseContactCardVo(); |
|
|
|
//是否申请中 |
|
|
|
if (marriageInformationContactApplyQueryService.checkApplying(usageRecord.getUserId(), usageRecord.getTargetMiId())){ |
|
|
|
//申请过了 |
|
|
|
vo.setSuccess(true); |
|
|
|
}else { |
|
|
|
MarriageInformation marriageInformation = marriageInformationQueryService.queryByUserId(usageRecord.getUserId()); |
|
|
|
vo.setRealNameAuthenticated(StrUtil.isNotBlank(marriageInformation.getIdentityCard())); |
|
|
|
if (!vo.getRealNameAuthenticated()) { |
|
|
|
//已经认证 |
|
|
|
int usageFreeCount = contactCardUsageRecordQueryService.countUsageRecord(usageRecord.getUserId(), CardUsageTyepEnum.FREE); |
|
|
|
if (usageFreeCount < 10) { |
|
|
|
ContactCardUsageRecord record = ContactCardUsageRecord.build(usageRecord.getUserId(), usageRecord.getTargetMiId(), CardUsageTyepEnum.FREE); |
|
|
|
contactCardUsageRecordDao.insert(record); |
|
|
|
vo.setSuccess(true); |
|
|
|
} else { |
|
|
|
//免费使用完后,看看有没有联系卡使用 |
|
|
|
if (rightApplicationService.consumeRight(usageRecord.getUserId(), marriageInformation.getId(), RightTypeEnum.CONTACT_CARD, null)) { |
|
|
|
ContactCardUsageRecord record = ContactCardUsageRecord.build(usageRecord.getUserId(), usageRecord.getTargetMiId(), CardUsageTyepEnum.CARD); |
|
|
|
contactCardUsageRecordDao.insert(record); |
|
|
|
vo.setSuccess(true); |
|
|
|
} else { |
|
|
|
vo.setSuccess(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
} |