| | |
| | | } |
| | | try { |
| | | JSONObject content = JSON.parseObject(coupon.getContent()); |
| | | BigDecimal deductionAmount = content.getBigDecimal("deductionAmount"); |
| | | // 满减券使用 deductionAmount,代金券历史规则将抵扣额存放在 conditionalAmount。 |
| | | BigDecimal deductionAmount = Integer.valueOf(2).equals(coupon.getType()) |
| | | ? content.getBigDecimal("conditionalAmount") |
| | | : content.getBigDecimal("deductionAmount"); |
| | | return deductionAmount == null ? BigDecimal.ZERO : deductionAmount.max(BigDecimal.ZERO); |
| | | } catch (Exception e) { |
| | | LOGGER.warn("解析优惠券抵扣规则失败,couponId={}", coupon.getId(), e); |
| | |
| | | List<CouponListVo> listVos = new ArrayList<>(); |
| | | for (Map<String, Object> userCoupon : userCoupons) { |
| | | Integer type = Integer.valueOf(userCoupon.get("type").toString()); |
| | | // 支付减免只支持满减券和代金券;体验券/抵扣券不能用于订单金额计算。 |
| | | if (type != 1 && type != 2) { |
| | | continue; |
| | | } |
| | | CouponListVo couponListVo = new CouponListVo(); |
| | | couponListVo.setId(Long.valueOf(userCoupon.get("id").toString())); |
| | | couponListVo.setName(userCoupon.get("name").toString()); |
| | |
| | | @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(); |
| | | return queryStoreCouponList(uid, site.getStoreId(), price, lon, lat); |
| | | } |
| | | |
| | | @Override |
| | | public List<CouponListVo> queryStoreCouponList(Integer uid, Integer storeId, Double price, String lon, String lat) throws Exception { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(lon, lat); |
| | | String provinceCode = geocode.get("provinceCode"); |
| | | String cityCode = geocode.get("cityCode"); |
| | |
| | | List<CouponListVo> listVos = new ArrayList<>(); |
| | | for (Map<String, Object> userCoupon : userCoupons) { |
| | | Integer type = Integer.valueOf(userCoupon.get("type").toString()); |
| | | if (type != 1 && type != 2) { |
| | | continue; |
| | | } |
| | | CouponListVo couponListVo = new CouponListVo(); |
| | | couponListVo.setId(Long.valueOf(userCoupon.get("id").toString())); |
| | | couponListVo.setName(userCoupon.get("name").toString()); |