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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations