| | |
| | | import com.doumee.dao.business.NoticeMapper; |
| | | import com.doumee.dao.business.join.MemberJoinMapper; |
| | | import com.doumee.dao.business.join.NoticeJoinMapper; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.business.model.Notice; |
| | | import com.doumee.dao.business.model.Shop; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.web.dto.NoticeCardDTO; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.web.request.CouponNoticeRequest; |
| | | import com.doumee.service.business.NoticeService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | |
| | | |
| | | @Override |
| | | public PageData<NoticeCardDTO> findNoticeCardDTOPage(PageWrap<Notice> pageWrap) { |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); |
| | | IPage<Notice> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | LambdaQueryWrapper<Notice> queryWrapper = new LambdaQueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | queryWrapper.eq(Notice::getType,pageWrap.getModel().getType()) |
| | | .eq(Notice::getObjMemberId,loginUserInfo.getMemberId()); |
| | | |
| | | Notice notice = pageWrap.getModel(); |
| | | |
| | | queryWrapper.ne(Objects.nonNull(notice.getQueryType())&&Constants.equalsInteger(notice.getQueryType(),Constants.ZERO), |
| | | Notice::getObjType,Constants.TWO) |
| | | .eq(Objects.nonNull(notice.getQueryType())&&Constants.equalsInteger(notice.getQueryType(),Constants.ONE), |
| | | Notice::getObjType,Constants.TWO) |
| | | .eq(Notice::getMemberId,notice.getMemberId()) |
| | | .orderByAsc(Notice::getStatus) |
| | | .orderByDesc(Notice::getId) |
| | | ; |
| | | IPage<Notice> noticeIPage = noticeMapper.selectPage(page, queryWrapper); |
| | | |
| | | List<NoticeCardDTO> noticeCardDTOs = new ArrayList<>(); |
| | | if (CollectionUtils.isEmpty(noticeIPage.getRecords())){ |
| | | return PageData.from(new Page<>()); |
| | | noticeCardDTOs = noticeIPage.getRecords().stream().map(s -> { |
| | | NoticeCardDTO noticeCardDTO = new NoticeCardDTO(); |
| | | BeanUtils.copyProperties(s, noticeCardDTO); |
| | | return noticeCardDTO; |
| | | |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | List<NoticeCardDTO> noticeCardDTOs = noticeIPage.getRecords().stream().map(s -> { |
| | | NoticeCardDTO noticeCardDTO = new NoticeCardDTO(); |
| | | BeanUtils.copyProperties(s, noticeCardDTO); |
| | | return noticeCardDTO; |
| | | |
| | | }).collect(Collectors.toList()); |
| | | |
| | | PageData<NoticeCardDTO> pageData = new PageData<>(); |
| | | pageData.setPage(pageWrap.getPage()); |
| | | pageData.setCapacity(pageWrap.getCapacity()); |
| | |
| | | return pageData; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | * @param type 0消费者;1=经销商; |
| | | * @param objType 0商城订单 1积分流水 2互动评价 3优惠券 |
| | | * |
| | | */ |
| | | |
| | | public void saveNoticeInfo(Integer type,Integer objType,Integer memberId |
| | | ,String title,String content,Integer objId){ |
| | | Notice notice = new Notice(); |
| | | notice.setCreateDate(new Date()); |
| | | notice.setIsdeleted(Constants.ZERO); |
| | | notice.setTitle(title); |
| | | notice.setContent(content); |
| | | notice.setType(type); |
| | | notice.setObjType(objType); |
| | | notice.setObjId(objId); |
| | | notice.setMemberId(memberId); |
| | | notice.setStatus(Constants.ZERO); |
| | | noticeMapper.insert(notice); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 积分变动消息类型 |
| | | * @param integralObjType 积分变动类型 |
| | | * @param memberId 用户主键/商户主键 |
| | | * @param integral 变动积分/现金值 |
| | | * @param objId 关联对象主键 - 积分流水变动记录主键 |
| | | * @param param1 param2 |
| | | */ |
| | | @Override |
| | | public void saveMemberIntegralNotice(Constants.IntegralObjType integralObjType,Integer type, |
| | | Integer memberId, |
| | | BigDecimal integral, |
| | | Integer objId,String param1){ |
| | | String title = integralObjType.getName(); |
| | | String info = integralObjType.getNoteinfo(); |
| | | info = info.replace("${param}",integral.toString()).replace("${param1}",param1); |
| | | this.saveNoticeInfo( |
| | | type, |
| | | Constants.ONE, |
| | | memberId, |
| | | title, |
| | | info, |
| | | objId |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * 发放优惠券 站内信 |
| | | * @param memberId |
| | | * @param couponList |
| | | */ |
| | | @Override |
| | | public void couponNotice(Integer memberId,List<CouponNoticeRequest> couponList){ |
| | | String noticeInfo = "恭喜您获得${param}"; |
| | | //恭喜您获得 满50减10抵扣券 |
| | | String replaceInfo = ""; |
| | | //整理优惠券内容 |
| | | for (CouponNoticeRequest c:couponList) { |
| | | MemberCoupon mc = c.getMemberCoupon(); |
| | | String info = Constants.equalsInteger(mc.getCouponType(),Constants.ZERO)? |
| | | "满"+mc.getLimitPrice()+"元减"+mc.getPrice()+"元抵扣券*"+c.getNum(): |
| | | "满"+mc.getLimitPrice()+"元享"+mc.getPrice()+"折券"; |
| | | replaceInfo = replaceInfo + (StringUtils.isBlank(replaceInfo)? |
| | | info:","+info); |
| | | } |
| | | noticeInfo.replace("${param}",replaceInfo); |
| | | |
| | | this.saveNoticeInfo( |
| | | Constants.ZERO, |
| | | Constants.ONE, |
| | | memberId, |
| | | "获得系统发放的优惠券", |
| | | noticeInfo, |
| | | null |
| | | ); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 积分过期 站内消息 |
| | | * @param memberId |
| | | * @param integral |
| | | * @param expireDateNum |
| | | */ |
| | | @Override |
| | | public void expireNotice(Integer memberId, BigDecimal integral,Integer expireDateNum){ |
| | | //您有1000积分30天后过期,请尽快使用 |
| | | String noticeInfo = "您有${param}积分即将过期,请尽快使用"; |
| | | if(integral.compareTo(BigDecimal.ZERO)<=Constants.ZERO){ |
| | | return; |
| | | } |
| | | noticeInfo.replace("${param}",integral.toString()); |
| | | this.saveNoticeInfo( |
| | | Constants.ZERO, |
| | | Constants.ONE, |
| | | memberId, |
| | | "您的积分将在"+expireDateNum+"天后清空,请尽快使用", |
| | | noticeInfo, |
| | | null |
| | | ); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 评论消息 站内信 |
| | | * @param memberId |
| | | * @param objId |
| | | * @param memberName |
| | | */ |
| | | @Override |
| | | public void commonNotice(Integer memberId, Integer objId,String memberName ){ |
| | | //您有1000积分30天后过期,请尽快使用 |
| | | String noticeInfo = "${param}回复了您的评论"; |
| | | noticeInfo.replace("${param}",memberName); |
| | | this.saveNoticeInfo( |
| | | Constants.ZERO, |
| | | Constants.TWO, |
| | | memberId, |
| | | noticeInfo, |
| | | noticeInfo, |
| | | objId |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * 订单支付成功 发送消息 |
| | | * @param shopId |
| | | * @param objId |
| | | * @param receiveType |
| | | */ |
| | | @Override |
| | | public void orderPayNotice(Integer shopId, Integer objId,Integer receiveType){ |
| | | if(Constants.equalsInteger(receiveType,Constants.ZERO)){ |
| | | return; |
| | | } |
| | | //您有新的【发货方式】订单待处理 |
| | | String noticeInfo = "您有新的${param}订单待处理"; |
| | | noticeInfo.replace("${param}",Constants.equalsInteger(receiveType,Constants.ZERO)?"物流发货":"门店自提"); |
| | | this.saveNoticeInfo( |
| | | Constants.ONE, |
| | | Constants.ZERO, |
| | | shopId, |
| | | noticeInfo, |
| | | noticeInfo, |
| | | objId |
| | | ); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单取消 发送站内信 |
| | | * @param shopId |
| | | * @param objId |
| | | * @param orderNo |
| | | */ |
| | | @Override |
| | | public void orderCancelNotice(Integer shopId, Integer objId,String orderNo){ |
| | | // 您的订单{订单号},已由客户手动取消,请知悉 |
| | | String noticeInfo = " 您的订单${param},已由客户手动取消,请知悉"; |
| | | noticeInfo.replace("${param}",orderNo); |
| | | this.saveNoticeInfo( |
| | | Constants.ONE, |
| | | Constants.ZERO, |
| | | shopId, |
| | | noticeInfo, |
| | | noticeInfo, |
| | | objId |
| | | ); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |