update 下发停车优惠券时,记录到数据库表中

This commit is contained in:
Lemon
2024-10-15 16:02:43 +08:00
parent 1776075ac2
commit 2196fbf8d8
4 changed files with 42 additions and 2 deletions

View File

@@ -104,7 +104,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ActiveProfiles("pre")
@ActiveProfiles("dev")
@SpringBootTest(classes = JsowellApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
public class SpringBootTestController {
@@ -264,12 +264,27 @@ public class SpringBootTestController {
@Autowired
private PileSnGenerateService pileSnGenerateService;
@Autowired
private CarCouponRecordService carCouponRecordService;
@Test
public void getEBikePileSnTest() {
List<String> strings = pileSnGenerateService.generateEBikeSN(8);
System.out.println(strings);
}
@Test
public void testInsetCarCoupon() {
CarCouponRecord carCouponRecord = new CarCouponRecord();
carCouponRecord.setOrderCode("123456");
carCouponRecord.setReturnCode("10004");
carCouponRecord.setReturnMsg("该车牌已领取过该券包中的优惠券");
carCouponRecord.setPlateNumber("粤BD26691");
carCouponRecord.setStationId(Long.parseLong("19"));
carCouponRecordService.insertCarCouponRecord(carCouponRecord);
}
@Test
public void getListByMemberIdAndOrderStatusTest() {
String memberId = "12345678";

View File

@@ -1,5 +1,6 @@
package com.jsowell.pile.dto.lutongyunting;
import com.jsowell.pile.domain.OrderBasicInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -39,4 +40,9 @@ public class BindCouponDTO {
* 车牌颜色
*/
private Integer plateColor;
/**
* 订单基本信息
*/
private OrderBasicInfo orderBasicInfo;
}

View File

@@ -651,6 +651,7 @@ public class CommonService {
.secretKey(parkingInfo.getSecretKey())
.plateNumber(orderBasicInfo.getPlateNumber())
.plateColor(5) // 5-绿牌车
.orderBasicInfo(orderBasicInfo)
.build();
// 绑定优惠券
return ltytService.bindCoupon(dto);

View File

@@ -9,8 +9,11 @@ import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.sign.MD5Util;
import com.jsowell.pile.domain.CarCouponRecord;
import com.jsowell.pile.domain.OrderBasicInfo;
import com.jsowell.pile.dto.lutongyunting.BindCouponDTO;
import com.jsowell.pile.dto.lutongyunting.GetTokenDTO;
import com.jsowell.pile.service.CarCouponRecordService;
import com.jsowell.thirdparty.lutongyunting.common.LTYTCommonParams;
import com.jsowell.thirdparty.lutongyunting.service.LTYTService;
import org.slf4j.Logger;
@@ -35,6 +38,9 @@ public class LTYTServiceImpl implements LTYTService {
@Autowired
private RedisCache redisCache;
@Autowired
private CarCouponRecordService carCouponRecordService;
// private static final String APP_ID = "I2qa3hdr116100dc"; // I2qa3hdr116100dc I2qa3jfnd96f267c
// private static final String SECRET_KEY = "2qa3hdr13754a8e"; // 2qa3hdr13754a8e 2qa3jfndb37926d
@@ -94,6 +100,7 @@ public class LTYTServiceImpl implements LTYTService {
*/
@Override
public String bindCoupon(BindCouponDTO dto) throws UnsupportedEncodingException {
OrderBasicInfo orderBasicInfo = dto.getOrderBasicInfo();
// 获取令牌
GetTokenDTO tokenDTO = new GetTokenDTO();
tokenDTO.setAppId(dto.getAppId());
@@ -123,8 +130,19 @@ public class LTYTServiceImpl implements LTYTService {
String result = HttpUtil.post(url, JSON.toJSONString(jsonObject));
log.info("给指定车辆绑定优惠券 params:{}, result:{}", JSON.toJSONString(jsonObject), result);
JSONObject resultJson = JSONObject.parseObject(result);
String msg = resultJson.getString("msg");
return resultJson.getString("msg");
// 将下发优惠券信息存入表
CarCouponRecord carCouponRecord = new CarCouponRecord();
carCouponRecord.setOrderCode(orderBasicInfo.getOrderCode());
carCouponRecord.setReturnCode(String.valueOf(resultJson.get("code")));
carCouponRecord.setReturnMsg(msg);
carCouponRecord.setPlateNumber(dto.getPlateNumber());
carCouponRecord.setStationId(Long.parseLong(orderBasicInfo.getStationId()));
carCouponRecordService.insertCarCouponRecord(carCouponRecord);
return msg;
}
public static void main(String[] args) throws UnsupportedEncodingException {