Merge branch 'test6.9.3' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.3
Showing
4 changed files
with
76 additions
and
8 deletions
1 | +package com.yohoufo.common.utils; | ||
2 | + | ||
3 | +import com.google.common.collect.Sets; | ||
4 | + | ||
5 | +import java.util.Set; | ||
6 | +import java.util.regex.Matcher; | ||
7 | +import java.util.regex.Pattern; | ||
8 | + | ||
9 | +/** | ||
10 | + * Created by li.ma on 2019/5/7. | ||
11 | + */ | ||
12 | +public class DomainCheckUtil { | ||
13 | + // 图片的域名只能是公司内部的域名 | ||
14 | + private static Set<String> YOHODOMAINLIST = Sets.newHashSet("yohobuy.com", "yoho.cn", "yhbimg.com", "yohoboys.com"); | ||
15 | + | ||
16 | + /** | ||
17 | + * 是否存在非法的域名 | ||
18 | + * @param imageUrl | ||
19 | + * @return true 存在 | ||
20 | + */ | ||
21 | + public static boolean existInvalidDomain(String imageUrl) { | ||
22 | + if (imageUrl.startsWith("//")) { | ||
23 | + return compareDomain(imageUrl.substring(2, imageUrl.indexOf('/', 2))); | ||
24 | + } | ||
25 | + | ||
26 | + String propertyStr = imageUrl.replace('\\', '/'); | ||
27 | + Pattern p = Pattern.compile("[http:|https:]//(.+?)[/|'|\"|\\s|>]", Pattern.CASE_INSENSITIVE); | ||
28 | + Matcher matcher = p.matcher(propertyStr); | ||
29 | + while (matcher.find()) { | ||
30 | + String domainStr = matcher.group(1); // 查询字符串中链接的域名 | ||
31 | + if (compareDomain(domainStr)) { | ||
32 | + return true; | ||
33 | + } | ||
34 | + } | ||
35 | + return false; | ||
36 | + } | ||
37 | + | ||
38 | + public static boolean compareDomain(String domain) { | ||
39 | + boolean result = true; | ||
40 | + for (String yohoDomainStr : YOHODOMAINLIST) { | ||
41 | + if (domain.endsWith(yohoDomainStr)) { // 如果域名并不是YOHO相关的域名,则剔除 | ||
42 | + result = false; | ||
43 | + } | ||
44 | + } | ||
45 | + return result; | ||
46 | + } | ||
47 | + | ||
48 | + public static void main(String[] args) { | ||
49 | + //System.out.println(queryInvalidDomain("//img01.yohoboys.com/license/1554113944689/Screenshot_20190401_173857_com.yoho.jpg")); | ||
50 | + System.out.println(existInvalidDomain("http://img01.yohoboys.com/license/1554113944689/Screenshot_20190401_173857_com.yoho.jpg")); | ||
51 | + } | ||
52 | +} |
@@ -160,7 +160,7 @@ public class BuyerOrderCancelService { | @@ -160,7 +160,7 @@ public class BuyerOrderCancelService { | ||
160 | inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode); | 160 | inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode); |
161 | }else { | 161 | }else { |
162 | inBoxFacade.buyerCancelBeforeSellerDeliver(buyerUid, orderCode, | 162 | inBoxFacade.buyerCancelBeforeSellerDeliver(buyerUid, orderCode, |
163 | - penaltyAmount.toPlainString(), psog); | 163 | + penaltyAmount.toPlainString(), psog,reSellAfterCancel); |
164 | } | 164 | } |
165 | //TODO 整个过程异步去执行(考虑退费依赖订单状态) | 165 | //TODO 整个过程异步去执行(考虑退费依赖订单状态) |
166 | //(退费)退保证金给卖家 | 166 | //(退费)退保证金给卖家 |
@@ -1505,7 +1505,7 @@ public class InBoxFacade { | @@ -1505,7 +1505,7 @@ public class InBoxFacade { | ||
1505 | } | 1505 | } |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | - public void buyerCancelBeforeSellerDeliver(int buyerUid, long orderCode,String compesant, SellerOrderGoods sog) { | 1508 | + public void buyerCancelBeforeSellerDeliver(int buyerUid, long orderCode,String compesant, SellerOrderGoods sog,boolean autoReSellFlag) { |
1509 | Integer sellerUid = sog.getUid(); | 1509 | Integer sellerUid = sog.getUid(); |
1510 | String prdName = sog.getProductName(); | 1510 | String prdName = sog.getProductName(); |
1511 | String sizeName = sog.getSizeName(); | 1511 | String sizeName = sog.getSizeName(); |
@@ -1522,6 +1522,9 @@ public class InBoxFacade { | @@ -1522,6 +1522,9 @@ public class InBoxFacade { | ||
1522 | Product product = productMapper.selectByPrimaryKey(sog.getProductId()); | 1522 | Product product = productMapper.selectByPrimaryKey(sog.getProductId()); |
1523 | String productCode = product.getProductCode(); | 1523 | String productCode = product.getProductCode(); |
1524 | InboxBusinessTypeEnum ibtOfSeller = InboxBusinessTypeEnum.SALE_CLOSED_BY_BUYER_AFTER_PAID; | 1524 | InboxBusinessTypeEnum ibtOfSeller = InboxBusinessTypeEnum.SALE_CLOSED_BY_BUYER_AFTER_PAID; |
1525 | + if(autoReSellFlag){ | ||
1526 | + ibtOfSeller = InboxBusinessTypeEnum.SALE_CLOSED_AUTO_RESELL_BY_BUYER_AFTER_PAID; | ||
1527 | + } | ||
1525 | String paramsOfSeller = buildParams(prdName, sizeName,productCode); | 1528 | String paramsOfSeller = buildParams(prdName, sizeName,productCode); |
1526 | InboxReqVO reqOfSeller = buildInboxReqVO(sellerUid, paramsOfSeller, ibtOfSeller); | 1529 | InboxReqVO reqOfSeller = buildInboxReqVO(sellerUid, paramsOfSeller, ibtOfSeller); |
1527 | InBoxResponse respOfSeller = inBoxSDK.addInbox(reqOfSeller); | 1530 | InBoxResponse respOfSeller = inBoxSDK.addInbox(reqOfSeller); |
@@ -1536,7 +1539,11 @@ public class InBoxFacade { | @@ -1536,7 +1539,11 @@ public class InBoxFacade { | ||
1536 | } | 1539 | } |
1537 | List<String> mobileList = Arrays.asList(phone); | 1540 | List<String> mobileList = Arrays.asList(phone); |
1538 | 1541 | ||
1539 | - String content= getReplacedContent(InboxBusinessTypeEnum.SMS_CANCELED_BY_BUYER_AFTER_PAID.getContent(),orderCode,prdName,sizeName,productCode); | 1542 | + InboxBusinessTypeEnum sms=InboxBusinessTypeEnum.SMS_CANCELED_BY_BUYER_AFTER_PAID; |
1543 | + if(autoReSellFlag){ | ||
1544 | + sms=InboxBusinessTypeEnum.SMS_CANCELED_AUTO_RESELL_BY_BUYER_AFTER_PAID; | ||
1545 | + } | ||
1546 | + String content= getReplacedContent(sms.getContent(),orderCode,prdName,sizeName,productCode); | ||
1540 | sendSmsService.smsSendByMobile(content,mobileList); | 1547 | sendSmsService.smsSendByMobile(content,mobileList); |
1541 | logger.info("record buyerCancelBeforeSellerDeliver inbox sms msg, sellerUid {}, orderCode {},prdName {} ,sizeName {} ,productCode {}", | 1548 | logger.info("record buyerCancelBeforeSellerDeliver inbox sms msg, sellerUid {}, orderCode {},prdName {} ,sizeName {} ,productCode {}", |
1542 | sellerUid, orderCode, prdName,sizeName,productCode); | 1549 | sellerUid, orderCode, prdName,sizeName,productCode); |
@@ -5,8 +5,14 @@ import java.text.ParseException; | @@ -5,8 +5,14 @@ import java.text.ParseException; | ||
5 | import java.text.SimpleDateFormat; | 5 | import java.text.SimpleDateFormat; |
6 | import java.util.Date; | 6 | import java.util.Date; |
7 | import java.util.List; | 7 | import java.util.List; |
8 | +import java.util.Set; | ||
9 | +import java.util.regex.Matcher; | ||
10 | +import java.util.regex.Pattern; | ||
8 | 11 | ||
12 | +import com.yohoufo.common.exception.GatewayException; | ||
13 | +import com.yohoufo.common.utils.DomainCheckUtil; | ||
9 | import org.apache.commons.lang3.StringUtils; | 14 | import org.apache.commons.lang3.StringUtils; |
15 | +import org.elasticsearch.common.collect.Sets; | ||
10 | import org.slf4j.Logger; | 16 | import org.slf4j.Logger; |
11 | import org.slf4j.LoggerFactory; | 17 | import org.slf4j.LoggerFactory; |
12 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -36,6 +42,8 @@ public class SelfShelvesServiceImpl implements SelfShelvesService { | @@ -36,6 +42,8 @@ public class SelfShelvesServiceImpl implements SelfShelvesService { | ||
36 | 42 | ||
37 | @Override | 43 | @Override |
38 | public int save(ProductSelfShelves pss, String price, String saleTime, List<String> imageList) { | 44 | public int save(ProductSelfShelves pss, String price, String saleTime, List<String> imageList) { |
45 | + checkImageDomain(imageList); | ||
46 | + | ||
39 | pss.setPrice(StringUtils.isEmpty(price) ? null : new BigDecimal(price)); | 47 | pss.setPrice(StringUtils.isEmpty(price) ? null : new BigDecimal(price)); |
40 | pss.setSaleTime(StringUtils.isEmpty(saleTime) ? null : (int)convertDateToLong(saleTime)); | 48 | pss.setSaleTime(StringUtils.isEmpty(saleTime) ? null : (int)convertDateToLong(saleTime)); |
41 | pss.setCreateTime(DateUtil.getCurrentTimeSecond()); | 49 | pss.setCreateTime(DateUtil.getCurrentTimeSecond()); |
@@ -53,10 +61,12 @@ public class SelfShelvesServiceImpl implements SelfShelvesService { | @@ -53,10 +61,12 @@ public class SelfShelvesServiceImpl implements SelfShelvesService { | ||
53 | return num; | 61 | return num; |
54 | } | 62 | } |
55 | 63 | ||
56 | - public static void main(String[] args){ | ||
57 | - String price = "123456.66"; | ||
58 | - BigDecimal bd=new BigDecimal(price); | ||
59 | - System.out.println(bd); | 64 | + private void checkImageDomain(List<String> imageList) { |
65 | + imageList.stream().forEach(item -> { | ||
66 | + if (DomainCheckUtil.existInvalidDomain(item)) { | ||
67 | + throw new UfoServiceException(500, "系统异常"); | ||
68 | + } | ||
69 | + }); | ||
60 | } | 70 | } |
61 | 71 | ||
62 | private long convertDateToLong(String date) { | 72 | private long convertDateToLong(String date) { |
@@ -72,5 +82,4 @@ public class SelfShelvesServiceImpl implements SelfShelvesService { | @@ -72,5 +82,4 @@ public class SelfShelvesServiceImpl implements SelfShelvesService { | ||
72 | } | 82 | } |
73 | return dateDate.getTime() / 1000; | 83 | return dateDate.getTime() / 1000; |
74 | } | 84 | } |
75 | - | ||
76 | } | 85 | } |
-
Please register or login to post a comment