| | |
| | | import com.yeshi.fanli.dto.vipshop.VipShopOrderQueryModel; |
| | | import com.yeshi.fanli.dto.vipshop.VipShopQueryOrderResultDTO; |
| | | import com.yeshi.fanli.entity.vipshop.VipShopOrder; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.yeshi.utils.HttpUtil; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.net.URLEncoder; |
| | |
| | | |
| | | |
| | | public static VipShopOrder getOrderDetail(String orderSn) { |
| | | VipShopOrder vipShopOrder = getOrderDetail(orderSn, null); |
| | | if (vipShopOrder == null) { |
| | | //临时使用 |
| | | return getOrderDetail(orderSn, "B8DCE961C5DBD2F52AAEECB6F307546608445FE3"); |
| | | } |
| | | return vipShopOrder; |
| | | } |
| | | |
| | | public static VipShopOrder getOrderDetail(String orderSn, String accessToken) { |
| | | |
| | | String url = "http://api.tbk.dingdanxia.com/vip/order_details?apikey=" + API_KEY; |
| | | url += "&orderSn=" + orderSn; |
| | | if (!StringUtil.isNullOrEmpty(accessToken)) { |
| | | url += "&access_token=" + accessToken; |
| | | } |
| | | |
| | | String result = HttpUtil.get(url); |
| | | System.out.println(result); |
| | | JSONObject data = JSONObject.fromObject(result); |
| | | if (data.optInt("code") != 200) { |
| | | return null; |
| | | } |
| | | VipShopOrder vipShopOrder = new Gson().fromJson(data.optJSONObject("data").toString(), VipShopOrder.class); |
| | | return vipShopOrder; |
| | | if (data.optJSONObject("data") != null) { |
| | | VipShopOrder vipShopOrder = new Gson().fromJson(data.optJSONObject("data").toString(), VipShopOrder.class); |
| | | return vipShopOrder; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * @author hxh |
| | | * @description 从链接中解析商品ID |
| | | * @date 17:36 2024/4/26 |
| | | * @param: link |
| | | * @return java.lang.String |
| | | **/ |
| | | public static String parseGoodsIdFromLink(String link){ |
| | | String url = "http://api.tbk.dingdanxia.com/vip/viplink_check?apikey=" + API_KEY; |
| | | url += "&url=" + URLEncoder.encode(link); |
| | | String result = HttpUtil.get(url); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | | if(resultJSON.optInt("code")==200){ |
| | | return resultJSON.optJSONObject("data").optString("goodsId"); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | //获取accesstoken的信息 |
| | | public static String getAcessTokenInfo(String code, String state) { |
| | | String url = "http://api.tbk.dingdanxia.com/user/get_vip_access?apikey=" + API_KEY; |
| | | url += "&code=" + code; |
| | | url += "&state=" + state; |
| | | String result = HttpUtil.get(url); |
| | | return result; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // convertLinkByUrl("6918302458239328477", "123"); |
| | | // convertLinkByUrl("https://t.vip.com/T7RyKKCJLj9", "437032"); |
| | | |
| | | |
| | | |
| | | // |
| | | // VipShopOrderQueryModel queryModel = new VipShopOrderQueryModel(); |
| | | // queryModel.setPage(1); |
| | | // queryModel.setPageSize(20); |
| | |
| | | // VipShopQueryOrderResultDTO resultDTO = getOrderList(queryModel); |
| | | // System.out.println(resultDTO); |
| | | |
| | | getOrderDetail("21081436395569"); |
| | | // String result = getAcessTokenInfo("576a51ae7b9b4db1bbfc921cf381ac0c", "1234"); |
| | | // System.out.println(result); |
| | | VipShopOrder order = getOrderDetail("24092976176343"); |
| | | // convertLink("6920342191507923649","437032"); |
| | | // System.out.println(parseGoodsIdFromLink("https://t.vip.com/8F39raFxwN7")); |
| | | } |
| | | |
| | | } |