Authored by mali

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

@@ -26,6 +26,8 @@ public class OrdersPayTransfer { @@ -26,6 +26,8 @@ public class OrdersPayTransfer {
26 private Integer updateTime; 26 private Integer updateTime;
27 27
28 private String alipayTradeResult; 28 private String alipayTradeResult;
  29 +
  30 + private Integer interfaceType;
29 31
30 public Integer getId() { 32 public Integer getId() {
31 return id; 33 return id;
@@ -122,4 +124,13 @@ public class OrdersPayTransfer { @@ -122,4 +124,13 @@ public class OrdersPayTransfer {
122 public void setAlipayTradeResult(String alipayTradeResult) { 124 public void setAlipayTradeResult(String alipayTradeResult) {
123 this.alipayTradeResult = alipayTradeResult == null ? null : alipayTradeResult.trim(); 125 this.alipayTradeResult = alipayTradeResult == null ? null : alipayTradeResult.trim();
124 } 126 }
  127 +
  128 + public Integer getInterfaceType() {
  129 + return interfaceType;
  130 + }
  131 +
  132 + public void setInterfaceType(Integer interfaceType) {
  133 + this.interfaceType = interfaceType;
  134 + }
  135 +
125 } 136 }
@@ -13,13 +13,14 @@ @@ -13,13 +13,14 @@
13 <result column="status" property="status" jdbcType="INTEGER" /> 13 <result column="status" property="status" jdbcType="INTEGER" />
14 <result column="create_time" property="createTime" jdbcType="INTEGER" /> 14 <result column="create_time" property="createTime" jdbcType="INTEGER" />
15 <result column="update_time" property="updateTime" jdbcType="INTEGER" /> 15 <result column="update_time" property="updateTime" jdbcType="INTEGER" />
  16 + <result column="interface_type" property="interfaceType" jdbcType="INTEGER" />
16 </resultMap> 17 </resultMap>
17 <resultMap id="ResultMapWithBLOBs" type="com.yohoufo.dal.order.model.OrdersPayTransfer" extends="BaseResultMap" > 18 <resultMap id="ResultMapWithBLOBs" type="com.yohoufo.dal.order.model.OrdersPayTransfer" extends="BaseResultMap" >
18 <result column="alipay_trade_result" property="alipayTradeResult" jdbcType="LONGVARCHAR" /> 19 <result column="alipay_trade_result" property="alipayTradeResult" jdbcType="LONGVARCHAR" />
19 </resultMap> 20 </resultMap>
20 <sql id="Base_Column_List" > 21 <sql id="Base_Column_List" >
21 id, buyer_order_code, seller_order_code, alipay_trade_id, transfer_type, uid, alipay_account, 22 id, buyer_order_code, seller_order_code, alipay_trade_id, transfer_type, uid, alipay_account,
22 - amount, status, create_time, update_time 23 + amount, status, create_time, update_time,interface_type
23 </sql> 24 </sql>
24 <sql id="Blob_Column_List" > 25 <sql id="Blob_Column_List" >
25 alipay_trade_result 26 alipay_trade_result
@@ -169,6 +170,9 @@ @@ -169,6 +170,9 @@
169 <if test="alipayTradeResult != null" > 170 <if test="alipayTradeResult != null" >
170 alipay_trade_result = #{alipayTradeResult,jdbcType=LONGVARCHAR}, 171 alipay_trade_result = #{alipayTradeResult,jdbcType=LONGVARCHAR},
171 </if> 172 </if>
  173 + <if test="interfaceType != null" >
  174 + interface_type = #{interfaceType,jdbcType=INTEGER},
  175 + </if>
172 </set> 176 </set>
173 where id = #{id,jdbcType=INTEGER} 177 where id = #{id,jdbcType=INTEGER}
174 </update> 178 </update>
@@ -689,6 +689,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -689,6 +689,7 @@ public class PaymentServiceImpl implements IPaymentService {
689 logger.info("transferMon开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", buyerOrderCode, alipayAccount, transferAmount); 689 logger.info("transferMon开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", buyerOrderCode, alipayAccount, transferAmount);
690 690
691 if(exceedMillion()) { 691 if(exceedMillion()) {
  692 + transfer.setTransferType(2);
692 Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), record, buyerOrderCode, account, transferAmount, now); 693 Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), record, buyerOrderCode, account, transferAmount, now);
693 String resultStr = JSON.toJSONString(mapResult); 694 String resultStr = JSON.toJSONString(mapResult);
694 jsonObject = JSON.parseObject(resultStr); 695 jsonObject = JSON.parseObject(resultStr);
@@ -700,6 +701,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -700,6 +701,7 @@ public class PaymentServiceImpl implements IPaymentService {
700 } 701 }
701 } 702 }
702 703
  704 + transfer.setTransferType(1);
703 jsonObject = alipayService.transferMoney(Long.toString(buyerOrderCode), account.getAlipayId(), account.getAlipayAccount(), transferAmount); 705 jsonObject = alipayService.transferMoney(Long.toString(buyerOrderCode), account.getAlipayId(), account.getAlipayAccount(), transferAmount);
704 if (jsonObject == null) { 706 if (jsonObject == null) {
705 logger.warn("transferMonErr 转账失败 , orderCode is {}", buyerOrderCode); 707 logger.warn("transferMonErr 转账失败 , orderCode is {}", buyerOrderCode);
@@ -718,6 +720,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -718,6 +720,7 @@ public class PaymentServiceImpl implements IPaymentService {
718 transfer.setAlipayTradeId(orderId); 720 transfer.setAlipayTradeId(orderId);
719 transfer.setStatus(1); 721 transfer.setStatus(1);
720 } else if(exceedMillion(jsonObject)) { 722 } else if(exceedMillion(jsonObject)) {
  723 + transfer.setTransferType(2);
721 Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), record, buyerOrderCode, account, transferAmount, now); 724 Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), record, buyerOrderCode, account, transferAmount, now);
722 String resultStr = JSON.toJSONString(mapResult); 725 String resultStr = JSON.toJSONString(mapResult);
723 jsonObject = JSON.parseObject(resultStr); 726 jsonObject = JSON.parseObject(resultStr);
@@ -813,6 +816,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -813,6 +816,7 @@ public class PaymentServiceImpl implements IPaymentService {
813 logger.info("transAllEarnest开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", orderCode, account, amount); 816 logger.info("transAllEarnest开始调用阿里接口参数buyerOrderCode={}, alipayAccount={}, transferAmount={}", orderCode, account, amount);
814 817
815 if(exceedMillion()) { 818 if(exceedMillion()) {
  819 + transfer.setTransferType(2);
816 Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), record, orderCode, aliPayAccount, amount, now); 820 Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), record, orderCode, aliPayAccount, amount, now);
817 String resultStr = JSON.toJSONString(mapResult); 821 String resultStr = JSON.toJSONString(mapResult);
818 jsonObject = JSON.parseObject(resultStr); 822 jsonObject = JSON.parseObject(resultStr);
@@ -824,6 +828,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -824,6 +828,7 @@ public class PaymentServiceImpl implements IPaymentService {
824 } 828 }
825 } 829 }
826 830
  831 + transfer.setTransferType(1);
827 jsonObject = alipayService.transferMoney(Long.toString(orderCode), aliPayAccount.getAlipayId(), aliPayAccount.getAlipayAccount(), amount); 832 jsonObject = alipayService.transferMoney(Long.toString(orderCode), aliPayAccount.getAlipayId(), aliPayAccount.getAlipayAccount(), amount);
828 if (jsonObject == null) { 833 if (jsonObject == null) {
829 logger.warn("transAllEarnestErr 转账失败 , orderCode is {}", orderCode); 834 logger.warn("transAllEarnestErr 转账失败 , orderCode is {}", orderCode);
@@ -843,6 +848,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -843,6 +848,7 @@ public class PaymentServiceImpl implements IPaymentService {
843 transfer.setStatus(1); 848 transfer.setStatus(1);
844 return true; 849 return true;
845 } else if(exceedMillion(jsonObject)) { 850 } else if(exceedMillion(jsonObject)) {
  851 + transfer.setTransferType(2);
846 Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), record, orderCode, aliPayAccount, amount, now); 852 Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), record, orderCode, aliPayAccount, amount, now);
847 String resultStr = JSON.toJSONString(mapResult); 853 String resultStr = JSON.toJSONString(mapResult);
848 jsonObject = JSON.parseObject(resultStr); 854 jsonObject = JSON.parseObject(resultStr);
@@ -1069,6 +1075,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -1069,6 +1075,7 @@ public class PaymentServiceImpl implements IPaymentService {
1069 } 1075 }
1070 } 1076 }
1071 JSONObject jsonObject = null; 1077 JSONObject jsonObject = null;
  1078 + Integer transferType = null;
1072 try { 1079 try {
1073 OrdersPayTransfer transfer = ordersPayTransferMapper.selectByBuyerOrderCode(orderCode); 1080 OrdersPayTransfer transfer = ordersPayTransferMapper.selectByBuyerOrderCode(orderCode);
1074 if (transfer == null) { 1081 if (transfer == null) {
@@ -1077,16 +1084,14 @@ public class PaymentServiceImpl implements IPaymentService { @@ -1077,16 +1084,14 @@ public class PaymentServiceImpl implements IPaymentService {
1077 if (transfer == null || transfer.getStatus() == 1) { 1084 if (transfer == null || transfer.getStatus() == 1) {
1078 throw new ServiceException(400, "转账记录已成功转账,流水id=" + tradeBillsId); 1085 throw new ServiceException(400, "转账记录已成功转账,流水id=" + tradeBillsId);
1079 } 1086 }
  1087 + transferType = transfer.getInterfaceType();
  1088 + if (transferType == null || transferType < 1 || transferType > 2) {
  1089 + throw new ServiceException(400, "转账记录接口类型有误,流水id=" + tradeBillsId);
  1090 + }
1080 1091
1081 - if(exceedMillion()) {  
1082 - Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), preSuccess, orderCode, account, amount, now);  
1083 - String resultStr = JSON.toJSONString(mapResult);  
1084 - jsonObject = JSON.parseObject(resultStr);  
1085 - if(!StringUtils.equals("T", mapResult.get("is_success"))) {  
1086 - throw new ServiceException(500, "转账失败:返回={}" + resultStr);  
1087 - } else {  
1088 - return;  
1089 - } 1092 + if (transferType == 2) {
  1093 + transferWhenExceedMillion(transfer.getId(), preSuccess, orderCode, account, amount, now);
  1094 + return;
1090 } 1095 }
1091 1096
1092 jsonObject = alipayService.transferMoney(Long.toString(orderCode), account.getAlipayId(), account.getAlipayAccount(), amount); 1097 jsonObject = alipayService.transferMoney(Long.toString(orderCode), account.getAlipayId(), account.getAlipayAccount(), amount);
@@ -1116,21 +1121,15 @@ public class PaymentServiceImpl implements IPaymentService { @@ -1116,21 +1121,15 @@ public class PaymentServiceImpl implements IPaymentService {
1116 transferSuccess.setStatus(1); 1121 transferSuccess.setStatus(1);
1117 transferSuccess.setUpdateTime(now); 1122 transferSuccess.setUpdateTime(now);
1118 ordersPayTransferMapper.updateByPrimaryKeySelective(transferSuccess); 1123 ordersPayTransferMapper.updateByPrimaryKeySelective(transferSuccess);
1119 - } else if(exceedMillion(jsonObject)) {  
1120 - Map<String, String> mapResult = transferWhenExceedMillion(transfer.getId(), tradeBills, orderCode, account, amount, now);  
1121 - String resultStr = JSON.toJSONString(mapResult);  
1122 - jsonObject = JSON.parseObject(resultStr);  
1123 - if(!StringUtils.equals("T", mapResult.get("is_success"))) {  
1124 - throw new ServiceException(500, "转账失败:返回={}" + resultStr);  
1125 - } else {  
1126 - return;  
1127 - }  
1128 } else { 1124 } else {
1129 logger.warn("manualDealErr 返回code或者order_id不是成功状态,code={}, orderId={}", code, orderId); 1125 logger.warn("manualDealErr 返回code或者order_id不是成功状态,code={}, orderId={}", code, orderId);
1130 // 上报 1126 // 上报
1131 throw new ServiceException(500, "转账失败:返回code="+code+",order_id="+orderId); 1127 throw new ServiceException(500, "转账失败:返回code="+code+",order_id="+orderId);
1132 } 1128 }
1133 } catch (Exception e) { 1129 } catch (Exception e) {
  1130 + if (transferType != null && transferType == 2) {
  1131 + return;
  1132 + }
1134 logger.warn("manualDealErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage()); 1133 logger.warn("manualDealErr 转账失败 , orderCode is {}, msg is {}", orderCode, e.getMessage());
1135 String alarmMsg = "订单号:" + orderCode + ",操作类型(转账),流水id=" + tradeBillsId + ",msg=" + e.getMessage(); 1134 String alarmMsg = "订单号:" + orderCode + ",操作类型(转账),流水id=" + tradeBillsId + ",msg=" + e.getMessage();
1136 if (jsonObject != null) { 1135 if (jsonObject != null) {