1
This commit is contained in:
@@ -533,13 +533,16 @@ public class JDUtil {
|
||||
* 接口描述:通过商品链接、领券链接、活动链接获取普通推广链接或优惠券二合一推广链接
|
||||
* jd.union.open.promotion.bysubunionid.get
|
||||
*/
|
||||
String transfer(String url) {
|
||||
String transfer(String url,String giftCouponKey) {
|
||||
JdClient client = new DefaultJdClient(SERVER_URL, ACCESS_TOKEN, LPF_APP_KEY_WZ, LPF_SECRET_KEY_WZ);
|
||||
|
||||
UnionOpenPromotionBysubunionidGetRequest request=new UnionOpenPromotionBysubunionidGetRequest();
|
||||
PromotionCodeReq promotionCodeReq=new PromotionCodeReq();
|
||||
promotionCodeReq.setSceneId(1);
|
||||
promotionCodeReq.setMaterialId(url);
|
||||
if (giftCouponKey!=null){
|
||||
promotionCodeReq.setGiftCouponKey(giftCouponKey);
|
||||
}
|
||||
|
||||
request.setPromotionCodeReq(promotionCodeReq);
|
||||
|
||||
@@ -740,7 +743,7 @@ public class JDUtil {
|
||||
|
||||
StringBuilder enrichedContent = new StringBuilder();
|
||||
for (String url : urls) {
|
||||
String transferUrl = transfer(url);
|
||||
String transferUrl = transfer(url,null);
|
||||
if (transferUrl != null) {
|
||||
enrichedContent.append("原链接:").append(url).append("\n")
|
||||
.append("转链后链接:").append(transferUrl).append("\n");
|
||||
@@ -778,17 +781,6 @@ public class JDUtil {
|
||||
if (cacheMap.get("text"+fromWxid) != null) {
|
||||
String data = cacheMap.get("text" + fromWxid);
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
//"materialUrl": "jingfen.jd.com/detail/BsrqLq5CfIziE7BSl3ItPp8q_3DFaNVYJqfkRRLc7HR.html",
|
||||
//"oriItemId": "BMrqLq5CfIz9X04KC3ItPp8q_3DFaNVYJqfkRRLc7HR",
|
||||
//"owner": "g",
|
||||
//"shopInfo": {
|
||||
// "shopId": 1000001741,
|
||||
// "shopLabel": "0",
|
||||
// "shopLevel": 4.9,
|
||||
// "shopName": "松下洗衣机京东自营旗舰店"
|
||||
//},
|
||||
//"skuName": "松下(Panasonic)白月光4.0Ultra 洗烘套装 10kg滚筒洗衣机+变频热泵烘干机 除毛升级2.0 水氧SPA护理 8532N+8532NR",
|
||||
//"spuid": 100137629936,
|
||||
skuId = jsonObject.getString("materialUrl");
|
||||
String owner1 = jsonObject.getString("owner");
|
||||
if (owner1 != null && owner1.equals("g")){
|
||||
@@ -841,7 +833,7 @@ public class JDUtil {
|
||||
String formattedAmount = String.format("%.2f", amount);
|
||||
state.getCollectedFields().put("amount", formattedAmount);
|
||||
state.setCurrentStep(STEP_QUANTITY);
|
||||
wxUtil.sendTextMessage(fromWxid, "请输入数量(1-1000):", 1, fromWxid);
|
||||
wxUtil.sendTextMessage(fromWxid, "请输入数量(1-100):", 1, fromWxid);
|
||||
break;
|
||||
|
||||
case STEP_QUANTITY:
|
||||
@@ -852,8 +844,8 @@ public class JDUtil {
|
||||
}
|
||||
|
||||
int quantity = Integer.parseInt(message);
|
||||
if (quantity < 1 || quantity > 1000) {
|
||||
wxUtil.sendTextMessage(fromWxid, "数量需在1-1000之间", 1, fromWxid);
|
||||
if (quantity < 1 || quantity > 100) {
|
||||
wxUtil.sendTextMessage(fromWxid, "数量需在1-100之间", 1, fromWxid);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -872,6 +864,18 @@ public class JDUtil {
|
||||
|
||||
logger.info("用户 {} 礼金创建成功:批次ID={}, 参数:SKU={}, 金额={}元,数量={}, Owner={}", fromWxid, giftKey, skuId, amount, quantity, owner); // 新增关键成功日志
|
||||
state.getCollectedFields().put("giftKey", giftKey);
|
||||
|
||||
// 需要调用转链,传入礼金批次ID,返回转链和文案
|
||||
if (cacheMap.get("text"+fromWxid) != null) {
|
||||
String data = cacheMap.get("text" + fromWxid);
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
skuId = jsonObject.getString("materialUrl");
|
||||
String transfer = transfer(skuId, giftKey);
|
||||
wxUtil.sendTextMessage(fromWxid, "附带礼金的链接:\n" + transfer, 1, fromWxid);
|
||||
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -1171,6 +1175,7 @@ public class JDUtil {
|
||||
//"skuName": "松下(Panasonic)白月光4.0Ultra 洗烘套装 10kg滚筒洗衣机+变频热泵烘干机 除毛升级2.0 水氧SPA护理 8532N+8532NR",
|
||||
//"spuid": 100137629936,
|
||||
dataList.add(JSONObject.toJSONString(productInfo.getData()[0]));
|
||||
resultList.add(dataList);
|
||||
|
||||
|
||||
HashMap<String, String> itemMap = new HashMap<>();
|
||||
@@ -1217,7 +1222,7 @@ public class JDUtil {
|
||||
StringBuilder wenan = new StringBuilder().append("文案生成: \n");
|
||||
// 完成转链后替换链接为u.jd.com链接,文案不修改就返回
|
||||
for (HashMap<String, String> stringStringHashMap : resultList) {
|
||||
String transferUrl = transfer(stringStringHashMap.get("materialUrl"));
|
||||
String transferUrl = transfer(stringStringHashMap.get("materialUrl"),null);
|
||||
wenan = new StringBuilder(message.replace(stringStringHashMap.get("url"), transferUrl));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user