魏熙美 6 lat temu
rodzic
commit
24afdbb855
15 zmienionych plików z 455 dodań i 129 usunięć
  1. 14
    2
      CODE/smart-community/app-api/src/main/java/com/community/huiju/common/perproties/PayNotifyPerproties.java
  2. 31
    11
      CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/AliPayController.java
  3. 47
    17
      CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/WxPayController.java
  4. 9
    0
      CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TaUserLicenseOrderMapper.java
  5. 3
    3
      CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpBillInvoice.java
  6. 3
    3
      CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpBillOrder.java
  7. 2
    1
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/AliPayServiceI.java
  8. 7
    0
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/ITaUserLicenseService.java
  9. 25
    5
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/WxPayServiceI.java
  10. 12
    16
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/AliPayServiceImpl.java
  11. 6
    6
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/BillServiceImpl.java
  12. 32
    1
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserLicenseServiceImpl.java
  13. 249
    60
      CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/WxPayServiceImpl.java
  14. 8
    4
      CODE/smart-community/app-api/src/main/resources/application.yml
  15. 7
    0
      CODE/smart-community/community-common/src/main/java/com/community/commom/constant/Constant.java

+ 14
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/perproties/PayNotifyPerproties.java Wyświetl plik

@@ -4,6 +4,8 @@ import lombok.Data;
4 4
 import org.springframework.boot.context.properties.ConfigurationProperties;
5 5
 import org.springframework.stereotype.Component;
6 6
 
7
+import java.math.BigDecimal;
8
+
7 9
 /**
8 10
  * 支付回调地址配置
9 11
  * @author weiximei
@@ -14,13 +16,23 @@ import org.springframework.stereotype.Component;
14 16
 public class PayNotifyPerproties {
15 17
 
16 18
     /**
17
-     * 微信回调
19
+     * 微信回调 物业缴费
18 20
      */
19 21
     private String wxBillNotify;
20 22
 
21 23
     /**
22
-     * 支付宝回调
24
+     * 支付宝回调 物业缴费
23 25
      */
24 26
     private String aliBillNotify;
25 27
 
28
+    /**
29
+     * 微信回调 车缴费
30
+     */
31
+    private String wxCarNotify;
32
+
33
+    /**
34
+     * 支付宝回调 车缴费
35
+     */
36
+    private String aliCarNotify;
37
+
26 38
 }

+ 31
- 11
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/AliPayController.java Wyświetl plik

@@ -19,10 +19,7 @@ import org.slf4j.LoggerFactory;
19 19
 import org.springframework.beans.factory.annotation.Autowired;
20 20
 import org.springframework.beans.factory.annotation.Value;
21 21
 import org.springframework.cloud.context.config.annotation.RefreshScope;
22
-import org.springframework.web.bind.annotation.PathVariable;
23
-import org.springframework.web.bind.annotation.RequestMapping;
24
-import org.springframework.web.bind.annotation.RequestMethod;
25
-import org.springframework.web.bind.annotation.RestController;
22
+import org.springframework.web.bind.annotation.*;
26 23
 
27 24
 import javax.servlet.http.HttpServletRequest;
28 25
 import javax.servlet.http.HttpServletResponse;
@@ -57,15 +54,17 @@ public class AliPayController {
57 54
 	private String ALIPAY_PUBLIC_KEY;
58 55
 	
59 56
 	@ApiOperation(value = "统一下单", notes = "统一下单")
60
-	@ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "Integer", name = "billInvoiceId", value = "账单Id"),
57
+	@ApiImplicitParams({
58
+			@ApiImplicitParam(paramType = "path", dataType = "String", name = "outTradeNo", value = "订单号"),
59
+			@ApiImplicitParam(paramType = "form", dataType = "String", name = "type", value = "订单类型:type: 类型(car 车缴费, bill 物业缴费)"),
61 60
 			@ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token") })
62 61
 	@RequestMapping(value = "/aliPayOrder/{outTradeNo}",method = RequestMethod.GET)
63
-	public ResponseBean wxUnifiedOrder(@PathVariable("outTradeNo") String outTradeNo, HttpSession session){
62
+	public ResponseBean wxUnifiedOrder(@PathVariable("outTradeNo") String outTradeNo, @RequestParam("type") String type, HttpSession session){
64 63
 		ResponseBean responseBean = new ResponseBean();
65 64
 		UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
66 65
 		String resp = "";
67 66
 		try {
68
-			resp = aliPayService.AliPayOrder(outTradeNo,userElement);
67
+			resp = aliPayService.AliPayOrder(outTradeNo, type,userElement);
69 68
 		} catch (Exception e) {
70 69
 			e.printStackTrace();
71 70
 			responseBean.addError(e.getMessage());
@@ -75,9 +74,24 @@ public class AliPayController {
75 74
 		return responseBean;
76 75
 	}
77 76
 	
78
-	@ApiOperation(value = "支付宝手机订单支付完成后回调", notes = "支付宝手机订单支付完成后回调")
79
-	@RequestMapping(value = "/aliPayNotify",method = RequestMethod.POST)
80
-	public void aliPayNotify(HttpServletRequest request, HttpServletResponse response){
77
+	@ApiOperation(value = "支付宝手机订单支付完成后回调 物业缴费", notes = "支付宝手机订单支付完成后回调")
78
+	@RequestMapping(value = "/aliPayBillNotify",method = RequestMethod.POST)
79
+	public void aliPayBillNotify(HttpServletRequest request, HttpServletResponse response){
80
+		wxNotify(request, Constant.PAY_TYPE_BILL);
81
+	}
82
+
83
+	@ApiOperation(value = "支付宝手机订单支付完成后回调 车缴费", notes = "支付宝手机订单支付完成后回调 车缴费")
84
+	@RequestMapping(value = "/aliPayCarNotify",method = RequestMethod.POST)
85
+	public void aliPayCarNotify(HttpServletRequest request, HttpServletResponse response){
86
+		wxNotify(request, Constant.PAY_TYPE_CAR);
87
+	}
88
+
89
+	/**
90
+	 * 支付回调
91
+	 * @param request
92
+	 * @param type
93
+	 */
94
+	private void wxNotify(HttpServletRequest request, String type) {
81 95
 		System.out.println("alipay result  start =======");
82 96
 		Map<String,String> params = new HashMap<String,String>();
83 97
 		Map requestParams = request.getParameterMap();
@@ -98,7 +112,12 @@ public class AliPayController {
98 112
 			boolean flag = AlipaySignature.rsaCheckV1(params, ALIPAY_PUBLIC_KEY, CHARSET_UTF8,"RSA2");
99 113
 			if (flag){
100 114
 				params.put("pay_type","2");
101
-				wxPayService.wxNotify(params);
115
+				if (Constant.PAY_TYPE_BILL.equals(type)) {
116
+					wxPayService.wxBillNotify(params);
117
+				} else if (Constant.PAY_TYPE_CAR.equals(type)){
118
+					wxPayService.wxCarNotify(params);
119
+				}
120
+
102 121
 			}
103 122
 		} catch (AlipayApiException e) {
104 123
 			e.printStackTrace();
@@ -106,4 +125,5 @@ public class AliPayController {
106 125
 			e.printStackTrace();
107 126
 		}
108 127
 	}
128
+
109 129
 }

+ 47
- 17
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/WxPayController.java Wyświetl plik

@@ -70,14 +70,32 @@ public class WxPayController {
70 70
 		return responseBean;
71 71
 	}
72 72
 	
73
-	@ApiOperation(value = "手机订单支付完成后回调", notes = "手机订单支付完成后回调")
74
-	@RequestMapping(value = "/wxNotify",method = RequestMethod.POST)
75
-	public String wxNotify(HttpServletRequest request, HttpServletResponse response){
73
+	@ApiOperation(value = "手机订单支付完成后回调 物业缴费", notes = "手机订单支付完成后回调 物业缴费")
74
+	@RequestMapping(value = "/wxBillNotify",method = RequestMethod.POST)
75
+	public String wxBillNotify(HttpServletRequest request, HttpServletResponse response){
76
+		return wxNotify(request, Constant.PAY_TYPE_BILL);
77
+	}
78
+
79
+
80
+	@ApiOperation(value = "手机订单支付完成后回调 车缴费", notes = "手机订单支付完成后回调 车缴费")
81
+	@RequestMapping(value = "/wxCarNotify",method = RequestMethod.POST)
82
+	public String wxCarNotify(HttpServletRequest request, HttpServletResponse response){
83
+
84
+		return wxNotify(request, Constant.PAY_TYPE_CAR);
85
+	}
86
+
87
+	/**
88
+	 * 微信支付回调
89
+	 * @param request
90
+	 * @param type
91
+	 * @return
92
+	 */
93
+	private String wxNotify(HttpServletRequest request, String type) {
76 94
 		String failResult = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[失败]]></return_msg>" + "</xml> ";
77 95
 		String successResult = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>" + "<return_msg><![CDATA[OK]]></return_msg>" + "</xml> ";
78 96
 		InputStream inStream;
79 97
 		try {
80
-			
98
+
81 99
 			inStream = request.getInputStream();
82 100
 			ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
83 101
 			byte[] buffer = new byte[1024];
@@ -85,21 +103,27 @@ public class WxPayController {
85 103
 			while ((len = inStream.read(buffer)) != -1) {
86 104
 				outSteam.write(buffer, 0, len);
87 105
 			}
88
-			
106
+
89 107
 			// 获取微信调用我们notify_url的返回信息
90 108
 			String result = new String(outSteam.toByteArray(), "utf-8");
91 109
 			WXPayUtil.getLogger().info("wxnotify:微信支付----result----=" + result);
92
-			
110
+
93 111
 			// 关闭流
94 112
 			outSteam.close();
95 113
 			inStream.close();
96
-			
114
+
97 115
 			// xml转换为map
98 116
 			Map<String, String> resultMap = WXPayUtil.xmlToMap(result);
99 117
 			if (WXPayConstants.SUCCESS.equalsIgnoreCase(resultMap.get("result_code"))) {
100 118
 				//处理业务逻辑 修改订单状态等
101 119
 				resultMap.put("pay_type","0");
102
-				String state = wxPayService.wxNotify(resultMap);
120
+				String state = "";
121
+				if (Constant.PAY_TYPE_CAR.equals(type)) {
122
+					state = wxPayService.wxCarNotify(resultMap);
123
+				} else if (Constant.PAY_TYPE_BILL.equals(type)) {
124
+					state = wxPayService.wxBillNotify(resultMap);
125
+				}
126
+
103 127
 				if (state.equals("success")){
104 128
 					log.info("微信支付成功。。");
105 129
 					return successResult;
@@ -107,14 +131,16 @@ public class WxPayController {
107 131
 			}else{
108 132
 				return failResult;
109 133
 			}
110
-			
134
+
111 135
 		} catch (Exception e) {
112 136
 			log.error("手机支付回调通知失败",e);
113 137
 			return failResult;
114
-			
138
+
115 139
 		}
140
+
116 141
 		return failResult;
117 142
 	}
143
+
118 144
 	
119 145
 	@ApiOperation(value = "订单查询", notes = "订单查询")
120 146
 	@ApiImplicitParams({
@@ -137,17 +163,20 @@ public class WxPayController {
137 163
 	
138 164
 	@ApiOperation(value = "准备开始支付", notes = "准备开始支付")
139 165
 	@ApiImplicitParams({
140
-			@ApiImplicitParam(paramType = "body", dataType = "Integer", name = "billInvoiceIdList", value = "账单Id集合"),
166
+			@ApiImplicitParam(paramType = "body", dataType = "String", name = "parameter", value = "idArray:账单Id集合, type: 类型(car 车缴费, bill 物业缴费), extensionMonth: 延期月份,也就是延期几个月!只有在 车缴费的时候才有效"),
141 167
 			@ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
142 168
 	})
143 169
 	@RequestMapping(value = "/wxStartPay",method = RequestMethod.POST)
144
-	public ResponseBean wxStartPay(@RequestBody String billInvoiceIdList, HttpSession session){
170
+	public ResponseBean wxStartPay(@RequestBody String parameter, HttpSession session){
145 171
 		ResponseBean responseBean = new ResponseBean();
146 172
 		try {
147 173
 			UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
148
-			 Integer[] integers = JSONObject.parseArray(billInvoiceIdList).toArray(new Integer[]{});
174
+			JSONObject jsonObject = JSONObject.parseObject(parameter);
175
+			Integer[] integers = jsonObject.getJSONArray("idArray").toArray(new Integer[]{});
176
+			String type = jsonObject.getString("type");
177
+			Integer extensionMonth = jsonObject.getInteger("extensionMonth");
149 178
 
150
-			String outTradeNo = wxPayService.wxStartPay( Arrays.asList(integers), userElement);
179
+			String outTradeNo = wxPayService.wxStartPay(Arrays.asList(integers), type, extensionMonth,userElement);
151 180
 			Map<String,Object> resultMap = Maps.newHashMap();
152 181
 			resultMap.put("outTradeNo", outTradeNo);
153 182
 			responseBean.addSuccess(resultMap);
@@ -161,15 +190,16 @@ public class WxPayController {
161 190
 	
162 191
 	@ApiOperation(value = "取消支付", notes = "取消支付")
163 192
 	@ApiImplicitParams({
164
-			@ApiImplicitParam(paramType = "path", dataType = "Integer", name = "outTradeNo", value = "订单号"),
193
+			@ApiImplicitParam(paramType = "path", dataType = "String", name = "outTradeNo", value = "订单号"),
194
+			@ApiImplicitParam(paramType = "form", dataType = "String", name = "outTradeNo", value = "type: 类型(car 车缴费, bill 物业缴费)"),
165 195
 			@ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token")
166 196
 	})
167 197
 	@RequestMapping(value = "/wxCancelPay/{outTradeNo}",method = RequestMethod.POST)
168
-	public ResponseBean wxCancelPay(@PathVariable("outTradeNo") String outTradeNo, HttpSession session){
198
+	public ResponseBean wxCancelPay(@PathVariable("outTradeNo") String outTradeNo, @RequestParam("type") String type,HttpSession session){
169 199
 		ResponseBean responseBean = new ResponseBean();
170 200
 		try {
171 201
 			UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
172
-			wxPayService.wxCancelPay(outTradeNo,userElement);
202
+			wxPayService.wxCancelPay(outTradeNo, type,userElement);
173 203
 		} catch (Exception e) {
174 204
 			e.printStackTrace();
175 205
 			responseBean.addError(e.getMessage());

+ 9
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TaUserLicenseOrderMapper.java Wyświetl plik

@@ -29,4 +29,13 @@ public interface TaUserLicenseOrderMapper {
29 29
     @ResultMap("BaseResultMap")
30 30
     @Select("select * from ta_user_license_order where community_id = #{communityId} and ta_user_id = #{userId} and order_status = 1")
31 31
     List<TaUserLicenseOrder> selectRecords(@Param("communityId") Integer communityId, @Param("userId") Integer userId);
32
+
33
+    /**
34
+     * 根据订单号查询
35
+     * @param orderNo
36
+     * @return
37
+     */
38
+    @ResultMap("BaseResultMap")
39
+    @Select("select * from ta_user_license_order where order_number=#{orderNo}")
40
+    List<TaUserLicenseOrder> selectByOrderNumber(String orderNo);
32 41
 }

+ 3
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpBillInvoice.java Wyświetl plik

@@ -47,7 +47,7 @@ public class TpBillInvoice {
47 47
     /**
48 48
      * 转换后金额,用于支付
49 49
      */
50
-    private String sumPayPrice;
50
+    private Double sumPayPrice;
51 51
 
52 52
     public Integer getId() {
53 53
         return id;
@@ -193,11 +193,11 @@ public class TpBillInvoice {
193 193
         this.payType = payType;
194 194
     }
195 195
 
196
-    public String getSumPayPrice() {
196
+    public Double getSumPayPrice() {
197 197
         return sumPayPrice;
198 198
     }
199 199
 
200
-    public void setSumPayPrice(String sumPayPrice) {
200
+    public void setSumPayPrice(Double sumPayPrice) {
201 201
         this.sumPayPrice = sumPayPrice;
202 202
     }
203 203
 }

+ 3
- 3
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpBillOrder.java Wyświetl plik

@@ -35,7 +35,7 @@ public class TpBillOrder {
35 35
     /**
36 36
      * 订单总额
37 37
      */
38
-    private String sumPrice;
38
+    private Double sumPrice;
39 39
 
40 40
     /**
41 41
      * 缴费单集合
@@ -138,11 +138,11 @@ public class TpBillOrder {
138 138
         this.billList = billList;
139 139
     }
140 140
 
141
-    public String getSumPrice() {
141
+    public Double getSumPrice() {
142 142
         return sumPrice;
143 143
     }
144 144
 
145
-    public void setSumPrice(String sumPrice) {
145
+    public void setSumPrice(Double sumPrice) {
146 146
         this.sumPrice = sumPrice;
147 147
     }
148 148
 }

+ 2
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/AliPayServiceI.java Wyświetl plik

@@ -9,8 +9,9 @@ public interface AliPayServiceI {
9 9
 	 * 微信支付统一下单
10 10
 	 * @return
11 11
 	 * @param outTradeNo
12
+	 * @param type  类型(car 车缴费, bill 物业缴费)
12 13
 	 * @param userElement
13 14
 	 */
14
-	String AliPayOrder(String outTradeNo, UserElement userElement) throws Exception;
15
+	String AliPayOrder(String outTradeNo, String type, UserElement userElement) throws Exception;
15 16
 	
16 17
 }

+ 7
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/ITaUserLicenseService.java Wyświetl plik

@@ -16,6 +16,13 @@ public interface ITaUserLicenseService {
16 16
      */
17 17
     ResponseBean associatedLicense(UserElement userElement, String carNo);
18 18
 
19
+    /**
20
+     * 用户查询车牌
21
+     * @param carNo
22
+     * @return
23
+     */
24
+    ResponseBean getLicense(UserElement userElement, String carNo);
25
+
19 26
     /**
20 27
      * 获取用户所有车牌
21 28
      * @param userElement

+ 25
- 5
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/WxPayServiceI.java Wyświetl plik

@@ -16,11 +16,11 @@ public interface WxPayServiceI {
16 16
 	Map<String, String> wxUnifiedOrder(String outTradeNo, String type, UserElement userElement) throws Exception;
17 17
 	
18 18
 	/**
19
-	 * 支付成功的回调
19
+	 * 支付成功的回调 物业缴费
20 20
 	 * @return
21 21
 	 * @param resultMap
22 22
 	 */
23
-	String wxNotify(Map<String, String> resultMap) throws Exception;
23
+	String wxBillNotify(Map<String, String> resultMap) throws Exception;
24 24
 	
25 25
 	/**
26 26
 	 * 订单查询
@@ -30,16 +30,36 @@ public interface WxPayServiceI {
30 30
 	
31 31
 	/**
32 32
 	 * 准备支付
33
-	 * @param billInvoiceIdArray
33
+	 * @param idArray 账单的id
34 34
 	 * @param userElement
35
+	 * @param type 订单类型  car 车缴费 , bill 物业缴费
36
+	 * @param extensionMonth 延期月份,也就是延期几个月!
37
+	 *                        	只有在 车缴费的时候才有效
35 38
 	 * @throws Exception
36 39
 	 */
37
-	String wxStartPay(List<Integer> billInvoiceIdArray, UserElement userElement) throws Exception;
40
+	String wxStartPay(List<Integer> idArray, String type,  Integer extensionMonth, UserElement userElement) throws Exception;
38 41
 	
39 42
 	/**
40 43
 	 * 取消支付
41 44
 	 * @param outTradeNo 订单号
45
+	 * @param type  订单类型  car 车缴费 , bill 物业缴费
42 46
 	 * @param userElement
43 47
 	 */
44
-	void wxCancelPay(String outTradeNo, UserElement userElement) throws Exception;
48
+	void wxCancelPay(String outTradeNo, String type, UserElement userElement) throws Exception;
49
+
50
+	/**
51
+	 * 支付成功的回调 车缴费
52
+	 * @param resultMap
53
+	 * @return
54
+	 */
55
+	String wxCarNotify(Map<String, String> resultMap);
56
+
57
+	/**
58
+	 * 根据订单类型获取 金额 和 回调地址
59
+	 * @param type
60
+	 * @param orderNo
61
+	 * @return
62
+	 * @throws Exception
63
+	 */
64
+	Map<String,Object> getOrderPriceAndNotifyUrl(String type, String orderNo) throws Exception;
45 65
 }

+ 12
- 16
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/AliPayServiceImpl.java Wyświetl plik

@@ -6,6 +6,7 @@ import com.alipay.api.DefaultAlipayClient;
6 6
 import com.alipay.api.domain.AlipayTradeAppPayModel;
7 7
 import com.alipay.api.request.AlipayTradeAppPayRequest;
8 8
 import com.alipay.api.response.AlipayTradeAppPayResponse;
9
+import com.community.commom.constant.Constant;
9 10
 import com.community.commom.session.UserElement;
10 11
 import com.community.huiju.common.perproties.PayNotifyPerproties;
11 12
 import com.community.huiju.common.wxpay.HfWxConfig;
@@ -18,6 +19,7 @@ import com.community.huiju.model.TaUser;
18 19
 import com.community.huiju.model.TpBillInvoice;
19 20
 import com.community.huiju.model.TpBillOrder;
20 21
 import com.community.huiju.service.AliPayServiceI;
22
+import com.community.huiju.service.WxPayServiceI;
21 23
 import org.apache.commons.collections.CollectionUtils;
22 24
 import org.slf4j.Logger;
23 25
 import org.slf4j.LoggerFactory;
@@ -28,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
28 30
 
29 31
 import java.math.BigDecimal;
30 32
 import java.util.List;
33
+import java.util.Map;
31 34
 
32 35
 import static com.alipay.api.AlipayConstants.CHARSET_UTF8;
33 36
 
@@ -68,7 +71,8 @@ public class AliPayServiceImpl implements AliPayServiceI {
68 71
 	private String ALIPAY_PUBLIC_KEY;
69 72
 
70 73
 	@Autowired
71
-	private PayNotifyPerproties payNotifyPerproties;
74
+	private WxPayServiceI wxPayServiceI;
75
+
72 76
 
73 77
 	/**
74 78
 	 * 支付宝统一下单
@@ -79,18 +83,10 @@ public class AliPayServiceImpl implements AliPayServiceI {
79 83
 	 */
80 84
 	@Override
81 85
 	@Transactional(rollbackFor = Exception.class)
82
-	public String AliPayOrder(String outTradeNo, UserElement userElement) throws Exception {
83
-		Integer userId = userElement.getId();
84
-
85
-		//获取支付金额
86
-		List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByOrderBumber(outTradeNo);
87
-		if (CollectionUtils.isEmpty(billOrderList)){
88
-			throw new Exception("订单不存在");
89
-		}
90
-
91
-		// 计算金额
92
-		Integer payPrice = billOrderList.stream().mapToInt(e -> tpBillInvoiceMapper.selectByPrimaryKey(e.getTpBillInvoiceId()).getPayPrice()).sum();
86
+	public String AliPayOrder(String outTradeNo, String type, UserElement userElement) throws Exception {
93 87
 
88
+		String typeName = Constant.PAY_TYPE_BILL.equals(type) ? "物业缴费" : Constant.PAY_TYPE_CAR.equals(type) ? "车缴费" : "缴费";
89
+		Map<String, Object> orderPriceAndNotifyUrl = wxPayServiceI.getOrderPriceAndNotifyUrl(type, outTradeNo);
94 90
 		
95 91
 		//下单
96 92
 		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", ALI_APP_ID, APP_PRIVATE_KEY, "json", CHARSET_UTF8, ALIPAY_PUBLIC_KEY, "RSA2");
@@ -98,14 +94,14 @@ public class AliPayServiceImpl implements AliPayServiceI {
98 94
 		AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
99 95
 		//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
100 96
 		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
101
-		model.setBody("缴费");
102
-		model.setSubject("缴费");
97
+		model.setBody(typeName);
98
+		model.setSubject(typeName);
103 99
 		model.setOutTradeNo(outTradeNo);
104 100
 		model.setTimeoutExpress("30m");
105
-		model.setTotalAmount(BigDecimal.valueOf(Long.valueOf(payPrice)).divide(new BigDecimal(100)).toString());
101
+		model.setTotalAmount(BigDecimal.valueOf(Long.valueOf(String.valueOf(orderPriceAndNotifyUrl.get("payPrice")))).divide(new BigDecimal(100)).toString());
106 102
 		model.setProductCode("QUICK_MSECURITY_PAY");
107 103
 		request.setBizModel(model);
108
-		request.setNotifyUrl(payNotifyPerproties.getAliBillNotify());
104
+		request.setNotifyUrl(String.valueOf(orderPriceAndNotifyUrl.get("notifyUrl")));
109 105
 		try {
110 106
 			//这里和普通的接口调用不同,使用的是sdkExecute
111 107
 			AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);

+ 6
- 6
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/BillServiceImpl.java Wyświetl plik

@@ -71,7 +71,7 @@ public class BillServiceImpl implements BillServiceI {
71 71
 		List<Map<String,Object>> billsList = tpBillInvoiceMapper.getBillsList(userElement.getCommunityId(), userElement.getRoomNoId(), payType);
72 72
 		billsList.forEach(e-> {
73 73
 			String payPrice = String.valueOf(e.get("payPrice"));
74
-			String payPriceDouble = BigDecimal.valueOf(Long.valueOf(payPrice)).divide(new BigDecimal(100)).toString();
74
+			Double payPriceDouble = Double.valueOf(payPrice) / 100;
75 75
 			e.put("payPrice", payPriceDouble);
76 76
 		});
77 77
 		Map<String,Object> result = Maps.newHashMap();
@@ -89,7 +89,7 @@ public class BillServiceImpl implements BillServiceI {
89 89
 	public Map<String, Object> getBillInvoiceDetail(Integer communityId,Integer billInvoiceId) {
90 90
 		Map<String, Object> billInvoiceDetail = tpBillInvoiceMapper.getBillInvoiceDetail(communityId, billInvoiceId);
91 91
 		String payPrice = String.valueOf(billInvoiceDetail.get("payPrice"));
92
-		String payPriceDouble = BigDecimal.valueOf(Long.valueOf(payPrice)).divide(new BigDecimal(100)).toString();
92
+		Double payPriceDouble = Double.valueOf(payPrice) / 100;
93 93
 		billInvoiceDetail.put("payPrice", payPriceDouble);
94 94
 		return billInvoiceDetail;
95 95
 	}
@@ -110,10 +110,10 @@ public class BillServiceImpl implements BillServiceI {
110 110
 
111 111
 			// 缴费组
112 112
 			List<TpBillInvoice> tpBillInvoices = orderList.stream().map(billOrder -> tpBillInvoiceMapper.selectByIdBillInvoiceInfo(billOrder.getTpBillInvoiceId())).collect(Collectors.toList());
113
-			tpBillInvoices.forEach( billInvoice -> billInvoice.setSumPayPrice(BigDecimal.valueOf(Long.valueOf(billInvoice.getPayPrice())).divide(new BigDecimal(100)).toString()));
113
+			tpBillInvoices.forEach( billInvoice -> billInvoice.setSumPayPrice(Double.valueOf(billInvoice.getPayPrice() + "") / 100));
114 114
 
115 115
 			// 所有缴费组的总额
116
-			String billCountPrice = BigDecimal.valueOf(Long.valueOf(tpBillInvoices.stream().map(billCount -> billCount.getPayPrice()).count())).divide(new BigDecimal(100)).toString();
116
+			Double billCountPrice = Double.valueOf(tpBillInvoices.stream().map(billCount -> billCount.getPayPrice()).count() + "") / 100;
117 117
 
118 118
 
119 119
 			e.setBillList(tpBillInvoices);
@@ -143,10 +143,10 @@ public class BillServiceImpl implements BillServiceI {
143 143
 		}
144 144
 		// 每个缴费单数据
145 145
 		List<TpBillInvoice> tpBillInvoices = billOrderList.stream().map(e -> tpBillInvoiceMapper.selectByIdBillInvoiceInfo(e.getTpBillInvoiceId())).collect(Collectors.toList());
146
-		tpBillInvoices.forEach(e -> e.setSumPayPrice(BigDecimal.valueOf(Long.valueOf(e.getPayPrice())).divide(new BigDecimal(100)).toString()));
146
+		tpBillInvoices.forEach(e -> e.setSumPayPrice(Double.valueOf(e.getPayPrice() + "") / 100));
147 147
 
148 148
 		// 这个订单总额
149
-		String billCountPrice = BigDecimal.valueOf(Long.valueOf(tpBillInvoices.stream().map(e -> e.getPayPrice()).count())).divide(new BigDecimal(100)).toString();
149
+		Double billCountPrice = Double.valueOf(tpBillInvoices.stream().map(e -> e.getPayPrice()).count() + "") / 100;
150 150
 
151 151
 		// 因为订单号是多条,取第一条即可
152 152
 		TpBillOrder tpBillOrder = billOrderList.get(0);

+ 32
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/TaUserLicenseServiceImpl.java Wyświetl plik

@@ -10,6 +10,7 @@ import com.community.huiju.service.ITaUserLicenseService;
10 10
 import lombok.extern.slf4j.Slf4j;
11 11
 import org.springframework.beans.factory.annotation.Autowired;
12 12
 import org.springframework.stereotype.Service;
13
+import org.springframework.transaction.annotation.Transactional;
13 14
 
14 15
 import java.math.BigDecimal;
15 16
 import java.text.ParseException;
@@ -35,6 +36,7 @@ public class TaUserLicenseServiceImpl implements ITaUserLicenseService {
35 36
     private IFuShiService iFuShiService;
36 37
 
37 38
     @Override
39
+    @Transactional(rollbackFor = Exception.class)
38 40
     public ResponseBean associatedLicense(UserElement userElement, String carNo) {
39 41
         ResponseBean responseBean = new ResponseBean();
40 42
 
@@ -55,11 +57,14 @@ public class TaUserLicenseServiceImpl implements ITaUserLicenseService {
55 57
         if (null == taUserLicense.getId()) {
56 58
             rows = taUserLicenseMapper.insertSelective(taUserLicense);
57 59
         } else {
60
+            taUserLicense.setUpdateUser(userElement.getId());
61
+            taUserLicense.setUpdateDate(new Date());
58 62
             rows = taUserLicenseMapper.updateByPrimaryKeySelective(taUserLicense);
59 63
         }
60 64
 
61 65
 
62 66
         if (rows > 0) {
67
+            taUserLicense.setUnitPrice(String.valueOf(Double.valueOf(taUserLicense.getUnitPrice()) / 100));
63 68
             responseBean.addSuccess(taUserLicense);
64 69
             return responseBean;
65 70
         }
@@ -68,8 +73,24 @@ public class TaUserLicenseServiceImpl implements ITaUserLicenseService {
68 73
         return responseBean;
69 74
     }
70 75
 
76
+    @Override
77
+    @Transactional(rollbackFor = Exception.class)
78
+    public ResponseBean getLicense(UserElement userElement, String carNo) {
79
+        ResponseBean responseBean = new ResponseBean();
80
+        TaUserLicense taUserLicense = taUserLicenseMapper.selectByUserIdAndCommunityIdAndLicensePlate(userElement.getCommunityId(), userElement.getId(), carNo);
81
+        if (null != taUserLicense) {
82
+            taUserLicense = getTaUserLicense(carNo, taUserLicense);
83
+            taUserLicense.setUpdateUser(userElement.getId());
84
+            taUserLicense.setUpdateDate(new Date());
85
+            taUserLicenseMapper.updateByPrimaryKeySelective(taUserLicense);
86
+        }
87
+
88
+        responseBean.addSuccess(taUserLicense);
89
+        return responseBean;
90
+    }
71 91
 
72 92
     @Override
93
+    @Transactional(rollbackFor = Exception.class)
73 94
     public ResponseBean getAllUserLicense(UserElement userElement) {
74 95
         ResponseBean responseBean = new ResponseBean();
75 96
         List<TaUserLicense> taUserLicenses = taUserLicenseMapper.selectAllByCommunityIdAndUserId(userElement.getCommunityId(), userElement.getId());
@@ -79,7 +100,10 @@ public class TaUserLicenseServiceImpl implements ITaUserLicenseService {
79 100
 
80 101
         taUserLicenses = taUserLicenses.stream().map(e-> {
81 102
             TaUserLicense taUserLicense = getTaUserLicense(e.getLicensePlate(), e);
103
+            taUserLicense.setUpdateUser(userElement.getId());
104
+            taUserLicense.setUpdateDate(new Date());
82 105
             taUserLicenseMapper.updateByPrimaryKeySelective(taUserLicense);
106
+            taUserLicense.setUnitPrice(String.valueOf(Double.valueOf(taUserLicense.getUnitPrice()) / 100));
83 107
             return taUserLicense;
84 108
         }).collect(Collectors.toList());
85 109
 
@@ -105,10 +129,16 @@ public class TaUserLicenseServiceImpl implements ITaUserLicenseService {
105 129
 
106 130
         // 获取到的车牌信息
107 131
         Map<String,Object> map = (Map<String,Object>)resultCar;
132
+        Integer dataType = (Integer) map.get("DataType");
133
+        if (dataType.intValue() != 1) {
134
+            throw new WisdomException("该车牌不是月租车!");
135
+        }
136
+
108 137
         Map<String,Object> jsonParam = (Map<String, Object>) map.get("JsonParam");
109 138
 
110 139
         taUserLicense.setLicensePlate(carNo);
111
-        taUserLicense.setUnitPrice(BigDecimal.valueOf(Long.valueOf(String.valueOf(jsonParam.get("Cost")))).multiply(new BigDecimal(100)).toString());
140
+        String price = String.valueOf(Double.valueOf(((BigDecimal) jsonParam.get("Cost")).toString()) * 100);
141
+        taUserLicense.setUnitPrice(price.substring(0, price.lastIndexOf(".")));
112 142
         taUserLicense.setCreateDate(new Date());
113 143
         taUserLicense.setParkingLot(String.valueOf(jsonParam.get("ParkingName")));
114 144
 
@@ -123,6 +153,7 @@ public class TaUserLicenseServiceImpl implements ITaUserLicenseService {
123 153
     }
124 154
 
125 155
     @Override
156
+    @Transactional(rollbackFor = Exception.class)
126 157
     public ResponseBean deleteUserLicense(UserElement userElement, Integer licenseId) {
127 158
         ResponseBean responseBean = new ResponseBean();
128 159
 

+ 249
- 60
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/WxPayServiceImpl.java Wyświetl plik

@@ -1,5 +1,7 @@
1 1
 package com.community.huiju.service.impl;
2 2
 
3
+import com.community.commom.constant.Constant;
4
+import com.community.commom.mode.ResponseBean;
3 5
 import com.community.commom.session.UserElement;
4 6
 import com.community.huiju.common.perproties.PayNotifyPerproties;
5 7
 import com.community.huiju.common.wxpay.HfWxConfig;
@@ -9,17 +11,23 @@ import com.community.huiju.common.wxpay.WXPayUtil;
9 11
 import com.community.huiju.dao.*;
10 12
 import com.community.huiju.exception.WisdomException;
11 13
 import com.community.huiju.model.*;
14
+import com.community.huiju.service.IFuShiService;
15
+import com.community.huiju.service.ITaUserLicenseService;
12 16
 import com.community.huiju.service.WxPayServiceI;
13 17
 import com.google.common.collect.Lists;
14 18
 import com.google.common.collect.Maps;
15 19
 import org.apache.commons.collections.CollectionUtils;
20
+import org.apache.commons.lang.StringUtils;
16 21
 import org.slf4j.Logger;
17 22
 import org.slf4j.LoggerFactory;
18 23
 import org.springframework.beans.factory.annotation.Autowired;
19 24
 import org.springframework.stereotype.Service;
20 25
 import org.springframework.transaction.annotation.Transactional;
21 26
 
27
+import java.math.BigDecimal;
22 28
 import java.time.Instant;
29
+import java.time.LocalDateTime;
30
+import java.time.ZoneId;
23 31
 import java.util.*;
24 32
 import java.util.concurrent.atomic.AtomicReference;
25 33
 import java.util.stream.Collectors;
@@ -63,6 +71,19 @@ public class WxPayServiceImpl implements WxPayServiceI {
63 71
 	@Autowired
64 72
 	private PayNotifyPerproties payNotifyPerproties;
65 73
 
74
+	@Autowired
75
+	private TaUserLicenseOrderMapper taUserLicenseOrderMapper;
76
+
77
+	@Autowired
78
+	private IFuShiService iFuShiService;
79
+
80
+	@Autowired
81
+	private TaUserLicenseMapper taUserLicenseMapper;
82
+
83
+	@Autowired
84
+	private ITaUserLicenseService iTaUserLicenseService;
85
+
86
+
66 87
 	/**
67 88
 	 * 微信支付统一下单
68 89
 	 *
@@ -78,9 +99,11 @@ public class WxPayServiceImpl implements WxPayServiceI {
78 99
 
79 100
 		Map<String, Object> orderPriceAndNotifyUrl = getOrderPriceAndNotifyUrl(type, orderNo);
80 101
 
102
+		String typeName = Constant.PAY_TYPE_BILL.equals(type) ? "物业缴费" : Constant.PAY_TYPE_CAR.equals(type) ? "车缴费" : "缴费";
103
+
81 104
 		//下单
82 105
 		Map<String, String> data = new HashMap<String, String>();
83
-		data.put("body", "缴费");
106
+		data.put("body", typeName);
84 107
 		//商品号唯一
85 108
 		data.put("out_trade_no", orderNo);
86 109
 		data.put("device_info", "");
@@ -111,15 +134,10 @@ public class WxPayServiceImpl implements WxPayServiceI {
111 134
 		secondSignData.put("package", "Sign=WXPay");
112 135
 		secondSignData.put("sign", WXPayUtil.generateSignature(secondSignData, config.getKey(), WXPayConstants.SignType.MD5));
113 136
 
114
-		log.info("订单: {}, 状态变更为正在支付", orderNo);
137
+		log.info("订单: {},订单类型: {}, 状态变更为正在支付", orderNo, type);
115 138
 
116 139
 		// 更改订单状态 为正在支付
117
-		List<TpBillOrder> billOrders = tpBillOrderMapper.selectByOrderBumber(orderNo);
118
-		billOrders.forEach(e-> {
119
-			e.setOrderStatus("3");
120
-			tpBillOrderMapper.updateByPrimaryKeySelective(e);
121
-		});
122
-
140
+		updateOrderStatus(orderNo, type, "2");
123 141
 		return secondSignData;
124 142
 	}
125 143
 
@@ -130,11 +148,12 @@ public class WxPayServiceImpl implements WxPayServiceI {
130 148
 	 * @return
131 149
 	 * @throws Exception
132 150
 	 */
133
-	private Map<String,Object> getOrderPriceAndNotifyUrl(String type, String orderNo) throws Exception {
151
+	@Override
152
+	public Map<String,Object> getOrderPriceAndNotifyUrl(String type, String orderNo) throws Exception {
134 153
 		Map<String,Object> orderMap = Maps.newHashMap();
135 154
 
136 155
 		// 物业缴费
137
-		if ("bill".equals(type)) {
156
+		if (Constant.PAY_TYPE_BILL.equals(type)) {
138 157
 			//获取支付金额
139 158
 			List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByOrderBumber(orderNo);
140 159
 			if (CollectionUtils.isEmpty(billOrderList)){
@@ -147,20 +166,36 @@ public class WxPayServiceImpl implements WxPayServiceI {
147 166
 				}
148 167
 			});
149 168
 			// 计算金额
150
-			Integer payPrice = billOrderList.stream().mapToInt(e -> tpBillInvoiceMapper.selectByPrimaryKey(e.getTpBillInvoiceId()).getPayPrice()).sum();
151
-
169
+			Long payPrice = billOrderList.stream().mapToLong(e -> tpBillInvoiceMapper.selectByPrimaryKey(e.getTpBillInvoiceId()).getPayPrice()).sum();
152 170
 			orderMap.put("orderNo", orderNo);
153 171
 			orderMap.put("payPrice", String.valueOf(payPrice));
154 172
 			orderMap.put("notifyUrl", payNotifyPerproties.getWxBillNotify());
155 173
 
156
-		} else if ("car".equals(type)) {
174
+		} else if (Constant.PAY_TYPE_CAR.equals(type)) { // 车缴费
175
+			List<TaUserLicenseOrder> userLicenseOrders = taUserLicenseOrderMapper.selectByOrderNumber(orderNo);
176
+			if (CollectionUtils.isEmpty(userLicenseOrders)) {
177
+				throw new Exception("订单不存在");
178
+			}
179
+			// 检测订单是否 已关闭
180
+			userLicenseOrders.forEach(e-> {
181
+				if ("3".equals(e.getOrderStatus())) {
182
+					throw new WisdomException("无法支付已关闭的订单!");
183
+				}
184
+			});
157 185
 
186
+			// 总额
187
+			Long payPrice = userLicenseOrders.stream().map(e -> Long.parseLong(e.getExtensionPrice())).count();
188
+			orderMap.put("orderNo", orderNo);
189
+			orderMap.put("payPrice", String.valueOf(payPrice));
190
+			orderMap.put("notifyUrl", payNotifyPerproties.getWxCarNotify());
158 191
 		}
159 192
 
160 193
 		return orderMap;
161 194
 	}
162 195
 
163 196
 
197
+
198
+
164 199
 	/**
165 200
 	 * 支付成功的回调
166 201
 	 *
@@ -169,7 +204,7 @@ public class WxPayServiceImpl implements WxPayServiceI {
169 204
 	 */
170 205
 	@Override
171 206
 	@Transactional(rollbackFor = Exception.class)
172
-	public String wxNotify(Map<String, String> resultMap) throws Exception {
207
+	public String wxBillNotify(Map<String, String> resultMap) throws Exception {
173 208
 		String outTradeNo = resultMap.get("out_trade_no");
174 209
 		List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByOrderBumber(outTradeNo);
175 210
 		if (CollectionUtils.isEmpty(billOrderList)){
@@ -227,14 +262,10 @@ public class WxPayServiceImpl implements WxPayServiceI {
227 262
 //			tpMessageMapper.updateByPrimaryKeySelective(tpMessage);
228 263
 		}
229 264
 
230
-		log.info("订单: {}, 状态变更为支付成功", outTradeNo);
265
+		log.info("订单: {},订单类型: {}, 状态变更为支付成功", outTradeNo, Constant.PAY_TYPE_BILL);
231 266
 
232 267
 		// 更改订单状态 为支付成功
233
-		List<TpBillOrder> billOrders = tpBillOrderMapper.selectByOrderBumber(outTradeNo);
234
-		billOrders.forEach(e-> {
235
-			e.setOrderStatus("1");
236
-			tpBillOrderMapper.updateByPrimaryKeySelective(e);
237
-		});
268
+		updateOrderStatus(outTradeNo, Constant.PAY_TYPE_BILL, "1");
238 269
 
239 270
 		return "success";
240 271
 	}
@@ -256,44 +287,117 @@ public class WxPayServiceImpl implements WxPayServiceI {
256 287
 	
257 288
 	@Override
258 289
 	@Transactional(rollbackFor = Exception.class)
259
-	public String wxStartPay(List<Integer> billInvoiceIdArray, UserElement userElement) throws Exception {
290
+	public String wxStartPay(List<Integer> idArray, String type, Integer extensionMonth, UserElement userElement) throws Exception {
291
+		if (StringUtils.isBlank(type)) {
292
+			throw new WisdomException("type 不能为空!");
293
+		}
260 294
 
261
-		// 如果是家属/租客, 应该用业主的用户id
295
+		// 缴费的用户
262 296
 		TaUser taUser = taUserMapper.selectByPrimaryKey(userElement.getId());
263 297
 
264 298
 		Random random = new Random();
265 299
 		String orderNo = String.valueOf(System.currentTimeMillis()) + random.nextInt();
266 300
 
267
-		//获取支付金额
268
-		for (Integer billInvoiceId : billInvoiceIdArray) {
269
-			TpBillInvoice tpBillInvoice = tpBillInvoiceMapper.selectByPrimaryKey(billInvoiceId);
270
-			if (null == tpBillInvoice){
271
-				throw new Exception("订单不存在");
272
-			}else if (!tpBillInvoice.getBillStatus().equals("0")){
273
-				throw new Exception("正在支付的订单");
301
+		// 创建订单
302
+		createOrder(idArray, type, taUser, userElement, orderNo, extensionMonth, null);
303
+
304
+		return orderNo;
305
+	}
306
+
307
+	/**
308
+	 * 创建订单
309
+	 * @param idArray
310
+	 * @param type
311
+	 * @param taUser
312
+	 * @param userElement
313
+	 * @param orderNo
314
+	 * @param extensionMonth 延期月份,也就是延期几个月!
315
+	 *                       	只有在 车缴费的时候才有效
316
+	 * @param paymentType 缴费方式 1是支付宝 2是微信支付
317
+	 * @throws Exception
318
+	 */
319
+	private void createOrder(List<Integer> idArray, String type, TaUser taUser, UserElement userElement, String orderNo, Integer extensionMonth, String paymentType) throws Exception {
320
+		// 物业缴费
321
+		if (Constant.PAY_TYPE_BILL.equals(type)) {
322
+			//获取支付金额
323
+			for (Integer billInvoiceId : idArray) {
324
+				TpBillInvoice tpBillInvoice = tpBillInvoiceMapper.selectByPrimaryKey(billInvoiceId);
325
+				if (null == tpBillInvoice){
326
+					throw new Exception("订单不存在");
327
+				}else if (!tpBillInvoice.getBillStatus().equals("0")){
328
+					throw new Exception("正在支付的订单");
329
+				}
330
+
331
+				TpBillOrder tpBillOrder = new TpBillOrder();
332
+				tpBillOrder.setCommunityId(userElement.getCommunityId());
333
+				tpBillOrder.setTpBillId(tpBillInvoice.getBillId());
334
+				tpBillOrder.setTpBillInvoiceId(tpBillInvoice.getId());
335
+				tpBillOrder.setCreateDate(new Date());
336
+				tpBillOrder.setCreateUser(userElement.getId());
337
+				tpBillOrder.setUpdateDate(new Date());
338
+				tpBillOrder.setUpdateUser(userElement.getId());
339
+				tpBillOrder.setOrderBumber(orderNo);
340
+				tpBillOrder.setPayPhone(taUser.getLoginName());
341
+				tpBillOrder.setOrderStatus("0");
342
+
343
+				tpBillOrderMapper.insertSelective(tpBillOrder);
344
+
345
+			}
346
+			// 修改缴费人, 修改为正在缴费
347
+			updateBillInvoiceBillStatus(idArray, taUser.getUserName(), "2");
348
+
349
+			// 车缴费
350
+		} else if (Constant.PAY_TYPE_CAR.equals(type)) {
351
+			if (null == extensionMonth && extensionMonth > 0) {
352
+				throw new Exception("延期月份不能为空,并且要大于0!");
274 353
 			}
275 354
 
276
-			TpBillOrder tpBillOrder = new TpBillOrder();
277
-			tpBillOrder.setCommunityId(userElement.getCommunityId());
278
-			tpBillOrder.setTpBillId(tpBillInvoice.getBillId());
279
-			tpBillOrder.setTpBillInvoiceId(tpBillInvoice.getId());
280
-			tpBillOrder.setCreateDate(new Date());
281
-			tpBillOrder.setCreateUser(userElement.getId());
282
-			tpBillOrder.setUpdateDate(new Date());
283
-			tpBillOrder.setUpdateUser(userElement.getId());
284
-			tpBillOrder.setOrderBumber(orderNo);
285
-			tpBillOrder.setPayPhone(taUser.getLoginName());
286
-			tpBillOrder.setOrderStatus("0");
355
+			for (Integer clicenseId : idArray) {
356
+				// 根据车牌id,查询车牌
357
+				TaUserLicense taUserLicense = taUserLicenseMapper.selectByPrimaryKey(clicenseId);
358
+				// 获取车牌最新信息
359
+				ResponseBean responseLicense = iTaUserLicenseService.getLicense(userElement, taUserLicense.getLicensePlate());
360
+				Object licenseData = responseLicense.getData();
361
+				if (null != licenseData && licenseData instanceof TaUserLicense) {
362
+					taUserLicense = (TaUserLicense) licenseData;
363
+				}
287 364
 
288
-			tpBillOrderMapper.insertSelective(tpBillOrder);
365
+				TaUserLicenseOrder taUserLicenseOrder = new TaUserLicenseOrder();
366
+				taUserLicenseOrder.setCommunityId(userElement.getCommunityId());
367
+				taUserLicenseOrder.setTaUserId(userElement.getId());
368
+				taUserLicenseOrder.setOrderNumber(orderNo);
369
+				taUserLicenseOrder.setOrderStatus("0");
370
+				taUserLicenseOrder.setCreateDate(new Date());
371
+				taUserLicenseOrder.setCreateUser(userElement.getId());
372
+				taUserLicenseOrder.setExtensionMonth(extensionMonth);
373
+
374
+				// 费用
375
+				String extensionPrice = BigDecimal.valueOf(Double.valueOf(taUserLicense.getUnitPrice()) / 100).multiply(BigDecimal.valueOf(extensionMonth)).toString();
376
+				String price = String.valueOf(Double.valueOf(extensionPrice) * 100);
377
+				taUserLicenseOrder.setExtensionPrice(price.substring(0, price.lastIndexOf(".")));
378
+
379
+				taUserLicenseOrder.setPaymentTel(taUser.getLoginName());
380
+				taUserLicenseOrder.setPaymentName(taUser.getUserName());
381
+				taUserLicenseOrder.setPaymentType(paymentType);
382
+
383
+				// 到期时间 (具体的到期时候,在支付回调里面以车辆管理系统为准)
384
+				LocalDateTime localDateTime = LocalDateTime.ofInstant(taUserLicense.getExpireDate().toInstant(), ZoneId.systemDefault());
385
+				localDateTime.plusMonths(extensionMonth);
386
+				taUserLicenseOrder.setExpireDate(Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()));
387
+				taUserLicenseOrder.setUnitPrice(taUserLicense.getUnitPrice());
388
+				taUserLicenseOrder.setParkingLot(taUserLicense.getParkingLot());
389
+				taUserLicenseOrder.setLicensePlate(taUserLicense.getLicensePlate());
390
+
391
+				// 插入数据
392
+				taUserLicenseOrderMapper.insertSelective(taUserLicenseOrder);
289 393
 
290
-		}
394
+			}
291 395
 
292
-		// 修改缴费人
293
-		 updateBillInvoiceBillStatus(billInvoiceIdArray, taUser.getUserName(), "3");
294
-		return orderNo;
396
+		}
295 397
 	}
296
-	
398
+
399
+
400
+
297 401
 	/**
298 402
 	 * 取消支付
299 403
 	 *
@@ -302,7 +406,19 @@ public class WxPayServiceImpl implements WxPayServiceI {
302 406
 	 */
303 407
 	@Override
304 408
 	@Transactional(rollbackFor = Exception.class)
305
-	public void wxCancelPay(String outTradeNo, UserElement userElement) throws Exception {
409
+	public void wxCancelPay(String outTradeNo, String type, UserElement userElement) throws Exception {
410
+
411
+		/**
412
+		 * 如果是车缴费订单,就只直接更新 订单状态为关闭
413
+		 */
414
+		// 如果是车缴费
415
+		if (Constant.PAY_TYPE_CAR.equals(type)) {
416
+			// 更改订单状态 为订单已关闭
417
+			updateOrderStatus(outTradeNo, type, "3");
418
+			return;
419
+		}
420
+
421
+		// --------------------------- 物业缴费 --------------------------------
306 422
 
307 423
 		//获取支付金额
308 424
 		List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByOrderBumber(outTradeNo);
@@ -313,7 +429,7 @@ public class WxPayServiceImpl implements WxPayServiceI {
313 429
 		List<TpBillInvoice> billInvoiceList = Lists.newArrayList();
314 430
 		for (TpBillOrder tpBillOrder : billOrderList) {
315 431
 			TpBillInvoice billInvoice = tpBillInvoiceMapper.selectByPrimaryKey(tpBillOrder.getTpBillInvoiceId());
316
-			if (!billInvoice.getBillStatus().equals("3")){
432
+			if (!billInvoice.getBillStatus().equals("2")){
317 433
 				throw new Exception("不是正在支付的订单");
318 434
 			}
319 435
 			billInvoiceList.add(billInvoice);
@@ -324,25 +440,74 @@ public class WxPayServiceImpl implements WxPayServiceI {
324 440
 
325 441
 		//更新为 未支付状态
326 442
 		updateBillInvoiceBillStatus(billInvoiceIdList, "","0");
327
-		log.info("订单: {}, 状态变更为取消支付", outTradeNo);
443
+		log.info("订单: {}, 订单类型: {}, 状态变更为取消支付", outTradeNo, type);
328 444
 
329 445
 		// 更改订单状态 为订单已关闭
330
-		List<TpBillOrder> billOrders = tpBillOrderMapper.selectByOrderBumber(outTradeNo);
331
-		billOrders.forEach(e-> {
332
-			e.setOrderStatus("3");
333
-			tpBillOrderMapper.updateByPrimaryKeySelective(e);
446
+		updateOrderStatus(outTradeNo, type, "3");
447
+
448
+	}
449
+
450
+	@Override
451
+	public String wxCarNotify(Map<String, String> resultMap) {
452
+
453
+		String outTradeNo = resultMap.get("out_trade_no");
454
+		String pay_type = resultMap.get("pay_type");
455
+		String payTypeName = pay_type.equals("0") ? "微信支付" : pay_type.equals("2") ? "支付宝" : "未知";
456
+
457
+		List<TaUserLicenseOrder> userLicenseOrderList = taUserLicenseOrderMapper.selectByOrderNumber(outTradeNo);
458
+		if (CollectionUtils.isEmpty(userLicenseOrderList)){
459
+			return "不存在的订单";
460
+		}
461
+
462
+		userLicenseOrderList.forEach(e-> {
463
+			e.setPaymentType(pay_type);
464
+			UserElement userElement = new UserElement();
465
+			userElement.setCommunityId(e.getCommunityId());
466
+			userElement.setId(e.getTaUserId());
467
+			ResponseBean responseLicense = iTaUserLicenseService.getLicense(userElement, e.getLicensePlate());
468
+			Object licenseData = responseLicense.getData();
469
+			TaUserLicense taUserLicense = null;
470
+			if (null != licenseData && licenseData instanceof TaUserLicense) {
471
+				taUserLicense = (TaUserLicense) licenseData;
472
+			}
473
+
474
+			e.setExpireDate(taUserLicense.getExpireDate());
475
+
476
+			taUserLicenseOrderMapper.updateByPrimaryKeySelective(e);
477
+
334 478
 		});
479
+
480
+
481
+		log.info("订单: {},订单类型: {}, 状态变更为支付成功", outTradeNo, Constant.PAY_TYPE_CAR);
482
+
483
+		// 更改订单状态 为支付成功
484
+		updateOrderStatus(outTradeNo, Constant.PAY_TYPE_CAR, "1");
485
+
486
+		log.info("订单:{},订单类型: {} 开始推送到 车辆管理系统 ", outTradeNo, Constant.PAY_TYPE_CAR);
487
+
488
+		TaUserLicenseOrder taUserLicenseOrder = userLicenseOrderList.get(0);
489
+
490
+		TaUser taUser = taUserMapper.selectByPrimaryKey(taUserLicenseOrder.getTaUserId());
491
+
492
+
493
+		// 推送到车辆管理系统
494
+		iFuShiService.apiThirdPartyMonthCardPay(taUser.getLoginName(), "2",
495
+								String.valueOf(taUserLicenseOrder.getExtensionMonth()),
496
+								payTypeName, taUserLicenseOrder.getLicensePlate(),
497
+								null, String.valueOf(Double.valueOf(taUserLicenseOrder.getExtensionPrice()) / 100));
498
+
499
+		return "success";
335 500
 	}
336
-	
501
+
337 502
 	/**
338 503
 	 * 更新支付状态
339 504
 	 * @param billInvoiceIdList
340
-	 * @param billStatus
505
+	 * @param status
341 506
 	 */
342
-	private void updateBillInvoiceBillStatus(List<Integer> billInvoiceIdList, String billStatus) {
507
+	private void updateBillInvoiceBillStatus(List<Integer> billInvoiceIdList, String status) {
343 508
 		billInvoiceIdList.forEach(e -> {
344 509
 			TpBillInvoice tpBillInvoiceUpdate = new TpBillInvoice();
345
-			tpBillInvoiceUpdate.setBillStatus(billStatus);
510
+			tpBillInvoiceUpdate.setBillStatus(status);
346 511
 			tpBillInvoiceUpdate.setId(e);
347 512
 			tpBillInvoiceMapper.updateByPrimaryKeySelective(tpBillInvoiceUpdate);
348 513
 		});
@@ -353,16 +518,40 @@ public class WxPayServiceImpl implements WxPayServiceI {
353 518
 	 * 更新支付状态
354 519
 	 * @param billInvoiceIdList
355 520
 	 * @param userName 缴费人
356
-	 * @param billStatus
521
+	 * @param status
357 522
 	 */
358
-	private void updateBillInvoiceBillStatus(List<Integer> billInvoiceIdList, String userName, String billStatus) {
523
+	private void updateBillInvoiceBillStatus(List<Integer> billInvoiceIdList, String userName, String status) {
359 524
 		billInvoiceIdList.forEach(e -> {
360 525
 			TpBillInvoice tpBillInvoiceUpdate = new TpBillInvoice();
361
-			tpBillInvoiceUpdate.setBillStatus(billStatus);
526
+			tpBillInvoiceUpdate.setBillStatus(status);
362 527
 			tpBillInvoiceUpdate.setId(e);
363 528
 			tpBillInvoiceUpdate.setPayName(userName);
364 529
 			tpBillInvoiceMapper.updateByPrimaryKeySelective(tpBillInvoiceUpdate);
365 530
 		});
531
+	}
366 532
 
533
+	/**
534
+	 * 更改订单状态
535
+	 * @param orderNumber
536
+	 * @param type
537
+	 * @param status
538
+	 */
539
+	private void updateOrderStatus(String orderNumber, String type, String status){
540
+		// 物业缴费
541
+		if (Constant.PAY_TYPE_BILL.equals(type)) {
542
+			List<TpBillOrder> billOrders = tpBillOrderMapper.selectByOrderBumber(orderNumber);
543
+			billOrders.forEach(e-> {
544
+				e.setOrderStatus(status);
545
+				tpBillOrderMapper.updateByPrimaryKeySelective(e);
546
+			});
547
+
548
+			// 车缴费
549
+		} else if (Constant.PAY_TYPE_CAR.equals(type)) {
550
+			List<TaUserLicenseOrder> taUserLicenseOrders = taUserLicenseOrderMapper.selectByOrderNumber(orderNumber);
551
+			taUserLicenseOrders.forEach(e-> {
552
+				e.setOrderStatus(status);
553
+				taUserLicenseOrderMapper.updateByPrimaryKeySelective(e);
554
+			});
555
+		}
367 556
 	}
368 557
 }

+ 8
- 4
CODE/smart-community/app-api/src/main/resources/application.yml Wyświetl plik

@@ -52,10 +52,14 @@ weixin:
52 52
 
53 53
 # 支付回调
54 54
 pay-notify:
55
-  wx-bill-notify: http://106.14.20.193:8086/app-api/wxNotify
56
-  ali-bill-notify: http://106.14.20.193:8086/app-api/aliPayNotify
57
-#  wx-bill-notify: http://ycapi.jcjyhn.com/app-api/wxNotify
58
-#  ali-bill-notify: http://ycapi.jcjyhn.com/app-api/aliPayNotify
55
+  wx-bill-notify: http://106.14.20.193:8086/app-api/wxBillNotify
56
+  ali-bill-notify: http://106.14.20.193:8086/app-api/aliPayBillNotify
57
+  wx-car-notify: http://106.14.20.193:8086/app-api/wxCarNotify
58
+  ali-car-notify: http://106.14.20.193:8086/app-api/aliPayCarNotify
59
+#  wx-bill-notify: http://ycapi.jcjyhn.com/app-api/wxBillNotify
60
+#  ali-bill-notify: http://ycapi.jcjyhn.com/app-api/aliPayBillNotify
61
+#  wx-car-notify: http://ycapi.jcjyhn.com/app-api/wxCarNotify
62
+#  ali-car-notify: http://ycapi.jcjyhn.com/app-api/aliPayCarNotify
59 63
 
60 64
 # 大苏
61 65
 da-su:

+ 7
- 0
CODE/smart-community/community-common/src/main/java/com/community/commom/constant/Constant.java Wyświetl plik

@@ -234,4 +234,11 @@ public class Constant {
234 234
 
235 235
     /** 用户待审核 **/
236 236
     public static final String TO_AUDIT = "0";
237
+
238
+    /** 缴费类型 物业 **/
239
+    public static final String PAY_TYPE_BILL = "bill";
240
+
241
+
242
+    /** 缴费类型 车缴费 **/
243
+    public static final String PAY_TYPE_CAR = "car";
237 244
 }