From 6e10c39f65a160db7b1100c878e10564996160fe Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 24 Jul 2019 11:37:31 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=81=9C=E8=BD=A6][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E5=81=9C=E8=BD=A6=E6=95=B0=E6=8D=AE=E5=85=A5=E5=BA=93=E4=BF=AE?= =?UTF-8?q?=E6=94=B9,15=E5=88=86=E9=92=9F=E5=86=85=E7=BC=B4=E8=B4=B9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95update=EF=BC=8C=E4=B8=8D=E5=86=8Dinsert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../callback/WxCarCallBackController.java | 32 +++++++++++++------ .../resources/mapper/WxCarCmdLogMapper.xml | 5 ++- .../resources/mapper/WxCarPayRecordMapper.xml | 3 ++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarCallBackController.java b/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarCallBackController.java index f2609a95c..fcc48b4ba 100644 --- a/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarCallBackController.java +++ b/mallinkCallback/src/main/java/com/iformall/controller/callback/WxCarCallBackController.java @@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; @@ -382,13 +383,24 @@ public class WxCarCallBackController extends BaseController { if(StringUtils.isNotBlank(tenantId)) { map.put("tenantId", tenantId); } + String paidServiceFee = paramMap.get(ETCPUtil.ETCP_PAID_SERVICE_FEE); + String fee = paramMap.get(ETCPUtil.ETCP_FEE); + Date feeTime = null; + + if(StringUtils.isNotBlank(etcpTime)) { + try { + feeTime = dateFormat.parse(etcpTime); + } catch (ParseException e) { + logger.error("解析fee time出错" + etcpTime); + } + } map.put("plateNumber", carNumber); map.put("orderId", orderId); + map.put("fee", fee); map.put("feeTime", etcpTime); WxCarCmdLog carCmdLog = wxCarCmdLogService.getByOrderId(map); if(carCmdLog != null) { - logger.error("ETCP order已入库: " + orderId); - return new Result(EnumETCPCode.SUCCESS.getCode(), EnumETCPCode.SUCCESS.getMessage()); + logger.error("ETCP order paid 已入库: " + orderId); } Date currentDate = new Date(); @@ -396,6 +408,10 @@ public class WxCarCallBackController extends BaseController { if(StringUtils.isNotBlank(tenantId)) { wxCarCmdLog.setTenantId(tenantId); } + if(carCmdLog != null) { + // 如果有15分钟的已支付的数据,自动覆盖 + wxCarCmdLog.setId(carCmdLog.getId()); + } wxCarCmdLog.setVendorType(EnumCarVendor.CAR_ETCP.getCode()); wxCarCmdLog.setCmdType(EnumCarCmd.CAR_ETCP_CALLBACK_PAY_MANUAL.getCode()); wxCarCmdLog.setCmdJson(JSON.toJSONString(paramMap)); @@ -408,16 +424,13 @@ public class WxCarCallBackController extends BaseController { return new Result(ErrorCode.DB_FAIL.getCode(), "入库错误" + paramMap.toString()); } - String paidServiceFee = paramMap.get(ETCPUtil.ETCP_PAID_SERVICE_FEE); - String fee = paramMap.get(ETCPUtil.ETCP_FEE); - try { // 保存WxCarPayRecord WxCarPayRecord record = new WxCarPayRecord(); record.setSynId(orderId); record.setFee(fee); - if(StringUtils.isNotBlank(etcpTime)) { - record.setFeeTime(dateFormat.parse(etcpTime)); + if(feeTime != null) { + record.setFeeTime(feeTime); } record.setPaidServiceFee(paidServiceFee); record.setVendorType(wxCarCmdLog.getVendorType()); @@ -426,9 +439,10 @@ public class WxCarCallBackController extends BaseController { WxCarPayRecord query = new WxCarPayRecord(); query.setSynId(orderId); - if(StringUtils.isNotBlank(etcpTime)) { - query.setFeeTime(dateFormat.parse(etcpTime)); + if(feeTime != null) { + query.setFeeTime(feeTime); } + // 缴费时间在15分钟以内,更新之前的数据, ETCP会把之前的缴费自动退款 PageInfo page = wxCarPayRecordService.findCarPayListByPage(query,1,2); if(page != null && page.getList().size() > 0){ if(page.getList().size() >= 2){ diff --git a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml index f6a6dc993..3f89e5f82 100644 --- a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml @@ -136,8 +136,11 @@ and order_id = #{orderId} + + and JSON_EXTRACT(cmd_json,'$.fee') = #{fee} + - and fee_time = #{feeTime} + and TIMESTAMPDIFF(MINUTE, `fee_time`, #{feeTime}) <= 15 diff --git a/mallinkService/src/main/resources/mapper/WxCarPayRecordMapper.xml b/mallinkService/src/main/resources/mapper/WxCarPayRecordMapper.xml index f4787cb98..8db66b319 100644 --- a/mallinkService/src/main/resources/mapper/WxCarPayRecordMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCarPayRecordMapper.xml @@ -44,6 +44,9 @@ and `fee_time` = #{feeTimeStr} + + and TIMESTAMPDIFF(MINUTE, `fee_time`, #{feeTime}) <= 15 + and `tenant_id` = #{tenantId}