|
|
|
@ -0,0 +1,73 @@
|
|
|
|
|
package com.ms.api.spi.order;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.jinritemai.cloud.base.api.BaseRequest;
|
|
|
|
|
import com.jinritemai.cloud.base.api.BaseResponse;
|
|
|
|
|
import com.jinritemai.cloud.base.api.ExtensionService;
|
|
|
|
|
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
|
|
|
|
|
import com.ms.api.common.R;
|
|
|
|
|
import com.ms.api.common.Ret;
|
|
|
|
|
import com.ms.api.common.SPIBaseService;
|
|
|
|
|
import com.ms.api.dto.order.RsyncDdOrdersAndPurchaseOrdersRequestDTO;
|
|
|
|
|
import com.ms.api.service.OpOrderService;
|
|
|
|
|
import com.ms.api.tool.CommonTool;
|
|
|
|
|
import com.ms.api.tool.DsJsonRequestTemplate;
|
|
|
|
|
import com.ms.api.tool.SecurityTool;
|
|
|
|
|
import com.ms.dal.entity.OpOrder;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@ExtensionService("rsyncDdOrdersAndPurchaseOrders")
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class RsyncDdOrdersAndPurchaseOrdersService extends SPIBaseService implements ExtensionServiceHandler<RsyncDdOrdersAndPurchaseOrdersRequestDTO, Ret> {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private DsJsonRequestTemplate dsJsonRequestTemplate;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpOrderService opOrderService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse<Ret> handle(BaseRequest<RsyncDdOrdersAndPurchaseOrdersRequestDTO> req) {
|
|
|
|
|
initHandle(req);
|
|
|
|
|
|
|
|
|
|
String orderIdsStr = req.getData().getOrderIds();
|
|
|
|
|
String sourceOrderIdsStr = req.getData().getSourceOrderIds();
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(orderIdsStr)) {
|
|
|
|
|
List<String> orderIds = CommonTool.splitWithComma(orderIdsStr);
|
|
|
|
|
Map<String, OpOrder> orderIdAndOrderMap = opOrderService.getOpOrdersByOrderIds(orderIds);
|
|
|
|
|
if (!opOrderService.checkOrdersBelongShop(shopId, orderIdAndOrderMap.values())) {
|
|
|
|
|
return R.ok(Ret.fail("无法操作不属于本店铺的订单"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 请求DS,同步1688订单
|
|
|
|
|
if (!StringUtils.isEmpty(sourceOrderIdsStr)) {
|
|
|
|
|
List<String> sourceOrderIds = CommonTool.splitWithComma(sourceOrderIdsStr);
|
|
|
|
|
try {
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("platform", "ddMicroApp");
|
|
|
|
|
params.put("sourceOrderIds", sourceOrderIds);
|
|
|
|
|
String res = dsJsonRequestTemplate.execute("/order/rsyncPurchaseOrderBySourceOrderIds", params);
|
|
|
|
|
log.info(res);
|
|
|
|
|
Map retMap = JSON.parseObject(res, Map.class);
|
|
|
|
|
if (retMap.get("result").equals("fail")) {
|
|
|
|
|
log.error("同步1688订单失败");
|
|
|
|
|
};
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("同步1688订单失败,原因:" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// todo:
|
|
|
|
|
|
|
|
|
|
return R.ok(Ret.success());
|
|
|
|
|
}
|
|
|
|
|
}
|