Authored by qinchao

Merge branch 'test6.8.8' of http://git.yoho.cn/ufo/yohoufo-fore into test6.8.8

@@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl; @@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
  5 +import com.google.common.cache.Cache;
5 import com.yoho.core.config.ConfigReader; 6 import com.yoho.core.config.ConfigReader;
6 import com.yoho.core.dal.datasource.annotation.Database; 7 import com.yoho.core.dal.datasource.annotation.Database;
7 import com.yoho.error.ServiceError; 8 import com.yoho.error.ServiceError;
@@ -49,11 +50,13 @@ import com.yohoufo.order.utils.PaymentHelper; @@ -49,11 +50,13 @@ import com.yohoufo.order.utils.PaymentHelper;
49 import lombok.val; 50 import lombok.val;
50 import org.apache.commons.collections.CollectionUtils; 51 import org.apache.commons.collections.CollectionUtils;
51 import org.apache.commons.lang3.StringUtils; 52 import org.apache.commons.lang3.StringUtils;
  53 +import org.elasticsearch.common.cache.CacheBuilder;
52 import org.slf4j.Logger; 54 import org.slf4j.Logger;
53 import org.springframework.beans.factory.annotation.Autowired; 55 import org.springframework.beans.factory.annotation.Autowired;
54 import org.springframework.stereotype.Service; 56 import org.springframework.stereotype.Service;
55 57
56 import java.math.BigDecimal; 58 import java.math.BigDecimal;
  59 +import java.text.SimpleDateFormat;
57 import java.util.Date; 60 import java.util.Date;
58 import java.util.Map; 61 import java.util.Map;
59 import java.util.Objects; 62 import java.util.Objects;
@@ -1168,8 +1171,8 @@ public class PaymentServiceImpl implements IPaymentService { @@ -1168,8 +1171,8 @@ public class PaymentServiceImpl implements IPaymentService {
1168 // {"msg":"Business Failed","code":"40004","sub_msg":"单日最多可转100万元","sub_code":"EXCEED_LIMIT_DM_MAX_AMOUNT"} 1171 // {"msg":"Business Failed","code":"40004","sub_msg":"单日最多可转100万元","sub_code":"EXCEED_LIMIT_DM_MAX_AMOUNT"}
1169 if (StringUtils.equals("40004", jsonObject.getString("code")) 1172 if (StringUtils.equals("40004", jsonObject.getString("code"))
1170 && StringUtils.equals("EXCEED_LIMIT_DM_MAX_AMOUNT", jsonObject.getString("sub_code"))) { 1173 && StringUtils.equals("EXCEED_LIMIT_DM_MAX_AMOUNT", jsonObject.getString("sub_code"))) {
1171 - exceedMillion = true;  
1172 - logger.info("transferWhenExceedMillion 转账阿里接口返回 {},进入商家转账模式 exceedMillion={}", jsonObject, exceedMillion); 1174 + lastTransferDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
  1175 + logger.info("transferWhenExceedMillion 转账阿里接口返回 {},进入商家转账模式 lastTransferDate={}", jsonObject, lastTransferDate);
1173 return true; 1176 return true;
1174 } 1177 }
1175 return false; 1178 return false;
@@ -1178,10 +1181,15 @@ public class PaymentServiceImpl implements IPaymentService { @@ -1178,10 +1181,15 @@ public class PaymentServiceImpl implements IPaymentService {
1178 private boolean exceedMillion() { 1181 private boolean exceedMillion() {
1179 boolean zkValue = configReader.getBoolean("ufo.order.pay.exceedSwitch", false); 1182 boolean zkValue = configReader.getBoolean("ufo.order.pay.exceedSwitch", false);
1180 logger.info("transferWhenExceedMillion ufo.order.pay.exceedSwitch={}", zkValue); 1183 logger.info("transferWhenExceedMillion ufo.order.pay.exceedSwitch={}", zkValue);
1181 - return zkValue || exceedMillion; 1184 + if (zkValue) {
  1185 + return true;
  1186 + }
  1187 + String nowDate = new SimpleDateFormat("yyyyMMdd").format(new Date());
  1188 + return StringUtils.equals(lastTransferDate, nowDate);
1182 } 1189 }
1183 1190
1184 - private volatile boolean exceedMillion = false; 1191 + private volatile String lastTransferDate = null;
  1192 +
1185 @Autowired 1193 @Autowired
1186 private ConfigReader configReader; 1194 private ConfigReader configReader;
1187 1195
@@ -4,6 +4,7 @@ package com.yohoufo.order; @@ -4,6 +4,7 @@ package com.yohoufo.order;
4 import com.google.common.base.Splitter; 4 import com.google.common.base.Splitter;
5 import com.yohoufo.common.utils.RSAUtils; 5 import com.yohoufo.common.utils.RSAUtils;
6 import com.yohoufo.order.config.AlipayConfig; 6 import com.yohoufo.order.config.AlipayConfig;
  7 +import org.junit.Assert;
7 import org.junit.Test; 8 import org.junit.Test;
8 import org.junit.runner.RunWith; 9 import org.junit.runner.RunWith;
9 import org.junit.runners.BlockJUnit4ClassRunner; 10 import org.junit.runners.BlockJUnit4ClassRunner;
@@ -19,7 +20,7 @@ public class BaseTest { @@ -19,7 +20,7 @@ public class BaseTest {
19 String sign = "BEDIzBQ6n7fyb4uAxH4lQt/GI9aaEY1Pxhz5tTH6q18u3Sz3ERzlnOLv1mIeD5BrFPtjDFc0R4WlUJ0a4do2/1pHd6SBP7hD3U5olP2Dw+HjoFDzlKBAueiDqOgfPpyVtrks/oZ7n5bu4jh2+XVKfN3JkMyem++yoKqEN0kQywc="; 20 String sign = "BEDIzBQ6n7fyb4uAxH4lQt/GI9aaEY1Pxhz5tTH6q18u3Sz3ERzlnOLv1mIeD5BrFPtjDFc0R4WlUJ0a4do2/1pHd6SBP7hD3U5olP2Dw+HjoFDzlKBAueiDqOgfPpyVtrks/oZ7n5bu4jh2+XVKfN3JkMyem++yoKqEN0kQywc=";
20 String key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB"; 21 String key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB";
21 boolean res = RSAUtils.verify(preSignStr, sign, key, AlipayConfig.input_charset); 22 boolean res = RSAUtils.verify(preSignStr, sign, key, AlipayConfig.input_charset);
22 - System.out.println(res); 23 + Assert.assertTrue(res);
23 } 24 }
24 25
25 @Test 26 @Test