mirror of https://github.com/jeecgboot/jeecg-boot
feat: clear logistic channel name
parent
f54660d001
commit
556820e0e2
|
@ -2,14 +2,14 @@ package org.jeecg.modules.business.domain.api.mabang.dochangeorder;
|
||||||
|
|
||||||
import org.jeecg.modules.business.domain.api.mabang.Request;
|
import org.jeecg.modules.business.domain.api.mabang.Request;
|
||||||
|
|
||||||
public class EditLogisticRequest extends Request {
|
public class ClearLogisticRequest extends Request {
|
||||||
public EditLogisticRequest(EditLogisticRequestBody body) {
|
public ClearLogisticRequest(ClearLogisticRequestBody body) {
|
||||||
super(body);
|
super(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChangeOrderResponse send() {
|
public ClearLogisticResponse send() {
|
||||||
String jsonString = rawSend().getBody();
|
String jsonString = rawSend().getBody();
|
||||||
return ChangeOrderResponse.parse(jsonString);
|
return ClearLogisticResponse.parse(jsonString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,28 @@
|
||||||
package org.jeecg.modules.business.domain.api.mabang.dochangeorder;
|
package org.jeecg.modules.business.domain.api.mabang.dochangeorder;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
import org.jeecg.modules.business.domain.api.mabang.RequestBody;
|
import org.jeecg.modules.business.domain.api.mabang.RequestBody;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class EditLogisticRequestBody implements RequestBody {
|
public class ClearLogisticRequestBody implements RequestBody {
|
||||||
|
|
||||||
|
|
||||||
private String platformOrderId;
|
private String platformOrderId;
|
||||||
private String logisticChannelName;
|
|
||||||
/**
|
|
||||||
* 1 : edit, 2: delete, 3: add
|
|
||||||
*/
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
public EditLogisticRequestBody(String platformOrderId, String logisticChannelName, int type) {
|
public ClearLogisticRequestBody(String platformOrderId) {
|
||||||
this.platformOrderId = platformOrderId;
|
this.platformOrderId = platformOrderId;
|
||||||
this.logisticChannelName = logisticChannelName;
|
|
||||||
this.type = type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String api() {
|
public String api() {
|
||||||
return "order-do-change-order";
|
return "order-do-order-logistics";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject parameters() {
|
public JSONObject parameters() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
putNonNull(json, "platformOrderId", platformOrderId);
|
putNonNull(json, "platformOrderId", platformOrderId);
|
||||||
putNonNull(json, "myLogisticsId", logisticChannelName);
|
putNonNull(json, "type", 1);
|
||||||
putNonNull(json, "type", type);
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,46 +4,20 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.Response;
|
import org.jeecg.modules.business.domain.api.mabang.Response;
|
||||||
|
|
||||||
public class ChangeOrderResponse extends Response {
|
public class ClearLogisticResponse extends Response {
|
||||||
private final String message;
|
|
||||||
/**
|
|
||||||
* Erp order number
|
|
||||||
*/
|
|
||||||
private final String orderId;
|
|
||||||
|
|
||||||
|
|
||||||
private ChangeOrderResponse(Code status, String message, String orderId) {
|
private ClearLogisticResponse(Code status) {
|
||||||
super(status);
|
super(status);
|
||||||
this.message = message;
|
|
||||||
this.orderId = orderId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChangeOrderResponse parse(String json) {
|
public static ClearLogisticResponse parse(String json) {
|
||||||
JSONObject jsonObject = JSON.parseObject(json);
|
JSONObject jsonObject = JSON.parseObject(json);
|
||||||
String code = jsonObject.getString("code");
|
String code = jsonObject.getString("code");
|
||||||
String message = jsonObject.getString("message");
|
|
||||||
if (code.equals("200")) {
|
if (code.equals("200")) {
|
||||||
JSONObject data = jsonObject.getJSONObject("data");
|
return new ClearLogisticResponse(Code.SUCCESS);
|
||||||
String orderId = data.getString("orderId");
|
|
||||||
return new ChangeOrderResponse(Code.SUCCESS, message, orderId);
|
|
||||||
} else {
|
} else {
|
||||||
return new ChangeOrderResponse(Code.ERROR, message, null);
|
return new ClearLogisticResponse(Code.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrderId() {
|
|
||||||
return orderId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "ChangeOrderResponse{" +
|
|
||||||
"message='" + message + '\'' +
|
|
||||||
", orderId='" + orderId + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderReq
|
||||||
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderRequestBody;
|
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderRequestBody;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderResponse;
|
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderResponse;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.getorderlist.*;
|
import org.jeecg.modules.business.domain.api.mabang.getorderlist.*;
|
||||||
|
import org.jeecg.modules.business.entity.PlatformOrder;
|
||||||
import org.jeecg.modules.business.service.IPlatformOrderService;
|
import org.jeecg.modules.business.service.IPlatformOrderService;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobDataMap;
|
import org.quartz.JobDataMap;
|
||||||
|
@ -87,7 +88,8 @@ public class AddPortraitTubeJob implements Job {
|
||||||
throw new RuntimeException("EndDateTime must be strictly greater than StartDateTime !");
|
throw new RuntimeException("EndDateTime must be strictly greater than StartDateTime !");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> platformOrderIds = platformOrderService.fetchUninvoicedOrdersForShops(startDateTime, endDateTime, shops);
|
List<PlatformOrder> platformOrders = platformOrderService.fetchUninvoicedOrdersForShops(startDateTime, endDateTime, shops);
|
||||||
|
List<String> platformOrderIds = platformOrders.stream().map(PlatformOrder::getPlatformOrderId).collect(Collectors.toList());
|
||||||
List<List<String>> platformOrderIdLists = Lists.partition(platformOrderIds, 10);
|
List<List<String>> platformOrderIdLists = Lists.partition(platformOrderIds, 10);
|
||||||
|
|
||||||
List<OrderListRequestBody> requests = new ArrayList<>();
|
List<OrderListRequestBody> requests = new ArrayList<>();
|
||||||
|
|
|
@ -5,7 +5,6 @@ import org.codehaus.jettison.json.JSONArray;
|
||||||
import org.codehaus.jettison.json.JSONException;
|
import org.codehaus.jettison.json.JSONException;
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.*;
|
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.*;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.getorderlist.Order;
|
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobDataMap;
|
import org.quartz.JobDataMap;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
|
|
|
@ -6,10 +6,9 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.codehaus.jettison.json.JSONArray;
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
import org.codehaus.jettison.json.JSONException;
|
import org.codehaus.jettison.json.JSONException;
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.ChangeOrderResponse;
|
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.*;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.RemoveSkuRequest;
|
|
||||||
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.RemoveSkuRequestBody;
|
|
||||||
import org.jeecg.modules.business.domain.api.mabang.getorderlist.*;
|
import org.jeecg.modules.business.domain.api.mabang.getorderlist.*;
|
||||||
|
import org.jeecg.modules.business.entity.PlatformOrder;
|
||||||
import org.jeecg.modules.business.service.IPlatformOrderService;
|
import org.jeecg.modules.business.service.IPlatformOrderService;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobDataMap;
|
import org.quartz.JobDataMap;
|
||||||
|
@ -81,7 +80,8 @@ public class RemoveVirtualProductJob implements Job {
|
||||||
throw new RuntimeException("EndDateTime must be strictly greater than StartDateTime !");
|
throw new RuntimeException("EndDateTime must be strictly greater than StartDateTime !");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> platformOrderIds = platformOrderService.fetchUninvoicedOrdersForShops(startDateTime, endDateTime, shops);
|
List<PlatformOrder> platformOrders = platformOrderService.fetchUninvoicedOrdersForShops(startDateTime, endDateTime, shops);
|
||||||
|
List<String> platformOrderIds = platformOrders.stream().map(PlatformOrder::getPlatformOrderId).collect(Collectors.toList());
|
||||||
List<List<String>> platformOrderIdLists = Lists.partition(platformOrderIds, 10);
|
List<List<String>> platformOrderIdLists = Lists.partition(platformOrderIds, 10);
|
||||||
|
|
||||||
List<OrderListRequestBody> requests = new ArrayList<>();
|
List<OrderListRequestBody> requests = new ArrayList<>();
|
||||||
|
@ -112,6 +112,7 @@ public class RemoveVirtualProductJob implements Job {
|
||||||
log.info("{}/{} mabang orders have been retrieved.", mabangOrders.size(), platformOrderIds.size());
|
log.info("{}/{} mabang orders have been retrieved.", mabangOrders.size(), platformOrderIds.size());
|
||||||
|
|
||||||
log.info("Constructing virtual SKU removal requests");
|
log.info("Constructing virtual SKU removal requests");
|
||||||
|
List<Order> ordersWithLogistic = new ArrayList<>();
|
||||||
List<RemoveSkuRequestBody> removeSkuRequests = new ArrayList<>();
|
List<RemoveSkuRequestBody> removeSkuRequests = new ArrayList<>();
|
||||||
Set<String> shopErpCodes = virtualSkusByShop.keySet();
|
Set<String> shopErpCodes = virtualSkusByShop.keySet();
|
||||||
for (Order mabangOrder : mabangOrders) {
|
for (Order mabangOrder : mabangOrders) {
|
||||||
|
@ -126,6 +127,9 @@ public class RemoveVirtualProductJob implements Job {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!virtualSkuToRemove.isEmpty()) {
|
if (!virtualSkuToRemove.isEmpty()) {
|
||||||
|
if(!mabangOrder.getLogisticChannelName().isEmpty()) {
|
||||||
|
ordersWithLogistic.add(mabangOrder);
|
||||||
|
}
|
||||||
RemoveSkuRequestBody removeSkuRequestBody = new RemoveSkuRequestBody(mabangOrder.getPlatformOrderId(),
|
RemoveSkuRequestBody removeSkuRequestBody = new RemoveSkuRequestBody(mabangOrder.getPlatformOrderId(),
|
||||||
virtualSkuToRemove);
|
virtualSkuToRemove);
|
||||||
removeSkuRequests.add(removeSkuRequestBody);
|
removeSkuRequests.add(removeSkuRequestBody);
|
||||||
|
@ -134,6 +138,19 @@ public class RemoveVirtualProductJob implements Job {
|
||||||
}
|
}
|
||||||
log.info("{} virtual SKU removal requests to be sent to MabangAPI", removeSkuRequests.size());
|
log.info("{} virtual SKU removal requests to be sent to MabangAPI", removeSkuRequests.size());
|
||||||
|
|
||||||
|
// First we delete the logistic channel names, otherwise we can't delete virtual skus
|
||||||
|
List<CompletableFuture<Boolean>> clearLogisticFutures = ordersWithLogistic.stream()
|
||||||
|
.map(orderWithLogistic -> CompletableFuture.supplyAsync(() -> {
|
||||||
|
ClearLogisticRequestBody body = new ClearLogisticRequestBody(orderWithLogistic.getPlatformOrderId());
|
||||||
|
ClearLogisticRequest request = new ClearLogisticRequest(body);
|
||||||
|
ClearLogisticResponse response = request.send();
|
||||||
|
return response.success();
|
||||||
|
}, executor))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<Boolean> logisticResults = clearLogisticFutures.stream().map(CompletableFuture::join).collect(Collectors.toList());
|
||||||
|
long logisticClearSuccessCount = logisticResults.stream().filter(b -> b).count();
|
||||||
|
log.info("{}/{} logistic channel names cleared successfully.", logisticClearSuccessCount, ordersWithLogistic.size());
|
||||||
|
|
||||||
List<CompletableFuture<Boolean>> removeSkuFutures = removeSkuRequests.stream()
|
List<CompletableFuture<Boolean>> removeSkuFutures = removeSkuRequests.stream()
|
||||||
.map(removeSkuRequestBody -> CompletableFuture.supplyAsync(() -> {
|
.map(removeSkuRequestBody -> CompletableFuture.supplyAsync(() -> {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
|
@ -161,7 +161,7 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
|
||||||
List<String> fetchBillCodesOfParcelsWithoutTrace(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
|
List<String> fetchBillCodesOfParcelsWithoutTrace(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
|
||||||
@Param("transporters") List<String> transporters);
|
@Param("transporters") List<String> transporters);
|
||||||
|
|
||||||
List<String> fetchUninvoicedOrdersForShops(@Param("startDateTime") LocalDateTime startDateTime,
|
List<PlatformOrder> fetchUninvoicedOrdersForShops(@Param("startDateTime") LocalDateTime startDateTime,
|
||||||
@Param("endDateTime") LocalDateTime endDateTime,
|
@Param("endDateTime") LocalDateTime endDateTime,
|
||||||
@Param("shops") List<String> shops);
|
@Param("shops") List<String> shops);
|
||||||
|
|
||||||
|
|
|
@ -404,8 +404,8 @@
|
||||||
AND internal_tracking_number IS NOT NULL;
|
AND internal_tracking_number IS NOT NULL;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="fetchUninvoicedOrdersForShops" resultType="java.lang.String">
|
<select id="fetchUninvoicedOrdersForShops" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
||||||
SELECT platform_order_id
|
SELECT platform_order_id, logistic_channel_name
|
||||||
FROM platform_order po join shop s ON po.shop_id = s.id
|
FROM platform_order po join shop s ON po.shop_id = s.id
|
||||||
WHERE erp_code IN
|
WHERE erp_code IN
|
||||||
<foreach
|
<foreach
|
||||||
|
|
|
@ -129,7 +129,7 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
|
||||||
|
|
||||||
List<String> fetchBillCodesOfParcelsWithoutTrace(Date startDate, Date endDate, List<String> transporters);
|
List<String> fetchBillCodesOfParcelsWithoutTrace(Date startDate, Date endDate, List<String> transporters);
|
||||||
|
|
||||||
List<String> fetchUninvoicedOrdersForShops(LocalDateTime startDate, LocalDateTime endDate, List<String> shops);
|
List<PlatformOrder> fetchUninvoicedOrdersForShops(LocalDateTime startDate, LocalDateTime endDate, List<String> shops);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch platformOrderId of shipped AND invoiced orders, from startDatetime to endDatetime, excluding orders from
|
* Fetch platformOrderId of shipped AND invoiced orders, from startDatetime to endDatetime, excluding orders from
|
||||||
|
|
|
@ -369,7 +369,7 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> fetchUninvoicedOrdersForShops(LocalDateTime startDate, LocalDateTime endDate, List<String> shops) {
|
public List<PlatformOrder> fetchUninvoicedOrdersForShops(LocalDateTime startDate, LocalDateTime endDate, List<String> shops) {
|
||||||
return platformOrderMap.fetchUninvoicedOrdersForShops(startDate, endDate, shops);
|
return platformOrderMap.fetchUninvoicedOrdersForShops(startDate, endDate, shops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,6 @@
|
||||||
<td style="padding:10px 0;"><b>Client :</b> ${invoiceEntity}</td>
|
<td style="padding:10px 0;"><b>Client :</b> ${invoiceEntity}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding:10px 0;"><b>Numéro de facture :</b> <a href="http://app.wia-sourcing.com/business/admin/shippingInvoice/Invoice?invoice=${invoiceNumber}"> ${invoiceNumber} </a></td>
|
<td style="padding:10px 0;"><b>Numéro de facture :</b> <a href="http://app.wia-sourcing.com/business/admin/invoice/Invoice?invoice=${invoiceNumber}"> ${invoiceNumber} </a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<#include "../components/footer.ftl">
|
<#include "../components/footer.ftl">
|
|
@ -12,6 +12,6 @@
|
||||||
<td style="padding:10px 0;"><b>Client :</b> ${invoiceEntity}</td>
|
<td style="padding:10px 0;"><b>Client :</b> ${invoiceEntity}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding:10px 0;"><b>Numéro de facture :</b> <a href="http://app.wia-sourcing.com/business/admin/shippingInvoice/Invoice?invoice=${invoiceNumber}"> ${invoiceNumber} </a></td>
|
<td style="padding:10px 0;"><b>Numéro de facture :</b> <a href="http://app.wia-sourcing.com/business/admin/invoice/Invoice?invoice=${invoiceNumber}"> ${invoiceNumber} </a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<#include "components/footer.ftl">
|
<#include "components/footer.ftl">
|
Loading…
Reference in New Issue