傅行帆 6 年前
父节点
当前提交
36659a3a75

+ 2
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/AliPayController.java 查看文件

@@ -58,10 +58,10 @@ public class AliPayController {
58 58
 	@RequestMapping(value = "/aliPayOrder/{billInvoiceId}",method = RequestMethod.GET)
59 59
 	public ResponseBean wxUnifiedOrder(@PathVariable("billInvoiceId") Integer billInvoiceId, HttpSession session){
60 60
 		ResponseBean responseBean = new ResponseBean();
61
-		//UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
61
+		UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
62 62
 		String resp = "";
63 63
 		try {
64
-			resp = aliPayService.AliPayOrder(1,null);
64
+			resp = aliPayService.AliPayOrder(billInvoiceId,userElement);
65 65
 		} catch (Exception e) {
66 66
 			e.printStackTrace();
67 67
 			responseBean.addError(e.getMessage());

+ 18
- 19
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/AliPayServiceImpl.java 查看文件

@@ -72,23 +72,23 @@ public class AliPayServiceImpl implements AliPayServiceI {
72 72
 	@Override
73 73
 	@Transactional(rollbackFor = Exception.class)
74 74
 	public String AliPayOrder(Integer billInvoiceId, UserElement userElement) throws Exception {
75
-		//Integer userId = userElement.getId();
76
-		//
77
-		//// 如果是家属/租客, 应该用业主的用户id
78
-		//TaUser taUser = taUserMapper.selectByPrimaryKey(userId);
79
-		//TaSysRole taSysRole = taSysRoleMapper.findRoleByUserId(userId);
80
-		//if (null != taSysRole && taSysRole.getId().intValue() != 1) {
81
-		//	TaUser ownerUser = taUserMapper.selectByPrimaryKey(taUser.getParentId());
82
-		//	userId = ownerUser.getId();
83
-		//}
84
-		//
85
-		////获取支付金额
86
-		//TpBillInvoice tpBillInvoice = tpBillInvoiceMapper.selectByIdAndUserId(billInvoiceId,userId,userElement.getCommunityId());
87
-		//if (null == tpBillInvoice){
88
-		//	throw new Exception("订单不存在");
89
-		//}else if (!tpBillInvoice.getBillStatus().equals("3")){
90
-		//	throw new Exception("不是正在支付的订单");
91
-		//}
75
+		Integer userId = userElement.getId();
76
+
77
+		// 如果是家属/租客, 应该用业主的用户id
78
+		TaUser taUser = taUserMapper.selectByPrimaryKey(userId);
79
+		TaSysRole taSysRole = taSysRoleMapper.findRoleByUserId(userId);
80
+		if (null != taSysRole && taSysRole.getId().intValue() != 1) {
81
+			TaUser ownerUser = taUserMapper.selectByPrimaryKey(taUser.getParentId());
82
+			userId = ownerUser.getId();
83
+		}
84
+
85
+		//获取支付金额
86
+		TpBillInvoice tpBillInvoice = tpBillInvoiceMapper.selectByIdAndUserId(billInvoiceId,userId,userElement.getCommunityId());
87
+		if (null == tpBillInvoice){
88
+			throw new Exception("订单不存在");
89
+		}else if (!tpBillInvoice.getBillStatus().equals("3")){
90
+			throw new Exception("不是正在支付的订单");
91
+		}
92 92
 		
93 93
 		//下单
94 94
 		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", ALI_APP_ID, APP_PRIVATE_KEY, "json", CHARSET_UTF8, ALIPAY_PUBLIC_KEY, "RSA2");
@@ -98,8 +98,7 @@ public class AliPayServiceImpl implements AliPayServiceI {
98 98
 		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
99 99
 		model.setBody("我是测试数据");
100 100
 		model.setSubject("App支付测试Java");
101
-		//model.setOutTradeNo(tpBillInvoice.getOutTradeNo());
102
-		model.setOutTradeNo("1");
101
+		model.setOutTradeNo(tpBillInvoice.getOutTradeNo());
103 102
 		model.setTimeoutExpress("30m");
104 103
 		model.setTotalAmount("0.01");
105 104
 		model.setProductCode("QUICK_MSECURITY_PAY");