| | |
| | | |
| | | import static java.util.Objects.isNull; |
| | | import static java.util.Objects.nonNull; |
| | | import static org.apache.commons.lang3.StringUtils.capitalize; |
| | | import static org.apache.commons.lang3.StringUtils.isNotBlank; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.collection.ListUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | 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.ComActAcidRecordVO; |
| | | import com.panzhihua.common.model.vos.community.microCommercialStreet.McsLoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.user.*; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.*; |
| | | import com.panzhihua.service_user.dao.*; |
| | | import com.panzhihua.service_user.entity.SysAppConfig; |
| | |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import com.panzhihua.service_user.model.dos.SysUserAgreementDO; |
| | | import com.panzhihua.service_user.model.dos.SysUserDO; |
| | | import com.panzhihua.service_user.model.dos.SysUserFeedbackDO; |
| | | import com.panzhihua.service_user.model.dos.SysUserInputDO; |
| | | import com.panzhihua.service_user.model.dos.SysUserNoticeDO; |
| | | import com.panzhihua.service_user.model.dos.SysUserRoleDO; |
| | | import com.panzhihua.service_user.model.dtos.DataKanbanDTO; |
| | |
| | | |
| | | import cn.hutool.core.util.IdcardUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | // import com.panzhihua.common.service.grid.GridService; |
| | | |
| | |
| | | private SysTemplateConfigDao sysTemplateConfigDao; |
| | | @Resource |
| | | private ObjectMapper objectMapper; |
| | | @Resource |
| | | private CommunityService communityService; |
| | | private static final Integer ALLCOUNTY=1; |
| | | private static final Integer ALLSTREET=2; |
| | | private static final Integer ALLCOMMUNITY=3; |
| | |
| | | * @return token |
| | | */ |
| | | @Override |
| | | public R updateInsertUser(String openid, String sessionKey, String unionid) { |
| | | public R updateInsertUser(String openid, String sessionKey, String unionid,String appId) { |
| | | SysUserDO sysUserDO = |
| | | userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getOpenid, openid)); |
| | | boolean empty = ObjectUtils.isEmpty(sysUserDO); |
| | |
| | | sysUserDO1.setLastLoginTime(date); |
| | | sysUserDO1.setPassword(encode); |
| | | sysUserDO1.setType(1); |
| | | sysUserDO1.setAppId(appId); |
| | | num = userDao.insert(sysUserDO1); |
| | | } else { |
| | | String encode = new BCryptPasswordEncoder().encode(UserConstants.PASSWORD); |
| | |
| | | sysUserDO.setPassword(encode); |
| | | sysUserDO.setLastLoginTime(date); |
| | | sysUserDO.setType(1); |
| | | sysUserDO.setAppId(appId); |
| | | num = userDao.updateById(sysUserDO); |
| | | } |
| | | if (num > 0) { |
| | |
| | | } |
| | | } |
| | | loginUserInfoVO.setIsRealNamed(sysUserDO.getIdCard() != null); |
| | | //是否社区或街道后台 |
| | | int countSocialOrg=userDao.countSocialOrg(sysUserDO.getUserId()); |
| | | if(countSocialOrg>0){ |
| | | loginUserInfoVO.setUserType(3); |
| | | } |
| | | else { |
| | | if(loginUserInfoVO.getStreetId()!=null){ |
| | | loginUserInfoVO.setUserType(1); |
| | | loginUserInfoVO.setLevel(3); |
| | | } |
| | | else { |
| | | loginUserInfoVO.setUserType(2); |
| | | loginUserInfoVO.setLevel(4); |
| | | } |
| | | } |
| | | if (sysUserDO.getType().equals(11)){ |
| | | loginUserInfoVO.setLevel(5); |
| | | }else if (sysUserDO.getType().equals(12)){ |
| | | loginUserInfoVO.setLevel(2); |
| | | }else if (isNull(loginUserInfoVO.getLevel())){ |
| | | loginUserInfoVO.setLevel(1); |
| | | } |
| | | //是否为三说会堂专家 |
| | | R expert = communityService.isExpert(loginUserInfoVO.getPhone()); |
| | | if (R.isOk(expert)){ |
| | | loginUserInfoVO.setType(13); |
| | | } |
| | | return R.ok(loginUserInfoVO); |
| | | } |
| | | |
| | |
| | | else { |
| | | if(loginUserInfoVO.getStreetId()!=null){ |
| | | loginUserInfoVO.setUserType(1); |
| | | loginUserInfoVO.setLevel(3); |
| | | } |
| | | else { |
| | | loginUserInfoVO.setUserType(2); |
| | | loginUserInfoVO.setLevel(4); |
| | | } |
| | | } |
| | | if (sysUserDO.getType().equals(11)){ |
| | | loginUserInfoVO.setLevel(5); |
| | | }else if (sysUserDO.getType().equals(12)){ |
| | | loginUserInfoVO.setLevel(2); |
| | | }else if (isNull(loginUserInfoVO.getLevel())){ |
| | | loginUserInfoVO.setLevel(1); |
| | | } |
| | | return R.ok(loginUserInfoVO); |
| | | } |
| | |
| | | String encode = new BCryptPasswordEncoder().encode(administratorsUserVO.getPassword()); |
| | | administratorsUserVO.setPassword(encode); |
| | | BeanUtils.copyProperties(administratorsUserVO, sysUserDO); |
| | | sysUserDO.setAppId(administratorsUserVO.getAppid()); |
| | | int insert = 0; |
| | | try { |
| | | insert = userDao.insert(sysUserDO); |
| | |
| | | } |
| | | 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); |
| | | 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()+"&couponId="+uuLoginVO.getCouponId(),headerMap,null); |
| | | JSONObject result = JSON.parseObject(resultJson); |
| | | if(result.get("status").equals(1)){ |
| | | return R.ok(result.get("data")); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R userRate(Integer type, Long streetId, Long areaCode, Integer range) { |
| | | public R userRate(Integer type, Long streetId, Long areaCode, Integer range,String appId) { |
| | | IndexDataAnalysisVO analysisVO=new IndexDataAnalysisVO(); |
| | | if (type.equals(BYSTREET) || type.equals(BYAREA)){ |
| | | //街道,区县筛选 |
| | |
| | | BeanUtils.copyProperties(indexDataVO,analysisVO ); |
| | | }else { |
| | | //总量数据 |
| | | IndexDataKanbanVO indexDataKanbanVO = userDao.selectIndexDataKanban(null); |
| | | IndexDataKanbanVO indexDataKanbanVO = userDao.selectIndexDataKanban(appId); |
| | | BeanUtils.copyProperties(indexDataKanbanVO,analysisVO ); |
| | | } |
| | | String date=""; |
| | |
| | | date = DateUtil.parse(dateTime.toString(), "yyyy-MM-dd HH:mm:ss").toString(); |
| | | } |
| | | } |
| | | List<UserProportion> userProportions = userDao.userAnalysis(type, date, streetId,areaCode); |
| | | List<UserProportion> userProportions = userDao.userAnalysis(type, date, streetId,areaCode,appId); |
| | | List<UserRateAnalysisVO> userRateAnalysisVOList=new ArrayList<>(); |
| | | Boolean monthRange=false; |
| | | if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(range)){ |
| | |
| | | } |
| | | //获取本月的用户总数作为计算占比的用户总数 |
| | | //IndexDataKanbanVO data = userDao.dataKanBanStreet(streetId, areaCode, date); |
| | | Integer monthUsers = userDao.getMonthUsers(streetId, areaCode, date); |
| | | Integer monthUsers = userDao.getMonthUsers(streetId, areaCode, date,appId); |
| | | vo.setRate(getRate(monthUsers,userProportion.getUser())); |
| | | }else{ |
| | | vo.setRate(getRate(analysisVO.getAllUser(),userProportion.getUser())); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R realUser(Integer type, Long streetId, Long areaCode, Integer range) { |
| | | public R realUser(Integer type, Long streetId, Long areaCode, Integer range,String appId) { |
| | | IndexDataAnalysisVO analysisVO=new IndexDataAnalysisVO(); |
| | | if (type.equals(BYSTREET) || type.equals(BYAREA)){ |
| | | //街道,区县筛选 |
| | |
| | | BeanUtils.copyProperties(indexDataVO,analysisVO ); |
| | | }else { |
| | | //总量数据 |
| | | IndexDataKanbanVO indexDataKanbanVO = userDao.selectIndexDataKanban(null); |
| | | IndexDataKanbanVO indexDataKanbanVO = userDao.selectIndexDataKanban(appId); |
| | | BeanUtils.copyProperties(indexDataKanbanVO,analysisVO ); |
| | | } |
| | | String date=""; |
| | |
| | | } |
| | | } |
| | | RealUserVO realUserVO=new RealUserVO(); |
| | | List<RealUser> realUsers = userDao.realUserCount(type, date, streetId, areaCode); |
| | | List<RealUser> realUsers = userDao.realUserCount(type, date, streetId, areaCode,appId); |
| | | List<RealUserAnalysisVO> realUserList=new ArrayList<>(); |
| | | realUserVO.setRealUserCount(getStreetRealUser(realUsers)); |
| | | Integer rate = getRate(analysisVO.getAllUser(), realUserVO.getRealUserCount()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R userActivity(Integer type, Long streetId, Long areaCode, Integer range) { |
| | | public R userActivity(Integer type, Long streetId, Long areaCode, Integer range, String appId) { |
| | | UserActivityAnalysisVO vo=new UserActivityAnalysisVO(); |
| | | List<Date> activeX=getTwentyDays(); |
| | | List<String> activeY=new ArrayList<>(); |
| | |
| | | } |
| | | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); |
| | | for (Date date : activeX) { |
| | | Map<String, Long> map = userDao.getDailyAddAndActive(DateUtil.parse(sdf.format(date)), streetId,areaCode); |
| | | Map<String, Long> map = userDao.getDailyAddAndActive(DateUtil.parse(sdf.format(date)), streetId,areaCode, appId); |
| | | adY.add(map.get("addUser").toString()); |
| | | activeY.add(map.get("activeUser").toString()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R resetPassword(Integer type, String account) { |
| | | SysUserDO sysUserDO=userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getAccount,account).eq(SysUserDO::getType,type)); |
| | | public R resetPassword(Integer type, String account,String appId) { |
| | | SysUserDO sysUserDO=userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getAccount,account).eq(SysUserDO::getType,type).eq(SysUserDO::getAppId,appId)); |
| | | if(sysUserDO!=null){ |
| | | sysUserDO.setPassword("$2a$10$F/2lE2NMhKNHJfi5.FLmfu7jIr7ImRWgCTTeO6m3IRNR2V4sv8YR."); |
| | | userDao.updateById(sysUserDO); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 三说会堂新增业务中心或专家账号 |
| | | * */ |
| | | @Override |
| | | public R addExpertOrIndustryCenter(AdministratorsUserVO administratorsUserVO) { |
| | | SysUserDO sysUserDO=new SysUserDO(); |
| | | //是否存在相同账号 |
| | | SysUserDO userDO = userDao.selectOne(new QueryWrapper<SysUserDO>().eq("account", administratorsUserVO.getAccount())); |
| | | if (isNull(userDO)){ |
| | | sysUserDO.setAppId("wx0cef797390444b75"); |
| | | sysUserDO.setCreateAt(new Date()); |
| | | sysUserDO.setUserId(administratorsUserVO.getUserId()); |
| | | sysUserDO.setAccount(administratorsUserVO.getAccount()); |
| | | sysUserDO.setPassword(new BCryptPasswordEncoder().encode(administratorsUserVO.getPassword())); |
| | | sysUserDO.setName(administratorsUserVO.getName()); |
| | | if (nonNull(administratorsUserVO.getImageUrl())){ |
| | | sysUserDO.setImageUrl(administratorsUserVO.getImageUrl()); |
| | | } |
| | | if (nonNull(administratorsUserVO.getType())){ |
| | | sysUserDO.setType(administratorsUserVO.getType()); |
| | | } |
| | | userDao.insert(sysUserDO); |
| | | //分配权限 |
| | | SysUserRoleDO sysUserRole=new SysUserRoleDO(); |
| | | sysUserRole.setUserId(sysUserDO.getUserId()); |
| | | if (sysUserDO.getType().equals(11)){ |
| | | sysUserRole.setRoleId(Long.parseLong(UserConstants.SANSHUO_EXPERT_ROLE)); |
| | | //将专家小程序账号设置为专家权限 |
| | | SysUserDO sysUserDO1 = userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getType, 1).eq(SysUserDO::getPhone, administratorsUserVO.getPhone())); |
| | | if (nonNull(sysUserDO1)){ |
| | | sysUserDO1.setType(13); |
| | | userDao.updateById(sysUserDO1); |
| | | log.info("添加专家小程序账号权限"); |
| | | } |
| | | }else{ |
| | | sysUserRole.setRoleId(Long.parseLong(UserConstants.SANSHUO_INDUSTRY_CENTER_ROLE)); |
| | | } |
| | | //配置权限 |
| | | sysUserRoleDAO.insert(sysUserRole); |
| | | return R.ok(); |
| | | } |
| | | return R.fail("账户名已存在"); |
| | | } |
| | | |
| | | /** |
| | | * 三说会堂后台重置密码 |
| | | * */ |
| | | @Override |
| | | public R resetPassExpertOrIndustryCenter(String account,String password) { |
| | | SysUserDO sysUserDO = userDao.selectOne(new QueryWrapper<SysUserDO>().eq("account", account)); |
| | | if (nonNull(sysUserDO)){ |
| | | sysUserDO.setPassword(new BCryptPasswordEncoder().encode(password)); |
| | | userDao.updateById(sysUserDO); |
| | | return R.ok(); |
| | | } |
| | | return R.fail("修改失败"); |
| | | } |
| | | |
| | | /** |
| | | * 移除专家权限 |
| | | * */ |
| | | @Override |
| | | public R removeExpertRole(String phone) { |
| | | if (nonNull(phone)){ |
| | | //是否有权限为专家的账号 |
| | | SysUserDO sysUserDO = userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getType, 11).eq(SysUserDO::getPhone, phone)); |
| | | if (nonNull(sysUserDO)){ |
| | | //删除后台账号 |
| | | sysUserDO.setStatus(2); |
| | | userDao.updateById(sysUserDO); |
| | | log.info("禁用专家后台账号成功"); |
| | | } |
| | | //小程序账号移除专家权限 |
| | | SysUserDO sysUserDO1 = userDao.selectOne(new QueryWrapper<SysUserDO>().lambda().eq(SysUserDO::getType, 13).eq(SysUserDO::getPhone, phone)); |
| | | if (nonNull(sysUserDO1)){ |
| | | sysUserDO1.setType(1); |
| | | userDao.updateById(sysUserDO1); |
| | | log.info("移除专家权限成功"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R getAreaAndStreet() { |