Showing
6 changed files
with
138 additions
and
29 deletions
@@ -41,6 +41,16 @@ public class Coupon { | @@ -41,6 +41,16 @@ public class Coupon { | ||
41 | 41 | ||
42 | private String skupForbidType; | 42 | private String skupForbidType; |
43 | 43 | ||
44 | + private String skupAllowType; | ||
45 | + | ||
46 | + public String getSkupAllowType() { | ||
47 | + return skupAllowType; | ||
48 | + } | ||
49 | + | ||
50 | + public void setSkupAllowType(String skupAllowType) { | ||
51 | + this.skupAllowType = skupAllowType; | ||
52 | + } | ||
53 | + | ||
44 | public String getSkupForbidType() { | 54 | public String getSkupForbidType() { |
45 | return skupForbidType; | 55 | return skupForbidType; |
46 | } | 56 | } |
@@ -21,11 +21,12 @@ | @@ -21,11 +21,12 @@ | ||
21 | <result column="pid" jdbcType="INTEGER" property="pid" /> | 21 | <result column="pid" jdbcType="INTEGER" property="pid" /> |
22 | <result column="remark" jdbcType="VARCHAR" property="remark" /> | 22 | <result column="remark" jdbcType="VARCHAR" property="remark" /> |
23 | <result column="skup_forbid_type" jdbcType="VARCHAR" property="skupForbidType" /> | 23 | <result column="skup_forbid_type" jdbcType="VARCHAR" property="skupForbidType" /> |
24 | + <result column="skup_allow_type" jdbcType="VARCHAR" property="skupAllowType" /> | ||
24 | </resultMap> | 25 | </resultMap> |
25 | <sql id="Base_Column_List"> | 26 | <sql id="Base_Column_List"> |
26 | id, coupon_token, coupon_name, coupon_amount, coupon_type, coupon_num, use_num, send_num, | 27 | id, coupon_token, coupon_name, coupon_amount, coupon_type, coupon_num, use_num, send_num, |
27 | - use_limit_type, use_limit_value, product_limit_type, product_limit_value, start_time, | ||
28 | - end_time, status, create_time, pid, remark,skup_forbid_type | 28 | + use_limit_type, use_limit_value, product_limit_type, product_limit_value, start_time, |
29 | + end_time, status, create_time, pid, remark,skup_forbid_type,skup_allow_type | ||
29 | </sql> | 30 | </sql> |
30 | <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> | 31 | <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> |
31 | select | 32 | select |
1 | package com.yohoufo.order.charge; | 1 | package com.yohoufo.order.charge; |
2 | 2 | ||
3 | import com.google.common.collect.Lists; | 3 | import com.google.common.collect.Lists; |
4 | +import com.yohobuy.ufo.model.order.constants.OrderConstant; | ||
4 | import com.yohobuy.ufo.model.order.constants.RegionEnum; | 5 | import com.yohobuy.ufo.model.order.constants.RegionEnum; |
5 | import com.yohobuy.ufo.model.promotion.UserCouponsBo; | 6 | import com.yohobuy.ufo.model.promotion.UserCouponsBo; |
6 | import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum; | 7 | import com.yohobuy.ufo.model.promotion.constant.CouponProductLimitTypeEnum; |
@@ -9,7 +10,9 @@ import com.yohobuy.ufo.model.promotion.constant.CouponUseLimitTypeEnum; | @@ -9,7 +10,9 @@ import com.yohobuy.ufo.model.promotion.constant.CouponUseLimitTypeEnum; | ||
9 | import com.yohoufo.order.charge.model.ChargeGoods; | 10 | import com.yohoufo.order.charge.model.ChargeGoods; |
10 | import com.yohoufo.order.charge.model.CouponMatchResult; | 11 | import com.yohoufo.order.charge.model.CouponMatchResult; |
11 | import com.yohoufo.order.utils.LoggerUtils; | 12 | import com.yohoufo.order.utils.LoggerUtils; |
13 | +import com.yohoufo.order.utils.SellerGoodsHelper; | ||
12 | import org.apache.commons.collections.CollectionUtils; | 14 | import org.apache.commons.collections.CollectionUtils; |
15 | +import org.apache.commons.lang3.StringUtils; | ||
13 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
14 | import org.springframework.stereotype.Component; | 17 | import org.springframework.stereotype.Component; |
15 | 18 | ||
@@ -17,6 +20,7 @@ import java.math.BigDecimal; | @@ -17,6 +20,7 @@ import java.math.BigDecimal; | ||
17 | import java.util.Arrays; | 20 | import java.util.Arrays; |
18 | import java.util.LinkedList; | 21 | import java.util.LinkedList; |
19 | import java.util.List; | 22 | import java.util.List; |
23 | +import java.util.stream.Collectors; | ||
20 | 24 | ||
21 | /** | 25 | /** |
22 | * Created by jiexiang.wu on 2018/11/19. | 26 | * Created by jiexiang.wu on 2018/11/19. |
@@ -37,7 +41,7 @@ public class CouponRuleMatcher { | @@ -37,7 +41,7 @@ public class CouponRuleMatcher { | ||
37 | RULE_MATCHERS.add(new UseLimitRuleMatcher()); | 41 | RULE_MATCHERS.add(new UseLimitRuleMatcher()); |
38 | 42 | ||
39 | // skup类型匹配 | 43 | // skup类型匹配 |
40 | - RULE_MATCHERS.add(new SkupForbidRuleMatcher()); | 44 | +// RULE_MATCHERS.add(new SkupForbidRuleMatcher()); |
41 | 45 | ||
42 | // 按商品区域匹配 | 46 | // 按商品区域匹配 |
43 | RULE_MATCHERS.add(new SkupRegionRuleMatcher()); | 47 | RULE_MATCHERS.add(new SkupRegionRuleMatcher()); |
@@ -150,24 +154,63 @@ public class CouponRuleMatcher { | @@ -150,24 +154,63 @@ public class CouponRuleMatcher { | ||
150 | } | 154 | } |
151 | } | 155 | } |
152 | 156 | ||
153 | - private static class SkupForbidRuleMatcher implements IRuleMatcher { | 157 | + // 6.9.10之后 从[禁用] 改成 [可用] |
158 | +// private static class SkupForbidRuleMatcher implements IRuleMatcher { | ||
159 | +// @Override | ||
160 | +// public String ruleName() { | ||
161 | +// return "SkupForbid"; | ||
162 | +// } | ||
163 | +// | ||
164 | +// @Override | ||
165 | +// public boolean match(ChargeGoods chargeGoods, UserCouponsBo couponsBo) { | ||
166 | +// | ||
167 | +// if (couponsBo.getSkupForbidType() == null){ | ||
168 | +// return true; | ||
169 | +// } | ||
170 | +// | ||
171 | +// if (Arrays.asList(couponsBo.getSkupForbidType().split(",")).contains(String.valueOf(chargeGoods.getAttributes()))){ | ||
172 | +// return false; | ||
173 | +// } | ||
174 | +// | ||
175 | +// return true; | ||
176 | +// } | ||
177 | +// } | ||
178 | + | ||
179 | + | ||
180 | + private static class SkupAllowRuleMatcher implements IRuleMatcher{ | ||
181 | + | ||
154 | @Override | 182 | @Override |
155 | public String ruleName() { | 183 | public String ruleName() { |
156 | - return "SkupForbid"; | 184 | + return "SkupAllow"; |
157 | } | 185 | } |
158 | 186 | ||
159 | @Override | 187 | @Override |
160 | public boolean match(ChargeGoods chargeGoods, UserCouponsBo couponsBo) { | 188 | public boolean match(ChargeGoods chargeGoods, UserCouponsBo couponsBo) { |
161 | 189 | ||
162 | - if (couponsBo.getSkupForbidType() == null){ | 190 | + |
191 | + if (StringUtils.isEmpty(couponsBo.getSkupAllowType())){ | ||
163 | return true; | 192 | return true; |
164 | } | 193 | } |
165 | 194 | ||
166 | - if (Arrays.asList(couponsBo.getSkupForbidType().split(",")).contains(String.valueOf(chargeGoods.getAttributes()))){ | ||
167 | - return false; | 195 | + // 该优惠券允许的skup属性 |
196 | + if (Arrays.asList(couponsBo.getSkupAllowType().split(",")).contains(String.valueOf(chargeGoods.getAttributes()))){ | ||
197 | + return true; | ||
168 | } | 198 | } |
169 | 199 | ||
170 | - return true; | 200 | + // 特殊处理 |
201 | + // 现货: 现货发货1-N & 现货寄存1-Y | ||
202 | + // 闪购: 闪购发货3-N & 闪购寄存3-Y | ||
203 | + String depositRequirement = chargeGoods.isDepositRequirement()? OrderConstant.Y_STR: OrderConstant.N_STR; | ||
204 | + | ||
205 | + List<String> specialAttributeList = Arrays.stream(couponsBo.getSkupAllowType().split(",")).filter(x->x.contains(OrderConstant.SPLIT_STR)).collect(Collectors.toList()); | ||
206 | + for (String specialAttribute : specialAttributeList){ | ||
207 | + String[] items = specialAttribute.split(OrderConstant.SPLIT_STR); | ||
208 | + if (items[0].equalsIgnoreCase(String.valueOf(chargeGoods.getAttributes())) && depositRequirement.equalsIgnoreCase(items[1])){ | ||
209 | + return true; | ||
210 | + } | ||
211 | + } | ||
212 | + | ||
213 | + return false; | ||
171 | } | 214 | } |
172 | } | 215 | } |
173 | 216 |
1 | +package com.yohoufo.order; | ||
2 | + | ||
3 | +import com.google.common.collect.Lists; | ||
4 | +import com.google.common.collect.Sets; | ||
5 | +import com.yohoufo.common.utils.RandomUtil; | ||
6 | +import com.yohoufo.common.utils.StringSimilarity; | ||
7 | +import org.apache.commons.io.FileUtils; | ||
8 | + | ||
9 | +import java.io.IOException; | ||
10 | +import java.util.Arrays; | ||
11 | +import java.util.HashSet; | ||
12 | +import java.util.List; | ||
13 | +import java.util.stream.Collectors; | ||
14 | + | ||
15 | +public class ForbidToAllowTest { | ||
16 | + | ||
17 | + | ||
18 | + final static String SQL_CONTANT = "update ufo_promotion.coupon set skup_allow_type='$skup_allow_type' where skup_forbid_type='$skup_forbid_type';"; | ||
19 | + | ||
20 | + public static void main(String[] args) throws IOException { | ||
21 | + | ||
22 | + | ||
23 | +// String str1 = "望京东园523号楼融科望京中心写字楼A座1208-"; | ||
24 | +// String str = "望京东园$$523号楼融科望&&京中心写字楼A座1208-15010019250"; | ||
25 | +// System.out.println(StringSimilarity.getSimilarityRatio(str1, str)); | ||
26 | + | ||
27 | + | ||
28 | + List<String> orderAttributes = Lists.newArrayList(); | ||
29 | + orderAttributes.add("1"); | ||
30 | + orderAttributes.add("2"); | ||
31 | + orderAttributes.add("3"); | ||
32 | + orderAttributes.add("4"); | ||
33 | + orderAttributes.add("5"); | ||
34 | + orderAttributes.add("6"); | ||
35 | + orderAttributes.add("7"); | ||
36 | + orderAttributes.add("17"); | ||
37 | + | ||
38 | + List<String> forbidAttrs = FileUtils.readLines(new java.io.File("/Users/tanling/tempnodes/attribute.txt")); | ||
39 | + | ||
40 | + | ||
41 | + List<String> sql = Lists.newArrayList(); | ||
42 | + | ||
43 | + for (String forbidAttr : forbidAttrs){ | ||
44 | + String[] forbidAttrItem = forbidAttr.split(","); | ||
45 | + | ||
46 | + List<String> allowAttribute = Lists.newCopyOnWriteArrayList(orderAttributes); | ||
47 | + allowAttribute.removeAll(Arrays.stream(forbidAttrItem).collect(Collectors.toList())); | ||
48 | + | ||
49 | + if (allowAttribute.contains("1")){ | ||
50 | + allowAttribute.remove("1"); | ||
51 | + allowAttribute.add("1-N"); | ||
52 | + allowAttribute.add("1-Y"); | ||
53 | + } | ||
54 | + | ||
55 | + if (allowAttribute.contains("3")){ | ||
56 | + allowAttribute.remove("3"); | ||
57 | + allowAttribute.add("3-N"); | ||
58 | + allowAttribute.add("3-Y"); | ||
59 | + } | ||
60 | + | ||
61 | +// System.out.println(forbidAttr + " " + allowAttribute); | ||
62 | + | ||
63 | + sql.add(SQL_CONTANT.replace("$skup_allow_type", allowAttribute.stream().collect(Collectors.joining(","))).replace("$skup_forbid_type", forbidAttr)); | ||
64 | + | ||
65 | + } | ||
66 | + | ||
67 | + sql.stream().forEach(x-> System.out.println(x)); | ||
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | ||
73 | + } | ||
74 | +} |
1 | -package com.yohoufo.order; | ||
2 | - | ||
3 | -import com.google.common.collect.Sets; | ||
4 | -import com.yohoufo.common.utils.RandomUtil; | ||
5 | -import com.yohoufo.common.utils.StringSimilarity; | ||
6 | - | ||
7 | -import java.util.HashSet; | ||
8 | - | ||
9 | -public class TestRandom { | ||
10 | - | ||
11 | - | ||
12 | - public static void main(String[] args){ | ||
13 | - | ||
14 | - | ||
15 | - String str1 = "望京东园523号楼融科望京中心写字楼A座1208-"; | ||
16 | - String str = "望京东园$$523号楼融科望&&京中心写字楼A座1208-15010019250"; | ||
17 | - System.out.println(StringSimilarity.getSimilarityRatio(str1, str)); | ||
18 | - | ||
19 | - } | ||
20 | -} |
@@ -44,6 +44,7 @@ public class CouponConvert { | @@ -44,6 +44,7 @@ public class CouponConvert { | ||
44 | couponBo.setStatus(userCoupon.getStatus()); | 44 | couponBo.setStatus(userCoupon.getStatus()); |
45 | 45 | ||
46 | couponBo.setSkupForbidType(coupon.getSkupForbidType()); | 46 | couponBo.setSkupForbidType(coupon.getSkupForbidType()); |
47 | + couponBo.setSkupAllowType(coupon.getSkupAllowType()); | ||
47 | 48 | ||
48 | // use_limit_type use_limit_value 满多少元可用 | 49 | // use_limit_type use_limit_value 满多少元可用 |
49 | if (coupon.getUseLimitType()!=null && CouponUseLimitTypeEnum.AMOUNT_LIMIT.getLimitType().equals(String.valueOf(coupon.getUseLimitType()))){ | 50 | if (coupon.getUseLimitType()!=null && CouponUseLimitTypeEnum.AMOUNT_LIMIT.getLimitType().equals(String.valueOf(coupon.getUseLimitType()))){ |
-
Please register or login to post a comment