fix(优惠券中心):携程全链路调试完成,调试对接逻辑优化,新增设备一键起飞的指令接口,二维码新增类型字段来区分二维码中航线的的用途等逻辑
This commit is contained in:
+14
-24
@@ -228,13 +228,13 @@ public class CtripCouponController {
|
||||
String couponType = "DISCOUNT";
|
||||
BigDecimal amount = price != null ? price.multiply(new BigDecimal("0.1")) : new BigDecimal("10.00"); // 10%折扣
|
||||
|
||||
// 设置有效期(从订单使用日期开始,有效期7天)
|
||||
String useStartDate = (String) item.get("useStartDate");
|
||||
String validStartTimeStr = useStartDate + " 00:00:00";
|
||||
String validEndTimeStr = useStartDate + " 23:59:59"; // 当天有效
|
||||
// 设置有效期(从当前时间开始,有效期30天)
|
||||
Date now = new Date();
|
||||
Date validStartTime = now;
|
||||
Date validEndTime = new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000L); // 30天后过期
|
||||
|
||||
log.info("生成的优惠券信息 - ctripCouponId: {}, userPhone: {}, amount: {}",
|
||||
ctripCouponId, userPhone, amount);
|
||||
log.info("生成的优惠券信息 - ctripCouponId: {}, userPhone: {}, amount: {}, 有效期: {} 至 {}",
|
||||
ctripCouponId, userPhone, amount, validStartTime, validEndTime);
|
||||
|
||||
// 验证必要参数
|
||||
if (userPhone == null || userPhone.trim().isEmpty()) {
|
||||
@@ -256,21 +256,6 @@ public class CtripCouponController {
|
||||
return buildSuccessResponseWithOrder(otaOrderId, supplierOrderId, items);
|
||||
}
|
||||
|
||||
// 时间解析
|
||||
Date validStartTime = parseDate(validStartTimeStr);
|
||||
Date validEndTime = parseDate(validEndTimeStr);
|
||||
|
||||
if (validStartTime == null || validEndTime == null) {
|
||||
log.error("时间格式错误 - validStartTime: {}, validEndTime: {}", validStartTimeStr, validEndTimeStr);
|
||||
return buildErrorResponse("0003", "时间格式错误");
|
||||
}
|
||||
|
||||
// 验证有效期是否已过期
|
||||
if (validEndTime.before(new Date())) {
|
||||
log.error("优惠券有效期已过期");
|
||||
return buildErrorResponse("0011", "优惠券有效期已过期");
|
||||
}
|
||||
|
||||
// 从ctripCouponId中提取订单ID(格式:CTRIP_订单ID_序号)
|
||||
String ctripOrderId = null;
|
||||
if (ctripCouponId != null && ctripCouponId.startsWith("CTRIP_")) {
|
||||
@@ -1005,11 +990,16 @@ public class CtripCouponController {
|
||||
|
||||
/**
|
||||
* 生成供应商订单号(与订单服务保持一致)
|
||||
* 实现幂等性:相同otaOrderId返回相同的supplierOrderId
|
||||
*/
|
||||
private String generateSupplierOrderId(String otaOrderId) {
|
||||
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
String random = UUID.randomUUID().toString().replace("-", "").substring(0, 8);
|
||||
return "SUPPLIER_" + otaOrderId + "_" + timestamp + "_" + random;
|
||||
// 使用otaOrderId的哈希值生成固定的订单号,确保幂等性
|
||||
int hash = otaOrderId.hashCode();
|
||||
|
||||
// 使用哈希值生成固定的8位字符串,确保相同otaOrderId生成相同的supplierOrderId
|
||||
String fixedPart = String.format("%08x", Math.abs(hash) % 0x100000000L);
|
||||
|
||||
return "SUPPLIER_" + otaOrderId + "_" + fixedPart;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-1
@@ -96,6 +96,12 @@ public class CtripQueryOrderResponse {
|
||||
private String useStartDate; // 使用开始日期
|
||||
@JsonProperty("useEndDate")
|
||||
private String useEndDate; // 使用结束日期
|
||||
@JsonProperty("orderStatus")
|
||||
private Integer orderStatus; // 订单状态:0-待确认,1-已确认,2-已取消,3-已过期
|
||||
@JsonProperty("useQuantity")
|
||||
private Integer useQuantity; // 已使用数量
|
||||
@JsonProperty("cancelQuantity")
|
||||
private Integer cancelQuantity; // 已取消数量
|
||||
@JsonProperty("passengers")
|
||||
private List<CtripResponsePassenger> passengers; // 乘客信息
|
||||
@JsonProperty("vouchers")
|
||||
@@ -144,6 +150,8 @@ public class CtripQueryOrderResponse {
|
||||
public static class CtripResponsePassenger {
|
||||
@JsonProperty("passengerId")
|
||||
private String passengerId; // 乘客ID
|
||||
@JsonProperty("passengerStatus")
|
||||
private Integer passengerStatus; // 乘客状态:0-正常,1-已取消
|
||||
@JsonProperty("name")
|
||||
private String name; // 乘客姓名
|
||||
@JsonProperty("mobile")
|
||||
@@ -164,11 +172,13 @@ public class CtripQueryOrderResponse {
|
||||
public static class CtripResponseVoucher {
|
||||
@JsonProperty("voucherId")
|
||||
private String voucherId; // 凭证ID
|
||||
@JsonProperty("voucherStatus")
|
||||
private Integer voucherStatus; // 凭证状态:0-正常,1-已使用,2-已取消
|
||||
@JsonProperty("voucherCode")
|
||||
private String voucherCode; // 凭证码
|
||||
@JsonProperty("voucherType")
|
||||
private Integer voucherType; // 凭证类型
|
||||
@JsonProperty("status")
|
||||
private Integer status; // 凭证状态
|
||||
private Integer status; // 凭证状态(兼容字段)
|
||||
}
|
||||
}
|
||||
+11
-4
@@ -84,7 +84,9 @@ public class CtripOrderServiceImpl implements ICtripOrderService {
|
||||
// 1. 检查订单是否已存在
|
||||
if (isOrderExists(body.getOtaOrderId(), body.getSequenceId())) {
|
||||
log.info("订单已存在且已下单成功,otaOrderId: {}, sequenceId: {}", body.getOtaOrderId(), body.getSequenceId());
|
||||
return buildSuccessResponse(header, body, "SUPPLIER_" + body.getOtaOrderId(), "订单已存在");
|
||||
// 使用generateSupplierOrderId确保幂等性
|
||||
String supplierOrderId = generateSupplierOrderId(body.getOtaOrderId());
|
||||
return buildSuccessResponse(header, body, supplierOrderId, "订单已存在");
|
||||
}
|
||||
|
||||
// 2. 创建新订单
|
||||
@@ -1010,11 +1012,16 @@ public class CtripOrderServiceImpl implements ICtripOrderService {
|
||||
|
||||
/**
|
||||
* 生成供应商订单号
|
||||
* 实现幂等性:相同otaOrderId返回相同的supplierOrderId
|
||||
*/
|
||||
private String generateSupplierOrderId(String otaOrderId) {
|
||||
String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
String random = UUID.randomUUID().toString().replace("-", "").substring(0, 8);
|
||||
return "SUPPLIER_" + otaOrderId + "_" + timestamp + "_" + random;
|
||||
// 使用otaOrderId的哈希值生成固定的订单号,确保幂等性
|
||||
int hash = otaOrderId.hashCode();
|
||||
|
||||
// 使用哈希值生成固定的8位字符串,确保相同otaOrderId生成相同的supplierOrderId
|
||||
String fixedPart = String.format("%08x", Math.abs(hash) % 0x100000000L);
|
||||
|
||||
return "SUPPLIER_" + otaOrderId + "_" + fixedPart;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+148
-8
@@ -220,7 +220,7 @@ public class CtripQueryOrderServiceImpl implements ICtripQueryOrderService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建优惠券查询响应
|
||||
* 构建订单查询响应(符合携程QueryOrder接口要求)
|
||||
*/
|
||||
private CtripQueryOrderResponse buildCouponQueryResponse(CtripQueryOrderRequest.CtripHeader header,
|
||||
List<Coupon> coupons,
|
||||
@@ -230,7 +230,7 @@ public class CtripQueryOrderServiceImpl implements ICtripQueryOrderService {
|
||||
// 设置响应头
|
||||
CtripQueryOrderResponse.CtripResponseHeader responseHeader = new CtripQueryOrderResponse.CtripResponseHeader();
|
||||
responseHeader.setResultCode("0000");
|
||||
responseHeader.setResultMessage("查询成功");
|
||||
responseHeader.setResultMessage("操作成功");
|
||||
response.setHeader(responseHeader);
|
||||
|
||||
// 设置响应体
|
||||
@@ -239,32 +239,142 @@ public class CtripQueryOrderServiceImpl implements ICtripQueryOrderService {
|
||||
responseBody.setSupplierOrderId(body.getSupplierOrderId());
|
||||
responseBody.setSequenceId(body.getSequenceId());
|
||||
|
||||
// 设置优惠券信息
|
||||
responseBody.setCoupons(buildCouponResponseList(coupons));
|
||||
// 根据携程QueryOrder接口要求,返回订单项信息
|
||||
responseBody.setItems(buildOrderItemsFromCoupons(coupons, body.getOtaOrderId()));
|
||||
|
||||
try {
|
||||
// 将响应体转换为JSON字符串
|
||||
String bodyJson = objectMapper.writeValueAsString(responseBody);
|
||||
log.info("优惠券查询响应body JSON: {}", bodyJson);
|
||||
log.info("订单查询响应body JSON: {}", bodyJson);
|
||||
|
||||
// 对body进行AES加密
|
||||
String encryptedBody = ctripDecryptUtil.encryptAES(bodyJson);
|
||||
if (encryptedBody == null) {
|
||||
log.error("加密优惠券查询响应body失败");
|
||||
log.error("加密订单查询响应body失败");
|
||||
return buildErrorResponse(header, "0001", "加密响应失败");
|
||||
}
|
||||
|
||||
log.info("优惠券查询响应body加密成功,长度: {}", encryptedBody.length());
|
||||
log.info("订单查询响应body加密成功,长度: {}", encryptedBody.length());
|
||||
response.setBody(encryptedBody);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("构建优惠券查询响应body异常", e);
|
||||
log.error("构建订单查询响应body异常", e);
|
||||
return buildErrorResponse(header, "0001", "构建响应失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据优惠券信息构建订单项列表
|
||||
* 严格按照携程QueryOrder接口标准格式返回数据
|
||||
*/
|
||||
private List<CtripQueryOrderResponse.CtripResponseOrderItem> buildOrderItemsFromCoupons(List<Coupon> coupons, String otaOrderId) {
|
||||
List<CtripQueryOrderResponse.CtripResponseOrderItem> items = new ArrayList<>();
|
||||
|
||||
if (coupons == null || coupons.isEmpty()) {
|
||||
log.warn("没有找到对应的优惠券,otaOrderId: {}", otaOrderId);
|
||||
return items;
|
||||
}
|
||||
|
||||
// 为每个优惠券创建一个订单项
|
||||
for (int i = 0; i < coupons.size(); i++) {
|
||||
Coupon coupon = coupons.get(i);
|
||||
CtripQueryOrderResponse.CtripResponseOrderItem item = new CtripQueryOrderResponse.CtripResponseOrderItem();
|
||||
|
||||
// 设置订单项基本信息(只包含标准格式要求的字段)
|
||||
// itemId: 如果为空(调用了预下单创建接口,但是没有调用预下单支付接口),该字段必需传0
|
||||
String itemId = coupon.getCtripCouponId();
|
||||
if (itemId == null || itemId.trim().isEmpty()) {
|
||||
itemId = "0"; // 按照接口说明,为空时必须传0
|
||||
}
|
||||
item.setItemId(itemId);
|
||||
item.setQuantity(1); // 默认数量为1
|
||||
|
||||
// 设置订单状态和数量信息
|
||||
String status = coupon.getStatus();
|
||||
if ("UNUSED".equals(status)) {
|
||||
item.setOrderStatus(1); // 已确认
|
||||
item.setUseQuantity(0); // 未使用
|
||||
item.setCancelQuantity(0); // 未取消
|
||||
} else if ("USED".equals(status)) {
|
||||
item.setOrderStatus(1); // 已确认
|
||||
item.setUseQuantity(1); // 已使用
|
||||
item.setCancelQuantity(0); // 未取消
|
||||
} else if ("EXPIRED".equals(status)) {
|
||||
item.setOrderStatus(3); // 已过期
|
||||
item.setUseQuantity(0); // 未使用
|
||||
item.setCancelQuantity(0); // 未取消
|
||||
} else {
|
||||
item.setOrderStatus(1); // 默认已确认
|
||||
item.setUseQuantity(0); // 默认未使用
|
||||
item.setCancelQuantity(0); // 默认未取消
|
||||
}
|
||||
|
||||
// 设置使用日期(从优惠券有效期获取)
|
||||
if (coupon.getValidStartTime() != null) {
|
||||
item.setUseStartDate(formatDate(coupon.getValidStartTime()));
|
||||
}
|
||||
if (coupon.getValidEndTime() != null) {
|
||||
item.setUseEndDate(formatDate(coupon.getValidEndTime()));
|
||||
}
|
||||
|
||||
// 设置乘客信息(只包含标准格式要求的字段)
|
||||
List<CtripQueryOrderResponse.CtripResponsePassenger> passengers = new ArrayList<>();
|
||||
if (coupon.getUserPhone() != null) {
|
||||
CtripQueryOrderResponse.CtripResponsePassenger passenger = new CtripQueryOrderResponse.CtripResponsePassenger();
|
||||
passenger.setPassengerId("PASS_" + coupon.getUserPhone());
|
||||
// passengerStatus: 0、待使用;1、已使用;2、已取消
|
||||
if ("UNUSED".equals(status)) {
|
||||
passenger.setPassengerStatus(0); // 待使用
|
||||
} else if ("USED".equals(status)) {
|
||||
passenger.setPassengerStatus(1); // 已使用
|
||||
} else if ("EXPIRED".equals(status)) {
|
||||
passenger.setPassengerStatus(2); // 已取消
|
||||
} else {
|
||||
passenger.setPassengerStatus(0); // 默认待使用
|
||||
}
|
||||
passengers.add(passenger);
|
||||
}
|
||||
item.setPassengers(passengers);
|
||||
|
||||
// 设置凭证信息(只包含标准格式要求的字段)
|
||||
List<CtripQueryOrderResponse.CtripResponseVoucher> vouchers = new ArrayList<>();
|
||||
CtripQueryOrderResponse.CtripResponseVoucher voucher = new CtripQueryOrderResponse.CtripResponseVoucher();
|
||||
voucher.setVoucherId(coupon.getCtripCouponId() != null ? coupon.getCtripCouponId() : "VOUCHER_" + otaOrderId + "_" + (i + 1));
|
||||
// voucherStatus: 0、待使用;1、已使用;2、已取消
|
||||
if ("UNUSED".equals(status)) {
|
||||
voucher.setVoucherStatus(0); // 待使用
|
||||
} else if ("USED".equals(status)) {
|
||||
voucher.setVoucherStatus(1); // 已使用
|
||||
} else if ("EXPIRED".equals(status)) {
|
||||
voucher.setVoucherStatus(2); // 已取消
|
||||
} else {
|
||||
voucher.setVoucherStatus(0); // 默认待使用
|
||||
}
|
||||
vouchers.add(voucher);
|
||||
item.setVouchers(vouchers);
|
||||
|
||||
items.add(item);
|
||||
log.info("构建订单项完成: itemId={}, orderStatus={}, useQuantity={}, cancelQuantity={}",
|
||||
item.getItemId(), item.getOrderStatus(), item.getUseQuantity(), item.getCancelQuantity());
|
||||
}
|
||||
|
||||
log.info("构建订单项列表完成,数量: {}", items.size());
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期为字符串
|
||||
*/
|
||||
private String formatDate(java.util.Date date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建优惠券响应列表
|
||||
*/
|
||||
@@ -471,6 +581,36 @@ public class CtripQueryOrderServiceImpl implements ICtripQueryOrderService {
|
||||
responseHeader.setResultMessage(resultMessage);
|
||||
response.setHeader(responseHeader);
|
||||
|
||||
// 即使返回码不是0000,也加密响应体以确保安全性
|
||||
try {
|
||||
// 创建错误响应体
|
||||
CtripQueryOrderResponse.CtripResponseBody responseBody = new CtripQueryOrderResponse.CtripResponseBody();
|
||||
responseBody.setOtaOrderId(header != null ? "ERROR" : null);
|
||||
responseBody.setSupplierOrderId("ERROR");
|
||||
responseBody.setSequenceId("ERROR");
|
||||
responseBody.setItems(new ArrayList<>()); // 空列表
|
||||
|
||||
// 将响应体转换为JSON字符串
|
||||
String bodyJson = objectMapper.writeValueAsString(responseBody);
|
||||
log.info("错误响应body JSON: {}", bodyJson);
|
||||
|
||||
// 对body进行AES加密
|
||||
String encryptedBody = ctripDecryptUtil.encryptAES(bodyJson);
|
||||
if (encryptedBody == null) {
|
||||
log.error("加密错误响应body失败");
|
||||
// 如果加密失败,设置空字符串
|
||||
response.setBody("");
|
||||
} else {
|
||||
log.info("错误响应body加密成功,长度: {}", encryptedBody.length());
|
||||
response.setBody(encryptedBody);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("构建错误响应body异常", e);
|
||||
// 如果构建失败,设置空字符串
|
||||
response.setBody("");
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
+86
@@ -214,4 +214,90 @@ public class ApiDeviceController {
|
||||
public Result<Map> getWayline(@RequestParam String no){
|
||||
return Result.succeed(orderCenterService.getWaylineByOrderNo(no));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发设备指令接口
|
||||
* 通过设备ID和二维码类型获取航线信息,生成随机订单号,下发指令
|
||||
*/
|
||||
@Operation(summary = "下发设备指令")
|
||||
@PostMapping("/command/{deviceId}")
|
||||
public Result sendDeviceCommand(@PathVariable("deviceId") String deviceId, @RequestParam(defaultValue = "2") Integer qrcodeType) {
|
||||
log.info("开始下发设备指令: deviceId={}, qrcodeType={}", deviceId, qrcodeType);
|
||||
try {
|
||||
// 1. 生成随机订单号
|
||||
String orderNo = generateRandomOrderNo();
|
||||
|
||||
// 2. 根据设备ID和二维码类型获取二维码信息
|
||||
Map<String, Object> qrcodeResult = orderCenterService.getQrcodeByDeviceId(deviceId, qrcodeType);
|
||||
if (qrcodeResult == null || qrcodeResult.isEmpty()) {
|
||||
return Result.failed("未找到对应的二维码配置");
|
||||
}
|
||||
|
||||
// 3. 构建控制消息(使用默认的control参数)
|
||||
JsonObject controlMessage = buildCommandMessage(orderNo, deviceId, qrcodeResult);
|
||||
if (controlMessage == null) {
|
||||
return Result.failed("暂未开放控制权限");
|
||||
}
|
||||
|
||||
// 4. 发送设备控制请求
|
||||
String url = baseUrl + "/device/instance/" + deviceId + "/property";
|
||||
Map<String, String> result = requestUtils.getPostRequestResultMap(url, controlMessage.toString());
|
||||
|
||||
// 5. 处理响应结果
|
||||
return handleDeviceResponse(result, orderNo);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("下发设备指令异常: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
||||
return Result.failed("系统异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机订单号
|
||||
*/
|
||||
private String generateRandomOrderNo() {
|
||||
return "CMD_" + System.currentTimeMillis() + "_" + (int)(Math.random() * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建指令消息
|
||||
*/
|
||||
private JsonObject buildCommandMessage(String orderNo, String deviceId, Map<String, Object> qrcodeResult) {
|
||||
// 使用默认的control参数,这里可以根据需要修改
|
||||
String control = "camera_photo_take"; // 默认使用拍照指令
|
||||
|
||||
if (!ControlEnum.contains(ControlEnum.valueOf(control.toUpperCase()))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
JsonObject jsonObject = gson.fromJson(controlMessageConstant.CONTROL_MESSAGE_MAP.get(control), JsonObject.class);
|
||||
JsonObject data = jsonObject.getAsJsonObject("data");
|
||||
|
||||
// 设置订单信息
|
||||
data.addProperty("order_no", orderNo);
|
||||
|
||||
// 设置航线信息
|
||||
String waylineFilePath = MapUtil.getStrValue(qrcodeResult, "waylineFilePath");
|
||||
String waylineId = MapUtil.getStrValue(qrcodeResult, "waylineId");
|
||||
log.info("waylineFilePath:{}, waylineId:{}", waylineFilePath, waylineId);
|
||||
data.addProperty("wayline_link_url", waylineFilePath);
|
||||
|
||||
LineFile lineFile = lineFileService.findLineFileByWaylineId(waylineId);
|
||||
Assert.notNull(lineFile,"航线文件签名不正确");
|
||||
data.addProperty("file_md5", lineFile.getSign());
|
||||
|
||||
// 新增takeOffOneKey字段
|
||||
data.addProperty("takeOffOneKey", true);
|
||||
|
||||
// 设置设备视频流地址
|
||||
try {
|
||||
data.add("stream_urls", gson.fromJson(liveStreamService.generateStreamUrls(deviceId).toJSONString(), JsonElement.class));
|
||||
} catch (Exception e) {
|
||||
log.error("生成设备推流/拉流地址异常: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
||||
data.addProperty("stream_urls", "{}");
|
||||
}
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -31,6 +31,15 @@ public interface OrderCenterService {
|
||||
@GetMapping("/qrcode/wayline/{orderNo}")
|
||||
Map<String,Object> getWaylineByOrderNo(@PathVariable("orderNo") String orderNo);
|
||||
|
||||
/**
|
||||
* 根据设备ID和二维码类型获取二维码信息
|
||||
* @param deviceId 设备ID
|
||||
* @param qrcodeType 二维码类型(1:游客下单,2:定时巡查,3:其他)
|
||||
* @return 二维码信息
|
||||
*/
|
||||
@GetMapping("/qrcode/device/{deviceId}")
|
||||
Map<String,Object> getQrcodeByDeviceId(@PathVariable("deviceId") String deviceId, @RequestParam("qrcodeType") Integer qrcodeType);
|
||||
|
||||
/**
|
||||
* 设备离线时自动创建退款订单
|
||||
* @param orderNo 订单号
|
||||
|
||||
+1
@@ -913,6 +913,7 @@ public class OrderController {
|
||||
Tourism tourism = tourismMap.get(order.getTourismId());
|
||||
orderFileMap.put("addr", tourism != null ? tourism.getTourismAddress() : "");
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
orderFileMap.put("orderStatus", order.getOrderStatus());
|
||||
|
||||
// 从缓存获取文件列表
|
||||
List<OrderFile> allFiles = orderFilesMap.getOrDefault(order.getOrderNo(), new ArrayList<>());
|
||||
|
||||
+15
@@ -149,4 +149,19 @@ public class QrCodeController {
|
||||
map.put("waylineId",qrCode.getWaylineId());
|
||||
return map;
|
||||
}
|
||||
|
||||
@GetMapping("/device/{deviceId}")
|
||||
public Map<String,Object> getQrcodeByDeviceId(@PathVariable("deviceId") String deviceId, @RequestParam("qrcodeType") Integer qrcodeType){
|
||||
// 根据设备ID和二维码类型查询二维码信息
|
||||
QrCode qrCode = qrCodeService.getByDeviceIdAndType(deviceId, qrcodeType);
|
||||
Assert.notNull(qrCode,"二维码数据不能为空");
|
||||
|
||||
String waylineFilePath = fileCenterService.getFileViewUrl(qrCode.getWaylineId());
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("waylineFilePath",waylineFilePath);
|
||||
map.put("waylineId",qrCode.getWaylineId());
|
||||
map.put("codeId",qrCode.getCodeId());
|
||||
map.put("tourismId",qrCode.getTourismId());
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,12 @@ public interface QrCodeMapper extends SuperMapper<QrCode> {
|
||||
// ID查询
|
||||
QrCode getByCodeId(@Param("codeId") String codeId);
|
||||
|
||||
/**
|
||||
* 根据设备ID和二维码类型查询二维码信息
|
||||
* @param deviceId 设备ID
|
||||
* @param qrcodeType 二维码类型
|
||||
* @return 二维码信息
|
||||
*/
|
||||
QrCode getByDeviceIdAndType(@Param("deviceId") String deviceId, @Param("qrcodeType") Integer qrcodeType);
|
||||
|
||||
}
|
||||
|
||||
@@ -105,4 +105,10 @@ public class QrCode extends SuperEntity {
|
||||
@Schema(description = "是否为测试二维码")
|
||||
private Integer isTest;
|
||||
|
||||
/**
|
||||
* 二维码类型(1:游客下单,2:定时巡查,3:其他)
|
||||
*/
|
||||
@Schema(description = "二维码类型(1:游客下单,2:定时巡查,3:其他)")
|
||||
private Integer qrcodeType;
|
||||
|
||||
}
|
||||
|
||||
@@ -34,5 +34,13 @@ public interface IQrCodeService extends ISuperService<QrCode> {
|
||||
* @return
|
||||
*/
|
||||
QrCode getByCodeId(String codeId);
|
||||
|
||||
/**
|
||||
* 根据设备ID和二维码类型查询二维码信息
|
||||
* @param deviceId 设备ID
|
||||
* @param qrcodeType 二维码类型
|
||||
* @return 二维码信息
|
||||
*/
|
||||
QrCode getByDeviceIdAndType(String deviceId, Integer qrcodeType);
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -51,6 +51,11 @@ public class QrCodeServiceImpl extends SuperServiceImpl<QrCodeMapper, QrCode> im
|
||||
return baseMapper.getByCodeId(codeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QrCode getByDeviceIdAndType(String deviceId, Integer qrcodeType) {
|
||||
return baseMapper.getByDeviceIdAndType(deviceId, qrcodeType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
<if test="p.deviceSn != null and p.deviceSn != ''">
|
||||
AND q.device_sn = #{p.deviceSn}
|
||||
</if>
|
||||
<if test="p.qrcodeType != null">
|
||||
AND q.qrcode_type = #{p.qrcodeType}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY q.create_time DESC
|
||||
</select>
|
||||
@@ -44,4 +47,13 @@
|
||||
INSERT INTO qrcodes (code_id, tourism_id, device_sn)
|
||||
VALUES (#{codeId}, #{tourismId}, #{deviceSn})
|
||||
</insert>
|
||||
|
||||
<select id="getByDeviceIdAndType" resultMap="QrCodeResultMap">
|
||||
SELECT * FROM qrcodes
|
||||
WHERE device_sn = #{deviceId}
|
||||
AND qrcode_type = #{qrcodeType}
|
||||
AND is_del = 0
|
||||
ORDER BY create_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
+10
-1
@@ -7,7 +7,7 @@ import {
|
||||
ProFormDigit,
|
||||
} from '@ant-design/pro-components';
|
||||
import { Form } from 'antd';
|
||||
import { ENABLE_PROFIT_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS } from '../index';
|
||||
import { ENABLE_PROFIT_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS, QRCODE_TYPE_OPTIONS } from '../index';
|
||||
|
||||
// 添加测试二维码选项常量
|
||||
export const IS_TEST_OPTIONS = [
|
||||
@@ -201,6 +201,15 @@ const CreateForm: React.FC<CreateFormProps> = ({
|
||||
initialValue={0}
|
||||
tooltip="测试二维码的数据不会计入正式统计"
|
||||
/>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="qrcodeType"
|
||||
label="二维码类型"
|
||||
options={QRCODE_TYPE_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择二维码类型' }]}
|
||||
initialValue={1}
|
||||
tooltip="用于区分该二维码是游客下单、定时巡查,还是其他用途"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
|
||||
+9
-1
@@ -6,7 +6,7 @@ import {
|
||||
ProFormText,
|
||||
ProFormDigit,
|
||||
} from '@ant-design/pro-components';
|
||||
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_PROFIT_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS } from '../index';
|
||||
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_PROFIT_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS, QRCODE_TYPE_OPTIONS } from '../index';
|
||||
import { Form, Space } from 'antd';
|
||||
import styles from './index.less';
|
||||
|
||||
@@ -210,6 +210,14 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
||||
rules={[{ required: true, message: '请选择是否为测试二维码' }]}
|
||||
tooltip="测试二维码的数据不会计入正式统计"
|
||||
/>
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="qrcodeType"
|
||||
label="二维码类型"
|
||||
options={QRCODE_TYPE_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择二维码类型' }]}
|
||||
tooltip="用于区分该二维码是游客下单、定时巡查,还是其他用途"
|
||||
/>
|
||||
</ProForm.Group>
|
||||
|
||||
<ProForm.Group>
|
||||
|
||||
@@ -61,6 +61,13 @@ export const IS_TEST_OPTIONS = [
|
||||
{ label: '是', value: 1 },
|
||||
] as const;
|
||||
|
||||
// 添加二维码类型选项常量
|
||||
export const QRCODE_TYPE_OPTIONS = [
|
||||
{ label: '游客下单', value: 1 },
|
||||
{ label: '定时巡查', value: 2 },
|
||||
{ label: '其他', value: 3 },
|
||||
] as const;
|
||||
|
||||
const handleApiRequest = async (
|
||||
apiCall: () => Promise<any>,
|
||||
loadingMessage: string,
|
||||
@@ -461,6 +468,25 @@ const TableList: React.FC = () => {
|
||||
1: { text: '是' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '二维码类型',
|
||||
dataIndex: 'qrcodeType',
|
||||
width: 120,
|
||||
render: (_, record) => {
|
||||
const typeMap = {
|
||||
1: { color: 'green', text: '游客下单' },
|
||||
2: { color: 'blue', text: '定时巡查' },
|
||||
3: { color: 'orange', text: '其他' },
|
||||
};
|
||||
const { color, text } = typeMap[record.qrcodeType || 1] || typeMap[1];
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
},
|
||||
valueEnum: {
|
||||
1: { text: '游客下单' },
|
||||
2: { text: '定时巡查' },
|
||||
3: { text: '其他' },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '应用ID',
|
||||
dataIndex: 'tenantId',
|
||||
@@ -542,6 +568,12 @@ const TableList: React.FC = () => {
|
||||
placeholder="请选择是否为测试二维码"
|
||||
options={IS_TEST_OPTIONS}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="qrcodeType"
|
||||
label="二维码类型"
|
||||
placeholder="请选择二维码类型"
|
||||
options={QRCODE_TYPE_OPTIONS}
|
||||
/>
|
||||
<ProFormSelect
|
||||
name="tenantId"
|
||||
label="应用ID"
|
||||
|
||||
@@ -86,6 +86,7 @@ declare namespace ORDERS {
|
||||
enableProfit?: number; // 是否开启分润(0:否,1:是)
|
||||
enableVideoEdit?: number; // 是否开启一键成片(0:否,1:是)
|
||||
waylineId?: string; // 航线ID
|
||||
qrcodeType?: number; // 二维码类型(1:游客下单,2:定时巡查,3:其他)
|
||||
}
|
||||
|
||||
type HomeCarousel = {
|
||||
|
||||
Reference in New Issue
Block a user