anderx 4 years ago
parent
commit
7cb69c7b25
1 changed files with 11 additions and 12 deletions
  1. 11 12
      src/main/java/com/kede/wxsdk/service/WxService.java

+ 11 - 12
src/main/java/com/kede/wxsdk/service/WxService.java

@@ -161,12 +161,7 @@ public class WxService {
 					if (map.get("trade_state").equals("SUCCESS")) {
 						Order os=orderMapper.selectByPrimaryKey(out_trade_no);
 						if (os.getPayStatus()!=1) {
-							Order o=new Order();
-							o.setOrderNo(out_trade_no);
-							o.setPayStatus(1);
-							o.setPayAmount(new BigDecimal(total_fee).divide(new BigDecimal(100)));
-							o.setWxOrderNo(transaction_id);
-							orderMapper.updateByPrimaryKeySelective(o);
+							insertOrder(total_fee, transaction_id, out_trade_no);
 						}
 					}
 				}catch (Exception e) {
@@ -175,6 +170,15 @@ public class WxService {
 				}
 				return map;
 	}
+
+	private void insertOrder(String total_fee, String transaction_id, String out_trade_no) {
+		Order o=new Order();
+		o.setOrderNo(out_trade_no);
+		o.setPayStatus(1);
+		o.setPayAmount(new BigDecimal(total_fee).divide(new BigDecimal(100)));
+		o.setWxOrderNo(transaction_id);
+		orderMapper.updateByPrimaryKeySelective(o);
+	}
 	
 	/**
 	 *	 微信撤销订单
@@ -249,12 +253,7 @@ public class WxService {
 		if (result_code.equals("SUCCESS")) {
 			Order os=orderMapper.selectByPrimaryKey(out_trade_no);
 			if (os.getPayStatus()!=1) {
-				Order o=new Order();
-				o.setOrderNo(out_trade_no);
-				o.setPayAmount(new BigDecimal(total_fee));
-				o.setWxOrderNo(transaction_id);
-				o.setPayStatus(1);
-				orderMapper.updateByPrimaryKeySelective(o);
+				insertOrder(total_fee, transaction_id, out_trade_no);
 			}
 		}
 		LoggerUtils.debug(getClass(),"\n\n\n\n\n>>>>>>>>>>>>>>>>>>>>>>>>微信回调结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n\n\n");