From 2196fbf8d86e6da0c4a4a8ecccffec4839c51127 Mon Sep 17 00:00:00 2001 From: Lemon Date: Tue, 15 Oct 2024 16:02:43 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=B8=8B=E5=8F=91=E5=81=9C=E8=BD=A6?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E6=97=B6=EF=BC=8C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/java/SpringBootTestController.java | 17 +++++++++++++++- .../pile/dto/lutongyunting/BindCouponDTO.java | 6 ++++++ .../thirdparty/common/CommonService.java | 1 + .../service/impl/LTYTServiceImpl.java | 20 ++++++++++++++++++- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index a36e1d5e6..7511f5c74 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -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 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"; 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 2c8a93eb7..a2f1caaff 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,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; } 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 0dd732358..ccb02287b 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 @@ -651,6 +651,7 @@ public class CommonService { .secretKey(parkingInfo.getSecretKey()) .plateNumber(orderBasicInfo.getPlateNumber()) .plateColor(5) // 5-绿牌车 + .orderBasicInfo(orderBasicInfo) .build(); // 绑定优惠券 return ltytService.bindCoupon(dto); diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lutongyunting/service/impl/LTYTServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lutongyunting/service/impl/LTYTServiceImpl.java index 5ede04f55..94cabc553 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lutongyunting/service/impl/LTYTServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lutongyunting/service/impl/LTYTServiceImpl.java @@ -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 {