mirror of https://github.com/jeecgboot/jeecg-boot
fix: seperated mabang api call, result sent by websocket
parent
fab81cd905
commit
080cf38c08
|
@ -38,6 +38,7 @@ 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.service.ISysMessageService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
|
@ -46,6 +47,7 @@ import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -68,6 +70,7 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.jeecg.modules.business.entity.Invoice.InvoicingMethod.PRESHIPPING;
|
||||
import static org.jeecg.modules.business.vo.PlatformOrderOperation.Action.*;
|
||||
|
||||
/**
|
||||
|
@ -102,6 +105,8 @@ public class PlatformOrderController {
|
|||
private IShopService shopService;
|
||||
@Autowired
|
||||
private ISecurityService securityService;
|
||||
@Autowired
|
||||
private ISysMessageService sysMessageService;
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
@ -661,4 +666,18 @@ public class PlatformOrderController {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/editOrdersRemark")
|
||||
public Result<?> editOrdersRemark(@RequestBody InvoiceOrdersEditParam param) {
|
||||
String userId = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
|
||||
if(param.getInvoicingMethod() == PRESHIPPING) {
|
||||
ResponsesWithMsg<String> mabangResponses = platformOrderMabangService.editOrdersRemark(param.getInvoiceNumber());
|
||||
if(!mabangResponses.getFailures().isEmpty())
|
||||
sysMessageService.sendProgress(userId, HttpStatus.BAD_REQUEST.value(),mabangResponses.getFailures(), "websocket.mabang.editOrdersRemarkError", "editOrdersRemark");
|
||||
else sysMessageService.sendProgress(userId, HttpStatus.OK.value(), null,"websocket.mabang.editOrdersRemarkSuccess", "editOrdersRemark");
|
||||
return Result.OK(mabangResponses);
|
||||
}
|
||||
sysMessageService.pushProgress(userId, "Method not supported");
|
||||
return Result.error(HttpStatus.NOT_FOUND.value(), "Invoicing method not supported");
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ import org.jeecg.modules.business.mapper.PlatformOrderMapper;
|
|||
import org.jeecg.modules.business.mapper.PurchaseOrderContentMapper;
|
||||
import org.jeecg.modules.business.service.*;
|
||||
import org.jeecg.modules.business.vo.*;
|
||||
import org.jeecg.modules.message.websocket.WebSocketSender;
|
||||
import org.jeecg.modules.message.service.ISysMessageService;
|
||||
import org.jeecg.modules.quartz.entity.QuartzJob;
|
||||
import org.jeecg.modules.quartz.service.IQuartzJobService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -119,7 +119,7 @@ public class InvoiceController {
|
|||
@Autowired
|
||||
private ICreditService creditService;
|
||||
@Autowired
|
||||
private IPlatformOrderMabangService platformOrderMabangService;
|
||||
private ISysMessageService sysMessageService;
|
||||
@Autowired
|
||||
Environment env;
|
||||
|
||||
|
@ -251,20 +251,11 @@ public class InvoiceController {
|
|||
@PostMapping(value = "/makeComplete")
|
||||
public Result<?> makeCompleteShippingInvoice(@RequestBody ShippingInvoiceParam param) {
|
||||
try {
|
||||
JSONObject response = new JSONObject();
|
||||
|
||||
String method = param.getErpStatuses().toString().equals("[3]") ? POSTSHIPPING.getMethod() : param.getErpStatuses().toString().equals("[1, 2]") ? PRESHIPPING.getMethod() : ALL.getMethod();
|
||||
InvoiceMetaData metaData = shippingInvoiceService.makeCompleteInvoicePostShipping(param, method);
|
||||
balanceService.updateBalance(param.clientID(), metaData.getInvoiceCode(), COMPLETE.name());
|
||||
|
||||
if(method.equals(PRESHIPPING.getMethod())) {
|
||||
ResponsesWithMsg<String> mabangResponses = platformOrderMabangService.editOrdersRemark(metaData.getInvoiceCode());
|
||||
response.put("metaData", metaData);
|
||||
response.put("mabangResponses", mabangResponses);
|
||||
return Result.OK(response);
|
||||
}
|
||||
response.put("metaData", metaData);
|
||||
return Result.OK(response);
|
||||
return Result.OK(metaData);
|
||||
} catch (UserException e) {
|
||||
return Result.error(e.getMessage());
|
||||
} catch (IOException | ParseException e) {
|
||||
|
@ -335,7 +326,6 @@ public class InvoiceController {
|
|||
public Result<?> makeManualPurchaseInvoice(@RequestBody ShippingInvoiceOrderParam param) {
|
||||
InvoiceMetaData metaData;
|
||||
try {
|
||||
JSONObject response = new JSONObject();
|
||||
List<SkuQuantity> skuQuantities = skuService.getSkuQuantitiesFromOrderIds(param.orderIds());
|
||||
if(skuQuantities.isEmpty()) {
|
||||
return Result.error("Nothing to invoice.");
|
||||
|
@ -369,14 +359,7 @@ public class InvoiceController {
|
|||
emailService.sendSimpleMessage(destEmail, subject, htmlBody, session);
|
||||
log.info("Mail sent successfully");
|
||||
}
|
||||
if(param.getType().equals(PRESHIPPING.getMethod())) {
|
||||
ResponsesWithMsg<String> mabangResponses = platformOrderMabangService.editOrdersRemark(metaData.getInvoiceCode());
|
||||
response.put("metaData", metaData);
|
||||
response.put("mabangResponses", mabangResponses);
|
||||
return Result.OK(response);
|
||||
}
|
||||
response.put("metaData", metaData);
|
||||
return Result.OK(response);
|
||||
return Result.OK(metaData);
|
||||
} catch (UserException e) {
|
||||
return Result.error(e.getMessage());
|
||||
} catch (IOException e) {
|
||||
|
@ -399,7 +382,6 @@ public class InvoiceController {
|
|||
@PostMapping(value = "/makeManualComplete")
|
||||
public Result<?> makeManualCompleteInvoice(@RequestBody ShippingInvoiceOrderParam param) {
|
||||
try {
|
||||
JSONObject response = new JSONObject();
|
||||
InvoiceMetaData metaData = shippingInvoiceService.makeCompleteInvoice(param);
|
||||
String clientCategory = clientCategoryService.getClientCategoryByClientId(param.clientID());
|
||||
if(clientCategory.equals(ClientCategory.CategoryName.CONFIRMED.getName()) || clientCategory.equals(ClientCategory.CategoryName.VIP.getName())) {
|
||||
|
@ -426,14 +408,7 @@ public class InvoiceController {
|
|||
emailService.sendSimpleMessage(destEmail, subject, htmlBody, session);
|
||||
log.info("Mail sent successfully");
|
||||
}
|
||||
if(param.getType().equals(PRESHIPPING.getMethod())) {
|
||||
ResponsesWithMsg<String> mabangResponses = platformOrderMabangService.editOrdersRemark(metaData.getInvoiceCode());
|
||||
response.put("metaData", metaData);
|
||||
response.put("mabangResponses", mabangResponses);
|
||||
return Result.OK(response);
|
||||
}
|
||||
response.put("metaData", metaData);
|
||||
return Result.OK(response);
|
||||
return Result.OK(metaData);
|
||||
} catch (UserException e) {
|
||||
return Result.error(e.getMessage());
|
||||
} catch (IOException | ParseException e) {
|
||||
|
@ -599,9 +574,12 @@ public class InvoiceController {
|
|||
lambdaQueryWrapper.isNull(PlatformOrder::getShippingInvoiceNumber);
|
||||
lambdaQueryWrapper.inSql(PlatformOrder::getId, "SELECT id FROM platform_order po WHERE po.erp_status = '3' AND po.shipping_time between '" + param.getStart() + "' AND '" + param.getEnd() + "'" );
|
||||
// on récupère les résultats de la requete
|
||||
List<PlatformOrder> orderID = platformOrderMapper.selectList(lambdaQueryWrapper);
|
||||
List<PlatformOrder> platformOrderIds = platformOrderMapper.selectList(lambdaQueryWrapper);
|
||||
if(platformOrderIds == null || platformOrderIds.isEmpty()) {
|
||||
return Result.error(404, "No orders for selected client/shops");
|
||||
}
|
||||
// on récupère seulement les ID des commandes
|
||||
List<String> orderIds = orderID.stream().map(PlatformOrder::getId).collect(Collectors.toList());
|
||||
List<String> orderIds = platformOrderIds.stream().map(PlatformOrder::getId).collect(Collectors.toList());
|
||||
ShippingInvoiceOrderParam args = new ShippingInvoiceOrderParam(param.clientID(), orderIds, "postShipping");
|
||||
// on check s'il y a des SKU sans prix
|
||||
return checkSkuPrices(args);
|
||||
|
@ -804,7 +782,7 @@ public class InvoiceController {
|
|||
@RequestParam(value = "complete[]", required = false) List<String> completeClientIds) throws IOException {
|
||||
|
||||
String userId = ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId();
|
||||
pushProgress(userId, "开始执行开票任务,请稍候...");
|
||||
sysMessageService.pushProgress(userId, "开始执行开票任务,请稍候...");
|
||||
|
||||
List<InvoiceMetaData> metaDataErrorList = new ArrayList<>();
|
||||
TaskHistory ongoingBITask = taskHistoryService.getLatestRunningTask(SI_G.name());
|
||||
|
@ -817,19 +795,19 @@ public class InvoiceController {
|
|||
TaskHistory lastRunningTask = taskHistoryService.getLatestRunningTask(SI_G.name());
|
||||
|
||||
if(shippingClientIds != null) {
|
||||
pushProgress(userId, "正在处理 预发货 客户发票...");
|
||||
sysMessageService.pushProgress(userId, "正在处理 预发货 客户发票...");
|
||||
log.info("Making shipping invoice for clients : {}", shippingClientIds);
|
||||
invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(shippingClientIds, 0));
|
||||
}
|
||||
if(completeClientIds != null) {
|
||||
pushProgress(userId, "正在处理 已发货 客户发票...");
|
||||
sysMessageService.pushProgress(userId, "正在处理 已发货 客户发票...");
|
||||
log.info("Making complete shipping invoice for clients : {}", completeClientIds);
|
||||
invoiceList.addAll(shippingInvoiceService.breakdownInvoiceClientByType(completeClientIds, 1));
|
||||
}
|
||||
if (invoiceList.isEmpty()) {
|
||||
lastRunningTask.setOngoing(SUCCESS.getCode());
|
||||
taskHistoryService.updateById(lastRunningTask);
|
||||
pushProgress(userId, "没有生成任何发票。");
|
||||
sysMessageService.pushProgress(userId, "没有生成任何发票。");
|
||||
return Result.ok("Nothing invoiced");
|
||||
}
|
||||
List<String> filenameList = new ArrayList<>();
|
||||
|
@ -852,7 +830,7 @@ public class InvoiceController {
|
|||
}
|
||||
if (cpt % step == 0 || cpt == total) {
|
||||
int percent = (int)(((double) cpt / total) * 100);
|
||||
pushProgress(userId, "发票生成进度:" + percent + "% (" + cpt + "/" + total + ")");
|
||||
sysMessageService.pushProgress(userId, "发票生成进度:" + percent + "% (" + cpt + "/" + total + ")");
|
||||
}
|
||||
log.info("Generating detail files ...{}/{}", cpt++, invoiceList.size());
|
||||
}
|
||||
|
@ -877,7 +855,7 @@ public class InvoiceController {
|
|||
emailService.sendMessageWithAttachment(destEmail, subject, htmlBody, zipFilename,session);
|
||||
Map<String, Object> summary = new HashMap<>();
|
||||
summary.put("total", total);
|
||||
pushProgress(userId, "全部完成", summary);
|
||||
sysMessageService.pushProgress(userId, "全部完成", summary);
|
||||
log.info("Mail sent successfully");
|
||||
|
||||
lastRunningTask.setOngoing(SUCCESS.getCode());
|
||||
|
@ -888,22 +866,10 @@ public class InvoiceController {
|
|||
e.printStackTrace();
|
||||
lastRunningTask.setOngoing(CANCELLED.getCode());
|
||||
taskHistoryService.updateById(lastRunningTask);
|
||||
pushProgress(userId, "发票任务失败!");
|
||||
sysMessageService.pushProgress(userId, "发票任务失败!");
|
||||
return Result.error("An error occurred while trying to send an email.");
|
||||
}
|
||||
}
|
||||
private void pushProgress(String userId, String message) {
|
||||
pushProgress(userId, message, null);
|
||||
}
|
||||
private void pushProgress(String userId, String message, Map<String, Object> data) {
|
||||
JSONObject msg = new JSONObject();
|
||||
msg.put("cmd", "user");
|
||||
msg.put("msgTxt", message);
|
||||
if (data != null) {
|
||||
msg.put("data", data);
|
||||
}
|
||||
WebSocketSender.sendToUser(userId, msg.toJSONString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an estimate of shipping fees for selected orders
|
||||
|
|
|
@ -123,7 +123,10 @@ public class ShippingInvoiceFactory {
|
|||
public ShippingInvoice createShippingInvoice(String customerId, List<String> orderIds, String type, String start, String end) throws UserException {
|
||||
log.info("Creating an invoice with arguments:\n client ID: {}, order IDs: {}]", customerId, orderIds);
|
||||
// find orders and their contents of the invoice
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderDataForUpdate(orderIds);
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchUninvoicedOrderDataForUpdate(orderIds);
|
||||
if (uninvoicedOrderToContent == null || uninvoicedOrderToContent.isEmpty()) {
|
||||
throw new UserException("Orders not found or already invoiced");
|
||||
}
|
||||
Set<PlatformOrder> platformOrders = uninvoicedOrderToContent.keySet();
|
||||
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
|
||||
List<String> shopIds = platformOrders.stream()
|
||||
|
@ -169,7 +172,10 @@ public class ShippingInvoiceFactory {
|
|||
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);
|
||||
// find orders and their contents of the invoice
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchOrderDataForUpdate(orderIds);
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> uninvoicedOrderToContent = platformOrderService.fetchUninvoicedOrderDataForUpdate(orderIds);
|
||||
if (uninvoicedOrderToContent == null || uninvoicedOrderToContent.isEmpty()) {
|
||||
throw new UserException("Orders not found or already invoiced");
|
||||
}
|
||||
Set<PlatformOrder> platformOrders = uninvoicedOrderToContent.keySet();
|
||||
List<SavRefundWithDetail> savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId);
|
||||
List<String> shopIds = platformOrders.stream()
|
||||
|
|
|
@ -3,7 +3,9 @@ package org.jeecg.modules.business.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
@ -125,8 +127,10 @@ public class Invoice implements Serializable {
|
|||
POSTSHIPPING("post-shipping"),
|
||||
ALL("all");
|
||||
|
||||
@JsonValue
|
||||
private final String method;
|
||||
|
||||
@JsonCreator
|
||||
public static InvoicingMethod fromString(String method) {
|
||||
for(InvoicingMethod invoicingMethod : InvoicingMethod.values()) {
|
||||
if(invoicingMethod.method.equalsIgnoreCase(method)) {
|
||||
|
|
|
@ -46,9 +46,9 @@ public interface PlatformOrderContentMapper extends BaseMapper<PlatformOrderCont
|
|||
* @param orderIds Order IDs
|
||||
* @return order contents
|
||||
*/
|
||||
// TODO : check all usage and update if need to use FOR UPDATE instead
|
||||
List<PlatformOrderContent> fetchOrderContent(List<String> orderIds);
|
||||
List<PlatformOrderContent> fetchOrderContentForUpdate(List<String> orderIds);
|
||||
List<PlatformOrderContent> fetchUninvoicedOrderContentForUpdate(List<String> orderIds);
|
||||
|
||||
List<SkuDetail> searchSkuDetail(List<String> skuIDs);
|
||||
|
||||
|
|
|
@ -256,8 +256,9 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
|
|||
@Param("start") String startDate, @Param("end") String endDate,
|
||||
@Param("order") String order, @Param("column") String column,
|
||||
@Param("offset") Integer offset, @Param("size") Integer pageSize);
|
||||
void selectBatchIdsForUpdate(@Param("ids") List<String> orderIds);
|
||||
@MapKey("id")
|
||||
Map<String, PlatformOrder> selectBatchIdsForUpdate(@Param("ids") List<String> orderIds);
|
||||
Map<String, PlatformOrder> selectBatchUninvoicedIdsForUpdate(@Param("ids") List<String> orderIds);
|
||||
|
||||
PlatformOrder selectForUpdateSkipLock(@Param("id") String orderId);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,16 @@
|
|||
AND platform_order_id IN <foreach collection="list" index="i" item="item" open="(" separator="," close=")">#{item}</foreach>
|
||||
FOR UPDATE;
|
||||
</select>
|
||||
<select id="fetchUninvoicedOrderContentForUpdate" parameterType="java.lang.String"
|
||||
resultType="org.jeecg.modules.business.entity.PlatformOrderContent">
|
||||
SELECT *
|
||||
FROM platform_order_content poc
|
||||
JOIN platform_order po ON poc.platform_order_id = po.id
|
||||
WHERE poc.erp_status <> 5
|
||||
AND poc.platform_order_id IN <foreach collection="list" index="i" item="item" open="(" separator="," close=")">#{item}</foreach>
|
||||
AND po.shipping_invoice_number IS NULL
|
||||
FOR UPDATE;
|
||||
</select>
|
||||
|
||||
<select id="searchSkuDetail"
|
||||
resultType="org.jeecg.modules.business.vo.SkuDetail"
|
||||
|
|
|
@ -1391,6 +1391,15 @@
|
|||
</foreach>
|
||||
FOR UPDATE;
|
||||
</select>
|
||||
<select id="selectBatchUninvoicedIdsForUpdate" 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>
|
||||
AND shipping_invoice_number IS NULL
|
||||
FOR UPDATE;
|
||||
</select>
|
||||
<select id="selectForUpdateSkipLock" resultType="org.jeecg.modules.business.entity.PlatformOrder">
|
||||
SELECT * FROM platform_order
|
||||
WHERE id = #{id}
|
||||
|
|
|
@ -108,7 +108,9 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
|
|||
*/
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderData(List<String> orderIds);
|
||||
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataForUpdate(List<String> orderIds);
|
||||
void selectOrderDataForUpdate(List<String> orderIds);
|
||||
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> fetchUninvoicedOrderDataForUpdate(List<String> orderIds);
|
||||
|
||||
Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataByInvoiceCode(String invoiceCode);
|
||||
|
||||
|
|
|
@ -155,13 +155,13 @@ public class PlatformOrderMabangServiceImpl extends ServiceImpl<PlatformOrderMab
|
|||
try {
|
||||
if (!oldOrders.isEmpty()) {
|
||||
log.info("{} orders to be inserted/updated.", oldOrders.size());
|
||||
platformOrderService.fetchOrderDataForUpdate(oldOrders.stream().map(Order::getId).collect(toList()));
|
||||
platformOrderService.selectOrderDataForUpdate(oldOrders.stream().map(Order::getId).collect(toList()));
|
||||
platformOrderMabangMapper.batchUpdateById(oldOrders);
|
||||
platformOrderMabangMapper.batchDeleteByMainID(oldOrders.stream().map(Order::getId).collect(toList()));
|
||||
}
|
||||
if (!ordersFromShippedToCompleted.isEmpty()) {
|
||||
log.info("{} orders to be updated from Shipped to Completed.", ordersFromShippedToCompleted.size());
|
||||
platformOrderService.fetchOrderDataForUpdate(ordersFromShippedToCompleted.stream().map(Order::getId).collect(toList()));
|
||||
platformOrderService.selectOrderDataForUpdate(ordersFromShippedToCompleted.stream().map(Order::getId).collect(toList()));
|
||||
platformOrderMabangMapper.batchUpdateById(ordersFromShippedToCompleted);
|
||||
log.info("Contents of {} orders to be updated from Shipped to Completed.", ordersFromShippedToCompleted.size());
|
||||
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
||||
|
@ -170,7 +170,7 @@ public class PlatformOrderMabangServiceImpl extends ServiceImpl<PlatformOrderMab
|
|||
}
|
||||
if (!invoicedShippedOrders.isEmpty()) {
|
||||
log.info("{} orders to be updated from Pending/Preparing to Shipped.", invoicedShippedOrders.size());
|
||||
platformOrderService.fetchOrderDataForUpdate(invoicedShippedOrders.stream().map(Order::getId).collect(toList()));
|
||||
platformOrderService.selectOrderDataForUpdate(invoicedShippedOrders.stream().map(Order::getId).collect(toList()));
|
||||
platformOrderMabangMapper.batchUpdateById(invoicedShippedOrders);
|
||||
log.info("Contents of {} orders to be updated from Pending/Preparing to Shipped.", invoicedShippedOrders.size());
|
||||
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
||||
|
@ -179,7 +179,7 @@ public class PlatformOrderMabangServiceImpl extends ServiceImpl<PlatformOrderMab
|
|||
}
|
||||
if (!obsoleteOrders.isEmpty()) {
|
||||
log.info("{} orders to become obsolete.", obsoleteOrders.size());
|
||||
platformOrderService.fetchOrderDataForUpdate(obsoleteOrders.stream().map(Order::getId).collect(toList()));
|
||||
platformOrderService.selectOrderDataForUpdate(obsoleteOrders.stream().map(Order::getId).collect(toList()));
|
||||
platformOrderMabangMapper.batchUpdateById(obsoleteOrders);
|
||||
log.info("Contents of {} orders to be updated to Obsolete.", obsoleteOrders.size());
|
||||
platformOrderMabangMapper.batchUpdateErpStatusByMainId(
|
||||
|
@ -396,6 +396,11 @@ public class PlatformOrderMabangServiceImpl extends ServiceImpl<PlatformOrderMab
|
|||
public ResponsesWithMsg<String> editOrdersRemark(String invoiceNumber) {
|
||||
ResponsesWithMsg<String> responses = new ResponsesWithMsg<>();
|
||||
List<String> platformOrderIds = platformOrderService.getPlatformOrderIdsByInvoiceNumber(invoiceNumber);
|
||||
if(platformOrderIds.isEmpty()) {
|
||||
log.info("No orders found with invoice number {}", invoiceNumber);
|
||||
responses.addFailure(invoiceNumber, "No orders found with invoice number");
|
||||
return responses;
|
||||
}
|
||||
log.info("Editing orders remark with invoice number {} for platform order ids {}", invoiceNumber, platformOrderIds);
|
||||
ExecutorService executor = ThrottlingExecutorService.createExecutorService(DEFAULT_NUMBER_OF_THREADS,
|
||||
MABANG_API_RATE_LIMIT_PER_MINUTE, TimeUnit.MINUTES);
|
||||
|
|
|
@ -313,9 +313,14 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
|
|||
return orderContents.stream().collect(groupingBy(platformOrderContent -> orderMap.get(platformOrderContent.getPlatformOrderId())));
|
||||
}
|
||||
@Override
|
||||
public Map<PlatformOrder, List<PlatformOrderContent>> fetchOrderDataForUpdate(List<String> orderIds) {
|
||||
Map<String, PlatformOrder> ordersMapById = platformOrderMap.selectBatchIdsForUpdate(orderIds);
|
||||
List<PlatformOrderContent> orderContents = platformOrderContentMap.fetchOrderContentForUpdate(orderIds);
|
||||
public void selectOrderDataForUpdate(List<String> orderIds) {
|
||||
platformOrderMap.selectBatchIdsForUpdate(orderIds);
|
||||
platformOrderContentMap.fetchOrderContentForUpdate(orderIds);
|
||||
}
|
||||
@Override
|
||||
public Map<PlatformOrder, List<PlatformOrderContent>> fetchUninvoicedOrderDataForUpdate(List<String> orderIds) {
|
||||
Map<String, PlatformOrder> ordersMapById = platformOrderMap.selectBatchUninvoicedIdsForUpdate(orderIds);
|
||||
List<PlatformOrderContent> orderContents = platformOrderContentMap.fetchUninvoicedOrderContentForUpdate(orderIds);
|
||||
return orderContents.stream().collect(groupingBy(platformOrderContent -> ordersMapById.get(platformOrderContent.getPlatformOrderId())));
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package org.jeecg.modules.business.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.business.entity.Invoice;
|
||||
|
||||
@Data
|
||||
public class InvoiceOrdersEditParam {
|
||||
private final String invoiceNumber;
|
||||
private final Invoice.InvoicingMethod invoicingMethod;
|
||||
|
||||
public InvoiceOrdersEditParam(@JsonProperty("invoiceNumber") String invoiceNumber,
|
||||
@JsonProperty("invoicingMethod") Invoice.InvoicingMethod invoicingMethod) {
|
||||
this.invoiceNumber = invoiceNumber;
|
||||
this.invoicingMethod = invoicingMethod;
|
||||
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ package org.jeecg.modules.message.service;
|
|||
import org.jeecg.common.system.base.service.JeecgService;
|
||||
import org.jeecg.modules.message.entity.SysMessage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: jeecg-boot
|
||||
|
@ -11,4 +13,9 @@ import org.jeecg.modules.message.entity.SysMessage;
|
|||
*/
|
||||
public interface ISysMessageService extends JeecgService<SysMessage> {
|
||||
|
||||
void pushProgress(String userId, String message);
|
||||
|
||||
void pushProgress(String userId, String message, Map<String, Object> data);
|
||||
|
||||
<T> void sendProgress(String userId, int code, T data, String message, String task);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package org.jeecg.modules.message.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.system.base.service.impl.JeecgServiceImpl;
|
||||
import org.jeecg.modules.message.entity.SysMessage;
|
||||
import org.jeecg.modules.message.mapper.SysMessageMapper;
|
||||
import org.jeecg.modules.message.service.ISysMessageService;
|
||||
import org.jeecg.modules.message.websocket.WebSocketSender;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 消息
|
||||
* @Author: jeecg-boot
|
||||
|
@ -14,5 +18,29 @@ import org.springframework.stereotype.Service;
|
|||
*/
|
||||
@Service
|
||||
public class SysMessageServiceImpl extends JeecgServiceImpl<SysMessageMapper, SysMessage> implements ISysMessageService {
|
||||
|
||||
@Override
|
||||
public void pushProgress(String userId, String message) {
|
||||
pushProgress(userId, message, null);
|
||||
}
|
||||
@Override
|
||||
public void pushProgress(String userId, String message, Map<String, Object> data) {
|
||||
JSONObject msg = new JSONObject();
|
||||
msg.put("cmd", "user");
|
||||
msg.put("msgTxt", message);
|
||||
if (data != null) {
|
||||
msg.put("data", data);
|
||||
}
|
||||
WebSocketSender.sendToUser(userId, msg.toJSONString());
|
||||
}
|
||||
@Override
|
||||
public <T> void sendProgress(String userId, int code, T data, String message, String task) {
|
||||
JSONObject msg = new JSONObject();
|
||||
msg.put("task", task);
|
||||
msg.put("code", code);
|
||||
msg.put("msgTxt", message);
|
||||
if(data != null) {
|
||||
msg.put("data", data);
|
||||
}
|
||||
WebSocketSender.sendToUser(userId, msg.toJSONString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue