|
|
@@ -1,546 +0,0 @@
|
|
|
-package zs.payment.service.paysupply.impl;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.ObjectUtils;
|
|
|
-import zs.payment.dto.OrderDetailDTO;
|
|
|
-import zs.payment.entity.Orders;
|
|
|
-import zs.payment.enums.CallbackMessageType;
|
|
|
-import zs.payment.enums.ProductSupplyRedis;
|
|
|
-import zs.payment.messages.KafkaProducer;
|
|
|
-import zs.payment.req.*;
|
|
|
-import zs.payment.req.aftersales.AfterSalesOrderReq;
|
|
|
-import zs.payment.req.aftersales.AfterSalesOrderTypeReq;
|
|
|
-import zs.payment.req.storage.StoragePageReq;
|
|
|
-import zs.payment.resp.Result;
|
|
|
-
|
|
|
-import zs.payment.service.order.OrdersService;
|
|
|
-import zs.payment.service.paysupply.PaySupplyService;
|
|
|
-import zs.payment.utils.HttpUtil;
|
|
|
-import zs.payment.utils.RedisUtils;
|
|
|
-
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import static zs.payment.enums.ProductSupplyRedis.SUPPLY_TOKEN;
|
|
|
-
|
|
|
-@Service
|
|
|
-@Slf4j
|
|
|
-public class PaySupplyServiceImpl implements PaySupplyService {
|
|
|
-
|
|
|
-
|
|
|
- @Value("${supply.demain}")
|
|
|
- private String prefixUrl;
|
|
|
-
|
|
|
- @Value("${supply.appKey}")
|
|
|
- private String appKey;
|
|
|
- @Value("${supply.appSecret}")
|
|
|
- private String appSecret;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OrdersService ordersService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private RedisUtils redisUtils;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private KafkaProducer kafkaProducer;
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result detailList(ProductDetailReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("ids", req.getIds());
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/product/storage/detailList", params, headers);
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- log.info("查看商品详情失败,{}", req.getIds());
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- return Result.success(respJson.getJSONObject("data").getJSONArray("list"));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 请求上游获取token并缓存到Redis
|
|
|
- * 成功返回 Result.success(token),失败返回 Result.fail(msg)
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Result fetchAndCacheToken() {
|
|
|
- // 先判断TTL,剩余时间大于1小时才取缓存token直接返回
|
|
|
- if (redisUtils.ttl(SUPPLY_TOKEN) > 3600) {
|
|
|
- return Result.success(redisUtils.get(SUPPLY_TOKEN));
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("app_key", appKey);
|
|
|
- params.put("app_secret", appSecret);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/application/getToken", params);
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject data = respJson.getJSONObject("data");
|
|
|
- String token = data.getString("token");
|
|
|
- long expiresAt = data.getLongValue("expiresAt");
|
|
|
-
|
|
|
- long ttlSeconds = (expiresAt - System.currentTimeMillis()) / 1000;
|
|
|
- if (ttlSeconds <= 0) ttlSeconds = 60;
|
|
|
-
|
|
|
- redisUtils.set(SUPPLY_TOKEN, token, (int) ttlSeconds);
|
|
|
-
|
|
|
- return Result.success(token);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result cursorList(ProductPageReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("pageSize", req.getPageSize());
|
|
|
- if (req.getCursor() != null) {
|
|
|
- params.put("cursor", req.getCursor());
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/product/storage/cursorList", params, headers);
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- return Result.success(respJson.getJSONObject("data"));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result beforeCheck(OrderCheckReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("spu", req.getSpu());
|
|
|
- params.put("address", req.getAddress());
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/order/beforeCheck", params, headers);
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- return Result.success(respJson.getJSONObject("data"));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result orderConfirmOnly(OrderReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("spu", req.getSpu());
|
|
|
- params.put("address", req.getAddress());
|
|
|
- params.put("order_sn", req.getOrderSn());
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/order/orderConfirmOnly", params, headers);
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- List<Orders> orders = JSONObject.parseArray(
|
|
|
- respJson.getJSONObject("data").getJSONArray("Orders").toJSONString(),
|
|
|
- Orders.class
|
|
|
- );
|
|
|
- log.info("仅下单,存储订单");
|
|
|
- ordersService.addBatchOrder(orders);
|
|
|
-
|
|
|
- return Result.success(orders);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result orderPayOnly(OrderPayReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("order_sn", req.getOrderSn());
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/order/orderPayOnly", params, headers);
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- List<Orders> orders = JSONObject.parseArray(
|
|
|
- respJson.getJSONObject("data").getJSONArray("Orders").toJSONString(),
|
|
|
- Orders.class
|
|
|
- );
|
|
|
- return Result.success(orders);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result order(OrderReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("spu", req.getSpu());
|
|
|
- params.put("address", req.getAddress());
|
|
|
- params.put("order_sn", req.getOrderSn());
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/order", params, headers);
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- List<Orders> orders = JSONObject.parseArray(
|
|
|
- respJson.getJSONObject("data").getJSONArray("Orders").toJSONString(),
|
|
|
- Orders.class
|
|
|
- );
|
|
|
- log.info("下单并支付,存储订单");
|
|
|
- ordersService.addBatchOrder(orders);
|
|
|
- return Result.success(orders);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result appCloseOrder(CloseOrderReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("order_id", req.getOrderId());
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/order/appCloseOrder", params, headers);
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
- //{
|
|
|
- // "body": {
|
|
|
- // "MSG": "SUCCESS",
|
|
|
- // "CODE": 200,
|
|
|
- // "data": {
|
|
|
- // "errorOrdersSNs": null,
|
|
|
- // "successOrdersSNs": [
|
|
|
- // 195319850638
|
|
|
- // ]
|
|
|
- // }
|
|
|
- // },
|
|
|
- // "success": true
|
|
|
- //}
|
|
|
- return Result.success(respJson.getJSONObject("data"));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result getAfterSalesTypeNameMap(AfterSalesOrderTypeReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("order_id", req.getOrderId());
|
|
|
- params.put("order_item_id",req.getOrderItemId());
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplateGet(prefixUrl + "/supplyapi/app/afterSales/getAfterSalesTypeNameMap", params, headers);
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- return Result.success(respJson.getJSONObject("data"));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result afterSalesCreate(AfterSalesOrderReq req) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("order_id", req.getOrderId());
|
|
|
- params.put("is_received",req.getIsReceived());
|
|
|
- params.put("order_item_id",req.getOrderItemId());
|
|
|
- if (!ObjectUtils.isEmpty(req.getAmount())){
|
|
|
- //退款总额不为空
|
|
|
- params.put("amount",req.getAmount());
|
|
|
- }
|
|
|
- if (!ObjectUtils.isEmpty(req.getRefundType())){
|
|
|
- // 退款方式: "0": "退款", "1": "退货退款"
|
|
|
- params.put("refund_type",req.getRefundType());
|
|
|
- }
|
|
|
- if (!ObjectUtils.isEmpty(req.getTechnicalServicesFee())){
|
|
|
- //技术服务费
|
|
|
- params.put("technical_services_fee",req.getTechnicalServicesFee());
|
|
|
- }
|
|
|
-
|
|
|
- if (!ObjectUtils.isEmpty(req.getFreight())){
|
|
|
- //运费
|
|
|
- params.put("freight",req.getFreight());
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/afterSales/create", params, headers);
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- //todo 需要把data进行存储,方便之后的取消售后操作
|
|
|
-
|
|
|
-
|
|
|
- return Result.success(respJson.getJSONObject("data"));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result afterSalesClose(Integer id) {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("id", id);
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/afterSales/close", params, headers);
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return Result.success(respJson.getJSONObject("data"));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result getMyStorageIdsList(StoragePageReq req) {
|
|
|
-
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("page", req.getPage());
|
|
|
- params.put("pageSize",req.getPageSize());
|
|
|
- params.put("create_sort",req.getCreateSort());
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/product/storage/getMyStorageIdsList", params, headers);
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
- //把选品库中的商品同步到企云商城中 list:[2932,9600]
|
|
|
- JSONArray array = respJson.getJSONObject("data").getJSONArray("list");
|
|
|
- kafkaProducer.sendMessage(CallbackMessageType.GOODS_SYNC, array.toString());
|
|
|
-
|
|
|
- return Result.success(respJson.getJSONObject("data"));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result syncToQiyun() {
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- log.error("syncToQiyun: 获取token失败");
|
|
|
- return Result.fail("获取token失败");
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- int page = 1;
|
|
|
- int pageSize = 50;
|
|
|
- int total = 0;
|
|
|
- boolean isFirstPage = true;
|
|
|
-
|
|
|
- try {
|
|
|
- while (true) {
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("page", page);
|
|
|
- params.put("pageSize", pageSize);
|
|
|
- params.put("create_sort", "desc");
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
-
|
|
|
- String resp = HttpUtil.restTemplatePost(
|
|
|
- prefixUrl + "/supplyapi/app/product/storage/getMyStorageIdsList",
|
|
|
- params,
|
|
|
- headers
|
|
|
- );
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- log.error("syncToQiyun: 调用选品库列表接口失败,page={},msg={}", page, respJson.getString("msg"));
|
|
|
- return Result.fail("调用选品库列表接口失败: " + respJson.getString("msg"));
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject data = respJson.getJSONObject("data");
|
|
|
- JSONArray array = data.getJSONArray("list");
|
|
|
-
|
|
|
- if (isFirstPage) {
|
|
|
- total = data.getIntValue("total");
|
|
|
- isFirstPage = false;
|
|
|
- }
|
|
|
-
|
|
|
- if (array != null && !array.isEmpty()) {
|
|
|
- if (!sendKafkaMessageWithRetry(array.toString())) {
|
|
|
- log.error("syncToQiyun: Kafka发送失败,page={},已重试3次", page);
|
|
|
- return Result.fail("Kafka发送失败,第" + page + "页数据发送失败");
|
|
|
- }
|
|
|
- log.info("syncToQiyun: 成功发送第{}页数据,共{}条", page, array.size());
|
|
|
- }
|
|
|
-
|
|
|
- int currentPage = data.getIntValue("page");
|
|
|
- int currentPageSize = data.getIntValue("pageSize");
|
|
|
- int nextPage = currentPage + 1;
|
|
|
-
|
|
|
- if (nextPage * currentPageSize > total) {
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- page = nextPage;
|
|
|
- }
|
|
|
-
|
|
|
- log.info("syncToQiyun: 所有商品数据同步完成,总计{}条", total);
|
|
|
- return Result.success(true);
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("syncToQiyun: 执行异常", e);
|
|
|
- return Result.fail("执行异常: " + e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private boolean sendKafkaMessageWithRetry(String message) {
|
|
|
- int maxRetries = 3;
|
|
|
-
|
|
|
- for (int retryCount = 0; retryCount < maxRetries; retryCount++) {
|
|
|
- try {
|
|
|
- kafkaProducer.sendMessage(CallbackMessageType.GOODS_SYNC, message);
|
|
|
- return true;
|
|
|
- } catch (Exception e) {
|
|
|
- log.warn("syncToQiyun: Kafka发送失败,第{}次重试", retryCount + 1);
|
|
|
- if (retryCount == maxRetries - 1) {
|
|
|
- log.error("syncToQiyun: Kafka发送失败,已达到最大重试次数3次,消息内容: {}", message, e);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result updateOrderLogistic(String orderSn) {
|
|
|
-
|
|
|
- Result tokenResult = fetchAndCacheToken();
|
|
|
- if (!tokenResult.isSuccess()) {
|
|
|
- return tokenResult;
|
|
|
- }
|
|
|
- String token = (String) tokenResult.getBody().get("token");
|
|
|
-
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("order_sn", orderSn);
|
|
|
-
|
|
|
-
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("x-token", token);
|
|
|
- String resp = HttpUtil.restTemplatePost(prefixUrl + "/supplyapi/app/order/Logistic", params, headers);
|
|
|
-
|
|
|
-
|
|
|
- JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
- if (respJson.getIntValue("code") != 0) {
|
|
|
- return Result.fail(respJson.getString("msg"));
|
|
|
- }
|
|
|
- //获取物流信息
|
|
|
- JSONArray array = respJson.getJSONArray("data");
|
|
|
- //获取物流中的物流编号+物流编码
|
|
|
-
|
|
|
- for (int i = 0; i < array.size(); i++) {
|
|
|
- //物流编号
|
|
|
- String expressNo = array.getJSONObject(i).getString("express_no");
|
|
|
- //物流编码
|
|
|
- String companyCode = array.getJSONObject(i).getString("company_code");
|
|
|
- //todo 更新自研系统的物流
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return Result.success(respJson.getJSONArray("data"));
|
|
|
- }
|
|
|
-}
|