mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 11:49:49 +08:00
新增 路通云停平台 给车辆绑定优惠券接口
This commit is contained in:
@@ -45,6 +45,7 @@ import com.jsowell.pile.domain.ykcCommond.IssueQRCodeCommand;
|
|||||||
import com.jsowell.pile.domain.ykcCommond.ProofreadTimeCommand;
|
import com.jsowell.pile.domain.ykcCommond.ProofreadTimeCommand;
|
||||||
import com.jsowell.pile.dto.*;
|
import com.jsowell.pile.dto.*;
|
||||||
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
||||||
|
import com.jsowell.pile.dto.lutongyunting.BindCouponDTO;
|
||||||
import com.jsowell.pile.dto.lutongyunting.GetTokenDTO;
|
import com.jsowell.pile.dto.lutongyunting.GetTokenDTO;
|
||||||
import com.jsowell.pile.mapper.MemberBasicInfoMapper;
|
import com.jsowell.pile.mapper.MemberBasicInfoMapper;
|
||||||
import com.jsowell.pile.mapper.PileBillingTemplateMapper;
|
import com.jsowell.pile.mapper.PileBillingTemplateMapper;
|
||||||
@@ -402,12 +403,22 @@ public class SpringBootTestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParking() {
|
public void testParking() throws UnsupportedEncodingException {
|
||||||
GetTokenDTO dto = new GetTokenDTO();
|
// GetTokenDTO dto = new GetTokenDTO();
|
||||||
|
// dto.setAppId("I2qa3hdr116100dc");
|
||||||
|
// dto.setSecretKey("2qa3hdr13754a8e");
|
||||||
|
// String token = ltytService.getToken(dto);
|
||||||
|
// System.out.println(token);
|
||||||
|
|
||||||
|
BindCouponDTO dto = new BindCouponDTO();
|
||||||
dto.setAppId("I2qa3hdr116100dc");
|
dto.setAppId("I2qa3hdr116100dc");
|
||||||
dto.setSecretKey("2qa3hdr13754a8e");
|
dto.setSecretKey("2qa3hdr13754a8e");
|
||||||
String token = ltytService.getToken(dto);
|
dto.setMerchantId("3prv98bm8db70a9");
|
||||||
System.out.println(token);
|
dto.setCouponId("3prvd0q7a4817bf");
|
||||||
|
dto.setPlateNumber("贵A12345");
|
||||||
|
dto.setPlateColor(1);
|
||||||
|
String s = ltytService.bindCoupon(dto);
|
||||||
|
System.out.println(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class BindCouponDTO {
|
public class BindCouponDTO {
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
private String secretKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 优惠券商家标识
|
* 优惠券商家标识
|
||||||
*/
|
*/
|
||||||
@@ -28,5 +32,5 @@ public class BindCouponDTO {
|
|||||||
/**
|
/**
|
||||||
* 车牌颜色
|
* 车牌颜色
|
||||||
*/
|
*/
|
||||||
private String plateColor;
|
private Integer plateColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package com.jsowell.thirdparty.lutongyunting.service;
|
|||||||
import com.jsowell.pile.dto.lutongyunting.BindCouponDTO;
|
import com.jsowell.pile.dto.lutongyunting.BindCouponDTO;
|
||||||
import com.jsowell.pile.dto.lutongyunting.GetTokenDTO;
|
import com.jsowell.pile.dto.lutongyunting.GetTokenDTO;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* 路通云停 Service
|
||||||
*
|
*
|
||||||
* @author Lemon
|
* @author Lemon
|
||||||
* @Date 2023/8/23 11:07
|
* @Date 2023/8/23 11:07
|
||||||
@@ -23,5 +25,5 @@ public interface LTYTService {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String bindCoupon(BindCouponDTO dto);
|
String bindCoupon(BindCouponDTO dto) throws UnsupportedEncodingException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,21 @@ import com.alibaba.fastjson2.JSON;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.jsowell.common.constant.CacheConstants;
|
import com.jsowell.common.constant.CacheConstants;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
|
import com.jsowell.common.exception.BusinessException;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.common.util.sign.MD5Util;
|
import com.jsowell.common.util.sign.MD5Util;
|
||||||
import com.jsowell.pile.dto.lutongyunting.BindCouponDTO;
|
import com.jsowell.pile.dto.lutongyunting.BindCouponDTO;
|
||||||
import com.jsowell.pile.dto.lutongyunting.GetTokenDTO;
|
import com.jsowell.pile.dto.lutongyunting.GetTokenDTO;
|
||||||
|
import com.jsowell.thirdparty.lutongyunting.common.LTYTCommonParams;
|
||||||
import com.jsowell.thirdparty.lutongyunting.service.LTYTService;
|
import com.jsowell.thirdparty.lutongyunting.service.LTYTService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -89,11 +93,53 @@ public class LTYTServiceImpl implements LTYTService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String bindCoupon(BindCouponDTO dto) {
|
public String bindCoupon(BindCouponDTO dto) throws UnsupportedEncodingException {
|
||||||
|
// 获取令牌
|
||||||
|
GetTokenDTO tokenDTO = new GetTokenDTO();
|
||||||
|
tokenDTO.setAppId(dto.getAppId());
|
||||||
|
tokenDTO.setSecretKey(dto.getSecretKey());
|
||||||
|
String token = getToken(tokenDTO);
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
throw new BusinessException("", "路通云停系统 给指定车辆绑定优惠券 方法获取令牌失败");
|
||||||
|
}
|
||||||
|
// LTYTCommonParams params = new LTYTCommonParams();
|
||||||
|
// params.setAppId(dto.getAppId());
|
||||||
|
// params.setAccTime(DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS));
|
||||||
|
// params.setToken(token);
|
||||||
|
// params.setVersion("1.0");
|
||||||
|
|
||||||
|
String url = BASE_URL + "bindCoupon";
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
// 公共参数
|
||||||
|
jsonObject.put("appId", dto.getAppId());
|
||||||
|
jsonObject.put("token", token);
|
||||||
|
jsonObject.put("accTime", DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS));
|
||||||
|
jsonObject.put("version", "1.0");
|
||||||
|
// 业务参数
|
||||||
|
jsonObject.put("merchantId", dto.getMerchantId());
|
||||||
|
jsonObject.put("couponId", dto.getCouponId());
|
||||||
|
jsonObject.put("plateNumber", dto.getPlateNumber());
|
||||||
|
jsonObject.put("plateColor", dto.getPlateColor());
|
||||||
|
|
||||||
|
String encodeData = URLEncoder.encode(JSON.toJSONString(jsonObject), "UTF-8");
|
||||||
|
jsonObject.put("data", encodeData);
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
String result = HttpUtil.post(url, JSON.toJSONString(jsonObject));
|
||||||
|
log.info("给指定车辆绑定优惠券 params:{}, result:{}", JSON.toJSONString(jsonObject), result);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("merchantId", "merchantId");
|
||||||
|
jsonObject.put("couponId", "couponId");
|
||||||
|
jsonObject.put("plateNumber", "plateNumber");
|
||||||
|
jsonObject.put("plateColor", 2);
|
||||||
|
|
||||||
|
String encodeData = URLEncoder.encode(JSON.toJSONString(jsonObject), "UTF-8");
|
||||||
|
System.out.println(encodeData);
|
||||||
// String accTime = DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS);
|
// String accTime = DateUtils.dateTimeNow(DateUtils.YYYYMMDDHHMMSS);
|
||||||
// Map<String, Object> map = new LinkedMap<>();
|
// Map<String, Object> map = new LinkedMap<>();
|
||||||
// map.put("appId", "appId");
|
// map.put("appId", "appId");
|
||||||
|
|||||||
Reference in New Issue
Block a user