| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.activity.entity.Coupon; |
| | | import com.dsh.activity.entity.CouponStore; |
| | | 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.feignclient.account.model.Student; |
| | | import com.dsh.activity.feignclient.course.CoursePackageClient; |
| | | import com.dsh.activity.feignclient.course.model.CoursePackage; |
| | | import com.dsh.activity.feignclient.other.StoreClient; |
| | | import com.dsh.activity.feignclient.other.model.StoreDetailOfCourse; |
| | | import com.dsh.activity.mapper.CouponMapper; |
| | | import com.dsh.activity.mapper.CouponStoreMapper; |
| | | import com.dsh.activity.mapper.UserCouponMapper; |
| | | import com.dsh.activity.model.ConponJsonRuleModel; |
| | | import com.dsh.activity.model.CouponListVo; |
| | |
| | | @Autowired |
| | | private CouponMapper couponMapper; |
| | | |
| | | @Autowired |
| | | private StoreClient storeClient; |
| | | |
| | | @Autowired |
| | | private CouponStoreMapper csMapper; |
| | | |
| | | /** |
| | | * 获取购买课程可用优惠券列表 |
| | |
| | | List<CouponPackageResp> respList = new ArrayList<>(); |
| | | AppUser appUser = appClient.queryAppUser(uid); |
| | | 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<UserCoupon> userCoupons = this.baseMapper.queryCanuseConponIds(appUser.getId(),null); |
| | | List<UserCoupon> userCoupons = this.baseMapper.selectList(new QueryWrapper<UserCoupon>() |
| | | .eq("userId",appUser.getId() ) |
| | | .orderByDesc("insertTime")); |
| | | if (userCoupons.size() > 0){ |
| | | for (UserCoupon userCoupon : userCoupons) { |
| | | Coupon coupon = couponMapper.selectById(userCoupon.getCouponId()); |
| | |
| | | break; |
| | | case 3: |
| | | packageResp.setAvailable("指定门店可用"); |
| | | packageResp.setCityOrStore(""); |
| | | CouponStore couponStore = csMapper.selectOne(new QueryWrapper<CouponStore>() |
| | | .eq("couponId",coupon.getId())); |
| | | StoreDetailOfCourse courseOfStore = storeClient.getCourseOfStore(couponStore.getStoreId()); |
| | | packageResp.setCityOrStore(courseOfStore.getStoreName()+","+courseOfStore.getStoreAddr()); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | break; |
| | | } |
| | | packageResp.setRuleModel(ruleModel); |
| | | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | packageResp.setEffectiveTime(simpleDateFormat.format(coupon.getEndTime())); |
| | | |
| | | if (userCoupon.getStatus() == 1){ |
| | | if (DateUtil.getDate().before(coupon.getEndTime())){ |
| | | packageResp.setUseStatus(1); |