| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.activity.entity.Coupon; |
| | | import com.dsh.activity.entity.TStudent; |
| | | import com.dsh.activity.entity.UserCoupon; |
| | | import com.dsh.activity.feignclient.account.AppUserClient; |
| | | import com.dsh.activity.feignclient.account.StudentClient; |
| | | import com.dsh.activity.feignclient.account.model.AppUser; |
| | |
| | | import com.dsh.activity.model.CouponListVo; |
| | | import com.dsh.activity.model.request.IntegralGoodsOfSearch; |
| | | import com.dsh.activity.service.ICouponService; |
| | | import com.dsh.activity.service.UserCouponService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private UserCouponService userCouponService; |
| | | |
| | | @Autowired |
| | | private ICouponService couponService; |
| | | |
| | | /** |
| | | * 获取购买会员支付成功页面的优惠券 |
| | |
| | | AppUser appUser = appUserClient.queryAppUser(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<Student> 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<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)); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | for (Coupon coupon : list) { |
| | | |
| | | |
| | | |
| | | LocalDateTime currentTime = LocalDateTime.now(); |
| | | LocalDateTime oneMinuteAgo = currentTime.minusSeconds(6000); |
| | | |
| | | |
| | | |
| | | 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()); |
| | | } |
| | | List<Coupon> userId = new ArrayList<>(); |
| | | if (ids.size()>0) { |
| | | |
| | | userId = couponService.list(new QueryWrapper<Coupon>().in("id", ids)); |
| | | } |
| | | |
| | | |
| | | for (Coupon coupon : userId) { |
| | | if (coupon.getDistributionMethod()!=2){ |
| | | continue; |
| | | } |
| | | CouponListVo couponListVo = new CouponListVo(); |
| | | couponListVo.setId(coupon.getId().longValue()); |
| | | couponListVo.setName(coupon.getName()); |
| | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryCouponListOfSearch(CouponListOfSearch ofSearch) { |
| | | return this.baseMapper.queryCouponListOfSearch(ofSearch.getName(),ofSearch.getType(),ofSearch.getDistributionMethod(),ofSearch.getUserPopulation(),ofSearch.getStatus(),ofSearch.getState(),ofSearch.getPage(),ofSearch.getCityCode(),ofSearch.getStoreId()); |
| | | return this.baseMapper.queryCouponListOfSearch(ofSearch.getName(), |
| | | ofSearch.getType(), |
| | | ofSearch.getDistributionMethod(), |
| | | ofSearch.getUserPopulation(), |
| | | ofSearch.getStatus(), |
| | | ofSearch.getState(), |
| | | ofSearch.getCityCode(), |
| | | ofSearch.getStoreId(), |
| | | ofSearch.getOperatorId(), |
| | | ofSearch.getObjType()); |
| | | } |
| | | |
| | | @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()); |
| | | } |