fix : added enum to describe invoice status and product availability

pull/6221/head
Gauthier LO 2024-01-10 11:57:59 +01:00
parent be558d5c9a
commit 0795f245c2
2 changed files with 42 additions and 16 deletions

View File

@ -486,7 +486,6 @@ public class InvoiceController {
log.info("User : {} is requesting uninvoiced orders for shops : [{}]", log.info("User : {} is requesting uninvoiced orders for shops : [{}]",
((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername(), ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername(),
shopIds); shopIds);
// list of orders and their status : <order, shipping status, purchase status>
// checking shipping data availability // checking shipping data availability
List<String> shopIdList = Arrays.asList(shopIds.split(",")); List<String> shopIdList = Arrays.asList(shopIds.split(","));
@ -508,8 +507,8 @@ public class InvoiceController {
//rename shop id by shop name to prevent it to leak in front //rename shop id by shop name to prevent it to leak in front
orderFront.setShopId(shops.get(orderFront.getShopId())); orderFront.setShopId(shops.get(orderFront.getShopId()));
// set default value of shipping and purchase availability // set default value of shipping and purchase availability
orderFront.setShippingAvailable("0"); orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Available.code);
orderFront.setPurchaseAvailable("0"); orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Available.code);
List<String> skuIds = entry.getValue().stream().map(PlatformOrderContent::getSkuId).distinct().collect(Collectors.toList()); List<String> skuIds = entry.getValue().stream().map(PlatformOrderContent::getSkuId).distinct().collect(Collectors.toList());
// finds the first sku that isn't in db // finds the first sku that isn't in db
List<Sku> skuIdsFound = skuService.listByIds(skuIds); List<Sku> skuIdsFound = skuService.listByIds(skuIds);
@ -519,8 +518,8 @@ public class InvoiceController {
else else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing one or more sku in db"); errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing one or more sku in db");
orderFront.setShippingAvailable("-1"); orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
orderFront.setPurchaseAvailable("-1"); orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
} }
if(entry.getKey().getShippingInvoiceNumber() == null) { if(entry.getKey().getShippingInvoiceNumber() == null) {
@ -530,7 +529,7 @@ public class InvoiceController {
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing logistic channel for order : " + entry.getKey().getPlatformOrderId()); errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing logistic channel for order : " + entry.getKey().getPlatformOrderId());
else else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing logistic channel"); errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing logistic channel");
orderFront.setShippingAvailable("-1"); orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
} }
// finds the first product with missing weight // finds the first product with missing weight
String missingWeightProductId = productService.searchFirstEmptyWeightProduct(skuIds); String missingWeightProductId = productService.searchFirstEmptyWeightProduct(skuIds);
@ -539,7 +538,7 @@ public class InvoiceController {
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing one or more weight for order : " + entry.getKey().getPlatformOrderId()); errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing one or more weight for order : " + entry.getKey().getPlatformOrderId());
else else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing weight"); errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing weight");
orderFront.setShippingAvailable("-1"); orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
} }
} }
if(entry.getKey().getPurchaseInvoiceNumber() == null) { if(entry.getKey().getPurchaseInvoiceNumber() == null) {
@ -550,32 +549,35 @@ public class InvoiceController {
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing one or more sku price for order : " + entry.getKey().getPlatformOrderId()); errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), "Error : Missing one or more sku price for order : " + entry.getKey().getPlatformOrderId());
else else
errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing one or more sku price"); errorMapToOrderId.put(entry.getKey().getPlatformOrderId(), errorMapToOrderId.get(entry.getKey().getPlatformOrderId()) + " and missing one or more sku price");
orderFront.setPurchaseAvailable("-1"); orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Unavailable.code);
} }
} }
// set purchase order status (-1 = unavailable, 0 = available, 1 = invoiced, 2 = paid) // set purchase order status (-1 = unavailable, 0 = available, 1 = invoiced, 2 = paid)
if(entry.getKey().getProductAvailable() == null) { if(entry.getKey().getProductAvailable() == null) {
orderFront.setProductAvailable("0"); orderFront.setProductAvailable(PlatformOrderFront.productStatus.Unavailable.code);
entry.getKey().setProductAvailable("0"); entry.getKey().setProductAvailable(PlatformOrderFront.productStatus.Unavailable.code);
} }
if(entry.getKey().getProductAvailable().equals("0") && entry.getKey().getVirtualProductAvailable().equals("1") && entry.getKey().getPurchaseInvoiceNumber() == null) if(entry.getKey().getProductAvailable().equals(PlatformOrderFront.productStatus.Unavailable.code)
orderFront.setProductAvailable("2"); && entry.getKey().getVirtualProductAvailable().equals(PlatformOrderFront.productStatus.Available.code)
&& entry.getKey().getPurchaseInvoiceNumber() == null
)
orderFront.setProductAvailable(PlatformOrderFront.productStatus.Ordered.code);
if(entry.getKey().getPurchaseInvoiceNumber() != null) { if(entry.getKey().getPurchaseInvoiceNumber() != null) {
PurchaseOrder purchase = purchaseOrderService.getPurchaseByInvoiceNumber(entry.getKey().getPurchaseInvoiceNumber()); PurchaseOrder purchase = purchaseOrderService.getPurchaseByInvoiceNumber(entry.getKey().getPurchaseInvoiceNumber());
if(purchase.getPaidAmount().compareTo(BigDecimal.ZERO) == 0) if(purchase.getPaidAmount().compareTo(BigDecimal.ZERO) == 0)
orderFront.setPurchaseAvailable("1");// invoiced orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Invoiced.code);// invoiced
else else
orderFront.setPurchaseAvailable("2");// paid orderFront.setPurchaseAvailable(PlatformOrderFront.invoiceStatus.Paid.code);// paid
} }
// set shipping order status (-1 = unavailable, 0 = available, 1 = invoiced, 2 = paid) // set shipping order status (-1 = unavailable, 0 = available, 1 = invoiced, 2 = paid)
if(entry.getKey().getShippingInvoiceNumber() != null) { if(entry.getKey().getShippingInvoiceNumber() != null) {
ShippingInvoice shippingInvoice = iShippingInvoiceService.getShippingInvoice(entry.getKey().getShippingInvoiceNumber()); ShippingInvoice shippingInvoice = iShippingInvoiceService.getShippingInvoice(entry.getKey().getShippingInvoiceNumber());
if(shippingInvoice.getPaidAmount().compareTo(BigDecimal.ZERO) == 0) { if(shippingInvoice.getPaidAmount().compareTo(BigDecimal.ZERO) == 0) {
orderFront.setShippingAvailable("1"); // invoiced orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Invoiced.code); // invoiced
} }
else { else {
orderFront.setShippingAvailable("2"); // paid orderFront.setShippingAvailable(PlatformOrderFront.invoiceStatus.Paid.code); // paid
} }
} }
orderFronts.add(orderFront); orderFronts.add(orderFront);

View File

@ -105,4 +105,28 @@ public class PlatformOrderFront {
@Excel(name = "可开采购票0=不可1=可)", width = 15) @Excel(name = "可开采购票0=不可1=可)", width = 15)
@ApiModelProperty(value = "可开采购票0=不可1=可)") @ApiModelProperty(value = "可开采购票0=不可1=可)")
private String purchaseAvailable; private String purchaseAvailable;
public enum invoiceStatus {
Unavailable("-1"),
Available("0"),
Invoiced("1"),
Paid("2");
public final String code;
invoiceStatus(String code) {
this.code = code;
}
}
public enum productStatus {
Unavailable("0"),
Available("1"),
Ordered("2");
public final String code;
productStatus(String code) {
this.code = code;
}
}
} }