Authored by mali

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

@@ -15,22 +15,27 @@ import java.util.Map; @@ -15,22 +15,27 @@ import java.util.Map;
15 public enum TransferCase { 15 public enum TransferCase {
16 16
17 17
18 - APPRAISE_SUCCESS(1),  
19 - APPRAISE_FAIL(2),  
20 - SELLER_PLAY_BUYER(3),  
21 - DELIVER_TIME_OUT(4),  
22 - BUYER_CANCEL_BEFORE_SELLER_DELIVER(5),  
23 - BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6); 18 + APPRAISE_SUCCESS(1, "鉴定通过[货款->卖家]"),
  19 + APPRAISE_FAIL(2, "鉴定不通过[保证金->买家]"),
  20 + SELLER_PLAY_BUYER(3,"有买家时卖家不卖[保证金->买家]"),
  21 + DELIVER_TIME_OUT(4,"卖家超时发货[保证金->买家]"),
  22 + BUYER_CANCEL_BEFORE_SELLER_DELIVER(5,"卖家未发货时买家取消[部分货款->卖家]"),
  23 + BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6,"卖家已发货时买家取消[部分货款->卖家]");
24 24
25 private int code; 25 private int code;
  26 + private String info;
26 27
27 - TransferCase(int code) { 28 + TransferCase(int code, String info) {
28 this.code = code; 29 this.code = code;
  30 + this.info = info;
29 } 31 }
30 32
31 public int getCode() { 33 public int getCode() {
32 return code; 34 return code;
33 } 35 }
  36 + public String getInfo() {
  37 + return info;
  38 + }
34 39
35 40
36 private static Map<Integer, TransferCase> cache; 41 private static Map<Integer, TransferCase> cache;
@@ -624,11 +624,11 @@ public class PaymentServiceImpl implements IPaymentService { @@ -624,11 +624,11 @@ public class PaymentServiceImpl implements IPaymentService {
624 transfer.setAlipayAccount(account.getAlipayAccount()); 624 transfer.setAlipayAccount(account.getAlipayAccount());
625 } 625 }
626 String alipayAccount = transfer.getAlipayAccount(); 626 String alipayAccount = transfer.getAlipayAccount();
627 - 627 + JSONObject jsonObject = null;
628 // 转账 628 // 转账
629 try { 629 try {
630 logger.info("transferMon开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", buyerOrderCode, alipayAccount, transferAmount); 630 logger.info("transferMon开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", buyerOrderCode, alipayAccount, transferAmount);
631 - JSONObject jsonObject = alipayService.transferMoney(Long.toString(buyerOrderCode), account.getAlipayId(), account.getAlipayAccount(), transferAmount); 631 + jsonObject = alipayService.transferMoney(Long.toString(buyerOrderCode), account.getAlipayId(), account.getAlipayAccount(), transferAmount);
632 if (jsonObject == null) { 632 if (jsonObject == null) {
633 logger.warn("transferMonErr 转账失败 , orderCode is {}", buyerOrderCode); 633 logger.warn("transferMonErr 转账失败 , orderCode is {}", buyerOrderCode);
634 transfer.setStatus(3); 634 transfer.setStatus(3);
@@ -651,7 +651,12 @@ public class PaymentServiceImpl implements IPaymentService { @@ -651,7 +651,12 @@ public class PaymentServiceImpl implements IPaymentService {
651 } 651 }
652 } catch (Exception e) { 652 } catch (Exception e) {
653 logger.warn("transferMonErr 转账失败 , orderCode is {}, msg is {}", buyerOrderCode, e.getMessage()); 653 logger.warn("transferMonErr 转账失败 , orderCode is {}, msg is {}", buyerOrderCode, e.getMessage());
654 - alarm("转账失败", "ufo.order.transferMon", "订单号:" + buyerOrderCode + "操作类型(" + transferType + ")转账失败,msg=" + e.getMessage()); 654 + String alarmMsg = "订单号:" + buyerOrderCode + ",操作类型:" + transferCase.getInfo() + ",msg=" + e.getMessage();
  655 + if (jsonObject != null) {
  656 + alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
  657 + }
  658 + logger.info("transferMonErr 转账失败 , alarmMsg is {}", alarmMsg);
  659 + alarm("转账失败", "ufo.order.transferMon", alarmMsg);
655 transfer.setStatus(3); 660 transfer.setStatus(3);
656 if(e instanceof ServiceException) { 661 if(e instanceof ServiceException) {
657 throw new ServiceException(((ServiceException) e).getCode(), e.getMessage()); 662 throw new ServiceException(((ServiceException) e).getCode(), e.getMessage());
@@ -733,9 +738,10 @@ public class PaymentServiceImpl implements IPaymentService { @@ -733,9 +738,10 @@ public class PaymentServiceImpl implements IPaymentService {
733 logger.info("transAllEarnest参数检查成功!"); 738 logger.info("transAllEarnest参数检查成功!");
734 739
735 // 转账 740 // 转账
  741 + JSONObject jsonObject = null;
736 try { 742 try {
737 logger.info("transAllEarnest开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", orderCode, alipayAccount, amount); 743 logger.info("transAllEarnest开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", orderCode, alipayAccount, amount);
738 - JSONObject jsonObject = alipayService.transferMoney(Long.toString(orderCode), alipayId, alipayAccount, amount); 744 + jsonObject = alipayService.transferMoney(Long.toString(orderCode), alipayId, alipayAccount, amount);
739 if (jsonObject == null) { 745 if (jsonObject == null) {
740 logger.warn("transAllEarnestErr 转账失败 , orderCode is {}", orderCode); 746 logger.warn("transAllEarnestErr 转账失败 , orderCode is {}", orderCode);
741 transfer.setStatus(3); 747 transfer.setStatus(3);
@@ -759,7 +765,12 @@ public class PaymentServiceImpl implements IPaymentService { @@ -759,7 +765,12 @@ public class PaymentServiceImpl implements IPaymentService {
759 } 765 }
760 } catch (Exception e) { 766 } catch (Exception e) {
761 logger.warn("transAllEarnestErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage()); 767 logger.warn("transAllEarnestErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage());
762 - alarm("转账失败", "ufo.order.transAllEarnest", "订单号:" + orderCode + "操作类型(" + 6 + ")转账失败,msg=" + e.getMessage()); 768 + String alarmMsg = "订单号:" + orderCode + ",操作类型(商家退出入驻退保证金),msg=" + e.getMessage();
  769 + if (jsonObject != null) {
  770 + alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
  771 + }
  772 + logger.info("transAllEarnestErr 转账失败 , alarmMsg is {}", alarmMsg);
  773 + alarm("转账失败", "ufo.order.transAllEarnest", alarmMsg);
763 transfer.setStatus(3); 774 transfer.setStatus(3);
764 if(e instanceof ServiceException) { 775 if(e instanceof ServiceException) {
765 throw new ServiceException(((ServiceException) e).getCode(), e.getMessage()); 776 throw new ServiceException(((ServiceException) e).getCode(), e.getMessage());
@@ -925,12 +936,13 @@ public class PaymentServiceImpl implements IPaymentService { @@ -925,12 +936,13 @@ public class PaymentServiceImpl implements IPaymentService {
925 } 936 }
926 937
927 // '1:买家uid; 2:卖家uid','1:保证金;2:货款;3:补偿款', '1:用户收入; 2:用户支出' 938 // '1:买家uid; 2:卖家uid','1:保证金;2:货款;3:补偿款', '1:用户收入; 2:用户支出'
  939 + PayRefundBo refundBo = null;
928 try { 940 try {
929 if (/* 退货款 */((tradeBills.getUserType() == 1 && tradeBills.getTradeType() == 2 && tradeBills.getIncomeOutcome() == 1) 941 if (/* 退货款 */((tradeBills.getUserType() == 1 && tradeBills.getTradeType() == 2 && tradeBills.getIncomeOutcome() == 1)
930 /* 退保证金(普通用户) */ 942 /* 退保证金(普通用户) */
931 || (tradeBills.getUserType() == 2 && tradeBills.getTradeType() == 1 && tradeBills.getIncomeOutcome() == 1 && !isMerchantExit))) { 943 || (tradeBills.getUserType() == 2 && tradeBills.getTradeType() == 1 && tradeBills.getIncomeOutcome() == 1 && !isMerchantExit))) {
932 logger.warn("manualDeal人工退款 , tradeBills is {}", tradeBills); 944 logger.warn("manualDeal人工退款 , tradeBills is {}", tradeBills);
933 - PayRefundBo refundBo = manualRefund(orderCode, amount); 945 + refundBo = manualRefund(orderCode, amount);
934 if (refundBo.getRefundStatus() == RefundContant.PAYMENT_REFUND_RESULTCODE_SUCCESS) { 946 if (refundBo.getRefundStatus() == RefundContant.PAYMENT_REFUND_RESULTCODE_SUCCESS) {
935 // 加新流水 947 // 加新流水
936 tradeBills.setDealRelateId(tradeBills.getId()); 948 tradeBills.setDealRelateId(tradeBills.getId());
@@ -945,8 +957,12 @@ public class PaymentServiceImpl implements IPaymentService { @@ -945,8 +957,12 @@ public class PaymentServiceImpl implements IPaymentService {
945 } 957 }
946 } catch (Exception e) { 958 } catch (Exception e) {
947 logger.warn("manualDealErr 退款失败 , tradeBillsId is {}, msg is {}", tradeBillsId, e.getMessage()); 959 logger.warn("manualDealErr 退款失败 , tradeBillsId is {}, msg is {}", tradeBillsId, e.getMessage());
948 - alarm("人工处理退款失败", "ufo.order.manualDeal",  
949 - "订单号:" + orderCode + "操作类型(退款)转账失败,流水id=" + tradeBillsId + ",msg=" + e.getMessage()); 960 + String alarmMsg = "订单号:" + orderCode + ",操作类型(退款),流水id=" + tradeBillsId + ",msg=" + e.getMessage();
  961 + if (refundBo != null) {
  962 + alarmMsg += ",DETAIL=" + JSON.toJSONString(refundBo);
  963 + }
  964 + logger.info("manualDealErr 退款失败 , alarmMsg is {}", alarmMsg);
  965 + alarm("人工处理退款失败", "ufo.order.manualDeal", alarmMsg );
950 preSuccess.setDealStatus(0); 966 preSuccess.setDealStatus(0);
951 tradeBillsMapper.updateToFailByPrimaryKey(preSuccess); 967 tradeBillsMapper.updateToFailByPrimaryKey(preSuccess);
952 if (e instanceof ServiceException) { 968 if (e instanceof ServiceException) {
@@ -955,6 +971,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -955,6 +971,7 @@ public class PaymentServiceImpl implements IPaymentService {
955 throw new ServiceException(500, "退款失败id=" + tradeBillsId); 971 throw new ServiceException(500, "退款失败id=" + tradeBillsId);
956 } 972 }
957 } 973 }
  974 + JSONObject jsonObject = null;
958 try { 975 try {
959 OrdersPayTransfer transfer = ordersPayTransferMapper.selectByBuyerOrderCode(orderCode); 976 OrdersPayTransfer transfer = ordersPayTransferMapper.selectByBuyerOrderCode(orderCode);
960 if (transfer == null) { 977 if (transfer == null) {
@@ -964,7 +981,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -964,7 +981,7 @@ public class PaymentServiceImpl implements IPaymentService {
964 throw new ServiceException(400, "转账记录已成功转账,流水id=" + tradeBillsId); 981 throw new ServiceException(400, "转账记录已成功转账,流水id=" + tradeBillsId);
965 } 982 }
966 983
967 - JSONObject jsonObject = alipayService.transferMoney(Long.toString(orderCode), account.getAlipayId(), account.getAlipayAccount(), amount); 984 + jsonObject = alipayService.transferMoney(Long.toString(orderCode), account.getAlipayId(), account.getAlipayAccount(), amount);
968 if (jsonObject == null) { 985 if (jsonObject == null) {
969 logger.warn("manualDeal 转账失败 , req is {}", req); 986 logger.warn("manualDeal 转账失败 , req is {}", req);
970 throw new ServiceException(500, "转账失败:阿里接口返回null"); 987 throw new ServiceException(500, "转账失败:阿里接口返回null");
@@ -991,8 +1008,12 @@ public class PaymentServiceImpl implements IPaymentService { @@ -991,8 +1008,12 @@ public class PaymentServiceImpl implements IPaymentService {
991 } 1008 }
992 } catch (Exception e) { 1009 } catch (Exception e) {
993 logger.warn("manualDealErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage()); 1010 logger.warn("manualDealErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage());
994 - alarm("人工处理转账失败", "ufo.order.manualDeal",  
995 - "订单号:" + orderCode + "操作类型(退款)转账失败,流水id=" + tradeBillsId + ",msg=" + e.getMessage()); 1011 + String alarmMsg = "订单号:" + orderCode + ",操作类型(转账),流水id=" + tradeBillsId + ",msg=" + e.getMessage();
  1012 + if (jsonObject != null) {
  1013 + alarmMsg += ",阿里返回DETAIL=" + jsonObject.toJSONString();
  1014 + }
  1015 + logger.info("manualDealErr 转账失败 , alarmMsg is {}", alarmMsg);
  1016 + alarm("人工处理转账失败", "ufo.order.manualDeal", alarmMsg);
996 preSuccess.setDealStatus(0); 1017 preSuccess.setDealStatus(0);
997 tradeBillsMapper.updateToFailByPrimaryKey(preSuccess); 1018 tradeBillsMapper.updateToFailByPrimaryKey(preSuccess);
998 if (e instanceof ServiceException) { 1019 if (e instanceof ServiceException) {
@@ -138,11 +138,12 @@ public abstract class AlipayServiceAbstract extends AbstractPayService { @@ -138,11 +138,12 @@ public abstract class AlipayServiceAbstract extends AbstractPayService {
138 * @param alipayAccount 138 * @param alipayAccount
139 * @param transferAmount 139 * @param transferAmount
140 * @return 140 * @return
  141 + * @throws Exception
141 */ 142 */
142 - public JSONObject transferMoney(String transferOrderCode, String alipayUid, String alipayAccount, BigDecimal transferAmount){ 143 + public JSONObject transferMoney(String transferOrderCode, String alipayUid, String alipayAccount, BigDecimal transferAmount) throws Exception{
143 144
144 Map<String, String> queryParams = buildTransferParams(transferOrderCode, alipayUid, alipayAccount, transferAmount); 145 Map<String, String> queryParams = buildTransferParams(transferOrderCode, alipayUid, alipayAccount, transferAmount);
145 - String respTxt = sendOpenApiRequest(transferOrderCode, queryParams); 146 + String respTxt = sendOpenApiRequestWithException(transferOrderCode, queryParams);
146 147
147 JSONObject result = null; 148 JSONObject result = null;
148 149
@@ -173,6 +174,13 @@ public abstract class AlipayServiceAbstract extends AbstractPayService { @@ -173,6 +174,13 @@ public abstract class AlipayServiceAbstract extends AbstractPayService {
173 logger.info("[{}] trade openapi resp: {}", orderCode, response); 174 logger.info("[{}] trade openapi resp: {}", orderCode, response);
174 return response; 175 return response;
175 } 176 }
  177 +
  178 + private String sendOpenApiRequestWithException(String orderCode, Map<String, String> paramMap) throws Exception {
  179 + logger.info("[{}] send openapi request: {}", orderCode, paramMap);
  180 + String response = httpClient.postFormData(AlipayConfig.OPENAPI_URL, paramMap);
  181 + logger.info("[{}] trade openapi resp: {}", orderCode, response);
  182 + return response;
  183 + }
176 184
177 185
178 private PayQueryBo queryOpenApiConvert(String orderCode, String respText) { 186 private PayQueryBo queryOpenApiConvert(String orderCode, String respText) {
@@ -364,6 +364,11 @@ public class ProductController { @@ -364,6 +364,11 @@ public class ProductController {
364 cacheAop.clearCache( 364 cacheAop.clearCache(
365 ProductController.class.getMethod("queryStorageInfo", new Class[] { Integer.class }), 365 ProductController.class.getMethod("queryStorageInfo", new Class[] { Integer.class }),
366 new Object[] { storageId }); 366 new Object[] { storageId });
  367 +
  368 + LOG.info("clearCache queryStorageSuggestPrice storageId = {}, ", storageId);
  369 + cacheAop.clearCache(
  370 + ProductController.class.getMethod("queryStorageSuggestPrice", new Class[] { Collection.class }),
  371 + new Object[] { storageId });
367 } 372 }
368 } 373 }
369 } catch (Exception e) { 374 } catch (Exception e) {
@@ -230,7 +230,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -230,7 +230,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
230 } 230 }
231 result = productChainMapper.selectByTagId(tagId); 231 result = productChainMapper.selectByTagId(tagId);
232 if(result != null){ 232 if(result != null){
233 - clientCache.set(kb.getKey(), 10 * 60 , result );//10分钟 233 + clientCache.setEx(kb, result,10 * 60 );//10分钟
234 } 234 }
235 logger.info("queryTransactionIdByTagId from db success! tagId={},result={}", tagId,result); 235 logger.info("queryTransactionIdByTagId from db success! tagId={},result={}", tagId,result);
236 return result; 236 return result;
@@ -281,15 +281,14 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -281,15 +281,14 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
281 RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyRelation:").appendVar(authUid); 281 RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyRelation:").appendVar(authUid);
282 IdentifyRelation result = clientCache.get(kb, IdentifyRelation.class); 282 IdentifyRelation result = clientCache.get(kb, IdentifyRelation.class);
283 if( result != null){ 283 if( result != null){
284 - logger.info("queryIdentifyRelation from cache success! authUid={}", authUid); 284 + logger.info("queryIdentifyRelation from cache success! authUid={}, result={}", authUid, result);
285 return result; 285 return result;
286 } 286 }
287 -  
288 result = identifyRelationMapper.selectByauthUid(authUid); 287 result = identifyRelationMapper.selectByauthUid(authUid);
289 -  
290 if(result != null){ 288 if(result != null){
291 - clientCache.set(kb.getKey(), 2 * 60 * 60, result );//两小时 289 + clientCache.setEx(kb, result, 2 * 60 * 60 );//两小时
292 } 290 }
  291 + logger.info("queryIdentifyRelation from db success! authUid={}, result={}", authUid, result);
293 return result; 292 return result;
294 } 293 }
295 294
@@ -299,13 +298,14 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -299,13 +298,14 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
299 appendVar(tagId).appendVar(":").appendVar(nfcUid); 298 appendVar(tagId).appendVar(":").appendVar(nfcUid);
300 IdentifyRecord result = clientCache.get(kb, IdentifyRecord.class); 299 IdentifyRecord result = clientCache.get(kb, IdentifyRecord.class);
301 if( result != null){ 300 if( result != null){
302 - logger.info("queryIdentifyRecord from cache success! tagId={},nfcUid={} ",tagId, nfcUid ); 301 + logger.info("queryIdentifyRecord from cache success! tagId={},nfcUid={},result={} ",tagId, nfcUid,result );
303 return result; 302 return result;
304 } 303 }
305 result = identifyRecordsMapper.selectByTagAndNfcId(tagId, nfcUid); 304 result = identifyRecordsMapper.selectByTagAndNfcId(tagId, nfcUid);
306 if(result != null){ 305 if(result != null){
307 - clientCache.set(kb.getKey(), 5 * 60, result ); 306 + clientCache.setEx(kb, result, 5 * 60 );
308 } 307 }
  308 + logger.info("queryIdentifyRecord from db success! tagId={},nfcUid={},result={} ",tagId, nfcUid,result );
309 return result; 309 return result;
310 } 310 }
311 311
@@ -319,13 +319,13 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{ @@ -319,13 +319,13 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
319 319
320 RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:"). 320 RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:").
321 appendVar(tagId).appendVar(":").appendVar(nfcUid); 321 appendVar(tagId).appendVar(":").appendVar(nfcUid);
322 - clientCache.set(kb.getKey(), 5 * 60, result ); 322 + clientCache.setEx(kb, result,5 * 60 );
323 } 323 }
324 324
325 private ProductIdentifyResp getIdentifyFromCache(String tagId, String nfcUid) { 325 private ProductIdentifyResp getIdentifyFromCache(String tagId, String nfcUid) {
326 RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:"). 326 RedisKeyBuilder kb = new RedisKeyBuilder().appendFixed("ufo:product:identifyResultInfo:").
327 appendVar(tagId).appendVar(":").appendVar(nfcUid); 327 appendVar(tagId).appendVar(":").appendVar(nfcUid);
328 - ProductIdentifyResp identifyResp = clientCache.get(kb.getKey(), ProductIdentifyResp.class); 328 + ProductIdentifyResp identifyResp = clientCache.get(kb, ProductIdentifyResp.class);
329 return identifyResp; 329 return identifyResp;
330 } 330 }
331 331