| package com.xzx.gc.system.service; | 
|   | 
| import cn.hutool.core.collection.CollUtil; | 
| import com.xzx.gc.common.Result; | 
| import com.xzx.gc.common.constant.CommonEnum; | 
| import com.xzx.gc.common.constant.Constants; | 
| import com.xzx.gc.common.dto.gdmap.GdReverseGEODto; | 
| import com.xzx.gc.common.utils.BusinessUtil; | 
| import com.xzx.gc.common.utils.gdmap.GdMapUtil; | 
| import com.xzx.gc.entity.AddressInfo; | 
| import com.xzx.gc.entity.AddressLevelInfo; | 
| import com.xzx.gc.entity.OtherUserInfo; | 
| import com.xzx.gc.entity.UserInfo; | 
| import com.xzx.gc.system.mapper.UserMapper; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.transaction.annotation.Transactional; | 
| import tk.mybatis.mapper.entity.Example; | 
|   | 
| import javax.servlet.http.HttpServletRequest; | 
| import java.util.List; | 
|   | 
| @Service | 
| @Transactional | 
| @Slf4j | 
| public class UserService { | 
|     @Autowired | 
|     private UserMapper userMapper; | 
|   | 
|     @Autowired | 
|     private AddressLevelService addressLevelService; | 
|   | 
|     @Autowired | 
|     private OtherUserService otherUserService; | 
|   | 
|     @Autowired | 
|     private HttpServletRequest request; | 
|   | 
|     @Autowired | 
|     private BusinessUtil businessUtil; | 
|   | 
|   | 
|     public UserInfo findById(String userId){ | 
|         return userMapper.selectByPrimaryKey(userId); | 
|     } | 
|   | 
|     public List<UserInfo> findForBiddenByTime(){ | 
|         Example example=new Example(UserInfo.class); | 
|         Example.Criteria criteria = example.createCriteria(); | 
|         criteria.andEqualTo("delFlag",Constants.DEL_NOT_FLAG); | 
|         criteria.andCondition("DATE_FORMAT(regist_time,'%Y-%m-%d')=date_sub(CURRENT_DATE(), interval 1 day)"); | 
|         List<UserInfo> userInfo1 = userMapper.selectByExample(example); | 
|         return userInfo1; | 
|     } | 
|   | 
|     /** | 
|      * 根据用户经纬度查询位置 | 
|      * @return | 
|      */ | 
|     public AddressLevelInfo findByLocation(String location){ | 
|         GdReverseGEODto gdReverseGEODto = new GdReverseGEODto(); | 
|         gdReverseGEODto.setLocation(location); | 
|         Result areaInfo = GdMapUtil.getAreaInfo(gdReverseGEODto, 0); | 
|         if (areaInfo.getCode() == 0) { | 
|             AddressInfo addressInfo = (AddressInfo) areaInfo.getData(); | 
|             AddressLevelInfo addressLevelInfo=new AddressLevelInfo(); | 
|             addressLevelInfo.setLevel3Name(addressInfo.getTownshipName()); | 
|             addressLevelInfo.setLevel2Name(addressInfo.getCityName()); | 
|             addressLevelInfo.setLevel1Name(addressInfo.getProvinceName()); | 
|             List<AddressLevelInfo> byAny = addressLevelService.findByAny(addressLevelInfo); | 
|             if(CollUtil.isNotEmpty(byAny)){ | 
|                 return byAny.get(0); | 
|             }else { | 
|                 return null; | 
|             } | 
|         } else { | 
|             return null; | 
|         } | 
|     } | 
|   | 
|     /** | 
|      * 查询手机号码 | 
|      * @param userId | 
|      * @param type    类型 0普通用户 1平台用户 | 
|      * @return | 
|      */ | 
|     public String findOtherByUserId(String userId,int type){ | 
|         if (businessUtil.isApp(request.getHeader("clientType"))) { | 
|             OtherUserInfo byId = otherUserService.findById(userId); | 
|             if(byId!=null)return byId.getMobilePhone(); | 
|         }else{ | 
|             UserInfo byId = findById(userId); | 
|             if(byId!=null)return byId.getMobilePhone(); | 
|         } | 
|         return "未知"; | 
|     } | 
|   | 
|     public List<UserInfo> findForBidden(){ | 
|         UserInfo userInfo = new UserInfo(); | 
|         userInfo.setDelFlag(Constants.DEL_NOT_FLAG); | 
|         List<UserInfo> userInfo1 = userMapper.select(userInfo); | 
|         return userInfo1; | 
|     } | 
| } |