| | |
| | | import com.dsh.activity.model.request.IntegralGoodsOfSearch; |
| | | import com.dsh.activity.service.ICouponService; |
| | | import com.dsh.activity.service.UserCouponService; |
| | | import com.dsh.activity.util.RedisUtil; |
| | | import com.dsh.activity.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Resource |
| | | private StudentClient studentClient; |
| | | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private UserCouponService userCouponService; |
| | | |
| | | @Autowired |
| | | private ICouponService couponService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | |
| | | /** |
| | | * 获取购买会员支付成功页面的优惠券 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<CouponListVo> queryCouponList(Integer uid, Integer distributionMethod) throws Exception { |
| | | AppUser appUser = appUserClient.queryAppUser(uid); |
| | | String value = redisUtil.getValue("VIP_P_" + uid); |
| | | if (ToolUtil.isEmpty(value)) { |
| | | Thread.sleep(3000); |
| | | value = redisUtil.getValue("VIP_P_" + uid); |
| | | } |
| | | List<CouponListVo> listVos = new ArrayList<>(); |
| | | if (null != appUser) { |
| | | // List<Integer> userPopulation = new ArrayList<>(); |
| | | // userPopulation.add(1);//全部用户 |
| | | // if (1 == appUser.getIsVip()) { |
| | | // userPopulation.add(2);//年度会员 |
| | | // } |
| | | // List<TStudent> students = studentClient.queryStudentList(uid); |
| | | // if (students.size() > 0) { |
| | | // userPopulation.add(3);//已有学员用户 |
| | | // } |
| | | |
| | | |
| | | // List<Coupon> list = this.list(new QueryWrapper<Coupon>().eq("distributionMethod", distributionMethod) |
| | | // .in("userPopulation", userPopulation) |
| | | // .eq("auditStatus", 2).eq("status", 2).eq("state", 1) |
| | | // .last(" and now() between startTime and endTime order by insertTime desc")); |
| | | |
| | | |
| | | // List<Coupon> list = this.list(new QueryWrapper<Coupon>().eq("distributionMethod", 2).eq("userPopulation",2) |
| | | // .le("startTime", new Date()).ge("endTime", new Date()).eq("auditStatus", 2) |
| | | // .eq("state", 1)); |
| | | if (ToolUtil.isNotEmpty(value)) { |
| | | List<Long> longs = JSON.parseArray(value, Long.class); |
| | | List<UserCoupon> list = userCouponService.getBaseMapper().selectBatchIds(longs); |
| | | List<Integer> collect = list.stream().map(UserCoupon::getCouponId).collect(Collectors.toList()); |
| | | List<Coupon> coupons = couponService.getBaseMapper().selectBatchIds(collect); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | |
| | | |
| | | LocalDateTime currentTime = LocalDateTime.now(); |
| | | LocalDateTime oneMinuteAgo = currentTime.minusSeconds(30); |
| | | |
| | | List<UserCoupon> list = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", uid).ge("insertTime", oneMinuteAgo)); |
| | | List<Integer> ids = new ArrayList<>(); |
| | | for (UserCoupon userCoupon : list) { |
| | | ids.add(userCoupon.getCouponId()); |
| | | } |
| | | |
| | | // if (ids.size()>0){ |
| | | List<Coupon> userId = couponService.list(new QueryWrapper<Coupon>().in("id",ids)); |
| | | // return userId; |
| | | // |
| | | // } |
| | | |
| | | |
| | | for (Coupon coupon : userId) { |
| | | for (Coupon coupon : coupons) { |
| | | if (coupon.getDistributionMethod() != 2) { |
| | | continue; |
| | | } |
| | | CouponListVo couponListVo = new CouponListVo(); |
| | | couponListVo.setId(coupon.getId().longValue()); |
| | | couponListVo.setName(coupon.getName()); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Map<String, Object> queryConponRuleOfJson(Integer id) { |
| | | return this.baseMapper.queryConponRuleOfJson(id); |
| | |
| | | ofSearch.getUserPopulation(), |
| | | ofSearch.getStatus(), |
| | | ofSearch.getState(), |
| | | ofSearch.getPage(), |
| | | ofSearch.getCityCode(), |
| | | ofSearch.getStoreId(), |
| | | ofSearch.getOperatorId(), |
| | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryCouponListOfSearch1(CouponListOfSearch ofSearch) { |
| | | return this.baseMapper.queryCouponListOfSearch1(ofSearch.getName(),ofSearch.getType(),ofSearch.getDistributionMethod(),ofSearch.getUserPopulation(),ofSearch.getStatus(),ofSearch.getState(),ofSearch.getPage(),ofSearch.getCityCode(),ofSearch.getStoreId()); |
| | | } |
| | | @Override |
| | | public List<Map<String, Object>> queryCouponExamineList(CouponExamineListSearch ofSearch) { |
| | | return this.baseMapper.queryCouponExamineList(ofSearch.getName(),ofSearch.getType(),ofSearch.getUserPopulation(),ofSearch.getDistributionMethod(),ofSearch.getAuditStatus(),ofSearch.getPage()); |
| | | return this.baseMapper.queryCouponListOfSearch1(ofSearch.getName(), ofSearch.getType(), ofSearch.getDistributionMethod(), ofSearch.getUserPopulation(), ofSearch.getStatus(), ofSearch.getState(), ofSearch.getPage(), ofSearch.getCityCode(), ofSearch.getStoreId()); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> listRecord(Page<Object> objectPage, Integer id, List<Integer> ids, Integer type) { |
| | | return this.baseMapper.listRecord(objectPage,id,ids,type); |
| | | public List<Map<String, Object>> queryCouponExamineList(CouponExamineListSearch ofSearch) { |
| | | return this.baseMapper.queryCouponExamineList(ofSearch.getName(), ofSearch.getType(), ofSearch.getUserPopulation(), ofSearch.getDistributionMethod(), ofSearch.getAuditStatus(), ofSearch.getPage()); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> listRecord(Integer id, List<Integer> ids, Integer type) { |
| | | return this.baseMapper.listRecord(id, ids, type); |
| | | } |
| | | |
| | | @Override |