From 147a7ce2b1cc45cb58c69c82c3b0e0b2d3910b05 Mon Sep 17 00:00:00 2001
From: tangxiaobao <303826152@qq.com>
Date: 星期五, 03 九月 2021 18:13:53 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/test' into txb

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommunityApi.java |  165 +++++++++++++++++++++++++++----------------------------
 1 files changed, 81 insertions(+), 84 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommunityApi.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommunityApi.java
index 912692f..4d21238 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommunityApi.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommunityApi.java
@@ -10,6 +10,9 @@
 
 import javax.annotation.Resource;
 
+import cn.hutool.core.date.DateUtil;
+import com.panzhihua.service_community.model.dos.*;
+import com.panzhihua.service_community.service.*;
 import org.springframework.beans.BeanUtils;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
@@ -85,32 +88,6 @@
 import com.panzhihua.service_community.dao.ComActActSignDAO;
 import com.panzhihua.service_community.dao.ComEldersAuthHistoryRecordMapper;
 import com.panzhihua.service_community.dao.ComMngPopulationDAO;
-import com.panzhihua.service_community.model.dos.ComActActEvaluateDO;
-import com.panzhihua.service_community.model.dos.ComActActPrizeDO;
-import com.panzhihua.service_community.model.dos.ComActDynDO;
-import com.panzhihua.service_community.model.dos.ComActEasyPhotoDO;
-import com.panzhihua.service_community.model.dos.ComActMicroWishDO;
-import com.panzhihua.service_community.model.dos.ComEldersAuthHistoryRecordDO;
-import com.panzhihua.service_community.model.dos.ComEldersAuthUserDO;
-import com.panzhihua.service_community.model.dos.ComMngStructAreaDO;
-import com.panzhihua.service_community.model.dos.EldersAuthDO;
-import com.panzhihua.service_community.service.ComActActEvaluateService;
-import com.panzhihua.service_community.service.ComActActPrizeService;
-import com.panzhihua.service_community.service.ComActActivityService;
-import com.panzhihua.service_community.service.ComActDynService;
-import com.panzhihua.service_community.service.ComActEasyPhotoActivityService;
-import com.panzhihua.service_community.service.ComActEasyPhotoService;
-import com.panzhihua.service_community.service.ComActMessageService;
-import com.panzhihua.service_community.service.ComActMicroWishService;
-import com.panzhihua.service_community.service.ComActQuestnaireService;
-import com.panzhihua.service_community.service.ComActService;
-import com.panzhihua.service_community.service.ComEldersAuthUserService;
-import com.panzhihua.service_community.service.ComMngStructAreaDistrictService;
-import com.panzhihua.service_community.service.ComMngStructAreaService;
-import com.panzhihua.service_community.service.ComMngStructHouseService;
-import com.panzhihua.service_community.service.ComMngStructOtherBuildService;
-import com.panzhihua.service_community.service.ComMngVolunteerMngService;
-import com.panzhihua.service_community.service.EldersAuthService;
 
 import cn.hutool.core.util.IdcardUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -167,6 +144,8 @@
     private ComActEasyPhotoActivityService comActEasyPhotoActivityService;
     @Resource
     private ComActActEvaluateService comActActEvaluateService;
+    @Resource
+    private ComEldersAuthElderlyService comEldersAuthElderlyService;
 
     /**
      * 新增社区活动
@@ -2121,67 +2100,71 @@
         if (authUserDO == null) {
             return R.fail("未查询到老人信息");
         }
-
-        Long elderId = authUserDO.getId();
-        boolean canReAuthThisMonth = comEldersAuthUserService.checkReAuthAgain(elderId);
-        if (!canReAuthThisMonth) {
-            return R.fail("当月已认证,不能再次进行认证");
-        }
-
+        //根据身份证获取出生日期并获取岁数
         String idCard = authUserDO.getIdCard();
-
-        Long loginUserId = eldersAuthAddByFamilyDTO.getUserId();
-        EldersAuthDO eldersAuthDO = new EldersAuthDO();
-        eldersAuthDO.setSumitUserId(loginUserId);
-        eldersAuthDO.setCreateBy(loginUserId);
-        eldersAuthDO.setCreateAt(new Date());
-        eldersAuthDO.setIdCard(idCard);
-        eldersAuthDO.setAuthUserName(authUserDO.getName());
-        eldersAuthDO.setVideoUrl(eldersAuthAddByFamilyDTO.getVideoUrl());
-        eldersAuthDO.setFamilyUserId(authUserDO.getId());
-        eldersAuthDO.setAge(IdcardUtil.getAgeByIdCard(idCard));
-        // 根据身份证查询出籍贯 出生日期
-        // String domicile = IdCard.domicile(eldersAuthDO.getIdCard());
-        String domicile = eldersAuthService.queryDomicile(eldersAuthDO.getIdCard());
-        if (StringUtils.isEmpty(domicile)) {
-            domicile = "暂无";
-        }
-
         Date birthDay = IdCard.birthDay(idCard);
-        eldersAuthDO.setDomicile(domicile);
-        eldersAuthDO.setBirthDay(birthDay);
-        int add = eldersAuthService.getBaseMapper().insert(eldersAuthDO);
-        if (add == 1) {
-            // 设置认证成功
-            Long familyUserId = eldersAuthDO.getFamilyUserId();
-            ComEldersAuthUserDO comEldersAuthUserDO = new ComEldersAuthUserDO();
-            comEldersAuthUserDO.setId(familyUserId);
-            comEldersAuthUserDO.setIsAuth(1);
-            boolean updated = comEldersAuthUserService.updateById(comEldersAuthUserDO);
-            if (!updated) {
-                throw new ServiceException("添加认证失败,更新认证状态");
-            }
-            // 认证成功 添加认证记录
-            List<ComEldersAuthHistoryRecordDO> authHistoryRecordDOList =
-                comEldersAuthHistoryRecordMapper.selectList(new QueryWrapper<ComEldersAuthHistoryRecordDO>().lambda()
-                    .eq(ComEldersAuthHistoryRecordDO::getIdCard, idCard)
-                    .ge(ComEldersAuthHistoryRecordDO::getCreateAt, DateUtils.getFirstDayOfMonth()));
-            if (authHistoryRecordDOList.isEmpty()) {
-                ComEldersAuthHistoryRecordDO authHistoryRecordDO = new ComEldersAuthHistoryRecordDO();
-                authHistoryRecordDO.setUserId(eldersAuthAddByFamilyDTO.getFamilyUserId());
-                authHistoryRecordDO.setAuthId(eldersAuthDO.getId());
-                BeanUtils.copyProperties(eldersAuthDO, authHistoryRecordDO);
-                authHistoryRecordDO.setId(null);
-                authHistoryRecordDO.setBrithday(AgeUtils.getAgeFormatBirthday(IdcardUtil.getBirthByIdCard(idCard)));
-                authHistoryRecordDO.setAge(IdcardUtil.getAgeByIdCard(idCard));
-                authHistoryRecordDO.setIsAuth(1);
-                authHistoryRecordDO.setDomicile(domicile);
-                comEldersAuthHistoryRecordMapper.insert(authHistoryRecordDO);
-            }
-            return R.ok(eldersAuthDO.getId());
-        }
+        long year=DateUtil.betweenYear(birthDay,DateUtil.date(),true);
+        if(authUserDO.getBigAgeId()!=null){
+            ComEldersAuthElderlyDO comEldersAuthElderlyDO=comEldersAuthElderlyService.getById(authUserDO.getBigAgeId());
+            if(comEldersAuthElderlyDO!=null&&comEldersAuthElderlyDO.getIsExist()==ComEldersAuthElderlyDO.isExist.yes&&comEldersAuthElderlyDO.getIsBigAge()==ComEldersAuthElderlyDO.isBigAge.yes&&year>=80){
+                Long elderId = authUserDO.getId();
+                boolean canReAuthThisMonth = comEldersAuthUserService.checkReAuthAgain(elderId);
+                if (!canReAuthThisMonth) {
+                    return R.fail("当月已认证,不能再次进行认证");
+                }
+                Long loginUserId = eldersAuthAddByFamilyDTO.getUserId();
+                EldersAuthDO eldersAuthDO = new EldersAuthDO();
+                eldersAuthDO.setSumitUserId(loginUserId);
+                eldersAuthDO.setCreateBy(loginUserId);
+                eldersAuthDO.setCreateAt(new Date());
+                eldersAuthDO.setIdCard(idCard);
+                eldersAuthDO.setAuthUserName(authUserDO.getName());
+                eldersAuthDO.setVideoUrl(eldersAuthAddByFamilyDTO.getVideoUrl());
+                eldersAuthDO.setFamilyUserId(authUserDO.getId());
+                eldersAuthDO.setAge(IdcardUtil.getAgeByIdCard(idCard));
+                // 根据身份证查询出籍贯 出生日期
+                // String domicile = IdCard.domicile(eldersAuthDO.getIdCard());
+                String domicile = eldersAuthService.queryDomicile(eldersAuthDO.getIdCard());
+                if (StringUtils.isEmpty(domicile)) {
+                    domicile = "暂无";
+                }
+                eldersAuthDO.setDomicile(domicile);
+                eldersAuthDO.setBirthDay(birthDay);
+                int add = eldersAuthService.getBaseMapper().insert(eldersAuthDO);
+                if (add == 1) {
+                    // 设置认证成功
+                    Long familyUserId = eldersAuthDO.getFamilyUserId();
+                    ComEldersAuthUserDO comEldersAuthUserDO = new ComEldersAuthUserDO();
+                    comEldersAuthUserDO.setId(familyUserId);
+                    comEldersAuthUserDO.setIsAuth(1);
+                    boolean updated = comEldersAuthUserService.updateById(comEldersAuthUserDO);
+                    if (!updated) {
+                        throw new ServiceException("添加认证失败,更新认证状态");
+                    }
+                    // 认证成功 添加认证记录
+                    List<ComEldersAuthHistoryRecordDO> authHistoryRecordDOList =
+                            comEldersAuthHistoryRecordMapper.selectList(new QueryWrapper<ComEldersAuthHistoryRecordDO>().lambda()
+                                    .eq(ComEldersAuthHistoryRecordDO::getIdCard, idCard)
+                                    .ge(ComEldersAuthHistoryRecordDO::getCreateAt, DateUtils.getFirstDayOfMonth()));
+                    if (authHistoryRecordDOList.isEmpty()) {
+                        ComEldersAuthHistoryRecordDO authHistoryRecordDO = new ComEldersAuthHistoryRecordDO();
+                        authHistoryRecordDO.setUserId(eldersAuthAddByFamilyDTO.getFamilyUserId());
+                        authHistoryRecordDO.setAuthId(eldersAuthDO.getId());
+                        BeanUtils.copyProperties(eldersAuthDO, authHistoryRecordDO);
+                        authHistoryRecordDO.setId(null);
+                        authHistoryRecordDO.setBrithday(AgeUtils.getAgeFormatBirthday(IdcardUtil.getBirthByIdCard(idCard)));
+                        authHistoryRecordDO.setAge(IdcardUtil.getAgeByIdCard(idCard));
+                        authHistoryRecordDO.setIsAuth(1);
+                        authHistoryRecordDO.setDomicile(domicile);
+                        comEldersAuthHistoryRecordMapper.insert(authHistoryRecordDO);
+                    }
+                    return R.ok(eldersAuthDO.getId());
+                }
 
-        return R.fail();
+            }
+            return R.fail("不满足认证条件");
+        }
+        return R.fail("未查询到高龄老人库数据");
     }
 
     /**
@@ -2318,6 +2301,20 @@
     }
 
     /**
+     * 获取首页弹窗接口
+     *
+     * @param userId
+     *            用户id
+     * @param communityId
+     *            社区id
+     * @return 首页弹窗接口
+     */
+    @PostMapping("easyphoto/getUserRewards")
+    public R getUserRewards(@RequestParam("userId") Long userId, @RequestParam("communityId") Long communityId) {
+        return comActEasyPhotoService.getUserReward(userId, communityId);
+    }
+
+    /**
      * 读取用户随手拍奖励
      * 
      * @param userId

--
Gitblit v1.7.1