fix(优惠券中心):携程订单接口对接第一版完成对接,新增加密请求体方法
This commit is contained in:
+80
@@ -1166,4 +1166,84 @@ public class CtripCouponController {
|
|||||||
return Result.succeed(result);
|
return Result.succeed(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试接口 - 生成携程核销优惠券请求的加密body
|
||||||
|
*/
|
||||||
|
@Operation(summary = "测试接口 - 生成携程核销优惠券请求的加密body")
|
||||||
|
@PostMapping("/test/generate-verify-request")
|
||||||
|
public Result<Map<String, Object>> generateVerifyRequest(@RequestBody Map<String, Object> request) {
|
||||||
|
log.info("收到生成携程核销优惠券请求体请求");
|
||||||
|
|
||||||
|
// 验证请求体不为空
|
||||||
|
if (request == null || request.isEmpty()) {
|
||||||
|
log.error("请求体为空");
|
||||||
|
return Result.succeed(Map.of("success", false, "error", "请求体不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 解析请求参数
|
||||||
|
String ctripCouponId = (String) request.get("ctripCouponId");
|
||||||
|
String orderNo = (String) request.get("orderNo");
|
||||||
|
|
||||||
|
if (ctripCouponId == null || orderNo == null) {
|
||||||
|
log.error("参数不完整 - ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo);
|
||||||
|
return Result.succeed(Map.of("success", false, "error", "参数不完整"));
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("开始生成携程核销优惠券请求体,ctripCouponId: {}, orderNo: {}", ctripCouponId, orderNo);
|
||||||
|
|
||||||
|
// 构建核销请求的body - 按照携程核销优惠券接口规范
|
||||||
|
Map<String, Object> requestBody = new HashMap<>();
|
||||||
|
requestBody.put("userPhone", "13800138000"); // 默认用户手机号
|
||||||
|
requestBody.put("orderNo", orderNo);
|
||||||
|
requestBody.put("orderAmount", 100.00); // 默认订单金额
|
||||||
|
|
||||||
|
// 构建完整的请求(包含header和body)
|
||||||
|
Map<String, Object> fullRequest = new HashMap<>();
|
||||||
|
|
||||||
|
// 构建header
|
||||||
|
Map<String, Object> header = new HashMap<>();
|
||||||
|
header.put("accountId", "c50a8f2a4a59c9e7");
|
||||||
|
header.put("serviceName", "VerifyCoupon");
|
||||||
|
header.put("requestTime", java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
|
header.put("version", "1.0");
|
||||||
|
|
||||||
|
// 生成签名
|
||||||
|
String bodyJson = objectMapper.writeValueAsString(requestBody);
|
||||||
|
String sign = ctripDecryptUtil.generateSign("c50a8f2a4a59c9e7", "VerifyCoupon",
|
||||||
|
header.get("requestTime").toString(), bodyJson, "1.0");
|
||||||
|
header.put("sign", sign);
|
||||||
|
|
||||||
|
// 使用AES加密body
|
||||||
|
String encryptedBody = ctripDecryptUtil.encryptAES(bodyJson);
|
||||||
|
|
||||||
|
fullRequest.put("header", header);
|
||||||
|
fullRequest.put("body", encryptedBody); // 加密后的body
|
||||||
|
|
||||||
|
// 生成JSON字符串
|
||||||
|
String requestJson = objectMapper.writeValueAsString(fullRequest);
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("success", true);
|
||||||
|
result.put("url", "/coupon/ctrip/verify");
|
||||||
|
result.put("method", "POST");
|
||||||
|
result.put("headers", Map.of("Content-Type", "application/json"));
|
||||||
|
result.put("originalBody", requestBody);
|
||||||
|
result.put("encryptedBody", encryptedBody);
|
||||||
|
result.put("fullRequest", fullRequest);
|
||||||
|
result.put("requestJson", requestJson);
|
||||||
|
result.put("message", "携程核销优惠券请求体生成成功");
|
||||||
|
|
||||||
|
log.info("携程核销优惠券请求体生成成功: {}", result);
|
||||||
|
return Result.succeed(result);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("生成携程核销优惠券请求体失败", e);
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("error", e.getMessage());
|
||||||
|
return Result.succeed(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,8 @@ logging:
|
|||||||
ctrip:
|
ctrip:
|
||||||
# AES加密配置
|
# AES加密配置
|
||||||
aes:
|
aes:
|
||||||
key: 087b36ad0dff7942 # 请替换为实际的AES密钥
|
key: 087b36ad0dff7942 # 为实际的AES密钥
|
||||||
iv: 750e15a31356a99d # 请替换为实际的AES IV
|
iv: 750e15a31356a99d # 为实际的AES IV
|
||||||
# 签名配置(使用账户密钥进行签名计算)
|
# 签名配置(使用账户密钥进行签名计算)
|
||||||
# API配置
|
# API配置
|
||||||
api:
|
api:
|
||||||
@@ -56,5 +56,5 @@ ctrip:
|
|||||||
retry-times: 3 # 重试次数
|
retry-times: 3 # 重试次数
|
||||||
# 账户配置
|
# 账户配置
|
||||||
account:
|
account:
|
||||||
id: c50a8f2a4a59c9e7 # 请替换为实际的账户ID
|
id: c50a8f2a4a59c9e7 # 为实际的账户ID
|
||||||
secret: ce6033ae31124ec5cdab3d2bc79f2622 # 请替换为实际的账户密钥
|
secret: ce6033ae31124ec5cdab3d2bc79f2622 # 实际的账户密钥
|
||||||
|
|||||||
+6
-4
@@ -105,17 +105,19 @@ public class TourismController {
|
|||||||
@Parameter(name = "longitude", description = "经度", required = true, in = ParameterIn.QUERY),
|
@Parameter(name = "longitude", description = "经度", required = true, in = ParameterIn.QUERY),
|
||||||
@Parameter(name = "latitude", description = "纬度", required = true, in = ParameterIn.QUERY),
|
@Parameter(name = "latitude", description = "纬度", required = true, in = ParameterIn.QUERY),
|
||||||
@Parameter(name = "radius", description = "搜索半径(公里),默认10km", required = false, in = ParameterIn.QUERY),
|
@Parameter(name = "radius", description = "搜索半径(公里),默认10km", required = false, in = ParameterIn.QUERY),
|
||||||
@Parameter(name = "limit", description = "返回数量限制,默认20个", required = false, in = ParameterIn.QUERY)
|
@Parameter(name = "limit", description = "返回数量限制,默认20个", required = false, in = ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "showInHomepage", description = "是否在首页显示(0:不显示,1:显示),默认1(只显示设置为显示的景区)", required = false, in = ParameterIn.QUERY)
|
||||||
})
|
})
|
||||||
@GetMapping("/nearby")
|
@GetMapping("/nearby")
|
||||||
public Result<List<TourismWithDistance>> findNearbyTourisms(
|
public Result<List<TourismWithDistance>> findNearbyTourisms(
|
||||||
@RequestParam BigDecimal longitude,
|
@RequestParam BigDecimal longitude,
|
||||||
@RequestParam BigDecimal latitude,
|
@RequestParam BigDecimal latitude,
|
||||||
@RequestParam(required = false) Double radius,
|
@RequestParam(required = false) Double radius,
|
||||||
@RequestParam(required = false) Integer limit) {
|
@RequestParam(required = false) Integer limit,
|
||||||
|
@RequestParam(required = false, defaultValue = "1") Integer showInHomepage) {
|
||||||
try {
|
try {
|
||||||
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}", longitude, latitude, radius, limit);
|
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}, 首页显示: {}", longitude, latitude, radius, limit, showInHomepage);
|
||||||
List<TourismWithDistance> tourisms = tourismService.findNearbyTourisms(longitude, latitude, radius, limit);
|
List<TourismWithDistance> tourisms = tourismService.findNearbyTourisms(longitude, latitude, radius, limit, showInHomepage);
|
||||||
return Result.succeed(tourisms, "查询附近景区成功");
|
return Result.succeed(tourisms, "查询附近景区成功");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("查询附近景区失败", e);
|
log.error("查询附近景区失败", e);
|
||||||
|
|||||||
+1
-1
@@ -532,7 +532,7 @@ public interface DashboardMapper {
|
|||||||
|
|
||||||
@Select({
|
@Select({
|
||||||
"<script>",
|
"<script>",
|
||||||
"SELECT code_id as value, name as label FROM qrcodes",
|
"SELECT code_id as value, CONCAT(name, ' | ¥', FORMAT(price/100, 2), '元') as label FROM qrcodes",
|
||||||
"WHERE is_del = 0",
|
"WHERE is_del = 0",
|
||||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||||
" AND is_test = 0",
|
" AND is_test = 0",
|
||||||
|
|||||||
@@ -48,13 +48,15 @@ public interface TourismMapper extends SuperMapper<Tourism> {
|
|||||||
* @param latitude 纬度
|
* @param latitude 纬度
|
||||||
* @param radius 搜索半径(公里)
|
* @param radius 搜索半径(公里)
|
||||||
* @param limit 返回数量限制
|
* @param limit 返回数量限制
|
||||||
|
* @param showInHomepage 是否在首页显示(0:不显示,1:显示,null:显示所有)
|
||||||
* @return 附近景区列表(包含距离信息)
|
* @return 附近景区列表(包含距离信息)
|
||||||
*/
|
*/
|
||||||
List<TourismWithDistance> findNearbyTourisms(
|
List<TourismWithDistance> findNearbyTourisms(
|
||||||
@Param("longitude") BigDecimal longitude,
|
@Param("longitude") BigDecimal longitude,
|
||||||
@Param("latitude") BigDecimal latitude,
|
@Param("latitude") BigDecimal latitude,
|
||||||
@Param("radius") Double radius,
|
@Param("radius") Double radius,
|
||||||
@Param("limit") Integer limit
|
@Param("limit") Integer limit,
|
||||||
|
@Param("showInHomepage") Integer showInHomepage
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,4 +54,9 @@ public class Tourism extends SuperEntity {
|
|||||||
private String tenantId;
|
private String tenantId;
|
||||||
private String company;
|
private String company;
|
||||||
private Integer isDel;
|
private Integer isDel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否在首页显示(0:不显示,1:显示)
|
||||||
|
*/
|
||||||
|
private Integer showInHomepage;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -53,9 +53,10 @@ public interface ITourismService extends ISuperService<Tourism> {
|
|||||||
* @param latitude 纬度
|
* @param latitude 纬度
|
||||||
* @param radius 搜索半径(公里)
|
* @param radius 搜索半径(公里)
|
||||||
* @param limit 返回数量限制
|
* @param limit 返回数量限制
|
||||||
|
* @param showInHomepage 是否在首页显示(0:不显示,1:显示,null:显示所有)
|
||||||
* @return 附近景区列表(包含距离信息)
|
* @return 附近景区列表(包含距离信息)
|
||||||
*/
|
*/
|
||||||
List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit);
|
List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit, Integer showInHomepage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据经纬度范围查询景区
|
* 根据经纬度范围查询景区
|
||||||
|
|||||||
+8
-3
@@ -67,8 +67,8 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit) {
|
public List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit, Integer showInHomepage) {
|
||||||
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}", longitude, latitude, radius, limit);
|
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}, 首页显示: {}", longitude, latitude, radius, limit, showInHomepage);
|
||||||
|
|
||||||
// 参数验证
|
// 参数验证
|
||||||
if (longitude == null || latitude == null) {
|
if (longitude == null || latitude == null) {
|
||||||
@@ -84,7 +84,12 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
|||||||
limit = 20; // 默认返回20个
|
limit = 20; // 默认返回20个
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TourismWithDistance> tourisms = baseMapper.findNearbyTourisms(longitude, latitude, radius, limit);
|
// 默认只显示设置为显示的景区
|
||||||
|
if (showInHomepage == null) {
|
||||||
|
showInHomepage = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TourismWithDistance> tourisms = baseMapper.findNearbyTourisms(longitude, latitude, radius, limit, showInHomepage);
|
||||||
log.info("查询到附近景区数量: {}", tourisms.size());
|
log.info("查询到附近景区数量: {}", tourisms.size());
|
||||||
|
|
||||||
// 为每个景区添加订单展示图片
|
// 为每个景区添加订单展示图片
|
||||||
|
|||||||
@@ -56,6 +56,21 @@
|
|||||||
AND status = 1
|
AND status = 1
|
||||||
AND longitude IS NOT NULL
|
AND longitude IS NOT NULL
|
||||||
AND latitude IS NOT NULL
|
AND latitude IS NOT NULL
|
||||||
|
]]>
|
||||||
|
<choose>
|
||||||
|
<when test="showInHomepage != null">
|
||||||
|
<if test="showInHomepage == 1">
|
||||||
|
AND (show_in_homepage = 1 OR show_in_homepage IS NULL)
|
||||||
|
</if>
|
||||||
|
<if test="showInHomepage == 0">
|
||||||
|
AND show_in_homepage = 0
|
||||||
|
</if>
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
AND (show_in_homepage = 1 OR show_in_homepage IS NULL)
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
<![CDATA[
|
||||||
HAVING distance <= #{radius}
|
HAVING distance <= #{radius}
|
||||||
ORDER BY distance ASC
|
ORDER BY distance ASC
|
||||||
]]>
|
]]>
|
||||||
|
|||||||
@@ -485,12 +485,17 @@ const Welcome: React.FC = () => {
|
|||||||
{/* 新增二维码选择器 */}
|
{/* 新增二维码选择器 */}
|
||||||
<Select
|
<Select
|
||||||
placeholder="选择二维码"
|
placeholder="选择二维码"
|
||||||
style={{ width: 200 }}
|
style={{ width: 250 }}
|
||||||
allowClear
|
allowClear
|
||||||
disabled={!selectedTourism}
|
disabled={!selectedTourism}
|
||||||
options={getCurrentTourismQrcodes()}
|
options={getCurrentTourismQrcodes()}
|
||||||
value={selectedQrcode}
|
value={selectedQrcode}
|
||||||
onChange={setSelectedQrcode}
|
onChange={setSelectedQrcode}
|
||||||
|
showSearch
|
||||||
|
optionFilterProp="label"
|
||||||
|
filterOption={(input, option) =>
|
||||||
|
(String(option?.label) ?? '').toLowerCase().includes(input.toLowerCase())
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
{/* 新增平台分账比例选择 */}
|
{/* 新增平台分账比例选择 */}
|
||||||
<span>平台分账比例:</span>
|
<span>平台分账比例:</span>
|
||||||
|
|||||||
+12
@@ -88,6 +88,18 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
|
|||||||
rules={[{ required: true, message: '此项为必填项' }]}
|
rules={[{ required: true, message: '此项为必填项' }]}
|
||||||
placeholder="请选择状态"
|
placeholder="请选择状态"
|
||||||
/>
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="showInHomepage"
|
||||||
|
label="首页显示"
|
||||||
|
width="md"
|
||||||
|
options={[
|
||||||
|
{ label: '显示', value: 1 },
|
||||||
|
{ label: '不显示', value: 0 },
|
||||||
|
]}
|
||||||
|
rules={[{ required: true, message: '此项为必填项' }]}
|
||||||
|
placeholder="请选择是否在首页显示"
|
||||||
|
tooltip="控制景区是否在首页附近景区列表中显示"
|
||||||
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
|
|||||||
@@ -204,6 +204,23 @@ const TableList: React.FC = () => {
|
|||||||
'0': { text: '未启用', status: 'Error' },
|
'0': { text: '未启用', status: 'Error' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '首页显示',
|
||||||
|
dataIndex: 'showInHomepage',
|
||||||
|
valueType: 'select',
|
||||||
|
valueEnum: {
|
||||||
|
'1': { text: '显示', status: 'Success' },
|
||||||
|
'0': { text: '不显示', status: 'Default' },
|
||||||
|
},
|
||||||
|
render: (_, record) => {
|
||||||
|
const showInHomepage = record.showInHomepage ?? 1; // 默认为1(显示)
|
||||||
|
return showInHomepage === 1 ? (
|
||||||
|
<Tag color="green">显示</Tag>
|
||||||
|
) : (
|
||||||
|
<Tag color="default">不显示</Tag>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
dataIndex: 'createTime',
|
dataIndex: 'createTime',
|
||||||
@@ -318,6 +335,18 @@ const TableList: React.FC = () => {
|
|||||||
rules={[formRules.required]}
|
rules={[formRules.required]}
|
||||||
initialValue="1"
|
initialValue="1"
|
||||||
/>
|
/>
|
||||||
|
<ProFormSelect
|
||||||
|
name="showInHomepage"
|
||||||
|
label="首页显示"
|
||||||
|
width="md"
|
||||||
|
options={[
|
||||||
|
{ label: '显示', value: 1 },
|
||||||
|
{ label: '不显示', value: 0 },
|
||||||
|
]}
|
||||||
|
rules={[formRules.required]}
|
||||||
|
initialValue={1}
|
||||||
|
tooltip="控制景区是否在首页附近景区列表中显示"
|
||||||
|
/>
|
||||||
</ProForm.Group>
|
</ProForm.Group>
|
||||||
|
|
||||||
<ProForm.Group>
|
<ProForm.Group>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ declare namespace ORDERS {
|
|||||||
status: number;
|
status: number;
|
||||||
tenantId?: string;
|
tenantId?: string;
|
||||||
updateTime?: string;
|
updateTime?: string;
|
||||||
|
showInHomepage?: number; // 是否在首页显示(0:不显示,1:显示)
|
||||||
}
|
}
|
||||||
|
|
||||||
type TourismWithDistance = Tourism & {
|
type TourismWithDistance = Tourism & {
|
||||||
|
|||||||
Reference in New Issue
Block a user