| | |
| | | |
| | | @Autowired |
| | | private TRechargeRecordMapper tRechargeRecordMapper; |
| | | @Autowired |
| | | private TUserToCouponMapper tUserToCouponMapper; |
| | | |
| | | @Override |
| | | public EntityWrapper<TAgent> getAgentWrapper(String principal, String principalPhone, String createTime) { |
| | |
| | | wrapper.eq("id",ShiroKit.getUser().getObjectId()); |
| | | } |
| | | wrapper.ne("status", StatusEnum.DELETE.getCode()); |
| | | wrapper.orderBy("createTime",false); |
| | | return wrapper; |
| | | } |
| | | |
| | |
| | | && Objects.nonNull(order.getCouponId()) && order.getAgentId().equals(tAgent.getId())).collect(Collectors.toList()); |
| | | model.addAttribute("usedCoupon",usedCoupon.size()); |
| | | // 已使用优惠券金额求和,已使用优惠券id |
| | | List<Integer> usedCouponId = usedCoupon.stream().map(TOrder::getCouponId).collect(Collectors.toList()); |
| | | // 查询已使用优惠券金额求和 |
| | | List<TCoupon> tCoupons1 = tCouponMapper.selectList(new EntityWrapper<TCoupon>().in("id", usedCouponId)); |
| | | if(CollectionUtils.isEmpty(tCoupons1)){ |
| | | model.addAttribute("couponPriceSum", BigDecimal.ZERO); |
| | | }else { |
| | | tCoupons1.stream().map(TCoupon::getCouponPreferentialAmount).reduce(BigDecimal::add).ifPresent(bigDecimal -> model.addAttribute("couponPriceSum", bigDecimal)); |
| | | } |
| | | // List<Integer> usedCouponId = usedCoupon.stream().map(TOrder::getCouponId).collect(Collectors.toList()); |
| | | // if(CollectionUtils.isEmpty(usedCouponId)){ |
| | | // // 如果优惠券为空 |
| | | // model.addAttribute("couponPriceSum", BigDecimal.ZERO); |
| | | // }else { |
| | | // // 查询已使用优惠券金额求和 |
| | | // List<TCoupon> tCoupons1 = tCouponMapper.selectList(new EntityWrapper<TCoupon>().in("id", usedCouponId)); |
| | | // if(CollectionUtils.isEmpty(tCoupons1)){ |
| | | // model.addAttribute("couponPriceSum", BigDecimal.ZERO); |
| | | // }else { |
| | | // tCoupons1.stream().map(TCoupon::getCouponPreferentialAmount).reduce(BigDecimal::add).ifPresent(bigDecimal -> model.addAttribute("couponPriceSum", bigDecimal)); |
| | | // } |
| | | // } |
| | | // 优惠券信息 |
| | | // 过滤代理商发放的优惠券 |
| | | List<TCoupon> tCoupons = tCouponMapper.selectList(new EntityWrapper<TCoupon>()); |
| | | model.addAttribute("issuedCoupon",tCoupons.size()); |
| | | List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>().eq("objectId",tAgent.getId()) |
| | | .eq("roleType",3)); |
| | | BigDecimal couponPriceSum = BigDecimal.ZERO; |
| | | for (TUserToCoupon userToCoupon : tUserToCoupons) { |
| | | TCoupon tCoupons1 = tCouponMapper.selectById(userToCoupon.getCouponId()); |
| | | couponPriceSum = couponPriceSum.add(tCoupons1.getCouponPreferentialAmount().multiply(new BigDecimal(userToCoupon.getCouponTotal()))); |
| | | } |
| | | model.addAttribute("couponPriceSum", couponPriceSum); |
| | | // 过滤代理商发放的优惠券 |
| | | int sum = tUserToCoupons.stream().mapToInt(TUserToCoupon::getCouponTotal).sum(); |
| | | model.addAttribute("issuedCoupon",sum); |
| | | // 司机信息 |
| | | // 司机数 |
| | | List<TDriver> drivers = tDriverMapper.selectList(new EntityWrapper<TDriver>().eq("agentId", tAgent.getId())); |
| | |
| | | List<TOrder> tOrders = tOrderMapper.selectList(new EntityWrapper<TOrder>()); |
| | | // 查询优惠券 |
| | | List<TCoupon> tCoupons = tCouponMapper.selectList(new EntityWrapper<TCoupon>()); |
| | | // 用户 |
| | | List<TUserToCoupon> tUserToCoupons = tUserToCouponMapper.selectList(new EntityWrapper<TUserToCoupon>()); |
| | | // 查询司机信息 |
| | | List<TDriver> tDrivers = tDriverMapper.selectList(new EntityWrapper<TDriver>()); |
| | | |
| | |
| | | && Objects.nonNull(order.getCouponId()) && tAgent.getId().equals(order.getAgentId())).collect(Collectors.toList()); |
| | | tAgentResp.setUsedCoupon(usedCoupon.size()); |
| | | // 已使用优惠券金额求和,已使用优惠券id |
| | | List<Integer> usedCouponId = usedCoupon.stream().map(TOrder::getCouponId).collect(Collectors.toList()); |
| | | // 查询已使用优惠券金额求和 |
| | | List<TCoupon> tCoupons1 = tCouponMapper.selectList(new EntityWrapper<TCoupon>().in("id", usedCouponId)); |
| | | tCoupons1.stream().map(TCoupon::getCouponPreferentialAmount).reduce(BigDecimal::add).ifPresent(tAgentResp::setCouponPriceSum); |
| | | // List<Integer> usedCouponId = usedCoupon.stream().map(TOrder::getCouponId).collect(Collectors.toList()); |
| | | // if(CollectionUtils.isEmpty(usedCouponId)){ |
| | | // tAgentResp.setCouponPriceSum(BigDecimal.ZERO); |
| | | // }else { |
| | | // // 查询已使用优惠券金额求和 |
| | | // BigDecimal couponPriceSum = BigDecimal.ZERO; |
| | | // for (Integer id : usedCouponId) { |
| | | // TCoupon tCoupons1 = tCouponMapper.selectById(id); |
| | | // couponPriceSum = couponPriceSum.add(tCoupons1.getCouponPreferentialAmount()); |
| | | // } |
| | | // tAgentResp.setCouponPriceSum(couponPriceSum); |
| | | // } |
| | | } |
| | | |
| | | if(!CollectionUtils.isEmpty(tCoupons)){ |
| | | if(!CollectionUtils.isEmpty(tUserToCoupons)){ |
| | | // 过滤代理商发放的优惠券 |
| | | List<TCoupon> coupons = tCoupons.stream().filter(coupon -> tAgent.getId().equals(coupon.getAgentId())).collect(Collectors.toList()); |
| | | tAgentResp.setIssuedCoupon(coupons.size()); |
| | | List<TUserToCoupon> userToCoupons = tUserToCoupons.stream().filter(coupon -> tAgent.getId().equals(coupon.getObjectId()) && coupon.getRoleType() == 3).collect(Collectors.toList()); |
| | | int sum = userToCoupons.stream().mapToInt(TUserToCoupon::getCouponTotal).sum(); |
| | | tAgentResp.setIssuedCoupon(sum); |
| | | BigDecimal couponPriceSum = BigDecimal.ZERO; |
| | | for (TUserToCoupon userToCoupon : userToCoupons) { |
| | | TCoupon tCoupons1 = tCouponMapper.selectById(userToCoupon.getCouponId()); |
| | | couponPriceSum = couponPriceSum.add(tCoupons1.getCouponPreferentialAmount().multiply(new BigDecimal(userToCoupon.getCouponTotal()))); |
| | | } |
| | | tAgentResp.setCouponPriceSum(couponPriceSum); |
| | | } |
| | | |
| | | if(!CollectionUtils.isEmpty(tDrivers)){ |