| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.LabelsMapper; |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.ShopJoinMapper; |
| | | import com.doumee.dao.business.ShopMapper; |
| | |
| | | import com.doumee.dao.web.dto.CouponDTO; |
| | | import com.doumee.dao.web.dto.MemberDTO; |
| | | import com.doumee.dao.web.dto.MultiFileDTO; |
| | | import com.doumee.dao.web.dto.ResetSystemUserPwdDTO; |
| | | import com.doumee.dao.web.dto.shop.*; |
| | | import com.doumee.service.business.*; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.commons.collections.MapUtils; |
| | | import org.apache.commons.lang3.RandomStringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | |
| | | @Autowired |
| | | private ShopNewsService shopNewsService; |
| | | @Autowired |
| | | private LabelsMapper labelsMapper; |
| | | |
| | | @Autowired |
| | | private MultifileService multifileService; |
| | |
| | | isCreateParamValid(shop,user); |
| | | shop.setCreator(user.getId()); |
| | | shop.setCreateDate(new Date()); |
| | | shop.setEditor(user.getId()); |
| | | shop.setEditDate(shop.getCreateDate()); |
| | | shop.setIsdeleted(Constants.ZERO); |
| | | shop.setStatus(Constants.ZERO); |
| | | shop.setIsrec(Constants.ONE); |
| | | shop.setOrigin(Constants.ONE); |
| | | shop.setSaleType(Constants.formatIntegerNum(shop.getSaleType())); |
| | | String salt = RandomStringUtils.randomAlphabetic(6); |
| | | |
| | | shop.setPassword(shop.getCode()+"@123456"); |
| | | // 生成密码 |
| | | shop.setPassword(Utils.Secure.encryptPassword(shop.getPassword(), salt)); |
| | | shop.setSalt(salt); |
| | | shopMapper.insert(shop); |
| | | return shop.getId(); |
| | | } |
| | | |
| | | public void isCreateParamValid(Shop shop , LoginUserInfo user){ |
| | | if(StringUtils.isBlank(shop.getName())|| |
| | | StringUtils.isBlank(shop.getImgurl())|| |
| | | shop.getMemberId()==null |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); |
| | | try { |
| | | String[] ss = shop.getLocationInfo().split(","); |
| | | shop.setLatitude(BigDecimal.valueOf(Double.parseDouble(ss[0]))); |
| | | shop.setLongitude(BigDecimal.valueOf(Double.parseDouble(ss[1]))); |
| | | }catch (Exception e){ |
| | | } |
| | | Member member=memberMapper.selectById(shop.getMemberId()); |
| | | |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"店铺负责人不存在"); |
| | | if(StringUtils.isBlank(shop.getUsername()) |
| | | || StringUtils.isBlank(shop.getPhone()) |
| | | || StringUtils.isBlank(shop.getBusinessImg()) |
| | | || StringUtils.isBlank(shop.getStartTime()) |
| | | || shop.getLatitude()==null |
| | | || shop.getLongitude()==null |
| | | || shop.getBigAreaId()==null |
| | | || shop.getAreaId()==null |
| | | || StringUtils.isBlank(shop.getRealname()) |
| | | || StringUtils.isBlank(shop.getName()) |
| | | || StringUtils.isBlank(shop.getCode())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if(AreasServiceImpl.getAddressByAreaId(shop.getAreaId()) ==null){ |
| | | |
| | | Shop query=new Shop(); |
| | | query.setIsdeleted(Constants.ZERO); |
| | | query.setMemberId(shop.getMemberId()); |
| | | if(shop.getId()!=null){ |
| | | Shop result= shopMapper.selectOne(new QueryWrapper<>(query) |
| | | .last("limit 1") |
| | | ); |
| | | if(!Constants.equalsInteger(result.getId(),shop.getId())){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"店铺负责人已被关联,请从新选择负责人"); |
| | | } |
| | | }else{ |
| | | List<Shop> result= shopMapper.selectList(new QueryWrapper<>(query)); |
| | | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(result)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"店铺负责人已存在,请从新选择负责人"); |
| | | } |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请选择正确的省市区信息~"); |
| | | } |
| | | |
| | | if(labelsMapper.selectById(shop.getBigAreaId()) ==null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请选择正确的区域信息~"); |
| | | } |
| | | if(shopMapper.selectCount(new QueryWrapper<Shop>().lambda() |
| | | .eq(Shop::getName,shop.getName()) |
| | | .ne(shop.getId()!=null,Shop::getId,shop.getId()) |
| | | .eq(Shop::getIsdeleted,Constants.ZERO))>0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"经销商名称重复,请返回修改~"); |
| | | } |
| | | if(shopMapper.selectCount(new QueryWrapper<Shop>().lambda() |
| | | .eq(Shop::getCode,shop.getCode()) |
| | | .ne(shop.getId()!=null,Shop::getId,shop.getId()) |
| | | .eq(Shop::getIsdeleted,Constants.ZERO))>0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"门店ID重复,请返回修改~"); |
| | | } |
| | | if(shopMapper.selectCount(new QueryWrapper<Shop>().lambda() |
| | | .eq(Shop::getUsername,shop.getUsername()) |
| | | .ne(shop.getId()!=null,Shop::getId,shop.getId()) |
| | | .eq(Shop::getIsdeleted,Constants.ZERO))>0){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"登录账号重复,请返回修改~"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public void updateById(Shop shop) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(shop.getId()==null){ |
| | | if(shop.getId()==null ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); |
| | | } |
| | | isCreateParamValid(shop,user); |
| | |
| | | if(Objects.nonNull(shop)&&StringUtils.isNotBlank(shop.getImgurl())){ |
| | | shop.setImgFullUrl(path+shop.getImgurl()); |
| | | } |
| | | shop.setAreas(AreasServiceImpl.getAddressByAreaId(shop.getAreaId())); |
| | | if(shop.getLatitude()!=null && shop.getLongitude()!=null){ |
| | | shop.setLocationInfo(shop.getLatitude().doubleValue()+","+shop.getLongitude().doubleValue()); |
| | | } |
| | | MPJLambdaWrapper<ProductLabel> queryproduct = new MPJLambdaWrapper<>(); |
| | | queryproduct.selectAs(Labels::getName,ProductLabel::getLablesName); |
| | | queryproduct.eq(ProductLabel::getIsdeleted,Constants.ZERO); |
| | |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | |
| | | queryWrapper.selectAll(Shop.class); |
| | | queryWrapper.selectAs(Labels::getName,Shop::getBigAreaName); |
| | | queryWrapper.selectAs(Member::getNickname,Shop::getNickName); |
| | | queryWrapper.selectAs(Member::getImgurl,Shop::getMemberImgurl); |
| | | queryWrapper.selectAs(Member::getPhone,Shop::getMemberPhone); |
| | | |
| | | queryWrapper.leftJoin(Member.class,Member::getId,Shop::getMemberId); |
| | | queryWrapper.leftJoin(Labels.class,Labels::getId,Shop::getBigAreaId); |
| | | |
| | | queryWrapper.eq(Shop::getIsdeleted, Constants.ZERO); |
| | | |
| | | queryWrapper.and(StringUtils.isNotBlank(pageWrap.getModel().getName()),s->s.like(Shop::getName,pageWrap.getModel().getName())); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getCode()) ,Shop::getCode,pageWrap.getModel().getCode()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getUsername()) ,Shop::getName,pageWrap.getModel().getUsername()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getName()) ,Shop::getName,pageWrap.getModel().getName()); |
| | | queryWrapper.eq(pageWrap.getModel().getSaleType()!=null, Shop::getSaleType, pageWrap.getModel().getSaleType()); |
| | | queryWrapper.eq(pageWrap.getModel().getStatus()!=null, Shop::getStatus, pageWrap.getModel().getStatus()); |
| | | queryWrapper.eq(pageWrap.getModel().getIsrec()!=null, Shop::getIsrec, pageWrap.getModel().getIsrec()); |
| | | queryWrapper.orderByDesc(Shop::getCreateDate); |
| | | IPage<Shop> result = shopJoinMapper.selectJoinPage(page, Shop.class, queryWrapper); |
| | | |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILE).getCode(); |
| | | for(Shop model:result.getRecords()){ |
| | | model.setImgFullUrl(path); |
| | | model.setAreas( AreasServiceImpl.getAddressByAreaId(model.getAreaId())); |
| | | if(model.getLatitude()!=null && model.getLongitude()!=null){ |
| | | model.setLocationInfo(model.getLatitude().doubleValue()+","+model.getLongitude().doubleValue()); |
| | | } |
| | | |
| | | } |
| | | return PageData.from(result ); |
| | | } |
| | |
| | | memberCoupon.setShopId(shopId); |
| | | memberCoupon.setType(Constants.ZERO); |
| | | memberCoupon.setStatus(Constants.ONE); |
| | | Integer shopCouponUseCount = memberCouponService.count(memberCoupon); |
| | | long shopCouponUseCount = memberCouponService.count(memberCoupon); |
| | | |
| | | ShopFollow shopFollow = new ShopFollow(); |
| | | shopFollow.setObjId(shopId); |
| | | shopFollow.setObjType(Constants.ZERO); |
| | | Integer shopFansCount = shopFollowService.count(shopFollow); |
| | | long shopFansCount = shopFollowService.count(shopFollow); |
| | | |
| | | ShopNews shopNews = new ShopNews(); |
| | | shopNews.setShopId(shopId); |
| | | Integer shopNewCount = shopNewsService.count(shopNews); |
| | | long shopNewCount = shopNewsService.count(shopNews); |
| | | ShopDataStatisticsDTO shopDataStatisticsDTO = new ShopDataStatisticsDTO(); |
| | | shopDataStatisticsDTO.setShopCouponUseCount(shopCouponUseCount) |
| | | .setShopFansCount(shopFansCount).setShopNewCount(shopNewCount); |
| | |
| | | shopScan.setMemberId(shop.getMemberId()); |
| | | shopScanService.create(shopScan); |
| | | } |
| | | |
| | | @Override |
| | | public void resetPwd(Shop dto) { |
| | | // 查询用户 |
| | | Shop shop = findById(dto.getId()); |
| | | if (shop == null) { |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | // 修改密码 |
| | | Shop updateUserDto = new Shop(); |
| | | updateUserDto.setId(dto.getId()); |
| | | updateUserDto.setPassword(Utils.Secure.encryptPassword( shop.getCode()+"@123456", shop.getSalt())); |
| | | shopMapper.updateById(updateUserDto); |
| | | } |
| | | } |