| | |
| | | import static java.util.Objects.nonNull; |
| | | import static org.apache.commons.lang3.StringUtils.isNotBlank; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Random; |
| | | import java.util.Set; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.NumberUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.common.model.dtos.community.microCommercialStreet.BindUserPhoneDTO; |
| | | import com.panzhihua.common.model.vos.community.ComAreaTownCommunityVO; |
| | | import com.panzhihua.common.model.vos.community.acid.ComActAcidMemberVO; |
| | | import com.panzhihua.common.model.vos.community.microCommercialStreet.McsLoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.user.*; |
| | | import com.panzhihua.common.utlis.*; |
| | | import com.panzhihua.service_user.dao.*; |
| | | import com.panzhihua.service_user.entity.SysAppConfig; |
| | | import com.panzhihua.service_user.entity.SysTemplateConfig; |
| | |
| | | import com.panzhihua.common.model.vos.grid.admin.GridMemberBuildingVO; |
| | | import com.panzhihua.common.model.vos.partybuilding.ActivityManagerVO; |
| | | import com.panzhihua.common.model.vos.shop.ShopStoreVO; |
| | | import com.panzhihua.common.model.vos.user.AdministratorsUserVO; |
| | | import com.panzhihua.common.model.vos.user.ChangePasswordVO; |
| | | import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO; |
| | | import com.panzhihua.common.model.vos.user.ComMngUserTagVO; |
| | | import com.panzhihua.common.model.vos.user.CommunityUserInfoVO; |
| | | import com.panzhihua.common.model.vos.user.MenuRoleVO; |
| | | import com.panzhihua.common.model.vos.user.NoticeUnReadVO; |
| | | import com.panzhihua.common.model.vos.user.SysOperLogVO; |
| | | import com.panzhihua.common.model.vos.user.SysUserAgreementVO; |
| | | import com.panzhihua.common.model.vos.user.SysUserFeedbackVO; |
| | | import com.panzhihua.common.model.vos.user.SysUserNoticeVO; |
| | | import com.panzhihua.common.model.vos.user.SysUserVO; |
| | | import com.panzhihua.common.model.vos.user.UpdateUserArchivesVO; |
| | | import com.panzhihua.common.model.vos.user.UserArchivesVO; |
| | | import com.panzhihua.common.model.vos.user.UserPhoneVO; |
| | | import com.panzhihua.common.utlis.IdCard; |
| | | import com.panzhihua.common.utlis.SensitiveUtil; |
| | | import com.panzhihua.common.utlis.SmsUtil; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.common.utlis.WxUtil; |
| | | import com.panzhihua.common.utlis.WxXCXTempSend; |
| | | import com.panzhihua.service_user.model.dos.ComActFourMember; |
| | | import com.panzhihua.service_user.model.dos.ComMngFamilyInfoDO; |
| | | import com.panzhihua.service_user.model.dos.ComMngUserTagDO; |
| | |
| | | private SysAppConfigDao sysAppConfigDao; |
| | | @Resource |
| | | private SysTemplateConfigDao sysTemplateConfigDao; |
| | | public static final Integer ALLCOUNTY=1; |
| | | public static final Integer ALLSTREET=2; |
| | | public static final Integer ALLCOMMUNITY=3; |
| | | public static final Integer BYSTREET=4; |
| | | |
| | | // @Resource |
| | | // private GridService gridService; |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public R updateUserWeiXinPhone(Long userId, String purePhoneNumber) { |
| | | SysUserDO sysUserDO = new SysUserDO(); |
| | | sysUserDO.setPhone(purePhoneNumber); |
| | | sysUserDO.setUserId(userId); |
| | | userDao.updateMemberRole(purePhoneNumber, purePhoneNumber); |
| | | userDao.updateServiceTeam(purePhoneNumber, purePhoneNumber); |
| | | int i = userDao.updateById(sysUserDO); |
| | | if (i > 0) { |
| | | return R.ok(purePhoneNumber); |
| | | } else { |
| | | return R.fail("维护微信手机号失败"); |
| | | SysUserDO sysUserDO=userDao.selectById(userId); |
| | | if(sysUserDO!=null){ |
| | | userDao.updateMemberRole(purePhoneNumber, sysUserDO.getPhone()); |
| | | userDao.updateServiceTeam(purePhoneNumber, sysUserDO.getPhone()); |
| | | sysUserDO.setPhone(purePhoneNumber); |
| | | sysUserDO.setUserId(userId); |
| | | int i = userDao.updateById(sysUserDO); |
| | | if (i > 0) { |
| | | return R.ok(purePhoneNumber); |
| | | } else { |
| | | return R.fail("维护微信手机号失败"); |
| | | } |
| | | } |
| | | return R.ok(sysUserDO.getPhone()); |
| | | } |
| | | |
| | | /** |
| | |
| | | loginUserInfoVO.setIsAcidMember(2); |
| | | } |
| | | loginUserInfoVO.setRelationName(acidMember.getRelationName()); |
| | | } |
| | | Integer count=userDao.selectOrgAdmin(phone); |
| | | if(count>0){ |
| | | loginUserInfoVO.setIsCheckUnitAdmin(1); |
| | | } |
| | | Long checkUnitId=userDao.selectCheckUnitId(phone); |
| | | if(checkUnitId!=null){ |
| | | loginUserInfoVO.setCheckUnitId(checkUnitId); |
| | | } |
| | | |
| | | else { |
| | | loginUserInfoVO.setIsCheckUnitAdmin(0); |
| | | } |
| | | //是否网格员 |
| | | int easyPhotoMember = userDao.countEasyPhotoMember(phone, userCommunityId); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | if (insert > 0 && sysUserDO.getType() == 3 &&sysUserDO.getStreetId()==null) {// 添加的用户是社区账号时 |
| | | // 添加网格综合治理管理后台用户 |
| | | SysUserDO sysUserDOWangGe = new SysUserDO(); |
| | | BeanUtils.copyProperties(sysUserDO, sysUserDOWangGe); |
| | | sysUserDOWangGe.setUserId(null); |
| | | sysUserDOWangGe.setType(7);// 网格综治后台 |
| | | try { |
| | | int addWange = userDao.insert(sysUserDOWangGe); |
| | | if (addWange != 1) { |
| | | throw new ServiceException("新增网格综合治理管理后台用户失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("网格综合治理管理后台用户报错【{}】", e.getMessage()); |
| | | if (e.getMessage().contains("union_phone_type")) { |
| | | throw new ServiceException("手机号已经存在"); |
| | | } else if (e.getMessage().contains("union_account_type")) { |
| | | throw new ServiceException("账户已经存在"); |
| | | }else if(e.getMessage().contains("23000")){ |
| | | throw new ServiceException("手机号已存在"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | if (insert > 0) { |
| | | SysUserDO sysUserDO1 = userDao |
| | | .selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getType, administratorsUserVO.getType()) |
| | |
| | | * @return 删除结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R deleteUserBackstage(AdministratorsUserVO administratorsUserVO) { |
| | | Long userId = administratorsUserVO.getUserId(); |
| | | SysUserDO sysUserDO = userDao.selectById(userId); |
| | |
| | | @Override |
| | | public R getSysUserVOByPhone(String phone) { |
| | | SysUserDO sysUserDO = userDao |
| | | .selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getPhone, phone).eq(SysUserDO::getType, 1)); |
| | | .selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getPhone, phone).eq(SysUserDO::getType, 1).orderByDesc(SysUserDO::getCreateAt).last("limit 1")); |
| | | if (ObjectUtils.isEmpty(sysUserDO)) { |
| | | return R.fail("用户不存在"); |
| | | return R.fail("账号或密码错误"); |
| | | } |
| | | SysUserVO sysUserVO = new SysUserVO(); |
| | | BeanUtils.copyProperties(sysUserDO, sysUserVO); |
| | |
| | | query.eq(SysUserDO::getType, type); |
| | | SysUserDO sysUserDO = userDao.selectOne(query); |
| | | if (ObjectUtils.isEmpty(sysUserDO)) { |
| | | return R.fail("用户不存在"); |
| | | return R.fail("账号或密码错误"); |
| | | } |
| | | SysUserVO sysUserVO = new SysUserVO(); |
| | | BeanUtils.copyProperties(sysUserDO, sysUserVO); |
| | |
| | | public R getUserInfoByUnionId(String unionId) { |
| | | SysUserDO sysUserDO = userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getUnionid, unionId)); |
| | | if (isNull(sysUserDO)) { |
| | | return R.fail("用户不存在"); |
| | | return R.fail("账号或密码错误"); |
| | | } |
| | | LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO(); |
| | | BeanUtils.copyProperties(sysUserDO, loginUserInfoVO); |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R uuLogin(UuLoginVO uuLoginVO) { |
| | | uuLoginVO.setAppid("10000"); |
| | | String timeStamp=PayUtil.create_timestamp(); |
| | | uuLoginVO.setTimestamp(timeStamp); |
| | | try { |
| | | uuLoginVO.setSign(PayUtil.MD5(uuLoginVO.getAppid()+"e10adc3949ba59abbe56e057f20f883e"+timeStamp).toLowerCase(Locale.ROOT)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Map<String, String> headerMap=new HashMap<>(); |
| | | headerMap.put("appid","10000"); |
| | | String resultJson=HttpClientUtil.get("https://api.uucsh.cn/member/wx/get-access?province="+uuLoginVO.getProvince()+"&city="+uuLoginVO.getCity()+"&area="+uuLoginVO.getArea()+"&appid=10000×tamp="+uuLoginVO.getTimestamp()+"&sign="+uuLoginVO.getSign()+"&mobile="+uuLoginVO.getMobile(),headerMap,null); |
| | | JSONObject result = JSON.parseObject(resultJson); |
| | | if(result.get("status").equals(1)){ |
| | | return R.ok(result.get("data")); |
| | | } |
| | | return R.fail("信息错误"); |
| | | } |
| | | |
| | | @Override |
| | | public R checkExport(String account, String password,String oldPassword) { |
| | | if(new BCryptPasswordEncoder().matches(password, oldPassword)){ |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R newIndexData(Integer type, Long streetId) { |
| | | IndexDataKanbanVO indexDataKanbanVO = userDao.selectIndexDataKanban(null); |
| | | IndexDataAnalysisVO vo=new IndexDataAnalysisVO(); |
| | | if (ObjectUtils.isEmpty(type)){ |
| | | //不传默认为所有区县 |
| | | type=ALLCOUNTY; |
| | | } |
| | | if (type.equals(ALLCOUNTY) || type.equals(ALLCOMMUNITY) || type.equals(ALLSTREET)){ |
| | | BeanUtils.copyProperties(indexDataKanbanVO,vo); |
| | | }else { |
| | | IndexDataKanbanVO indexDataVO = userDao.dataKanBanStreet(streetId); |
| | | BeanUtils.copyProperties(indexDataVO,vo); |
| | | } |
| | | List<UserProportion> userProportionsTotal = userDao.userAnalysis(type, null, streetId); |
| | | Integer streetUser = userDao.streetUserCount(streetId); |
| | | for (UserProportion userProportion : userProportionsTotal) { |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion)){ |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion.getUser())){ |
| | | //计算占比 |
| | | //userProportion.setAreaCode(null); |
| | | if (type.equals(BYSTREET)){ |
| | | userProportion.setRate(getRate(streetUser,userProportion.getUser())); |
| | | } |
| | | userProportion.setRate(getRate(vo.getAllUser(),userProportion.getUser())); |
| | | } |
| | | } |
| | | } |
| | | List<UserProportion> userProportionsMonth = userDao.userAnalysis(type, DateUtil.beginOfMonth(new Date()).toString(), streetId); |
| | | for (UserProportion userProportion : userProportionsMonth) { |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion)){ |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(userProportion.getUser())){ |
| | | //计算占比 |
| | | //userProportion.setAreaCode(null); |
| | | if (type.equals(BYSTREET)){ |
| | | userProportion.setRate(getRate(streetUser,userProportion.getUser())); |
| | | } |
| | | userProportion.setRate(getRate(vo.getAllUser(),userProportion.getUser())); |
| | | } |
| | | } |
| | | } |
| | | vo.setUserProportionTotal(userProportionsTotal); |
| | | vo.setUserProportionMonth(userProportionsMonth); |
| | | List<RealUser> realUsersTotal = userDao.realUserCount(type, null, streetId); |
| | | List<RealUser> realUsersMonth = userDao.realUserCount(type, DateUtil.beginOfMonth(new Date()).toString(), streetId); |
| | | vo.setRealUsersTotal(realUsersTotal); |
| | | vo.setRealUsersMonth(realUsersMonth); |
| | | vo.setRealUser(getStreetRealUser(realUsersTotal)); |
| | | vo.setRealUserRate(getRate(vo.getAllUser(),vo.getRealUser())); |
| | | vo.setUserActivityXAll(getTwentyDays()); |
| | | vo.setUserActivityXMonth(getMonthTwentyDays()); |
| | | List<String> addUserYAll=new ArrayList<>(); |
| | | List<String> addUserYMonth=new ArrayList<>(); |
| | | List<String> activeUserYAll=new ArrayList<>(); |
| | | List<String> activeUserYMonth=new ArrayList<>(); |
| | | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); |
| | | //获取用户行为Y轴 |
| | | for (Date date : vo.getUserActivityXAll()) { |
| | | //查询当天的新增和日活 |
| | | Map<String, Long> map = userDao.getDailyAddAndActive(DateUtil.parse(sdf.format(date)), streetId); |
| | | addUserYAll.add(map.get("addUser").toString()); |
| | | activeUserYAll.add(map.get("activeUser").toString()); |
| | | } |
| | | for (Date date : vo.getUserActivityXMonth()) { |
| | | Map<String, Long> map = userDao.getDailyAddAndActive(DateUtil.parse(sdf.format(date)), streetId); |
| | | addUserYMonth.add(map.get("addUser").toString()); |
| | | activeUserYMonth.add(map.get("activeUser").toString()); |
| | | } |
| | | vo.setAddUserYAll(addUserYAll); |
| | | vo.setAddUserYWeek(addUserYMonth); |
| | | vo.setActiveUserYAll(activeUserYAll); |
| | | vo.setActiveUserYMonth(activeUserYMonth); |
| | | if (type.equals(BYSTREET) || type.equals(ALLCOMMUNITY) || type.equals(ALLSTREET)){ |
| | | //获取其他用户 |
| | | vo.setOtherUser(indexDataKanbanVO.getAllUser()-countUser(vo.getUserProportionTotal())); |
| | | vo.setOtherUserRate(getRate(indexDataKanbanVO.getAllUser(),vo.getOtherUser())); |
| | | } |
| | | return R.ok(vo); |
| | | } |
| | | |
| | | /** |
| | | * 获取最近20天数据 |
| | | * |
| | | * @return |
| | | */ |
| | | private List<Date> getTwentyDays() { |
| | | List<Date> dates = new ArrayList<>(); |
| | | Date date = new Date(); |
| | | for (int i = 19; i >= 0; i--) { |
| | | Date date1 = DateUtils.addDays(date, -i); |
| | | dates.add(date1); |
| | | } |
| | | return dates; |
| | | } |
| | | |
| | | /** |
| | | * 获取最近本月20天数据 |
| | | * |
| | | * @return |
| | | */ |
| | | private List<Date> getMonthTwentyDays() { |
| | | List<Date> dates = new ArrayList<>(); |
| | | Date date = new Date(); |
| | | Long offset = DateUtil.between(new Date(), DateUtil.beginOfMonth(date), DateUnit.DAY); |
| | | if (offset>=20){ |
| | | for (int i = 19; i >= 0; i--) { |
| | | Date date1 = DateUtils.addDays(date, -i); |
| | | dates.add(date1); |
| | | } |
| | | }else{ |
| | | //距离月初不足20天 |
| | | for (int i = offset.intValue(); i >= 0; i--) { |
| | | Date date1 = DateUtils.addDays(date, -i); |
| | | dates.add(date1); |
| | | } |
| | | } |
| | | return dates; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 计算占比 |
| | | * */ |
| | | private Double getRate(Integer total,Integer count){ |
| | | if (0 != total && null != total){ |
| | | if (0 != count && null != count){ |
| | | BigDecimal div = NumberUtil.div(count.toString(), total.toString(),2); |
| | | return div.doubleValue(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 计算街道实名用户总数 |
| | | * */ |
| | | private Integer getStreetRealUser(List<RealUser> list){ |
| | | Integer count=0; |
| | | if (list.size()>0){ |
| | | for (RealUser realUser : list) { |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(realUser)){ |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(realUser.getCount())){ |
| | | count+=realUser.getCount(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | /** |
| | | * 计算当前统计范围内的所有用户数 |
| | | * */ |
| | | public Integer countUser(List<UserProportion> list){ |
| | | Integer count=0; |
| | | if (list.size()>0){ |
| | | for (UserProportion proportion : list) { |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(proportion)){ |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(proportion.getUser())){ |
| | | count+=proportion.getUser(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | } |