diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java index 331d8a32a..3dcd1091d 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java @@ -928,4 +928,21 @@ public class TempController extends BaseController { logger.info("时间区间查询订单统计 result:{}", response); return response; } + + /** + * 更新钱包code为空的数据 + * http://localhost:8080/temp/updateWalletCode + */ + @PostMapping("/updateWalletCode") + public RestApiResponse updateWalletCode() { + RestApiResponse response = null; + try { + tempService.updateWalletCode(); + response = new RestApiResponse<>(); + } catch (Exception e) { + logger.error("更新钱包code为空数据 error", e); + } + logger.info("更新钱包code为空数据 result:{}", response); + return response; + } } diff --git a/jsowell-admin/src/main/java/com/jsowell/service/TempService.java b/jsowell-admin/src/main/java/com/jsowell/service/TempService.java index 559b455b0..cc3fc980b 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/TempService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/TempService.java @@ -80,6 +80,9 @@ public class TempService { @Autowired private AdapayCallbackRecordService adapayCallbackRecordService; + @Autowired + private MemberBasicInfoService memberBasicInfoService; + @Autowired protected TransactionService transactionService; @@ -131,6 +134,9 @@ public class TempService { @Autowired private NotificationService notificationService; + @Autowired + private MemberWalletInfoService memberWalletInfoService; + /** * 计算订单耗电量 * 内蒙古站点 @@ -1331,5 +1337,23 @@ public class TempService { logger.info("查询订单数量结果:{}", JSONObject.toJSONString(result)); return result; } + + public void updateWalletCode() { + // 查询钱包dode为空的数据 + List memberWalletInfoList = memberWalletInfoService.queryWalletIsNull(); + + // 分批处理, 1000条为一批 + List> partition = Lists.partition(memberWalletInfoList, 1000); + + partition.parallelStream().forEach(walletInfoList -> { + walletInfoList.forEach(walletInfo -> { + // 生成钱包code + walletInfo.setWalletCode(memberBasicInfoService.generateWalletCode()); + }); + // 批量更新钱包code + memberWalletInfoService.updateBatchSelective(walletInfoList); + }); + + } } diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/UploadRealTimeMonitorHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/UploadRealTimeMonitorHandler.java index 0448a2ff3..973b3b085 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/UploadRealTimeMonitorHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/yunkuaichong/UploadRealTimeMonitorHandler.java @@ -358,12 +358,6 @@ public class UploadRealTimeMonitorHandler extends AbstractYkcHandler { // 异步推送第三方平台实时数据V2 CompletableFuture.runAsync(() -> { try { - log.info("thirdpartyTaskExecutor状态:活跃线程数={}, 队列大小={}, 任务总数={}, 拒绝任务数={}", - thirdpartyTaskExecutor.getActiveCount(), - thirdpartyTaskExecutor.getThreadPoolExecutor().getQueue().size(), - thirdpartyTaskExecutor.getThreadPoolExecutor().getTaskCount(), - thirdpartyTaskExecutor.getThreadPoolExecutor().getRejectedExecutionHandler().toString()); - commonService.pushRealTimeInfoV2(pileSn, connectorCode, connectorStatus, realTimeMonitorData, transactionCode); // log.info("统一推送第三方平台实时数据V2 success, pileSn:{}, connectorCode:{}, connectorStatus:{}, realTimeMonitorData:{}, transactionCode:{}", pileSn, connectorCode, connectorStatus, realTimeMonitorData, transactionCode); } catch (Exception e) { diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayService.java b/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayService.java index a612d0662..b1ace922a 100644 --- a/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayService.java +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayService.java @@ -1105,6 +1105,7 @@ public class AdapayService { } /** + * 实时分账的调退款接口 * 创建退款请求 */ public RefundResponse createRefundRequest(String paymentId, BigDecimal refundAmt, String wechatAppId, String memberId, String scenarioType, String orderCode) { diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/domain/MemberWalletInfo.java b/jsowell-pile/src/main/java/com/jsowell/pile/domain/MemberWalletInfo.java index 75e04d98a..1f9415f8a 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/domain/MemberWalletInfo.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/domain/MemberWalletInfo.java @@ -4,15 +4,17 @@ import java.math.BigDecimal; import java.util.Date; import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.Getter; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.experimental.Accessors; +import lombok.experimental.SuperBuilder; /** * 会员钱包信息表 */ -@Getter -@Setter +@Data +@Accessors(chain = true) +@SuperBuilder @Builder @AllArgsConstructor @NoArgsConstructor diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberWalletInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberWalletInfoMapper.java index db221124d..34faa8443 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberWalletInfoMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/MemberWalletInfoMapper.java @@ -3,64 +3,35 @@ package com.jsowell.pile.mapper; import com.jsowell.pile.domain.MemberWalletInfo; import com.jsowell.pile.vo.base.MemberWalletVO; import org.apache.ibatis.annotations.Param; -import org.springframework.stereotype.Repository; import java.util.List; -@Repository public interface MemberWalletInfoMapper { - /** - * delete by primary key - * - * @param id primaryKey - * @return deleteCount - */ int deleteByPrimaryKey(Integer id); - /** - * insert record to table - * - * @param record the record - * @return insert count - */ int insert(MemberWalletInfo record); - /** - * insert record to table selective - * - * @param record the record - * @return insert count - */ + int insertOrUpdate(MemberWalletInfo record); + + int insertOrUpdateSelective(MemberWalletInfo record); + int insertSelective(MemberWalletInfo record); - /** - * select by primary key - * - * @param id primary key - * @return object by primary key - */ MemberWalletInfo selectByPrimaryKey(Integer id); - /** - * update record selective - * - * @param record the updated record - * @return update count - */ int updateByPrimaryKeySelective(MemberWalletInfo record); - /** - * update record - * - * @param record the updated record - * @return update count - */ int updateByPrimaryKey(MemberWalletInfo record); - // MemberWalletInfo selectByMemberId(String memberId); + int updateBatch(@Param("list") List list); + + int updateBatchSelective(@Param("list") List list); + + int batchInsert(@Param("list") List list); /** * 根据会员id和目标运营商id查询用户钱包信息 + * * @param memberId * @param merchantId * @return @@ -72,4 +43,6 @@ public interface MemberWalletInfoMapper { MemberWalletInfo selectByWalletCode(@Param("walletCode") String walletCode); MemberWalletVO selectMemberWalletInfo(String walletCode); -} \ No newline at end of file + + List queryWalletIsNull(); +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/MemberWalletInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/MemberWalletInfoService.java index 590501f5b..06c73c307 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/MemberWalletInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/MemberWalletInfoService.java @@ -25,4 +25,8 @@ public interface MemberWalletInfoService { List selectByMemberWalletList(String memberId); MemberWalletVO selectMemberWalletInfo(String walletCode); + + List queryWalletIsNull(); + + int updateBatchSelective(List walletInfoList); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberWalletInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberWalletInfoServiceImpl.java index b3f8debf7..37201480f 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberWalletInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberWalletInfoServiceImpl.java @@ -120,4 +120,14 @@ public class MemberWalletInfoServiceImpl implements MemberWalletInfoService { return memberWalletVO; } + @Override + public List queryWalletIsNull() { + return memberWalletInfoMapper.queryWalletIsNull(); + } + + @Override + public int updateBatchSelective(List walletInfoList) { + return memberWalletInfoMapper.updateBatchSelective(walletInfoList); + } + } diff --git a/jsowell-pile/src/main/resources/mapper/pile/MemberWalletInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/MemberWalletInfoMapper.xml index b0944611e..5c570823a 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/MemberWalletInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/MemberWalletInfoMapper.xml @@ -19,12 +19,12 @@ - id, member_id, merchant_id, wallet_code, principal_balance, gift_balance, version, + id, member_id, merchant_id, wallet_code, principal_balance, gift_balance, version, create_by, create_time, update_by, update_time, del_flag select @@ -226,4 +566,12 @@ and sub_type = '11') t3 on t3.wallet_code = t1.wallet_code where t1.wallet_code = #{walletCode,jdbcType=VARCHAR} - \ No newline at end of file + + + diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java index 0cc8f9738..2fe8d7939 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java @@ -419,42 +419,43 @@ public class CommonService { String stationId = String.valueOf(pileBasicInfo.getStationId()); // 查询该站点是否推送第三方平台 List thirdPartySecretInfoVOS = thirdpartySecretInfoService.queryStationToPlatformList(stationId); - - log.info("推送实时数据到第三方平台 stationId:{}, thirdPartySecretInfoVOS:{}", stationId, thirdPartySecretInfoVOS); - if (CollectionUtils.isEmpty(thirdPartySecretInfoVOS)) { return; } - - // 推送 - for (ThirdPartySecretInfoVO thirdPartySecretInfoVO : thirdPartySecretInfoVOS) { - NotificationDTO dto = new NotificationDTO(); - dto.setStationId(stationId); - dto.setPileConnectorCode(pileConnectorCode); - dto.setStatus(changedStatus); - dto.setPlatformType(thirdPartySecretInfoVO.getPlatformType()); - - notificationService.notificationStationStatus(dto); - - log.info("交易流水号transactionCode:{}", transactionCode); - // 查询订单信息 - OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); - // 新运有三个平台,当这个transactionCode为null或orderInfo为null时,这里就不会继续推送其它两家平台,直接return了 - // 也就是说,只要这台桩没有订单,为空闲状态,就只推送一家平台循环就终止了 - - //判断transactionCode和orderInfo是否为空,为空就不推送充电状态 - if (Strings.isEmpty(transactionCode)){ -// return; - continue; + OrderBasicInfo orderInfo = new OrderBasicInfo(); + if(Constants.ILLEGAL_TRANSACTION_CODE.equals(transactionCode)){ + //表示为非法交易流水号"00000000000000000000000000000000",不推送充电状态 + orderInfo = null; + }else{ + // 查询订单信息,避免每个平台都查询一次 + if (transactionCode != null) { + orderInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode); } - if (Objects.isNull(orderInfo)) { - continue; - } - dto.setOrderCode(orderInfo.getOrderCode()); - notificationService.notificationConnectorChargeStatus(dto); - } + for (ThirdPartySecretInfoVO thirdPartySecretInfoVO : thirdPartySecretInfoVOS) { + try { + NotificationDTO dto = new NotificationDTO(); + dto.setStationId(stationId); + dto.setPileConnectorCode(pileConnectorCode); + dto.setStatus(changedStatus); + dto.setPlatformType(thirdPartySecretInfoVO.getPlatformType()); + + // 先推送站点状态 + notificationService.notificationStationStatus(dto); + + // 如果有订单信息,推送充电状态 + if (orderInfo != null) { + dto.setOrderCode(orderInfo.getOrderCode()); + notificationService.notificationConnectorChargeStatus(dto); + } else { + log.info("无订单信息,仅推送站点状态,平台类型:{}", thirdPartySecretInfoVO.getPlatformType()); + } + } catch (Exception e) { + log.error("推送实时数据到平台失败,平台类型:{},错误信息:{}", + thirdPartySecretInfoVO.getPlatformType(), e.getMessage(), e); + } + } } diff --git a/pom.xml b/pom.xml index 84ce530c9..0a03e06e4 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 2.0.23 6.2.2 - 2.11.0 + 2.16.1 1.4 3.2.2 4.1.2