| | |
| | | import com.dsh.activity.feignclient.account.model.AppUser; |
| | | import com.dsh.activity.feignclient.course.CoursePackageClient; |
| | | import com.dsh.activity.feignclient.course.model.CoursePackage; |
| | | import com.dsh.activity.feignclient.other.SiteClient; |
| | | 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.CouponMapper; |
| | | import com.dsh.activity.mapper.CouponStoreMapper; |
| | |
| | | @Resource |
| | | private CouponStoreMapper csMapper; |
| | | |
| | | @Resource |
| | | private SiteClient siteClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取购买课程可用优惠券列表 |
| | | * @param uid |
| | |
| | | continue; |
| | | } |
| | | couponListVo.setUseCondition("满" + num1 + "元可用"); |
| | | couponListVo.setFavorable(jsonObject.getDouble("deductionAmount") + "元"); |
| | | 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; |
| | | } |
| | | if(price.compareTo(num1) <= 0){ |
| | | continue; |
| | | } |
| | | couponListVo.setUseCondition(""); |
| | | couponListVo.setFavorable(num1 + "元"); |
| | | couponListVo.setFavorable(num1 + ""); |
| | | } |
| | | if (type == 3) {//体验券{"num1":1} |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | couponListVo.setUseCondition(""); |
| | | couponListVo.setFavorable(jsonObject.getString("experienceName")); |
| | | } |
| | | listVos.add(couponListVo); |
| | | } |
| | | return listVos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取预约场地可用优惠券列表 |
| | | * @param siteId |
| | | * @param price |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<CouponListVo> querySiteCouponList(Integer uid, Integer siteId, Double price, String lon, String lat) throws Exception { |
| | | Site site = siteClient.querySiteById(siteId); |
| | | Integer storeId = site.getStoreId(); |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(lon, lat); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String cityCode = geocode.get("cityCode"); |
| | | List<Map<String, Object>> userCoupons = this.baseMapper.queryAvailableCouponList(uid, storeId, provinceCode, cityCode); |
| | | List<CouponListVo> listVos = new ArrayList<>(); |
| | | for (Map<String, Object> userCoupon : userCoupons) { |
| | | Integer type = Integer.valueOf(userCoupon.get("type").toString()); |
| | | CouponListVo couponListVo = new CouponListVo(); |
| | | couponListVo.setId(Long.valueOf(userCoupon.get("id").toString())); |
| | | couponListVo.setName(userCoupon.get("name").toString()); |
| | | couponListVo.setType(type); |
| | | couponListVo.setEffectiveTime(userCoupon.get("endTime").toString()); |
| | | String content = userCoupon.get("content").toString(); |
| | | if (type == 1) {//满减{"num1":1,"num2":1} |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | if(price.compareTo(num1) <= 0){ |
| | | continue; |
| | | } |
| | | 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; |
| | | } |
| | | if(price.compareTo(num1) <= 0){ |
| | | continue; |
| | | } |
| | | couponListVo.setUseCondition(""); |
| | | couponListVo.setFavorable(num1 + ""); |
| | | } |
| | | if (type == 3) {//体验券{"num1":1} |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | switch (coupon.getType()) { |
| | | case 1: |
| | | // {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} |
| | | // 满减券 |
| | | Double num1 = jsonObject.getDouble("num1"); |
| | | Double num2 = jsonObject.getDouble("num2"); |
| | | Double num1 = jsonObject.getDouble("conditionalAmount"); |
| | | Double num2 = jsonObject.getDouble("deductionAmount"); |
| | | ruleModel.setConditionalAmount("满"+num1+"可用"); |
| | | ruleModel.setDeductionAmount("¥ "+num2); |
| | | ruleModel.setExperienceName(""); |
| | | break; |
| | | case 2: |
| | | // 代金券 |
| | | Double jsonObjectDouble = jsonObject.getDouble("num1"); |
| | | Double jsonObjectDouble = jsonObject.getDouble("conditionalAmount"); |
| | | ruleModel.setConditionalAmount(""); |
| | | ruleModel.setDeductionAmount("¥ "+jsonObjectDouble); |
| | | ruleModel.setExperienceName(""); |
| | |
| | | // 体验券 |
| | | ruleModel.setConditionalAmount(""); |
| | | ruleModel.setDeductionAmount(""); |
| | | ruleModel.setExperienceName(jsonObject.getString("num1")); |
| | | ruleModel.setExperienceName(jsonObject.getString("experienceName")); |
| | | break; |
| | | default: |
| | | break; |