|
@@ -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
|
}
|