dingxin 6 years ago
parent
commit
926f08a482

+ 8
- 0
CODE/smart-community/app-api/pom.xml View File

@@ -114,6 +114,14 @@
114 114
 			<scope>provided</scope>
115 115
 		</dependency>
116 116
 
117
+		<!-- https://mvnrepository.com/artifact/com.alipay.sdk/alipay-sdk-java -->
118
+		<dependency>
119
+			<groupId>com.alipay.sdk</groupId>
120
+			<artifactId>alipay-sdk-java</artifactId>
121
+			<version>3.3.49.ALL</version>
122
+		</dependency>
123
+
124
+
117 125
 		<!-- log4j -->
118 126
 
119 127
 		<!--<dependency>-->

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

@@ -0,0 +1,100 @@
1
+package com.community.huiju.controller;
2
+
3
+import com.alipay.api.AlipayApiException;
4
+import com.alipay.api.internal.util.AlipaySignature;
5
+import com.community.commom.constant.Constant;
6
+import com.community.commom.mode.ResponseBean;
7
+import com.community.commom.session.UserElement;
8
+import com.community.huiju.common.wxpay.WXPayConstants;
9
+import com.community.huiju.common.wxpay.WXPayUtil;
10
+import com.community.huiju.service.AliPayServiceI;
11
+import com.google.common.collect.Maps;
12
+import io.swagger.annotations.Api;
13
+import io.swagger.annotations.ApiImplicitParam;
14
+import io.swagger.annotations.ApiImplicitParams;
15
+import io.swagger.annotations.ApiOperation;
16
+import org.slf4j.Logger;
17
+import org.slf4j.LoggerFactory;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.beans.factory.annotation.Value;
20
+import org.springframework.cloud.context.config.annotation.RefreshScope;
21
+import org.springframework.web.bind.annotation.PathVariable;
22
+import org.springframework.web.bind.annotation.RequestMapping;
23
+import org.springframework.web.bind.annotation.RequestMethod;
24
+import org.springframework.web.bind.annotation.RestController;
25
+
26
+import javax.servlet.http.HttpServletRequest;
27
+import javax.servlet.http.HttpServletResponse;
28
+import javax.servlet.http.HttpSession;
29
+import java.io.ByteArrayOutputStream;
30
+import java.io.InputStream;
31
+import java.util.HashMap;
32
+import java.util.Iterator;
33
+import java.util.Map;
34
+
35
+import static com.alipay.api.AlipayConstants.CHARSET_UTF8;
36
+
37
+/**
38
+ * @author FXF
39
+ * @date 2019-03-12
40
+ */
41
+@RestController
42
+@RefreshScope
43
+@RequestMapping("/")
44
+@Api(value = "支付宝支付 API", description = "支付宝支付 API")
45
+public class AliPayController {
46
+	
47
+	private Logger log = LoggerFactory.getLogger(AliPayController.class);
48
+	
49
+	@Autowired
50
+	private AliPayServiceI aliPayService;
51
+	
52
+	@Value("${alipay.ALIPAY_PUBLIC_KEY}")
53
+	private String ALIPAY_PUBLIC_KEY;
54
+	
55
+	@ApiOperation(value = "统一下单", notes = "统一下单")
56
+	@ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "Integer", name = "billInvoiceId", value = "账单Id"),
57
+			@ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token") })
58
+	@RequestMapping(value = "/aliPayOrder/{billInvoiceId}",method = RequestMethod.GET)
59
+	public ResponseBean wxUnifiedOrder(@PathVariable("billInvoiceId") Integer billInvoiceId, HttpSession session){
60
+		ResponseBean responseBean = new ResponseBean();
61
+		//UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
62
+		String resp = "";
63
+		try {
64
+			resp = aliPayService.AliPayOrder(1,null);
65
+		} catch (Exception e) {
66
+			e.printStackTrace();
67
+			responseBean.addError(e.getMessage());
68
+			return responseBean;
69
+		}
70
+		responseBean.addSuccess(resp);
71
+		return responseBean;
72
+	}
73
+	
74
+	@ApiOperation(value = "支付宝手机订单支付完成后回调", notes = "支付宝手机订单支付完成后回调")
75
+	@RequestMapping(value = "/aliPayNotify",method = RequestMethod.POST)
76
+	public void wxNotify(HttpServletRequest request, HttpServletResponse response){
77
+		Map<String,String> params = new HashMap<String,String>();
78
+		Map requestParams = request.getParameterMap();
79
+		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
80
+			String name = (String) iter.next();
81
+			String[] values = (String[]) requestParams.get(name);
82
+			String valueStr = "";
83
+			for (int i = 0; i < values.length; i++) {
84
+				valueStr = (i == values.length - 1) ? valueStr + values[i]
85
+						: valueStr + values[i] + ",";
86
+			}
87
+			//乱码解决,这段代码在出现乱码时使用。
88
+			//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
89
+			params.put(name, valueStr);
90
+		}
91
+		//切记alipaypublickey是支付宝的公钥,请去open.alipay.com对应应用下查看。
92
+		try {
93
+			System.out.println(params);
94
+			boolean flag = AlipaySignature.rsaCheckV1(params, ALIPAY_PUBLIC_KEY, CHARSET_UTF8,"RSA2");
95
+			System.out.println(flag);
96
+		} catch (AlipayApiException e) {
97
+			e.printStackTrace();
98
+		}
99
+	}
100
+}

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

@@ -266,6 +266,35 @@ public class SocialController extends BaseController {
266 266
         return responseBean;
267 267
     }
268 268
 
269
+
270
+    @ApiOperation(value = "查询二手租赁回复", notes = "查询二手租赁回复")
271
+    @ApiImplicitParams({
272
+            @ApiImplicitParam(paramType = "query", dataType = "integer", name = "transactionId", value = "活动帖子id"),
273
+            @ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token"),
274
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageNum", value = "第几页"),
275
+            @ApiImplicitParam(paramType = "query", dataTypeClass = Integer.class, name = "pageSize", value = "一页多少行"),
276
+            @ApiImplicitParam(paramType = "query", dataTypeClass = String.class, name = "order", value = "asc 正序(默认), desc倒序")
277
+    })
278
+    @RequestMapping(value = "/getTransactionReply", method = RequestMethod.GET)
279
+    public ResponseBean findUsedDetailsReply(@RequestParam("transactionId") Integer transactionId,
280
+                                             @RequestParam(value = "order", defaultValue = "asc") String order,
281
+                                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
282
+                                             @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize,
283
+                                             HttpSession session) {
284
+        ResponseBean responseBean = new ResponseBean();
285
+        UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
286
+
287
+        if (!check(userElement.getCommunityId())) {
288
+            responseBean.addError("小区不存在");
289
+            return responseBean;
290
+        }
291
+
292
+        responseBean = socialServiceI.findUsedDetailsReply(transactionId, userElement, order, pageNum, pageSize);
293
+        return responseBean;
294
+    }
295
+
296
+
297
+
269 298
     @ApiOperation(value = "获取所有的二手租赁帖子", notes = "获取所有的二手租赁帖子")
270 299
     @ApiImplicitParams({@ApiImplicitParam(paramType = "path", dataType = "integer", name = "communityId", value = "小区Id"),
271 300
             @ApiImplicitParam(paramType = "query", dataType = "String", name = "type", value = "帖子类型"),

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

@@ -44,8 +44,6 @@ public class TpTransaction {
44 44
 
45 45
     private  String roleName;
46 46
 
47
-    // 帖子的回复集合
48
-    private List<TpTransactionReply> replies;
49 47
 
50 48
     public String getRoleName() {
51 49
         return roleName;
@@ -188,11 +186,4 @@ public class TpTransaction {
188 186
         this.createUserName = createUserName;
189 187
     }
190 188
 
191
-    public List<TpTransactionReply> getReplies() {
192
-        return replies;
193
-    }
194
-
195
-    public void setReplies(List<TpTransactionReply> replies) {
196
-        this.replies = replies;
197
-    }
198 189
 }

+ 16
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/AliPayServiceI.java View File

@@ -0,0 +1,16 @@
1
+package com.community.huiju.service;
2
+
3
+import com.community.commom.session.UserElement;
4
+
5
+import java.util.Map;
6
+
7
+public interface AliPayServiceI {
8
+	/**
9
+	 * 微信支付统一下单
10
+	 * @return
11
+	 * @param billInvoiceId
12
+	 * @param userElement
13
+	 */
14
+	String AliPayOrder(Integer billInvoiceId, UserElement userElement) throws Exception;
15
+	
16
+}

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

@@ -170,10 +170,21 @@ public interface SocialServiceI {
170 170
 	ResponseBean reportTransaction(Integer userId,Integer communityId, String paramets);
171 171
 
172 172
 	/**
173
-	 * 二帖子回复
174
-	 * @param paramets
175
-	 * @param userElement
173
+	 * 查询 二手交易帖子的回复
174
+	 * @param transactionId 帖子id
175
+	 * @param userElement 用户信息体
176
+	 * @param order asc 正序  desc 倒序
177
+	 * @param pageNum
178
+	 * @param pageSize
176 179
 	 * @return
177 180
 	 */
181
+	ResponseBean findUsedDetailsReply(Integer transactionId, UserElement userElement, String order, Integer pageNum, Integer pageSize);
182
+	/**
183
+	 * 二帖子回复
184
+	 *@param paramets
185
+	 *@param userElement
186
+	 *@return
187
+	 */
178 188
     ResponseBean addTransactionReply(String paramets, UserElement userElement);
189
+
179 190
 }

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

@@ -0,0 +1,119 @@
1
+package com.community.huiju.service.impl;
2
+
3
+import com.alipay.api.AlipayApiException;
4
+import com.alipay.api.AlipayClient;
5
+import com.alipay.api.DefaultAlipayClient;
6
+import com.alipay.api.domain.AlipayTradeAppPayModel;
7
+import com.alipay.api.request.AlipayTradeAppPayRequest;
8
+import com.alipay.api.response.AlipayTradeAppPayResponse;
9
+import com.community.commom.session.UserElement;
10
+import com.community.huiju.common.wxpay.HfWxConfig;
11
+import com.community.huiju.common.wxpay.WXPay;
12
+import com.community.huiju.common.wxpay.WXPayConstants;
13
+import com.community.huiju.common.wxpay.WXPayUtil;
14
+import com.community.huiju.dao.TaSysRoleMapper;
15
+import com.community.huiju.dao.TaUserMapper;
16
+import com.community.huiju.dao.TpBillInvoiceMapper;
17
+import com.community.huiju.dao.TpBillMapper;
18
+import com.community.huiju.dao.TpBillStatementMapper;
19
+import com.community.huiju.model.TaSysRole;
20
+import com.community.huiju.model.TaUser;
21
+import com.community.huiju.model.TpBillInvoice;
22
+import com.community.huiju.service.AliPayServiceI;
23
+import org.slf4j.Logger;
24
+import org.slf4j.LoggerFactory;
25
+import org.springframework.beans.factory.annotation.Autowired;
26
+import org.springframework.beans.factory.annotation.Value;
27
+import org.springframework.stereotype.Service;
28
+import org.springframework.transaction.annotation.Transactional;
29
+
30
+import static com.alipay.api.AlipayConstants.CHARSET_UTF8;
31
+
32
+/**
33
+ * @author FXF
34
+ * @date 2018-10-25
35
+ */
36
+@Service("aliPayService")
37
+@Transactional(rollbackFor = Exception.class)
38
+public class AliPayServiceImpl implements AliPayServiceI {
39
+	private Logger log = LoggerFactory.getLogger(AliPayServiceImpl.class);
40
+	
41
+	@Autowired
42
+	private TpBillInvoiceMapper tpBillInvoiceMapper;
43
+	
44
+	@Autowired
45
+	private TpBillStatementMapper tpBillStatementMapper;
46
+
47
+	@Autowired
48
+	private TpBillMapper tpBillMapper;
49
+
50
+	@Autowired
51
+	private TaUserMapper taUserMapper;
52
+
53
+	@Autowired
54
+	private TaSysRoleMapper taSysRoleMapper;
55
+	
56
+	@Value("${alipay.APP_PRIVATE_KEY}")
57
+	private String APP_PRIVATE_KEY;
58
+	
59
+	@Value("${alipay.APP_ID}")
60
+	private String ALI_APP_ID;
61
+	
62
+	@Value("${alipay.ALIPAY_PUBLIC_KEY}")
63
+	private String ALIPAY_PUBLIC_KEY;
64
+	
65
+	/**
66
+	 * 支付宝统一下单
67
+	 *
68
+	 * @return
69
+	 * @param billInvoiceId
70
+	 * @param userElement
71
+	 */
72
+	@Override
73
+	@Transactional(rollbackFor = Exception.class)
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
+		//}
92
+		
93
+		//下单
94
+		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", ALI_APP_ID, APP_PRIVATE_KEY, "json", CHARSET_UTF8, ALIPAY_PUBLIC_KEY, "RSA2");
95
+		//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
96
+		AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
97
+		//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
98
+		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
99
+		model.setBody("我是测试数据");
100
+		model.setSubject("App支付测试Java");
101
+		//model.setOutTradeNo(tpBillInvoice.getOutTradeNo());
102
+		model.setOutTradeNo("1");
103
+		model.setTimeoutExpress("30m");
104
+		model.setTotalAmount("0.01");
105
+		model.setProductCode("QUICK_MSECURITY_PAY");
106
+		request.setBizModel(model);
107
+		request.setNotifyUrl("http://106.14.20.193:8086/app-api/aliPayNotify");
108
+		try {
109
+			//这里和普通的接口调用不同,使用的是sdkExecute
110
+			AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
111
+			//就是orderString 可以直接给客户端请求,无需再做处理。
112
+			System.out.println(response.getBody());
113
+			return response.getBody();
114
+		} catch (AlipayApiException e) {
115
+			e.printStackTrace();
116
+		}
117
+		return null;
118
+	}
119
+}

+ 11
- 4
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/SocialServiceImpl.java View File

@@ -732,10 +732,6 @@ public class SocialServiceImpl implements SocialServiceI {
732 732
         List<String> imgList = tdImagesList.stream().map(e->new String(e.getImageUrl())).collect(Collectors.toList());
733 733
         tpTransaction.setImgList(imgList);
734 734
 
735
-        // 查询回复信息
736
-        List<TpTransactionReply> transactionReplies = tpTransactionReplyMapper.getCommunityIdAndTransactionId(communityId, tpTransaction.getId());
737
-        tpTransaction.setReplies(transactionReplies);
738
-
739 735
         return tpTransaction;
740 736
 
741 737
     }
@@ -772,4 +768,15 @@ public class SocialServiceImpl implements SocialServiceI {
772 768
 
773 769
         return responseBean;
774 770
     }
771
+
772
+    @Override
773
+    public ResponseBean findUsedDetailsReply(Integer transactionId, UserElement userElement, String order, Integer pageNum, Integer pageSize) {
774
+        ResponseBean responseBean = new ResponseBean();
775
+
776
+        PageHelper.startPage(pageNum, pageSize, "create_date " + order);
777
+        List<TpTransactionReply> replies = tpTransactionReplyMapper.getCommunityIdAndTransactionId(userElement.getCommunityId(), transactionId);
778
+
779
+        responseBean.addSuccess(replies);
780
+        return responseBean;
781
+    }
775 782
 }

+ 5
- 1
CODE/smart-community/app-api/src/main/resources/application.yml View File

@@ -18,4 +18,8 @@ pagehelper:
18 18
 # 打印sql
19 19
 logging:
20 20
   level:
21
-    com.community.huiju.dao: debug
21
+    com.community.huiju.dao: debug
22
+alipay:
23
+  APP_ID: 2019021463230548
24
+  APP_PRIVATE_KEY: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCkrvqeBeJNNeKByYSBq8U+V0STFBh70IGaHi2oPa3TiF6u2WAJ7YlH2h1S4Zj2Ezojckfl0m8y/nqpPay6gSMBOpR38A+94gNiH7BVfyecuuQ9z+2BJdOxN5RkEBBkUqeW4oUbrgY4mRLPRrUKvAu/4Brd0eojkkEW0hJUxqgKj+C4H5tR+6DRowHcO23Q/98+4qlSRjhygLVK4m+u8+zb26RxF4v0ogooF+EAZQLOqz3N4uaZs2ajgnecG0drtei7mxbpyqHMr0idP4U4Lx63yXViRNWpHQ7u7byOBQNV9MFHWPHKt+aNOqZ61LCXpJt777usQPzQJggZj6TpRtT3AgMBAAECggEAHM36Sf+PeJ/PMZJU2fV4d5H+DZe7PJTYxmM26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ndk5MTd0gjX4C4C3FKf2vbdqFuCKAPzJ0rTs/rLcjz2/g8I7BMvVd/sEh77iewsVLvSLhF2ZRxD9Mc2qfffU4hq8F4WIyLVgvizFU=
25
+  ALIPAY_PUBLIC_KEY: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnJtkEz+TiJR/KbLDeP0rKQTSrQO7g8sGU0G0RYIN3KF6CiWd+eaT/ioM0BpR1Jx+IuAdpo3DFBqhLA6ABSHXFZPRikcxNlsyz2JgkwzfsRY+DxcPnYYNZFK7pUbku8L/AIxZiFQcbunwz36acazaZpun0zgrQlcBZqBCTCIgkT2fMQbPTm/MrmUKjDTE0VP+1mFyjYUVZWpJEYE5AJ3+x7jAPmuEdSMwKONUtOOTByDrkmXJ60RGE8zCmO/oUmOGxnTQRYfNjvBZ0lbVdP/bAw6qHVFBElzPHjNerbMK/geLuiLs3vkDY9tw7A4GQYMnjKuoetuMUhxZ6nRTH6NCeQIDAQAB

+ 3
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/ToBannerServiceImpl.java View File

@@ -15,7 +15,9 @@ import com.community.huiju.vo.ToBannerVO;
15 15
 import com.github.pagehelper.Page;
16 16
 import com.github.pagehelper.PageHelper;
17 17
 import com.google.common.collect.Maps;
18
+import org.apache.commons.httpclient.HttpState;
18 19
 import org.apache.commons.lang.StringUtils;
20
+import org.apache.http.HttpStatus;
19 21
 import org.springframework.beans.BeanUtils;
20 22
 import org.springframework.beans.factory.annotation.Autowired;
21 23
 import org.springframework.stereotype.Service;
@@ -190,7 +192,7 @@ public class ToBannerServiceImpl implements IToBannerService {
190 192
 
191 193
     @Override
192 194
     public ResponseBean getBanner(ToBanner banner,Integer pageNum, Integer pageSize) {
193
-
195
+        
194 196
         ResponseBean response = new ResponseBean();
195 197
 
196 198
         Page<ToBanner> page = PageHelper.startPage(pageNum,pageSize);