mirror of https://github.com/jeecgboot/jeecg-boot
feat : extra fees, fixes
parent
e528d9f947
commit
f8e66e6208
|
@ -12,7 +12,9 @@ import org.jeecg.common.config.TenantContext;
|
|||
import org.jeecg.common.constant.TenantConstant;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.base.event.SkuDeclaredValueModifiedEvent;
|
||||
import org.jeecg.modules.base.event.SkuModifiedEvent;
|
||||
import org.jeecg.modules.base.event.SkuPriceModifiedEvent;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -37,6 +39,9 @@ public class MybatisInterceptor implements Interceptor {
|
|||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
private static final String INSERT_SUCCESS_MSG = "添加成功!";
|
||||
private static final String UPDATE_SUCCESS_MSG = "修改成功!";
|
||||
|
||||
@Override
|
||||
public Object intercept(Invocation invocation) throws Throwable {
|
||||
MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
|
||||
|
@ -181,15 +186,35 @@ public class MybatisInterceptor implements Interceptor {
|
|||
String operationStatus = dto.getLogContent().split(",")[2];
|
||||
String requestParam = dto.getRequestParam();
|
||||
if(table.equals("sku")) {
|
||||
if(operationStatus.equals("添加成功!")) {
|
||||
if(operationStatus.equals(INSERT_SUCCESS_MSG)) {
|
||||
String id = extractIdFromRequestParam(requestParam);
|
||||
eventPublisher.publishEvent(new SkuModifiedEvent(this, id, "INSERT"));
|
||||
}
|
||||
if(operationStatus.equals("修改成功!")) {
|
||||
if(operationStatus.equals(UPDATE_SUCCESS_MSG)) {
|
||||
String id = extractIdFromRequestParam(requestParam);
|
||||
eventPublisher.publishEvent(new SkuModifiedEvent(this, id, "UPDATE"));
|
||||
}
|
||||
}
|
||||
if(table.equals("sku_price")) {
|
||||
if(operationStatus.equals(INSERT_SUCCESS_MSG)) {
|
||||
String id = extractIdFromRequestParam(requestParam);
|
||||
eventPublisher.publishEvent(new SkuPriceModifiedEvent(this, id, "INSERT"));
|
||||
}
|
||||
if(operationStatus.equals(UPDATE_SUCCESS_MSG)) {
|
||||
String id = extractIdFromRequestParam(requestParam);
|
||||
eventPublisher.publishEvent(new SkuPriceModifiedEvent(this, id, "UPDATE"));
|
||||
}
|
||||
}
|
||||
if(table.equals("sku_declared_value")) {
|
||||
if(operationStatus.equals(INSERT_SUCCESS_MSG)) {
|
||||
String id = extractIdFromRequestParam(requestParam);
|
||||
eventPublisher.publishEvent(new SkuDeclaredValueModifiedEvent(this, id, "INSERT"));
|
||||
}
|
||||
if(operationStatus.equals(UPDATE_SUCCESS_MSG)) {
|
||||
String id = extractIdFromRequestParam(requestParam);
|
||||
eventPublisher.publishEvent(new SkuDeclaredValueModifiedEvent(this, id, "UPDATE"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.jeecg.modules.base.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
@Getter
|
||||
public class SkuWeightModifiedEvent extends ApplicationEvent {
|
||||
private final String id;
|
||||
private final String operation; // "INSERT", "UPDATE", "DELETE"
|
||||
|
||||
public SkuWeightModifiedEvent(Object source, String id, String operation) {
|
||||
super(source);
|
||||
this.id = id;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
}
|
|
@ -102,30 +102,30 @@ public class ExtraFeeController extends JeecgController<ExtraFee, IExtraFeeServi
|
|||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param extraFees
|
||||
* @param extraFee
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "extra fee content-添加")
|
||||
@ApiOperation(value="extra fee content-添加", notes="extra fee content-添加")
|
||||
@RequiresPermissions("business:extra_fee:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody ExtraFee extraFees) {
|
||||
extraFeeService.save(extraFees);
|
||||
public Result<String> add(@RequestBody ExtraFee extraFee) {
|
||||
extraFeeService.save(extraFee);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param extraFees
|
||||
* @param extraFee
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "extra fee content-编辑")
|
||||
@ApiOperation(value="extra fee content-编辑", notes="extra fee content-编辑")
|
||||
@RequiresPermissions("business:extra_fee:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody ExtraFee extraFees) {
|
||||
extraFeeService.updateById(extraFees);
|
||||
public Result<String> edit(@RequestBody ExtraFee extraFee) {
|
||||
extraFeeService.updateById(extraFee);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
|
@ -137,11 +137,17 @@ public class ExtraFeeController extends JeecgController<ExtraFee, IExtraFeeServi
|
|||
*/
|
||||
@AutoLog(value = "extra fee content-通过id删除")
|
||||
@ApiOperation(value="extra fee content-通过id删除", notes="extra fee content-通过id删除")
|
||||
@RequiresPermissions("business:extra_fee:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
public Result<String> delete(@RequestParam(name="id") String id) {
|
||||
ExtraFee extraFee = extraFeeService.getById(id);
|
||||
if(extraFee == null) {
|
||||
return Result.error(404,"Fee not found");
|
||||
}
|
||||
if(extraFee.getInvoiceNumber() != null) {
|
||||
return Result.error(403, "Cannot delete invoiced fee");
|
||||
}
|
||||
extraFeeService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,23 +175,23 @@ public class ExtraFeeController extends JeecgController<ExtraFee, IExtraFeeServi
|
|||
@ApiOperation(value="extra fee content-通过id查询", notes="extra fee content-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<ExtraFee> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
ExtraFee extraFees = extraFeeService.getById(id);
|
||||
if(extraFees==null) {
|
||||
ExtraFee extraFee = extraFeeService.getById(id);
|
||||
if(extraFee==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(extraFees);
|
||||
return Result.OK(extraFee);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param extraFees
|
||||
* @param extraFee
|
||||
*/
|
||||
@RequiresPermissions("business:extra_fee:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, ExtraFee extraFees) {
|
||||
return super.exportXls(request, extraFees, ExtraFee.class, "extra fee content");
|
||||
public ModelAndView exportXls(HttpServletRequest request, ExtraFee extraFee) {
|
||||
return super.exportXls(request, extraFee, ExtraFee.class, "extra fee content");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.jeecg.common.system.query.QueryGenerator;
|
|||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.modules.business.entity.Sku;
|
||||
import org.jeecg.modules.business.entity.SkuWeight;
|
||||
import org.jeecg.modules.business.mongoService.SkuMongoService;
|
||||
import org.jeecg.modules.business.service.ISecurityService;
|
||||
import org.jeecg.modules.business.service.ISkuService;
|
||||
import org.jeecg.modules.business.service.ISkuWeightService;
|
||||
|
@ -25,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.modules.business.vo.SkuWeightParam;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -49,6 +51,8 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
|||
private ISkuWeightService skuWeightService;
|
||||
@Autowired
|
||||
private ISecurityService securityService;
|
||||
@Autowired
|
||||
private SkuMongoService skuMongoService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
|
@ -184,6 +188,7 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
|||
skuWeightService.save(skuWeight);
|
||||
return Result.OK("data.invoice.effectiveDate");
|
||||
}
|
||||
@Transactional
|
||||
@PostMapping(value = "/updateBatch")
|
||||
public Result<String> updateBatch(@RequestBody SkuWeightParam param) {
|
||||
boolean isEmployee = securityService.checkIsEmployee();
|
||||
|
@ -204,6 +209,7 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
|||
skuWeight.setSkuId(skuId);
|
||||
skuWeight.setWeight(param.getWeight());
|
||||
skuWeights.add(skuWeight);
|
||||
skuMongoService.upsertSkuWeight(skuWeight);
|
||||
}
|
||||
skuWeightService.saveBatch(skuWeights);
|
||||
return Result.OK("data.invoice.effectiveDate");
|
||||
|
|
|
@ -76,6 +76,8 @@ public class InvoiceController {
|
|||
@Autowired
|
||||
private ExchangeRatesMapper exchangeRatesMapper;
|
||||
@Autowired
|
||||
private IExtraFeeService extraFeeService;
|
||||
@Autowired
|
||||
private IShopService shopService;
|
||||
@Autowired
|
||||
private PlatformOrderShippingInvoiceService shippingInvoiceService;
|
||||
|
@ -736,7 +738,8 @@ public class InvoiceController {
|
|||
public byte[] downloadInvoiceDetail(@RequestParam("invoiceNumber") String invoiceNumber, @RequestParam("invoiceEntity") String invoiceEntity, @RequestParam("internalCode") String internalCode) throws IOException {
|
||||
List<FactureDetail> factureDetails = shippingInvoiceService.getInvoiceDetail(invoiceNumber);
|
||||
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceNumber);
|
||||
return shippingInvoiceService.exportToExcel(factureDetails, refunds, invoiceNumber, invoiceEntity, internalCode);
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findByInvoiceNumber(invoiceNumber);
|
||||
return shippingInvoiceService.exportToExcel(factureDetails, refunds, extraFees, invoiceNumber, invoiceEntity, internalCode);
|
||||
}
|
||||
@GetMapping(value = "/downloadInvoiceInventory")
|
||||
public byte[] downloadInvoiceInventory(@RequestParam("invoiceCode") String invoiceCode, @RequestParam("internalCode") String internalCode, @RequestParam("invoiceEntity") String invoiceEntity) throws IOException {
|
||||
|
@ -881,7 +884,8 @@ public class InvoiceController {
|
|||
filenameList.add(INVOICE_DIR + "//" + metaData.getFilename());
|
||||
List<FactureDetail> factureDetails = shippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode());
|
||||
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode());
|
||||
shippingInvoiceService.exportToExcel(factureDetails, refunds, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode());
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findByInvoiceNumber(metaData.getInvoiceCode());
|
||||
shippingInvoiceService.exportToExcel(factureDetails, refunds, extraFees, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode());
|
||||
filenameList.add(INVOICE_DETAIL_DIR + "//" + metaData.getInternalCode() + "_(" + metaData.getInvoiceEntity() + ")_" + metaData.getInvoiceCode() + "_Détail_calcul_de_facture.xlsx");
|
||||
}
|
||||
log.info("Generating detail files ...{}/{}", cpt++, invoiceList.size());
|
||||
|
@ -1088,12 +1092,29 @@ public class InvoiceController {
|
|||
List<PlatformOrder> platformOrderList = iShippingInvoiceService.getPlatformOrder(invoiceNumber);
|
||||
|
||||
List<BigDecimal> refundList = iSavRefundService.getRefundAmount(invoiceNumber);
|
||||
Map<String, Map.Entry<Integer, BigDecimal>> feeAndQtyPerCountry = new HashMap<>(); // it maps number of order and shipping fee per country : <France,<250, 50.30>>, <UK, <10, 2.15>>
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findByInvoiceNumber(invoiceNumber);
|
||||
Map<String, Fee> feeAndQtyPerCountry = new HashMap<>(); // it maps number of order and shipping fee per country : <France,<250, 50.30>>, <UK, <10, 2.15>>
|
||||
BigDecimal serviceFee = BigDecimal.ZERO; // po.order_service_fee + poc.service_fee
|
||||
BigDecimal pickingFee = BigDecimal.ZERO;
|
||||
BigDecimal packagingMatFee = BigDecimal.ZERO;
|
||||
BigDecimal vat = BigDecimal.ZERO;
|
||||
BigDecimal refund = BigDecimal.ZERO;
|
||||
Map<String, Fee> extraFeesMap = new HashMap<>(); // <"extra fee name", <quantity, amount>>, <"extra fee name", <quantity, amount>>, ...
|
||||
|
||||
if(extraFees != null) {
|
||||
for(ExtraFeeResult extraFee : extraFees) {
|
||||
if(!extraFeesMap.containsKey(extraFee.getEnName())) {
|
||||
Fee fee = new Fee(extraFee.getQuantity(), extraFee.getUnitPrice());
|
||||
extraFeesMap.put(extraFee.getEnName(), fee);
|
||||
}
|
||||
else {
|
||||
Integer existingQuantity = extraFeesMap.get(extraFee.getEnName()).getQuantity();
|
||||
Fee fee = new Fee(existingQuantity + extraFee.getQuantity(), extraFee.getUnitPrice());
|
||||
extraFeesMap.remove(extraFee.getEnName());
|
||||
extraFeesMap.put(extraFee.getEnName(), fee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// on parcours toutes les commandes pour récupérer : country, order_service_fee, fret_fee, picking_fee
|
||||
for(PlatformOrder p : platformOrderList) {
|
||||
|
@ -1115,15 +1136,18 @@ public class InvoiceController {
|
|||
// si oui on additionne la "qty" et "shipping fee"
|
||||
// sinon on ajoute juste à la map
|
||||
if(!feeAndQtyPerCountry.containsKey(country)) {
|
||||
feeAndQtyPerCountry.put(country, new AbstractMap.SimpleEntry<>(1, shippingFee));
|
||||
Fee fee = new Fee(1, shippingFee);
|
||||
feeAndQtyPerCountry.put(country, fee);
|
||||
}
|
||||
else {
|
||||
BigDecimal existingGlobalFee = feeAndQtyPerCountry.get(country).getValue();
|
||||
Integer existingOrderQuantity = feeAndQtyPerCountry.get(country).getKey();
|
||||
BigDecimal existingGlobalFee = feeAndQtyPerCountry.get(country).getUnitPrice();
|
||||
Integer existingOrderQuantity = feeAndQtyPerCountry.get(country).getQuantity();
|
||||
existingOrderQuantity ++;
|
||||
existingGlobalFee = existingGlobalFee.add(shippingFee);
|
||||
|
||||
Fee fee = new Fee(existingOrderQuantity, existingGlobalFee);
|
||||
feeAndQtyPerCountry.remove(country);
|
||||
feeAndQtyPerCountry.put(country, new AbstractMap.SimpleEntry<>(existingOrderQuantity, existingGlobalFee));
|
||||
feeAndQtyPerCountry.put(country, fee);
|
||||
}
|
||||
}
|
||||
// on fait la somme des remboursements
|
||||
|
@ -1149,6 +1173,7 @@ public class InvoiceController {
|
|||
invoiceDatas.setPickingFee(pickingFee);
|
||||
invoiceDatas.setPackagingMaterialFee(packagingMatFee);
|
||||
invoiceDatas.setFeeAndQtyPerCountry(feeAndQtyPerCountry);
|
||||
invoiceDatas.setExtraFees(extraFeesMap);
|
||||
|
||||
return Result.OK(invoiceDatas);
|
||||
}
|
||||
|
@ -1168,7 +1193,7 @@ public class InvoiceController {
|
|||
invoiceData.addAll(purchaseOrderContentMapper.selectInvoiceDataByID(order.getId()));
|
||||
}
|
||||
List<BigDecimal> refundList = iSavRefundService.getRefundAmount(invoiceNumber);
|
||||
Map<String, Map.Entry<Integer, BigDecimal>> feeAndQtyPerSku = new HashMap<>(); // it maps number of order and purchase fee per item : <France,<250, 50.30>>, <UK, <10, 2.15>>
|
||||
Map<String, Fee> feeAndQtyPerSku = new HashMap<>(); // it maps number of order and purchase fee per item : <France,<250, 50.30>>, <UK, <10, 2.15>>
|
||||
BigDecimal refund = BigDecimal.ZERO;
|
||||
|
||||
// on parcours toutes les commandes pour récupérer : country, purchaseFee
|
||||
|
@ -1180,15 +1205,17 @@ public class InvoiceController {
|
|||
// si oui on additionne la "qty" et "purchase fee"
|
||||
// sinon on ajoute juste à la map
|
||||
if(!feeAndQtyPerSku.containsKey(sku)) {
|
||||
feeAndQtyPerSku.put(sku, new AbstractMap.SimpleEntry<>(qty, purchaseFeePerSku));
|
||||
Fee fee = new Fee(qty, purchaseFeePerSku);
|
||||
feeAndQtyPerSku.put(sku, fee);
|
||||
}
|
||||
else {
|
||||
BigDecimal existingGlobalFee = feeAndQtyPerSku.get(sku).getValue();
|
||||
Integer existingOrderQuantity = feeAndQtyPerSku.get(sku).getKey();
|
||||
BigDecimal existingGlobalFee = feeAndQtyPerSku.get(sku).getUnitPrice();
|
||||
Integer existingOrderQuantity = feeAndQtyPerSku.get(sku).getQuantity();
|
||||
existingOrderQuantity += qty;
|
||||
existingGlobalFee = existingGlobalFee.add(purchaseFeePerSku);
|
||||
Fee fee = new Fee(existingOrderQuantity, existingGlobalFee);
|
||||
feeAndQtyPerSku.remove(sku);
|
||||
feeAndQtyPerSku.put(sku, new AbstractMap.SimpleEntry<>(existingOrderQuantity, existingGlobalFee));
|
||||
feeAndQtyPerSku.put(sku, fee);
|
||||
}
|
||||
}
|
||||
// on fait la somme des remboursements
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.modules.business.controller.admin.shippingInvoice;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -11,9 +12,9 @@ public class InvoiceDatas {
|
|||
@JSONField(name = "invoiceNumber")
|
||||
private String invoiceNumber;
|
||||
@JSONField(name = "feeAndQtyPerSku")
|
||||
private Map<String, Map.Entry<Integer, BigDecimal>> feeAndQtyPerSku;
|
||||
private Map<String, Fee> feeAndQtyPerSku;
|
||||
@JSONField(name = "feeAndQtyPerCountry")
|
||||
private Map<String, Map.Entry<Integer, BigDecimal>> feeAndQtyPerCountry;
|
||||
private Map<String, Fee> feeAndQtyPerCountry;
|
||||
@JSONField(name = "vat")
|
||||
private BigDecimal vat;
|
||||
@JSONField(name = "serviceFee")
|
||||
|
@ -30,5 +31,13 @@ public class InvoiceDatas {
|
|||
private BigDecimal finalAmountEur;
|
||||
@JSONField(name = "finalAmount")
|
||||
private BigDecimal finalAmount;
|
||||
@JSONField(name = "extraFees")
|
||||
private Map<String, Fee> extraFees;
|
||||
|
||||
}
|
||||
@Data
|
||||
@Builder
|
||||
class Fee {
|
||||
private Integer quantity;
|
||||
private BigDecimal unitPrice;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import java.util.stream.Collectors;
|
|||
@RequestMapping("/transaction")
|
||||
@Slf4j
|
||||
public class TransactionController {
|
||||
@Autowired
|
||||
private IExtraFeeService extraFeeService;
|
||||
@Autowired
|
||||
private EmailService emailService;
|
||||
@Autowired
|
||||
|
@ -107,6 +109,7 @@ public class TransactionController {
|
|||
List<String> shippingOrderIds = shippingOrders.stream().map(PlatformOrder::getId).collect(Collectors.toList());
|
||||
log.info("Estimating shipping fees for {}", shippingOrderIds.size());
|
||||
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
|
||||
extraFeeService,
|
||||
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
|
||||
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
|
||||
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env);
|
||||
|
|
|
@ -24,6 +24,8 @@ public class SheetManager {
|
|||
|
||||
private final Sheet savSheet;
|
||||
|
||||
private final Sheet extraFeeSheet;
|
||||
|
||||
private Sheet currentSheet;
|
||||
|
||||
private int currentRow;
|
||||
|
@ -32,10 +34,11 @@ public class SheetManager {
|
|||
|
||||
private int max_col;
|
||||
|
||||
private SheetManager(Workbook workbook, Sheet detailSheet, Sheet savSheet) {
|
||||
private SheetManager(Workbook workbook, Sheet detailSheet, Sheet savSheet, Sheet extraFeeSheet) {
|
||||
this.workbook = workbook;
|
||||
this.detailSheet = detailSheet;
|
||||
this.savSheet = savSheet;
|
||||
this.extraFeeSheet = extraFeeSheet;
|
||||
this.currentRow = 0;
|
||||
this.currentCol = 0;
|
||||
max_col = 10;
|
||||
|
@ -48,7 +51,7 @@ public class SheetManager {
|
|||
* @return the sheetManager instance.
|
||||
*/
|
||||
public static SheetManager createXLSX() {
|
||||
return createXLSX("Détails", "SAV");
|
||||
return createXLSX("Détails", "SAV", "Frais supplémentaires");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,11 +61,12 @@ public class SheetManager {
|
|||
* @param savSheetName SAV sheet name
|
||||
* @return the sheetManager object.
|
||||
*/
|
||||
public static SheetManager createXLSX(String detailSheetName, String savSheetName) {
|
||||
public static SheetManager createXLSX(String detailSheetName, String savSheetName, String extraFeeSheetName) {
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
Sheet detailSheet = workbook.createSheet(detailSheetName);
|
||||
Sheet savSheet = workbook.createSheet(savSheetName);
|
||||
return new SheetManager(workbook, detailSheet, savSheet);
|
||||
Sheet extraFeeSheet = workbook.createSheet(extraFeeSheetName);
|
||||
return new SheetManager(workbook, detailSheet, savSheet, extraFeeSheet);
|
||||
}
|
||||
|
||||
public void startDetailsSheet() {
|
||||
|
@ -75,6 +79,12 @@ public class SheetManager {
|
|||
this.currentCol = 0;
|
||||
}
|
||||
|
||||
public void startExtraFeeSheet() {
|
||||
this.currentSheet = extraFeeSheet;
|
||||
this.currentRow = 0;
|
||||
this.currentCol = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@code readXLS} but for ".xlsx" Excel workbook.
|
||||
*
|
||||
|
@ -85,7 +95,7 @@ public class SheetManager {
|
|||
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(0), workbook.getSheetAt(1));
|
||||
return new SheetManager(workbook, workbook.getSheetAt(0), workbook.getSheetAt(1), workbook.getSheetAt(2));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,6 +214,7 @@ public class SheetManager {
|
|||
for (int i = 0; i < max_col; i++) {
|
||||
detailSheet.autoSizeColumn(i);
|
||||
savSheet.autoSizeColumn(i);
|
||||
extraFeeSheet.autoSizeColumn(i);
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(target.toFile());
|
||||
workbook.write(fos);
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.jeecg.modules.business.entity.Client;
|
|||
import org.jeecg.modules.business.entity.SavRefundWithDetail;
|
||||
import org.jeecg.modules.business.service.*;
|
||||
import org.jeecg.modules.business.vo.BalanceData;
|
||||
import org.jeecg.modules.business.vo.ExtraFeeResult;
|
||||
import org.jeecg.modules.business.vo.FactureDetail;
|
||||
import org.jeecg.modules.business.vo.InvoiceMetaData;
|
||||
import org.quartz.Job;
|
||||
|
@ -36,6 +37,8 @@ public class ConfirmedClientsInvoicingJob implements Job {
|
|||
@Autowired
|
||||
private EmailService emailService;
|
||||
@Autowired
|
||||
private IExtraFeeService extraFeeService;
|
||||
@Autowired
|
||||
private PlatformOrderShippingInvoiceService platformOrderShippingInvoiceService;
|
||||
@Autowired
|
||||
private ISavRefundWithDetailService savRefundWithDetailService;
|
||||
|
@ -100,8 +103,9 @@ public class ConfirmedClientsInvoicingJob implements Job {
|
|||
invoicedMetaDataList.add(metaData);
|
||||
List<FactureDetail> factureDetails = platformOrderShippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode());
|
||||
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode());
|
||||
List<ExtraFeeResult> extraFess = extraFeeService.findByInvoiceNumber(metaData.getInvoiceCode());
|
||||
try {
|
||||
platformOrderShippingInvoiceService.exportToExcel(factureDetails, refunds, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode());
|
||||
platformOrderShippingInvoiceService.exportToExcel(factureDetails, refunds, extraFess, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.codehaus.jettison.json.JSONObject;
|
|||
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.*;
|
||||
import org.jeecg.modules.business.entity.Sku;
|
||||
import org.jeecg.modules.business.entity.SkuWeight;
|
||||
import org.jeecg.modules.business.model.SkuDocument;
|
||||
import org.jeecg.modules.business.mongoService.SkuMongoService;
|
||||
import org.jeecg.modules.business.service.EmailService;
|
||||
import org.jeecg.modules.business.service.ISkuListMabangService;
|
||||
|
@ -137,8 +138,12 @@ public class MabangSkuSyncJob implements Job {
|
|||
// Mongo sync after update transaction
|
||||
for(Sku sku : updatedSkuRemarkMap.keySet()) {
|
||||
skuMongoService.updateSkuFromMabangSync(sku);
|
||||
SkuWeight skuWeight = skuWeightService.getBySkuId(sku.getId());
|
||||
skuMongoService.updateSkuWeight(sku.getErpCode(), skuWeight.getWeight());
|
||||
// TODO : pb if we update weight locally and the effective date is not now, then we cannot update it on Mabang and thus creating a conflict.
|
||||
// SkuWeight skuWeight = skuWeightService.getBySkuId(sku.getId());
|
||||
// SkuDocument skuDocument = skuMongoService.findBySkuId(sku.getId());
|
||||
// if(skuDocument.getLatestSkuWeight().getWeight() != skuWeight.getWeight()) {
|
||||
// skuMongoService.upsertSkuWeight(skuWeight);
|
||||
// }
|
||||
}
|
||||
|
||||
Map<Sku, String> skusNeedTreatmentMap = new HashMap<>(updatedSkuRemarkMap);
|
||||
|
|
|
@ -21,8 +21,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A Job that retrieves all Sku from Mabang
|
||||
* if the sku is of status 3 (normal) and not in DB, then we insert it in DB
|
||||
* A Job that pairs sku with client based on sku suffix
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
|
|
|
@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.jeecg.modules.business.entity.*;
|
||||
import org.jeecg.modules.business.service.*;
|
||||
import org.jeecg.modules.business.vo.BalanceData;
|
||||
import org.jeecg.modules.business.vo.ExtraFeeResult;
|
||||
import org.jeecg.modules.business.vo.FactureDetail;
|
||||
import org.jeecg.modules.business.vo.InvoiceMetaData;
|
||||
import org.quartz.Job;
|
||||
|
@ -12,6 +13,7 @@ import org.quartz.JobExecutionContext;
|
|||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||
|
||||
|
@ -25,6 +27,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class VipInvoicingJob implements Job {
|
||||
@Autowired
|
||||
private IBalanceService balanceService;
|
||||
|
@ -33,6 +36,8 @@ public class VipInvoicingJob implements Job {
|
|||
@Autowired
|
||||
private EmailService emailService;
|
||||
@Autowired
|
||||
private IExtraFeeService extraFeeService;
|
||||
@Autowired
|
||||
private PlatformOrderShippingInvoiceService platformOrderShippingInvoiceService;
|
||||
@Autowired
|
||||
private ISavRefundWithDetailService savRefundWithDetailService;
|
||||
|
@ -76,8 +81,9 @@ public class VipInvoicingJob implements Job {
|
|||
invoicedMetaDataList.add(metaData);
|
||||
List<FactureDetail> factureDetails = platformOrderShippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode());
|
||||
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode());
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findByInvoiceNumber(metaData.getInvoiceCode());
|
||||
try {
|
||||
platformOrderShippingInvoiceService.exportToExcel(factureDetails, refunds, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode());
|
||||
platformOrderShippingInvoiceService.exportToExcel(factureDetails, refunds, extraFees, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ 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.ExtraFeeResult;
|
||||
import org.jeecg.modules.business.vo.PromotionDetail;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -24,9 +25,10 @@ public class CompleteInvoice extends ShippingInvoice {
|
|||
|
||||
public CompleteInvoice(Client targetClient, String code, String subject,
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> ordersToContent,
|
||||
List<SavRefundWithDetail> savRefunds, List<PurchaseInvoiceEntry> purchaseInvoiceEntries,
|
||||
List<SavRefundWithDetail> savRefunds, List<ExtraFeeResult> extraFees,
|
||||
List<PurchaseInvoiceEntry> purchaseInvoiceEntries,
|
||||
List<PromotionDetail> promotions, BigDecimal exchangeRate) {
|
||||
super(targetClient, code, subject, ordersToContent, savRefunds, exchangeRate);
|
||||
super(targetClient, code, subject, ordersToContent, savRefunds, extraFees,exchangeRate);
|
||||
this.purchaseInvoiceEntries = purchaseInvoiceEntries;
|
||||
this.promotions = promotions;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package org.jeecg.modules.business.domain.shippingInvoice;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.jeecg.modules.business.domain.invoice.AbstractInvoice;
|
||||
import org.jeecg.modules.business.domain.invoice.InvoiceStyleFactory;
|
||||
import org.jeecg.modules.business.domain.invoice.Row;
|
||||
import org.jeecg.modules.business.entity.*;
|
||||
import org.jeecg.modules.business.vo.ExtraFeeResult;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,16 +23,21 @@ public class ShippingInvoice extends AbstractInvoice<String, Object, Integer, Ob
|
|||
private final Map<PlatformOrder, List<PlatformOrderContent>> ordersToContent;
|
||||
|
||||
private final List<SavRefundWithDetail> savRefunds;
|
||||
|
||||
private final List<ExtraFeeResult> extraFees;
|
||||
@Getter
|
||||
@Setter
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
public ShippingInvoice(Client targetClient, String code,
|
||||
String subject,
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> ordersToContent,
|
||||
List<SavRefundWithDetail> savRefunds, BigDecimal exchangeRate) {
|
||||
List<SavRefundWithDetail> savRefunds,
|
||||
List<ExtraFeeResult> extraFees,
|
||||
BigDecimal exchangeRate) {
|
||||
super(targetClient, code, subject, exchangeRate);
|
||||
this.ordersToContent = ordersToContent;
|
||||
this.savRefunds = savRefunds;
|
||||
this.extraFees = extraFees;
|
||||
totalAmount = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
|
@ -144,19 +152,25 @@ public class ShippingInvoice extends AbstractInvoice<String, Object, Integer, Ob
|
|||
totalAmount = totalAmount.add(refundForOrder);
|
||||
}
|
||||
}
|
||||
if(extraFees != null) {
|
||||
for (ExtraFeeResult extraFee : extraFees) {
|
||||
BigDecimal extraFeeAmount = extraFee.getUnitPrice().multiply(BigDecimal.valueOf(extraFee.getQuantity()));
|
||||
Row<String, Object, Integer, Object, BigDecimal> extraFeeRow = new Row<>(
|
||||
extraFee.getDescription() == null ? extraFee.getEnName() : extraFee.getDescription(),
|
||||
extraFee.getUnitPrice(),
|
||||
extraFee.getQuantity(),
|
||||
null,
|
||||
extraFeeAmount
|
||||
);
|
||||
rows.add(extraFeeRow);
|
||||
totalAmount = totalAmount.add(extraFeeAmount);
|
||||
}
|
||||
}
|
||||
totalAmount = totalAmount.add(vatForEU);
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
public BigDecimal getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public void setTotalAmount(BigDecimal totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
}
|
||||
|
||||
public BigDecimal reducedAmount() {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
|
|
@ -14,10 +14,7 @@ import org.jeecg.modules.business.domain.purchase.invoice.PurchaseInvoiceEntry;
|
|||
import org.jeecg.modules.business.entity.*;
|
||||
import org.jeecg.modules.business.mapper.*;
|
||||
import org.jeecg.modules.business.service.*;
|
||||
import org.jeecg.modules.business.vo.PromotionDetail;
|
||||
import org.jeecg.modules.business.vo.ShippingFeesEstimation;
|
||||
import org.jeecg.modules.business.vo.SkuQuantity;
|
||||
import org.jeecg.modules.business.vo.SkuWeightDiscountServiceFees;
|
||||
import org.jeecg.modules.business.vo.*;
|
||||
import org.jeecg.modules.business.vo.clientPlatformOrder.section.OrdersStatisticData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.simpleframework.xml.core.Complete;
|
||||
|
@ -45,6 +42,7 @@ import static java.util.stream.Collectors.*;
|
|||
@Component
|
||||
public class ShippingInvoiceFactory {
|
||||
|
||||
private final IExtraFeeService extraFeeService;
|
||||
private final IPlatformOrderService platformOrderService;
|
||||
private final ClientMapper clientMapper;
|
||||
private final ShopMapper shopMapper;
|
||||
|
@ -80,7 +78,7 @@ public class ShippingInvoiceFactory {
|
|||
}
|
||||
});
|
||||
|
||||
public ShippingInvoiceFactory(IPlatformOrderService platformOrderService, ClientMapper clientMapper,
|
||||
public ShippingInvoiceFactory(IExtraFeeService extraFeeService, IPlatformOrderService platformOrderService, ClientMapper clientMapper,
|
||||
ShopMapper shopMapper, LogisticChannelMapper logisticChannelMapper,
|
||||
LogisticChannelPriceMapper logisticChannelPriceMapper,
|
||||
IPlatformOrderContentService platformOrderContentService,
|
||||
|
@ -89,6 +87,7 @@ public class ShippingInvoiceFactory {
|
|||
PurchaseOrderContentMapper purchaseOrderContentMapper,
|
||||
SkuPromotionHistoryMapper skuPromotionHistoryMapper, ISavRefundService savRefundService,
|
||||
ISavRefundWithDetailService savRefundWithDetailService, EmailService emailService, Environment env) {
|
||||
this.extraFeeService = extraFeeService;
|
||||
this.platformOrderService = platformOrderService;
|
||||
this.clientMapper = clientMapper;
|
||||
this.shopMapper = shopMapper;
|
||||
|
@ -137,6 +136,7 @@ public class ShippingInvoiceFactory {
|
|||
.map(PlatformOrder::getShopId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findNotInvoicedByShops(shopIds);
|
||||
log.info("Orders to be invoiced: {}", uninvoicedOrderToContent);
|
||||
String subject;
|
||||
if(type.equals("shipping"))
|
||||
|
@ -147,7 +147,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, savRefunds, subject, true);
|
||||
return createInvoice(customerId, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,6 +182,7 @@ public class ShippingInvoiceFactory {
|
|||
.map(PlatformOrder::getShopId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findNotInvoicedByShops(shopIds);
|
||||
log.info("Orders to be invoiced: {}", uninvoicedOrderToContent);
|
||||
String subject;
|
||||
if(shippingMethod.equals("shipping"))
|
||||
|
@ -194,8 +195,8 @@ 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");
|
||||
if(balance != null)
|
||||
return createCompleteInvoiceWithBalance(username, customerId, balance, shopIds, uninvoicedOrderToContent, savRefunds, subject);
|
||||
return createInvoice(username, customerId, null, shopIds, uninvoicedOrderToContent, savRefunds, subject);
|
||||
return createCompleteInvoiceWithBalance(username, customerId, balance, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject);
|
||||
return createInvoice(username, customerId, null, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject);
|
||||
}
|
||||
|
||||
|
||||
|
@ -224,7 +225,7 @@ public class ShippingInvoiceFactory {
|
|||
@Transactional
|
||||
public CompleteInvoice createInvoice(String username, String customerId, BigDecimal balance, List<String> shopIds,
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> orderAndContent,
|
||||
List<SavRefundWithDetail> savRefunds, String subject) throws UserException {
|
||||
List<SavRefundWithDetail> savRefunds, List<ExtraFeeResult> extraFees, String subject) throws UserException {
|
||||
Client client = clientMapper.selectById(customerId);
|
||||
log.info("User {} is creating a complete invoice for customer {}", username, client.getInternalCode());
|
||||
|
||||
|
@ -261,10 +262,13 @@ public class ShippingInvoiceFactory {
|
|||
if (savRefunds != null) {
|
||||
updateSavRefundsInDb(savRefunds, invoiceCode);
|
||||
}
|
||||
|
||||
if(extraFees != null) {
|
||||
List<String> extraFeesIds = extraFees.stream().map(ExtraFeeResult::getId).collect(toList());
|
||||
extraFeeService.updateInvoiceNumberByIds(extraFeesIds, invoiceCode);
|
||||
}
|
||||
updateOrdersAndContentsInDb(orderAndContent);
|
||||
|
||||
return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds,
|
||||
return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, extraFees,
|
||||
purchaseOrderSkuList, promotionDetails, eurToUsd);
|
||||
}
|
||||
|
||||
|
@ -294,7 +298,7 @@ public class ShippingInvoiceFactory {
|
|||
@Transactional
|
||||
public CompleteInvoice createCompleteInvoiceWithBalance(String username, String customerId, BigDecimal balance, List<String> shopIds,
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> orderAndContent,
|
||||
List<SavRefundWithDetail> savRefunds, String subject) throws UserException, MessagingException {
|
||||
List<SavRefundWithDetail> savRefunds, List<ExtraFeeResult> extraFees, String subject) throws UserException, MessagingException {
|
||||
// sorting by order time
|
||||
orderAndContent = orderAndContent.entrySet().stream().sorted(
|
||||
Map.Entry.comparingByKey(Comparator.comparing(PlatformOrder::getOrderTime))
|
||||
|
@ -394,10 +398,13 @@ public class ShippingInvoiceFactory {
|
|||
if (savRefunds != null) {
|
||||
updateSavRefundsInDb(savRefunds, invoiceCode);
|
||||
}
|
||||
|
||||
if(extraFees != null) {
|
||||
List<String> extraFeesIds = extraFees.stream().map(ExtraFeeResult::getId).collect(toList());
|
||||
extraFeeService.updateInvoiceNumberByIds(extraFeesIds, invoiceCode);
|
||||
}
|
||||
updateOrdersAndContentsInDb(orderAndContent);
|
||||
|
||||
return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds,
|
||||
return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, extraFees,
|
||||
purchaseOrderSkuList, promotionDetails, eurToUsd);
|
||||
}
|
||||
|
||||
|
@ -480,6 +487,7 @@ public class ShippingInvoiceFactory {
|
|||
);
|
||||
// find orders and their contents of the invoice
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent;
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findNotInvoicedByShops(shopIds);
|
||||
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
|
||||
String subject;
|
||||
if(erpStatuses.toString().equals("[3]")) {
|
||||
|
@ -509,9 +517,9 @@ public class ShippingInvoiceFactory {
|
|||
uninvoicedOrderToContent = platformOrderService.findUninvoicedOrderContentsForShopsAndStatus(shopIds, begin, end, erpStatuses, warehouses);
|
||||
}
|
||||
if(balance != null) {
|
||||
return createInvoiceWithBalance(customerId, balance, shopIds, uninvoicedOrderToContent, savRefunds, subject, false);
|
||||
return createInvoiceWithBalance(customerId, balance, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject, false);
|
||||
}
|
||||
return createInvoice(customerId, shopIds, uninvoicedOrderToContent, savRefunds, subject, false);
|
||||
return createInvoice(customerId, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -541,6 +549,7 @@ public class ShippingInvoiceFactory {
|
|||
public ShippingInvoice createInvoice(String customerId, List<String> shopIds,
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> orderAndContent,
|
||||
List<SavRefundWithDetail> savRefunds,
|
||||
List<ExtraFeeResult> extraFees,
|
||||
String subject, boolean skipShippingTimeComparing) throws UserException {
|
||||
log.info("Orders to be invoiced: {}", orderAndContent);
|
||||
if (orderAndContent == null || orderAndContent.size() == 0) {
|
||||
|
@ -578,7 +587,11 @@ public class ShippingInvoiceFactory {
|
|||
if (savRefunds != null) {
|
||||
updateSavRefundsInDb(savRefunds, invoiceCode);
|
||||
}
|
||||
ShippingInvoice invoice = new ShippingInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, eurToUsd);
|
||||
if(extraFees != null) {
|
||||
List<String> extraFeesIds = extraFees.stream().map(ExtraFeeResult::getId).collect(toList());
|
||||
extraFeeService.updateInvoiceNumberByIds(extraFeesIds, invoiceCode);
|
||||
}
|
||||
ShippingInvoice invoice = new ShippingInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, extraFees, eurToUsd);
|
||||
updateOrdersAndContentsInDb(orderAndContent);
|
||||
return invoice;
|
||||
}
|
||||
|
@ -610,6 +623,7 @@ public class ShippingInvoiceFactory {
|
|||
public ShippingInvoice createInvoiceWithBalance(String customerId, BigDecimal balance, List<String> shopIds,
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> orderAndContent,
|
||||
List<SavRefundWithDetail> savRefunds,
|
||||
List<ExtraFeeResult> extraFees,
|
||||
String subject, boolean skipShippingTimeComparing) throws UserException {
|
||||
log.info("Orders to be invoiced: {}", orderAndContent);
|
||||
if (orderAndContent == null || orderAndContent.isEmpty()) {
|
||||
|
@ -650,7 +664,7 @@ public class ShippingInvoiceFactory {
|
|||
if (savRefunds != null) {
|
||||
updateSavRefundsInDb(savRefunds, invoiceCode);
|
||||
}
|
||||
ShippingInvoice invoice = new ShippingInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, eurToUsd);
|
||||
ShippingInvoice invoice = new ShippingInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, extraFees, eurToUsd);
|
||||
updateOrdersAndContentsInDb(orderAndContent);
|
||||
return invoice;
|
||||
}
|
||||
|
@ -1217,6 +1231,7 @@ public class ShippingInvoiceFactory {
|
|||
shopPackageMatFeeMap.put(shop.getId(), shop.getPackagingMaterialFee());
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> orders = uninvoicedOrdersByShopId.get(shop.getId());
|
||||
try {
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findNotInvoicedByShops(Collections.singletonList(shop.getId()));
|
||||
Map<String, List<String>> orderIdErrorMap = calculateFees(null, logisticChannelMap, orders, channelPriceMap, countryList, skuRealWeights, skuServiceFees,
|
||||
latestDeclaredValues, client, shopServiceFeeMap,shopPackageMatFeeMap, null);
|
||||
if(!orderIdErrorMap.isEmpty()) {
|
||||
|
@ -1224,7 +1239,7 @@ public class ShippingInvoiceFactory {
|
|||
throw new UserException(errorEntry.getValue().toString());
|
||||
}
|
||||
BigDecimal eurToUsd = exchangeRatesMapper.getLatestExchangeRate("EUR", "USD");
|
||||
ShippingInvoice invoice = new ShippingInvoice(client, "", "", orders, null, eurToUsd);
|
||||
ShippingInvoice invoice = new ShippingInvoice(client, "", "", orders, null, extraFees, eurToUsd);
|
||||
// Calculate total amounts
|
||||
invoice.tableData();
|
||||
estimations.add(new ShippingFeesEstimation(
|
||||
|
@ -1281,13 +1296,14 @@ public class ShippingInvoiceFactory {
|
|||
shopPackageMatFeeMap.put(shop.getId(), shop.getPackagingMaterialFee());
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> orders = uninvoicedOrdersByShopId.get(shop.getId());
|
||||
try {
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findNotInvoicedByShops(Collections.singletonList(shop.getId()));
|
||||
Map<String, List<String>> platformOrderIdErrorMap = calculateFees(null, logisticChannelMap, orders, channelPriceMap, countryList, skuRealWeights, skuServiceFees,
|
||||
latestDeclaredValues, client, shopServiceFeeMap, shopPackageMatFeeMap, null);
|
||||
platformOrderIdErrorMap.forEach((key, value) -> errorMessages.addAll(value));
|
||||
orders.entrySet().removeIf(entries -> platformOrderIdErrorMap.containsKey(entries.getKey().getId()));
|
||||
List<String> estimationsOrderIds = orders.keySet().stream().map(PlatformOrder::getId).collect(Collectors.toList());
|
||||
BigDecimal eurToUsd = exchangeRatesMapper.getLatestExchangeRate("EUR", "USD");
|
||||
ShippingInvoice invoice = new ShippingInvoice(client, "", "", orders, null, eurToUsd);
|
||||
ShippingInvoice invoice = new ShippingInvoice(client, "", "", orders, null, extraFees, eurToUsd);
|
||||
// Calculate total amounts
|
||||
invoice.tableData();
|
||||
estimations.add(new ShippingFeesEstimation(
|
||||
|
@ -1304,6 +1320,7 @@ public class ShippingInvoiceFactory {
|
|||
log.info("Building existing shipping invoice : {} - Client ID : {}, ", invoiceCode, clientId);
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> ordersMapContent = platformOrderService.fetchOrderDataByInvoiceCode(invoiceCode);
|
||||
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceCode);
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findByInvoiceNumber(invoiceCode);
|
||||
String subject;
|
||||
if(shippingMethod.equals("post-shipping")) {
|
||||
subject = String.format("Shipping fees from %s to %s", start, end);
|
||||
|
@ -1316,7 +1333,7 @@ public class ShippingInvoiceFactory {
|
|||
Client client = clientMapper.selectById(clientId);
|
||||
BigDecimal eurToUsd = exchangeRatesMapper.getExchangeRateFromDate("EUR", "USD", start);
|
||||
|
||||
return new ShippingInvoice(client, invoiceCode, subject, ordersMapContent, savRefunds, eurToUsd);
|
||||
return new ShippingInvoice(client, invoiceCode, subject, ordersMapContent, savRefunds, extraFees, eurToUsd);
|
||||
}
|
||||
public PurchaseInvoice buildExistingPurchaseInvoice (String invoiceCode) {
|
||||
PurchaseOrder order = purchaseOrderService.getPurchaseByInvoiceNumber(invoiceCode);
|
||||
|
@ -1331,6 +1348,7 @@ public class ShippingInvoiceFactory {
|
|||
log.info("Building existing complete invoice : {} - Client ID : {}, ", invoiceCode, clientId);
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> ordersMapContent = platformOrderService.fetchOrderDataByInvoiceCode(invoiceCode);
|
||||
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceCode);
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findByInvoiceNumber(invoiceCode);
|
||||
String subject;
|
||||
if(shippingMethod.equals("post-shipping"))
|
||||
subject = String.format("Purchase and Shipping fees from %s to %s", start, end);
|
||||
|
@ -1343,7 +1361,7 @@ public class ShippingInvoiceFactory {
|
|||
List<PurchaseInvoiceEntry> purchaseOrderSkuList = purchaseOrderContentMapper.selectInvoiceDataByID(purchaseID);
|
||||
List<PromotionDetail> promotionDetails = skuPromotionHistoryMapper.selectPromotionByPurchase(purchaseID);
|
||||
|
||||
return new CompleteInvoice(client, invoiceCode, subject, ordersMapContent, savRefunds,
|
||||
return new CompleteInvoice(client, invoiceCode, subject, ordersMapContent, savRefunds, extraFees,
|
||||
purchaseOrderSkuList, promotionDetails, eurToUsd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,5 +28,13 @@ public interface ExtraFeeMapper extends BaseMapper<ExtraFee> {
|
|||
@Param("status") String status);
|
||||
|
||||
void updateFee(@Param("id") String id, @Param("description") String description, @Param("qty") Integer quantity, @Param("price") BigDecimal unitPrice);
|
||||
|
||||
List<ExtraFeeResult> findNotInvoicedByShops(@Param("shopIds") List<String> shopIds);
|
||||
|
||||
void updateInvoiceNumberByIds(@Param("ids") List<String> feeIds, @Param("invoiceNumber") String invoiceCode);
|
||||
|
||||
List<ExtraFeeResult> findByInvoiceNumber(@Param("invoiceNumber") String invoiceCode);
|
||||
|
||||
void cancelInvoice(@Param("invoiceNumber") String invoiceNumber, @Param("clientId") String clientId);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,4 +57,54 @@
|
|||
IF(option_id = (SELECT id FROM extra_fee_option WHERE en_name = 'Autres') AND invoice_number IS NULL, #{description}, description)
|
||||
WHERE id = #{id};
|
||||
</update>
|
||||
<select id="findNotInvoicedByShops" resultType="org.jeecg.modules.business.vo.ExtraFeeResult">
|
||||
SELECT ef.id,
|
||||
s.erp_code as shop,
|
||||
efo.en_name,
|
||||
efo.zh_name,
|
||||
ef.description,
|
||||
ef.quantity,
|
||||
ef.unit_price,
|
||||
ef.invoice_number
|
||||
FROM extra_fee ef
|
||||
JOIN extra_fee_option efo ON efo.id = ef.option_id
|
||||
JOIN shop s ON s.id = ef.shop_id
|
||||
WHERE shop_id IN
|
||||
<foreach collection="shopIds" item="shopId" open="(" separator="," close=")">
|
||||
#{shopId}
|
||||
</foreach>
|
||||
AND invoice_number IS NULL;
|
||||
</select>
|
||||
<update id="updateInvoiceNumberByIds">
|
||||
UPDATE extra_fee
|
||||
SET invoice_number = #{invoiceNumber}
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
<select id="findByInvoiceNumber" resultType="org.jeecg.modules.business.vo.ExtraFeeResult">
|
||||
SELECT ef.id,
|
||||
ef.create_by,
|
||||
ef.create_time,
|
||||
s.erp_code as shop,
|
||||
efo.en_name,
|
||||
efo.zh_name,
|
||||
ef.description,
|
||||
ef.quantity,
|
||||
ef.unit_price,
|
||||
ef.invoice_number
|
||||
FROM extra_fee ef
|
||||
JOIN extra_fee_option efo ON efo.id = ef.option_id
|
||||
JOIN shop s ON s.id = ef.shop_id
|
||||
WHERE invoice_number = #{invoiceNumber};
|
||||
</select>
|
||||
<update id="cancelInvoice">
|
||||
UPDATE extra_fee
|
||||
JOIN shop s ON extra_fee.shop_id = s.id
|
||||
JOIN client c ON s.owner_id = c.id
|
||||
SET invoice_number = NULL
|
||||
WHERE invoice_number = #{invoiceNumber}
|
||||
AND c.id = #{clientId};
|
||||
</update>
|
||||
</mapper>
|
|
@ -3,28 +3,31 @@ package org.jeecg.modules.business.mongoService;
|
|||
import org.jeecg.modules.business.entity.Sku;
|
||||
import org.jeecg.modules.business.entity.SkuDeclaredValue;
|
||||
import org.jeecg.modules.business.entity.SkuPrice;
|
||||
import org.jeecg.modules.business.entity.SkuWeight;
|
||||
import org.jeecg.modules.business.model.SkuDocument;
|
||||
import org.jeecg.modules.business.vo.SkuOrderPage;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
public interface SkuMongoService {
|
||||
void updateSkuWeight(String erpCode, Integer weight);
|
||||
SkuDocument findByErpCode(String erpCode);
|
||||
SkuDocument findBySkuId(String skuId);
|
||||
|
||||
void findAndReplace(String field, String value, SkuDocument skuDocument);
|
||||
|
||||
void deleteBySkuId(String skuId);
|
||||
|
||||
void upsertSkuPrice(SkuPrice price);
|
||||
|
||||
void deleteBySkuId(String skuId);
|
||||
void deleteSkuPriceBySkuId(String skuId);
|
||||
|
||||
void upsertSkuDeclaredValue(SkuDeclaredValue skuDeclaredValue);
|
||||
|
||||
void deleteSkuDeclaredValueBySkuId(String skuId);
|
||||
|
||||
void deleteSkuPriceBySkuId(String skuId);
|
||||
void upsertSkuWeight(SkuWeight skuWeight);
|
||||
|
||||
void deleteSkuWeightBySkuId(String skuId);
|
||||
|
||||
void updateStock(Sku sku);
|
||||
|
||||
|
|
|
@ -4,15 +4,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.jeecg.modules.base.event.SkuDeclaredValueModifiedEvent;
|
||||
import org.jeecg.modules.base.event.SkuModifiedEvent;
|
||||
import org.jeecg.modules.base.event.SkuPriceModifiedEvent;
|
||||
import org.jeecg.modules.business.entity.SensitiveAttribute;
|
||||
import org.jeecg.modules.business.entity.Sku;
|
||||
import org.jeecg.modules.business.entity.SkuDeclaredValue;
|
||||
import org.jeecg.modules.business.entity.SkuPrice;
|
||||
import org.jeecg.modules.base.event.SkuWeightModifiedEvent;
|
||||
import org.jeecg.modules.business.entity.*;
|
||||
import org.jeecg.modules.business.model.SkuDocument;
|
||||
import org.jeecg.modules.business.service.ISensitiveAttributeService;
|
||||
import org.jeecg.modules.business.service.ISkuDeclaredValueService;
|
||||
import org.jeecg.modules.business.service.ISkuPriceService;
|
||||
import org.jeecg.modules.business.service.ISkuService;
|
||||
import org.jeecg.modules.business.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -29,6 +24,8 @@ public class SkuMongoSyncService {
|
|||
@Autowired
|
||||
private ISkuPriceService skuPriceService;
|
||||
@Autowired
|
||||
private ISkuWeightService skuWeightService;
|
||||
@Autowired
|
||||
private ISensitiveAttributeService sensitiveAttributeService;
|
||||
|
||||
/**
|
||||
|
@ -125,4 +122,25 @@ public class SkuMongoSyncService {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@EventListener
|
||||
public void handeSkuWeightModifiedEvent(SkuWeightModifiedEvent event) {
|
||||
log.info("Received a SkuWeightModifiedEvent: {}", event);
|
||||
String id = event.getId();
|
||||
String operation = event.getOperation();
|
||||
|
||||
SkuWeight skuWeight = skuWeightService.getById(id);
|
||||
|
||||
switch (operation) {
|
||||
case "INSERT":
|
||||
case "UPDATE":
|
||||
skuMongoService.upsertSkuWeight(skuWeight);
|
||||
break;
|
||||
case "DELETE":
|
||||
skuMongoService.deleteSkuWeightBySkuId(skuWeight.getSkuId());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.jeecg.modules.business.entity.Sku;
|
||||
import org.jeecg.modules.business.entity.SkuDeclaredValue;
|
||||
import org.jeecg.modules.business.entity.SkuPrice;
|
||||
import org.jeecg.modules.business.entity.SkuWeight;
|
||||
import org.jeecg.modules.business.model.SkuDocument;
|
||||
import org.jeecg.modules.business.mongoRepository.SkuRepository;
|
||||
import org.jeecg.modules.business.mongoService.SkuMongoService;
|
||||
|
@ -28,20 +29,6 @@ public class SkuMongoServiceImpl implements SkuMongoService {
|
|||
@Autowired
|
||||
private SkuRepository skuRepository;
|
||||
|
||||
@Override
|
||||
public void updateSkuWeight(String erpCode, Integer weight) {
|
||||
log.info("updateSkuWeight erpCode: {}, weight: {}", erpCode, weight);
|
||||
Query query = new Query(Criteria.where("erpCode").is(erpCode));
|
||||
Update update = new Update().set("weight", weight);
|
||||
|
||||
UpdateResult result = mongoTemplate.updateFirst(query, update, SkuDocument.class);
|
||||
|
||||
if(result == null)
|
||||
log.error("updateSkuWeight failed");
|
||||
else
|
||||
log.info("{} document(s) updated ..", result.getModifiedCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkuDocument findByErpCode(String erpCode) {
|
||||
return skuRepository.findByErpCode(erpCode);
|
||||
|
@ -63,6 +50,12 @@ public class SkuMongoServiceImpl implements SkuMongoService {
|
|||
.findAndReplace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBySkuId(String skuId) {
|
||||
Query query = new Query(Criteria.where("skuId").is(skuId));
|
||||
mongoTemplate.findAndRemove(query, SkuDocument.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upsertSkuPrice(SkuPrice price) {
|
||||
Query query = new Query(Criteria.where("skuId").is(price.getSkuId()));
|
||||
|
@ -91,9 +84,14 @@ public class SkuMongoServiceImpl implements SkuMongoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteBySkuId(String skuId) {
|
||||
public void deleteSkuPriceBySkuId(String skuId) {
|
||||
Query query = new Query(Criteria.where("skuId").is(skuId));
|
||||
mongoTemplate.findAndRemove(query, SkuDocument.class);
|
||||
mongoTemplate.update(SkuDocument.class)
|
||||
.matching(query)
|
||||
.apply(new Update()
|
||||
.unset("latestSkuPrice")
|
||||
)
|
||||
.findAndModifyValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -126,16 +124,33 @@ public class SkuMongoServiceImpl implements SkuMongoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteSkuPriceBySkuId(String skuId) {
|
||||
public void upsertSkuWeight(SkuWeight skuWeight) {
|
||||
Query query = new Query(Criteria.where("skuId").is(skuWeight.getSkuId()));
|
||||
SkuDocument.LatestSkuWeight latestSkuWeight = SkuDocument.LatestSkuWeight.builder()
|
||||
.weight(skuWeight.getWeight())
|
||||
.effectiveDate(skuWeight.getEffectiveDate())
|
||||
.build();
|
||||
mongoTemplate.update(SkuDocument.class)
|
||||
.matching(query)
|
||||
.apply(new Update()
|
||||
.set("latestSkuWeight", latestSkuWeight)
|
||||
.set("updateTime", skuWeight.getCreateTime())
|
||||
.set("updateBy", skuWeight.getCreateBy())
|
||||
)
|
||||
.withOptions(FindAndModifyOptions.options().upsert(true))
|
||||
.findAndModifyValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSkuWeightBySkuId(String skuId) {
|
||||
Query query = new Query(Criteria.where("skuId").is(skuId));
|
||||
mongoTemplate.update(SkuDocument.class)
|
||||
.matching(query)
|
||||
.apply(new Update()
|
||||
.unset("latestSkuPrice")
|
||||
.unset("latestSkuWeight")
|
||||
)
|
||||
.findAndModifyValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStock(Sku sku) {
|
||||
Query query = new Query(Criteria.where("skuId").is(sku.getId()));
|
||||
|
@ -187,6 +202,7 @@ public class SkuMongoServiceImpl implements SkuMongoService {
|
|||
return skuOrderPages.stream()
|
||||
.map(this::convertSkuDocumentToSkuOrderPage).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public SkuOrderPage convertSkuDocumentToSkuOrderPage(SkuDocument skuDocument) {
|
||||
SkuOrderPage skuOrderPage = new SkuOrderPage();
|
||||
skuOrderPage.setId(skuDocument.getSkuId());
|
||||
|
|
|
@ -20,4 +20,12 @@ public interface IExtraFeeService extends IService<ExtraFee> {
|
|||
Integer countAllFees(String shop, String status);
|
||||
|
||||
void updateFee(ExtraFeeParam feeParam) throws Exception;
|
||||
|
||||
List<ExtraFeeResult> findNotInvoicedByShops(List<String> shopIds);
|
||||
|
||||
void updateInvoiceNumberByIds(List<String> feeIds, String invoiceCode);
|
||||
|
||||
List<ExtraFeeResult> findByInvoiceNumber(String invoiceCode);
|
||||
|
||||
void cancelInvoice(String invoiceNumber, String clientId);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -54,6 +55,8 @@ public class PlatformOrderShippingInvoiceService {
|
|||
@Autowired
|
||||
ICurrencyService currencyService;
|
||||
@Autowired
|
||||
IExtraFeeService extraFeeService;
|
||||
@Autowired
|
||||
ShippingInvoiceMapper shippingInvoiceMapper;
|
||||
@Autowired
|
||||
PlatformOrderMapper platformOrderMapper;
|
||||
|
@ -160,6 +163,14 @@ public class PlatformOrderShippingInvoiceService {
|
|||
"Montant total du remboursement",
|
||||
"N° de facture"
|
||||
};
|
||||
private final static String[] EXTRA_FEE_TITLES = {
|
||||
"Boutique",
|
||||
"Type",
|
||||
"Description",
|
||||
"Quantité",
|
||||
"Prix unitaire",
|
||||
"N° de facture"
|
||||
};
|
||||
private final static String[] PURCHASE_INVENTORY_TITLES = {
|
||||
"SKU",
|
||||
"Nom Anglais",
|
||||
|
@ -211,6 +222,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
public InvoiceMetaData makeInvoice(ShippingInvoiceParam param, String ... user) throws UserException, ParseException, IOException {
|
||||
// Creates factory
|
||||
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
|
||||
extraFeeService,
|
||||
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
|
||||
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
|
||||
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env);
|
||||
|
@ -242,6 +254,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
public InvoiceMetaData makeInvoice(ShippingInvoiceOrderParam param) throws UserException, ParseException, IOException {
|
||||
// Creates factory
|
||||
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
|
||||
extraFeeService,
|
||||
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
|
||||
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
|
||||
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env);
|
||||
|
@ -265,6 +278,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
public InvoiceMetaData makeCompleteInvoice(ShippingInvoiceOrderParam param) throws UserException, ParseException, IOException, MessagingException {
|
||||
// Creates factory
|
||||
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
|
||||
extraFeeService,
|
||||
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
|
||||
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
|
||||
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env);
|
||||
|
@ -287,6 +301,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
public InvoiceMetaData makeCompleteInvoicePostShipping(ShippingInvoiceParam param, String method, String ... user) throws UserException, ParseException, IOException, MessagingException {
|
||||
// Creates factory
|
||||
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
|
||||
extraFeeService,
|
||||
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
|
||||
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
|
||||
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env);
|
||||
|
@ -371,6 +386,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
public List<ShippingFeesEstimation> getShippingFeesEstimation(List<String> errorMessages) {
|
||||
// Creates factory
|
||||
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
|
||||
extraFeeService,
|
||||
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
|
||||
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
|
||||
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env);
|
||||
|
@ -386,6 +402,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
public List<ShippingFeesEstimation> getShippingFeesEstimation(String clientId, List<String> orderIds,List<String> errorMessages) {
|
||||
// Creates factory
|
||||
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
|
||||
extraFeeService,
|
||||
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
|
||||
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
|
||||
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env);
|
||||
|
@ -413,7 +430,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
return factureDetailMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public byte[] exportToExcel(List<FactureDetail> details, List<SavRefundWithDetail> refunds, String invoiceNumber, String invoiceEntity, String internalCode) throws IOException {
|
||||
public byte[] exportToExcel(List<FactureDetail> details, List<SavRefundWithDetail> refunds, List<ExtraFeeResult> extraFees, String invoiceNumber, String invoiceEntity, String internalCode) throws IOException {
|
||||
SheetManager sheetManager = SheetManager.createXLSX();
|
||||
sheetManager.startDetailsSheet();
|
||||
for (String title : DETAILS_TITLES) {
|
||||
|
@ -498,6 +515,31 @@ public class PlatformOrderShippingInvoiceService {
|
|||
sheetManager.nextRow();
|
||||
}
|
||||
|
||||
sheetManager.startExtraFeeSheet();
|
||||
for (String title: EXTRA_FEE_TITLES) {
|
||||
sheetManager.write(title);
|
||||
sheetManager.nextCol();
|
||||
}
|
||||
|
||||
sheetManager.moveCol(0);
|
||||
sheetManager.nextRow();
|
||||
|
||||
for (ExtraFeeResult extraFee: extraFees) {
|
||||
sheetManager.write(extraFee.getShop());
|
||||
sheetManager.nextCol();
|
||||
sheetManager.write(extraFee.getEnName());
|
||||
sheetManager.nextCol();
|
||||
sheetManager.write(extraFee.getDescription());
|
||||
sheetManager.nextCol();
|
||||
sheetManager.write(extraFee.getQuantity());
|
||||
sheetManager.nextCol();
|
||||
sheetManager.write(extraFee.getUnitPrice());
|
||||
sheetManager.nextCol();
|
||||
sheetManager.write(extraFee.getInvoiceNumber());
|
||||
sheetManager.moveCol(0);
|
||||
sheetManager.nextRow();
|
||||
}
|
||||
|
||||
Path target = Paths.get(INVOICE_DETAIL_DIR, internalCode + "_(" + invoiceEntity + ")_" + invoiceNumber + "_Détail_calcul_de_facture.xlsx");
|
||||
int i = 2;
|
||||
while (Files.exists(target)) {
|
||||
|
@ -750,7 +792,8 @@ public class PlatformOrderShippingInvoiceService {
|
|||
Client client = clientService.getClientFromInvoice(invoiceNumber);
|
||||
List<FactureDetail> details = getInvoiceDetail(invoiceNumber);
|
||||
List<SavRefundWithDetail> refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceNumber);
|
||||
exportToExcel(details, refunds, invoiceNumber, client.getInvoiceEntity(), client.getInternalCode());
|
||||
List<ExtraFeeResult> extraFees = extraFeeService.findByInvoiceNumber(invoiceNumber);
|
||||
exportToExcel(details, refunds, extraFees, invoiceNumber, client.getInvoiceEntity(), client.getInternalCode());
|
||||
pathList = getPath(INVOICE_DETAIL_DIR, invoiceNumber);
|
||||
}
|
||||
else {
|
||||
|
@ -834,6 +877,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
|
||||
public List<Path> generateInvoiceExcel(String invoiceNumber, String filetype) throws UserException, IOException {
|
||||
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
|
||||
extraFeeService,
|
||||
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
|
||||
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
|
||||
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env);
|
||||
|
|
|
@ -41,4 +41,24 @@ public class ExtraFeeServiceImpl extends ServiceImpl<ExtraFeeMapper, ExtraFee> i
|
|||
}
|
||||
extraFeeMapper.updateFee(feeParam.getId(), feeParam.getDescription(), feeParam.getQuantity(), feeParam.getUnitPrice());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtraFeeResult> findNotInvoicedByShops(List<String> shopIds) {
|
||||
return extraFeeMapper.findNotInvoicedByShops(shopIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInvoiceNumberByIds(List<String> feeIds, String invoiceCode) {
|
||||
extraFeeMapper.updateInvoiceNumberByIds(feeIds, invoiceCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtraFeeResult> findByInvoiceNumber(String invoiceCode) {
|
||||
return extraFeeMapper.findByInvoiceNumber(invoiceCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelInvoice(String invoiceNumber, String clientId) {
|
||||
extraFeeMapper.cancelInvoice(invoiceNumber, clientId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
|
|||
@Autowired
|
||||
private IClientService clientService;
|
||||
@Autowired
|
||||
private IExtraFeeService extraFeeService;
|
||||
@Autowired
|
||||
private IPlatformOrderContentService platformOrderContentService;
|
||||
@Autowired
|
||||
private IPlatformOrderService platformOrderService;
|
||||
|
@ -57,6 +59,7 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> impl
|
|||
public boolean cancelInvoice(String id, String invoiceNumber, String clientId) {
|
||||
String invoiceEntity = clientService.getById(clientId).getInvoiceEntity();
|
||||
|
||||
extraFeeService.cancelInvoice(invoiceNumber, clientId);
|
||||
savRefundService.cancelInvoice(invoiceNumber, clientId);
|
||||
if(Invoice.getType(invoiceNumber).equalsIgnoreCase(PURCHASE.name())) {
|
||||
PurchaseOrder po = purchaseOrderService.getById(id);
|
||||
|
|
|
@ -444,8 +444,11 @@ public class SkuListMabangServiceImpl extends ServiceImpl<SkuListMabangMapper, S
|
|||
String saleRemark = saleRemarkMatcher.group(1);
|
||||
int weight = (int) ceil(Double.parseDouble(saleRemark));
|
||||
if(oldSkuWeight.getWeight() != weight) {
|
||||
oldSkuWeight.setWeight(weight);
|
||||
skuWeightService.updateById(oldSkuWeight);
|
||||
SkuWeight newSkuWeight = new SkuWeight();
|
||||
newSkuWeight.setWeight(weight);
|
||||
newSkuWeight.setSkuId(sku.getId());
|
||||
newSkuWeight.setEffectiveDate(new Date());
|
||||
skuWeightService.save(newSkuWeight);
|
||||
isUpdated = true;
|
||||
}
|
||||
if(!saleRemarkMatcher.group(2).isEmpty()) {
|
||||
|
|
Loading…
Reference in New Issue