mirror of https://github.com/jeecgboot/jeecg-boot
commit
886ba778a8
|
@ -29,6 +29,7 @@ import org.jeecg.modules.quartz.service.IQuartzJobService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.dao.CannotAcquireLockException;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
||||||
|
@ -269,7 +270,7 @@ public class InvoiceController {
|
||||||
} catch (IOException | ParseException e) {
|
} catch (IOException | ParseException e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
return Result.error("Sorry, server error, please try later");
|
return Result.error("Sorry, server error, please try later");
|
||||||
} catch (MessagingException e) {
|
} catch (MessagingException | InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,7 +439,7 @@ public class InvoiceController {
|
||||||
} catch (IOException | ParseException e) {
|
} catch (IOException | ParseException e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
return Result.error("Sorry, server error, please try later");
|
return Result.error("Sorry, server error, please try later");
|
||||||
} catch (MessagingException | TemplateException e) {
|
} catch (MessagingException | TemplateException | InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1356,4 +1357,24 @@ public class InvoiceController {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@PostMapping("/editOrderTest")
|
||||||
|
public Result<?> editOrderTest(@RequestBody Map<String, String> params) {
|
||||||
|
System.out.println("Edit Order Test : " + params.get("orderId"));
|
||||||
|
String orderId = params.get("orderId");
|
||||||
|
try {
|
||||||
|
PlatformOrder orderToEdit = platformOrderService.selectForUpdateSkipLock(orderId);
|
||||||
|
|
||||||
|
if(orderToEdit == null) {
|
||||||
|
return Result.error(404,"Order not found.");
|
||||||
|
}
|
||||||
|
orderToEdit.setCanSend("2");
|
||||||
|
boolean edited = platformOrderService.updateById(orderToEdit);
|
||||||
|
return Result.OK(edited);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if(e instanceof CannotAcquireLockException) {
|
||||||
|
return Result.error(409,"Order is already being edited by another user.");
|
||||||
|
}
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class ShippingInvoiceFactory {
|
||||||
public ShippingInvoice createShippingInvoice(String customerId, List<String> orderIds, String type, String start, String end) throws UserException {
|
public ShippingInvoice createShippingInvoice(String customerId, List<String> orderIds, String type, String start, String end) throws UserException {
|
||||||
log.info("Creating an invoice with arguments:\n client ID: {}, order IDs: {}]", customerId, orderIds);
|
log.info("Creating an invoice with arguments:\n client ID: {}, order IDs: {}]", customerId, orderIds);
|
||||||
// find orders and their contents of the invoice
|
// find orders and their contents of the invoice
|
||||||
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderData(orderIds);
|
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderDataForUpdate(orderIds);
|
||||||
Set<PlatformOrder> platformOrders = uninvoicedOrderToContent.keySet();
|
Set<PlatformOrder> platformOrders = uninvoicedOrderToContent.keySet();
|
||||||
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
|
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
|
||||||
List<String> shopIds = platformOrders.stream()
|
List<String> shopIds = platformOrders.stream()
|
||||||
|
@ -166,10 +166,10 @@ public class ShippingInvoiceFactory {
|
||||||
* channel price, this exception will be thrown.
|
* channel price, this exception will be thrown.
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public CompleteInvoice createCompleteShippingInvoice(String username, String customerId, BigDecimal balance, List<String> orderIds, String shippingMethod, String start, String end) throws UserException, MessagingException {
|
public CompleteInvoice createCompleteShippingInvoice(String username, String customerId, BigDecimal balance, List<String> orderIds, String shippingMethod, String start, String end) throws UserException, MessagingException, InterruptedException {
|
||||||
log.info("Creating a complete invoice for \n client ID: {}, order IDs: {}]", customerId, orderIds);
|
log.info("Creating a complete invoice for \n client ID: {}, order IDs: {}]", customerId, orderIds);
|
||||||
// find orders and their contents of the invoice
|
// find orders and their contents of the invoice
|
||||||
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderData(orderIds);
|
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderDataForUpdate(orderIds);
|
||||||
Set<PlatformOrder> platformOrders = uninvoicedOrderToContent.keySet();
|
Set<PlatformOrder> platformOrders = uninvoicedOrderToContent.keySet();
|
||||||
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
|
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
|
||||||
List<String> shopIds = platformOrders.stream()
|
List<String> shopIds = platformOrders.stream()
|
||||||
|
|
|
@ -46,7 +46,9 @@ public interface PlatformOrderContentMapper extends BaseMapper<PlatformOrderCont
|
||||||
* @param orderIds Order IDs
|
* @param orderIds Order IDs
|
||||||
* @return order contents
|
* @return order contents
|
||||||
*/
|
*/
|
||||||
|
// TODO : check all usage and update if need to use FOR UPDATE instead
|
||||||
List<PlatformOrderContent> fetchOrderContent(List<String> orderIds);
|
List<PlatformOrderContent> fetchOrderContent(List<String> orderIds);
|
||||||
|
List<PlatformOrderContent> fetchOrderContentForUpdate(List<String> orderIds);
|
||||||
|
|
||||||
List<SkuDetail> searchSkuDetail(List<String> skuIDs);
|
List<SkuDetail> searchSkuDetail(List<String> skuIDs);
|
||||||
|
|
||||||
|
@ -84,4 +86,5 @@ public interface PlatformOrderContentMapper extends BaseMapper<PlatformOrderCont
|
||||||
List<ShoumanOrderContent> searchShoumanOrderContent();
|
List<ShoumanOrderContent> searchShoumanOrderContent();
|
||||||
|
|
||||||
List<ShoumanOrderContent> searchShoumanOrderContentByPlatformOrderId(@Param("platformOrderId") String platformOrderId);
|
List<ShoumanOrderContent> searchShoumanOrderContentByPlatformOrderId(@Param("platformOrderId") String platformOrderId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.business.mapper;
|
package org.jeecg.modules.business.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.MapKey;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.jeecg.modules.business.domain.api.mabang.getorderlist.Order;
|
import org.jeecg.modules.business.domain.api.mabang.getorderlist.Order;
|
||||||
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberData;
|
import org.jeecg.modules.business.domain.api.yd.YDTrackingNumberData;
|
||||||
|
@ -171,12 +172,12 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
|
||||||
List<PlatformOrderShopSync> fetchOrderInShopsWithoutShopifyNote(@Param("shops") List<String> shopCodes);
|
List<PlatformOrderShopSync> fetchOrderInShopsWithoutShopifyNote(@Param("shops") List<String> shopCodes);
|
||||||
List<PlatformOrder> fetchOrderInShopsReadyForAbnNumberJob(@Param("shops") List<String> shopCodes);
|
List<PlatformOrder> fetchOrderInShopsReadyForAbnNumberJob(@Param("shops") List<String> shopCodes);
|
||||||
|
|
||||||
List<PlatformOrder> fetchUninvoicedShippedOrderIDInShops(@Param("startDate") String startDate,
|
List<String> fetchUninvoicedShippedOrderIDInShops(@Param("startDate") String startDate,
|
||||||
@Param("endDate") String endDate,
|
@Param("endDate") String endDate,
|
||||||
@Param("shops") List<String> shops,
|
@Param("shops") List<String> shops,
|
||||||
@Param("warehouses") List<String> warehouses);
|
@Param("warehouses") List<String> warehouses);
|
||||||
|
|
||||||
List<PlatformOrder> fetchUninvoicedOrderIDInShopsAndOrderTime(@Param("startDate") String startDate,
|
List<String> fetchUninvoicedOrderIDInShopsAndOrderTime(@Param("startDate") String startDate,
|
||||||
@Param("endDate") String endDate,
|
@Param("endDate") String endDate,
|
||||||
@Param("shops") List<String> shops,
|
@Param("shops") List<String> shops,
|
||||||
@Param("erpStatuses") List<Integer> erpStatuses,
|
@Param("erpStatuses") List<Integer> erpStatuses,
|
||||||
|
@ -255,4 +256,8 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
|
||||||
@Param("start") String startDate, @Param("end") String endDate,
|
@Param("start") String startDate, @Param("end") String endDate,
|
||||||
@Param("order") String order, @Param("column") String column,
|
@Param("order") String order, @Param("column") String column,
|
||||||
@Param("offset") Integer offset, @Param("size") Integer pageSize);
|
@Param("offset") Integer offset, @Param("size") Integer pageSize);
|
||||||
|
@MapKey("id")
|
||||||
|
Map<String, PlatformOrder> selectBatchIdsForUpdate(@Param("ids") List<String> orderIds);
|
||||||
|
|
||||||
|
PlatformOrder selectForUpdateSkipLock(@Param("id") String orderId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,14 @@
|
||||||
WHERE erp_status <> 5
|
WHERE erp_status <> 5
|
||||||
AND platform_order_id IN <foreach collection="list" index="i" item="item" open="(" separator="," close=")">#{item}</foreach>
|
AND platform_order_id IN <foreach collection="list" index="i" item="item" open="(" separator="," close=")">#{item}</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="fetchOrderContentForUpdate" parameterType="java.lang.String"
|
||||||
|
resultType="org.jeecg.modules.business.entity.PlatformOrderContent">
|
||||||
|
SELECT *
|
||||||
|
FROM platform_order_content
|
||||||
|
WHERE erp_status <> 5
|
||||||
|
AND platform_order_id IN <foreach collection="list" index="i" item="item" open="(" separator="," close=")">#{item}</foreach>
|
||||||
|
FOR UPDATE;
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="searchSkuDetail"
|
<select id="searchSkuDetail"
|
||||||
resultType="org.jeecg.modules.business.vo.SkuDetail"
|
resultType="org.jeecg.modules.business.vo.SkuDetail"
|
||||||
|
@ -158,6 +166,7 @@
|
||||||
separator=",">
|
separator=",">
|
||||||
#{erpStatus}
|
#{erpStatus}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
FOR UPDATE;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findUninvoicedShippedOrderContents" resultType="org.jeecg.modules.business.entity.PlatformOrderContent">
|
<select id="findUninvoicedShippedOrderContents" resultType="org.jeecg.modules.business.entity.PlatformOrderContent">
|
||||||
|
|
|
@ -163,7 +163,8 @@
|
||||||
AND shipping_time >= #{begin}
|
AND shipping_time >= #{begin}
|
||||||
AND #{end} >= shipping_time
|
AND #{end} >= shipping_time
|
||||||
AND shipping_invoice_number IS NULL
|
AND shipping_invoice_number IS NULL
|
||||||
AND erp_status = 3;
|
AND erp_status = 3
|
||||||
|
FOR UPDATE;
|
||||||
</select>
|
</select>
|
||||||
<select id="findUninvoicedOrdersForShopsAndStatus" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
<select id="findUninvoicedOrdersForShopsAndStatus" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -193,6 +194,7 @@
|
||||||
>
|
>
|
||||||
#{erpStatus}
|
#{erpStatus}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
FOR UPDATE
|
||||||
;
|
;
|
||||||
</select>
|
</select>
|
||||||
<select id="findUninvoicedShippedOrders" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
<select id="findUninvoicedShippedOrders" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
||||||
|
@ -508,7 +510,7 @@
|
||||||
ORDER BY order_time;
|
ORDER BY order_time;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="fetchUninvoicedShippedOrderIDInShops" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
<select id="fetchUninvoicedShippedOrderIDInShops" resultType="java.lang.String">
|
||||||
SELECT po.id
|
SELECT po.id
|
||||||
FROM platform_order po
|
FROM platform_order po
|
||||||
JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name
|
JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name
|
||||||
|
@ -538,7 +540,7 @@
|
||||||
AND po.shipping_time between #{startDate} AND #{endDate}
|
AND po.shipping_time between #{startDate} AND #{endDate}
|
||||||
AND po.erp_status = 3;
|
AND po.erp_status = 3;
|
||||||
</select>
|
</select>
|
||||||
<select id="fetchUninvoicedOrderIDInShopsAndOrderTime" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
<select id="fetchUninvoicedOrderIDInShopsAndOrderTime" resultType="java.lang.String">
|
||||||
SELECT po.id
|
SELECT po.id
|
||||||
FROM platform_order po
|
FROM platform_order po
|
||||||
JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name
|
JOIN logistic_channel lc ON po.logistic_channel_name = lc.zh_name
|
||||||
|
@ -576,7 +578,8 @@
|
||||||
item="erpStatus"
|
item="erpStatus"
|
||||||
>
|
>
|
||||||
#{erpStatus}
|
#{erpStatus}
|
||||||
</foreach>;
|
</foreach>
|
||||||
|
FOR UPDATE;
|
||||||
</select>
|
</select>
|
||||||
<select id="fetchOrdersToArchiveBetweenDate" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
<select id="fetchOrdersToArchiveBetweenDate" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
||||||
SELECT *
|
SELECT *
|
||||||
|
@ -1380,4 +1383,17 @@
|
||||||
END as has_desynced_sku
|
END as has_desynced_sku
|
||||||
FROM orders
|
FROM orders
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectBatchIdsForUpdate" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
||||||
|
SELECT * FROM platform_order
|
||||||
|
WHERE id IN
|
||||||
|
<foreach collection="ids" separator="," open="(" close=")" index="index" item="id">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
FOR UPDATE;
|
||||||
|
</select>
|
||||||
|
<select id="selectForUpdateSkipLock" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
||||||
|
SELECT * FROM platform_order
|
||||||
|
WHERE id = #{id}
|
||||||
|
FOR UPDATE;
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -108,6 +108,8 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
|
||||||
*/
|
*/
|
||||||
Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderData(List<String> orderIds);
|
Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderData(List<String> orderIds);
|
||||||
|
|
||||||
|
Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataForUpdate(List<String> orderIds);
|
||||||
|
|
||||||
Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataByInvoiceCode(String invoiceCode);
|
Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataByInvoiceCode(String invoiceCode);
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,8 +152,6 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
|
||||||
|
|
||||||
List<PlatformOrder> fetchOrderInShopsReadyForAbnNumberJob(List<String> shopCodes);
|
List<PlatformOrder> fetchOrderInShopsReadyForAbnNumberJob(List<String> shopCodes);
|
||||||
|
|
||||||
List<PlatformOrder> fetchUninvoicedShippedOrderIDInShops(String startDate, String endDate, List<String> shops, List<String> warehouses);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all platform orders between 2 dates and of status erp_status 4 or 5
|
* Fetch all platform orders between 2 dates and of status erp_status 4 or 5
|
||||||
* this list will then be archived
|
* this list will then be archived
|
||||||
|
@ -293,4 +293,6 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
|
||||||
List<PlatformOrderFront> listByClientAndShops(String clientId, List<String> shopIds, String startDate, String endDate, String invoicingMethod, Integer pageNo, Integer pageSize, List<String> warehouses, String order, String column);
|
List<PlatformOrderFront> listByClientAndShops(String clientId, List<String> shopIds, String startDate, String endDate, String invoicingMethod, Integer pageNo, Integer pageSize, List<String> warehouses, String order, String column);
|
||||||
|
|
||||||
int countListByClientAndShops(String clientId, List<String> shopIDs, String start, String end, String invoicingMethod, List<String> warehouses);
|
int countListByClientAndShops(String clientId, List<String> shopIDs, String start, String end, String invoicingMethod, List<String> warehouses);
|
||||||
|
|
||||||
|
PlatformOrder selectForUpdateSkipLock(String orderId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,8 +207,7 @@ public class PlatformOrderShippingInvoiceService {
|
||||||
return new Period(beginZoned, endZoned, "");
|
return new Period(beginZoned, endZoned, "");
|
||||||
}
|
}
|
||||||
public List<String> getShippingOrderIdBetweenDate(List<String> shops, String start, String end, List<String> wareHouses) {
|
public List<String> getShippingOrderIdBetweenDate(List<String> shops, String start, String end, List<String> wareHouses) {
|
||||||
List<PlatformOrder> orders = platformOrderMapper.fetchUninvoicedShippedOrderIDInShops( start, end, shops, wareHouses);
|
return platformOrderMapper.fetchUninvoicedShippedOrderIDInShops( start, end, shops, wareHouses);
|
||||||
return orders.stream().map(PlatformOrder::getId).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Make an invoice based on parameters.
|
* Make an invoice based on parameters.
|
||||||
|
@ -265,7 +264,7 @@ public class PlatformOrderShippingInvoiceService {
|
||||||
* @throws IOException exception related to invoice file IO.
|
* @throws IOException exception related to invoice file IO.
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public InvoiceMetaData makeCompleteInvoice(ShippingInvoiceOrderParam param) throws UserException, ParseException, IOException, MessagingException {
|
public InvoiceMetaData makeCompleteInvoice(ShippingInvoiceOrderParam param) throws UserException, ParseException, IOException, MessagingException, InterruptedException {
|
||||||
String username = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername();
|
String username = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername();
|
||||||
// Creates invoice by factory
|
// Creates invoice by factory
|
||||||
CompleteInvoice invoice = factory.createCompleteShippingInvoice(username, param.clientID(), null, param.orderIds(), param.getType(), param.getStart(), param.getEnd());
|
CompleteInvoice invoice = factory.createCompleteShippingInvoice(username, param.clientID(), null, param.orderIds(), param.getType(), param.getStart(), param.getEnd());
|
||||||
|
@ -282,18 +281,16 @@ public class PlatformOrderShippingInvoiceService {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public InvoiceMetaData makeCompleteInvoicePostShipping(ShippingInvoiceParam param, String method, String ... user) throws UserException, ParseException, IOException, MessagingException {
|
public InvoiceMetaData makeCompleteInvoicePostShipping(ShippingInvoiceParam param, String method, String ... user) throws UserException, ParseException, IOException, MessagingException, InterruptedException {
|
||||||
String username = user.length > 0 ? user[0] : ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername();
|
String username = user.length > 0 ? user[0] : ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername();
|
||||||
List<PlatformOrder> platformOrderList;
|
List<String> orderIds;
|
||||||
if(method.equals(POSTSHIPPING.getMethod())) {
|
if(method.equals(POSTSHIPPING.getMethod())) {
|
||||||
//On récupère les commandes entre 2 dates d'expédition avec un status 3
|
//On récupère les commandes entre 2 dates d'expédition avec un status 3
|
||||||
platformOrderList = platformOrderMapper.fetchUninvoicedShippedOrderIDInShops(param.getStart(), param.getEnd(), param.shopIDs(), param.getWarehouses());
|
orderIds = platformOrderMapper.fetchUninvoicedShippedOrderIDInShops(param.getStart(), param.getEnd(), param.shopIDs(), param.getWarehouses());
|
||||||
} else {
|
} else {
|
||||||
// On récupère les commandes entre 2 dates de commandes avec un status (1,2) ou (1,2,3)
|
// On récupère les commandes entre 2 dates de commandes avec un status (1,2) ou (1,2,3)
|
||||||
platformOrderList = platformOrderMapper.fetchUninvoicedOrderIDInShopsAndOrderTime(param.getStart(), param.getEnd(), param.shopIDs(), param.getErpStatuses(), param.getWarehouses());
|
orderIds = platformOrderMapper.fetchUninvoicedOrderIDInShopsAndOrderTime(param.getStart(), param.getEnd(), param.shopIDs(), param.getErpStatuses(), param.getWarehouses());
|
||||||
}
|
}
|
||||||
// on récupère seulement les ID des commandes
|
|
||||||
List<String> orderIds = platformOrderList.stream().map(PlatformOrder::getId).collect(Collectors.toList());
|
|
||||||
// Creates invoice by factory
|
// Creates invoice by factory
|
||||||
CompleteInvoice invoice = factory.createCompleteShippingInvoice(username, param.clientID(), param.getBalance() ,orderIds, method, param.getStart(), param.getEnd());
|
CompleteInvoice invoice = factory.createCompleteShippingInvoice(username, param.clientID(), param.getBalance() ,orderIds, method, param.getStart(), param.getEnd());
|
||||||
return getInvoiceMetaDataAndInsert(username, invoice);
|
return getInvoiceMetaDataAndInsert(username, invoice);
|
||||||
|
@ -711,6 +708,8 @@ public class PlatformOrderShippingInvoiceService {
|
||||||
String internalCode = entry.getKey().getClient().getInternalCode();
|
String internalCode = entry.getKey().getClient().getInternalCode();
|
||||||
invoiceList.add(new InvoiceMetaData("", "error", internalCode, clientId, e.getMessage()));
|
invoiceList.add(new InvoiceMetaData("", "error", internalCode, clientId, e.getMessage()));
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,11 +155,13 @@ public class PlatformOrderMabangServiceImpl extends ServiceImpl<PlatformOrderMab
|
||||||
try {
|
try {
|
||||||
if (!oldOrders.isEmpty()) {
|
if (!oldOrders.isEmpty()) {
|
||||||
log.info("{} orders to be inserted/updated.", oldOrders.size());
|
log.info("{} orders to be inserted/updated.", oldOrders.size());
|
||||||
|
platformOrderService.fetchOrderDataForUpdate(oldOrders.stream().map(Order::getId).collect(toList()));
|
||||||
platformOrderMabangMapper.batchUpdateById(oldOrders);
|
platformOrderMabangMapper.batchUpdateById(oldOrders);
|
||||||
platformOrderMabangMapper.batchDeleteByMainID(oldOrders.stream().map(Order::getId).collect(toList()));
|
platformOrderMabangMapper.batchDeleteByMainID(oldOrders.stream().map(Order::getId).collect(toList()));
|
||||||
}
|
}
|
||||||
if (!ordersFromShippedToCompleted.isEmpty()) {
|
if (!ordersFromShippedToCompleted.isEmpty()) {
|
||||||
log.info("{} orders to be updated from Shipped to Completed.", ordersFromShippedToCompleted.size());
|
log.info("{} orders to be updated from Shipped to Completed.", ordersFromShippedToCompleted.size());
|
||||||
|
platformOrderService.fetchOrderDataForUpdate(ordersFromShippedToCompleted.stream().map(Order::getId).collect(toList()));
|
||||||
platformOrderMabangMapper.batchUpdateById(ordersFromShippedToCompleted);
|
platformOrderMabangMapper.batchUpdateById(ordersFromShippedToCompleted);
|
||||||
log.info("Contents of {} orders to be updated from Shipped to Completed.", ordersFromShippedToCompleted.size());
|
log.info("Contents of {} orders to be updated from Shipped to Completed.", ordersFromShippedToCompleted.size());
|
||||||
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
||||||
|
@ -168,6 +170,7 @@ public class PlatformOrderMabangServiceImpl extends ServiceImpl<PlatformOrderMab
|
||||||
}
|
}
|
||||||
if (!invoicedShippedOrders.isEmpty()) {
|
if (!invoicedShippedOrders.isEmpty()) {
|
||||||
log.info("{} orders to be updated from Pending/Preparing to Shipped.", invoicedShippedOrders.size());
|
log.info("{} orders to be updated from Pending/Preparing to Shipped.", invoicedShippedOrders.size());
|
||||||
|
platformOrderService.fetchOrderDataForUpdate(invoicedShippedOrders.stream().map(Order::getId).collect(toList()));
|
||||||
platformOrderMabangMapper.batchUpdateById(invoicedShippedOrders);
|
platformOrderMabangMapper.batchUpdateById(invoicedShippedOrders);
|
||||||
log.info("Contents of {} orders to be updated from Pending/Preparing to Shipped.", invoicedShippedOrders.size());
|
log.info("Contents of {} orders to be updated from Pending/Preparing to Shipped.", invoicedShippedOrders.size());
|
||||||
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
||||||
|
@ -176,6 +179,7 @@ public class PlatformOrderMabangServiceImpl extends ServiceImpl<PlatformOrderMab
|
||||||
}
|
}
|
||||||
if (!obsoleteOrders.isEmpty()) {
|
if (!obsoleteOrders.isEmpty()) {
|
||||||
log.info("{} orders to become obsolete.", obsoleteOrders.size());
|
log.info("{} orders to become obsolete.", obsoleteOrders.size());
|
||||||
|
platformOrderService.fetchOrderDataForUpdate(obsoleteOrders.stream().map(Order::getId).collect(toList()));
|
||||||
platformOrderMabangMapper.batchUpdateById(obsoleteOrders);
|
platformOrderMabangMapper.batchUpdateById(obsoleteOrders);
|
||||||
log.info("Contents of {} orders to be updated to Obsolete.", obsoleteOrders.size());
|
log.info("Contents of {} orders to be updated to Obsolete.", obsoleteOrders.size());
|
||||||
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
||||||
|
|
|
@ -37,7 +37,6 @@ import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.*;
|
import static java.util.stream.Collectors.*;
|
||||||
import static org.jeecg.modules.business.entity.Invoice.InvoicingMethod.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 平台订单表
|
* @Description: 平台订单表
|
||||||
|
@ -276,11 +275,10 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
||||||
return platformOrderMap.queryQuantities(client.getId());
|
return platformOrderMap.queryQuantities(client.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<PlatformOrder, List<PlatformOrderContent>> findUninvoicedOrders(List<String> shopIds, Date begin, Date end, List<String> warehouses) {
|
public Map<PlatformOrder, List<PlatformOrderContent>> findUninvoicedOrders(List<String> shopIds, Date begin, Date end, List<String> warehouses) {
|
||||||
List<PlatformOrder> orderList = platformOrderMap.findUninvoicedOrders(shopIds, begin, end, warehouses);
|
List<PlatformOrder> orderList = platformOrderMap.findUninvoicedOrders(shopIds, begin, end, warehouses);
|
||||||
List<PlatformOrderContent> orderContents = platformOrderContentMap.fetchOrderContent(orderList.stream().map(PlatformOrder::getId).collect(toList()));
|
List<PlatformOrderContent> orderContents = platformOrderContentMap.fetchOrderContentForUpdate(orderList.stream().map(PlatformOrder::getId).collect(toList()));
|
||||||
Map<String, PlatformOrder> orderMap = orderList.stream().collect(toMap(PlatformOrder::getId, Function.identity()));
|
Map<String, PlatformOrder> orderMap = orderList.stream().collect(toMap(PlatformOrder::getId, Function.identity()));
|
||||||
return orderContents.stream().collect(groupingBy(platformOrderContent -> orderMap.get(platformOrderContent.getPlatformOrderId())));
|
return orderContents.stream().collect(groupingBy(platformOrderContent -> orderMap.get(platformOrderContent.getPlatformOrderId())));
|
||||||
}
|
}
|
||||||
|
@ -315,6 +313,12 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
||||||
return orderContents.stream().collect(groupingBy(platformOrderContent -> orderMap.get(platformOrderContent.getPlatformOrderId())));
|
return orderContents.stream().collect(groupingBy(platformOrderContent -> orderMap.get(platformOrderContent.getPlatformOrderId())));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
public Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataForUpdate(List<String> orderIds) {
|
||||||
|
Map<String, PlatformOrder> ordersMapById = platformOrderMap.selectBatchIdsForUpdate(orderIds);
|
||||||
|
List<PlatformOrderContent> orderContents = platformOrderContentMap.fetchOrderContentForUpdate(orderIds);
|
||||||
|
return orderContents.stream().collect(groupingBy(platformOrderContent -> ordersMapById.get(platformOrderContent.getPlatformOrderId())));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
public Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataByInvoiceCode(String invoiceCode) {
|
public Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataByInvoiceCode(String invoiceCode) {
|
||||||
List<PlatformOrder> orderList = platformOrderMap.getPlatformOrdersByInvoiceNumber(invoiceCode);
|
List<PlatformOrder> orderList = platformOrderMap.getPlatformOrdersByInvoiceNumber(invoiceCode);
|
||||||
List<String> orderIds = orderList.stream().map(PlatformOrder::getId).collect(toList());
|
List<String> orderIds = orderList.stream().map(PlatformOrder::getId).collect(toList());
|
||||||
|
@ -394,10 +398,6 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
||||||
return platformOrderMap.fetchOrderInShopsReadyForAbnNumberJob(shopCodes);
|
return platformOrderMap.fetchOrderInShopsReadyForAbnNumberJob(shopCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<PlatformOrder> fetchUninvoicedShippedOrderIDInShops(String startDate, String endDate, List<String> shops, List<String> warehouses) {
|
|
||||||
return platformOrderMap.fetchUninvoicedShippedOrderIDInShops(startDate, endDate, shops, warehouses);
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public List<PlatformOrder> fetchOrdersToArchiveBetweenDate(String startDate, String endDate) {
|
public List<PlatformOrder> fetchOrdersToArchiveBetweenDate(String startDate, String endDate) {
|
||||||
return platformOrderMap.fetchOrdersToArchiveBetweenDate(startDate, endDate);
|
return platformOrderMap.fetchOrdersToArchiveBetweenDate(startDate, endDate);
|
||||||
|
@ -600,4 +600,9 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
||||||
}
|
}
|
||||||
return platformOrderMap.countListByClientAndShops(clientId, shopIDs, erpStatuses, warehouses, start, end);
|
return platformOrderMap.countListByClientAndShops(clientId, shopIDs, erpStatuses, warehouses, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlatformOrder selectForUpdateSkipLock(String orderId) {
|
||||||
|
return platformOrderMap.selectForUpdateSkipLock(orderId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue