|
|
|
@ -17,6 +17,7 @@ import com.qniao.das.domian.aggregate.marriageinformation.MarriageInformation; |
|
|
|
import com.qniao.das.domian.aggregate.marriageinformation.UserMarriageInformation; |
|
|
|
import com.qniao.framework.exception.BizException; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Objects; |
|
|
|
@ -53,12 +54,12 @@ public class ContactCardUsageRecordApplicationService { |
|
|
|
//已经认证 |
|
|
|
int usageFreeCount = contactCardUsageRecordQueryService.countUsageRecord(usageRecord.getUserId(), CardUsageTypeEnum.FREE); |
|
|
|
if (usageFreeCount < 10) { |
|
|
|
applyContact(usageRecord, marriageInformation); |
|
|
|
applyContact(usageRecord, marriageInformation, CardUsageTypeEnum.FREE); |
|
|
|
vo.setSuccess(true); |
|
|
|
} else { |
|
|
|
//免费使用完后,看看有没有联系卡使用 |
|
|
|
if (rightApplicationService.consumeRight(usageRecord.getUserId(), marriageInformation.getId(), RightTypeEnum.CONTACT_CARD, null)) { |
|
|
|
applyContact(usageRecord, marriageInformation); |
|
|
|
applyContact(usageRecord, marriageInformation, CardUsageTypeEnum.CARD); |
|
|
|
vo.setSuccess(true); |
|
|
|
} else { |
|
|
|
vo.setSuccess(false); |
|
|
|
@ -70,9 +71,11 @@ public class ContactCardUsageRecordApplicationService { |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
private void applyContact(ContactCardUsageRecord usageRecord, |
|
|
|
MarriageInformation applicantMarriageInformation) { |
|
|
|
ContactCardUsageRecord record = ContactCardUsageRecord.build(usageRecord.getUserId(), usageRecord.getTargetMiId(), CardUsageTypeEnum.FREE); |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void applyContact(ContactCardUsageRecord usageRecord, |
|
|
|
MarriageInformation applicantMarriageInformation, |
|
|
|
CardUsageTypeEnum usageType) { |
|
|
|
ContactCardUsageRecord record = ContactCardUsageRecord.build(usageRecord.getUserId(), usageRecord.getTargetMiId(), usageType); |
|
|
|
contactCardUsageRecordDao.insert(record); |
|
|
|
MarriageInformationContactApply apply = new MarriageInformationContactApply(); |
|
|
|
apply.setApplicantUserId(usageRecord.getUserId()); |
|
|
|
|