1
This commit is contained in:
@@ -91,4 +91,61 @@ public class JDOrderController {
|
||||
}
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开礼金(转发到内部服务)
|
||||
* 入参:materialUrl 或 skuId,amount(金额,单位元),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),返回短链
|
||||
* 入参:materialUrl,giftCouponKey(可选)
|
||||
*/
|
||||
@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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user