| | |
| | | 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.CouponCity; |
| | | import com.dsh.activity.entity.CouponStore; |
| | | import com.dsh.activity.entity.UserCoupon; |
| | | import com.dsh.activity.feignclient.account.AppUserClient; |
| | |
| | | import com.dsh.activity.feignclient.other.StoreClient; |
| | | import com.dsh.activity.feignclient.other.model.Site; |
| | | import com.dsh.activity.feignclient.other.model.StoreDetailOfCourse; |
| | | import com.dsh.activity.mapper.CouponCityMapper; |
| | | import com.dsh.activity.mapper.CouponMapper; |
| | | import com.dsh.activity.mapper.CouponStoreMapper; |
| | | import com.dsh.activity.mapper.UserCouponMapper; |
| | |
| | | private CouponMapper couponMapper; |
| | | |
| | | @Resource |
| | | private CouponCityMapper couponCityMapper; |
| | | |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | |
| | | @Resource |
| | |
| | | private SiteClient siteClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取购买课程可用优惠券列表 |
| | | * |
| | | * @param uid |
| | | * @param coursePackageId |
| | | * @return |
| | |
| | | if (type == 1) {//满减{"num1":1,"num2":1} |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | if (price.compareTo(num1) < 0) { |
| | | continue; |
| | | } |
| | | couponListVo.setUseCondition("满" + num1 + "元可用"); |
| | | couponListVo.setUseCondition("满¥" + num1 + "元可用"); |
| | | couponListVo.setFavorable(jsonObject.getString("deductionAmount")); |
| | | } |
| | | if (type == 2) {//代金券{"num1":1} |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | Double num1 = jsonObject.getDouble("deductionAmount"); |
| | | if(num1==null){ |
| | | num1=0d; |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | if (num1 == null) { |
| | | num1 = 0d; |
| | | } |
| | | if(price.compareTo(num1) <= 0){ |
| | | if (price.compareTo(num1) < 0) { |
| | | continue; |
| | | } |
| | | couponListVo.setUseCondition(""); |
| | |
| | | |
| | | /** |
| | | * 获取预约场地可用优惠券列表 |
| | | * |
| | | * @param siteId |
| | | * @param price |
| | | * @return |
| | |
| | | if (type == 1) {//满减{"num1":1,"num2":1} |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | if (price.compareTo(num1) < 0) { |
| | | continue; |
| | | } |
| | | couponListVo.setUseCondition("满" + num1 + "元可用"); |
| | |
| | | } |
| | | if (type == 2) {//代金券{"num1":1} |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | Double num1 = jsonObject.getDouble("deductionAmount"); |
| | | if(num1==null){ |
| | | num1=0d; |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | if (num1 == null) { |
| | | num1 = 0d; |
| | | } |
| | | if(price.compareTo(num1) <= 0){ |
| | | if (price.compareTo(num1) < 0) { |
| | | continue; |
| | | } |
| | | couponListVo.setUseCondition(""); |
| | |
| | | AppUser appUser = appClient.queryAppUser(uid); |
| | | if (null != appUser) { |
| | | List<UserCoupon> userCoupons = this.baseMapper.selectList(new QueryWrapper<UserCoupon>() |
| | | .eq("userId",appUser.getId() ) |
| | | .eq("userId", appUser.getId()) |
| | | .orderByDesc("insertTime")); |
| | | if (userCoupons.size() > 0){ |
| | | if (userCoupons.size() > 0) { |
| | | for (UserCoupon userCoupon : userCoupons) { |
| | | Coupon coupon = couponMapper.selectById(userCoupon.getCouponId()); |
| | | CouponPackageResp packageResp = new CouponPackageResp(); |
| | |
| | | packageResp.setName(coupon.getName()); |
| | | packageResp.setType(coupon.getType()); |
| | | packageResp.setUseCondition(coupon.getUseScope()); |
| | | switch (coupon.getUseScope()){ |
| | | switch (coupon.getUseScope()) { |
| | | case 1: |
| | | packageResp.setAvailable("全国通用"); |
| | | break; |
| | | case 2: |
| | | packageResp.setAvailable("指定城市可用"); |
| | | packageResp.setCityOrStore(""); |
| | | List<CouponCity> couponId = couponCityMapper.selectList(new QueryWrapper<CouponCity>().eq("couponId", coupon.getId())); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (CouponCity couponCity : couponId) { |
| | | stringBuilder.append(couponCity.getCity()); |
| | | } |
| | | packageResp.setCityOrStore(String.valueOf(stringBuilder)); |
| | | break; |
| | | case 3: |
| | | packageResp.setAvailable("指定门店可用"); |
| | | CouponStore couponStore = csMapper.selectOne(new QueryWrapper<CouponStore>() |
| | | .eq("couponId",coupon.getId())); |
| | | .eq("couponId", coupon.getId()).last("limit 1")); |
| | | StoreDetailOfCourse courseOfStore = storeClient.getCourseOfStore(couponStore.getStoreId()); |
| | | packageResp.setCityOrStore(courseOfStore.getStoreName()+","+courseOfStore.getStoreAddr()); |
| | | // packageResp.setCityOrStore(courseOfStore.getStoreName()+","+courseOfStore.getStoreAddr()); |
| | | packageResp.setCityOrStore(courseOfStore.getStoreName()); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | // 满减券 |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | Double num2 = jsonObject.getDouble("deductionAmount"); |
| | | ruleModel.setConditionalAmount("满"+num1+"可用"); |
| | | ruleModel.setDeductionAmount("¥ "+num2); |
| | | ruleModel.setConditionalAmount("满" + num1 + "可用"); |
| | | ruleModel.setDeductionAmount("¥ " + num2); |
| | | ruleModel.setExperienceName(""); |
| | | break; |
| | | case 2: |
| | | // 代金券 |
| | | Double jsonObjectDouble = jsonObject.getDouble("conditionalAmount"); |
| | | ruleModel.setConditionalAmount(""); |
| | | ruleModel.setDeductionAmount("¥ "+jsonObjectDouble); |
| | | ruleModel.setDeductionAmount("¥ " + jsonObjectDouble); |
| | | ruleModel.setExperienceName(""); |
| | | break; |
| | | case 3: |
| | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | packageResp.setEffectiveTime(simpleDateFormat.format(coupon.getEndTime())); |
| | | |
| | | if (userCoupon.getStatus() == 1){ |
| | | if (DateUtil.getDate().before(coupon.getEndTime())){ |
| | | if (userCoupon.getStatus() == 1) { |
| | | if (DateUtil.getDate().before(coupon.getEndTime())) { |
| | | packageResp.setUseStatus(1); |
| | | }else { |
| | | } else { |
| | | packageResp.setUseStatus(3); |
| | | } |
| | | } |
| | | if (userCoupon.getStatus() == 2){ |
| | | if (userCoupon.getStatus() == 2) { |
| | | packageResp.setUseStatus(2); |
| | | } |
| | | respList.add(packageResp); |
| | | } |
| | | if (null != req.getCouponType()){ |
| | | if (null != req.getCouponType()) { |
| | | respList = respList.stream() |
| | | .filter(couponPackageResp -> couponPackageResp.getType().equals(req.getCouponType())) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | if (null != req.getUseStatus()){ |
| | | if (null != req.getUseStatus()) { |
| | | respList = respList.stream() |
| | | .filter(couponPackageResp -> couponPackageResp.getUseStatus().equals(req.getUseStatus())) |
| | | .collect(Collectors.toList()); |