fix(优惠券中心):新增携程优惠券独立微服务模块
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
package com.central.coupon;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 优惠券中心启动类
|
||||
*
|
||||
* @author system
|
||||
* @date 2024-12-19
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@ComponentScan(basePackages = {"com.central.coupon"})
|
||||
public class CouponCenterApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CouponCenterApplication.class, args);
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package com.central.coupon.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.coupon.entity.Coupon;
|
||||
import com.central.coupon.service.ICouponService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 优惠券管理控制器
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/coupon")
|
||||
@Tag(name = "优惠券管理")
|
||||
public class CouponController {
|
||||
|
||||
@Autowired
|
||||
private ICouponService couponService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@Operation(summary = "查询列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping
|
||||
public PageResult<Coupon> list(@RequestParam Map<String, Object> params) {
|
||||
return couponService.findList(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询优惠券
|
||||
*/
|
||||
@Operation(summary = "根据ID查询优惠券")
|
||||
@GetMapping("/{id}")
|
||||
public Result<Coupon> getCouponById(@PathVariable Long id) {
|
||||
Coupon coupon = couponService.getById(id);
|
||||
return Result.succeed(coupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建优惠券
|
||||
*/
|
||||
@Operation(summary = "创建优惠券")
|
||||
@PostMapping
|
||||
public Result<Boolean> createCoupon(@RequestBody Coupon coupon) {
|
||||
boolean result = couponService.createCoupon(coupon);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新优惠券
|
||||
*/
|
||||
@Operation(summary = "更新优惠券")
|
||||
@PutMapping("/{id}")
|
||||
public Result<Boolean> updateCoupon(@PathVariable Long id, @RequestBody Coupon coupon) {
|
||||
coupon.setId(id);
|
||||
boolean result = couponService.updateCoupon(coupon);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除优惠券
|
||||
*/
|
||||
@Operation(summary = "删除优惠券")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Boolean> deleteCoupon(@PathVariable Long id) {
|
||||
boolean result = couponService.deleteCoupon(id);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户优惠券
|
||||
*/
|
||||
@Operation(summary = "根据手机号查询用户优惠券")
|
||||
@GetMapping("/user/{userPhone}")
|
||||
public Result<List<Coupon>> getCouponsByUserPhone(@PathVariable String userPhone) {
|
||||
List<Coupon> coupons = couponService.getCouponsByUserPhone(userPhone);
|
||||
return Result.succeed(coupons);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号查询可用优惠券
|
||||
*/
|
||||
@Operation(summary = "根据手机号查询可用优惠券")
|
||||
@GetMapping("/user/{userPhone}/available")
|
||||
public Result<List<Coupon>> getAvailableCouponsByUserPhone(@PathVariable String userPhone) {
|
||||
List<Coupon> coupons = couponService.getAvailableCouponsByUserPhone(userPhone);
|
||||
return Result.succeed(coupons);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用优惠券
|
||||
*/
|
||||
@Operation(summary = "使用优惠券")
|
||||
@PostMapping("/{id}/use")
|
||||
public Result<Boolean> useCoupon(@PathVariable Long id, @RequestParam String orderNo) {
|
||||
boolean result = couponService.useCoupon(id, orderNo);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
}
|
||||
+306
@@ -0,0 +1,306 @@
|
||||
package com.central.coupon.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.coupon.entity.Coupon;
|
||||
import com.central.coupon.service.ICouponService;
|
||||
import com.central.coupon.util.CtripDecryptUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 携程优惠券控制器
|
||||
* 专门处理携程相关的优惠券接口
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/coupon/ctrip")
|
||||
@Tag(name = "携程优惠券管理")
|
||||
public class CtripCouponController {
|
||||
|
||||
@Autowired
|
||||
private ICouponService couponService;
|
||||
|
||||
/**
|
||||
* 携程创建优惠券接口
|
||||
* 携程下单后回调,创建用户优惠券(手机号+携程券ID唯一,幂等)
|
||||
*
|
||||
* 请求参数:
|
||||
* - ctripCouponId: 携程券ID(唯一)
|
||||
* - userPhone: 用户手机号
|
||||
* - couponName: 优惠券名称
|
||||
* - couponType: 优惠券类型
|
||||
* - amount: 优惠券面额
|
||||
* - minAmount: 使用门槛金额(可选)
|
||||
* - discountRate: 折扣率(可选)
|
||||
* - validStartTime: 有效期开始时间(yyyy-MM-dd或yyyy-MM-dd HH:mm:ss)
|
||||
* - validEndTime: 有效期结束时间(yyyy-MM-dd或yyyy-MM-dd HH:mm:ss)
|
||||
*/
|
||||
@Operation(summary = "携程创建优惠券接口")
|
||||
@PostMapping("/create")
|
||||
public Result<Boolean> createCouponFromCtrip(@RequestBody Map<String, Object> request,
|
||||
HttpServletRequest httpRequest) {
|
||||
log.info("收到携程创建优惠券请求,IP: {}", httpRequest.getRemoteAddr());
|
||||
|
||||
try {
|
||||
// 提取请求参数
|
||||
String ctripCouponId = (String) request.get("ctripCouponId");
|
||||
String userPhone = (String) request.get("userPhone");
|
||||
String couponName = (String) request.get("couponName");
|
||||
Integer couponType = (Integer) request.get("couponType");
|
||||
BigDecimal amount = null;
|
||||
if (request.get("amount") != null) {
|
||||
amount = new BigDecimal(request.get("amount").toString());
|
||||
}
|
||||
BigDecimal minAmount = null;
|
||||
if (request.get("minAmount") != null) {
|
||||
minAmount = new BigDecimal(request.get("minAmount").toString());
|
||||
}
|
||||
Integer discountRate = (Integer) request.get("discountRate");
|
||||
String validStartTimeStr = (String) request.get("validStartTime");
|
||||
String validEndTimeStr = (String) request.get("validEndTime");
|
||||
|
||||
// 参数验证
|
||||
if (ctripCouponId == null || userPhone == null || couponName == null ||
|
||||
couponType == null || amount == null || validStartTimeStr == null || validEndTimeStr == null) {
|
||||
log.error("参数不完整 - ctripCouponId: {}, userPhone: {}, couponName: {}, couponType: {}, amount: {}, validStartTime: {}, validEndTime: {}",
|
||||
ctripCouponId, userPhone, couponName, couponType, amount, validStartTimeStr, validEndTimeStr);
|
||||
return Result.failed("参数不完整");
|
||||
}
|
||||
|
||||
// 幂等校验
|
||||
if (couponService.existsByUserPhoneAndCtripCouponId(userPhone, ctripCouponId)) {
|
||||
log.info("携程优惠券已存在,userPhone: {}, ctripCouponId: {}", userPhone, ctripCouponId);
|
||||
return Result.succeed(true);
|
||||
}
|
||||
|
||||
// 时间解析
|
||||
Date validStartTime = parseDate(validStartTimeStr);
|
||||
Date validEndTime = parseDate(validEndTimeStr);
|
||||
|
||||
if (validStartTime == null || validEndTime == null) {
|
||||
log.error("时间格式错误 - validStartTime: {}, validEndTime: {}", validStartTimeStr, validEndTimeStr);
|
||||
return Result.failed("时间格式错误");
|
||||
}
|
||||
|
||||
// 创建优惠券
|
||||
boolean result = couponService.createCouponFromCtrip(ctripCouponId, userPhone, couponName,
|
||||
couponType, amount, minAmount, discountRate, validStartTime, validEndTime);
|
||||
|
||||
if (result) {
|
||||
log.info("携程优惠券创建成功 - ctripCouponId: {}, userPhone: {}", ctripCouponId, userPhone);
|
||||
return Result.succeed(true);
|
||||
} else {
|
||||
log.error("携程优惠券创建失败 - ctripCouponId: {}, userPhone: {}", ctripCouponId, userPhone);
|
||||
return Result.failed("创建失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理携程创建优惠券请求异常", e);
|
||||
return Result.failed("系统异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程取消优惠券接口
|
||||
* 携程退券回调,取消用户优惠券(默认退第一个未用券)
|
||||
*
|
||||
* 请求参数:
|
||||
* - userPhone: 用户手机号
|
||||
*/
|
||||
@Operation(summary = "携程取消优惠券接口")
|
||||
@PostMapping("/cancel")
|
||||
public Result<Boolean> cancelCouponFromCtrip(@RequestParam String userPhone,
|
||||
HttpServletRequest httpRequest) {
|
||||
log.info("收到携程取消优惠券请求,IP: {}, userPhone: {}", httpRequest.getRemoteAddr(), userPhone);
|
||||
|
||||
try {
|
||||
// 参数验证
|
||||
if (userPhone == null || userPhone.trim().isEmpty()) {
|
||||
log.error("用户手机号不能为空");
|
||||
return Result.failed("用户手机号不能为空");
|
||||
}
|
||||
|
||||
// 查询用户可用优惠券
|
||||
List<Coupon> availableCoupons = couponService.getAvailableCouponsByUserPhone(userPhone);
|
||||
|
||||
if (availableCoupons.isEmpty()) {
|
||||
log.warn("用户无可用优惠券,userPhone: {}", userPhone);
|
||||
return Result.failed("无可退优惠券");
|
||||
}
|
||||
|
||||
// 选择第一个可用优惠券进行取消
|
||||
Coupon coupon = availableCoupons.get(0);
|
||||
coupon.setStatus(3); // 已作废
|
||||
coupon.setCancelTime(new Date());
|
||||
coupon.setUpdateTime(new Date());
|
||||
coupon.setUpdateBy("ctrip");
|
||||
|
||||
boolean result = couponService.updateCoupon(coupon);
|
||||
|
||||
if (result) {
|
||||
log.info("携程优惠券取消成功 - couponId: {}, userPhone: {}", coupon.getId(), userPhone);
|
||||
return Result.succeed(true);
|
||||
} else {
|
||||
log.error("携程优惠券取消失败 - couponId: {}, userPhone: {}", coupon.getId(), userPhone);
|
||||
return Result.failed("取消失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理携程取消优惠券请求异常", e);
|
||||
return Result.failed("系统异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销携程优惠券接口
|
||||
* 用户下单时,先查本地券,再调用携程核销接口,核销成功后本地状态设为已用
|
||||
*
|
||||
* 请求参数:
|
||||
* - userPhone: 用户手机号
|
||||
* - orderNo: 订单号
|
||||
*/
|
||||
@Operation(summary = "核销携程优惠券")
|
||||
@PostMapping("/verify")
|
||||
public Result<Boolean> verifyCtripCoupon(@RequestParam String userPhone,
|
||||
@RequestParam String orderNo,
|
||||
HttpServletRequest httpRequest) {
|
||||
log.info("收到核销携程优惠券请求,IP: {}, userPhone: {}, orderNo: {}",
|
||||
httpRequest.getRemoteAddr(), userPhone, orderNo);
|
||||
|
||||
try {
|
||||
// 参数验证
|
||||
if (userPhone == null || userPhone.trim().isEmpty()) {
|
||||
log.error("用户手机号不能为空");
|
||||
return Result.failed("用户手机号不能为空");
|
||||
}
|
||||
if (orderNo == null || orderNo.trim().isEmpty()) {
|
||||
log.error("订单号不能为空");
|
||||
return Result.failed("订单号不能为空");
|
||||
}
|
||||
|
||||
// 查询用户可用优惠券
|
||||
List<Coupon> availableCoupons = couponService.getAvailableCouponsByUserPhone(userPhone);
|
||||
if (availableCoupons.isEmpty()) {
|
||||
log.warn("用户无可用优惠券,userPhone: {}", userPhone);
|
||||
return Result.failed("无可用优惠券");
|
||||
}
|
||||
|
||||
// 选择第一个可用优惠券进行核销
|
||||
Coupon coupon = availableCoupons.get(0);
|
||||
log.info("选择优惠券进行核销 - couponId: {}, ctripCouponId: {}, amount: {}",
|
||||
coupon.getId(), coupon.getCtripCouponId(), coupon.getAmount());
|
||||
|
||||
// 调用携程核销接口
|
||||
boolean result = couponService.verifyCtripCoupon(coupon.getCtripCouponId(), orderNo);
|
||||
if (result) {
|
||||
log.info("携程核销成功,更新本地优惠券状态 - couponId: {}, orderNo: {}", coupon.getId(), orderNo);
|
||||
coupon.setStatus(1); // 已用
|
||||
coupon.setUsedTime(new Date());
|
||||
coupon.setUsedOrderNo(orderNo);
|
||||
couponService.updateCoupon(coupon);
|
||||
return Result.succeed(true);
|
||||
} else {
|
||||
log.error("携程核销失败,couponId: {}, orderNo: {}", coupon.getId(), orderNo);
|
||||
return Result.failed("携程核销失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("核销携程优惠券失败", e);
|
||||
return Result.failed("核销失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询携程优惠券状态
|
||||
*
|
||||
* 路径参数:
|
||||
* - ctripCouponId: 携程优惠券ID
|
||||
*/
|
||||
@Operation(summary = "查询携程优惠券状态")
|
||||
@GetMapping("/status/{ctripCouponId}")
|
||||
public Result<Map<String, Object>> getCtripCouponStatus(@PathVariable String ctripCouponId) {
|
||||
log.info("查询携程优惠券状态,ctripCouponId: {}", ctripCouponId);
|
||||
|
||||
try {
|
||||
if (ctripCouponId == null || ctripCouponId.trim().isEmpty()) {
|
||||
log.error("携程优惠券ID不能为空");
|
||||
return Result.failed("携程优惠券ID不能为空");
|
||||
}
|
||||
|
||||
Coupon coupon = couponService.getByCtripCouponId(ctripCouponId);
|
||||
if (coupon == null) {
|
||||
log.warn("优惠券不存在,ctripCouponId: {}", ctripCouponId);
|
||||
return Result.failed("优惠券不存在");
|
||||
}
|
||||
|
||||
Map<String, Object> status = Map.of(
|
||||
"ctripCouponId", coupon.getCtripCouponId(),
|
||||
"status", coupon.getStatus(),
|
||||
"statusText", getStatusText(coupon.getStatus()),
|
||||
"userPhone", coupon.getUserPhone(),
|
||||
"amount", coupon.getAmount(),
|
||||
"validStartTime", coupon.getValidStartTime(),
|
||||
"validEndTime", coupon.getValidEndTime(),
|
||||
"usedTime", coupon.getUsedTime(),
|
||||
"usedOrderNo", coupon.getUsedOrderNo()
|
||||
);
|
||||
|
||||
return Result.succeed(status);
|
||||
} catch (Exception e) {
|
||||
log.error("查询携程优惠券状态失败", e);
|
||||
return Result.failed("查询失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析日期字符串
|
||||
* 支持 yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss 格式
|
||||
*/
|
||||
private Date parseDate(String dateStr) {
|
||||
try {
|
||||
if (dateStr == null || dateStr.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dateStr.length() == 10) {
|
||||
// yyyy-MM-dd 格式
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return sdf.parse(dateStr);
|
||||
} else if (dateStr.length() == 19) {
|
||||
// yyyy-MM-dd HH:mm:ss 格式
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.parse(dateStr);
|
||||
} else {
|
||||
log.error("不支持的日期格式: {}", dateStr);
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("日期解析失败: {}", dateStr, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态文本
|
||||
*/
|
||||
private String getStatusText(Integer status) {
|
||||
switch (status) {
|
||||
case 0: return "未使用";
|
||||
case 1: return "已使用";
|
||||
case 2: return "已过期";
|
||||
case 3: return "已作废";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
}
|
||||
+1052
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,143 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 优惠券实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_coupon")
|
||||
public class Coupon implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 优惠券编号
|
||||
*/
|
||||
private String couponNo;
|
||||
|
||||
/**
|
||||
* 优惠券名称
|
||||
*/
|
||||
private String couponName;
|
||||
|
||||
/**
|
||||
* 优惠券类型:1-满减券,2-折扣券,3-免费券
|
||||
*/
|
||||
private Integer couponType;
|
||||
|
||||
/**
|
||||
* 优惠券面额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 使用门槛金额
|
||||
*/
|
||||
private BigDecimal minAmount;
|
||||
|
||||
/**
|
||||
* 折扣率(0-100,折扣券时使用)
|
||||
*/
|
||||
private Integer discountRate;
|
||||
|
||||
/**
|
||||
* 优惠券状态:0-未使用,1-已使用,2-已过期,3-已作废
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 用户手机号
|
||||
*/
|
||||
private String userPhone;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 来源:1-携程,2-高飞自建
|
||||
*/
|
||||
private Integer source;
|
||||
|
||||
/**
|
||||
* 携程优惠券ID(来源为携程时使用)
|
||||
*/
|
||||
private String ctripCouponId;
|
||||
|
||||
/**
|
||||
* 有效期开始时间
|
||||
*/
|
||||
private Date validStartTime;
|
||||
|
||||
/**
|
||||
* 有效期结束时间
|
||||
*/
|
||||
private Date validEndTime;
|
||||
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
private Date usedTime;
|
||||
|
||||
/**
|
||||
* 使用订单号
|
||||
*/
|
||||
private String usedOrderNo;
|
||||
|
||||
/**
|
||||
* 退券时间
|
||||
*/
|
||||
private Date cancelTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 携程核销实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_consumed")
|
||||
public class CtripConsumed {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 携程订单号
|
||||
*/
|
||||
private String otaOrderId;
|
||||
|
||||
/**
|
||||
* 供应商订单号
|
||||
*/
|
||||
private String supplierOrderId;
|
||||
|
||||
/**
|
||||
* 供应商处理批次流水号
|
||||
*/
|
||||
private String sequenceId;
|
||||
|
||||
/**
|
||||
* 订单项编号
|
||||
*/
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* 使用开始日期
|
||||
*/
|
||||
private String useStartDate;
|
||||
|
||||
/**
|
||||
* 使用结束日期
|
||||
*/
|
||||
private String useEndDate;
|
||||
|
||||
/**
|
||||
* 总数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 已使用数量
|
||||
*/
|
||||
private Integer useQuantity;
|
||||
|
||||
/**
|
||||
* 丢失金额
|
||||
*/
|
||||
private BigDecimal lostAmount;
|
||||
|
||||
/**
|
||||
* 丢失金额货币
|
||||
*/
|
||||
private String lostAmountCurrency;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 核销状态:0-待核销,1-已核销,2-部分核销,3-核销失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarkDetail;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 携程核销乘客信息实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_consumed_passenger")
|
||||
public class CtripConsumedPassenger {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 核销ID
|
||||
*/
|
||||
private Long consumedId;
|
||||
|
||||
/**
|
||||
* 乘客ID
|
||||
*/
|
||||
private String passengerId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 携程核销凭证信息实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_consumed_voucher")
|
||||
public class CtripConsumedVoucher {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 核销ID
|
||||
*/
|
||||
private Long consumedId;
|
||||
|
||||
/**
|
||||
* 凭证ID
|
||||
*/
|
||||
private String voucherId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 携程订单实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_order")
|
||||
public class CtripOrder {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 携程订单号
|
||||
*/
|
||||
private String otaOrderId;
|
||||
|
||||
/**
|
||||
* 供应商订单号
|
||||
*/
|
||||
private String supplierOrderId;
|
||||
|
||||
/**
|
||||
* 携程批次流水号
|
||||
*/
|
||||
private String sequenceId;
|
||||
|
||||
/**
|
||||
* 确认类型:1-仅通知,2-需确认
|
||||
*/
|
||||
private Integer confirmType;
|
||||
|
||||
/**
|
||||
* 最晚确认时间
|
||||
*/
|
||||
private LocalDateTime orderLastConfirmTime;
|
||||
|
||||
/**
|
||||
* 订单状态:0-待确认,1-已确认,2-已取消,3-已过期
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 携程订单项实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_order_item")
|
||||
public class CtripOrderItem {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单ID
|
||||
*/
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 订单项编号
|
||||
*/
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* 产品编码
|
||||
*/
|
||||
private String plu;
|
||||
|
||||
/**
|
||||
* 使用开始日期
|
||||
*/
|
||||
private LocalDate useStartDate;
|
||||
|
||||
/**
|
||||
* 使用结束日期
|
||||
*/
|
||||
private LocalDate useEndDate;
|
||||
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 销售价格
|
||||
*/
|
||||
private BigDecimal salePrice;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 携程乘客信息实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_passenger")
|
||||
public class CtripPassenger {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单项ID
|
||||
*/
|
||||
private Long orderItemId;
|
||||
|
||||
/**
|
||||
* 乘客ID
|
||||
*/
|
||||
private String passengerId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 证件类型
|
||||
*/
|
||||
private String cardType;
|
||||
|
||||
/**
|
||||
* 证件号码
|
||||
*/
|
||||
private String cardNo;
|
||||
|
||||
/**
|
||||
* 年龄类型:ADU-成人,CHD-儿童,INF-婴儿
|
||||
*/
|
||||
private String ageType;
|
||||
|
||||
/**
|
||||
* 性别:M-男,F-女
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 携程退款实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_refund")
|
||||
public class CtripRefund {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 携程订单号
|
||||
*/
|
||||
private String otaOrderId;
|
||||
|
||||
/**
|
||||
* 供应商订单号
|
||||
*/
|
||||
private String supplierOrderId;
|
||||
|
||||
/**
|
||||
* 携程批次流水号
|
||||
*/
|
||||
private String sequenceId;
|
||||
|
||||
/**
|
||||
* 退款总金额
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 退款总金额货币
|
||||
*/
|
||||
private String totalAmountCurrency;
|
||||
|
||||
/**
|
||||
* 最晚确认时间
|
||||
*/
|
||||
private LocalDateTime lastConfirmTime;
|
||||
|
||||
/**
|
||||
* 退款状态:0-待确认,1-已确认,2-已拒绝,3-已过期
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 确认结果码
|
||||
*/
|
||||
private String confirmResultCode;
|
||||
|
||||
/**
|
||||
* 确认结果信息
|
||||
*/
|
||||
private String confirmResultMessage;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.central.coupon.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 携程退款项实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("t_ctrip_refund_item")
|
||||
public class CtripRefundItem {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 退款ID
|
||||
*/
|
||||
private Long refundId;
|
||||
|
||||
/**
|
||||
* 订单项编号
|
||||
*/
|
||||
private String itemId;
|
||||
|
||||
/**
|
||||
* 供应商产品最小单位
|
||||
*/
|
||||
private String plu;
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 退款金额货币
|
||||
*/
|
||||
private String amountCurrency;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.coupon.entity.Coupon;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CouponMapper extends BaseMapper<Coupon> {
|
||||
|
||||
/**
|
||||
* 分页查询优惠券列表
|
||||
*/
|
||||
IPage<Coupon> selectCouponPage(Page<Coupon> page, @Param("coupon") Coupon coupon);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户优惠券
|
||||
*/
|
||||
List<Coupon> selectByUserPhone(@Param("userPhone") String userPhone);
|
||||
|
||||
/**
|
||||
* 根据手机号查询可用优惠券
|
||||
*/
|
||||
List<Coupon> selectAvailableByUserPhone(@Param("userPhone") String userPhone);
|
||||
|
||||
/**
|
||||
* 根据携程优惠券ID查询
|
||||
*/
|
||||
Coupon selectByCtripCouponId(@Param("ctripCouponId") String ctripCouponId);
|
||||
|
||||
/**
|
||||
* 根据订单号查询使用的优惠券
|
||||
*/
|
||||
Coupon selectByUsedOrderNo(@Param("usedOrderNo") String usedOrderNo);
|
||||
|
||||
/**
|
||||
* 更新优惠券状态为已使用
|
||||
*/
|
||||
int updateCouponUsed(@Param("id") Long id, @Param("usedOrderNo") String usedOrderNo);
|
||||
|
||||
/**
|
||||
* 批量更新过期优惠券状态
|
||||
*/
|
||||
int updateExpiredCoupons();
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.coupon.entity.CtripConsumed;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程核销Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CtripConsumedMapper extends BaseMapper<CtripConsumed> {
|
||||
|
||||
/**
|
||||
* 根据携程订单号查询核销信息
|
||||
*
|
||||
* @param otaOrderId 携程订单号
|
||||
* @return 核销信息列表
|
||||
*/
|
||||
List<CtripConsumed> selectByOtaOrderId(@Param("otaOrderId") String otaOrderId);
|
||||
|
||||
/**
|
||||
* 根据供应商订单号查询核销信息
|
||||
*
|
||||
* @param supplierOrderId 供应商订单号
|
||||
* @return 核销信息列表
|
||||
*/
|
||||
List<CtripConsumed> selectBySupplierOrderId(@Param("supplierOrderId") String supplierOrderId);
|
||||
|
||||
/**
|
||||
* 根据供应商批次流水号查询核销信息
|
||||
*
|
||||
* @param sequenceId 供应商批次流水号
|
||||
* @return 核销信息
|
||||
*/
|
||||
CtripConsumed selectBySequenceId(@Param("sequenceId") String sequenceId);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.coupon.entity.CtripConsumedPassenger;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程核销乘客信息Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CtripConsumedPassengerMapper extends BaseMapper<CtripConsumedPassenger> {
|
||||
|
||||
/**
|
||||
* 根据核销ID查询乘客列表
|
||||
*
|
||||
* @param consumedId 核销ID
|
||||
* @return 乘客列表
|
||||
*/
|
||||
List<CtripConsumedPassenger> selectByConsumedId(@Param("consumedId") Long consumedId);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.coupon.entity.CtripConsumedVoucher;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程核销凭证信息Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CtripConsumedVoucherMapper extends BaseMapper<CtripConsumedVoucher> {
|
||||
|
||||
/**
|
||||
* 根据核销ID查询凭证列表
|
||||
*
|
||||
* @param consumedId 核销ID
|
||||
* @return 凭证列表
|
||||
*/
|
||||
List<CtripConsumedVoucher> selectByConsumedId(@Param("consumedId") Long consumedId);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.order.entity.CtripOrderItem;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单项Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CtripOrderItemMapper extends BaseMapper<CtripOrderItem> {
|
||||
|
||||
/**
|
||||
* 根据订单ID查询订单项列表
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @return 订单项列表
|
||||
*/
|
||||
List<CtripOrderItem> selectByOrderId(@Param("orderId") Long orderId);
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.order.entity.CtripOrder;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 携程订单Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CtripOrderMapper extends BaseMapper<CtripOrder> {
|
||||
|
||||
/**
|
||||
* 根据携程订单号查询订单
|
||||
*
|
||||
* @param otaOrderId 携程订单号
|
||||
* @return 订单信息
|
||||
*/
|
||||
CtripOrder selectByOtaOrderId(@Param("otaOrderId") String otaOrderId);
|
||||
|
||||
/**
|
||||
* 根据供应商订单号查询订单
|
||||
*
|
||||
* @param supplierOrderId 供应商订单号
|
||||
* @return 订单信息
|
||||
*/
|
||||
CtripOrder selectBySupplierOrderId(@Param("supplierOrderId") String supplierOrderId);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.order.entity.CtripPassenger;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程乘客信息Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CtripPassengerMapper extends BaseMapper<CtripPassenger> {
|
||||
|
||||
/**
|
||||
* 根据订单项ID查询乘客列表
|
||||
*
|
||||
* @param orderItemId 订单项ID
|
||||
* @return 乘客列表
|
||||
*/
|
||||
List<CtripPassenger> selectByOrderItemId(@Param("orderItemId") Long orderItemId);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.coupon.entity.CtripRefundItem;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程退款项Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CtripRefundItemMapper extends BaseMapper<CtripRefundItem> {
|
||||
|
||||
/**
|
||||
* 根据退款ID查询退款项列表
|
||||
*
|
||||
* @param refundId 退款ID
|
||||
* @return 退款项列表
|
||||
*/
|
||||
List<CtripRefundItem> selectByRefundId(@Param("refundId") Long refundId);
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.central.coupon.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.coupon.entity.CtripRefund;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 携程退款Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface CtripRefundMapper extends BaseMapper<CtripRefund> {
|
||||
|
||||
/**
|
||||
* 根据携程订单号查询退款信息
|
||||
*
|
||||
* @param otaOrderId 携程订单号
|
||||
* @return 退款信息
|
||||
*/
|
||||
CtripRefund selectByOtaOrderId(@Param("otaOrderId") String otaOrderId);
|
||||
|
||||
/**
|
||||
* 根据供应商订单号查询退款信息
|
||||
*
|
||||
* @param supplierOrderId 供应商订单号
|
||||
* @return 退款信息
|
||||
*/
|
||||
CtripRefund selectBySupplierOrderId(@Param("supplierOrderId") String supplierOrderId);
|
||||
|
||||
/**
|
||||
* 根据携程批次流水号查询退款信息
|
||||
*
|
||||
* @param sequenceId 携程批次流水号
|
||||
* @return 退款信息
|
||||
*/
|
||||
CtripRefund selectBySequenceId(@Param("sequenceId") String sequenceId);
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单取消确认请求
|
||||
* 当订单在取消提交后供应商需异步确认进行操作(接受、拒绝)
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCancelOrderConfirmRequest {
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripHeader header;
|
||||
|
||||
/**
|
||||
* 请求体 - 可能是加密字符串或JSON对象
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private Object body;
|
||||
|
||||
/**
|
||||
* 携程请求头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripHeader {
|
||||
@JsonProperty("accountId")
|
||||
private String accountId; // 供应商帐号,由携程分配
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName; // 接口名称: CancelOrderConfirm
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime; // 请求时间(格式: yyyy-MM-dd HH:mm:ss)
|
||||
@JsonProperty("version")
|
||||
private String version; // 版本号, 1.0
|
||||
@JsonProperty("sign")
|
||||
private String sign; // 签名
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单取消确认体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripCancelOrderConfirmBody {
|
||||
@JsonProperty("sequenceId")
|
||||
private String sequenceId; // 供应商处理批次流水号
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId; // 携程订单号
|
||||
@JsonProperty("supplierOrderId")
|
||||
private String supplierOrderId; // 供应商订单号
|
||||
@JsonProperty("confirmResultCode")
|
||||
private String confirmResultCode; // 确认结果返回码
|
||||
@JsonProperty("confirmResultMessage")
|
||||
private String confirmResultMessage; // 确认结果信息
|
||||
@JsonProperty("items")
|
||||
private List<CtripCancelOrderConfirmItem> items; // 订单项节点
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单取消确认项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripCancelOrderConfirmItem {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId; // 订单项编号
|
||||
@JsonProperty("vouchers")
|
||||
private List<CtripVoucher> vouchers; // 已取消的凭证
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程凭证
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripVoucher {
|
||||
@JsonProperty("voucherId")
|
||||
private String voucherId; // 凭证编号
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 携程订单取消确认响应
|
||||
* 不接受同批次的取消推送多次不同操作(接受、拒绝)结果给到携程
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCancelOrderConfirmResponse {
|
||||
|
||||
/**
|
||||
* 返回头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripResponseHeader header;
|
||||
|
||||
/**
|
||||
* 处理结果返回码
|
||||
*/
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 处理结果返回信息
|
||||
*/
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage;
|
||||
|
||||
/**
|
||||
* 携程返回头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseHeader {
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode; // 处理结果返回码
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage; // 处理结果返回信息
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单取消请求
|
||||
* 提供携程与供应商系统进行订单取消操作的接口
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCancelOrderRequest {
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripHeader header;
|
||||
|
||||
/**
|
||||
* 请求体 - 可能是加密字符串或JSON对象
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private Object body;
|
||||
|
||||
/**
|
||||
* 携程请求头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripHeader {
|
||||
@JsonProperty("accountId")
|
||||
private String accountId; // 供应商帐号,由携程分配
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName; // 接口名称: CancelOrder
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime; // 请求时间(格式: yyyy-MM-dd HH:mm:ss)
|
||||
@JsonProperty("version")
|
||||
private String version; // 版本号, 1.0
|
||||
@JsonProperty("sign")
|
||||
private String sign; // 签名
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单取消体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripCancelOrderBody {
|
||||
@JsonProperty("sequenceId")
|
||||
private String sequenceId; // 携程处理批次流水号
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId; // 携程订单号
|
||||
@JsonProperty("supplierOrderId")
|
||||
private String supplierOrderId; // 供应商订单号
|
||||
@JsonProperty("confirmType")
|
||||
private Integer confirmType; // 确认类型:1-仅通知,2-供应商确认
|
||||
@JsonProperty("items")
|
||||
private List<CtripCancelOrderItem> items; // 订单项节点
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单取消项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripCancelOrderItem {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId; // 订单项编号
|
||||
@JsonProperty("PLU")
|
||||
private String PLU; // 供应商产品最小单位
|
||||
@JsonProperty("lastConfirmTime")
|
||||
private String lastConfirmTime; // 供应商最晚确认时间
|
||||
@JsonProperty("cancelType")
|
||||
private Integer cancelType; // 退订类型:0-全退,1-按份数部分退,2-按出行人部分退
|
||||
@JsonProperty("quantity")
|
||||
private Integer quantity; // 本次请求取消份数
|
||||
@JsonProperty("passengers")
|
||||
private List<CtripCancelPassenger> passengers; // 退订出行人节点
|
||||
@JsonProperty("amount")
|
||||
private BigDecimal amount; // 被取消的退款金额
|
||||
@JsonProperty("amountCurrency")
|
||||
private String amountCurrency; // 被取消的退款金额单位
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程取消出行人信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripCancelPassenger {
|
||||
@JsonProperty("passengerId")
|
||||
private String passengerId; // 出行人编号
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单取消响应
|
||||
* 当confirmType=2在取消发起时必须验证取消数量等于可退数量
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCancelOrderResponse {
|
||||
|
||||
/**
|
||||
* 返回头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripResponseHeader header;
|
||||
|
||||
/**
|
||||
* 处理结果返回码
|
||||
*/
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 处理结果返回信息
|
||||
*/
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage;
|
||||
|
||||
/**
|
||||
* 返回体(传输时该字段需要AES加密)
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private CtripResponseBody body;
|
||||
|
||||
/**
|
||||
* 携程返回头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseHeader {
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode; // 处理结果返回码
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage; // 处理结果返回信息
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseBody {
|
||||
@JsonProperty("supplierConfirmType")
|
||||
private Integer supplierConfirmType; // 供应商确认类型:1-取消已确认,2-取消待确认
|
||||
@JsonProperty("items")
|
||||
private List<CtripResponseOrderItem> items; // 订单项节点
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回订单项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseOrderItem {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId; // 订单项编号
|
||||
@JsonProperty("vouchers")
|
||||
private List<CtripVoucher> vouchers; // 已取消的凭证
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程凭证
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripVoucher {
|
||||
@JsonProperty("voucherId")
|
||||
private String voucherId; // 凭证编号
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单新订请求
|
||||
* 当客人在携程平台进行订单预定后,携程会通过该接口向供应商系统提交客人的预定信息来完成订单预定
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCreateOrderRequest {
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripHeader header;
|
||||
|
||||
/**
|
||||
* 请求体 - 可能是加密字符串或JSON对象
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private Object body; // 改为Object类型,支持字符串和对象两种格式
|
||||
|
||||
/**
|
||||
* 携程请求头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripHeader {
|
||||
@JsonProperty("accountId")
|
||||
private String accountId; // 供应商帐号,由携程分配
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName; // 接口名称: CreateOrder
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime; // 请求时间(格式: yyyy-MM-dd HH:mm:ss)
|
||||
@JsonProperty("version")
|
||||
private String version; // 版本号, 1.0
|
||||
@JsonProperty("sign")
|
||||
private String sign; // 签名
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripOrderBody {
|
||||
@JsonProperty("sequenceId")
|
||||
private String sequenceId; // 携程处理批次流水号。格式为处理日期(yyyyMMdd)+32位去分隔符的Guid
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId; // 携程订单号
|
||||
@JsonProperty("confirmType")
|
||||
private Integer confirmType; // 确认类型:1-仅通知供应商订单操作,2-供应商系统确认
|
||||
@JsonProperty("orderLastConfirmTime")
|
||||
private String orderLastConfirmTime; // 供应商最晚确认时间,格式:yyyy-MM-dd hh:mm:ss
|
||||
@JsonProperty("contacts")
|
||||
private List<CtripContact> contacts; // 联系人节点,为此笔订单联系人,并非实际出行人
|
||||
@JsonProperty("coupons")
|
||||
private List<CtripCoupon> coupons; // 优惠信息节点
|
||||
@JsonProperty("items")
|
||||
private List<CtripOrderItem> items; // 订单项节点
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripOrderItem {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId; // 订单项编号
|
||||
@JsonProperty("openId")
|
||||
private String openId; // 用户对外标识
|
||||
@JsonProperty("PLU")
|
||||
private String PLU; // 供应商产品最小单位
|
||||
@JsonProperty("locale")
|
||||
private String locale; // 语言-地区
|
||||
@JsonProperty("distributionChannel")
|
||||
private String distributionChannel; // 销售渠道
|
||||
@JsonProperty("useStartDate")
|
||||
private String useStartDate; // 使用日期
|
||||
@JsonProperty("useEndDate")
|
||||
private String useEndDate; // 最晚可使用日期
|
||||
@JsonProperty("lastConfirmTime")
|
||||
private String lastConfirmTime; // 供应商最晚确认时间(已废弃)
|
||||
@JsonProperty("remark")
|
||||
private String remark; // 备注信息
|
||||
@JsonProperty("price")
|
||||
private BigDecimal price; // 单位客人实付金额
|
||||
@JsonProperty("priceCurrency")
|
||||
private String priceCurrency; // 客人实付金额币种
|
||||
@JsonProperty("salePrice")
|
||||
private BigDecimal salePrice; // 单价卖价
|
||||
@JsonProperty("salePriceCurrency")
|
||||
private String salePriceCurrency; // 单位卖价币种
|
||||
@JsonProperty("cost")
|
||||
private BigDecimal cost; // 单价结算价
|
||||
@JsonProperty("costCurrency")
|
||||
private String costCurrency; // 单价结算价单位
|
||||
@JsonProperty("suggestedPrice")
|
||||
private BigDecimal suggestedPrice; // 供应商建议携程卖价
|
||||
@JsonProperty("suggestedPriceCurrency")
|
||||
private String suggestedPriceCurrency; // 供应商建议携程卖价单位
|
||||
@JsonProperty("quantity")
|
||||
private Integer quantity; // 订单数量
|
||||
@JsonProperty("passengers")
|
||||
private List<CtripPassenger> passengers; // 乘客信息
|
||||
@JsonProperty("adjunctions")
|
||||
private List<CtripAdjunction> adjunctions; // 附加信息
|
||||
@JsonProperty("deposit")
|
||||
private CtripDeposit deposit; // 押金信息
|
||||
@JsonProperty("expressDelivery")
|
||||
private CtripExpressDelivery expressDelivery; // 快递信息
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程乘客信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripPassenger {
|
||||
@JsonProperty("passengerId")
|
||||
private String passengerId; // 出行人编号
|
||||
@JsonProperty("name")
|
||||
private String name; // 姓名
|
||||
@JsonProperty("firstName")
|
||||
private String firstName; // 拼音或英文名
|
||||
@JsonProperty("lastName")
|
||||
private String lastName; // 拼音或英文姓
|
||||
@JsonProperty("mobile")
|
||||
private String mobile; // 手机号码/国际电话号码
|
||||
@JsonProperty("intlCode")
|
||||
private String intlCode; // 国际标准电话区号
|
||||
@JsonProperty("cardType")
|
||||
private String cardType; // 证件类型
|
||||
@JsonProperty("cardNo")
|
||||
private String cardNo; // 证件号
|
||||
@JsonProperty("birthDate")
|
||||
private String birthDate; // 生日
|
||||
@JsonProperty("ageType")
|
||||
private String ageType; // 年龄类型:ADU-成人,CHI-儿童,BAB-婴儿
|
||||
@JsonProperty("gender")
|
||||
private String gender; // 性别:M-男,F-女
|
||||
@JsonProperty("nationalityCode")
|
||||
private String nationalityCode; // 国籍代码
|
||||
@JsonProperty("nationalityName")
|
||||
private String nationalityName; // 国籍名称
|
||||
@JsonProperty("cardIssueCountry")
|
||||
private String cardIssueCountry; // 证件签发国
|
||||
@JsonProperty("cardIssuePlace")
|
||||
private String cardIssuePlace; // 证件签发地
|
||||
@JsonProperty("cardIssueDate")
|
||||
private String cardIssueDate; // 证件签发日期
|
||||
@JsonProperty("cardValidDate")
|
||||
private String cardValidDate; // 证件有效期
|
||||
@JsonProperty("cardIssueNumber")
|
||||
private Integer cardIssueNumber; // 证件签发次数
|
||||
@JsonProperty("birthPlace")
|
||||
private String birthPlace; // 出生地
|
||||
@JsonProperty("height")
|
||||
private Integer height; // 身高
|
||||
@JsonProperty("weight")
|
||||
private Integer weight; // 体重
|
||||
@JsonProperty("myopiaDegreeL")
|
||||
private Integer myopiaDegreeL; // 左眼近视度数
|
||||
@JsonProperty("myopiaDegreeR")
|
||||
private Integer myopiaDegreeR; // 右眼近视度数
|
||||
@JsonProperty("shoeSize")
|
||||
private Integer shoeSize; // 鞋码
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程联系人信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripContact {
|
||||
@JsonProperty("name")
|
||||
private String name; // 姓名
|
||||
@JsonProperty("mobile")
|
||||
private String mobile; // 手机号码/国际电话号码
|
||||
@JsonProperty("intlCode")
|
||||
private String intlCode; // 国际标准电话区号
|
||||
@JsonProperty("optionalMobile")
|
||||
private String optionalMobile; // 备选的手机号码/国际电话号码
|
||||
@JsonProperty("optionalIntlCode")
|
||||
private String optionalIntlCode; // 备选的国际标准电话区号
|
||||
@JsonProperty("email")
|
||||
private String email; // 邮箱地址
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程优惠券信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripCoupon {
|
||||
@JsonProperty("type")
|
||||
private Integer type; // 优惠券源类型:1-携程,2-供应商
|
||||
@JsonProperty("code")
|
||||
private String code; // 优惠券编码
|
||||
@JsonProperty("name")
|
||||
private String name; // 优惠券名称
|
||||
@JsonProperty("amount")
|
||||
private BigDecimal amount; // 优惠券金额
|
||||
@JsonProperty("amountCurrency")
|
||||
private String amountCurrency; // 优惠券金额单位
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程附加信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripAdjunction {
|
||||
@JsonProperty("name")
|
||||
private String name; // 名称
|
||||
@JsonProperty("nameCode")
|
||||
private String nameCode; // 名称编码(系统标识)
|
||||
@JsonProperty("content")
|
||||
private String content; // 内容
|
||||
@JsonProperty("contentCode")
|
||||
private String contentCode; // 内容编码(系统标识)
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程押金信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripDeposit {
|
||||
@JsonProperty("type")
|
||||
private Integer type; // 押金/保证金类型:1-网站预付,2-景区现付
|
||||
@JsonProperty("amount")
|
||||
private BigDecimal amount; // 押金/保证金金额
|
||||
@JsonProperty("amountCurrency")
|
||||
private String amountCurrency; // 押金/保证金单位
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程快递信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripExpressDelivery {
|
||||
@JsonProperty("type")
|
||||
private String type; // 配送类型:1-客人自提,2-供应商配送
|
||||
@JsonProperty("name")
|
||||
private String name; // 中文或英文姓名
|
||||
@JsonProperty("mobile")
|
||||
private String mobile; // 手机号码/国际电话号码
|
||||
@JsonProperty("intlCode")
|
||||
private String intlCode; // 国际标准电话区号
|
||||
@JsonProperty("country")
|
||||
private String country; // 国家
|
||||
@JsonProperty("province")
|
||||
private String province; // 省/直辖市
|
||||
@JsonProperty("city")
|
||||
private String city; // 市
|
||||
@JsonProperty("district")
|
||||
private String district; // 县/区
|
||||
@JsonProperty("address")
|
||||
private String address; // 详细地址
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单新订响应
|
||||
* 供应商在收到携程的下单请求时,需先判断同批次的携程订单号在供应商系统中是否存在且已下单成功
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripCreateOrderResponse {
|
||||
|
||||
/**
|
||||
* 返回头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripResponseHeader header;
|
||||
|
||||
/**
|
||||
* 处理结果返回码
|
||||
*/
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 处理结果返回信息。若返回结果为失败,需在此字段内明确描述失败原因
|
||||
*/
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage;
|
||||
|
||||
/**
|
||||
* 返回体(传输时该字段需要AES加密)
|
||||
* 该节点在返回码为0000时必填,其他均为非必填
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private CtripResponseBody body;
|
||||
|
||||
/**
|
||||
* 携程返回头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseHeader {
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode; // 处理结果返回码
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage; // 处理结果返回信息
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseBody {
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId; // 携程订单号
|
||||
@JsonProperty("supplierOrderId")
|
||||
private String supplierOrderId; // 供应商订单号
|
||||
@JsonProperty("supplierConfirmType")
|
||||
private Integer supplierConfirmType; // 供应商确认类型:1-新订已确认,2-新订待确认
|
||||
@JsonProperty("voucherSender")
|
||||
private Integer voucherSender; // 凭证发送方:1-携程对客发送凭证,2-供应商对客发送凭证
|
||||
@JsonProperty("vouchers")
|
||||
private List<CtripVoucher> vouchers; // 凭证集合节点
|
||||
@JsonProperty("orderExtendMessage")
|
||||
private String orderExtendMessage; // 订单附加信息
|
||||
@JsonProperty("items")
|
||||
private List<CtripResponseOrderItem> items; // 订单项节点
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程凭证
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripVoucher {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId; // 订单项编号,如果按资源单位来匹配凭证则必返回值
|
||||
@JsonProperty("voucherId")
|
||||
private String voucherId; // 凭证编号,isCredentialVouchers=1必填,需保证订单内唯一
|
||||
@JsonProperty("voucherType")
|
||||
private Integer voucherType; // 凭证形式:1-普通凭证,2-数字码,3-二维码图片,4-凭证图片,5-PDF确认单,6-凭证链接,7-条形码128格式,8-条形码417格式
|
||||
@JsonProperty("voucherCode")
|
||||
private String voucherCode; // 凭证数字码,当voucherType=2时必返回值
|
||||
@JsonProperty("voucherData")
|
||||
private String voucherData; // 凭证数据源
|
||||
@JsonProperty("voucherSeatInfo")
|
||||
private String voucherSeatInfo; // 凭证座位信息
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回订单项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseOrderItem {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId; // 订单项编号
|
||||
@JsonProperty("isCredentialVouchers")
|
||||
private Integer isCredentialVouchers; // 是否出行人与凭证有关联关系:0-不相关,1-相关
|
||||
@JsonProperty("passengerVouchers")
|
||||
private List<CtripPassengerVoucher> passengerVouchers; // 出行人凭证关系节点
|
||||
@JsonProperty("inventorys")
|
||||
private List<CtripInventory> inventorys; // 剩余库存数量节点
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程出行人凭证关系
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripPassengerVoucher {
|
||||
@JsonProperty("passengerId")
|
||||
private String passengerId; // 出行人编号
|
||||
@JsonProperty("voucherId")
|
||||
private String voucherId; // 凭证编号
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程库存信息
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripInventory {
|
||||
@JsonProperty("useDate")
|
||||
private String useDate; // 使用日期
|
||||
@JsonProperty("quantity")
|
||||
private Integer quantity; // 库存数量
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 携程订单退款确认请求
|
||||
* 当订单在退款提交后供应商需异步确认进行操作(接受、拒绝)
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripRefundOrderConfirmRequest {
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripHeader header;
|
||||
|
||||
/**
|
||||
* 请求体 - 可能是加密字符串或JSON对象
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private Object body;
|
||||
|
||||
/**
|
||||
* 携程请求头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripHeader {
|
||||
@JsonProperty("accountId")
|
||||
private String accountId; // 供应商帐号,由携程分配
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName; // 接口名称: RefundOrderConfirm
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime; // 请求时间(格式: yyyy-MM-dd HH:mm:ss)
|
||||
@JsonProperty("version")
|
||||
private String version; // 版本号, 1.0
|
||||
@JsonProperty("sign")
|
||||
private String sign; // 签名
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单退款确认体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripRefundOrderConfirmBody {
|
||||
@JsonProperty("sequenceId")
|
||||
private String sequenceId; // 供应商处理批次流水号
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId; // 携程订单号
|
||||
@JsonProperty("supplierOrderId")
|
||||
private String supplierOrderId; // 供应商订单号
|
||||
@JsonProperty("confirmResultCode")
|
||||
private String confirmResultCode; // 确认结果返回码
|
||||
@JsonProperty("confirmResultMessage")
|
||||
private String confirmResultMessage; // 确认结果信息
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 携程订单退款确认响应
|
||||
* 不接受同批次的退款推送多次不同操作(接受、拒绝)结果给到携程
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripRefundOrderConfirmResponse {
|
||||
|
||||
/**
|
||||
* 返回头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripResponseHeader header;
|
||||
|
||||
/**
|
||||
* 处理结果返回码
|
||||
*/
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 处理结果返回信息
|
||||
*/
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage;
|
||||
|
||||
/**
|
||||
* 携程返回头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseHeader {
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode; // 处理结果返回码
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage; // 处理结果返回信息
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 携程订单退款请求
|
||||
* 退款接口与订单取消逻辑并无关联,是纯粹的退钱操作
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripRefundOrderRequest {
|
||||
|
||||
/**
|
||||
* 请求头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripHeader header;
|
||||
|
||||
/**
|
||||
* 请求体 - 可能是加密字符串或JSON对象
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private Object body;
|
||||
|
||||
/**
|
||||
* 携程请求头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripHeader {
|
||||
@JsonProperty("accountId")
|
||||
private String accountId; // 供应商帐号,由携程分配
|
||||
@JsonProperty("serviceName")
|
||||
private String serviceName; // 接口名称: RefundOrder
|
||||
@JsonProperty("requestTime")
|
||||
private String requestTime; // 请求时间(格式: yyyy-MM-dd HH:mm:ss)
|
||||
@JsonProperty("version")
|
||||
private String version; // 版本号, 1.0
|
||||
@JsonProperty("sign")
|
||||
private String sign; // 签名
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单退款体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripRefundOrderBody {
|
||||
@JsonProperty("sequenceId")
|
||||
private String sequenceId; // 携程处理批次流水号
|
||||
@JsonProperty("otaOrderId")
|
||||
private String otaOrderId; // 携程订单号
|
||||
@JsonProperty("supplierOrderId")
|
||||
private String supplierOrderId; // 供应商订单号
|
||||
@JsonProperty("lastConfirmTime")
|
||||
private String lastConfirmTime; // 供应商最晚确认时间
|
||||
@JsonProperty("totalAmount")
|
||||
private BigDecimal totalAmount; // 退款总金额
|
||||
@JsonProperty("totalAmountCurrency")
|
||||
private String totalAmountCurrency; // 退款总金额单位
|
||||
@JsonProperty("items")
|
||||
private List<CtripRefundOrderItem> items; // 订单项节点
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程订单退款项
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripRefundOrderItem {
|
||||
@JsonProperty("itemId")
|
||||
private String itemId; // 订单项编号
|
||||
@JsonProperty("PLU")
|
||||
private String PLU; // 供应商产品最小单位
|
||||
@JsonProperty("amount")
|
||||
private BigDecimal amount; // 退款金额
|
||||
@JsonProperty("amountCurrency")
|
||||
private String amountCurrency; // 退款金额单位
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.central.coupon.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 携程订单退款响应
|
||||
* 在退款发起时必须验证退款金额小于等于可退金额
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class CtripRefundOrderResponse {
|
||||
|
||||
/**
|
||||
* 返回头
|
||||
*/
|
||||
@JsonProperty("header")
|
||||
private CtripResponseHeader header;
|
||||
|
||||
/**
|
||||
* 处理结果返回码
|
||||
*/
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 处理结果返回信息
|
||||
*/
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage;
|
||||
|
||||
/**
|
||||
* 返回体(传输时该字段需要AES加密)
|
||||
*/
|
||||
@JsonProperty("body")
|
||||
private CtripResponseBody body;
|
||||
|
||||
/**
|
||||
* 携程返回头
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseHeader {
|
||||
@JsonProperty("resultCode")
|
||||
private String resultCode; // 处理结果返回码
|
||||
@JsonProperty("resultMessage")
|
||||
private String resultMessage; // 处理结果返回信息
|
||||
}
|
||||
|
||||
/**
|
||||
* 携程返回体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class CtripResponseBody {
|
||||
@JsonProperty("supplierConfirmType")
|
||||
private Integer supplierConfirmType; // 供应商确认类型:1-退款已确认,2-退款待确认
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.central.coupon.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.central.coupon.entity.Coupon;
|
||||
import com.central.common.model.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 优惠券服务接口
|
||||
*/
|
||||
public interface ICouponService extends IService<Coupon> {
|
||||
|
||||
/**
|
||||
* 分页查询优惠券列表
|
||||
*/
|
||||
IPage<Coupon> getCouponPage(Page<Coupon> page, Coupon coupon);
|
||||
|
||||
/**
|
||||
* 查询优惠券列表(统一风格)
|
||||
*/
|
||||
PageResult<Coupon> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 创建优惠券
|
||||
*/
|
||||
boolean createCoupon(Coupon coupon);
|
||||
|
||||
/**
|
||||
* 更新优惠券
|
||||
*/
|
||||
boolean updateCoupon(Coupon coupon);
|
||||
|
||||
/**
|
||||
* 删除优惠券
|
||||
*/
|
||||
boolean deleteCoupon(Long id);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户优惠券
|
||||
*/
|
||||
List<Coupon> getCouponsByUserPhone(String userPhone);
|
||||
|
||||
/**
|
||||
* 根据手机号查询可用优惠券
|
||||
*/
|
||||
List<Coupon> getAvailableCouponsByUserPhone(String userPhone);
|
||||
|
||||
/**
|
||||
* 使用优惠券
|
||||
*/
|
||||
boolean useCoupon(Long couponId, String orderNo);
|
||||
|
||||
/**
|
||||
* 根据携程优惠券ID创建优惠券(携程接口调用)
|
||||
*/
|
||||
boolean createCouponFromCtrip(String ctripCouponId, String userPhone, String couponName,
|
||||
Integer couponType, java.math.BigDecimal amount,
|
||||
java.math.BigDecimal minAmount, Integer discountRate,
|
||||
java.util.Date validStartTime,
|
||||
java.util.Date validEndTime);
|
||||
|
||||
/**
|
||||
* 批量更新过期优惠券状态
|
||||
*/
|
||||
void updateExpiredCoupons();
|
||||
|
||||
/**
|
||||
* 核销携程优惠券
|
||||
*/
|
||||
boolean verifyCtripCoupon(String ctripCouponId, String orderNo);
|
||||
|
||||
/**
|
||||
* 根据携程优惠券ID查询优惠券
|
||||
*/
|
||||
Coupon getByCtripCouponId(String ctripCouponId);
|
||||
|
||||
/**
|
||||
* 检查用户手机号和携程优惠券ID是否已存在
|
||||
*/
|
||||
boolean existsByUserPhoneAndCtripCouponId(String userPhone, String ctripCouponId);
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.central.coupon.service;
|
||||
|
||||
/**
|
||||
* 携程API服务接口
|
||||
* 用于调用携程的优惠券相关API
|
||||
*/
|
||||
public interface ICtripApiService {
|
||||
|
||||
/**
|
||||
* 验证携程优惠券
|
||||
*
|
||||
* @param ctripCouponId 携程优惠券ID
|
||||
* @param orderNo 订单号
|
||||
* @return 验证结果
|
||||
*/
|
||||
boolean verifyCoupon(String ctripCouponId, String orderNo);
|
||||
|
||||
/**
|
||||
* 获取携程优惠券状态
|
||||
*
|
||||
* @param ctripCouponId 携程优惠券ID
|
||||
* @return 优惠券状态
|
||||
*/
|
||||
String getCouponStatus(String ctripCouponId);
|
||||
}
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
package com.central.coupon.service;
|
||||
|
||||
import com.central.coupon.model.CtripCreateOrderRequest;
|
||||
import com.central.coupon.model.CtripCreateOrderResponse;
|
||||
import com.central.coupon.model.CtripCancelOrderRequest;
|
||||
import com.central.coupon.model.CtripCancelOrderResponse;
|
||||
import com.central.coupon.model.CtripCancelOrderConfirmRequest;
|
||||
import com.central.coupon.model.CtripCancelOrderConfirmResponse;
|
||||
import com.central.coupon.model.CtripRefundOrderRequest;
|
||||
import com.central.coupon.model.CtripRefundOrderResponse;
|
||||
import com.central.coupon.model.CtripRefundOrderConfirmRequest;
|
||||
import com.central.coupon.model.CtripRefundOrderConfirmResponse;
|
||||
import com.central.coupon.model.CtripConsumedNoticeRequest;
|
||||
import com.central.coupon.model.CtripConsumedNoticeResponse;
|
||||
|
||||
/**
|
||||
* 携程订单服务接口
|
||||
* 处理携程订单相关的业务逻辑
|
||||
*/
|
||||
public interface ICtripOrderService {
|
||||
|
||||
/**
|
||||
* 处理订单新订
|
||||
* 当客人在携程平台进行订单预定后,携程会通过该接口向供应商系统提交客人的预定信息来完成订单预定
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 订单创建响应
|
||||
*/
|
||||
CtripCreateOrderResponse processCreateOrder(CtripCreateOrderRequest.CtripHeader header,
|
||||
CtripCreateOrderRequest.CtripOrderBody body);
|
||||
|
||||
/**
|
||||
* 处理订单取消
|
||||
* 提供携程与供应商系统进行订单取消操作的接口
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 订单取消响应
|
||||
*/
|
||||
CtripCancelOrderResponse processCancelOrder(CtripCancelOrderRequest.CtripHeader header,
|
||||
CtripCancelOrderRequest.CtripCancelOrderBody body);
|
||||
|
||||
/**
|
||||
* 处理订单取消确认
|
||||
* 当订单在取消提交后供应商需异步确认进行操作(接受、拒绝)
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 订单取消确认响应
|
||||
*/
|
||||
CtripCancelOrderConfirmResponse processCancelOrderConfirm(CtripCancelOrderConfirmRequest.CtripHeader header,
|
||||
CtripCancelOrderConfirmRequest.CtripCancelOrderConfirmBody body);
|
||||
|
||||
/**
|
||||
* 检查订单是否已存在
|
||||
* 供应商在收到携程的下单请求时,需先判断同批次的携程订单号在供应商系统中是否存在且已下单成功
|
||||
*
|
||||
* @param otaOrderId 携程订单号
|
||||
* @param sequenceId 携程处理批次流水号
|
||||
* @return 如果订单已存在且已下单成功返回true,否则返回false
|
||||
*/
|
||||
boolean isOrderExists(String otaOrderId, String sequenceId);
|
||||
|
||||
/**
|
||||
* 创建新订单
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 供应商订单号
|
||||
*/
|
||||
String createNewOrder(CtripCreateOrderRequest.CtripHeader header,
|
||||
CtripCreateOrderRequest.CtripOrderBody body);
|
||||
|
||||
/**
|
||||
* 检查订单取消数量是否合法
|
||||
* 当confirmType=2在取消发起时必须验证取消数量等于可退数量
|
||||
*
|
||||
* @param otaOrderId 携程订单号
|
||||
* @param supplierOrderId 供应商订单号
|
||||
* @param itemId 订单项编号
|
||||
* @param cancelQuantity 取消数量
|
||||
* @return 如果取消数量合法返回true,否则返回false
|
||||
*/
|
||||
boolean validateCancelQuantity(String otaOrderId, String supplierOrderId, String itemId, Integer cancelQuantity);
|
||||
|
||||
/**
|
||||
* 执行订单取消
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 取消结果
|
||||
*/
|
||||
boolean executeOrderCancel(CtripCancelOrderRequest.CtripHeader header,
|
||||
CtripCancelOrderRequest.CtripCancelOrderBody body);
|
||||
|
||||
/**
|
||||
* 处理优惠券信息
|
||||
* 当订单中包含优惠券信息时,需要处理优惠券的创建和使用
|
||||
*
|
||||
* @param coupons 优惠券列表
|
||||
* @param orderId 订单ID
|
||||
* @return 处理结果
|
||||
*/
|
||||
boolean processCoupons(java.util.List<CtripCreateOrderRequest.CtripCoupon> coupons, Long orderId);
|
||||
|
||||
/**
|
||||
* 生成凭证信息
|
||||
* 根据订单信息生成相应的凭证
|
||||
*
|
||||
* @param body 订单体
|
||||
* @param supplierOrderId 供应商订单号
|
||||
* @return 凭证列表
|
||||
*/
|
||||
java.util.List<CtripCreateOrderResponse.CtripVoucher> generateVouchers(
|
||||
CtripCreateOrderRequest.CtripOrderBody body, String supplierOrderId);
|
||||
|
||||
/**
|
||||
* 生成订单项响应
|
||||
*
|
||||
* @param body 订单体
|
||||
* @param supplierOrderId 供应商订单号
|
||||
* @return 订单项响应列表
|
||||
*/
|
||||
java.util.List<CtripCreateOrderResponse.CtripResponseOrderItem> generateOrderItems(
|
||||
CtripCreateOrderRequest.CtripOrderBody body, String supplierOrderId);
|
||||
|
||||
/**
|
||||
* 生成取消订单项响应
|
||||
*
|
||||
* @param body 取消订单体
|
||||
* @return 取消订单项响应列表
|
||||
*/
|
||||
java.util.List<CtripCancelOrderResponse.CtripResponseOrderItem> generateCancelOrderItems(
|
||||
CtripCancelOrderRequest.CtripCancelOrderBody body);
|
||||
|
||||
/**
|
||||
* 处理订单退款
|
||||
* 退款接口与订单取消逻辑并无关联,是纯粹的退钱操作
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 订单退款响应
|
||||
*/
|
||||
CtripRefundOrderResponse processRefundOrder(CtripRefundOrderRequest.CtripHeader header,
|
||||
CtripRefundOrderRequest.CtripRefundOrderBody body);
|
||||
|
||||
/**
|
||||
* 处理订单退款确认
|
||||
* 当订单在退款提交后供应商需异步确认进行操作(接受、拒绝)
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 订单退款确认响应
|
||||
*/
|
||||
CtripRefundOrderConfirmResponse processRefundOrderConfirm(CtripRefundOrderConfirmRequest.CtripHeader header,
|
||||
CtripRefundOrderConfirmRequest.CtripRefundOrderConfirmBody body);
|
||||
|
||||
/**
|
||||
* 检查订单退款金额是否合法
|
||||
* 在退款发起时必须验证退款金额小于等于可退金额
|
||||
*
|
||||
* @param otaOrderId 携程订单号
|
||||
* @param supplierOrderId 供应商订单号
|
||||
* @param refundAmount 退款金额
|
||||
* @return 如果退款金额合法返回true,否则返回false
|
||||
*/
|
||||
boolean validateRefundAmount(String otaOrderId, String supplierOrderId, java.math.BigDecimal refundAmount);
|
||||
|
||||
/**
|
||||
* 执行订单退款
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 退款结果
|
||||
*/
|
||||
boolean executeOrderRefund(CtripRefundOrderRequest.CtripHeader header,
|
||||
CtripRefundOrderRequest.CtripRefundOrderBody body);
|
||||
|
||||
/**
|
||||
* 处理订单核销通知
|
||||
* 当订单在新订确认后,供应商可将客人出行后的使用情况或归还物品等信息调用该接口将对应的最终结果同步给携程系统
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 订单核销通知响应
|
||||
*/
|
||||
CtripConsumedNoticeResponse processConsumedNotice(CtripConsumedNoticeRequest.CtripHeader header,
|
||||
CtripConsumedNoticeRequest.CtripConsumedNoticeBody body);
|
||||
|
||||
/**
|
||||
* 验证核销数量是否合法
|
||||
* 验证已核销数量不超过总数量
|
||||
*
|
||||
* @param itemId 订单项编号
|
||||
* @param totalQuantity 总数量
|
||||
* @param useQuantity 已核销数量
|
||||
* @return 如果核销数量合法返回true,否则返回false
|
||||
*/
|
||||
boolean validateConsumedQuantity(String itemId, Integer totalQuantity, Integer useQuantity);
|
||||
|
||||
/**
|
||||
* 执行订单核销
|
||||
*
|
||||
* @param header 请求头
|
||||
* @param body 请求体
|
||||
* @return 核销结果
|
||||
*/
|
||||
boolean executeOrderConsumed(CtripConsumedNoticeRequest.CtripHeader header,
|
||||
CtripConsumedNoticeRequest.CtripConsumedNoticeBody body);
|
||||
}
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
package com.central.coupon.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.central.coupon.entity.Coupon;
|
||||
import com.central.coupon.mapper.CouponMapper;
|
||||
import com.central.coupon.service.ICouponService;
|
||||
import com.central.coupon.service.ICtripApiService;
|
||||
import com.central.common.model.PageResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 优惠券服务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> implements ICouponService {
|
||||
|
||||
@Autowired
|
||||
private ICtripApiService ctripApiService;
|
||||
|
||||
@Override
|
||||
public IPage<Coupon> getCouponPage(Page<Coupon> page, Coupon coupon) {
|
||||
return baseMapper.selectCouponPage(page, coupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<Coupon> findList(Map<String, Object> params) {
|
||||
// 构建查询条件
|
||||
Coupon coupon = new Coupon();
|
||||
if (params.get("couponName") != null) {
|
||||
coupon.setCouponName((String) params.get("couponName"));
|
||||
}
|
||||
if (params.get("userPhone") != null) {
|
||||
coupon.setUserPhone((String) params.get("userPhone"));
|
||||
}
|
||||
if (params.get("status") != null) {
|
||||
coupon.setStatus(Integer.valueOf(params.get("status").toString()));
|
||||
}
|
||||
if (params.get("source") != null) {
|
||||
coupon.setSource(Integer.valueOf(params.get("source").toString()));
|
||||
}
|
||||
if (params.get("couponType") != null) {
|
||||
coupon.setCouponType(Integer.valueOf(params.get("couponType").toString()));
|
||||
}
|
||||
|
||||
// 分页查询
|
||||
Page<Coupon> page = new Page<>();
|
||||
if (params.get("page") != null) {
|
||||
page.setCurrent(Long.valueOf(params.get("page").toString()));
|
||||
}
|
||||
if (params.get("limit") != null) {
|
||||
page.setSize(Long.valueOf(params.get("limit").toString()));
|
||||
}
|
||||
|
||||
IPage<Coupon> result = getCouponPage(page, coupon);
|
||||
|
||||
return new PageResult<>(result.getRecords(), result.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean createCoupon(Coupon coupon) {
|
||||
if (coupon.getCouponNo() == null) {
|
||||
coupon.setCouponNo(generateCouponNo());
|
||||
}
|
||||
coupon.setCreateTime(new Date());
|
||||
coupon.setUpdateTime(new Date());
|
||||
return save(coupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateCoupon(Coupon coupon) {
|
||||
coupon.setUpdateTime(new Date());
|
||||
return updateById(coupon);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteCoupon(Long id) {
|
||||
return removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Coupon> getCouponsByUserPhone(String userPhone) {
|
||||
return baseMapper.selectByUserPhone(userPhone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Coupon> getAvailableCouponsByUserPhone(String userPhone) {
|
||||
return baseMapper.selectAvailableByUserPhone(userPhone);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean useCoupon(Long couponId, String orderNo) {
|
||||
Coupon coupon = getById(couponId);
|
||||
if (coupon == null) {
|
||||
log.error("优惠券不存在,couponId: {}", couponId);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coupon.getStatus() != 0) {
|
||||
log.error("优惠券状态不正确,couponId: {}, status: {}", couponId, coupon.getStatus());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coupon.getValidEndTime().before(new Date())) {
|
||||
log.error("优惠券已过期,couponId: {}", couponId);
|
||||
return false;
|
||||
}
|
||||
|
||||
return baseMapper.updateCouponUsed(couponId, orderNo) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean createCouponFromCtrip(String ctripCouponId, String userPhone, String couponName,
|
||||
Integer couponType, java.math.BigDecimal amount,
|
||||
java.math.BigDecimal minAmount, Integer discountRate,
|
||||
java.util.Date validStartTime,
|
||||
java.util.Date validEndTime) {
|
||||
|
||||
log.info("开始创建携程优惠券 - ctripCouponId: {}, userPhone: {}, couponName: {}, amount: {}, minAmount: {}",
|
||||
ctripCouponId, userPhone, couponName, amount, minAmount);
|
||||
|
||||
// 检查是否已存在该携程优惠券
|
||||
Coupon existingCoupon = baseMapper.selectByCtripCouponId(ctripCouponId);
|
||||
if (existingCoupon != null) {
|
||||
log.warn("携程优惠券已存在,ctripCouponId: {}, 优惠券ID: {}", ctripCouponId, existingCoupon.getId());
|
||||
return true; // 已存在也算成功
|
||||
}
|
||||
|
||||
log.info("携程优惠券不存在,开始创建新优惠券");
|
||||
|
||||
Coupon coupon = new Coupon();
|
||||
coupon.setCouponNo(generateCouponNo());
|
||||
coupon.setCouponName(couponName);
|
||||
coupon.setCouponType(couponType);
|
||||
coupon.setAmount(amount);
|
||||
coupon.setMinAmount(minAmount);
|
||||
coupon.setDiscountRate(discountRate);
|
||||
coupon.setStatus(0); // 未使用
|
||||
coupon.setUserPhone(userPhone);
|
||||
coupon.setSource(1); // 来源:携程
|
||||
coupon.setCtripCouponId(ctripCouponId);
|
||||
coupon.setValidStartTime(validStartTime);
|
||||
coupon.setValidEndTime(validEndTime);
|
||||
coupon.setCreateTime(new Date());
|
||||
coupon.setUpdateTime(new Date());
|
||||
coupon.setCreateBy("ctrip");
|
||||
coupon.setUpdateBy("ctrip");
|
||||
|
||||
log.info("优惠券对象创建完成,准备保存到数据库 - couponNo: {}", coupon.getCouponNo());
|
||||
|
||||
boolean saveResult = save(coupon);
|
||||
|
||||
if (saveResult) {
|
||||
log.info("携程优惠券保存成功 - 优惠券ID: {}, couponNo: {}, ctripCouponId: {}",
|
||||
coupon.getId(), coupon.getCouponNo(), ctripCouponId);
|
||||
} else {
|
||||
log.error("携程优惠券保存失败 - ctripCouponId: {}, userPhone: {}", ctripCouponId, userPhone);
|
||||
}
|
||||
|
||||
return saveResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateExpiredCoupons() {
|
||||
int count = baseMapper.updateExpiredCoupons();
|
||||
log.info("批量更新过期优惠券完成,更新数量: {}", count);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean verifyCtripCoupon(String ctripCouponId, String orderNo) {
|
||||
Coupon coupon = baseMapper.selectByCtripCouponId(ctripCouponId);
|
||||
if (coupon == null) {
|
||||
log.error("携程优惠券不存在,ctripCouponId: {}", ctripCouponId);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coupon.getStatus() != 0) {
|
||||
log.error("携程优惠券状态不正确,ctripCouponId: {}, status: {}", ctripCouponId, coupon.getStatus());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (coupon.getValidEndTime().before(new Date())) {
|
||||
log.error("携程优惠券已过期,ctripCouponId: {}", ctripCouponId);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 调用携程核销接口
|
||||
boolean ctripVerifyResult = ctripApiService.verifyCoupon(ctripCouponId, orderNo);
|
||||
if (!ctripVerifyResult) {
|
||||
log.error("携程核销失败,ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 更新本地优惠券状态
|
||||
return baseMapper.updateCouponUsed(coupon.getId(), orderNo) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coupon getByCtripCouponId(String ctripCouponId) {
|
||||
return baseMapper.selectByCtripCouponId(ctripCouponId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsByUserPhoneAndCtripCouponId(String userPhone, String ctripCouponId) {
|
||||
return lambdaQuery()
|
||||
.eq(Coupon::getUserPhone, userPhone)
|
||||
.eq(Coupon::getCtripCouponId, ctripCouponId)
|
||||
.count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成优惠券编号
|
||||
*/
|
||||
private String generateCouponNo() {
|
||||
return "CP" + System.currentTimeMillis() + UUID.randomUUID().toString().substring(0, 8).toUpperCase();
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.central.coupon.service.impl;
|
||||
|
||||
import com.central.coupon.service.ICtripApiService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 携程API服务实现类
|
||||
* 实现携程优惠券相关的API调用
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CtripApiServiceImpl implements ICtripApiService {
|
||||
|
||||
@Override
|
||||
public boolean verifyCoupon(String ctripCouponId, String orderNo) {
|
||||
log.info("调用携程核销接口,ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo);
|
||||
|
||||
try {
|
||||
// TODO: 实现真实的携程API调用
|
||||
// 这里应该调用携程的核销接口
|
||||
// 目前先模拟成功返回
|
||||
|
||||
// 构建请求参数
|
||||
Map<String, Object> requestParams = new HashMap<>();
|
||||
requestParams.put("ctripCouponId", ctripCouponId);
|
||||
requestParams.put("orderNo", orderNo);
|
||||
|
||||
log.info("携程核销请求参数: {}", requestParams);
|
||||
|
||||
// TODO: 发送HTTP请求到携程API
|
||||
// String url = "https://api.ctrip.com/coupon/verify";
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
// HttpEntity<Map<String, Object>> request = new HttpEntity<>(requestParams, headers);
|
||||
// ResponseEntity<String> response = restTemplate.postForEntity(url, request, String.class);
|
||||
|
||||
// 模拟API调用成功
|
||||
log.info("携程核销接口调用成功,ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo);
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("携程核销接口调用失败,ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCouponStatus(String ctripCouponId) {
|
||||
log.info("调用携程查询优惠券状态接口,ctripCouponId: {}", ctripCouponId);
|
||||
|
||||
try {
|
||||
// TODO: 实现真实的携程API调用
|
||||
// 这里应该调用携程的查询接口
|
||||
// 目前先模拟返回状态
|
||||
|
||||
// 构建请求参数
|
||||
Map<String, Object> requestParams = new HashMap<>();
|
||||
requestParams.put("ctripCouponId", ctripCouponId);
|
||||
|
||||
log.info("携程查询请求参数: {}", requestParams);
|
||||
|
||||
// TODO: 发送HTTP请求到携程API
|
||||
// String url = "https://api.ctrip.com/coupon/status";
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
// HttpEntity<Map<String, Object>> request = new HttpEntity<>(requestParams, headers);
|
||||
// ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
|
||||
|
||||
// 模拟API调用成功,返回状态
|
||||
log.info("携程查询接口调用成功,ctripCouponId: {}", ctripCouponId);
|
||||
return "VALID"; // 模拟返回有效状态
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("携程查询接口调用失败,ctripCouponId: {}", ctripCouponId, e);
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
}
|
||||
+1363
File diff suppressed because it is too large
Load Diff
+238
@@ -0,0 +1,238 @@
|
||||
package com.central.coupon.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* 携程解密工具类
|
||||
* 处理AES-128-CBC加密/解密和MD5签名验证
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CtripDecryptUtil {
|
||||
|
||||
@Value("${ctrip.aes.key:your-aes-key-here}")
|
||||
private String aesKey;
|
||||
|
||||
@Value("${ctrip.aes.iv:your-aes-iv-here}")
|
||||
private String aesIv;
|
||||
|
||||
@Value("${ctrip.md5.secret:your-md5-secret-here}")
|
||||
private String md5Secret;
|
||||
|
||||
/**
|
||||
* AES-128-CBC解密
|
||||
*
|
||||
* @param encryptedData 加密的数据
|
||||
* @return 解密后的数据,如果解密失败返回null
|
||||
*/
|
||||
public String decryptAES(String encryptedData) {
|
||||
try {
|
||||
log.info("开始AES解密,加密数据长度: {}", encryptedData.length());
|
||||
|
||||
// 使用Base64解码
|
||||
byte[] encryptedBytes = Base64.getDecoder().decode(encryptedData);
|
||||
|
||||
// 创建密钥规范
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(aesKey.getBytes(StandardCharsets.UTF_8), "AES");
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(aesIv.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 创建解密器
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
|
||||
// 解密
|
||||
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
|
||||
String decryptedData = new String(decryptedBytes, StandardCharsets.UTF_8);
|
||||
|
||||
log.info("AES解密成功,解密后数据长度: {}", decryptedData.length());
|
||||
return decryptedData;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("AES解密失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AES-128-CBC加密
|
||||
*
|
||||
* @param plainData 明文数据
|
||||
* @return 加密后的数据,如果加密失败返回null
|
||||
*/
|
||||
public String encryptAES(String plainData) {
|
||||
try {
|
||||
log.info("开始AES加密,明文数据长度: {}", plainData.length());
|
||||
|
||||
// 创建密钥规范
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(aesKey.getBytes(StandardCharsets.UTF_8), "AES");
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(aesIv.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// 创建加密器
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
|
||||
// 加密
|
||||
byte[] encryptedBytes = cipher.doFinal(plainData.getBytes(StandardCharsets.UTF_8));
|
||||
String encryptedData = Base64.getEncoder().encodeToString(encryptedBytes);
|
||||
|
||||
log.info("AES加密成功,加密后数据长度: {}", encryptedData.length());
|
||||
return encryptedData;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("AES加密失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证MD5签名
|
||||
*
|
||||
* @param accountId 供应商帐号
|
||||
* @param serviceName 接口名称
|
||||
* @param requestTime 请求时间
|
||||
* @param body 请求体
|
||||
* @param version 版本号
|
||||
* @param sign 签名
|
||||
* @return 验证结果
|
||||
*/
|
||||
public boolean verifySign(String accountId, String serviceName, String requestTime,
|
||||
String body, String version, String sign) {
|
||||
try {
|
||||
log.info("开始验证MD5签名,accountId: {}, serviceName: {}, requestTime: {}",
|
||||
accountId, serviceName, requestTime);
|
||||
|
||||
// 构建签名字符串
|
||||
String signString = buildSignString(accountId, serviceName, requestTime, body, version);
|
||||
|
||||
// 计算MD5
|
||||
String calculatedSign = calculateMD5(signString);
|
||||
|
||||
// 比较签名
|
||||
boolean isValid = calculatedSign.equalsIgnoreCase(sign);
|
||||
|
||||
log.info("MD5签名验证结果: {}, 期望签名: {}, 计算签名: {}", isValid, sign, calculatedSign);
|
||||
return isValid;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("MD5签名验证失败: {}", e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成MD5签名
|
||||
*
|
||||
* @param accountId 供应商帐号
|
||||
* @param serviceName 接口名称
|
||||
* @param requestTime 请求时间
|
||||
* @param body 请求体
|
||||
* @param version 版本号
|
||||
* @return MD5签名
|
||||
*/
|
||||
public String generateSign(String accountId, String serviceName, String requestTime,
|
||||
String body, String version) {
|
||||
try {
|
||||
String signString = buildSignString(accountId, serviceName, requestTime, body, version);
|
||||
return calculateMD5(signString);
|
||||
} catch (Exception e) {
|
||||
log.error("生成MD5签名失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建签名字符串
|
||||
* 格式:accountId + serviceName + requestTime + body + version + secret
|
||||
*/
|
||||
private String buildSignString(String accountId, String serviceName, String requestTime,
|
||||
String body, String version) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(accountId);
|
||||
sb.append(serviceName);
|
||||
sb.append(requestTime);
|
||||
sb.append(body);
|
||||
sb.append(version);
|
||||
sb.append(md5Secret);
|
||||
|
||||
String signString = sb.toString();
|
||||
log.debug("构建签名字符串: {}", signString);
|
||||
return signString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算MD5值
|
||||
*/
|
||||
private String calculateMD5(String input) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] digest = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : digest) {
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
} catch (Exception e) {
|
||||
log.error("计算MD5失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证时间戳是否在有效期内
|
||||
*
|
||||
* @param requestTime 请求时间字符串,格式:yyyy-MM-dd HH:mm:ss
|
||||
* @param validMinutes 有效期(分钟)
|
||||
* @return 是否有效
|
||||
*/
|
||||
public boolean isTimestampValid(String requestTime, int validMinutes) {
|
||||
try {
|
||||
// 解析请求时间
|
||||
java.time.LocalDateTime requestDateTime = java.time.LocalDateTime.parse(
|
||||
requestTime,
|
||||
java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
);
|
||||
|
||||
// 获取当前时间
|
||||
java.time.LocalDateTime now = java.time.LocalDateTime.now();
|
||||
|
||||
// 计算时间差
|
||||
long diffMinutes = java.time.Duration.between(requestDateTime, now).toMinutes();
|
||||
|
||||
boolean isValid = Math.abs(diffMinutes) <= validMinutes;
|
||||
log.info("时间戳验证结果: {}, 请求时间: {}, 当前时间: {}, 时间差(分钟): {}",
|
||||
isValid, requestTime, now, diffMinutes);
|
||||
|
||||
return isValid;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("时间戳验证失败: {}", e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证版本号
|
||||
*
|
||||
* @param version 版本号
|
||||
* @return 是否有效
|
||||
*/
|
||||
public boolean isVersionValid(String version) {
|
||||
if (version == null || version.trim().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查版本号格式,这里假设支持1.0和2.0
|
||||
return "1.0".equals(version) || "2.0".equals(version);
|
||||
}
|
||||
}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
package com.central.coupon.util;
|
||||
|
||||
/**
|
||||
* 携程响应码工具类
|
||||
* 定义携程API的标准响应码和错误码
|
||||
*/
|
||||
public class CtripResponseCodeUtil {
|
||||
|
||||
/**
|
||||
* 携程响应码
|
||||
*/
|
||||
public static class CtripResponseCodes {
|
||||
// 成功码
|
||||
public static final String SUCCESS = "0000";
|
||||
public static final String SUCCESS_MESSAGE = "操作成功";
|
||||
|
||||
// 系统错误码 (1xxx)
|
||||
public static final String SYSTEM_ERROR = "1001";
|
||||
public static final String SYSTEM_ERROR_MESSAGE = "系统错误";
|
||||
|
||||
public static final String PARAM_ERROR = "1002";
|
||||
public static final String PARAM_ERROR_MESSAGE = "参数错误";
|
||||
|
||||
public static final String SIGN_ERROR = "1003";
|
||||
public static final String SIGN_ERROR_MESSAGE = "签名验证失败";
|
||||
|
||||
public static final String DATA_INVALID = "1004";
|
||||
public static final String DATA_INVALID_MESSAGE = "数据格式错误";
|
||||
|
||||
public static final String TIMEOUT_ERROR = "1005";
|
||||
public static final String TIMEOUT_ERROR_MESSAGE = "请求超时";
|
||||
|
||||
public static final String SERVICE_UNAVAILABLE = "1006";
|
||||
public static final String SERVICE_UNAVAILABLE_MESSAGE = "服务不可用";
|
||||
|
||||
// 业务错误码 (2xxx)
|
||||
public static final String ORDER_NOT_FOUND = "2001";
|
||||
public static final String ORDER_NOT_FOUND_MESSAGE = "订单不存在";
|
||||
|
||||
public static final String ORDER_STATUS_ERROR = "2002";
|
||||
public static final String ORDER_STATUS_ERROR_MESSAGE = "订单状态错误";
|
||||
|
||||
public static final String COUPON_NOT_FOUND = "2003";
|
||||
public static final String COUPON_NOT_FOUND_MESSAGE = "优惠券不存在";
|
||||
|
||||
public static final String COUPON_ALREADY_USED = "2004";
|
||||
public static final String COUPON_ALREADY_USED_MESSAGE = "优惠券已使用";
|
||||
|
||||
public static final String COUPON_EXPIRED = "2005";
|
||||
public static final String COUPON_EXPIRED_MESSAGE = "优惠券已过期";
|
||||
|
||||
public static final String COUPON_INSUFFICIENT = "2006";
|
||||
public static final String COUPON_INSUFFICIENT_MESSAGE = "优惠券余额不足";
|
||||
|
||||
public static final String USER_NOT_FOUND = "2007";
|
||||
public static final String USER_NOT_FOUND_MESSAGE = "用户不存在";
|
||||
|
||||
public static final String PRODUCT_NOT_FOUND = "2008";
|
||||
public static final String PRODUCT_NOT_FOUND_MESSAGE = "产品不存在";
|
||||
|
||||
public static final String INVENTORY_INSUFFICIENT = "2009";
|
||||
public static final String INVENTORY_INSUFFICIENT_MESSAGE = "库存不足";
|
||||
|
||||
public static final String PRICE_ERROR = "2010";
|
||||
public static final String PRICE_ERROR_MESSAGE = "价格错误";
|
||||
|
||||
public static final String CONFIRM_TIME_EXPIRED = "2011";
|
||||
public static final String CONFIRM_TIME_EXPIRED_MESSAGE = "确认时间已过期";
|
||||
|
||||
public static final String DUPLICATE_ORDER = "2012";
|
||||
public static final String DUPLICATE_ORDER_MESSAGE = "重复订单";
|
||||
|
||||
public static final String VOUCHER_GENERATE_ERROR = "2013";
|
||||
public static final String VOUCHER_GENERATE_ERROR_MESSAGE = "凭证生成失败";
|
||||
|
||||
public static final String PASSENGER_INFO_ERROR = "2014";
|
||||
public static final String PASSENGER_INFO_ERROR_MESSAGE = "乘客信息错误";
|
||||
|
||||
public static final String CONTACT_INFO_ERROR = "2015";
|
||||
public static final String CONTACT_INFO_ERROR_MESSAGE = "联系人信息错误";
|
||||
|
||||
public static final String PAYMENT_ERROR = "2016";
|
||||
public static final String PAYMENT_ERROR_MESSAGE = "支付错误";
|
||||
|
||||
public static final String REFUND_ERROR = "2017";
|
||||
public static final String REFUND_ERROR_MESSAGE = "退款错误";
|
||||
|
||||
public static final String CONSUMED_ERROR = "2018";
|
||||
public static final String CONSUMED_ERROR_MESSAGE = "核销错误";
|
||||
|
||||
public static final String CANCEL_ERROR = "2019";
|
||||
public static final String CANCEL_ERROR_MESSAGE = "取消错误";
|
||||
|
||||
public static final String MODIFY_ERROR = "2020";
|
||||
public static final String MODIFY_ERROR_MESSAGE = "修改错误";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据错误码获取错误信息
|
||||
*/
|
||||
public static String getErrorMessage(String errorCode) {
|
||||
switch (errorCode) {
|
||||
case CtripResponseCodes.SUCCESS:
|
||||
return CtripResponseCodes.SUCCESS_MESSAGE;
|
||||
case CtripResponseCodes.SYSTEM_ERROR:
|
||||
return CtripResponseCodes.SYSTEM_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.PARAM_ERROR:
|
||||
return CtripResponseCodes.PARAM_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.SIGN_ERROR:
|
||||
return CtripResponseCodes.SIGN_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.DATA_INVALID:
|
||||
return CtripResponseCodes.DATA_INVALID_MESSAGE;
|
||||
case CtripResponseCodes.TIMEOUT_ERROR:
|
||||
return CtripResponseCodes.TIMEOUT_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.SERVICE_UNAVAILABLE:
|
||||
return CtripResponseCodes.SERVICE_UNAVAILABLE_MESSAGE;
|
||||
case CtripResponseCodes.ORDER_NOT_FOUND:
|
||||
return CtripResponseCodes.ORDER_NOT_FOUND_MESSAGE;
|
||||
case CtripResponseCodes.ORDER_STATUS_ERROR:
|
||||
return CtripResponseCodes.ORDER_STATUS_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.COUPON_NOT_FOUND:
|
||||
return CtripResponseCodes.COUPON_NOT_FOUND_MESSAGE;
|
||||
case CtripResponseCodes.COUPON_ALREADY_USED:
|
||||
return CtripResponseCodes.COUPON_ALREADY_USED_MESSAGE;
|
||||
case CtripResponseCodes.COUPON_EXPIRED:
|
||||
return CtripResponseCodes.COUPON_EXPIRED_MESSAGE;
|
||||
case CtripResponseCodes.COUPON_INSUFFICIENT:
|
||||
return CtripResponseCodes.COUPON_INSUFFICIENT_MESSAGE;
|
||||
case CtripResponseCodes.USER_NOT_FOUND:
|
||||
return CtripResponseCodes.USER_NOT_FOUND_MESSAGE;
|
||||
case CtripResponseCodes.PRODUCT_NOT_FOUND:
|
||||
return CtripResponseCodes.PRODUCT_NOT_FOUND_MESSAGE;
|
||||
case CtripResponseCodes.INVENTORY_INSUFFICIENT:
|
||||
return CtripResponseCodes.INVENTORY_INSUFFICIENT_MESSAGE;
|
||||
case CtripResponseCodes.PRICE_ERROR:
|
||||
return CtripResponseCodes.PRICE_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.CONFIRM_TIME_EXPIRED:
|
||||
return CtripResponseCodes.CONFIRM_TIME_EXPIRED_MESSAGE;
|
||||
case CtripResponseCodes.DUPLICATE_ORDER:
|
||||
return CtripResponseCodes.DUPLICATE_ORDER_MESSAGE;
|
||||
case CtripResponseCodes.VOUCHER_GENERATE_ERROR:
|
||||
return CtripResponseCodes.VOUCHER_GENERATE_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.PASSENGER_INFO_ERROR:
|
||||
return CtripResponseCodes.PASSENGER_INFO_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.CONTACT_INFO_ERROR:
|
||||
return CtripResponseCodes.CONTACT_INFO_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.PAYMENT_ERROR:
|
||||
return CtripResponseCodes.PAYMENT_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.REFUND_ERROR:
|
||||
return CtripResponseCodes.REFUND_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.CONSUMED_ERROR:
|
||||
return CtripResponseCodes.CONSUMED_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.CANCEL_ERROR:
|
||||
return CtripResponseCodes.CANCEL_ERROR_MESSAGE;
|
||||
case CtripResponseCodes.MODIFY_ERROR:
|
||||
return CtripResponseCodes.MODIFY_ERROR_MESSAGE;
|
||||
default:
|
||||
return "未知错误";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为成功码
|
||||
*/
|
||||
public static boolean isSuccess(String resultCode) {
|
||||
return CtripResponseCodes.SUCCESS.equals(resultCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为系统错误码
|
||||
*/
|
||||
public static boolean isSystemError(String resultCode) {
|
||||
return resultCode != null && resultCode.startsWith("1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为业务错误码
|
||||
*/
|
||||
public static boolean isBusinessError(String resultCode) {
|
||||
return resultCode != null && resultCode.startsWith("2");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
server:
|
||||
port: 8082
|
||||
servlet:
|
||||
context-path: /coupon-center
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: coupon-center
|
||||
profiles:
|
||||
active: dev
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/coupon_center?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: 123456
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
default-property-inclusion: non_null
|
||||
|
||||
# 携程API配置
|
||||
ctrip:
|
||||
aes:
|
||||
key: your-aes-key-here-16chars
|
||||
iv: your-aes-iv-here-16chars
|
||||
md5:
|
||||
secret: your-md5-secret-here
|
||||
api:
|
||||
timeout: 30000
|
||||
retry-times: 3
|
||||
base-url: https://api.ctrip.com
|
||||
|
||||
# MyBatis Plus配置
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:mapper/*.xml
|
||||
type-aliases-package: com.central.coupon.entity
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
cache-enabled: false
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto
|
||||
logic-delete-field: deleted
|
||||
logic-delete-value: 1
|
||||
logic-not-delete-value: 0
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.central.coupon: debug
|
||||
org.springframework.web: debug
|
||||
pattern:
|
||||
console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
|
||||
file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
|
||||
file:
|
||||
name: logs/coupon-center.log
|
||||
|
||||
# 开发环境配置
|
||||
---
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: dev
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/coupon_center_dev?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
|
||||
# 生产环境配置
|
||||
---
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: prod
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/coupon_center_prod?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||
profiles:
|
||||
active: prod
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.central.coupon: info
|
||||
org.springframework.web: warn
|
||||
@@ -0,0 +1,15 @@
|
||||
server:
|
||||
port: 8002
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: coupon-center
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
ip: 81.70.164.178
|
||||
# cloud:
|
||||
# nacos:
|
||||
# discovery:
|
||||
# metadata:
|
||||
# version: zlt
|
||||
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.coupon.mapper.CouponMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.coupon.entity.Coupon">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="coupon_no" property="couponNo" jdbcType="VARCHAR"/>
|
||||
<result column="coupon_name" property="couponName" jdbcType="VARCHAR"/>
|
||||
<result column="coupon_type" property="couponType" jdbcType="INTEGER"/>
|
||||
<result column="amount" property="amount" jdbcType="DECIMAL"/>
|
||||
<result column="min_amount" property="minAmount" jdbcType="DECIMAL"/>
|
||||
<result column="discount_rate" property="discountRate" jdbcType="INTEGER"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="user_phone" property="userPhone" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userId" jdbcType="BIGINT"/>
|
||||
<result column="source" property="source" jdbcType="INTEGER"/>
|
||||
<result column="ctrip_coupon_id" property="ctripCouponId" jdbcType="VARCHAR"/>
|
||||
<result column="valid_start_time" property="validStartTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="valid_end_time" property="validEndTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="used_time" property="usedTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="used_order_no" property="usedOrderNo" jdbcType="VARCHAR"/>
|
||||
<result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, coupon_no, coupon_name, coupon_type, amount, min_amount, discount_rate,
|
||||
status, user_phone, user_id, source, ctrip_coupon_id, valid_start_time, valid_end_time,
|
||||
used_time, used_order_no, cancel_time, create_time, update_time, create_by, update_by, remark, tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询优惠券列表 -->
|
||||
<select id="selectCouponPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
<where>
|
||||
<if test="coupon.couponName != null and coupon.couponName != ''">
|
||||
AND coupon_name LIKE CONCAT('%', #{coupon.couponName}, '%')
|
||||
</if>
|
||||
<if test="coupon.userPhone != null and coupon.userPhone != ''">
|
||||
AND user_phone = #{coupon.userPhone}
|
||||
</if>
|
||||
<if test="coupon.status != null">
|
||||
AND status = #{coupon.status}
|
||||
</if>
|
||||
<if test="coupon.source != null">
|
||||
AND source = #{coupon.source}
|
||||
</if>
|
||||
<if test="coupon.couponType != null">
|
||||
AND coupon_type = #{coupon.couponType}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据手机号查询用户优惠券 -->
|
||||
<select id="selectByUserPhone" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
WHERE user_phone = #{userPhone}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据手机号查询可用优惠券 -->
|
||||
<select id="selectAvailableByUserPhone" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
WHERE user_phone = #{userPhone}
|
||||
AND status = 0
|
||||
AND valid_start_time <= NOW()
|
||||
AND valid_end_time >= NOW()
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据携程优惠券ID查询 -->
|
||||
<select id="selectByCtripCouponId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
WHERE ctrip_coupon_id = #{ctripCouponId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据订单号查询使用的优惠券 -->
|
||||
<select id="selectByUsedOrderNo" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_coupon
|
||||
WHERE used_order_no = #{usedOrderNo}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 更新优惠券状态为已使用 -->
|
||||
<update id="updateCouponUsed">
|
||||
UPDATE t_coupon
|
||||
SET status = 1,
|
||||
used_time = NOW(),
|
||||
used_order_no = #{usedOrderNo},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 批量更新过期优惠券状态 -->
|
||||
<update id="updateExpiredCoupons">
|
||||
UPDATE t_coupon
|
||||
SET status = 2,
|
||||
update_time = NOW()
|
||||
WHERE status = 0
|
||||
AND valid_end_time < NOW()
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.order.mapper.CtripConsumedMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.order.entity.CtripConsumed">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="ota_order_id" property="otaOrderId" jdbcType="VARCHAR"/>
|
||||
<result column="supplier_order_id" property="supplierOrderId" jdbcType="VARCHAR"/>
|
||||
<result column="sequence_id" property="sequenceId" jdbcType="VARCHAR"/>
|
||||
<result column="item_id" property="itemId" jdbcType="VARCHAR"/>
|
||||
<result column="use_start_date" property="useStartDate" jdbcType="VARCHAR"/>
|
||||
<result column="use_end_date" property="useEndDate" jdbcType="VARCHAR"/>
|
||||
<result column="quantity" property="quantity" jdbcType="INTEGER"/>
|
||||
<result column="use_quantity" property="useQuantity" jdbcType="INTEGER"/>
|
||||
<result column="lost_amount" property="lostAmount" jdbcType="DECIMAL"/>
|
||||
<result column="lost_amount_currency" property="lostAmountCurrency" jdbcType="VARCHAR"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="remark_detail" property="remarkDetail" jdbcType="VARCHAR"/>
|
||||
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, ota_order_id, supplier_order_id, sequence_id, item_id, use_start_date, use_end_date,
|
||||
quantity, use_quantity, lost_amount, lost_amount_currency, remark, status,
|
||||
create_time, update_time, create_by, update_by, remark_detail, tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 根据携程订单号查询核销信息 -->
|
||||
<select id="selectByOtaOrderId" parameterType="string" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_consumed
|
||||
WHERE ota_order_id = #{otaOrderId,jdbcType=VARCHAR}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据供应商订单号查询核销信息 -->
|
||||
<select id="selectBySupplierOrderId" parameterType="string" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_consumed
|
||||
WHERE supplier_order_id = #{supplierOrderId,jdbcType=VARCHAR}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据供应商批次流水号查询核销信息 -->
|
||||
<select id="selectBySequenceId" parameterType="string" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_consumed
|
||||
WHERE sequence_id = #{sequenceId,jdbcType=VARCHAR}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.order.mapper.CtripConsumedPassengerMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.order.entity.CtripConsumedPassenger">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="consumed_id" property="consumedId" jdbcType="BIGINT"/>
|
||||
<result column="passenger_id" property="passengerId" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, consumed_id, passenger_id, create_time, update_time, create_by, update_by, remark, tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 根据核销ID查询乘客列表 -->
|
||||
<select id="selectByConsumedId" parameterType="long" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_consumed_passenger
|
||||
WHERE consumed_id = #{consumedId,jdbcType=BIGINT}
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.order.mapper.CtripConsumedVoucherMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.order.entity.CtripConsumedVoucher">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="consumed_id" property="consumedId" jdbcType="BIGINT"/>
|
||||
<result column="voucher_id" property="voucherId" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, consumed_id, voucher_id, create_time, update_time, create_by, update_by, remark, tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 根据核销ID查询凭证列表 -->
|
||||
<select id="selectByConsumedId" parameterType="long" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_consumed_voucher
|
||||
WHERE consumed_id = #{consumedId,jdbcType=BIGINT}
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.order.mapper.CtripOrderItemMapper">
|
||||
|
||||
<!-- 根据订单ID查询订单项列表 -->
|
||||
<select id="selectByOrderId" resultType="com.central.order.entity.CtripOrderItem">
|
||||
SELECT
|
||||
id,
|
||||
order_id,
|
||||
item_id,
|
||||
plu,
|
||||
use_start_date,
|
||||
use_end_date,
|
||||
price,
|
||||
sale_price,
|
||||
quantity,
|
||||
create_time,
|
||||
update_time,
|
||||
create_by,
|
||||
update_by,
|
||||
remark,
|
||||
tenant_id
|
||||
FROM t_ctrip_order_item
|
||||
WHERE order_id = #{orderId}
|
||||
ORDER BY id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.order.mapper.CtripOrderMapper">
|
||||
|
||||
<!-- 根据携程订单号查询订单 -->
|
||||
<select id="selectByOtaOrderId" resultType="com.central.order.entity.CtripOrder">
|
||||
SELECT
|
||||
id,
|
||||
ota_order_id,
|
||||
supplier_order_id,
|
||||
sequence_id,
|
||||
confirm_type,
|
||||
order_last_confirm_time,
|
||||
status,
|
||||
create_time,
|
||||
update_time,
|
||||
create_by,
|
||||
update_by,
|
||||
remark,
|
||||
tenant_id
|
||||
FROM t_ctrip_order
|
||||
WHERE ota_order_id = #{otaOrderId}
|
||||
</select>
|
||||
|
||||
<!-- 根据供应商订单号查询订单 -->
|
||||
<select id="selectBySupplierOrderId" resultType="com.central.order.entity.CtripOrder">
|
||||
SELECT
|
||||
id,
|
||||
ota_order_id,
|
||||
supplier_order_id,
|
||||
sequence_id,
|
||||
confirm_type,
|
||||
order_last_confirm_time,
|
||||
status,
|
||||
create_time,
|
||||
update_time,
|
||||
create_by,
|
||||
update_by,
|
||||
remark,
|
||||
tenant_id
|
||||
FROM t_ctrip_order
|
||||
WHERE supplier_order_id = #{supplierOrderId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.order.mapper.CtripPassengerMapper">
|
||||
|
||||
<!-- 根据订单项ID查询乘客列表 -->
|
||||
<select id="selectByOrderItemId" resultType="com.central.order.entity.CtripPassenger">
|
||||
SELECT
|
||||
id,
|
||||
order_item_id,
|
||||
passenger_id,
|
||||
name,
|
||||
mobile,
|
||||
card_type,
|
||||
card_no,
|
||||
age_type,
|
||||
gender,
|
||||
create_time,
|
||||
update_time,
|
||||
create_by,
|
||||
update_by,
|
||||
remark,
|
||||
tenant_id
|
||||
FROM t_ctrip_passenger
|
||||
WHERE order_item_id = #{orderItemId}
|
||||
ORDER BY id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.order.mapper.CtripRefundItemMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.order.entity.CtripRefundItem">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="refund_id" property="refundId" jdbcType="BIGINT"/>
|
||||
<result column="item_id" property="itemId" jdbcType="VARCHAR"/>
|
||||
<result column="plu" property="plu" jdbcType="VARCHAR"/>
|
||||
<result column="amount" property="amount" jdbcType="DECIMAL"/>
|
||||
<result column="amount_currency" property="amountCurrency" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, refund_id, item_id, plu, amount, amount_currency,
|
||||
create_time, update_time, create_by, update_by, remark, tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 根据退款ID查询退款项列表 -->
|
||||
<select id="selectByRefundId" parameterType="long" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_refund_item
|
||||
WHERE refund_id = #{refundId,jdbcType=BIGINT}
|
||||
ORDER BY create_time ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.order.mapper.CtripRefundMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="com.central.order.entity.CtripRefund">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="ota_order_id" property="otaOrderId" jdbcType="VARCHAR"/>
|
||||
<result column="supplier_order_id" property="supplierOrderId" jdbcType="VARCHAR"/>
|
||||
<result column="sequence_id" property="sequenceId" jdbcType="VARCHAR"/>
|
||||
<result column="total_amount" property="totalAmount" jdbcType="DECIMAL"/>
|
||||
<result column="total_amount_currency" property="totalAmountCurrency" jdbcType="VARCHAR"/>
|
||||
<result column="last_confirm_time" property="lastConfirmTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="confirm_result_code" property="confirmResultCode" jdbcType="VARCHAR"/>
|
||||
<result column="confirm_result_message" property="confirmResultMessage" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
<result column="tenant_id" property="tenantId" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, ota_order_id, supplier_order_id, sequence_id, total_amount, total_amount_currency,
|
||||
last_confirm_time, status, confirm_result_code, confirm_result_message,
|
||||
create_time, update_time, create_by, update_by, remark, tenant_id
|
||||
</sql>
|
||||
|
||||
<!-- 根据携程订单号查询退款信息 -->
|
||||
<select id="selectByOtaOrderId" parameterType="string" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_refund
|
||||
WHERE ota_order_id = #{otaOrderId,jdbcType=VARCHAR}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据供应商订单号查询退款信息 -->
|
||||
<select id="selectBySupplierOrderId" parameterType="string" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_refund
|
||||
WHERE supplier_order_id = #{supplierOrderId,jdbcType=VARCHAR}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据携程批次流水号查询退款信息 -->
|
||||
<select id="selectBySequenceId" parameterType="string" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM t_ctrip_refund
|
||||
WHERE sequence_id = #{sequenceId,jdbcType=VARCHAR}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user