| | |
| | | import com.stylefeng.guns.modular.system.model.TUserToCoupon; |
| | | import com.stylefeng.guns.modular.system.service.ITAppUserService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.apache.poi.hdf.extractor.TC; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | // List<TCoupon> notUsedList = tCoupons.stream().filter(coupon -> coupon.getCouponStatus().equals(CouponStatusEnum.NOT_USED.getCode())).collect(Collectors.toList()); |
| | | // List<TCoupon> usedList = tCoupons.stream().filter(coupon -> coupon.getCouponStatus().equals(CouponStatusEnum.USED.getCode())).collect(Collectors.toList()); |
| | | // List<TCoupon> expiredList = tCoupons.stream().filter(coupon -> coupon.getCouponStatus().equals(CouponStatusEnum.EXPIRED.getCode())).collect(Collectors.toList()); |
| | | // 查询当前用户优惠券数量 |
| | | List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().eq("userId", tAppUser.getId())); |
| | | |
| | | // 查询全部未删除优惠券 |
| | | List<TCoupon> tCoupons = tCouponMapper.selectList(new EntityWrapper<TCoupon>() |
| | | .eq("status", true)); |
| | | List<Integer> couponIds = tCoupons.stream().map(TCoupon::getId).collect(Collectors.toList()); |
| | | List<TUserToCoupon> tUserToCoupons; |
| | | if(CollectionUtils.isEmpty(couponIds)){ |
| | | tUserToCoupons = new ArrayList<>(); |
| | | }else { |
| | | // 查询当前用户优惠券数量 |
| | | tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().eq("userId", tAppUser.getId()) |
| | | .in("couponId",couponIds)); |
| | | } |
| | | int couponTotal = tUserToCoupons.stream().mapToInt(TUserToCoupon::getCouponTotal).sum(); |
| | | int validCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getValidCount).sum(); |
| | | int expireCount = tUserToCoupons.stream().mapToInt(TUserToCoupon::getExpireCount).sum(); |
| | |
| | | .filter(order -> OrderStateEnum.CANCELED.getCode() == order.getState()).collect(Collectors.toList()); |
| | | model.addAttribute("canceledNumber",collect.size()); |
| | | |
| | | TOrder tOrder = orders.get(0); |
| | | // 最近消费时间 |
| | | model.addAttribute("latelyTime",DateUtil.formatDate(tOrder.getCreateTime())); |
| | | // 最近消费金额 |
| | | model.addAttribute("latelyPrice",tOrder.getPayMoney()); |
| | | // 获取已支付订单 |
| | | List<TOrder> payOrder = orders.stream().filter(order -> order.getState().equals(OrderStateEnum.WAIT_EVALUATED.getCode()) |
| | | || order.getState().equals(OrderStateEnum.FINISH.getCode())).collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(payOrder)){ |
| | | // 最近消费时间 |
| | | model.addAttribute("latelyTime",""); |
| | | // 最近消费金额 |
| | | model.addAttribute("latelyPrice",""); |
| | | }else { |
| | | TOrder tOrder = payOrder.get(0); |
| | | // 最近消费时间 |
| | | model.addAttribute("latelyTime",DateUtil.formatDate(tOrder.getCreateTime())); |
| | | // 最近消费金额 |
| | | model.addAttribute("latelyPrice",tOrder.getPayMoney()); |
| | | } |
| | | |
| | | // 总消费次数 |
| | | List<TOrder> collect1 = orders.stream().filter(order->Objects.nonNull(order.getState())) |