| | |
| | | shop.setPassword(Utils.Secure.encryptPassword(shop.getPassword(), salt)); |
| | | shop.setSalt(salt); |
| | | shopMapper.insert(shop); |
| | | //分享码 |
| | | String url = inviteRecordService.createShopMiniProgramCode(shop.getId()); |
| | | if(StringUtils.isNotBlank(url)){ |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getProgramCode,url) |
| | | .eq(Shop::getId,shop.getId())); |
| | | } |
| | | //分享海报 |
| | | String posterUrl = inviteRecordService.createShareImg(Constants.ONE,shop.getId(),shop.getPosterImg()); |
| | | if(StringUtils.isNotBlank(posterUrl)){ |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getPosterImgCode,posterUrl) |
| | | .eq(Shop::getId,shop.getId())); |
| | | } |
| | | return shop.getId(); |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void updateById(Shop shop) { |
| | | public void updateById(Shop shop) throws Exception { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(shop.getId()==null ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); |
| | |
| | | shop.setEditor(user.getId()); |
| | | shop.setEditDate(new Date()); |
| | | |
| | | if(StringUtils.isBlank(model.getProgramCode())){ |
| | | //分享码 |
| | | String url = inviteRecordService.createShopMiniProgramCode(shop.getId()); |
| | | if(StringUtils.isNotBlank(url)){ |
| | | shop.setProgramCode(url); |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(shop.getPosterImg())){ |
| | | //分享海报 |
| | | String posterUrl = inviteRecordService.createShareImg(Constants.ONE,shop.getId(),shop.getPosterImg()); |
| | | if(StringUtils.isNotBlank(posterUrl)){ |
| | | shop.setPosterImgCode(posterUrl); |
| | | } |
| | | } |
| | | shopMapper.updateById(shop); |
| | | if(shop.getSaleType() !=null && !Constants.equalsInteger(shop.getSaleType(),model.getSaleType())){ |
| | | //如果销售模式发生编码,记录变更记录 |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void updateByIdInBatch(List<Shop> shops) { |
| | | if (CollectionUtils.isEmpty(shops)) { |
| | | return; |
| | | } |
| | | for (Shop shop: shops) { |
| | | this.updateById(shop); |
| | | } |
| | | } |
| | | // @Override |
| | | // public void updateByIdInBatch(List<Shop> shops) { |
| | | // if (CollectionUtils.isEmpty(shops)) { |
| | | // return; |
| | | // } |
| | | // for (Shop shop: shops) { |
| | | // this.updateById(shop); |
| | | // } |
| | | // } |
| | | |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | @Override |
| | |
| | | && StringUtils.isNotBlank(dto.getLgt())){ |
| | | isArea = true; |
| | | } |
| | | |
| | | List<Shop> shopList = shopJoinMapper.selectList(new MPJLambdaWrapper<Shop>() |
| | | List<Shop> shopList = shopJoinMapper.selectJoinList(Shop.class,new MPJLambdaWrapper<Shop>() |
| | | .selectAll(Shop.class) |
| | | .select(" CONVERT( ST_Distance_Sphere ( POINT ( LONGITUDE, LATITUDE ), POINT ( "+dto.getLgt()+", "+dto.getLat()+" )) /1000,DECIMAL(15,2))",Shop::getDistance) |
| | | .leftJoin(Areas.class,Areas::getId,Shop::getAreaId) |
| | | .eq(Objects.nonNull(dto.getCityId()),Areas::getParentId,dto.getCityId()) |
| | | .like(Objects.nonNull(dto.getShopName()),Shop::getName,dto.getShopName()) |
| | | .select(" CONVERT( ST_Distance_Sphere ( POINT ( LONGITUDE, LATITUDE ), POINT ( '"+dto.getLgt()+"' , '"+dto.getLat()+"' )) /1000,DECIMAL(15,2))",Shop::getDistance) |
| | | .leftJoin(SystemUser.class,SystemUser::getId,Shop::getCreator) |
| | | .like(StringUtils.isNotBlank(dto.getCityName()),Shop::getAddr,dto.getCityName()) |
| | | .like(StringUtils.isNotBlank(dto.getShopName()),Shop::getName,dto.getShopName()) |
| | | .orderByDesc(!isArea,Shop::getId) |
| | | .orderByAsc(isArea,Shop::getDistance) |
| | | .orderByAsc(isArea," distance ") |
| | | ); |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILE).getCode(); |
| | | for(Shop model:shopList){ |
| | | model.setImgFullUrl(path+model.getImgurl()); |
| | | |
| | | model.setImgFullUrl(StringUtils.isNotBlank(model.getImgurl())?path+model.getImgurl():null); |
| | | |
| | | } |
| | | return shopList; |