Merge pull request #20 from LQYBill/dev

Release 1.5.0
pull/6221/head
Qiuyi LI 2023-08-09 14:08:55 +02:00 committed by GitHub
commit 00914ac93e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 785 additions and 1230 deletions

76
db/util.sql Normal file
View File

@ -0,0 +1,76 @@
SELECT DISTINCT sku_id FROM platform_order_content WHERE sku_id not LIKE '1%';
UPDATE platform_order
SET fret_fee = NULL,
shipping_invoice_number = NULL
WHERE shipping_invoice_number IS NOT NULL;
UPDATE platform_order_content
SET shipping_fee = NULL,
service_fee = NULL,
vat = NULL
WHERE vat IS NOT NULL;
DELETE from platform_order_content WHERE sku_id is NULL;
SELECT @@character_set_database, @@collation_database;
SHOW VARIABLES LIKE 'collation%';
SHOW TABLE STATUS LIKE 'sen%';
ALTER DATABASE wia_app COLLATE utf8mb4_general_ci;
SELECT c.internal_code AS '',
s.erp_code AS SKU,
p.zh_name AS '',
p.weight AS '',
ROUND(calculate_shipping_fees(IF(sa.zh_name = '', '-', '-'), 'FR', '2021-06-24',
p.weight), 2) AS '',
get_registration_fees(IF(sa.zh_name = '', '-', '-'), 'FR', '2021-06-24',
p.weight) AS ''
FROM sku s
LEFT JOIN client_sku ON s.id = client_sku.sku_id
LEFT JOIN client c ON client_sku.client_id = c.id
JOIN product p ON p.id = s.product_id
JOIN sensitive_attribute sa ON p.sensitive_attribute_id = sa.id;
SELECT c.internal_code AS 'Client',
po.platform_order_id AS 'Order ID',
po.logistic_channel_name AS 'Logistic Channel',
po.platform_order_number AS 'Order Number',
po.order_time AS 'Order Time',
po.shipping_time AS 'Shipping Time',
po.country AS 'Country',
IF(s.erp_code IS NULL, poc.sku_id, s.erp_code) AS 'SKU',
poc.quantity AS 'Quantity',
po.fret_fee AS 'Fret Fee',
(SELECT SUM(poc.shipping_fee)
WHERE poc.platform_order_id = po.id) AS 'Shipping Fee',
poc.service_fee AS 'Service Fee',
po.status AS 'Status'
FROM platform_order po
JOIN platform_order_content poc ON po.id = poc.platform_order_id
LEFT JOIN shop ON po.shop_id = shop.id
LEFT JOIN client c ON shop.owner_id = c.id
LEFT JOIN sku s ON poc.sku_id = s.id
WHERE po.erp_status = 3
ORDER BY Client;
SELECT json_array(poc.shipping_fee)
from platform_order_content poc JOIN platform_order po ON po.id = poc.platform_order_id
WHERE poc.platform_order_id = po.id;
SELECT s.erp_code, count(DISTINCT po.id), sum(poc.quantity)
FROM platform_order po
JOIN platform_order_content poc ON po.id = poc.platform_order_id
JOIN shop s ON po.shop_id = s.id
WHERE shipping_invoice_number IS not NULL
AND po.erp_status = '3'
GROUP BY erp_code
ORDER BY erp_code;
SELECT s.erp_code, po.*
FROM platform_order po
JOIN platform_order_content poc ON po.id = poc.platform_order_id
JOIN shop s ON po.shop_id = s.id
WHERE shipping_invoice_number IS NULL
AND po.erp_status = '3' and (erp_code = 'EP5' OR erp_code ='EP6')
ORDER BY erp_code;

13
db/views/api_view.sql Normal file
View File

@ -0,0 +1,13 @@
CREATE OR REPLACE VIEW api_view AS
SELECT p.country, p.third_bill_code as trackingNumber,
(SELECT JSON_ARRAYAGG(
JSON_OBJECT(
'scanType', scan_type,
'scanTime', scan_time,
'description', IF(description_en IS NOT NULL, description_en, description)
))
FROM parcel_trace pt
WHERE p.id = pt.parcel_id
ORDER BY scan_time DESC
) AS traces
FROM parcel p;

View File

@ -0,0 +1,41 @@
CREATE FUNCTION calculate_shipping_fees(logistic_channel varchar(50), country varchar(2), shipping_date date,
weight int) RETURNS DOUBLE
BEGIN
DECLARE minimum_weight INT;
DECLARE minimum_weight_price double;
DECLARE cal_unit INT;
DECLARE cal_unit_price double;
DECLARE additional_cost double;
DECLARE shipping_fee double;
SELECT lcp.minimum_weight,
lcp.minimum_weight_price,
lcp.cal_unit,
lcp.cal_unit_price,
lcp.additional_cost
INTO minimum_weight,
minimum_weight_price,
cal_unit,
cal_unit_price,
additional_cost
FROM logistic_channel_price lcp
JOIN logistic_channel lc ON lc.id = lcp.channel_id
WHERE lc.zh_name = logistic_channel
AND weight_range_start <= weight
AND weight_range_end >= weight
AND effective_country = country
AND effective_date <= shipping_date
ORDER BY effective_date
DESC
LIMIT 1;
IF weight = 0 THEN
SET shipping_fee = 0;
ELSEIF weight < minimum_weight THEN
SET shipping_fee = minimum_weight_price;
ELSE
SET shipping_fee = ((weight - minimum_weight) / cal_unit) * cal_unit_price + minimum_weight_price;
END IF;
RETURN shipping_fee;
END;

View File

@ -0,0 +1,30 @@
CREATE OR REPLACE VIEW detail_de_facture AS
SELECT s.name AS 'Boutique',
po.platform_order_id AS 'N° de Mabang',
po.platform_order_number AS 'N° de commande',
po.tracking_number AS 'N° de suivi',
po.order_time AS 'Date de commande',
po.shipping_time AS 'Date d\'expédition',
po.recipient AS 'Nom de client',
po.country AS 'Pays',
po.postcode AS 'Code postal',
JSON_ARRAYAGG(sku.erp_code) AS 'SKU',
JSON_ARRAYAGG(p.en_name) AS 'Nom produits',
JSON_ARRAYAGG(poc.quantity) AS 'Quantité',
SUM(poc.purchase_fee) AS 'Frais d\'achat',
po.fret_fee AS 'Frais de FRET',
SUM(poc.shipping_fee) AS 'Frais de livraison',
po.order_service_fee + SUM(poc.service_fee) AS 'Frais de service',
po.picking_fee + SUM(poc.picking_fee) AS 'Frais de préparation',
po.packaging_material_fee AS 'Frais de matériel d\'emballage',
SUM(poc.vat) AS 'TVA',
po.shipping_invoice_number AS 'N° de facture'
FROM platform_order po
JOIN shop s ON po.shop_id = s.id
RIGHT JOIN platform_order_content poc ON po.id = poc.platform_order_id
JOIN sku ON poc.sku_id = sku.id
JOIN product p ON sku.product_id = p.id
WHERE shipping_invoice_number IS NOT NULL
AND poc.erp_status <> 5
GROUP BY po.id, s.name, po.order_time
ORDER BY s.name, po.order_time;

View File

@ -0,0 +1,51 @@
CREATE OR REPLACE VIEW full_logistic_expense_detail AS
SELECT led.tracking_number AS 'trackingNumber',
led.real_weight,
led.volumetric_weight,
led.charging_weight,
led.discount,
led.shipping_fee,
led.fuel_surcharge,
led.registration_fee,
led.second_delivery_fee,
led.vat,
led.vat_service_fee,
led.total_fee,
led.logistic_company_id,
led.additional_fee
FROM logistic_expense_detail led
WHERE tracking_number = logistic_internal_number
UNION
SELECT led.logistic_internal_number AS 'trackingNumber',
led.real_weight,
led.volumetric_weight,
led.charging_weight,
led.discount,
led.shipping_fee,
led.fuel_surcharge,
led.registration_fee,
led.second_delivery_fee,
led.vat,
led.vat_service_fee,
led.total_fee,
led.logistic_company_id,
led.additional_fee
FROM logistic_expense_detail led
WHERE tracking_number <> logistic_internal_number
UNION
SELECT led.tracking_number AS 'trackingNumber',
led.real_weight,
led.volumetric_weight,
led.charging_weight,
led.discount,
led.shipping_fee,
led.fuel_surcharge,
led.registration_fee,
led.second_delivery_fee,
led.vat,
led.vat_service_fee,
led.total_fee,
led.logistic_company_id,
led.additional_fee
FROM logistic_expense_detail led
WHERE tracking_number <> logistic_internal_number;

View File

@ -0,0 +1,24 @@
CREATE FUNCTION get_registration_fees(logistic_channel varchar(50), country varchar(2), shipping_date date,
weight int) RETURNS DOUBLE
BEGIN
DECLARE registration_fee double;
SELECT lcp.registration_fee
INTO registration_fee
FROM logistic_channel_price lcp
JOIN logistic_channel lc ON lc.id = lcp.channel_id
WHERE lc.zh_name = logistic_channel
AND weight_range_start <= weight
AND weight_range_end >= weight
AND effective_country = country
AND effective_date <= shipping_date
ORDER BY effective_date
DESC
LIMIT 1;
IF weight = 0 THEN
RETURN 0;
ELSE
RETURN registration_fee;
END IF;
END;

View File

@ -0,0 +1,25 @@
CREATE OR REPLACE VIEW inventory_record AS
SELECT sku.id AS id,
cs.client_id AS client_id,
sku.product_id AS product_id,
sku.erp_code AS erp_code,
sku.image_source AS image_source,
sku.available_amount AS available_amount,
p.moq AS moq,
rs.quantity AS red_quantity,
gs.quantity AS green_quantity,
sales_7.quantity AS sales_7,
sales_14.quantity AS sales_14,
sales_28.quantity AS sales_28,
sipo.quantity AS platform_order_quantity
FROM sku
JOIN product p ON sku.product_id = p.id
JOIN client_sku cs ON sku.id = cs.sku_id
LEFT JOIN sales_7 ON sku.id = sales_7.sku_id
LEFT JOIN sales_14 ON sku.id = sales_14.sku_id
LEFT JOIN sales_28 ON sku.id = sales_28.sku_id
LEFT JOIN red_sku rs ON sku.id = rs.sku_id
LEFT JOIN green_sku gs ON sku.id = gs.sku_id
LEFT JOIN sku_in_platform_order sipo ON sku.id = sipo.sku_id
ORDER BY platform_order_quantity DESC;

View File

@ -0,0 +1,16 @@
CREATE OR REPLACE VIEW logistic_fees_by_country AS
SELECT s.name AS '',
po.country AS '',
SUM(po.fret_fee) AS '',
SUM(led.registration_fee) AS '',
SUM(poc.shipping_fee) AS '',
SUM(led.total_fee) - SUM(registration_fee) AS '',
SUM(poc.vat) AS 'TVA',
SUM(led.vat) + SUM(led.vat_service_fee) AS 'TVA'
FROM platform_order po
JOIN shop s ON po.shop_id = s.id
RIGHT JOIN platform_order_content poc ON po.id = poc.platform_order_id
JOIN logistic_expense_detail led ON po.tracking_number = led.tracking_number
WHERE shipping_invoice_number IS NOT NULL
GROUP BY s.name, po.country
ORDER BY s.name

View File

@ -0,0 +1,29 @@
CREATE OR REPLACE VIEW logistic_profit_analyze AS
SELECT c.internal_code AS '',
shopErpCode AS '',
lc.name AS '',
logisticChannelName AS '线',
platformOrderId AS '',
platformOrderNumber AS '',
orderTime AS '',
shippingTime AS '',
poled.country AS '',
fretFee AS '',
registration_fee AS '',
(fretFee * 7.6 - registration_fee) AS '',
shippingFee AS '',
realShippingFee AS '',
(shippingFee * 7.6 - realShippingFee) AS '',
vatFee AS '',
(vat + vat_service_fee) AS '',
(vatFee * 7.6 - vat - vat_service_fee) AS '',
serviceFee AS '',
serviceFee * 7.6 AS '',
(fretFee * 7.6 - registration_fee + shippingFee * 7.6 -
realShippingFee + vat * 7.6 - vat - vat_service_fee) AS ''
FROM platform_order_logistic_expense_detail poled
JOIN shop s
ON shop_id = s.id
JOIN CLIENT c ON s.owner_id = c.id
JOIN logistic_company lc ON poled.logistic_company_id = lc.id;

View File

@ -0,0 +1,35 @@
CREATE OR REPLACE VIEW platform_order_logistic_expense_detail AS
SELECT s.erp_code AS 'shopErpCode',
po.tracking_number AS 'trackingNumber',
po.shop_id,
po.logistic_channel_name AS 'logisticChannelName',
po.platform_order_id AS 'platformOrderId',
po.platform_order_number AS 'platformOrderNumber',
po.order_time AS 'orderTime',
po.shipping_time AS 'shippingTime',
po.country,
po.fret_fee AS 'fretFee',
SUM(poc.shipping_fee) AS 'shippingFee',
SUM(poc.vat) AS 'vatFee',
po.order_service_fee + SUM(poc.service_fee) AS 'serviceFee',
po.shipping_invoice_number AS 'shippingInvoiceNumber',
fled.real_weight,
fled.volumetric_weight,
fled.charging_weight,
fled.discount,
fled.shipping_fee AS 'realShippingFee',
fled.fuel_surcharge,
fled.registration_fee,
fled.second_delivery_fee,
fled.vat,
fled.vat_service_fee,
fled.total_fee,
fled.logistic_company_id,
fled.additional_fee
FROM full_logistic_expense_detail fled
RIGHT JOIN platform_order po ON fled.trackingNumber = po.tracking_number
JOIN shop s ON po.shop_id = s.id
JOIN platform_order_content poc ON po.id = poc.platform_order_id
WHERE po.erp_status IN (3, 4)
GROUP BY po.id, s.erp_code
ORDER BY s.erp_code;

20
db/views/sales.sql Normal file
View File

@ -0,0 +1,20 @@
CREATE OR REPLACE VIEW sales_7 AS
SELECT poc.sku_id AS sku_id, SUM(poc.quantity) AS quantity
FROM platform_order_content poc
JOIN platform_order po ON poc.platform_order_id = po.id
WHERE po.order_time BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE()
GROUP BY poc.sku_id;
CREATE OR REPLACE VIEW sales_14 AS
SELECT poc.sku_id AS sku_id, SUM(poc.quantity) AS quantity
FROM platform_order_content poc
JOIN platform_order po ON poc.platform_order_id = po.id
WHERE po.order_time BETWEEN DATE_SUB(CURDATE(), INTERVAL 14 DAY) AND CURDATE()
GROUP BY poc.sku_id;
CREATE OR REPLACE VIEW sales_28 AS
SELECT poc.sku_id AS sku_id, SUM(poc.quantity) AS quantity
FROM platform_order_content poc
JOIN platform_order po ON poc.platform_order_id = po.id
WHERE po.order_time BETWEEN DATE_SUB(CURDATE(), INTERVAL 28 DAY) AND CURDATE()
GROUP BY poc.sku_id;

View File

@ -0,0 +1,42 @@
CREATE OR REPLACE VIEW sales_analyze AS
SELECT c.internal_code AS '',
s.name AS '',
s.erp_code AS '',
po.platform_order_number AS '',
po.country AS '',
po.order_time AS '',
CAST(po.order_time AS DATE) AS '',
CASE
WHEN
s2.erp_code IS NULL
THEN poc.sku_id
WHEN s2.erp_code IS NOT NULL
THEN s2.erp_code
END AS 'SKU',
p.zh_name AS '',
poc.quantity AS '',
p.weight AS '',
poc.purchase_fee AS '',
poc.service_fee AS '',
poc.shipping_fee AS '',
po.fret_fee AS '',
CASE
WHEN po.erp_status = '1'
THEN ''
WHEN po.erp_status = '2'
THEN ''
WHEN po.erp_status = '3'
THEN ''
WHEN po.erp_status = '4'
THEN ''
WHEN po.erp_status = '5'
THEN ''
END AS '',
po.logistic_channel_name AS ''
FROM platform_order_content poc
LEFT JOIN sku s2 ON poc.sku_id = s2.id
LEFT JOIN product p ON s2.product_id = p.id
JOIN platform_order po ON poc.platform_order_id = po.id
JOIN shop s ON po.shop_id = s.id
JOIN client c ON s.owner_id = c.id
ORDER BY order_time;

View File

@ -0,0 +1,16 @@
CREATE OR REPLACE VIEW sav_refund_with_detail
AS
SELECT sr.*,
po.platform_order_id AS mabang_id,
s.erp_code,
s.name as shop_name,
po.platform_order_number,
po.fret_fee,
SUM(poc.shipping_fee) AS shipping_fee,
SUM(poc.vat) AS vat,
po.order_service_fee + SUM(poc.service_fee) AS service_fee
FROM sav_refund sr
JOIN platform_order po ON sr.platform_order_id = po.id
JOIN platform_order_content poc ON po.id = poc.platform_order_id
JOIN shop s ON po.shop_id = s.id
GROUP BY po.id;

View File

@ -0,0 +1,25 @@
CREATE OR REPLACE VIEW sku_country_channel_choice AS
SELECT sku.id AS id,
cs.client_id AS client_id,
sku.product_id AS product_id,
sku.erp_code AS erp_code,
sku.image_source AS image_source,
sku.available_amount AS available_amount,
p.moq AS moq,
rs.quantity AS red_quantity,
gs.quantity AS green_quantity,
sales_7.quantity AS sales_7,
sales_14.quantity AS sales_14,
sales_28.quantity AS sales_28,
sipo.quantity AS platform_order_quantity
FROM sku
JOIN product p ON sku.product_id = p.id
JOIN client_sku cs ON sku.id = cs.sku_id
LEFT JOIN sales_7 ON sku.id = sales_7.sku_id
LEFT JOIN sales_14 ON sku.id = sales_14.sku_id
LEFT JOIN sales_28 ON sku.id = sales_28.sku_id
LEFT JOIN red_sku rs ON sku.id = rs.sku_id
LEFT JOIN green_sku gs ON sku.id = gs.sku_id
LEFT JOIN sku_in_platform_order sipo ON sku.id = sipo.sku_id
ORDER BY platform_order_quantity DESC;

View File

@ -0,0 +1,12 @@
CREATE OR REPLACE VIEW sku_current_price AS
SELECT id AS price_id,
sp.sku_id AS sku_id,
price AS price,
threshold AS threshold,
discounted_price AS discounted_price,
price_rmb AS price_rmb,
discounted_price_rmb AS discounted_price_rmb,
date AS date
FROM sku_price sp
INNER JOIN (SELECT sku_id, MAX(date) max_date FROM sku_price GROUP BY sku_id) sp2
ON sp.sku_id = sp2.sku_id AND sp.date = sp2.max_date

View File

@ -0,0 +1,5 @@
CREATE OR REPLACE VIEW sku_in_platform_order AS
SELECT poc.sku_id AS sku_id, SUM(poc.quantity) AS quantity
FROM platform_order_content poc join platform_order po ON poc.platform_order_id = po.id
WHERE po.status = 2
GROUP BY poc.sku_id;

View File

@ -0,0 +1,22 @@
CREATE OR REPLACE VIEW sku_price_promotion AS
SELECT s.id AS sku_id,
p.en_name AS name_en,
p.zh_name AS name_zh,
s.erp_code AS erp_code,
s.image_source AS image_source,
spr.promotion_id AS promotion_id,
spr.promo_milestone AS promo_milestone,
spr.quantity_purchased AS quantity_purchased,
spr.discount AS discount,
scp.price_id AS price_id,
scp.price AS price,
scp.threshold AS threshold,
scp.discounted_price AS discounted_price,
scp.price_rmb AS price_rmb,
scp.discounted_price_rmb AS discounted_price_rmb
FROM sku s
LEFT JOIN sku_promotion_relation spr ON s.id = spr.sku_id
LEFT JOIN sku_current_price scp ON s.id = scp.sku_id
JOIN product p ON s.product_id = p.id
LEFT JOIN sku_in_platform_order sipo ON s.id = sipo.sku_id
ORDER BY sipo.quantity DESC;

View File

@ -0,0 +1,7 @@
CREATE OR REPLACE VIEW sku_weight_discount_service_fees AS
SELECT s.id,
s.erp_code,
p.weight,
s.shipping_discount,
s.service_fee
FROM sku s JOIN product p ON p.id = s.product_id;

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,7 @@ import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.modules.business.vo.ProductsParam;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@ -260,4 +261,18 @@ public class ProductController {
return Result.OK("文件导入失败!");
}
@PostMapping(value="/editBatch")
public Result<?> editBatch(@RequestBody ProductsParam productsParam) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<Product> products = new ArrayList<>();
for(String id : productsParam.getIds()) {
Product product = new Product();
product.setId(id);
product.setWeight(productsParam.getWeight());
product.setUpdateBy(sysUser.getUsername());
products.add(product);
}
productService.updateWeightBatch(products);
return Result.ok("Updated all products");
}
}

View File

@ -55,6 +55,8 @@ public class InvoiceController {
@Autowired
private ISavRefundService iSavRefundService;
@Autowired
private ISavRefundWithDetailService savRefundWithDetailService;
@Autowired
private IExchangeRatesService iExchangeRatesService;
@Autowired
private IQuartzJobService quartzJobService;
@ -76,7 +78,7 @@ public class InvoiceController {
Set<String> skuIds = orderContents.stream().map(PlatformOrderContent::getSkuId).collect(Collectors.toSet());
List<String> skusWithoutPrice = platformOrderContentMap.searchSkuDetail(new ArrayList<>(skuIds))
.stream()
.filter(skuDetail -> skuDetail.getPrice().getPrice() == null)
.filter(skuDetail -> skuDetail.getPrice().getPrice() == null && skuDetail.getPrice().getPriceRmb() == null)
.map(SkuDetail::getErpCode)
.collect(Collectors.toList());
if (skusWithoutPrice.isEmpty()) {
@ -98,14 +100,19 @@ public class InvoiceController {
String warehouseString = String.join(",", warehouses);
QueryWrapper<PlatformOrder> queryWrapper = QueryGenerator.initQueryWrapper(platformOrder, req.getParameterMap());
LambdaQueryWrapper<PlatformOrder> lambdaQueryWrapper = queryWrapper.lambda();
if(type.equals("shipping"))
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, OrderStatus.Shipped.getCode());
else if(type.equals("pre-shipping"))
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, Arrays.asList(OrderStatus.Pending.getCode(), OrderStatus.Preparing.getCode()));
else if(type.equals("all"))
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, Arrays.asList(OrderStatus.Pending.getCode(), OrderStatus.Preparing.getCode(), OrderStatus.Shipped.getCode()));
else
return Result.error("Error 404 : page not found.");
switch (type) {
case "shipping":
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, OrderStatus.Shipped.getCode());
break;
case "pre-shipping":
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, Arrays.asList(OrderStatus.Pending.getCode(), OrderStatus.Preparing.getCode()));
break;
case "all":
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, Arrays.asList(OrderStatus.Pending.getCode(), OrderStatus.Preparing.getCode(), OrderStatus.Shipped.getCode()));
break;
default:
return Result.error("Error 404 : page not found.");
}
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
Page<PlatformOrder> page = new Page<>(pageNo, pageSize);
IPage<PlatformOrder> pageList;
@ -262,6 +269,7 @@ public class InvoiceController {
} else {
log.info("Specified shop IDs : " + param.shopIDs());
lambdaQueryWrapper.in(PlatformOrder::getShopId, param.shopIDs());
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
if(param.getErpStatuses() != null) {
log.info("Specified erpStatuses : " + param.getErpStatuses());
lambdaQueryWrapper.in(PlatformOrder::getErpStatus, param.getErpStatuses());
@ -294,6 +302,7 @@ public class InvoiceController {
} else {
log.info("Specified shop IDs : " + param.shopIDs());
lambdaQueryWrapper.in(PlatformOrder::getShopId, param.shopIDs());
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT id FROM platform_order po WHERE po.erp_status = '3' AND po.shipping_time between '" + param.getStart() + "' AND '" + param.getEnd() + "'" );
// on récupère les résultats de la requete
List<PlatformOrder> orderID = platformOrderMapper.selectList(lambdaQueryWrapper);
@ -324,8 +333,9 @@ public class InvoiceController {
@GetMapping(value = "/downloadInvoiceDetail")
public byte[] downloadInvoiceDetail(@RequestParam("invoiceNumber") String invoiceNumber, @RequestParam("invoiceEntity") String invoiceEntity) throws IOException {
List<FactureDetail> res = shippingInvoiceService.getInvoiceDetail(invoiceNumber);
return shippingInvoiceService.exportToExcel(res, invoiceNumber, invoiceEntity);
List<FactureDetail> factureDetails = shippingInvoiceService.getInvoiceDetail(invoiceNumber);
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceNumber);
return shippingInvoiceService.exportToExcel(factureDetails, refunds, invoiceNumber, invoiceEntity);
}
@GetMapping(value = "/breakdown/byShop")

View File

@ -42,6 +42,7 @@ public class CreateFulfillmentRequest extends ShopifyRequest {
UK_ROYAL_MAIL("https://www.royalmail.com/track-your-item#/tracking-results/%s", "Royal Mail", "(FJ002|WB788)[0-9]{6}GB"),
POST_NL("https://postnl.post/", "PostNL International Mail", "LS[0-9]{9}NL"),
COLI_COLI("https://www.colicoli.fr/trackings?id=%s", "Coli Coli", "CC[0-9]{14}[A-Z]*"),
LUXEMBOURG_POST("https://www.post.lu/particuliers/colis-courrier/track-and-trace#/search", "Luxembourg Post", "LL[0-9]{9}LU"),
;
private final String trackingUrl;

View File

@ -1,6 +1,6 @@
package org.jeecg.modules.business.domain.excel;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import lombok.Data;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -12,32 +12,35 @@ import java.nio.file.Path;
import java.util.Date;
/**
* Provide operation that manipulate Excel sheet driven by cursor.
* Provide operation that manipulates Excel sheet driven by cursor.
* The cursor's position is in the (0, 0) at the beginning.
*/
@Data
public class SheetManager {
private final Workbook workbook;
private final Sheet sheet;
private final Sheet detailSheet;
private int row;
private final Sheet savSheet;
private int col;
private Sheet currentSheet;
private int currentRow;
private int currentCol;
private int max_col;
private SheetManager(Workbook workbook, Sheet sheet) {
private SheetManager(Workbook workbook, Sheet detailSheet, Sheet savSheet) {
this.workbook = workbook;
this.sheet = sheet;
row = 0;
col = 0;
this.detailSheet = detailSheet;
this.savSheet = savSheet;
this.currentRow = 0;
this.currentCol = 0;
max_col = 10;
}
public Workbook getWorkbook() {
return workbook;
}
/**
* Create a manager for the first worksheet of an empty ".xlsx" Excel file.
* The created worksheet named "sheet1".
@ -45,47 +48,44 @@ public class SheetManager {
* @return the sheetManager instance.
*/
public static SheetManager createXLSX() {
return createXLSX("sheet1");
return createXLSX("Détails", "SAV");
}
/**
* Same as {@code createXLSX()}, with customer sheet name.
*
* @param name the customer sheet name
* @param detailSheetName Details sheet name
* @param savSheetName SAV sheet name
* @return the sheetManager object.
*/
public static SheetManager createXLSX(String name) {
public static SheetManager createXLSX(String detailSheetName, String savSheetName) {
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet(name);
return new SheetManager(workbook, sheet);
Sheet detailSheet = workbook.createSheet(detailSheetName);
Sheet savSheet = workbook.createSheet(savSheetName);
return new SheetManager(workbook, detailSheet, savSheet);
}
/**
* Create a sheet manager for a sheet of a ".xls" Excel workbook.
*
* @param path path of the workbook.
* @param sheetIndex index of the sheet, begin from 0
* @return the sheet manager object
* @throws IOException any error while opening the workbook.
*/
public static SheetManager readXLS(Path path, int sheetIndex) throws IOException {
FileInputStream fis = new FileInputStream(path.toFile());
Workbook workbook = new HSSFWorkbook(fis);
return new SheetManager(workbook, workbook.getSheetAt(sheetIndex));
public void startDetailsSheet() {
this.currentSheet = detailSheet;
}
public void startSavSheet() {
this.currentSheet = savSheet;
this.currentRow = 0;
this.currentCol = 0;
}
/**
* Same as {@code readXLS} but for ".xlsx" Excel workbook.
*
* @param path path of the workbook.
* @param sheetIndex index of the sheet, begin from 0
* @return the sheet manager object
* @throws IOException any error while opening the workbook.
*/
public static SheetManager readXLSX(Path path, int sheetIndex) throws IOException {
public static SheetManager readXLSX(Path path) throws IOException {
FileInputStream fis = new FileInputStream(path.toFile());
Workbook workbook = new XSSFWorkbook(fis);
return new SheetManager(workbook, workbook.getSheetAt(sheetIndex));
return new SheetManager(workbook, workbook.getSheetAt(0), workbook.getSheetAt(1));
}
/**
@ -96,12 +96,12 @@ public class SheetManager {
* @param col col index of the location
*/
public void go(int row, int col) {
this.row = row;
this.currentRow = row;
_moveCol(col);
}
public void moveRow(int row) {
this.row = row;
this.currentRow = row;
}
public void moveCol(int col) {
@ -109,31 +109,31 @@ public class SheetManager {
}
public int row() {
return row;
return currentRow;
}
public int col() {
return col;
return currentCol;
}
/**
* Move cursor to the bottom cell.
* Move the cursor to the bottom cell.
*/
public void nextRow() {
this.row += 1;
this.currentRow += 1;
}
/**
* Move cursor to the left cell.
* Move the cursor to the left cell.
*/
public void nextCol() {
_moveCol(this.col + 1);
_moveCol(this.currentCol + 1);
}
/**
* Write a value to the cell pointed by cursor.
*
* @param value the value to be wrote, if value is null then we will change the cell to a Blank cell.
* @param value the value to be written, if value is null then we will change the cell to a Blank cell.
*/
public void write(String value) {
cell().setCellValue(value);
@ -142,7 +142,7 @@ public class SheetManager {
/**
* Write a value to the cell pointed by cursor.
*
* @param value the value to be wrote, if value is null then we will change the cell to a Blank cell.
* @param value the value to be written, if value is null then we will change the cell to a Blank cell.
*/
public void write(int value) {
cell().setCellValue(value);
@ -151,7 +151,7 @@ public class SheetManager {
/**
* Write a value to the cell pointed by cursor.
*
* @param value the value to be wrote, if value is null then we will change the cell to a Blank cell.
* @param value the value to be written, if value is null then we will change the cell to a Blank cell.
*/
public void write(BigDecimal value) {
cell().setCellValue(value.doubleValue());
@ -160,7 +160,7 @@ public class SheetManager {
/**
* Write a value to the cell pointed by cursor.
*
* @param value the value to be wrote
* @param value the value to be written
*/
public void write(Date value) {
cell().setCellValue(value);
@ -202,7 +202,8 @@ public class SheetManager {
public void export(Path target) throws IOException {
/* adjust all cols' width before export */
for (int i = 0; i < max_col; i++) {
sheet.autoSizeColumn(i);
detailSheet.autoSizeColumn(i);
savSheet.autoSizeColumn(i);
}
FileOutputStream fos = new FileOutputStream(target.toFile());
workbook.write(fos);
@ -211,13 +212,13 @@ public class SheetManager {
private Cell cell() {
Row row = sheet.getRow(this.row);
Row row = currentSheet.getRow(this.currentRow);
if (row == null) {
row = sheet.createRow(this.row);
row = currentSheet.createRow(this.currentRow);
}
Cell cell = row.getCell(col);
Cell cell = row.getCell(currentCol);
if (cell == null) {
cell = row.createCell(col);
cell = row.createCell(currentCol);
}
return cell;
}
@ -226,7 +227,7 @@ public class SheetManager {
if (dst > max_col) {
max_col = dst + 5;
}
col = dst;
currentCol = dst;
}

View File

@ -1,11 +1,11 @@
package org.jeecg.modules.business.domain.shippingInvoice;
import org.jeecg.modules.business.domain.invoice.InvoiceStyleFactory;
import org.jeecg.modules.business.domain.invoice.Row;
import org.jeecg.modules.business.domain.purchase.invoice.PurchaseInvoiceEntry;
import org.jeecg.modules.business.entity.Client;
import org.jeecg.modules.business.entity.PlatformOrder;
import org.jeecg.modules.business.entity.PlatformOrderContent;
import org.jeecg.modules.business.entity.SavRefundWithDetail;
import org.jeecg.modules.business.vo.PromotionDetail;
import java.math.BigDecimal;
@ -22,11 +22,11 @@ public class CompleteInvoice extends ShippingInvoice {
private final List<PromotionDetail> promotions;
public CompleteInvoice(Client targetClient, String code,
String subject,
public CompleteInvoice(Client targetClient, String code, String subject,
Map<PlatformOrder, List<PlatformOrderContent>> ordersToContent,
List<PurchaseInvoiceEntry> purchaseInvoiceEntries, List<PromotionDetail> promotions, BigDecimal exchangeRate) {
super(targetClient, code, subject, ordersToContent, null, exchangeRate);
List<SavRefundWithDetail> savRefunds, List<PurchaseInvoiceEntry> purchaseInvoiceEntries,
List<PromotionDetail> promotions, BigDecimal exchangeRate) {
super(targetClient, code, subject, ordersToContent, savRefunds, exchangeRate);
this.purchaseInvoiceEntries = purchaseInvoiceEntries;
this.promotions = promotions;
}

View File

@ -109,17 +109,18 @@ public class ShippingInvoiceFactory {
* </ol>
*
* @param customerId the customer id
* @param ordersIds the list of order IDs
* @param orderIds the list of order IDs
* @return the generated invoice
* @throws UserException if package used by the invoice can not or find more than 1 logistic
* channel price, this exception will be thrown.
*/
@Transactional
public ShippingInvoice createShippingInvoice(String customerId, List<String> ordersIds, String type, String start, String end) throws UserException {
log.info("Creating an invoice with arguments:\n client ID: {}, order IDs: {}]", customerId, ordersIds);
public ShippingInvoice createShippingInvoice(String customerId, List<String> orderIds, String type, String start, String end) throws UserException {
log.info("Creating an invoice with arguments:\n client ID: {}, order IDs: {}]", customerId, orderIds);
// find orders and their contents of the invoice
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderData(ordersIds);
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderData(orderIds);
Set<PlatformOrder> platformOrders = uninvoicedOrderToContent.keySet();
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
List<String> shopIds = platformOrders.stream()
.map(PlatformOrder::getShopId)
.distinct()
@ -134,7 +135,7 @@ public class ShippingInvoiceFactory {
subject = String.format("Shipping fees, order time from %s to %s", start, end);
else
throw new UserException("Couldn't create shipping invoice of unknown type.");
return createInvoice(customerId, shopIds, uninvoicedOrderToContent, null, subject, true);
return createInvoice(customerId, shopIds, uninvoicedOrderToContent, savRefunds, subject, true);
}
/**
@ -152,18 +153,19 @@ public class ShippingInvoiceFactory {
*
* @param username current username
* @param customerId the customer id
* @param ordersIds the list of order IDs
* @param orderIds the list of order IDs
* @param shippingMethod "post" = postShipping, "pre" = preShipping, "all" = all shipping methods
* @return the generated invoice
* @throws UserException if package used by the invoice can not or find more than 1 logistic
* channel price, this exception will be thrown.
*/
@Transactional
public CompleteInvoice createCompleteShippingInvoice(String username, String customerId, List<String> ordersIds, String shippingMethod, String start, String end) throws UserException {
log.info("Creating a complete invoice for \n client ID: {}, order IDs: {}]", customerId, ordersIds);
public CompleteInvoice createCompleteShippingInvoice(String username, String customerId, List<String> orderIds, String shippingMethod, String start, String end) throws UserException {
log.info("Creating a complete invoice for \n client ID: {}, order IDs: {}]", customerId, orderIds);
// find orders and their contents of the invoice
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderData(ordersIds);
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderData(orderIds);
Set<PlatformOrder> platformOrders = uninvoicedOrderToContent.keySet();
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
List<String> shopIds = platformOrders.stream()
.map(PlatformOrder::getShopId)
.distinct()
@ -180,7 +182,7 @@ public class ShippingInvoiceFactory {
subject = String.format("Purchase and Shipping fees, order time from %s to %s", start, end);
else throw new UserException("Couldn't create complete invoice for unknown shipping method");
return createInvoice(username, customerId, shopIds, uninvoicedOrderToContent, subject);
return createInvoice(username, customerId, shopIds, uninvoicedOrderToContent, savRefunds, subject);
}
@ -200,6 +202,7 @@ public class ShippingInvoiceFactory {
* @param username Current username
* @param customerId Customer ID
* @param shopIds Shop IDs
* @param savRefunds List of SAV refunds
* @param subject Invoice subject
* @return the generated invoice
* @throws UserException if package used by the invoice can not or find more than 1 logistic
@ -208,7 +211,7 @@ public class ShippingInvoiceFactory {
@Transactional
public CompleteInvoice createInvoice(String username, String customerId, List<String> shopIds,
Map<PlatformOrder, List<PlatformOrderContent>> orderAndContent,
String subject) throws UserException {
List<SavRefundWithDetail> savRefunds, String subject) throws UserException {
Client client = clientMapper.selectById(customerId);
log.info("User {} is creating a complete invoice for customer {}", username, client.getInternalCode());
@ -243,10 +246,13 @@ public class ShippingInvoiceFactory {
List<PurchaseInvoiceEntry> purchaseOrderSkuList = purchaseOrderContentMapper.selectInvoiceDataByID(purchaseID);
List<PromotionDetail> promotionDetails = skuPromotionHistoryMapper.selectPromotionByPurchase(purchaseID);
if (savRefunds != null) {
updateSavRefundsInDb(savRefunds, invoiceCode);
}
updateOrdersAndContentsInDb(orderAndContent);
return new CompleteInvoice(client, invoiceCode, subject, orderAndContent,
return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds,
purchaseOrderSkuList, promotionDetails, eurToUsd);
}

View File

@ -8,7 +8,7 @@ import java.math.BigDecimal;
/**
* This class describe the relation among a sku identified by its id, its quantity,
* This class describes the relation among a sku identified by its id, its quantity,
* and its correspondent price and promotion.
*/
@Data
@ -19,6 +19,8 @@ public class OrderContentDetail {
private final Integer quantity;
private final BigDecimal exchangeRate;
/**
* Calculate the reduced amount by applying the promotion to the sku.
*
@ -35,7 +37,7 @@ public class OrderContentDetail {
* @return the total price (price * quantity)
*/
public BigDecimal totalPrice() {
BigDecimal unit = skuDetail.getPrice().getPrice(quantity);
BigDecimal unit = skuDetail.getPrice().getPrice(quantity, exchangeRate);
BigDecimal total = unit.multiply(new BigDecimal(quantity));
log.info("unit: {}", unit);
log.info("total: {}", total);
@ -43,7 +45,7 @@ public class OrderContentDetail {
}
public BigDecimal unitPrice(){
return skuDetail.getPrice().getPrice(quantity);
return skuDetail.getPrice().getPrice(quantity, exchangeRate);
}
public int promotionCount() {

View File

@ -21,7 +21,7 @@ import java.util.Date;
* @Description: 退
* @Author: jeecg-boot
* @Date: 2022-08-19
* @Version: V1.2
* @Version: V1.3
*/
@Data
@TableName("sav_refund_with_detail")
@ -116,10 +116,18 @@ public class SavRefundWithDetail implements Serializable {
*
*/
private String erpCode;
/**
*
*/
private String shopName;
/**
*
*/
private String platformOrderNumber;
/**
*
*/
private String mabangId;
/**
*
*/

View File

@ -13,13 +13,14 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
/**
* @Description: The price of a sku
* @Description: SKU
* @Author: jeecg-boot
* @Date: 2021-04-16
* @Version: V1.0
* @Date: 2023-05-10
* @Version: V1.1
*/
@ApiModel(value = "sku对象", description = "SKU表")
@Setter
@ -30,21 +31,36 @@ public class SkuPrice implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id in the DB
*
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
@Getter
private String id;
/**
*
*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**
*
*/
@JsonFormat(timezone = "GMT+2", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**
*
*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**
* SKU ID
*/
@Dict(dictTable = "sku", dicText = "erp_code", dicCode = "id")
@ApiModelProperty(value = "SKU ID")
@Getter
private String skuId;
/**
*
*/
@ -60,59 +76,57 @@ public class SkuPrice implements Serializable {
@ApiModelProperty(value = "优惠价起订量")
@Getter
private Integer threshold;
/**
* , maybe null from DB which stands for no discount price
*
*/
@Excel(name = "优惠价", width = 15)
@ApiModelProperty(value = "优惠价")
@Getter
private BigDecimal discountedPrice;
private java.math.BigDecimal discountedPrice;
/**
*
*/
@Excel(name = "生效日期", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+2", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "生效日期")
@Getter
private Date date;
/**创建人*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private Date createTime;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private Date updateTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
*
*/
@Excel(name = "人民币价格", width = 15)
@ApiModelProperty(value = "人民币价格")
@Getter
private java.math.BigDecimal priceRmb;
/**
*
*/
@Excel(name = "人民币优惠价", width = 15)
@ApiModelProperty(value = "人民币优惠价")
@Getter
private java.math.BigDecimal discountedPriceRmb;
/**
* The price of a sku depends on its quantity, Given a quantity here, return the correspondent price.
*
* @param quantity a quantity
* @param eurToRmb Exchange rate from EUR to RMB
* @return the price correspondent to the quantity
*/
public BigDecimal getPrice(int quantity) {
if (quantity >= threshold) {
return discountedPrice == null ? price : discountedPrice;
public BigDecimal getPrice(int quantity, BigDecimal eurToRmb) {
BigDecimal priceCandidate = price;
BigDecimal discountedPriceCandidate = discountedPrice == null ? price : discountedPrice;
if (priceRmb != null) {
priceCandidate = priceRmb.divide(eurToRmb, RoundingMode.HALF_UP);
discountedPriceCandidate = discountedPriceRmb == null ? priceCandidate : discountedPriceRmb.divide(eurToRmb, RoundingMode.HALF_UP);
}
return price;
if (quantity >= threshold) {
return discountedPriceCandidate;
}
return priceCandidate;
}
public String toString() {
return String.format("%s, %s[%d]", price, discountedPrice, threshold);
return String.format("%s, %s[%d], %s(RMB), %s[%d](RMB)", price, discountedPrice, threshold, priceRmb, discountedPriceRmb, threshold);
}
}

View File

@ -1,8 +1,11 @@
package org.jeecg.modules.business.mapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.business.entity.Product;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* @Description:
* @Author: jeecg-boot
@ -10,5 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @Version: V1.0
*/
public interface ProductMapper extends BaseMapper<Product> {
void updateWeightBatch(@Param("products") List<Product> product);
}

View File

@ -18,4 +18,5 @@ import java.util.List;
public interface SavRefundWithDetailMapper extends BaseMapper<SavRefundWithDetail> {
List<SavRefundWithDetail> findUnprocessedRefundsByClient(@Param("clientId") String clientId);
List<SavRefundWithDetail> fetchRefundsWhere(@Param("shop") String shop, @Param("orderID") String orderID, @Param("column") String column, @Param("order") String order);
List<SavRefundWithDetail> getRefundsByInvoiceNumber(@Param("invoiceNumber") String invoiceNumber);
}

View File

@ -96,6 +96,8 @@
<result property="threshold" column="threshold"/>
<result property="discountedPrice" column="discounted_price"/>
<result property="date" column="price_date"/>
<result property="priceRmb" column="price_rmb"/>
<result property="discountedPriceRmb" column="discounted_price_rmb"/>
</resultMap>
<resultMap id="promotionResultMap" type="org.jeecg.modules.business.entity.Promotion">

View File

@ -1,5 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.business.mapper.ProductMapper">
<update id="updateWeightBatch">
UPDATE product p
SET p.update_time = NOW(),
weight = case id
<foreach collection="products" separator=" " open="" close="" index="index" item="item">
when #{item.id} then #{item.weight}
</foreach>
end,
update_by = case id
<foreach collection="products" separator=" " open="" close="" index="index" item="item">
when #{item.id} then #{item.updateBy}
</foreach>
end
where id in
<foreach collection="products" separator="," open="(" close=")" index="index" item="item">
#{item.id}
</foreach>
</update>
</mapper>

View File

@ -8,6 +8,7 @@
JOIN platform_order po ON sr.platform_order_id = po.id
JOIN shop s ON po.shop_id = s.id
WHERE invoice_number IS NULL
AND sr.fret_fee IS NOT NULL
AND s.owner_id = #{clientId}
</select>
<select id="fetchRefundsWhere" resultType="org.jeecg.modules.business.entity.SavRefundWithDetail">
@ -19,4 +20,10 @@
AND po.platform_order_id LIKE #{orderID}
ORDER BY ${column} ${order};
</select>
<select id="getRefundsByInvoiceNumber" resultType="org.jeecg.modules.business.entity.SavRefundWithDetail">
SELECT *
FROM sav_refund_with_detail
WHERE invoice_number = #{invoiceNumber}
</select>
</mapper>

View File

@ -36,5 +36,6 @@ public interface IProductService extends IService<Product> {
*
*/
public void delBatchMain (Collection<? extends Serializable> idList);
public void updateWeightBatch (List<Product> productList);
}

View File

@ -14,4 +14,5 @@ import java.util.List;
public interface ISavRefundWithDetailService extends IService<SavRefundWithDetail> {
List<SavRefundWithDetail> findUnprocessedRefundsByClient(String clientId);
List<SavRefundWithDetail> fetchRefundsWhere(String shop, String orderID, String column, String order);
List<SavRefundWithDetail> getRefundsByInvoiceNumber(String invoiceNumber);
}

View File

@ -9,6 +9,7 @@ import org.jeecg.modules.business.domain.shippingInvoice.CompleteInvoice;
import org.jeecg.modules.business.domain.shippingInvoice.ShippingInvoice;
import org.jeecg.modules.business.domain.shippingInvoice.ShippingInvoiceFactory;
import org.jeecg.modules.business.entity.PlatformOrder;
import org.jeecg.modules.business.entity.SavRefundWithDetail;
import org.jeecg.modules.business.mapper.*;
import org.jeecg.modules.business.vo.*;
import org.jetbrains.annotations.NotNull;
@ -23,6 +24,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
@ -85,7 +87,7 @@ public class PlatformOrderShippingInvoiceService {
@Value("${jeecg.path.shippingInvoiceDetailDir}")
private String INVOICE_DETAIL_DIR;
private final static String[] titles = {
private final static String[] DETAILS_TITLES = {
"Boutique",
"N° de Mabang",
"N° de commande",
@ -107,6 +109,16 @@ public class PlatformOrderShippingInvoiceService {
"TVA",
"N° de facture"
};
private final static String[] SAV_TITLES = {
"Boutique",
"N° de Mabang",
"N° de commande",
"Date du remboursement",
"Montant d'achat remboursé",
"Montant de livraison remboursé",
"Montant total du remboursement",
"N° de facture"
};
public Period getValidPeriod(List<String> shopIDs) {
Date begin = platformOrderMapper.findEarliestUninvoicedPlatformOrder(shopIDs);
@ -318,9 +330,10 @@ public class PlatformOrderShippingInvoiceService {
return factureDetailMapper.selectList(queryWrapper);
}
public byte[] exportToExcel(List<FactureDetail> details, String invoiceNumber, String invoiceEntity) throws IOException {
public byte[] exportToExcel(List<FactureDetail> details, List<SavRefundWithDetail> refunds, String invoiceNumber, String invoiceEntity) throws IOException {
SheetManager sheetManager = SheetManager.createXLSX();
for (String title : titles) {
sheetManager.startDetailsSheet();
for (String title : DETAILS_TITLES) {
sheetManager.write(title);
sheetManager.nextCol();
}
@ -370,6 +383,37 @@ public class PlatformOrderShippingInvoiceService {
sheetManager.moveCol(0);
sheetManager.nextRow();
}
sheetManager.startSavSheet();
for (String title : SAV_TITLES) {
sheetManager.write(title);
sheetManager.nextCol();
}
sheetManager.moveCol(0);
sheetManager.nextRow();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (SavRefundWithDetail refund : refunds) {
sheetManager.write(refund.getShopName());
sheetManager.nextCol();
sheetManager.write(refund.getMabangId());
sheetManager.nextCol();
sheetManager.write(refund.getPlatformOrderNumber());
sheetManager.nextCol();
sheetManager.write(sdf.format(refund.getRefundDate()));
sheetManager.nextCol();
sheetManager.write(refund.getPurchaseRefundAmount());
sheetManager.nextCol();
sheetManager.write(refund.getShippingFee()
.add(refund.getFretFee())
.add(refund.getVat())
.add(refund.getServiceFee()));
sheetManager.nextCol();
sheetManager.write(refund.getTotalRefundAmount());
sheetManager.nextCol();
sheetManager.write(refund.getInvoiceNumber());
sheetManager.moveCol(0);
sheetManager.nextRow();
}
Path target = Paths.get(INVOICE_DETAIL_DIR, "Détail_calcul_de_facture_" + invoiceNumber + "_(" + invoiceEntity + ").xlsx");
int i = 2;

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.entity.*;
import org.jeecg.modules.business.mapper.ExchangeRatesMapper;
import org.jeecg.modules.business.mapper.PlatformOrderContentMapper;
import org.jeecg.modules.business.mapper.PlatformOrderMapper;
import org.jeecg.modules.business.service.IClientService;
@ -24,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
@ -48,14 +50,17 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
private final PlatformOrderContentMapper platformOrderContentMap;
private final IShippingFeesWaiverProductService shippingFeesWaiverProductService;
private final IClientService clientService;
private final ExchangeRatesMapper exchangeRatesMapper;
@Autowired
public PlatformOrderServiceImpl(PlatformOrderMapper platformOrderMap, PlatformOrderContentMapper platformOrderContentMap,
IShippingFeesWaiverProductService shippingFeesWaiverProductService, IClientService clientService) {
IShippingFeesWaiverProductService shippingFeesWaiverProductService, IClientService clientService,
ExchangeRatesMapper exchangeRatesMapper) {
this.platformOrderMap = platformOrderMap;
this.platformOrderContentMap = platformOrderContentMap;
this.shippingFeesWaiverProductService = shippingFeesWaiverProductService;
this.clientService = clientService;
this.exchangeRatesMapper = exchangeRatesMapper;
}
@Override
@ -217,6 +222,7 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
@Override
public List<OrderContentDetail> searchPurchaseOrderDetail(List<SkuQuantity> skuQuantities) {
BigDecimal eurToRmb = exchangeRatesMapper.getLatestExchangeRate("EUR", "RMB");
// convert list of (ID, quantity) to map between ID and quantity
Map<String, Integer> skuQuantity =
skuQuantities.stream()
@ -234,7 +240,8 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
.map(
skuDetail -> new OrderContentDetail(
skuDetail,
skuQuantity.get(skuDetail.getSkuId())
skuQuantity.get(skuDetail.getSkuId()),
eurToRmb
)
)
.collect(toList());

View File

@ -73,5 +73,10 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
productMapper.deleteById(id);
}
}
@Override
@Transactional
public void updateWeightBatch (List<Product> productList) {
productMapper.updateWeightBatch(productList);
}
}

View File

@ -31,4 +31,9 @@ public class SavRefundWithDetailServiceImpl extends ServiceImpl<SavRefundWithDet
public List<SavRefundWithDetail> fetchRefundsWhere(String shop, String orderID, String column, String order) {
return savRefundMapper.fetchRefundsWhere(shop, orderID, column, order);
}
@Override
public List<SavRefundWithDetail> getRefundsByInvoiceNumber(String invoiceNumber) {
return savRefundMapper.getRefundsByInvoiceNumber(invoiceNumber);
}
}

View File

@ -0,0 +1,16 @@
package org.jeecg.modules.business.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
public class ProductsParam {
private final List<String> ids;
private final int weight;
public ProductsParam(@JsonProperty("ids") List<String> ids, @JsonProperty("weight") int weight){
this.ids = ids;
this.weight = weight;
}
public List<String> getIds() { return ids; }
public int getWeight() { return weight; }
}

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>1.3.0</version>
<version>1.5.0</version>
<packaging>pom</packaging>
<name>WIA APP ${project.version} </name>