| | |
| | | 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; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | model.addAttribute("id",tAppUser.getId()); |
| | | model.addAttribute("nickname",tAppUser.getNickname()); |
| | | model.addAttribute("remark",tAppUser.getRemark()); |
| | | model.addAttribute("accountBalance",tAppUser.getAccountBalance()); |
| | | model.addAttribute("createTime",DateUtil.formatDate(tAppUser.getCreateTime())); |
| | | // todo 客户渠道 |
| | | model.addAttribute("customerChannel",""); |
| | |
| | | // 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.getPayTime())); |
| | | // 最近消费金额 |
| | | model.addAttribute("latelyPrice",tOrder.getPayMoney()); |
| | | } |
| | | |
| | | // 总消费次数 |
| | | List<TOrder> collect1 = orders.stream().filter(order->Objects.nonNull(order.getState())) |
| | |
| | | // 开始,结束时间 |
| | | if(StringUtils.hasLength(createTime)){ |
| | | String[] split = createTime.split(" - "); |
| | | Date startTime = DateUtil.getDate_str4(split[0]); |
| | | Date endTime = DateUtil.getDate_str4(split[1]); |
| | | Date startTime = DateUtil.getDate_str3(split[0]+" 00:00:00"); |
| | | Date endTime = DateUtil.getDate_str3(split[1]+" 23:59:59"); |
| | | wrapper.between("createtime",startTime,endTime); |
| | | } |
| | | // if(Objects.nonNull(startTime) && Objects.nonNull(endTime)){ |