| | |
| | | package com.stylefeng.guns.modular.shunfeng.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.shunfeng.dao.OrderRideMapper; |
| | | import com.stylefeng.guns.modular.shunfeng.model.OrderRide; |
| | | import com.stylefeng.guns.modular.shunfeng.model.vo.OrderRideInfoVo; |
| | | import com.stylefeng.guns.modular.shunfeng.model.vo.OrderRideVo; |
| | | import com.stylefeng.guns.modular.shunfeng.service.IOrderRideService; |
| | | import com.stylefeng.guns.modular.system.dao.UserActivityDiscount1Mapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.IUserCouponRecordService; |
| | | import com.stylefeng.guns.modular.system.service.IUserInfoService; |
| | | import com.stylefeng.guns.modular.system.service.IUserRedPacketRecordService; |
| | | import com.stylefeng.guns.modular.system.warpper.PreferentialDataVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | List<Map<String, Object>> maps = this.baseMapper.queryMyOrderList(uid, pageNum, size); |
| | | return maps; |
| | | } |
| | | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | | |
| | | @Autowired |
| | | private IUserCouponRecordService userCouponRecordService; |
| | | |
| | | @Autowired |
| | | private IUserRedPacketRecordService userRedPacketRecordService; |
| | | |
| | | @Resource |
| | | private UserActivityDiscount1Mapper userActivityDiscount1Mapper; |
| | | |
| | | @Override |
| | | public PreferentialDataVo queryBalance1(Integer orderId, Integer uid) { |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | PreferentialDataVo preferentialDataVo = new PreferentialDataVo(); |
| | | preferentialDataVo.setBalance(userInfo.getBalance()); |
| | | // OrderRide orderCrossCity = this.selectById(orderId); |
| | | // Integer ids = userInfoService.getDiscount(); |
| | | // if (ids != null) { |
| | | // List<UserActivityDiscount1> userActivityId = userActivityDiscount1Mapper.selectList(new EntityWrapper<UserActivityDiscount1>().eq("userActivityId", ids)); |
| | | // if (userActivityId.size() > 0) { |
| | | // |
| | | // preferentialDataVo.setDiscount(userActivityId.get(0).getLogistics()); |
| | | // } |
| | | // } |
| | | // // 查出当前用户的红包 并将订单的修改 |
| | | // List<UserRedPacketRecord> userRedPacketRecords = userRedPacketRecordService.selectList(new EntityWrapper<UserRedPacketRecord>().eq("userId", uid).eq("state", 1).le("money", orderCrossCity.getOrderMoney()).gt("expirationTime", new Date()).gt("endTime", new Date())); |
| | | // if (userRedPacketRecords.size() > 0) { |
| | | // |
| | | // preferentialDataVo.setRedPacket(userRedPacketRecords.get(0).getMoney()); |
| | | // orderCrossCity.setRedPacketId(userRedPacketRecords.get(0).getId()); |
| | | // orderCrossCity.setRedPacketMoney(userRedPacketRecords.get(0).getMoney()); |
| | | // this.updateById(orderCrossCity); |
| | | // } |
| | | // |
| | | // //获取优惠券中最优数据 |
| | | // List<UserCouponRecord> list = userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("companyId", orderCrossCity.getCompanyId()).eq("state", 1).le("money", orderCrossCity.getOrderMoney()).in("couponUseType", Arrays.asList(0, 3)).eq("userId", uid).where("now() < expirationTime")); |
| | | // Integer id = null; |
| | | // Double price = 0d; |
| | | // Integer type = 0; |
| | | // for (UserCouponRecord userCouponRecord : list) { |
| | | // if (userCouponRecord.getCouponType() == 1) {//抵扣券 |
| | | // if (price.compareTo(userCouponRecord.getMoney()) < 0) { |
| | | // price = userCouponRecord.getMoney(); |
| | | // id = userCouponRecord.getId(); |
| | | // type = 1; |
| | | // } |
| | | // } else {//满减券 |
| | | // if (orderCrossCity.getOrderMoney().compareTo(userCouponRecord.getFullMoney()) >= 0 && price.compareTo(userCouponRecord.getMoney()) < 0) { |
| | | // price = userCouponRecord.getMoney(); |
| | | // id = userCouponRecord.getId(); |
| | | // type = 1; |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // //获取打车卡中最优数 |
| | | // Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderCrossCity.getStartLon().toString(), orderCrossCity.getStartLat().toString()); |
| | | // CompanyCity companyCity = companyCityService.selectOne(new EntityWrapper<CompanyCity>().eq("companyId", orderCrossCity.getCompanyId()).eq("areaCode", geocode.get("districtCode")).eq("state", 1)); |
| | | // if (null == companyCity) { |
| | | // companyCity = companyCityService.selectOne(new EntityWrapper<CompanyCity>().eq("companyId", orderCrossCity.getCompanyId()).eq("cityCode", geocode.get("cityCode")).eq("state", 1)); |
| | | // } |
| | | // if (null == companyCity) { |
| | | // companyCity = companyCityService.selectOne(new EntityWrapper<CompanyCity>().eq("companyId", orderCrossCity.getCompanyId()).eq("provinceCode", geocode.get("provinceCode")).eq("state", 1)); |
| | | // } |
| | | // List<UserTaxiCard> userTaxiCards = new ArrayList<>(); |
| | | // if (companyCity != null) { |
| | | // userTaxiCards = userTaxiCardService.selectList(new EntityWrapper<UserTaxiCard>().like("companyCityId", "%" + companyCity.getId() + "%") |
| | | // .in("type", Arrays.asList(1, 2, 3, 4)).eq("userId", uid).where("now() between startTime and endTime")); |
| | | // } |
| | | // |
| | | // //全国卡 |
| | | // List<TaxiCard> taxiCards = taxiCardService.selectList(new EntityWrapper<TaxiCard>().eq("taxiCardType", 2).in("type", Arrays.asList(1, 2, 3, 4)).eq("state", 1)); |
| | | // if (taxiCards.size() > 0) { |
| | | // List<UserTaxiCard> userTaxiCards2 = userTaxiCardService.selectList(new EntityWrapper<UserTaxiCard>().eq("userId", uid) |
| | | // .in("type", Arrays.asList(1, 2, 3, 4)).in("taxiCardId", taxiCards.stream().map(TaxiCard::getId).collect(Collectors.toList())).where("now() between startTime and endTime")); |
| | | // userTaxiCards.addAll(userTaxiCards2); |
| | | // } |
| | | // Map<String, Object> map = getOptimalTaxiCards(orderCrossCity, price, id, type, userTaxiCards); |
| | | // price = Double.valueOf(map.get("price").toString()); |
| | | // id = null != map.get("id") ? Integer.valueOf(map.get("id").toString()) : null; |
| | | // type = Integer.valueOf(map.get("type").toString()); |
| | | // |
| | | // |
| | | // //亲密账户 |
| | | // List<UserTaxiCard> userTaxiCards_ = new ArrayList<>(); |
| | | // List<UserUser> bindUserId = userUserService.selectList(new EntityWrapper<UserUser>().eq("bindUserId", uid)); |
| | | // CompanyCity finalCompanyCity = companyCity; |
| | | // bindUserId.forEach(userUser -> { |
| | | // if (finalCompanyCity != null) { |
| | | // List<UserTaxiCard> userTaxiCards1 = userTaxiCardService.selectList(new EntityWrapper<UserTaxiCard>().in("type", Arrays.asList(1, 2, 3, 4)) |
| | | // .like("companyCityId", "%" + finalCompanyCity.getId() + "%").eq("userId", userUser.getUserId()).where("now() between startTime and endTime")); |
| | | // userTaxiCards_.addAll(userTaxiCards1); |
| | | // } |
| | | // |
| | | // //全国卡 |
| | | // if (taxiCards.size() > 0) { |
| | | // List<UserTaxiCard> userTaxiCards2 = userTaxiCardService.selectList(new EntityWrapper<UserTaxiCard>().eq("userId", userUser.getUserId()) |
| | | // .in("type", Arrays.asList(1, 2, 3, 4)).in("taxiCardId", taxiCards.stream().map(TaxiCard::getId).collect(Collectors.toList())).where("now() between startTime and endTime")); |
| | | // userTaxiCards_.addAll(userTaxiCards2); |
| | | // } |
| | | // }); |
| | | // map = getOptimalTaxiCards(orderCrossCity, price, id, type, userTaxiCards_); |
| | | // price = Double.valueOf(map.get("price").toString()); |
| | | // id = null != map.get("id") ? Integer.valueOf(map.get("id").toString()) : null; |
| | | // type = Integer.valueOf(map.get("type").toString()); |
| | | // |
| | | // if (price <= orderCrossCity.getOrderMoney() || type == 2) { |
| | | // preferentialDataVo.setObjectId(id); |
| | | // preferentialDataVo.setDiscountAmount(price); |
| | | // preferentialDataVo.setType(type); |
| | | // } |
| | | return preferentialDataVo; |
| | | } |
| | | } |