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;
|
||||
|
||||
public class EditLogisticRequest extends Request {
|
||||
public EditLogisticRequest(EditLogisticRequestBody body) {
|
||||
public class ClearLogisticRequest extends Request {
|
||||
public ClearLogisticRequest(ClearLogisticRequestBody body) {
|
||||
super(body);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeOrderResponse send() {
|
||||
public ClearLogisticResponse send() {
|
||||
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;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jeecg.modules.business.domain.api.mabang.RequestBody;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@Data
|
||||
public class EditLogisticRequestBody implements RequestBody {
|
||||
|
||||
public class ClearLogisticRequestBody implements RequestBody {
|
||||
|
||||
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.logisticChannelName = logisticChannelName;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String api() {
|
||||
return "order-do-change-order";
|
||||
return "order-do-order-logistics";
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject parameters() {
|
||||
JSONObject json = new JSONObject();
|
||||
putNonNull(json, "platformOrderId", platformOrderId);
|
||||
putNonNull(json, "myLogisticsId", logisticChannelName);
|
||||
putNonNull(json, "type", type);
|
||||
putNonNull(json, "type", 1);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,46 +4,20 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.modules.business.domain.api.mabang.Response;
|
||||
|
||||
public class ChangeOrderResponse extends Response {
|
||||
private final String message;
|
||||
/**
|
||||
* Erp order number
|
||||
*/
|
||||
private final String orderId;
|
||||
public class ClearLogisticResponse extends Response {
|
||||
|
||||
|
||||
private ChangeOrderResponse(Code status, String message, String orderId) {
|
||||
private ClearLogisticResponse(Code 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);
|
||||
String code = jsonObject.getString("code");
|
||||
String message = jsonObject.getString("message");
|
||||
if (code.equals("200")) {
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String orderId = data.getString("orderId");
|
||||
return new ChangeOrderResponse(Code.SUCCESS, message, orderId);
|
||||
return new ClearLogisticResponse(Code.SUCCESS);
|
||||
} 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.ChangeOrderResponse;
|
||||
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.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
|
@ -87,7 +88,8 @@ public class AddPortraitTubeJob implements Job {
|
|||
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<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.JSONObject;
|
||||
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.JobDataMap;
|
||||
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.JSONException;
|
||||
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.RemoveSkuRequest;
|
||||
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.RemoveSkuRequestBody;
|
||||
import org.jeecg.modules.business.domain.api.mabang.dochangeorder.*;
|
||||
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.quartz.Job;
|
||||
import org.quartz.JobDataMap;
|
||||
|
@ -81,7 +80,8 @@ public class RemoveVirtualProductJob implements Job {
|
|||
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<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("Constructing virtual SKU removal requests");
|
||||
List<Order> ordersWithLogistic = new ArrayList<>();
|
||||
List<RemoveSkuRequestBody> removeSkuRequests = new ArrayList<>();
|
||||
Set<String> shopErpCodes = virtualSkusByShop.keySet();
|
||||
for (Order mabangOrder : mabangOrders) {
|
||||
|
@ -126,6 +127,9 @@ public class RemoveVirtualProductJob implements Job {
|
|||
}
|
||||
}
|
||||
if (!virtualSkuToRemove.isEmpty()) {
|
||||
if(!mabangOrder.getLogisticChannelName().isEmpty()) {
|
||||
ordersWithLogistic.add(mabangOrder);
|
||||
}
|
||||
RemoveSkuRequestBody removeSkuRequestBody = new RemoveSkuRequestBody(mabangOrder.getPlatformOrderId(),
|
||||
virtualSkuToRemove);
|
||||
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());
|
||||
|
||||
// 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()
|
||||
.map(removeSkuRequestBody -> CompletableFuture.supplyAsync(() -> {
|
||||
boolean success = false;
|
||||
|
|
|
@ -161,7 +161,7 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
|
|||
List<String> fetchBillCodesOfParcelsWithoutTrace(@Param("startDate") Date startDate, @Param("endDate") Date endDate,
|
||||
@Param("transporters") List<String> transporters);
|
||||
|
||||
List<String> fetchUninvoicedOrdersForShops(@Param("startDateTime") LocalDateTime startDateTime,
|
||||
List<PlatformOrder> fetchUninvoicedOrdersForShops(@Param("startDateTime") LocalDateTime startDateTime,
|
||||
@Param("endDateTime") LocalDateTime endDateTime,
|
||||
@Param("shops") List<String> shops);
|
||||
|
||||
|
|
|
@ -404,8 +404,8 @@
|
|||
AND internal_tracking_number IS NOT NULL;
|
||||
</select>
|
||||
|
||||
<select id="fetchUninvoicedOrdersForShops" resultType="java.lang.String">
|
||||
SELECT platform_order_id
|
||||
<select id="fetchUninvoicedOrdersForShops" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
||||
SELECT platform_order_id, logistic_channel_name
|
||||
FROM platform_order po join shop s ON po.shop_id = s.id
|
||||
WHERE erp_code IN
|
||||
<foreach
|
||||
|
|
|
@ -129,7 +129,7 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
|
|||
|
||||
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
|
||||
|
|
|
@ -369,7 +369,7 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
|||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
<td style="padding:10px 0;"><b>Client :</b> ${invoiceEntity}</td>
|
||||
</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>
|
||||
<#include "../components/footer.ftl">
|
|
@ -12,6 +12,6 @@
|
|||
<td style="padding:10px 0;"><b>Client :</b> ${invoiceEntity}</td>
|
||||
</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>
|
||||
<#include "components/footer.ftl">
|
Loading…
Reference in New Issue