Search in sources :

Example 1 with Member

use of cn.lili.modules.member.entity.dos.Member in project lilishop by lilishop.

the class StoreServiceImpl method add.

@Override
@Transactional(rollbackFor = Exception.class)
public Store add(AdminStoreApplyDTO adminStoreApplyDTO) {
    // 判断店铺名称是否存在
    QueryWrapper<Store> queryWrapper = Wrappers.query();
    queryWrapper.eq("store_name", adminStoreApplyDTO.getStoreName());
    if (this.getOne(queryWrapper) != null) {
        throw new ServiceException(ResultCode.STORE_NAME_EXIST_ERROR);
    }
    Member member = memberService.getById(adminStoreApplyDTO.getMemberId());
    // 判断用户是否存在
    if (member == null) {
        throw new ServiceException(ResultCode.USER_NOT_EXIST);
    }
    // 判断是否拥有店铺
    if (Boolean.TRUE.equals(member.getHaveStore())) {
        throw new ServiceException(ResultCode.STORE_APPLY_DOUBLE_ERROR);
    }
    // 添加店铺
    Store store = new Store(member, adminStoreApplyDTO);
    this.save(store);
    // 判断是否存在店铺详情,如果没有则进行新建,如果存在则进行修改
    StoreDetail storeDetail = new StoreDetail(store, adminStoreApplyDTO);
    storeDetailService.save(storeDetail);
    // 设置会员-店铺信息
    memberService.update(new LambdaUpdateWrapper<Member>().eq(Member::getId, member.getId()).set(Member::getHaveStore, true).set(Member::getStoreId, store.getId()));
    return store;
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) StoreDetail(cn.lili.modules.store.entity.dos.StoreDetail) ServiceException(cn.lili.common.exception.ServiceException) Store(cn.lili.modules.store.entity.dos.Store) Member(cn.lili.modules.member.entity.dos.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Member

use of cn.lili.modules.member.entity.dos.Member in project lilishop by lilishop.

the class MemberEvaluationServiceImpl method addMemberEvaluation.

@Override
@Transactional(rollbackFor = Exception.class)
public MemberEvaluationDTO addMemberEvaluation(MemberEvaluationDTO memberEvaluationDTO, Boolean isSelf) {
    // 获取子订单信息
    OrderItem orderItem = orderItemService.getBySn(memberEvaluationDTO.getOrderItemSn());
    // 获取订单信息
    Order order = orderService.getBySn(orderItem.getOrderSn());
    // 检测是否可以添加会员评价
    Member member;
    checkMemberEvaluation(orderItem, order);
    if (Boolean.TRUE.equals(isSelf)) {
        // 自我评价商品时,获取当前登录用户信息
        member = memberService.getUserInfo();
    } else {
        // 获取用户信息 非自己评价时,读取数据库
        member = memberService.getById(order.getMemberId());
    }
    // 获取商品信息
    GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(memberEvaluationDTO.getSkuId());
    // 新增用户评价
    MemberEvaluation memberEvaluation = new MemberEvaluation(memberEvaluationDTO, goodsSku, member, order);
    // 过滤商品咨询敏感词
    memberEvaluation.setContent(SensitiveWordsFilter.filter(memberEvaluation.getContent()));
    // 添加评价
    this.save(memberEvaluation);
    // 修改订单货物评价状态为已评价
    orderItemService.updateCommentStatus(orderItem.getSn(), CommentStatusEnum.FINISHED);
    // 发送商品评价消息
    String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_COMMENT_COMPLETE.name();
    rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(memberEvaluation), RocketmqSendCallbackBuilder.commonCallback());
    return memberEvaluationDTO;
}
Also used : Order(cn.lili.modules.order.order.entity.dos.Order) GoodsSku(cn.lili.modules.goods.entity.dos.GoodsSku) MemberEvaluation(cn.lili.modules.member.entity.dos.MemberEvaluation) OrderItem(cn.lili.modules.order.order.entity.dos.OrderItem) Member(cn.lili.modules.member.entity.dos.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Member

use of cn.lili.modules.member.entity.dos.Member in project lilishop by lilishop.

the class MemberNoticeSenterServiceImpl method customSave.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean customSave(MemberNoticeSenter memberNoticeSenter) {
    if (this.saveOrUpdate(memberNoticeSenter)) {
        List<MemberNotice> memberNotices = new ArrayList<>();
        // 如果是选中会员发送
        if (memberNoticeSenter.getSendType().equals(SendTypeEnum.SELECT.name())) {
            // 判定消息是否有效
            if (!CharSequenceUtil.isEmpty(memberNoticeSenter.getMemberIds())) {
                String[] ids = memberNoticeSenter.getMemberIds().split(",");
                MemberNotice memberNotice;
                for (String id : ids) {
                    memberNotice = new MemberNotice();
                    memberNotice.setIsRead(false);
                    memberNotice.setContent(memberNoticeSenter.getContent());
                    memberNotice.setMemberId(id);
                    memberNotice.setTitle(memberNoticeSenter.getTitle());
                    memberNotices.add(memberNotice);
                }
            } else {
                return true;
            }
        } else // 否则是全部会员发送
        {
            List<Member> members = memberService.list();
            MemberNotice memberNotice;
            for (Member member : members) {
                memberNotice = new MemberNotice();
                memberNotice.setIsRead(false);
                memberNotice.setContent(memberNoticeSenter.getContent());
                memberNotice.setMemberId(member.getId());
                memberNotice.setTitle(memberNoticeSenter.getTitle());
                memberNotices.add(memberNotice);
            }
        }
        // 防止没有会员导致报错
        if (!memberNotices.isEmpty()) {
            // 批量保存
            if (memberNoticeService.saveBatch(memberNotices)) {
                return true;
            } else {
                throw new ServiceException(ResultCode.NOTICE_SEND_ERROR);
            }
        }
    }
    return true;
}
Also used : ServiceException(cn.lili.common.exception.ServiceException) MemberNotice(cn.lili.modules.member.entity.dos.MemberNotice) ArrayList(java.util.ArrayList) Member(cn.lili.modules.member.entity.dos.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Member

use of cn.lili.modules.member.entity.dos.Member in project lilishop by lilishop.

the class MemberServiceImpl method modifyPass.

@Override
public Member modifyPass(String oldPassword, String newPassword) {
    AuthUser tokenUser = UserContext.getCurrentUser();
    if (tokenUser == null) {
        throw new ServiceException(ResultCode.USER_NOT_LOGIN);
    }
    Member member = this.getById(tokenUser.getId());
    // 判断旧密码输入是否正确
    if (!new BCryptPasswordEncoder().matches(oldPassword, member.getPassword())) {
        throw new ServiceException(ResultCode.USER_OLD_PASSWORD_ERROR);
    }
    // 修改会员密码
    LambdaUpdateWrapper<Member> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
    lambdaUpdateWrapper.eq(Member::getId, member.getId());
    lambdaUpdateWrapper.set(Member::getPassword, new BCryptPasswordEncoder().encode(newPassword));
    this.update(lambdaUpdateWrapper);
    return member;
}
Also used : ServiceException(cn.lili.common.exception.ServiceException) ConnectAuthUser(cn.lili.modules.connect.entity.dto.ConnectAuthUser) AuthUser(cn.lili.common.security.AuthUser) Member(cn.lili.modules.member.entity.dos.Member) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)

Example 5 with Member

use of cn.lili.modules.member.entity.dos.Member in project lilishop by lilishop.

the class MemberServiceImpl method findByMobile.

@Override
public boolean findByMobile(String uuid, String mobile) {
    QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("mobile", mobile);
    Member member = this.baseMapper.selectOne(queryWrapper);
    if (member == null) {
        throw new ServiceException(ResultCode.USER_NOT_PHONE);
    }
    cache.put(CachePrefix.FIND_MOBILE + uuid, mobile, 300L);
    return true;
}
Also used : ServiceException(cn.lili.common.exception.ServiceException) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Member(cn.lili.modules.member.entity.dos.Member)

Aggregations

Member (cn.lili.modules.member.entity.dos.Member)38 ServiceException (cn.lili.common.exception.ServiceException)24 AuthUser (cn.lili.common.security.AuthUser)11 Transactional (org.springframework.transaction.annotation.Transactional)10 BCryptPasswordEncoder (org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder)8 ConnectAuthUser (cn.lili.modules.connect.entity.dto.ConnectAuthUser)5 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)5 Order (cn.lili.modules.order.order.entity.dos.Order)4 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)4 JSONObject (cn.hutool.json.JSONObject)3 GoodsSku (cn.lili.modules.goods.entity.dos.GoodsSku)3 Pintuan (cn.lili.modules.promotion.entity.dos.Pintuan)3 Store (cn.lili.modules.store.entity.dos.Store)3 StoreDetail (cn.lili.modules.store.entity.dos.StoreDetail)3 ApiOperation (io.swagger.annotations.ApiOperation)3 ArrayList (java.util.ArrayList)3 CartSkuVO (cn.lili.modules.order.cart.entity.vo.CartSkuVO)2 CartVO (cn.lili.modules.order.cart.entity.vo.CartVO)2 KanjiaActivity (cn.lili.modules.promotion.entity.dos.KanjiaActivity)2 KanjiaActivityGoods (cn.lili.modules.promotion.entity.dos.KanjiaActivityGoods)2