mirror of https://github.com/jeecgboot/jeecg-boot
feat: dl inventory in invoice list page, fix purchase result format for front, default provider name for sku purchase
parent
7dfeee0b6f
commit
f7fe3f1820
|
@ -222,24 +222,23 @@ public class PurchaseOrderController {
|
|||
platformOrderService.removePurchaseInvoiceNumber(purchaseOrder.getInvoiceNumber(), purchaseOrder.getClientId());
|
||||
List<PlatformOrder> platformOrders = platformOrderService.selectByPlatformOrderIds(platformOrderIds);
|
||||
log.info("Platform orders found for attribution : {}", platformOrders.stream().map(PlatformOrder::getPlatformOrderId).collect(Collectors.toList()));
|
||||
Map<String, List<String>> platformOrderIdUpdateMap = new HashMap<>();
|
||||
Map<String, Responses> responsesMappedByReason = new HashMap<>();
|
||||
Responses platformOrderIdUpdateResponse = new Responses();
|
||||
if(!platformOrders.isEmpty()) {
|
||||
for(PlatformOrder po : platformOrders) {
|
||||
po.setPurchaseInvoiceNumber(purchaseOrder.getInvoiceNumber());
|
||||
platformOrderIds.remove(po.getPlatformOrderId());
|
||||
if(platformOrderIdUpdateMap.get("success") != null)
|
||||
platformOrderIdUpdateMap.get("success").add(po.getPlatformOrderId());
|
||||
else
|
||||
platformOrderIdUpdateMap.put("success", new ArrayList<>(Collections.singletonList(po.getPlatformOrderId())));
|
||||
platformOrderIdUpdateResponse.addSuccess(po.getPlatformOrderId());
|
||||
}
|
||||
platformOrderService.updateBatchById(platformOrders);
|
||||
}
|
||||
if(!platformOrderIds.isEmpty()) {
|
||||
log.error("Platform orders not found: {}", platformOrderIds);
|
||||
platformOrderIdUpdateMap.put("fail", platformOrderIds);
|
||||
platformOrderIdUpdateResponse.getFailures().addAll(platformOrderIds);
|
||||
}
|
||||
purchaseOrderService.updateById(purchaseOrder);
|
||||
return Result.OK("sys.api.entryEditSuccess", platformOrderIdUpdateMap);
|
||||
responsesMappedByReason.put("Platform Order IDs Update / 平台订单号码更新 : " + purchaseOrder.getInvoiceNumber(), platformOrderIdUpdateResponse);
|
||||
return Result.OK("sys.api.entryEditSuccess", responsesMappedByReason);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -647,12 +647,31 @@ public class InvoiceController {
|
|||
String period = startDate + "-" + endDate;
|
||||
return shippingInvoiceService.exportToExcel(invoiceDetails, Collections.emptyList(), Collections.emptyList(), period, client.getInvoiceEntity(), client.getInternalCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Only downloads the inventory of skus that are in the invoice
|
||||
* Whereas downloadInventory downloads the inventory of a list of skus for the client
|
||||
* @param invoiceCode
|
||||
* @param internalCode
|
||||
* @param invoiceEntity
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@GetMapping(value = "/downloadInvoiceInventory")
|
||||
public byte[] downloadInvoiceInventory(@RequestParam("invoiceCode") String invoiceCode, @RequestParam("internalCode") String internalCode, @RequestParam("invoiceEntity") String invoiceEntity) throws IOException {
|
||||
InvoiceMetaData metaData = new InvoiceMetaData("", invoiceCode, internalCode, invoiceEntity, "");
|
||||
List<SkuOrderPage> skuOrderPages = skuService.getInventoryByInvoiceNumber(metaData.getInvoiceCode());
|
||||
return shippingInvoiceService.exportPurchaseInventoryToExcel(skuOrderPages, metaData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads the inventory of skus for the client
|
||||
* @param invoiceCode
|
||||
* @param internalCode
|
||||
* @param invoiceEntity
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@GetMapping(value = "/downloadInventory")
|
||||
public byte[] downloadInventory(@RequestParam("invoiceCode") String invoiceCode, @RequestParam("internalCode") String internalCode, @RequestParam("invoiceEntity") String invoiceEntity) throws IOException {
|
||||
InvoiceMetaData metaData = new InvoiceMetaData("", invoiceCode, internalCode, invoiceEntity, "");
|
||||
|
|
|
@ -8,19 +8,23 @@ import java.util.function.Function;
|
|||
|
||||
public class AddPurchaseOrderRequestBody implements RequestBody {
|
||||
private String providerName;
|
||||
private String employeeName;
|
||||
private String content;
|
||||
private List<SkuStockData> stockData;
|
||||
private final String employeeName;
|
||||
private final String content;
|
||||
private final List<SkuStockData> stockData;
|
||||
|
||||
private final static String DEFAULT_WAREHOUSE_NAME = "SZBA宝安仓";
|
||||
private final static String TEMPORARY_PROVIDER_NAME = "临时供货商";
|
||||
|
||||
public AddPurchaseOrderRequestBody(String employeeName, String providerName, String content, List<SkuStockData> stockData) {
|
||||
this.stockData = stockData;
|
||||
this.providerName = providerName;
|
||||
setProviderName(providerName);
|
||||
this.employeeName = employeeName;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setProviderName(String providerName) {
|
||||
this.providerName = providerName == null || providerName.isEmpty() ? TEMPORARY_PROVIDER_NAME : providerName;
|
||||
}
|
||||
@Override
|
||||
public String api() {
|
||||
return "pur-do-add-purchase";
|
||||
|
|
|
@ -85,6 +85,8 @@ public class PlatformOrderShippingInvoiceService {
|
|||
@Autowired
|
||||
private IShopService shopService;
|
||||
@Autowired
|
||||
private ISkuService skuService;
|
||||
@Autowired
|
||||
CountryService countryService;
|
||||
@Autowired
|
||||
IPurchaseOrderService purchaseOrderService;
|
||||
|
@ -791,6 +793,10 @@ public class PlatformOrderShippingInvoiceService {
|
|||
log.info("File asked is of type invoice detail");
|
||||
pathList = getPath(INVOICE_DETAIL_DIR, invoiceNumber);
|
||||
}
|
||||
if(filetype.equals("inventory")) {
|
||||
log.info("File asked is of type inventory");
|
||||
pathList = getPath(PURCHASE_INVENTORY_DIR, invoiceNumber);
|
||||
}
|
||||
if(pathList.isEmpty()) {
|
||||
log.error("NO INVOICE FILE FOUND : " + invoiceNumber);
|
||||
log.info("Generating a new invoice file ...");
|
||||
|
@ -803,6 +809,11 @@ public class PlatformOrderShippingInvoiceService {
|
|||
List<ExtraFeeResult> extraFees = extraFeeService.findByInvoiceNumber(invoiceNumber);
|
||||
exportToExcel(details, refunds, extraFees, invoiceNumber, client.getInvoiceEntity(), client.getInternalCode());
|
||||
pathList = getPath(INVOICE_DETAIL_DIR, invoiceNumber);
|
||||
} else if (filetype.equals("inventory")) {
|
||||
InvoiceMetaData metaData = purchaseOrderService.getMetaDataFromInvoiceNumbers(invoiceNumber);
|
||||
List<SkuOrderPage> skuOrderPages = skuService.getInventoryByInvoiceNumber(metaData.getInvoiceCode());
|
||||
exportPurchaseInventoryToExcel(skuOrderPages, metaData);
|
||||
pathList = getPath(PURCHASE_INVENTORY_DIR, invoiceNumber);
|
||||
}
|
||||
else {
|
||||
return "ERROR";
|
||||
|
|
Loading…
Reference in New Issue