public without sharing class LexLicenceReminderController {
    
    @AuraEnabled
    public static Results initReminder(){
        Results results = new Results();
        try {
            User useracc = [SELECT AccountId, Work_Location__c,UserPro_Type__c FROM user WHERE id =:UserInfo.getUserId()];
            String accountId = useracc.AccountId;
            List<Account> accList = [SELECT Name,Medical_Equipment_Expiration_Date__c FROM Account WHERE Id =:accountId];
            Account accountInfo = new Account();
            if(accList.size() == 1){
                accountInfo = accList[0];
            }else{
                results.result = 'Fail';
                results.isShowReminder = false;
                results.errorMsg = '未获取到经销商信息';
                return results;
            }
            if(accountInfo.Medical_Equipment_Expiration_Date__c != null){
                Integer days = LexUtility.getLicenceReminderDays();
                Date today = Date.today();
                // Date today = Date.newInstance(2024, 7, 21);
                Integer numberDaysDue = today.daysBetween(accountInfo.Medical_Equipment_Expiration_Date__c);
                if(numberDaysDue > days){
                    results.isShowReminder = false;
                }else{
                    results.isShowReminder = true;
                    results.days = numberDaysDue;
                }
                results.result = 'Success';
            }else {
                results.result = 'Fail';
                results.errorMsg = '未获取到医疗器械经营企业许可证有效期限';
            }
        } catch (Exception e) {
            results.result = 'Fail';
            results.isShowReminder = false;
            results.errorMsg = e.getLineNumber()+'---'+e.getMessage();
        }
        return results;
    }

    public class Results {
        @AuraEnabled
        public String result;
        @AuraEnabled
        public String errorMsg;
        @AuraEnabled
        public Boolean isShowReminder;
        @AuraEnabled
        public Integer days;
    }
}