mirror of https://github.com/jeecgboot/jeecg-boot
feature: (WIP) Invoicing in breakdown page
parent
846f75b10d
commit
314a4b7ac4
|
@ -18,7 +18,6 @@ import org.jeecg.modules.business.mapper.PlatformOrderContentMapper;
|
|||
import org.jeecg.modules.business.mapper.PlatformOrderMapper;
|
||||
import org.jeecg.modules.business.service.*;
|
||||
import org.jeecg.modules.business.vo.*;
|
||||
import org.jeecg.modules.message.entity.SysMessage;
|
||||
import org.jeecg.modules.quartz.entity.QuartzJob;
|
||||
import org.jeecg.modules.quartz.service.IQuartzJobService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -42,6 +41,8 @@ import java.util.stream.Collectors;
|
|||
@RequestMapping("/shippingInvoice")
|
||||
@Slf4j
|
||||
public class InvoiceController {
|
||||
@Autowired
|
||||
private IClientService clientService;
|
||||
@Autowired
|
||||
private IShopService shopService;
|
||||
@Autowired
|
||||
|
@ -154,15 +155,14 @@ public class InvoiceController {
|
|||
else return Result.error("No package in the selected period");
|
||||
}
|
||||
/**
|
||||
* Make invoice for orders indicated by param.
|
||||
* Make shipping invoice for shops between 2 dates and orders with specified status.
|
||||
*
|
||||
* @param param invoice making parameter
|
||||
* @param param ClientID, shopIDs[], startDate, endDate, erpStatuses[], warehouses[]
|
||||
* @return Result of the generation, in case of error, message will be contained,
|
||||
* in case of success, data will contain filename.
|
||||
*/
|
||||
@PostMapping(value = "/make")
|
||||
public Result<?> makeInvoice(@RequestBody ShippingInvoiceParam param) {
|
||||
System.out.println(param);
|
||||
try {
|
||||
InvoiceMetaData metaData = shippingInvoiceService.makeInvoice(param);
|
||||
return Result.OK(metaData);
|
||||
|
@ -174,8 +174,8 @@ public class InvoiceController {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Same as makeCompletePreShippingInvoice but for post shipping
|
||||
* @param param ClientID, shopIDs[], startDate, endDate
|
||||
* Make complete invoice (Purchase + shipping) for shops between 2 dates and orders with specified status.
|
||||
* @param param ClientID, shopIDs[], startDate, endDate, erpStatuses[], warehouses[]
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/makeComplete")
|
||||
|
@ -214,7 +214,7 @@ public class InvoiceController {
|
|||
|
||||
|
||||
/**
|
||||
* Make complete pre-shipping invoice (Purchase + shipping) for specified orders
|
||||
* Make complete shipping invoice (Purchase + shipping) for specified orders and statuses
|
||||
*
|
||||
* @param param Parameters for creating a pre-shipping invoice
|
||||
* @return Result of the generation, in case of error, message will be contained,
|
||||
|
@ -328,6 +328,11 @@ public class InvoiceController {
|
|||
return shippingInvoiceService.exportToExcel(res, invoiceNumber, invoiceEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a breakdown of all invoicable shops
|
||||
*
|
||||
* @return List of Shipping fees estimation
|
||||
*/
|
||||
@GetMapping(value = "/breakdown/byShop")
|
||||
public Result<?> getOrdersByClientAndShops() {
|
||||
List<String> errorMessages = new ArrayList<>();
|
||||
|
@ -335,10 +340,114 @@ public class InvoiceController {
|
|||
if (shippingFeesEstimation.isEmpty()) {
|
||||
return Result.error("No data");
|
||||
} else {
|
||||
Map<String, String> clientIDCodeMap = new HashMap<>();
|
||||
for(ShippingFeesEstimation estimation: shippingFeesEstimation) {
|
||||
String clientId;
|
||||
if(clientIDCodeMap.containsKey(estimation.getCode())){
|
||||
clientId = clientIDCodeMap.get(estimation.getCode());
|
||||
}
|
||||
else {
|
||||
clientId = clientService.getClientByInternalCode(estimation.getCode());
|
||||
clientIDCodeMap.put(estimation.getCode(), clientId);
|
||||
}
|
||||
if (estimation.getIsCompleteInvoice().equals("1")) {
|
||||
List<String> shopIds = shopService.listIdByClient(clientId);
|
||||
Period period = shippingInvoiceService.getValidPeriod(shopIds);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(period.start());
|
||||
String start = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1 < 10 ? "0" : "") + (calendar.get(Calendar.MONTH) + 1) + "-" + (calendar.get(Calendar.DAY_OF_MONTH) < 10 ? "0" : "") + (calendar.get(Calendar.DAY_OF_MONTH));
|
||||
calendar.setTime(period.end());
|
||||
String end = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1 < 10 ? "0" : "") + (calendar.get(Calendar.MONTH) + 1) + "-" + (calendar.get(Calendar.DAY_OF_MONTH) + 1 < 10 ? "0" : "") + (calendar.get(Calendar.DAY_OF_MONTH) + 1);
|
||||
|
||||
List<String> orderIds = shippingInvoiceService.getShippingOrderIdBetweenDate(shopIds, start, end, Arrays.asList("0", "1"));
|
||||
ShippingInvoiceOrderParam param = new ShippingInvoiceOrderParam(clientId, orderIds, "post");
|
||||
Result<?> checkSkuPrices = checkSkuPrices(param);
|
||||
estimation.setErrorMessage(checkSkuPrices.getCode() == 200 ? "" : checkSkuPrices.getMessage());
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
return Result.OK(errorMessages.toString(), shippingFeesEstimation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a list of ShippingFeesEstimations and groups the estimations by client
|
||||
* @param estimationsByShop List of estimations
|
||||
* @return List of estimation grouped by client
|
||||
*/
|
||||
@PostMapping(value = "/breakdown/byClient")
|
||||
public Result<?> getOrdersByClient(@RequestBody List<ShippingFeesEstimation> estimationsByShop) {
|
||||
Map<String, List<ShippingFeesEstimation>> estimationClientMap = new HashMap<>();
|
||||
List<ShippingFeesEstimationClient> estimationByClients = new ArrayList<>();
|
||||
estimationsByShop.forEach(estimation -> {
|
||||
if(estimationClientMap.containsKey(estimation.getCode())){
|
||||
estimationClientMap.get(estimation.getCode()).add(estimation);
|
||||
}else {
|
||||
List<ShippingFeesEstimation> l = new ArrayList<>();
|
||||
l.add(estimation);
|
||||
estimationClientMap.put(estimation.getCode(), l);
|
||||
}
|
||||
});
|
||||
for(Map.Entry<String, List<ShippingFeesEstimation>> entry : estimationClientMap.entrySet()) {
|
||||
String code = entry.getKey();
|
||||
String clientId = clientService.getClientByInternalCode(code);
|
||||
List<String> shops = new ArrayList<>();
|
||||
int ordersToProcess = 0;
|
||||
int processedOrders = 0;
|
||||
BigDecimal dueForProcessedOrders = BigDecimal.ZERO;
|
||||
String isCompleteInvoice = "0";
|
||||
int hasErrors = 0;
|
||||
for(ShippingFeesEstimation estimation: entry.getValue()) {
|
||||
shops.add(estimation.getShop());
|
||||
isCompleteInvoice = estimation.getIsCompleteInvoice();
|
||||
ordersToProcess += estimation.getOrdersToProcess();
|
||||
processedOrders += estimation.getProcessedOrders();
|
||||
dueForProcessedOrders = dueForProcessedOrders.add(estimation.getDueForProcessedOrders());
|
||||
hasErrors = estimation.getErrorMessage().isEmpty() ? hasErrors : hasErrors+1;
|
||||
}
|
||||
ShippingFeesEstimationClient estimationClient = new ShippingFeesEstimationClient(clientId, code, ordersToProcess, processedOrders, dueForProcessedOrders, isCompleteInvoice, hasErrors);
|
||||
estimationByClients.add(estimationClient);
|
||||
System.gc();
|
||||
}
|
||||
return Result.ok(estimationByClients);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoices all available orders with status 3 for a list of client
|
||||
* @param clientCodes list of clients to invoice
|
||||
* @param invoiceType invoice type (shipping or complete)
|
||||
* @return list of invoice infos
|
||||
*/
|
||||
@GetMapping(value = "/breakdown/makeInvoice")
|
||||
public Result<?> makeBreakdownInvoice(@RequestParam(value = "codes[]") List<String> clientCodes, @RequestParam("invoiceType") int invoiceType) {
|
||||
Map<String, List<String>> clientShopIDsMap = new HashMap<>();
|
||||
List<InvoiceMetaData> invoiceList = new ArrayList<>();
|
||||
for(String id: clientCodes) {
|
||||
clientShopIDsMap.put(id, shopService.listIdByClient(id));
|
||||
}
|
||||
for(Map.Entry<String, List<String>> entry: clientShopIDsMap.entrySet()) {
|
||||
Period period = shippingInvoiceService.getValidPeriod(entry.getValue());
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(period.start());
|
||||
String start = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.MONTH)+1) + "-" + (calendar.get(Calendar.DAY_OF_MONTH) < 10 ? "0" : "") + (calendar.get(Calendar.DAY_OF_MONTH));
|
||||
calendar.setTime(period.end());
|
||||
String end = calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.MONTH)+1) + "-" + (calendar.get(Calendar.DAY_OF_MONTH)+1 < 10 ? "0" : "") + (calendar.get(Calendar.DAY_OF_MONTH)+1);
|
||||
System.out.println( "[" + start + "] --- [" + end + "]");
|
||||
try {
|
||||
ShippingInvoiceParam param = new ShippingInvoiceParam(entry.getKey(), entry.getValue(), start, end, Collections.singletonList(3), Arrays.asList("0", "1"));
|
||||
InvoiceMetaData metaData;
|
||||
if(invoiceType == 0)
|
||||
metaData = shippingInvoiceService.makeInvoice(param);
|
||||
else
|
||||
metaData = shippingInvoiceService.makeCompleteInvoicePostShipping(param, "post");
|
||||
invoiceList.add(metaData);
|
||||
} catch (UserException | IOException | ParseException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
return Result.ok(invoiceList);
|
||||
}
|
||||
/**
|
||||
* Get an estimate of shipping fees for selected orders
|
||||
* @param param Parameters for creating a pre-shipping invoice
|
||||
|
|
|
@ -41,10 +41,6 @@ import org.springframework.web.servlet.ModelAndView;
|
|||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
|
@ -519,38 +515,107 @@ public class ShippingInvoiceController {
|
|||
String invoiceEntity = clientService.getClientEntity(clientId);
|
||||
List<Path> invoicePathList = getPath(INVOICE_LOCATION, invoiceNumber, invoiceEntity);
|
||||
List<Path> detailPathList = getPath(INVOICE_DETAIL_LOCATION, invoiceNumber, invoiceEntity);
|
||||
if(invoicePathList.isEmpty() ||detailPathList.isEmpty()) {
|
||||
boolean invoiceDeleted = false, detailDeleted = false;
|
||||
|
||||
if(invoicePathList.isEmpty()) {
|
||||
log.error("FILE NOT FOUND : " + invoiceNumber);
|
||||
return Result.ok("Invoice canceled, but file not found.");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (Path path : invoicePathList) {
|
||||
log.info(path.toString());
|
||||
}
|
||||
for (Path path : detailPathList) {
|
||||
log.info(path.toString());
|
||||
}
|
||||
try {
|
||||
File invoiceFile = new File(invoicePathList.get(0).toString());
|
||||
File detailFile = new File(detailPathList.get(0).toString());
|
||||
if(invoiceFile.delete()) {
|
||||
log.info("Invoice file {} delete successful.", invoicePathList.get(0).toString());
|
||||
invoiceDeleted = true;
|
||||
} else {
|
||||
log.error("Invoice file delete fail.");
|
||||
return Result.error("Invoice file delete fail.");
|
||||
}
|
||||
if(detailFile.delete()) {
|
||||
log.info("Detail file {} delete successful.", detailPathList.get(0).toString());
|
||||
} else {
|
||||
log.error("Detail file delete fail.");
|
||||
return Result.error("Detail file delete fail.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
if(detailPathList.isEmpty()) {
|
||||
log.error("DETAIL FILE NOT FOUND : " + invoiceNumber);
|
||||
} else {
|
||||
for (Path path : detailPathList) {
|
||||
log.info(path.toString());
|
||||
}
|
||||
try {
|
||||
File detailFile = new File(detailPathList.get(0).toString());
|
||||
if(detailFile.delete()) {
|
||||
log.info("Detail file {} delete successful.", detailPathList.get(0).toString());
|
||||
detailDeleted = true;
|
||||
} else {
|
||||
log.error("Detail file delete fail.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
log.info("Invoice files deleted.");
|
||||
return Result.ok("Invoice cancel successful.");
|
||||
return Result.ok("Invoice cancel successful." + (invoiceDeleted ? "" : " Failed to delete invoice file.") + (detailDeleted ? "" : " Failed to delete detail file."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a batch of invoices
|
||||
* @param ids list of invoice ids
|
||||
* @param invoiceNumbers list of invoice numbers
|
||||
* @param clientIds list of clients
|
||||
* @return result
|
||||
*/
|
||||
@PostMapping(value = "/cancelBatchInvoice")
|
||||
public Result<?> cancelBatchInvoice(@RequestParam("ids") List<String> ids, @RequestParam("invoiceNumbers") List<String> invoiceNumbers, @RequestParam("clientIds") List<String> clientIds) {
|
||||
|
||||
log.info("Cancelling invoices : {}", invoiceNumbers);
|
||||
platformOrderContentService.cancelBatchInvoice(invoiceNumbers);
|
||||
platformOrderService.cancelBatchInvoice(invoiceNumbers);
|
||||
savRefundService.cancelBatchInvoice(invoiceNumbers);
|
||||
shippingInvoiceService.delBatchMain(ids);
|
||||
log.info("Deleting invoice files ...");
|
||||
|
||||
for(int i = 0; i < ids.size(); i++) {
|
||||
String invoiceNumber = invoiceNumbers.get(i);
|
||||
String invoiceEntity = clientService.getClientEntity(clientIds.get(i));
|
||||
List<Path> invoicePathList = getPath(INVOICE_LOCATION, invoiceNumber, invoiceEntity);
|
||||
List<Path> detailPathList = getPath(INVOICE_DETAIL_LOCATION, invoiceNumber, invoiceEntity);
|
||||
|
||||
if(invoicePathList.isEmpty()) {
|
||||
log.error("FILE NOT FOUND : " + invoiceNumber + ", " + invoiceEntity);
|
||||
} else {
|
||||
for (Path path : invoicePathList) {
|
||||
log.info(path.toString());
|
||||
}
|
||||
try {
|
||||
File invoiceFile = new File(invoicePathList.get(0).toString());
|
||||
if(invoiceFile.delete()) {
|
||||
log.info("Invoice file {} delete successful.", invoicePathList.get(0).toString());
|
||||
} else {
|
||||
log.error("Invoice file delete fail.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(detailPathList.isEmpty()) {
|
||||
log.error("DETAIL FILE NOT FOUND : " + invoiceNumber + ", " + invoiceEntity);
|
||||
} else {
|
||||
for (Path path : detailPathList) {
|
||||
log.info(path.toString());
|
||||
}
|
||||
try {
|
||||
File detailFile = new File(detailPathList.get(0).toString());
|
||||
if(detailFile.delete()) {
|
||||
log.info("Detail file {} delete successful.", detailPathList.get(0).toString());
|
||||
} else {
|
||||
log.error("Detail file {} delete fail.", detailPathList.get(0).toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("End of invoice files deletion.");
|
||||
return Result.ok("Invoices cancellation finished.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -663,7 +663,7 @@ public class ShippingInvoiceFactory {
|
|||
}
|
||||
}
|
||||
if (channel == null) {
|
||||
String format = "Can not find propre channel for" +
|
||||
String format = "Can not find propre channel for " +
|
||||
"package Serial No: %s, delivered at %s, " +
|
||||
"weight: %s, channel name: %s, destination: %s";
|
||||
String msg = String.format(
|
||||
|
@ -685,7 +685,7 @@ public class ShippingInvoiceFactory {
|
|||
.max(Comparator.comparing(LogisticChannelPrice::getEffectiveDate));
|
||||
price = priceCandidate.orElse(null);
|
||||
if (price == null) {
|
||||
String format = "Can not find propre channel price for" +
|
||||
String format = "Can not find proper channel price for " +
|
||||
"package Serial No: %s, delivered at %s, " +
|
||||
"weight: %s, channel name: %s, destination: %s";
|
||||
String msg = String.format(
|
||||
|
@ -783,9 +783,11 @@ public class ShippingInvoiceFactory {
|
|||
// Calculate total amounts
|
||||
invoice.tableData();
|
||||
estimations.add(new ShippingFeesEstimation(
|
||||
client.getInternalCode(), shop.getErpCode(), 0, orders.entrySet().size(), invoice.getTotalAmount()));
|
||||
client.getInternalCode(), shop.getErpCode(), 0, orders.entrySet().size(), invoice.getTotalAmount(), client.getIsCompleteInvoice(), ""));
|
||||
} catch (UserException e) {
|
||||
log.error("Couldn't calculate all fees for shop {} for following reason {}", shop.getErpCode(), e.getMessage());
|
||||
estimations.add(new ShippingFeesEstimation(
|
||||
client.getInternalCode(), shop.getErpCode(), 0, orders.entrySet().size(), BigDecimal.ZERO, client.getIsCompleteInvoice(), e.getMessage()));
|
||||
errorMessages.add(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -839,7 +841,7 @@ public class ShippingInvoiceFactory {
|
|||
// Calculate total amounts
|
||||
invoice.tableData();
|
||||
estimations.add(new ShippingFeesEstimation(
|
||||
client.getInternalCode(), shop.getErpCode(), 0, orders.entrySet().size(), invoice.getTotalAmount()));
|
||||
client.getInternalCode(), shop.getErpCode(), 0, orders.entrySet().size(), invoice.getTotalAmount(), client.getIsCompleteInvoice(), ""));
|
||||
} catch (UserException e) {
|
||||
log.error("Couldn't calculate all fees for shop {} for following reason {}", shop.getErpCode(), e.getMessage());
|
||||
errorMessages.add(e.getMessage());
|
||||
|
|
|
@ -181,6 +181,9 @@ public class Client implements Serializable {
|
|||
@ApiModelProperty(value = "是否活跃")
|
||||
private String active;
|
||||
|
||||
@Excel(name = "是否完整发票", width = 15)
|
||||
@ApiModelProperty(value = "完整发票")
|
||||
private String isCompleteInvoice;
|
||||
public String fullName() {
|
||||
return firstName + " " + surname;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ import org.apache.ibatis.annotations.Param;
|
|||
import org.jeecg.modules.business.entity.Client;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 客户
|
||||
* @Author: jeecg-boot
|
||||
|
@ -15,4 +18,6 @@ import org.springframework.stereotype.Repository;
|
|||
public interface ClientMapper extends BaseMapper<Client> {
|
||||
|
||||
String getClientEntity(@Param("id") String id);
|
||||
Map<String, String> getClientsEntity(@Param("ids") List<String> ids);
|
||||
String getClientByInternalCode(@Param("code") String code);
|
||||
}
|
||||
|
|
|
@ -74,4 +74,5 @@ public interface PlatformOrderContentMapper extends BaseMapper<PlatformOrderCont
|
|||
List<PlatformOrderContent> fetchPlatformOrderContentsToArchive(@Param("orderIDs") List<String> orderIDs);
|
||||
void insertPlatformOrderContentsArchives(@Param("orderContents") List<PlatformOrderContent> platformOrderContents);
|
||||
void cancelInvoice(@Param("invoiceNumber") String invoiceNumber);
|
||||
void cancelBatchInvoice(@Param("invoiceNumbers") List<String> invoiceNumbers);
|
||||
}
|
||||
|
|
|
@ -182,4 +182,5 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
|
|||
List<PlatformOrder> fetchOrdersToArchiveBeforeDate(@Param("endDate") String endDate);
|
||||
void insertPlatformOrdersArchives(@Param("orders") List<PlatformOrder> platformOrders);
|
||||
void cancelInvoice(@Param("invoiceNumber") String invoiceNumber);
|
||||
void cancelBatchInvoice(@Param("invoiceNumbers") List<String> invoiceNumbers);
|
||||
}
|
||||
|
|
|
@ -18,4 +18,5 @@ import java.util.List;
|
|||
public interface SavRefundMapper extends BaseMapper<SavRefund> {
|
||||
List<BigDecimal> fetchRefundAmount(@Param("invoiceNumber") String invoiceNumber);
|
||||
void cancelInvoice(@Param("invoiceNumber") String invoiceNumber);
|
||||
void cancelBatchInvoice(@Param("invoiceNumbers") List<String> invoiceNumbers);
|
||||
}
|
||||
|
|
|
@ -20,4 +20,6 @@ public interface ShopMapper extends BaseMapper<Shop> {
|
|||
public List<Shop> selectByMainId(@Param("mainId") String mainId);
|
||||
|
||||
List<Shop> selectByClient(@Param("clientID") String clientID);
|
||||
|
||||
List<String> selectShopIdByClient(@Param("clientID") String clientID);
|
||||
}
|
||||
|
|
|
@ -6,4 +6,17 @@
|
|||
FROM client
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
<select id="getClientsEntity" parameterType="java.lang.String" resultType="java.util.Map">
|
||||
SELECT id, invoice_entity
|
||||
FROM client
|
||||
WHERE id IN
|
||||
<foreach collection="ids" separator="," open="(" close=")" index="index" item="id">
|
||||
#{id}
|
||||
</foreach>;
|
||||
</select>
|
||||
<select id="getClientByInternalCode" parameterType="java.lang.String" resultType="java.lang.String">
|
||||
SELECT id
|
||||
FROM client
|
||||
WHERE internal_code = #{code}
|
||||
</select>
|
||||
</mapper>
|
|
@ -158,11 +158,10 @@
|
|||
<select id="findUninvoicedShippedOrderContents" resultType="org.jeecg.modules.business.entity.PlatformOrderContent">
|
||||
SELECT poc.*
|
||||
FROM platform_order_content poc
|
||||
JOIN platform_order po ON poc.platform_order_id = po.id
|
||||
JOIN shop s ON po.shop_id = s.id
|
||||
WHERE
|
||||
po.shipping_invoice_number IS NULL
|
||||
AND poc.erp_status = 3
|
||||
JOIN platform_order po ON poc.platform_order_id = po.id
|
||||
JOIN shop s ON po.shop_id = s.id
|
||||
WHERE po.shipping_invoice_number IS NULL
|
||||
AND poc.erp_status = 3
|
||||
</select>
|
||||
|
||||
<update id="batchUpdateForPurchase">
|
||||
|
@ -281,11 +280,25 @@
|
|||
</insert>
|
||||
<update id="cancelInvoice">
|
||||
UPDATE platform_order_content
|
||||
SET picking_fee = 0.0,
|
||||
SET picking_fee = 0.0,
|
||||
shipping_fee = NULL,
|
||||
service_fee = NULL,
|
||||
vat = NULL,
|
||||
purchase_fee = 0.0
|
||||
WHERE platform_order_id IN (SELECT id FROM platform_order WHERE shipping_invoice_number = #{invoiceNumber});
|
||||
</update>
|
||||
<update id="cancelBatchInvoice">
|
||||
UPDATE platform_order_content
|
||||
SET picking_fee = 0.0,
|
||||
shipping_fee = NULL,
|
||||
service_fee = NULL,
|
||||
vat = NULL,
|
||||
purchase_fee = 0.0
|
||||
WHERE platform_order_id IN
|
||||
(SELECT id FROM platform_order
|
||||
WHERE shipping_invoice_number IN
|
||||
<foreach collection="invoiceNumbers" separator="," open="(" close=")" index="index" item="invoiceNumber">
|
||||
#{invoiceNumber}
|
||||
</foreach>);
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -599,4 +599,16 @@
|
|||
packaging_material_fee = 0.0
|
||||
WHERE shipping_invoice_number = #{invoiceNumber};
|
||||
</update>
|
||||
<update id="cancelBatchInvoice">
|
||||
UPDATE platform_order
|
||||
SET fret_fee = NULL,
|
||||
order_service_fee = NULL,
|
||||
shipping_invoice_number = NULL,
|
||||
picking_fee = 0.0,
|
||||
packaging_material_fee = 0.0
|
||||
WHERE shipping_invoice_number IN
|
||||
<foreach collection="invoiceNumbers" separator="," open="(" close=")" index="index" item="invoiceNumber">
|
||||
#{invoiceNumber}
|
||||
</foreach>;
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -13,4 +13,14 @@
|
|||
total_refund_amount = 0.0
|
||||
WHERE invoice_number = #{invoiceNumber};
|
||||
</update>
|
||||
<update id="cancelBatchInvoice">
|
||||
UPDATE sav_refund
|
||||
SET invoice_number = NULL,
|
||||
refund_date = NULL,
|
||||
total_refund_amount = 0.0
|
||||
WHERE invoice_number IN
|
||||
<foreach collection="invoiceNumbers" separator="," open="(" close=")" index="index" item="invoiceNumber">
|
||||
#{invoiceNumber}
|
||||
</foreach>;
|
||||
</update>
|
||||
</mapper>
|
|
@ -17,4 +17,9 @@
|
|||
FROM shop
|
||||
WHERE owner_id = #{clientID} AND active = '1'
|
||||
</select>
|
||||
<select id="selectShopIdByClient" resultType="java.lang.String">
|
||||
SELECT shop.id
|
||||
FROM shop
|
||||
WHERE owner_id = #{clientID} AND active = '1'
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 客户
|
||||
|
@ -38,6 +39,8 @@ public interface IClientService extends IService<Client> {
|
|||
*/
|
||||
public void delBatchMain (Collection<? extends Serializable> idList);
|
||||
public String getClientEntity(String id);
|
||||
public Map<String, String> getClientsEntity(List<String> ids);
|
||||
public String getClientByInternalCode(String code);
|
||||
/**
|
||||
* Get current user's client information
|
||||
* @return client or null if current user's role is not client
|
||||
|
|
|
@ -48,4 +48,9 @@ public interface IPlatformOrderContentService extends IService<PlatformOrderCont
|
|||
* @param invoiceNumber
|
||||
*/
|
||||
void cancelInvoice(String invoiceNumber);
|
||||
/**
|
||||
* Cancels a batch of invoices
|
||||
* @param invoiceNumbers
|
||||
*/
|
||||
void cancelBatchInvoice(List<String> invoiceNumbers);
|
||||
}
|
||||
|
|
|
@ -171,4 +171,9 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
|
|||
* @param invoiceNumber
|
||||
*/
|
||||
void cancelInvoice(String invoiceNumber);
|
||||
/**
|
||||
* Cancel Invoice
|
||||
* @param invoiceNumbers
|
||||
*/
|
||||
void cancelBatchInvoice(List<String> invoiceNumbers);
|
||||
}
|
||||
|
|
|
@ -13,9 +13,15 @@ import java.util.List;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISavRefundService extends IService<SavRefund> {
|
||||
List<BigDecimal> getRefundAmount(String invoiceNumber);/**
|
||||
List<BigDecimal> getRefundAmount(String invoiceNumber);
|
||||
/**
|
||||
* Cancel Invoice
|
||||
* @param invoiceNumber
|
||||
*/
|
||||
void cancelInvoice(String invoiceNumber);
|
||||
/**
|
||||
* Cancel Batch Invoice
|
||||
* @param invoiceNumbers
|
||||
*/
|
||||
void cancelBatchInvoice(List<String> invoiceNumbers);
|
||||
}
|
||||
|
|
|
@ -15,4 +15,5 @@ public interface IShopService extends IService<Shop> {
|
|||
public List<Shop> selectByMainId(String mainId);
|
||||
|
||||
List<Shop> listByClient(String clientID);
|
||||
List<String> listIdByClient(String clientID);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.modules.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.modules.business.controller.UserException;
|
||||
|
@ -124,7 +125,10 @@ public class PlatformOrderShippingInvoiceService {
|
|||
Date endZoned = Date.from(ldt.atZone(paris).toInstant());
|
||||
return new Period(beginZoned, endZoned);
|
||||
}
|
||||
|
||||
public List<String> getShippingOrderIdBetweenDate(List<String> shops, String start, String end, List<String> wareHouses) {
|
||||
List<PlatformOrder> orders = platformOrderMapper.fetchUninvoicedShippedOrderIDInShops( start, end, shops, wareHouses);
|
||||
return orders.stream().map(PlatformOrder::getId).collect(Collectors.toList());
|
||||
}
|
||||
/**
|
||||
* Make an invoice based on parameters.
|
||||
*
|
||||
|
@ -179,7 +183,7 @@ public class PlatformOrderShippingInvoiceService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Make a complete pre-shipping (purchase + shipping) invoice for specified orders
|
||||
* Make a complete shipping invoice (purchase + shipping) invoice for specified orders and order statuses
|
||||
*
|
||||
* @param param the parameters to make the invoice
|
||||
* @return name of the invoice, can be used to in {@code getInvoiceBinary}.
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 客户
|
||||
|
@ -121,4 +122,13 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme
|
|||
public String getClientEntity(String id) {
|
||||
return clientMapper.getClientEntity(id);
|
||||
}
|
||||
@Override
|
||||
public Map<String, String> getClientsEntity(List<String> ids) {
|
||||
return clientMapper.getClientsEntity(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientByInternalCode(String code) {
|
||||
return clientMapper.getClientByInternalCode(code);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,4 +66,8 @@ public class PlatformOrderContentServiceImpl extends ServiceImpl<PlatformOrderCo
|
|||
public void cancelInvoice(String invoiceNumber) {
|
||||
platformOrderContentMapper.cancelInvoice(invoiceNumber);
|
||||
}
|
||||
@Override
|
||||
public void cancelBatchInvoice(List<String> invoiceNumbers) {
|
||||
platformOrderContentMapper.cancelBatchInvoice(invoiceNumbers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -382,4 +382,8 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
|||
public void cancelInvoice(String invoiceNumber) {
|
||||
platformOrderMap.cancelInvoice(invoiceNumber);
|
||||
}
|
||||
@Override
|
||||
public void cancelBatchInvoice(List<String> invoiceNumbers) {
|
||||
platformOrderMap.cancelBatchInvoice(invoiceNumbers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,4 +36,8 @@ public class SavRefundServiceImpl extends ServiceImpl<SavRefundMapper, SavRefund
|
|||
public void cancelInvoice(String invoiceNumber) {
|
||||
savRefundMapper.cancelInvoice(invoiceNumber);
|
||||
}
|
||||
@Override
|
||||
public void cancelBatchInvoice(List<String> invoiceNumbers) {
|
||||
savRefundMapper.cancelBatchInvoice(invoiceNumbers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,4 +29,8 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IS
|
|||
public List<Shop> listByClient(String clientID) {
|
||||
return shopMapper.selectByClient(clientID);
|
||||
}
|
||||
@Override
|
||||
public List<String> listIdByClient(String clientID) {
|
||||
return shopMapper.selectShopIdByClient(clientID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.business.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -7,13 +8,31 @@ import java.math.BigDecimal;
|
|||
@Data
|
||||
public class ShippingFeesEstimation {
|
||||
|
||||
private final String code;
|
||||
private String code;
|
||||
|
||||
private final String shop;
|
||||
private String shop;
|
||||
|
||||
private final Integer ordersToProcess;
|
||||
private Integer ordersToProcess;
|
||||
|
||||
private final Integer processedOrders;
|
||||
private Integer processedOrders;
|
||||
|
||||
private final BigDecimal dueForProcessedOrders;
|
||||
private BigDecimal dueForProcessedOrders;
|
||||
|
||||
private String isCompleteInvoice;
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
public ShippingFeesEstimation(@JsonProperty("code") String code, @JsonProperty("shop")String shop,
|
||||
@JsonProperty("ordersToProcess")Integer ordersToProcess, @JsonProperty("processedOrders")Integer processedOrders,
|
||||
@JsonProperty("dueForProcessedOrders")BigDecimal dueForProcessedOrders,
|
||||
@JsonProperty("isCompleteInvoice")String isCompleteInvoice,
|
||||
@JsonProperty(value = "errorMessage")String errorMessage) {
|
||||
this.code = code;
|
||||
this.shop = shop;
|
||||
this.ordersToProcess = ordersToProcess;
|
||||
this.processedOrders = processedOrders;
|
||||
this.dueForProcessedOrders = dueForProcessedOrders;
|
||||
this.isCompleteInvoice = isCompleteInvoice;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package org.jeecg.modules.business.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class ShippingFeesEstimationClient {
|
||||
private final String clientId;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final Integer ordersToProcess;
|
||||
|
||||
private final Integer processedOrders;
|
||||
|
||||
private final BigDecimal dueForProcessedOrders;
|
||||
|
||||
private final String isCompleteInvoice;
|
||||
|
||||
private final Integer hasErrors;
|
||||
}
|
Loading…
Reference in New Issue