|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelImporter; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.dao.admin.request.FcodeImport; | 
|---|
|  |  |  | import com.doumee.dao.admin.request.ShopImport; | 
|---|
|  |  |  | import com.doumee.dao.admin.request.UpdateShopSortDTO; | 
|---|
|  |  |  | import com.doumee.dao.business.CategoryMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.CategorySegMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.MemberMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.SegmentsMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.ShopMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.UsersMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.join.ShopJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.ShopTree; | 
|---|
|  |  |  | import com.doumee.dao.business.vo.ShopTreeVo; | 
|---|
|  |  |  | import com.doumee.dao.system.model.SystemUser; | 
|---|
|  |  |  | import com.doumee.dao.web.reqeust.ShopQueryByLLDTO; | 
|---|
|  |  |  | import com.doumee.service.business.ShopService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.util.concurrent.Callable; | 
|---|
|  |  |  | import java.util.concurrent.ExecutorService; | 
|---|
|  |  |  | import java.util.concurrent.Executors; | 
|---|
|  |  |  | import java.util.concurrent.Future; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 志邦组织信息表Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  | private RedisTemplate<String, Object> redisTemplate; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ShopJoinMapper shopMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SegmentsMapper segmentsMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CategorySegMapper categorySegMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UsersMapper usersMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Long create(Shop shop) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<Shop> queryShopByLL(PageWrap<Shop> pageWrap) { | 
|---|
|  |  |  | if(Objects.isNull(pageWrap.getModel()) | 
|---|
|  |  |  | || Objects.isNull(pageWrap.getModel().getLatitude()) | 
|---|
|  |  |  | || Objects.isNull(pageWrap.getModel().getLongitude())){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | IPage<Shop> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | MPJLambdaWrapper<Shop> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | queryWrapper.select("ID,NAME,ADDRESS,PROVINCE_NAME,CITY_NAME,AREA_NAME,TOWN,AREA_NAME,LEGAL_PHONE," + | 
|---|
|  |  |  | " CONVERT (ST_Distance_Sphere (point ("+pageWrap.getModel().getLongitude()+", "+pageWrap.getModel().getLatitude()+" ), point ( LONGITUDE, LATITUDE )) /1000,decimal(15,2)) as distance ") | 
|---|
|  |  |  | .eq("isdeleted",Constants.ZERO) | 
|---|
|  |  |  | .isNotNull("LATITUDE") | 
|---|
|  |  |  | .isNotNull("LONGITUDE") | 
|---|
|  |  |  | .eq("ATTRIBUTE",Constants.ONE) | 
|---|
|  |  |  | .orderByAsc(" distance "); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | PageData<Shop> pageData = PageData.from(shopMapper.selectPage(page, queryWrapper)); | 
|---|
|  |  |  | String prefix = StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.RESOURCE_PATH).getCode()) + | 
|---|
|  |  |  | StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.USERS_FILE).getCode()); | 
|---|
|  |  |  | for (Shop shop:pageData.getRecords()) { | 
|---|
|  |  |  | //查询门店下导购数据 | 
|---|
|  |  |  | List<Users> usersList =usersMapper.selectList(new QueryWrapper<Users>().lambda().eq(Users::getDepartmentId,shop.getId()) | 
|---|
|  |  |  | .eq(Users::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Users::getStatus,Constants.ONE) | 
|---|
|  |  |  | .eq(Users::getType,Constants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (Users users:usersList) { | 
|---|
|  |  |  | if(StringUtils.isNotBlank(users.getImgurl())){ | 
|---|
|  |  |  | users.setImgurlFull(prefix + users.getImgurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | shop.setUsersList(usersList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return pageData; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Shop shopDetail(Long id,Long memberId) { | 
|---|
|  |  |  | Member member = memberMapper.selectById(memberId); | 
|---|
|  |  |  | if(Objects.isNull(member)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到用户信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryWrapper<Shop> queryWrapper = new QueryWrapper<Shop>(); | 
|---|
|  |  |  | //如果人员没有经纬度信息,则不查询距离 | 
|---|
|  |  |  | if(Objects.nonNull(member.getLatitude())&&Objects.nonNull(member.getLongitude())){ | 
|---|
|  |  |  | queryWrapper.select("ID,NAME,ADDRESS,PROVINCE_NAME,CITY_NAME,AREA_NAME,TOWN,AREA_NAME,LEGAL_PHONE," + | 
|---|
|  |  |  | " CONVERT (ST_Distance_Sphere (point ("+member.getLongitude()+", "+member.getLatitude()+" ), point ( LONGITUDE, LATITUDE )) /1000,decimal(15,2)) as distance "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | queryWrapper.eq("id",id); | 
|---|
|  |  |  | Shop shop = shopMapper.selectOne(queryWrapper); | 
|---|
|  |  |  | if(Objects.isNull(shop)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String prefix = StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.RESOURCE_PATH).getCode()) + | 
|---|
|  |  |  | StringUtils.trimToNull(systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.USERS_FILE).getCode()); | 
|---|
|  |  |  | List<Users> usersList =usersMapper.selectList(new QueryWrapper<Users>().lambda().eq(Users::getDepartmentId,shop.getId()) | 
|---|
|  |  |  | .eq(Users::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Users::getStatus,Constants.ONE) | 
|---|
|  |  |  | .eq(Users::getType,Constants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (Users users:usersList) { | 
|---|
|  |  |  | if(StringUtils.isNotBlank(users.getImgurl())){ | 
|---|
|  |  |  | users.setImgurlFull(prefix + users.getImgurl()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | shop.setUsersList(usersList); | 
|---|
|  |  |  | return shop; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|