mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
新增 交易记录报文中添加 绑定优惠券逻辑
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -833,7 +833,6 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
// 从redis中取出实时记录保存到表中
|
||||
realTimeMonitorDataRedis2DB(orderBasicInfo.getTransactionCode(), orderCode);
|
||||
|
||||
// TODO 如果该站点的停车场优惠券信息配置不为空,则需绑定一张优惠券
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user