This commit is contained in:
雷欧(林平凡)
2025-08-21 16:01:39 +08:00
parent 339a230186
commit 2c16f2d26f

View File

@@ -91,4 +91,61 @@ public class JDOrderController {
}
return AjaxResult.success(result);
}
/**
* 开礼金(转发到内部服务)
* 入参materialUrl 或 skuIdamount(金额,单位元)quantity(数量)owner(g/pop)skuName(可选)
* 返回内部服务原样JSON
*/
@PostMapping("/createGiftCoupon")
public AjaxResult createGiftCoupon(@RequestBody Map<String, Object> body) {
try {
String url = requestUrl + "createGiftCoupon";
JSONObject param = new JSONObject();
param.put("skey", skey);
// 透传必要参数
if (body.get("materialUrl") != null) param.put("materialUrl", body.get("materialUrl"));
if (body.get("skuId") != null) param.put("skuId", body.get("skuId"));
if (body.get("amount") != null) param.put("amount", body.get("amount"));
if (body.get("quantity") != null) param.put("quantity", body.get("quantity"));
if (body.get("owner") != null) param.put("owner", body.get("owner"));
if (body.get("skuName") != null) param.put("skuName", body.get("skuName"));
String result = HttpUtils.sendJsonPost(url, param.toJSONString());
// 优先返回JSON对象若非JSON则按字符串返回
try {
Object parsed = JSON.parse(result);
return AjaxResult.success(parsed);
} catch (Exception ignore) {
return AjaxResult.success(result);
}
} catch (Exception e) {
return AjaxResult.error("开礼金失败: " + e.getMessage());
}
}
/**
* 转链接口支持礼金Key返回短链
* 入参materialUrlgiftCouponKey(可选)
*/
@PostMapping("/transfer")
public AjaxResult transfer(@RequestBody Map<String, Object> body) {
try {
String url = requestUrl + "transfer";
JSONObject param = new JSONObject();
param.put("skey", skey);
if (body.get("materialUrl") != null) param.put("materialUrl", body.get("materialUrl"));
if (body.get("giftCouponKey") != null) param.put("giftCouponKey", body.get("giftCouponKey"));
String result = HttpUtils.sendJsonPost(url, param.toJSONString());
try {
Object parsed = JSON.parse(result);
return AjaxResult.success(parsed);
} catch (Exception ignore) {
return AjaxResult.success(result);
}
} catch (Exception e) {
return AjaxResult.error("转链失败: " + e.getMessage());
}
}
}