From 8fcffc1aa46ba54fa34eaa9663fa9bdee67326bc Mon Sep 17 00:00:00 2001 From: Lemon Date: Fri, 25 Aug 2023 17:11:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=20=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=8A=A5=E6=96=87=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20=20=E7=BB=91=E5=AE=9A=E4=BC=98=E6=83=A0=E5=88=B8=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TransactionRecordsRequestHandler.java | 62 ++++++++++++++++++- .../pile/dto/lutongyunting/BindCouponDTO.java | 6 ++ .../impl/OrderBasicInfoServiceImpl.java | 1 - .../mapper/pile/PileStationInfoMapper.xml | 1 + 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/jsowell-netty/src/main/java/com/jsowell/netty/handler/TransactionRecordsRequestHandler.java b/jsowell-netty/src/main/java/com/jsowell/netty/handler/TransactionRecordsRequestHandler.java index 52f2932ae..b324a3def 100644 --- a/jsowell-netty/src/main/java/com/jsowell/netty/handler/TransactionRecordsRequestHandler.java +++ b/jsowell-netty/src/main/java/com/jsowell/netty/handler/TransactionRecordsRequestHandler.java @@ -8,7 +8,9 @@ import com.jsowell.common.core.domain.ykc.YKCDataProtocol; import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode; import com.jsowell.common.core.redis.RedisCache; import com.jsowell.common.enums.ykc.OrderStatusEnum; +import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.enums.ykc.YKCChargingStopReasonEnum; +import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.BytesUtil; import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil; import com.jsowell.common.util.DateUtils; @@ -18,14 +20,19 @@ import com.jsowell.common.util.id.IdUtils; import com.jsowell.netty.factory.YKCOperateFactory; import com.jsowell.pile.domain.OrderBasicInfo; import com.jsowell.pile.domain.ThirdPartyStationRelation; +import com.jsowell.pile.domain.ThirdpartyParkingConfig; +import com.jsowell.pile.dto.lutongyunting.BindCouponDTO; import com.jsowell.pile.service.*; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.thirdparty.lianlian.service.LianLianService; +import com.jsowell.thirdparty.lutongyunting.service.LTYTService; import io.netty.channel.Channel; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.Objects; @@ -74,6 +81,15 @@ public class TransactionRecordsRequestHandler extends AbstractHandler { @Autowired private IMemberPlateNumberRelationService memberPlateNumberRelationService; + @Autowired + private IPileStationInfoService pileStationInfoService; + + @Autowired + private LTYTService ltytService; + + @Autowired + private IThirdPartyParkingConfigService thirdPartyParkingConfigService; + public static void main(String[] args) { // 获取消息体 String msg = "000000000000000000000000000000008823000000030601a08c2e0d0404170000380d0404170000000000000000000000000000000000000000000000000000000000000000400d0300ee250000ee250000c84b000000000000000000000000000000000000e0bb040000cee1040000ee250000ee250000c84b00000000000000000000000000000000000000010000380d04041745a511101970000000"; @@ -614,8 +630,8 @@ public class TransactionRecordsRequestHandler extends AbstractHandler { log.error("结算订单发生异常", e); } + // 联联平台 推送订单信息 notification_orderInfo try { - // 联联平台 推送订单信息 notification_orderInfo // 查询该站点是否推送联联平台 ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); relation.setStationId(Long.parseLong(orderBasicInfo.getStationId())); @@ -636,5 +652,49 @@ public class TransactionRecordsRequestHandler extends AbstractHandler { orderBasicInfoService.saveAbnormalOrder(data); log.warn("充电桩传来的交易记录,根据交易流水号:{}查询不到订单,判定为可疑账单", transactionCode); } + + // 给车辆绑定优惠券 + try { + String bindResult = bindCoupon(orderBasicInfo); + log.info("绑定优惠券 订单信息:{}, result;{}", orderBasicInfo, bindResult); + }catch (BusinessException e) { + log.error("绑定优惠券 error, code:{}, msg:{}", e.getCode(), e.getMessage()); + } catch (Exception e) { + log.error("绑定优惠券 error,", e); + } + + } + + + /** + * 绑定优惠券 + * @param orderBasicInfo + * @return + * @throws UnsupportedEncodingException + */ + private String bindCoupon(OrderBasicInfo orderBasicInfo) throws UnsupportedEncodingException { + if (orderBasicInfo == null) { + return null; + } + // 如果该站点的停车场优惠券信息配置不为空,则需绑定一张优惠券 + String stationId = orderBasicInfo.getStationId(); + PileStationVO stationInfo = pileStationInfoService.getStationInfo(stationId); + if (StringUtils.isBlank(stationInfo.getParkingId())) { + return "该订单无需绑定优惠券"; + } + ThirdpartyParkingConfig parkingInfo = thirdPartyParkingConfigService.selectByPrimaryKey(Integer.parseInt(stationInfo.getParkingId())); + if (parkingInfo == null) { + throw new BusinessException(ReturnCodeEnum.CODE_QUERY_PARKING_INFO_IS_NULL); + } + BindCouponDTO dto = BindCouponDTO.builder() + .appId(parkingInfo.getAppId()) + .merchantId(parkingInfo.getParkingMerchantId()) + .couponId(parkingInfo.getCouponId()) + .secretKey(parkingInfo.getSecretKey()) + .plateNumber(orderBasicInfo.getPlateNumber()) + .plateColor(5) // 5-绿牌车 + .build(); + // 绑定优惠券 + return ltytService.bindCoupon(dto); } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/lutongyunting/BindCouponDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/lutongyunting/BindCouponDTO.java index 7bc733a13..2c8a93eb7 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/lutongyunting/BindCouponDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/lutongyunting/BindCouponDTO.java @@ -1,6 +1,9 @@ package com.jsowell.pile.dto.lutongyunting; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; /** * 给指定车辆绑定优惠券 @@ -9,6 +12,9 @@ import lombok.Data; * @Date 2023/8/23 14:15 */ @Data +@NoArgsConstructor +@AllArgsConstructor +@Builder public class BindCouponDTO { private String appId; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index 68f73bced..378b8ca63 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -833,7 +833,6 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService { // 从redis中取出实时记录保存到表中 realTimeMonitorDataRedis2DB(orderBasicInfo.getTransactionCode(), orderCode); - // TODO 如果该站点的停车场优惠券信息配置不为空,则需绑定一张优惠券 } /** diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml index c590d0239..494c548ea 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileStationInfoMapper.xml @@ -302,6 +302,7 @@ SELECT t1.id as id, t1.dept_id as deptId, + t1.parking_id as parkingId, t1.station_name as stationName, count(t2.id) as pileNum, t1.area_code as areaCode,