dingxin 6 years ago
parent
commit
038f8057b6

+ 12
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/AliPayController.java View File

8
 import com.community.huiju.common.wxpay.WXPayConstants;
8
 import com.community.huiju.common.wxpay.WXPayConstants;
9
 import com.community.huiju.common.wxpay.WXPayUtil;
9
 import com.community.huiju.common.wxpay.WXPayUtil;
10
 import com.community.huiju.service.AliPayServiceI;
10
 import com.community.huiju.service.AliPayServiceI;
11
+import com.community.huiju.service.WxPayServiceI;
11
 import com.google.common.collect.Maps;
12
 import com.google.common.collect.Maps;
12
 import io.swagger.annotations.Api;
13
 import io.swagger.annotations.Api;
13
 import io.swagger.annotations.ApiImplicitParam;
14
 import io.swagger.annotations.ApiImplicitParam;
49
 	@Autowired
50
 	@Autowired
50
 	private AliPayServiceI aliPayService;
51
 	private AliPayServiceI aliPayService;
51
 	
52
 	
53
+	@Autowired
54
+	private WxPayServiceI wxPayService;
55
+	
52
 	@Value("${alipay.ALIPAY_PUBLIC_KEY}")
56
 	@Value("${alipay.ALIPAY_PUBLIC_KEY}")
53
 	private String ALIPAY_PUBLIC_KEY;
57
 	private String ALIPAY_PUBLIC_KEY;
54
 	
58
 	
73
 	
77
 	
74
 	@ApiOperation(value = "支付宝手机订单支付完成后回调", notes = "支付宝手机订单支付完成后回调")
78
 	@ApiOperation(value = "支付宝手机订单支付完成后回调", notes = "支付宝手机订单支付完成后回调")
75
 	@RequestMapping(value = "/aliPayNotify",method = RequestMethod.POST)
79
 	@RequestMapping(value = "/aliPayNotify",method = RequestMethod.POST)
76
-	public void wxNotify(HttpServletRequest request, HttpServletResponse response){
80
+	public void aliPayNotify(HttpServletRequest request, HttpServletResponse response){
81
+		System.out.println("alipay result  start =======");
77
 		Map<String,String> params = new HashMap<String,String>();
82
 		Map<String,String> params = new HashMap<String,String>();
78
 		Map requestParams = request.getParameterMap();
83
 		Map requestParams = request.getParameterMap();
79
 		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
84
 		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
90
 		}
95
 		}
91
 		//切记alipaypublickey是支付宝的公钥,请去open.alipay.com对应应用下查看。
96
 		//切记alipaypublickey是支付宝的公钥,请去open.alipay.com对应应用下查看。
92
 		try {
97
 		try {
93
-			System.out.println(params);
94
 			boolean flag = AlipaySignature.rsaCheckV1(params, ALIPAY_PUBLIC_KEY, CHARSET_UTF8,"RSA2");
98
 			boolean flag = AlipaySignature.rsaCheckV1(params, ALIPAY_PUBLIC_KEY, CHARSET_UTF8,"RSA2");
95
-			System.out.println(flag);
99
+			if (flag){
100
+				params.put("pay_type","2");
101
+				wxPayService.wxNotify(params);
102
+			}
96
 		} catch (AlipayApiException e) {
103
 		} catch (AlipayApiException e) {
97
 			e.printStackTrace();
104
 			e.printStackTrace();
105
+		} catch (Exception e) {
106
+			e.printStackTrace();
98
 		}
107
 		}
99
 	}
108
 	}
100
 }
109
 }

+ 1
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/WxPayController.java View File

95
 			Map<String, String> resultMap = WXPayUtil.xmlToMap(result);
95
 			Map<String, String> resultMap = WXPayUtil.xmlToMap(result);
96
 			if (WXPayConstants.SUCCESS.equalsIgnoreCase(resultMap.get("result_code"))) {
96
 			if (WXPayConstants.SUCCESS.equalsIgnoreCase(resultMap.get("result_code"))) {
97
 				//处理业务逻辑 修改订单状态等
97
 				//处理业务逻辑 修改订单状态等
98
+				resultMap.put("pay_type","0");
98
 				String state = wxPayService.wxNotify(resultMap);
99
 				String state = wxPayService.wxNotify(resultMap);
99
 				if (state.equals("success")){
100
 				if (state.equals("success")){
100
 					log.info("微信支付成功。。");
101
 					log.info("微信支付成功。。");

+ 26
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpTransactionReply.java View File

21
 
21
 
22
     private Date createDate;
22
     private Date createDate;
23
 
23
 
24
+    /**
25
+     * 住户端 的角色
26
+     */
27
+    private String taRoleName;
28
+
29
+    /**
30
+     * 被回复人 的角色
31
+     */
32
+    private String replyRoleName;
33
+
24
     public Integer getId() {
34
     public Integer getId() {
25
         return id;
35
         return id;
26
     }
36
     }
92
     public void setCreateDate(Date createDate) {
102
     public void setCreateDate(Date createDate) {
93
         this.createDate = createDate;
103
         this.createDate = createDate;
94
     }
104
     }
105
+
106
+    public String getTaRoleName() {
107
+        return taRoleName;
108
+    }
109
+
110
+    public void setTaRoleName(String taRoleName) {
111
+        this.taRoleName = taRoleName;
112
+    }
113
+
114
+    public String getReplyRoleName() {
115
+        return replyRoleName;
116
+    }
117
+
118
+    public void setReplyRoleName(String replyRoleName) {
119
+        this.replyRoleName = replyRoleName;
120
+    }
95
 }
121
 }

+ 5
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/AliPayServiceImpl.java View File

27
 import org.springframework.stereotype.Service;
27
 import org.springframework.stereotype.Service;
28
 import org.springframework.transaction.annotation.Transactional;
28
 import org.springframework.transaction.annotation.Transactional;
29
 
29
 
30
+import java.math.BigDecimal;
31
+
30
 import static com.alipay.api.AlipayConstants.CHARSET_UTF8;
32
 import static com.alipay.api.AlipayConstants.CHARSET_UTF8;
31
 
33
 
32
 /**
34
 /**
96
 		AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
98
 		AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
97
 		//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
99
 		//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
98
 		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
100
 		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
99
-		model.setBody("我是测试数据");
100
-		model.setSubject("App支付测试Java");
101
+		model.setBody(tpBillInvoice.getBillName());
102
+		model.setSubject(tpBillInvoice.getBillName());
101
 		model.setOutTradeNo(tpBillInvoice.getOutTradeNo());
103
 		model.setOutTradeNo(tpBillInvoice.getOutTradeNo());
102
 		model.setTimeoutExpress("30m");
104
 		model.setTimeoutExpress("30m");
103
-		model.setTotalAmount("0.01");
105
+		model.setTotalAmount(BigDecimal.valueOf(Long.valueOf(tpBillInvoice.getPayPrice())).divide(new BigDecimal(100)).toString());
104
 		model.setProductCode("QUICK_MSECURITY_PAY");
106
 		model.setProductCode("QUICK_MSECURITY_PAY");
105
 		request.setBizModel(model);
107
 		request.setBizModel(model);
106
 		request.setNotifyUrl("http://106.14.20.193:8086/app-api/aliPayNotify");
108
 		request.setNotifyUrl("http://106.14.20.193:8086/app-api/aliPayNotify");

+ 3
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/WxPayServiceImpl.java View File

134
 		tpBillInvoice.setBillStatus("1");
134
 		tpBillInvoice.setBillStatus("1");
135
 		tpBillInvoice.setPayDate(new Date());
135
 		tpBillInvoice.setPayDate(new Date());
136
 		tpBillInvoice.setUpdateDate(new Date());
136
 		tpBillInvoice.setUpdateDate(new Date());
137
-		// 缴费方式  0:微信支付  1:线下缴费
138
-		tpBillInvoice.setPayType("0");
137
+		// 缴费方式  0:微信支付  1:线下缴费 2.支付宝支付
138
+		tpBillInvoice.setPayType(resultMap.get("pay_type"));
139
 		tpBillInvoiceMapper.updateByPrimaryKeySelective(tpBillInvoice);
139
 		tpBillInvoiceMapper.updateByPrimaryKeySelective(tpBillInvoice);
140
 
140
 
141
 		//插入流水账单表
141
 		//插入流水账单表
146
 		tpBillStatement.setPayPrice(tpBillInvoice.getPayPrice());
146
 		tpBillStatement.setPayPrice(tpBillInvoice.getPayPrice());
147
 		tpBillStatement.setPayName(tpBillInvoice.getPayName());
147
 		tpBillStatement.setPayName(tpBillInvoice.getPayName());
148
 		tpBillStatement.setPayRemark(tpBillInvoice.getBillName());
148
 		tpBillStatement.setPayRemark(tpBillInvoice.getBillName());
149
-		tpBillStatement.setPayType("0");
149
+		tpBillStatement.setPayType(resultMap.get("pay_type"));
150
 		tpBillStatement.setCreateTime(new Date());
150
 		tpBillStatement.setCreateTime(new Date());
151
 		tpBillStatementMapper.insert(tpBillStatement);
151
 		tpBillStatementMapper.insert(tpBillStatement);
152
 
152
 

+ 5
- 3
CODE/smart-community/app-api/src/main/resources/mapper/TpTransactionReplyMapper.xml View File

141
   </update>
141
   </update>
142
   <select id="getCommunityIdAndTransactionId" resultMap="BaseResultMap">
142
   <select id="getCommunityIdAndTransactionId" resultMap="BaseResultMap">
143
     select
143
     select
144
-    <include refid="Base_Column_List"/>
145
-    from tp_transaction_reply
146
-    where community_id = #{communityId,jdbcType=INTEGER} and transaction_id = #{transactionId,jdbcType=INTEGER}
144
+      tr.*,
145
+      (select tsr.role_name from ta_sys_user_role tsur LEFT JOIN ta_sys_role tsr on tsur.role_id = tsr.id where tsur.user_id = tr.ta_user_id) as taRoleName,
146
+      (select tsr.role_name from ta_sys_user_role tsur LEFT JOIN ta_sys_role tsr on tsur.role_id = tsr.id where tsur.user_id = tr.reply_ta_user_id) as replyRoleName
147
+    from tp_transaction_reply tr
148
+    where tr.community_id = #{communityId,jdbcType=INTEGER} and tr.transaction_id = #{transactionId,jdbcType=INTEGER}
147
   </select>
149
   </select>
148
 </mapper>
150
 </mapper>